Boolean (ClassFileRepr repr, File depFile) { final boolean isGenerated; if (repr instanceof ClassRepr) { final ClassRepr clsRepr = (ClassRepr)repr; if (!clsRepr.hasInlinedConstants() && myCompiledFiles.contains(depFile)) { // Classes containing inlined constants from other classes and compiled against older constant values // may need to be recompiled several times within compile session. // Otherwise, it is safe to skip the file if it has already been compiled in this session. return true; } // If among affected files are annotation processor-generated, then we might need to re-generate them. // To achieve this, we need to recompile the whole chunk which will cause processors to re-generate these affected files isGenerated = clsRepr.isGenerated(); } else { isGenerated = false; } if (myAffectedFiles.contains(depFile)) { return !isGenerated; } Pair<Boolean, Boolean> shouldAffect = isAffected.computeIfAbsent(repr, r -> { debug("Dependent class: ", r.name); final Set<UsageRepr.Usage> depUsages = r.getUsages(); if (depUsages == null || depUsages.isEmpty()) { return Pair.create(false, !isGenerated); } for (UsageRepr.Usage usage : depUsages) { if (usage instanceof UsageRepr.AnnotationUsage) { final UsageRepr.AnnotationUsage annotationUsage = (UsageRepr.AnnotationUsage)usage; for (final UsageRepr.AnnotationUsage query : state.myAnnotationQuery) { if (query.satisfies(annotationUsage)) { debug("Added file due to annotation query"); return Pair.create(true, !isGenerated); } } } else if (state.myAffectedUsages.contains(usage)) { final UsageConstraint constraint = state.myUsageConstraints.get(usage); if (constraint == null) { debug("Added file with no constraints"); return Pair.create(true, !isGenerated); } if (constraint.checkResidence(r.name)) { debug("Added file with satisfied constraint"); return Pair.create(true, !isGenerated); } } } return Pair.create(false, true); }); if (shouldAffect.getFirst()) { myAffectedFiles.add(depFile); } return shouldAffect.getSecond(); }