Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
1,000
void (CompileContext context) { ALL_AFFECTED_FILES_KEY.set(context, null); ALL_COMPILED_FILES_KEY.set(context, null); }
cleanupChunkResources
1,001
boolean (File file) { final JavaSourceRootDescriptor rd = myBuildRootIndex.findJavaRootDescriptor(myContext, file); if (rd == null) { return true; } final BuildTarget<?> targetOfFile = rd.target; if (myChunkTargets.contains(targetOfFile)) { return true; } Set<BuildTarget<?>> targetOfFileWithDependencies = myCache.get(targetOfFile); if (targetOfFileWithDependencies == null) { targetOfFileWithDependencies = Iterators.collect(Iterators.recurseDepth(targetOfFile, new Iterators.Function<BuildTarget<?>, Iterable<? extends BuildTarget<?>>>() { @Override public Iterable<? extends BuildTarget<?>> fun(BuildTarget<?> t) { return myBuildTargetIndex.getDependencies(t, myContext); } }, false), new LinkedHashSet<>()); myCache.put(targetOfFile, targetOfFileWithDependencies); } return ContainerUtil.intersects(targetOfFileWithDependencies, myChunkTargets); }
accept
1,002
boolean (File file) { final JavaSourceRootDescriptor rd = myBuildRootIndex.findJavaRootDescriptor(myContext, file); return rd != null && myChunkTargets.contains(rd.target); }
belongsToCurrentTargetChunk
1,003
boolean (Collection<? extends File> files) { for (File file : files) { if (belongsToCurrentTargetChunk(file)) { return true; } } return false; }
containsFilesFromCurrentTargetChunk
1,004
boolean (File pathname) { return !myFilter.accept(pathname); }
accept
1,005
boolean (File file) { return !isJavadocExtSnippet(file); }
accept
1,006
boolean (File file) { String filePath = FileUtilRt.toSystemIndependentName(file.getPath()); int patternIndex = FIND_SNIPPETS_FOLDER_PATTERN.apply(filePath, 0); if (patternIndex < 0) { return false; } // ensure the file is under the root String rootPath = FileUtilRt.toSystemIndependentName(myRoot.getPath()); if (!FileUtil.startsWith(filePath, rootPath, SystemInfoRt.isFileSystemCaseSensitive, true)) { return false; } int fromIndex = rootPath.endsWith("/")? rootPath.length() - 1 : rootPath.length(); return patternIndex >= fromIndex || FIND_SNIPPETS_FOLDER_PATTERN.apply(filePath, fromIndex) >= 0; }
isJavadocExtSnippet
1,007
boolean (@NotNull File file) { return JavaBuilder.JAVA_SOURCES_FILTER.accept(file); }
shouldHonorFileEncodingForCompilation
1,008
FileFilter () { FileFilter baseFilter = super.createFileFilter(); final JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getCompilerConfiguration(getTarget().getModule().getProject()); final JavadocSnippetsSkipFilter snippetsSkipFilter = new JavadocSnippetsSkipFilter(getRootFile()); return file -> baseFilter.accept(file) && configuration.isResourceFile(file, getRootFile()) && snippetsSkipFilter.accept(file); }
createFileFilter
1,009
String () { return "RootDescriptor{" + "target='" + target + '\'' + ", root=" + root + ", generated=" + isGeneratedSources + '}'; }
toString
1,010
Set<File> () { return myExcludes; }
getExcludedRoots
1,011
String () { return myPackagePrefix; }
getPackagePrefix
1,012
String () { return FileUtil.toSystemIndependentName(root.getPath()); }
getRootId
1,013
File () { return root; }
getRootFile
1,014
ModuleBuildTarget () { return target; }
getTarget
1,015
FileFilter () { final JpsCompilerExcludes excludes = JpsJavaExtensionService.getInstance().getCompilerConfiguration(target.getModule().getProject()).getCompilerExcludes(); final FileFilter baseFilter = BuilderRegistry.getInstance().getModuleBuilderFileFilter(); final JavadocSnippetsSkipFilter snippetsSkipFilter = new JavadocSnippetsSkipFilter(getRootFile()); return file -> baseFilter.accept(file) && !excludes.isExcluded(file) && snippetsSkipFilter.accept(file) && myFilterForExcludedPatterns.accept(file); }
createFileFilter
1,016
boolean () { return isGeneratedSources; }
isGenerated
1,017
boolean () { return true; }
canUseFileCache
1,018
List<ModuleBuildTarget> (@NotNull JpsModel model) { List<JpsModule> modules = model.getProject().getModules(); List<ModuleBuildTarget> targets = new ArrayList<>(modules.size()); for (JpsModule module : modules) { targets.add(new ModuleBuildTarget(module, this)); } return targets; }
computeAllTargets
1,019
Loader (@NotNull JpsModel model) { return new Loader(model); }
createLoader
1,020
boolean () { return myTests; }
isTests
1,021
JavaModuleBuildTargetType (boolean tests) { return tests ? TEST : PRODUCTION; }
getInstance
1,022
boolean (@NotNull File file) { return false; }
shouldHonorFileEncodingForCompilation
1,023
File () { return myRoot; }
getRootFile
1,024
Set<File> () { return myExcludes; }
getExcludedRoots
1,025
ResourcesTarget () { return myTarget; }
getTarget
1,026
String () { return myPackagePrefix; }
getPackagePrefix
1,027
FileFilter () { final JpsProject project = getTarget().getModule().getProject(); final JpsCompilerExcludes excludes = JpsJavaExtensionService.getInstance().getCompilerConfiguration(project).getCompilerExcludes(); return file -> !excludes.isExcluded(file) && myFilterForExcludedPatterns.accept(file); }
createFileFilter
1,028
String () { return "ResourceRootDescriptor{target='" + myTarget + '\'' + ", root=" + myRoot + '}'; }
toString
1,029
boolean () { return true; }
canUseFileCache
1,030
String () { return FileUtil.toSystemIndependentName(myRoot.getPath()); }
getRootId
1,031
boolean (final int key) { try { return map.containsMapping(key); } catch (IOException e) { throw new BuildDataCorruptedException(e); } }
containsKey
1,032
Collection<V> (final int key) { final Collection<V> collection = cache.get(key); return collection == NULL_COLLECTION ? null : collection; }
get
1,033
void (int key, Collection<V> value) { try { cache.invalidate(key); if (value == null || value.isEmpty()) { map.remove(key); } else { map.put(key, value); } } catch (IOException e) { throw new BuildDataCorruptedException(e); } }
replace
1,034
void (final int key, final Collection<V> value) { try { cache.invalidate(key); map.appendData(key, new AppendablePersistentMap.ValueDataAppender() { @Override public void append(@NotNull DataOutput out) throws IOException { for (V v : value) { valueExternalizer.save(out, v); } } }); } catch (IOException e) { throw new BuildDataCorruptedException(e); } }
put
1,035
void (final int key, final V value) { put(key, Collections.singleton(value)); }
put
1,036
void (int key, Collection<V> values) { try { if (!values.isEmpty()) { final Collection<V> collection = cache.get(key); if (collection != NULL_COLLECTION) { if (collection.removeAll(values)) { cache.invalidate(key); if (collection.isEmpty()) { map.remove(key); } else { map.put(key, collection); } } } } } catch (IOException e) { throw new BuildDataCorruptedException(e); } }
removeAll
1,037
void (final int key, final V value) { try { final Collection<V> collection = cache.get(key); if (collection != NULL_COLLECTION) { if (collection.remove(value)) { cache.invalidate(key); if (collection.isEmpty()) { map.remove(key); } else { map.put(key, collection); } } } } catch (IOException e) { throw new BuildDataCorruptedException(e); } }
removeFrom
1,038
void (final int key) { try { cache.invalidate(key); map.remove(key); } catch (IOException e) { throw new BuildDataCorruptedException(e); } }
remove
1,039
void (IntObjectMultiMaplet<V> m) { m.forEachEntry((vs, value) -> put(value, vs)); }
putAll
1,040
void (IntObjectMultiMaplet<V> m) { m.forEachEntry((vs, value) -> replace(value, vs)); }
replaceAll
1,041
void () { try { cache.invalidateAll(); map.close(); } catch (IOException e) { throw new BuildDataCorruptedException(e); } }
close
1,042
void (boolean memoryCachesOnly) { if (memoryCachesOnly) { if (map.isDirty()) { map.dropMemoryCaches(); } } else { map.force(); } }
flush
1,043
File (final File rootDir, final String name) { final File file = new File(FileUtil.toSystemIndependentName(rootDir.getAbsoluteFile() + File.separator + name)); FileUtil.createIfDoesntExist(file); return file; }
getTableFile
1,044
int (final String s) { try { return StringUtil.isEmpty(s) ? myEmptyName : myEnumerator.enumerate(myRelativizer.toRelative(s)); } catch (IOException e) { throw new BuildDataCorruptedException(e); } }
get
1,045
void () { try { myEnumerator.close(); } catch (IOException e) { throw new BuildDataCorruptedException(e); } }
close
1,046
void () { myEnumerator.force(); }
flush
1,047
LoggerWrapper<Integer> (final Logger log) { return new LoggerWrapper<>() { @Override public boolean isDebugEnabled() { return log.isDebugEnabled(); } @Override public void debug(String comment, Integer s) { if (isDebugEnabled()) { log.debug(comment + getValue(s)); } } @Override public void debug(String comment, String t) { if (isDebugEnabled()) { log.debug(comment + t); } } @Override public void debug(String comment, boolean t) { if (isDebugEnabled()) { log.debug(comment + t); } } }; }
getLogger
1,048
boolean () { return log.isDebugEnabled(); }
isDebugEnabled
1,049
void (String comment, Integer s) { if (isDebugEnabled()) { log.debug(comment + getValue(s)); } }
debug
1,050
void (String comment, String t) { if (isDebugEnabled()) { log.debug(comment + t); } }
debug
1,051
void (String comment, boolean t) { if (isDebugEnabled()) { log.debug(comment + t); } }
debug
1,052
PathRelativizerService () { return myRelativizer; }
getRelativizer
1,053
String (String path) { // on case-insensitive file systems save paths in normalized (lowercase) format in order to make tests run deterministically return SystemInfo.isFileSystemCaseSensitive ? path : path.toLowerCase(Locale.US); }
debugString
1,054
void (boolean processInc) { myProcessConstantsIncrementally = processInc; }
setProcessConstantsIncrementally
1,055
String (final int name) { return myContext.getValue(name); }
valueOf
1,056
int (final String string) { return myContext.get(string); }
getName
1,057
Mappings () { synchronized (myLock) { try { return new Mappings(this); } catch (IOException e) { throw new BuildDataCorruptedException(e); } } }
createDelta
1,058
void (final @NotNull Collection<? extends File> compiled, final @NotNull Collection<? extends File> compiledWithErrors) { for (final File file : compiled) { if (!compiledWithErrors.contains(file)) { String relative = toRelative(file); if (!myRelativeSourceFilePathToClasses.containsKey(relative)) { myRelativeSourceFilePathToClasses.put(relative, new HashSet<>()); } } } }
compensateRemovedContent
1,059
Collection<ClassFileRepr> (File unchangedSource) { return myRelativeSourceFilePathToClasses.get(toRelative(unchangedSource)); }
sourceFileToClassesGet
1,060
String (File file) { return myRelativizer.toRelative(file.getAbsolutePath()); }
toRelative
1,061
File (String relativePath) { return new File(myRelativizer.toFull(relativePath)); }
toFull
1,062
IntIntTransientMultiMaplet () { return myRemovedSuperClasses; }
getRemovedSuperClasses
1,063
IntIntTransientMultiMaplet () { return myAddedSuperClasses; }
getAddedSuperClasses
1,064
void () { final Set<Pair<ClassFileRepr, File>> deleted = myDeletedClasses; if (deleted != null) { for (Pair<ClassFileRepr, File> pair : deleted) { final int deletedClassName = pair.first.name; final Iterable<File> sources = classToSourceFileGet(deletedClassName); if (sources == null || Iterators.isEmpty(sources)) { // if really deleted and not e.g. moved myChangedClasses.remove(deletedClassName); } } } for (Runnable pass = myPostPasses.poll(); pass != null; pass = myPostPasses.poll()) { pass.run(); } }
runPostPasses
1,065
IntSet (final IntSet acc, final boolean isField, final boolean root, final Predicate<? super ProtoMember> isSame, final int reflcass) { if (acc.contains(reflcass)) { return acc; // SOE prevention } final Iterable<ClassRepr> reprs = reprsByName(reflcass, ClassRepr.class); if (!Iterators.isEmpty(reprs)) { if (!root) { Iterable<ClassRepr> reprsWithoutMatchingMember = Iterators.filter(reprs, repr -> { for (ProtoMember m : isField? repr.getFields() : repr.getMethods()) { if (isSame.test(m)) { return false; } } return true; }); if (Iterators.isEmpty(reprsWithoutMatchingMember)) { return acc; } // should continue, if at least one repr does not have matching member defined acc.add(reflcass); } final IntSet subclasses = myClassToSubclasses.get(reflcass); if (subclasses != null) { final IntIterator subclassIterator = subclasses.iterator(); while (subclassIterator.hasNext()) { propagateMemberAccessRec(acc, isField, false, isSame, subclassIterator.nextInt()); } } } return acc; }
propagateMemberAccessRec
1,066
void (MethodRepr m, ClassRepr methodClass, final ClassRepr fromClass, final Predicate<? super MethodRepr> predicate, final Collection<? super Pair<MethodRepr, ClassRepr>> container, IntSet visitedClasses) { if (m.name == myInitName) { return; // overriding is not defined for constructors } final IntSet subClasses = myClassToSubclasses.get(fromClass.name); if (subClasses == null) { return; } if (visitedClasses == null) { visitedClasses = new IntOpenHashSet(); } if (!visitedClasses.add(fromClass.name)) { return; } final IntSet _visitedClasses = visitedClasses; subClasses.forEach(subClassName -> { Iterable<ClassRepr> reprs = Iterators.collect(reprsByName(subClassName, ClassRepr.class), new SmartList<>()); if (!Iterators.isEmpty(reprs)) { Iterable<Pair<MethodRepr, ClassRepr>> overriding = Iterators.flat(Iterators.map( reprs, r -> isVisibleIn(methodClass, m, r)? Iterators.map(r.findMethods(predicate), mm -> Pair.create(mm, r)) : Collections.emptyList()) ); Set<ClassRepr> found = new SmartHashSet<>(); for (Pair<MethodRepr, ClassRepr> pair : overriding) { container.add(pair); found.add(pair.getSecond()); } for (ClassRepr r : Iterators.filter(reprs, r -> !found.contains(r))) { // continue with reprs, for those no overriding members were found addOverridingMethods(m, methodClass, r, predicate, container, _visitedClasses); } } }); }
addOverridingMethods
1,067
boolean (final ClassRepr fromClass, final Predicate<? super MethodRepr> predicate, IntSet visitedClasses, ClassRepr visibilityScope) { if (visitedClasses == null) { visitedClasses = new IntOpenHashSet(); visitedClasses.add(fromClass.name); } for (TypeRepr.ClassType superName : fromClass.getSuperTypes()) { if (!visitedClasses.add(superName.className) || superName.className == myObjectClassName) { continue; } for (ClassRepr superClass : reprsByName(superName.className, ClassRepr.class)) { for (MethodRepr mm : superClass.findMethods(predicate)) { if (isVisibleIn(superClass, mm, visibilityScope)) { return true; } } if (hasOverriddenMethods(superClass, predicate, visitedClasses, visibilityScope)) { return true; } } } return false; }
hasOverriddenMethods
1,068
boolean (final ClassRepr fromClass, IntSet visitedClasses) { if (visitedClasses == null) { visitedClasses = new IntOpenHashSet(); visitedClasses.add(fromClass.name); } for (TypeRepr.ClassType superName : fromClass.getSuperTypes()) { if (!visitedClasses.add(superName.className) || superName.className == myObjectClassName) { continue; } Iterator<ClassRepr> superClasses = reprsByName(superName.className, ClassRepr.class).iterator(); if (!superClasses.hasNext()) { return true; } while (superClasses.hasNext()) { if (extendsLibraryClass(superClasses.next(), visitedClasses)) { return true; } } } return false; }
extendsLibraryClass
1,069
void (final ClassRepr fromClass, final Predicate<? super MethodRepr> predicate, final Collection<? super Pair<MethodRepr, ClassRepr>> container, IntSet visitedClasses, final ClassRepr visibilityScope) { if (visitedClasses == null) { visitedClasses = new IntOpenHashSet(); visitedClasses.add(fromClass.name); } for (TypeRepr.ClassType superName : fromClass.getSuperTypes()) { if (!visitedClasses.add(superName.className) || superName.className == myObjectClassName) { continue; // prevent SOE } Iterable<ClassRepr> superClasses = Iterators.collect(reprsByName(superName.className, ClassRepr.class), new SmartList<>()); if (!Iterators.isEmpty(superClasses)) { Iterable<Pair<MethodRepr, ClassRepr>> pairs = Iterators.flat( Iterators.map(superClasses, superClass -> Iterators.map(superClass.findMethods(mm -> predicate.test(mm) && isVisibleIn(superClass, mm, visibilityScope)), mm -> Pair.create(mm, superClass))) ); Set<ClassRepr> found = new SmartHashSet<>(); for (Pair<MethodRepr, ClassRepr> pair : pairs) { container.add(pair); found.add(pair.getSecond()); } for (ClassRepr superClass : Iterators.filter(superClasses, superClass -> !found.contains(superClass))) { // continue with those, for whom the matching method was not found addOverriddenMethods(superClass, predicate, container, visitedClasses, visibilityScope); } } else { container.add(Pair.create(MOCK_METHOD, MOCK_CLASS)); } } }
addOverriddenMethods
1,070
Iterable<MethodRepr> (ClassRepr cls) { return Iterators.flat(collectRecursively(cls, c-> c.getMethods())); }
allMethodsRecursively
1,071
Iterable<OverloadDescriptor> (final ClassRepr cls, Function<? super MethodRepr, Integer> correspondenceFinder) { Function<ClassRepr, Iterable<OverloadDescriptor>> converter = c -> Iterators.filter(Iterators.map(c.getMethods(), m -> { Integer accessScope = correspondenceFinder.apply(m); return accessScope != null? new OverloadDescriptor(accessScope, m, c) : null; }), Iterators.notNullFilter()); return Iterators.flat(Iterators.flat( collectRecursively(cls, converter), Iterators.map( Iterators.flat(Iterators.map(getAllSubclasses(cls.name), subName -> subName != cls.name? reprsByName(subName, ClassRepr.class) : Collections.emptyList())), repr -> converter.apply(repr) ) )); }
findAllOverloads
1,072
boolean (int residence) { final Iterable<File> fNames = classToSourceFileGet(residence); if (fNames == null || Iterators.isEmpty(fNames)) { return true; } for (File fName : fNames) { if (myFilter.accept(fName)) { return true; } } return false; }
checkResidence
1,073
boolean (final int residence) { final String className = myContext.getValue(residence); return className == null || !ClassRepr.getPackageName(className).equals(packageName); }
checkResidence
1,074
boolean (final int residence) { final Boolean inheritorOf = isInheritorOf(residence, rootClass, null); return (inheritorOf == null || !inheritorOf) && super.checkResidence(residence); }
checkResidence
1,075
boolean (final ClassRepr c, final ProtoMember m, final ClassRepr scope) { final boolean privacy = m.isPrivate() && c.name != scope.name; final boolean packageLocality = m.isPackageLocal() && !Objects.equals(c.getPackageName(), scope.getPackageName()); return !privacy && !packageLocality; }
isVisibleIn
1,076
boolean (final int s) { return s == myEmptyName; }
isEmpty
1,077
IntSet (final int root) { return addAllSubclasses(root, new IntOpenHashSet(DEFAULT_SET_CAPACITY, DEFAULT_SET_LOAD_FACTOR)); }
getAllSubclasses
1,078
IntSet (final int root, final IntSet acc) { if (acc.add(root)) { final IntSet directSubclasses = myClassToSubclasses.get(root); if (directSubclasses != null) { directSubclasses.forEach(s -> { addAllSubclasses(s, acc); }); } } return acc; }
addAllSubclasses
1,079
boolean (final int owner, final Proto member, final Collection<? super File> affectedFiles, final Collection<? extends File> currentlyCompiled, final @Nullable DependentFilesFilter filter) { final Util self = new Util(); final int classname = member instanceof ClassRepr? member.name : owner; // Public branch --- hopeless if (member.isPublic()) { debug("Public access, switching to a non-incremental mode"); return false; } final Set<File> toRecompile = FileCollectionFactory.createCanonicalFileSet(); // Protected branch if (member.isProtected()) { debug("Protected access, softening non-incremental decision: adding all relevant subclasses for a recompilation"); debug("Root class: ", classname); final IntSet propagated; if (member instanceof FieldRepr) { propagated = self.propagateFieldAccess(member.name, classname); } else { propagated = getAllSubclasses(classname); propagated.remove(classname); } propagated.forEach(className -> { final Iterable<File> fileNames = classToSourceFileGet(className); if (fileNames != null) { if (myDebugS.isDebugEnabled()) { for (File fileName : fileNames) { debug("Adding ", fileName); } } ContainerUtil.addAll(toRecompile, fileNames); } }); } final String cName = myContext.getValue(classname); if (cName != null) { final String packageName = ClassRepr.getPackageName(cName); debug("Softening non-incremental decision: adding all package classes for a recompilation"); debug("Package name: ", packageName); // Package-local branch myClassToRelativeSourceFilePath.forEachEntry((relFilePaths, value) -> { final String clsName = myContext.getValue(value); if (clsName != null && ClassRepr.getPackageName(clsName).equals(packageName)) { for (String rel : relFilePaths) { File file = toFull(rel); if (filter == null || filter.accept(file)) { debug("Adding: ", rel); toRecompile.add(file); } } } }); } // filtering already compiled and non-existing paths toRecompile.removeAll(currentlyCompiled); for (Iterator<File> it = toRecompile.iterator(); it.hasNext(); ) { final File file = it.next(); if (!file.exists()) { it.remove(); } } affectedFiles.addAll(toRecompile); return true; }
incrementalDecision
1,080
void () { if (myFilesToCompile != null) { myDelta.compensateRemovedContent( myFilesToCompile, myCompiledWithErrors != null ? myCompiledWithErrors : Collections.emptySet() ); } if (!myEasyMode) { final Collection<String> removed = myDelta.myRemovedFiles; if (removed != null) { for (final String file : removed) { final File sourceFile = new File(file); final Collection<ClassFileRepr> classes = sourceFileToClassesGet(sourceFile); if (classes != null) { for (ClassFileRepr c : classes) { debug("Affecting usages of removed class ", c.name); affectAll(c.name, sourceFile, myAffectedFiles, myCompiledFiles, myFilter); } } } } } }
processDisappearedClasses
1,081
void (final DiffState state, final ClassRepr.Diff diff, final ClassRepr it) { final Collection<MethodRepr> added = diff.methods().added(); if (added.isEmpty()) { return; } debug("Processing added methods: "); if (it.isAnnotation()) { debug("Class is annotation, skipping method analysis"); return; } assert myFuture != null; assert myPresent != null; assert myAffectedFiles != null; for (final MethodRepr m : added) { if (!m.isPrivate() && (it.isInterface() || it.isAbstract() || m.isAbstract())) { debug("Method: ", m.name); debug("Class is abstract, or is interface, or added non-private method is abstract => affecting all subclasses"); myFuture.affectSubclasses(it.name, myAffectedFiles, state.myAffectedUsages, state.myDependants, false, myCompiledFiles, null); break; } } if (it.isInterface()) { for (final MethodRepr m : added) { if (!m.isPrivate() && m.isAbstract()) { debug("Added non-private abstract method: ", m.name); myPresent.affectLambdaInstantiations(state, it.name); break; } } } for (final MethodRepr addedMethod : added) { debug("Method: ", addedMethod.name); final Supplier<IntSet> propagated = lazy(()-> myFuture.propagateMethodAccess(addedMethod, it.name)); if (!addedMethod.isPrivate() && addedMethod.myArgumentTypes.length > 0 && !myPresent.hasOverriddenMethods(it, MethodRepr.equalByJavaRules(addedMethod), null, it)) { debug("Conservative case on overriding methods, affecting method usages"); // do not propagate constructors access, since constructors are always concrete and not accessible via references to subclasses myFuture.affectMethodUsages(addedMethod, addedMethod.name == myInitName? null : propagated.get(), addedMethod.createMetaUsage(myContext, it.name), state.myAffectedUsages, state.myDependants); } if (!addedMethod.isPrivate()) { if (addedMethod.isStatic()) { myFuture.affectStaticMemberOnDemandUsages(it.name, propagated.get(), state.myAffectedUsages, state.myDependants); } Predicate<MethodRepr> lessSpecificCond = myFuture.lessSpecific(addedMethod); final Collection<MethodRepr> removed = diff.methods().removed(); for (final MethodRepr lessSpecific : it.findMethods(lessSpecificCond)) { if (!lessSpecific.equals(addedMethod) && !removed.contains(lessSpecific)) { debug("Found less specific method, affecting method usages"); myFuture.affectMethodUsages(lessSpecific, propagated.get(), lessSpecific.createUsage(myContext, it.name), state.myAffectedUsages, state.myDependants); } } debug("Processing overridden by specificity methods"); final Collection<Pair<MethodRepr, ClassRepr>> overridden = new HashSet<>(); myFuture.addOverriddenMethods(it, lessSpecificCond, overridden, null, it); for (final Pair<MethodRepr, ClassRepr> pair : overridden) { final MethodRepr method = pair.first; final ClassRepr methodClass = pair.second; if (methodClass == MOCK_CLASS) { continue; } debug("Method: ", method.name); debug("Class : ", methodClass.name); debug("Affecting method usages for that found"); myFuture.affectMethodUsages(method, myPresent.propagateMethodAccess(method, it.name), method.createUsage(myContext, it.name), state.myAffectedUsages, state.myDependants); } debug("Processing overriding by specificity methods"); final Predicate<MethodRepr> overrides = MethodRepr.equalByJavaRules(addedMethod); final Collection<Pair<MethodRepr, ClassRepr>> overriding = new HashSet<>(); myFuture.addOverridingMethods(addedMethod, it, it, lessSpecificCond, overriding, null); for (final Pair<MethodRepr, ClassRepr> pair : overriding) { final MethodRepr method = pair.first; final ClassRepr methodClass = pair.second; debug("Method: ", method.name); debug("Class : ", methodClass.name); if (overrides.test(method)) { debug("Current method overrides the added method"); final Iterable<File> files = classToSourceFileGet(methodClass.name); if (files != null && !containsAll(myFilesToCompile, files)) { ContainerUtil.addAll(myAffectedFiles, files); if (myDebugS.isDebugEnabled()) { for (File file : files) { debug("Affecting file ", file); } } } } else { debug("Current method does not override the added method"); debug("Affecting method usages for the method"); myPresent.appendDependents(methodClass, state.myDependants); myFuture.affectMethodUsages(method, myPresent.propagateMethodAccess(method, methodClass.name), method.createUsage(myContext, methodClass.name), state.myAffectedUsages, state.myDependants); } } getAllSubclasses(it.name).forEach(subClass -> { Iterable<ClassRepr> reprs = Iterators.collect(myFuture.reprsByName(subClass, ClassRepr.class), new SmartList<>()); if (Iterators.isEmpty(reprs)) { return; } final Iterable<File> sourceFileNames = classToSourceFileGet(subClass); if (sourceFileNames != null && !containsAll(myCompiledFiles, sourceFileNames)) { for (ClassRepr outerClassRepr : Iterators.flat(Iterators.map(reprs, r -> isEmpty(r.getOuterClassName())? Collections.emptyList() : myFuture.reprsByName(r.getOuterClassName(), ClassRepr.class)))) { if (myFuture.isMethodVisible(outerClassRepr, addedMethod) || myFuture.extendsLibraryClass(outerClassRepr, null)) { ContainerUtil.addAll(myAffectedFiles, sourceFileNames); for (File sourceFileName : sourceFileNames) { debug("Affecting file due to local overriding: ", sourceFileName); } break; } } } }); } } debug("End of added methods processing"); }
processAddedMethods
1,082
void (final DiffState state, final ClassRepr.Diff diff, final ClassRepr it) { final Collection<MethodRepr> removed = diff.methods().removed(); if (removed.isEmpty()) { return; } assert myFuture != null; assert myPresent != null; assert myAffectedFiles != null; assert myCompiledFiles != null; debug("Processing removed methods:"); for (final MethodRepr removedMethod : removed) { debug("Method ", removedMethod.name); final Collection<Pair<MethodRepr, ClassRepr>> overriddenMethods = myFuture.findOverriddenMethods(removedMethod, it); final Supplier<IntSet> propagated = lazy(()-> myFuture.propagateMethodAccess(removedMethod, it.name)); if (!removedMethod.isPrivate() && removedMethod.isStatic()) { debug("The method was static --- affecting static method import usages"); myFuture.affectStaticMemberImportUsages(removedMethod.name, it.name, propagated.get(), state.myAffectedUsages, state.myDependants); } if (removedMethod.isPackageLocal()) { // Sometimes javac cannot find an overridden package local method in superclasses, when superclasses are defined in different packages. // This results in compilation error when the code is compiled from the very beginning. // So even if we correctly find a corresponding overridden method and the bytecode compatibility remains, // we still need to affect package local method usages to behave similar to javac. debug("Removed method is package-local, affecting method usages"); myFuture.affectMethodUsages(removedMethod, propagated.get(), removedMethod.createUsage(myContext, it.name), state.myAffectedUsages, state.myDependants); } else if (overriddenMethods.isEmpty()) { debug("No overridden methods found, affecting method usages"); myFuture.affectMethodUsages(removedMethod, propagated.get(), removedMethod.createUsage(myContext, it.name), state.myAffectedUsages, state.myDependants); } else { boolean clearlyOverridden = isEmpty(removedMethod.signature) && Iterators.isEmpty( Iterators.filter(overriddenMethods, p -> p.first == MOCK_METHOD || !p.first.myType.equals(removedMethod.myType) || !isEmpty(p.first.signature) || removedMethod.isMoreAccessibleThan(p.first)) ); if (!clearlyOverridden) { debug("No clearly overridden methods found, affecting method usages"); myFuture.affectMethodUsages(removedMethod, propagated.get(), removedMethod.createUsage(myContext, it.name), state.myAffectedUsages, state.myDependants); } } final Collection<Pair<MethodRepr, ClassRepr>> overridingMethods = new HashSet<>(); myFuture.addOverridingMethods(removedMethod, it, it, MethodRepr.equalByJavaRules(removedMethod), overridingMethods, null); for (final Pair<MethodRepr, ClassRepr> p : overridingMethods) { final Iterable<File> fNames = classToSourceFileGet(p.second.name); if (fNames != null && !containsAll(myFilesToCompile, fNames)) { ContainerUtil.addAll(myAffectedFiles, fNames); if (myDebugS.isDebugEnabled()) { for (File fName : fNames) { debug("Affecting file by overriding: ", fName); } } } } if (!removedMethod.isAbstract() && !removedMethod.isStatic()) { propagated.get().forEach(p -> { if (p != it.name) { for (ClassRepr subClass : myFuture.reprsByName(p, ClassRepr.class)) { final Collection<Pair<MethodRepr, ClassRepr>> overriddenInSubclass = myFuture.findOverriddenMethods(removedMethod, subClass); overriddenInSubclass.addAll(overriddenMethods); boolean allAbstract = true; boolean visited = false; for (final Pair<MethodRepr, ClassRepr> pp : overriddenInSubclass) { final ClassRepr cc = pp.second; if (cc == MOCK_CLASS) { visited = true; continue; } if (!pp.first.isAbstract() && !pp.first.equals(removedMethod) /*need exact match for non-abstract methods*/) { continue; } visited = true; allAbstract = pp.first.isAbstract() || cc.isInterface(); if (!allAbstract) { break; } } if (allAbstract && visited) { final Iterable<File> sources = classToSourceFileGet(p); if (sources != null && !containsAll(myFilesToCompile, sources)) { ContainerUtil.addAll(myAffectedFiles, sources); debug("Removed method is not abstract & overrides some abstract method which is not then over-overridden in subclass ", p); for (File source : sources) { debug("Affecting subclass source file ", source); } } break; // classReprs } } } }); } } debug("End of removed methods processing"); }
processRemovedMethods
1,083
void (final DiffState state, final ClassRepr.Diff diff, final ClassRepr it) { final Collection<Pair<MethodRepr, MethodRepr.Diff>> changed = diff.methods().changed(); if (changed.isEmpty()) { return; } debug("Processing changed methods:"); assert myPresent != null; assert myFuture != null; assert myAffectedFiles != null; if (it.isInterface()) { for (final Pair<MethodRepr, MethodRepr.Diff> mr : changed) { if ((mr.second.removedModifiers() & Opcodes.ACC_ABSTRACT) != 0) { debug("Method became non-abstract: ", mr.first.name); myPresent.affectLambdaInstantiations(state, it.name); break; } } } final List<Pair<MethodRepr, MethodRepr.Diff>> moreAccessible = new ArrayList<>(); for (final Pair<MethodRepr, MethodRepr.Diff> mr : changed) { final MethodRepr m = mr.first; final MethodRepr.Diff d = mr.second; final boolean throwsChanged = !d.exceptions().unchanged(); debug("Method: ", m.name); if (d.accessExpanded()) { moreAccessible.add(mr); } if (it.isAnnotation()) { if (d.defaultRemoved()) { debug("Class is annotation, default value is removed => adding annotation query"); IntSet l = new IntOpenHashSet(DEFAULT_SET_CAPACITY, DEFAULT_SET_LOAD_FACTOR); l.add(m.name); final UsageRepr.AnnotationUsage annotationUsage = (UsageRepr.AnnotationUsage)UsageRepr .createAnnotationUsage(myContext, TypeRepr.createClassType(myContext, it.name), l, null); state.myAnnotationQuery.add(annotationUsage); } } else if (d.base() != Difference.NONE || throwsChanged) { final Supplier<IntSet> propagated = lazy(()-> myFuture.propagateMethodAccess(m, it.name)); boolean affected = false; boolean constrained = false; final Set<UsageRepr.Usage> usages = new HashSet<>(); if (d.packageLocalOn()) { debug("Method became package-private, affecting method usages outside the package"); myFuture.affectMethodUsages(m, propagated.get(), m.createUsage(myContext, it.name), usages, state.myDependants); for (final UsageRepr.Usage usage : usages) { state.myUsageConstraints.put(usage, myFuture.new PackageConstraint(it.getPackageName())); } state.myAffectedUsages.addAll(usages); affected = true; constrained = true; } if ((d.base() & Difference.TYPE) != 0 || (d.base() & Difference.SIGNATURE) != 0 || throwsChanged) { if (!affected) { debug("Return type, throws list or signature changed --- affecting method usages"); myFuture.affectMethodUsages(m, propagated.get(), m.createUsage(myContext, it.name), usages, state.myDependants); final List<Pair<MethodRepr, ClassRepr>> overridingMethods = new LinkedList<>(); myFuture.addOverridingMethods(m, it, it, MethodRepr.equalByJavaRules(m), overridingMethods, null); for(final Pair<MethodRepr, ClassRepr> p : overridingMethods) { final ClassRepr aClass = p.getSecond(); if (aClass != MOCK_CLASS) { final Iterable<File> fileNames = classToSourceFileGet(aClass.name); if (fileNames != null) { ContainerUtil.addAll(myAffectedFiles, fileNames); } } } state.myAffectedUsages.addAll(usages); affected = true; } } else if ((d.base() & Difference.ACCESS) != 0) { if ((d.addedModifiers() & (Opcodes.ACC_STATIC | Opcodes.ACC_PRIVATE | Opcodes.ACC_SYNTHETIC | Opcodes.ACC_BRIDGE)) != 0 || (d.removedModifiers() & Opcodes.ACC_STATIC) != 0) { // When synthetic or bridge flags are added, this effectively means that explicitly written in the code // method with the same signature and return type has been removed and a bridge method has been generated instead. // In some cases (e.g. using raw types) the presence of such synthetic methods in the bytecode is ignored by the compiler // so that the code that called such method via raw type reference might not compile anymore => to be on the safe side // we should recompile all places where the method was used if (!affected) { debug("Added {static | private | synthetic | bridge} specifier or removed static specifier --- affecting method usages"); myFuture.affectMethodUsages(m, propagated.get(), m.createUsage(myContext, it.name), usages, state.myDependants); state.myAffectedUsages.addAll(usages); affected = true; } if ((d.addedModifiers() & Opcodes.ACC_STATIC) != 0) { debug("Added static specifier --- affecting subclasses"); myFuture.affectSubclasses(it.name, myAffectedFiles, state.myAffectedUsages, state.myDependants, false, myCompiledFiles, null); if (!m.isPrivate()) { debug("Added static modifier --- affecting static member on-demand import usages"); myFuture.affectStaticMemberOnDemandUsages(it.name, propagated.get(), state.myAffectedUsages, state.myDependants); } } else if ((d.removedModifiers() & Opcodes.ACC_STATIC) != 0) { if (!m.isPrivate()) { debug("Removed static modifier --- affecting static method import usages"); myFuture.affectStaticMemberImportUsages(m.name, it.name, propagated.get(), state.myAffectedUsages, state.myDependants); } } } else { if ((d.addedModifiers() & (Opcodes.ACC_FINAL | Opcodes.ACC_PUBLIC | Opcodes.ACC_ABSTRACT)) != 0) { debug("Added final, public or abstract specifier --- affecting subclasses"); myFuture.affectSubclasses(it.name, myAffectedFiles, state.myAffectedUsages, state.myDependants, false, myCompiledFiles, null); if (it.isInterface() && (d.addedModifiers() & Opcodes.ACC_ABSTRACT) != 0) { myPresent.affectLambdaInstantiations(state, it.name); } } if ((d.addedModifiers() & Opcodes.ACC_PROTECTED) != 0 && (d.removedModifiers() & Opcodes.ACC_PRIVATE) == 0) { debug("Added public or package-private method became protected --- affect method usages with protected constraint"); if (!affected) { myFuture.affectMethodUsages(m, propagated.get(), m.createUsage(myContext, it.name), usages, state.myDependants); state.myAffectedUsages.addAll(usages); affected = true; } for (final UsageRepr.Usage usage : usages) { state.myUsageConstraints.put(usage, myFuture.new InheritanceConstraint(it)); } constrained = true; } } } if ((d.base() & Difference.ANNOTATIONS) != 0) { final Set<AnnotationsChangeTracker.Recompile> toRecompile = EnumSet.noneOf(AnnotationsChangeTracker.Recompile.class); for (AnnotationsChangeTracker extension : myAnnotationChangeTracker) { if (toRecompile.containsAll(AnnotationsChangeTracker.RECOMPILE_ALL)) { break; } final Set<AnnotationsChangeTracker.Recompile> actions = extension.methodAnnotationsChanged(myContext, (ProtoMethodEntity)m, d.annotations(), d.parameterAnnotations()); if (actions.contains(AnnotationsChangeTracker.Recompile.USAGES)) { debug("Extension "+extension.getClass().getName()+" requested recompilation because of changes in annotations list --- affecting method usages"); } if (actions.contains(AnnotationsChangeTracker.Recompile.SUBCLASSES)) { debug("Extension "+extension.getClass().getName()+" requested recompilation because of changes in method annotations or method parameter annotations list --- affecting subclasses"); } toRecompile.addAll(actions); } if (toRecompile.contains(AnnotationsChangeTracker.Recompile.USAGES)) { myFuture.affectMethodUsages(m, propagated.get(), m.createUsage(myContext, it.name), usages, state.myDependants); state.myAffectedUsages.addAll(usages); if (constrained) { // remove any constraints so that all usages of this method are recompiled for (UsageRepr.Usage usage : usages) { state.myUsageConstraints.remove(usage); } } } if (toRecompile.contains(AnnotationsChangeTracker.Recompile.SUBCLASSES)) { myFuture.affectSubclasses(it.name, myAffectedFiles, state.myAffectedUsages, state.myDependants, false, myCompiledFiles, null); } } } } if (!moreAccessible.isEmpty()) { final Iterable<OverloadDescriptor> allOverloads = myFuture.findAllOverloads(it, mr -> { Integer result = null; for (Pair<MethodRepr, MethodRepr.Diff> pair : moreAccessible) { MethodRepr m = pair.first; MethodRepr.Diff d = pair.second; if (mr.name == m.name && !m.equals(mr)) { int newAccess = m.access & (~d.removedModifiers()) | d.addedModifiers(); if (result == null || Difference.weakerAccess(result, newAccess)) { result = newAccess; } } } return result; }); for (OverloadDescriptor descr : allOverloads) { debug("Method became more accessible --- affect usages of overloading methods: ", descr.overloadMethod.name); final Set<UsageRepr.Usage> overloadsUsages = new HashSet<>(); myFuture.affectMethodUsages( descr.overloadMethod, myFuture.propagateMethodAccess(descr.overloadMethod, descr.overloadMethodOwner.name), descr.overloadMethod.createUsage(myContext, descr.overloadMethodOwner.name), overloadsUsages, state.myDependants ); state.myAffectedUsages.addAll(overloadsUsages); final UsageConstraint constr = Difference.isPackageLocal(descr.accessScope)? myFuture.new PackageConstraint(it.getPackageName()).negate() : Difference.isProtected(descr.accessScope)? myFuture.new InheritanceConstraint(it).negate() : null; if (constr != null) { for (final UsageRepr.Usage usage : overloadsUsages) { state.myUsageConstraints.put(usage, constr); } } } } debug("End of changed methods processing"); }
processChangedMethods
1,084
boolean (final DiffState state, final ClassRepr.Diff diff, final ClassRepr classRepr) { final Collection<FieldRepr> added = diff.fields().added(); if (added.isEmpty()) { return true; } debug("Processing added fields"); assert myFuture != null; assert myPresent != null; assert myCompiledFiles != null; assert myAffectedFiles != null; if (classRepr.isEnum()) { debug("Constants added to enum, affecting class usages ", classRepr.name); final UsageRepr.Usage usage = classRepr.createUsage(); state.myAffectedUsages.add(usage); // only mark synthetic classes used to implement switch statements: this will limit the number of recompiled classes to those where switch statements on changed enum are used state.myUsageConstraints.put(usage, residence -> { for (ClassRepr candidate : myPresent.reprsByName(residence, ClassRepr.class)) { if (candidate.isSynthetic()) { return true; } } return false; }); } for (final FieldRepr addedField : added) { debug("Field: ", addedField.name); if (!addedField.isPrivate()) { IntSet changedClassWithSubclasses = myFuture.propagateFieldAccess(addedField.name, classRepr.name); changedClassWithSubclasses.add(classRepr.name); changedClassWithSubclasses.forEach(subClass -> { final Iterable<ClassRepr> reprs = Iterators.collect(myFuture.reprsByName(subClass, ClassRepr.class), new SmartList<>()); if (!Iterators.isEmpty(reprs)) { final Iterable<File> sourceFileNames = classToSourceFileGet(subClass); if (sourceFileNames != null && !containsAll(myCompiledFiles, sourceFileNames)) { for (ClassRepr r : reprs) { if (r.isLocal()) { for (File sourceFileName : sourceFileNames) { debug("Affecting local subclass (introduced field can potentially hide surrounding method parameters/local variables): ", sourceFileName); myAffectedFiles.add(sourceFileName); } break; } else { final int outerClass = r.getOuterClassName(); if (!isEmpty(outerClass) && myFuture.isFieldVisible(outerClass, addedField)) { for (File sourceFileName : sourceFileNames) { debug("Affecting inner subclass (introduced field can potentially hide surrounding class fields): ", sourceFileName); myAffectedFiles.add(sourceFileName); } break; } } } } } debug("Affecting field usages referenced from subclass ", subClass); myFuture.affectFieldUsages(addedField, IntSet.of(), addedField.createUsage(myContext, subClass), state.myAffectedUsages, state.myDependants); if (addedField.isStatic()) { myFuture.affectStaticMemberOnDemandUsages(subClass, IntSet.of(), state.myAffectedUsages, state.myDependants); } myFuture.appendDependents(subClass, state.myDependants); }); } final Collection<Pair<FieldRepr, ClassRepr>> overriddenFields = new HashSet<>(); myFuture.addOverriddenFields(addedField, classRepr, overriddenFields, null, classRepr); for (final Pair<FieldRepr, ClassRepr> p : overriddenFields) { final FieldRepr overridden = p.first; final ClassRepr cc = p.second; if (!overridden.isPrivate()) { debug("Affecting usages of overridden field in class ", cc.name); myFuture.affectFieldUsages(overridden, myPresent.propagateFieldAccess(overridden.name, cc.name), overridden.createUsage(myContext, cc.name), state.myAffectedUsages, state.myDependants); } } } debug("End of added fields processing"); return true; }
processAddedFields
1,085
boolean (final DiffState state, final ClassRepr.Diff diff, final ClassRepr it) { final Collection<FieldRepr> removed = diff.fields().removed(); if (removed.isEmpty()) { return true; } assert myPresent != null; debug("Processing removed fields:"); for (final FieldRepr f : removed) { debug("Field: ", f.name); if (!myProcessConstantsIncrementally && !f.isPrivate() && (f.access & INLINABLE_FIELD_MODIFIERS_MASK) == INLINABLE_FIELD_MODIFIERS_MASK && f.hasValue()) { debug("Field had value and was (non-private) final static => a switch to non-incremental mode requested"); if (!incrementalDecision(it.name, f, myAffectedFiles, myFilesToCompile, myFilter)) { debug("End of Differentiate, returning false"); return false; } } final IntSet propagated = myPresent.propagateFieldAccess(f.name, it.name); myPresent.affectFieldUsages(f, propagated, f.createUsage(myContext, it.name), state.myAffectedUsages, state.myDependants); if (!f.isPrivate() && f.isStatic()) { debug("The field was static --- affecting static field import usages"); myPresent.affectStaticMemberImportUsages(f.name, it.name, propagated, state.myAffectedUsages, state.myDependants); } } debug("End of removed fields processing"); return true; }
processRemovedFields
1,086
boolean (final DiffState state, final ClassRepr.Diff diff, final ClassRepr it) { final Collection<Pair<FieldRepr, Difference>> changed = diff.fields().changed(); if (changed.isEmpty()) { return true; } debug("Processing changed fields:"); assert myFuture != null; assert myPresent != null; for (final Pair<FieldRepr, Difference> f : changed) { final Difference d = f.second; final FieldRepr field = f.first; debug("Field: ", field.name); final Supplier<IntSet> propagated = lazy(()-> myFuture.propagateFieldAccess(field.name, it.name)); // only if the field was a compile-time constant if (!field.isPrivate() && (field.access & INLINABLE_FIELD_MODIFIERS_MASK) == INLINABLE_FIELD_MODIFIERS_MASK && d.hadValue()) { final int changedModifiers = d.addedModifiers() | d.removedModifiers(); final boolean harmful = (changedModifiers & (Opcodes.ACC_STATIC | Opcodes.ACC_FINAL)) != 0; final boolean valueChanged = (d.base() & Difference.VALUE) != 0; if (harmful || valueChanged || d.accessRestricted()) { if (myProcessConstantsIncrementally) { debug("Potentially inlined field changed its access or value => affecting field usages and static member import usages"); myFuture.affectFieldUsages(field, propagated.get(), field.createUsage(myContext, it.name), state.myAffectedUsages, state.myDependants); myFuture.affectStaticMemberImportUsages(field.name, it.name, propagated.get(), state.myAffectedUsages, state.myDependants); } else { debug("Potentially inlined field changed its access or value => a switch to non-incremental mode requested"); if (!incrementalDecision(it.name, field, myAffectedFiles, myFilesToCompile, myFilter)) { debug("End of Differentiate, returning false"); return false; } } } } if (d.base() != Difference.NONE) { if ((d.base() & Difference.TYPE) != 0 || (d.base() & Difference.SIGNATURE) != 0) { debug("Type or signature changed --- affecting field usages"); myFuture.affectFieldUsages( field, propagated.get(), field.createUsage(myContext, it.name), state.myAffectedUsages, state.myDependants ); } else if ((d.base() & Difference.ACCESS) != 0) { if ((d.addedModifiers() & Opcodes.ACC_STATIC) != 0 || (d.removedModifiers() & Opcodes.ACC_STATIC) != 0 || (d.addedModifiers() & Opcodes.ACC_PRIVATE) != 0 || (d.addedModifiers() & Opcodes.ACC_VOLATILE) != 0) { debug("Added/removed static modifier or added private/volatile modifier --- affecting field usages"); myFuture.affectFieldUsages( field, propagated.get(), field.createUsage(myContext, it.name), state.myAffectedUsages, state.myDependants ); if (!field.isPrivate()) { if ((d.addedModifiers() & Opcodes.ACC_STATIC) != 0) { debug("Added static modifier --- affecting static member on-demand import usages"); myFuture.affectStaticMemberOnDemandUsages(it.name, propagated.get(), state.myAffectedUsages, state.myDependants); } else if ((d.removedModifiers() & Opcodes.ACC_STATIC) != 0) { debug("Removed static modifier --- affecting static field import usages"); myFuture.affectStaticMemberImportUsages(field.name, it.name, propagated.get(), state.myAffectedUsages, state.myDependants); } } } else { final Set<UsageRepr.Usage> usages = new HashSet<>(); if ((d.addedModifiers() & Opcodes.ACC_FINAL) != 0) { debug("Added final modifier --- affecting field assign usages"); myFuture.affectFieldUsages(field, propagated.get(), field.createAssignUsage(myContext, it.name), usages, state.myDependants); state.myAffectedUsages.addAll(usages); } if ((d.removedModifiers() & Opcodes.ACC_PUBLIC) != 0) { debug("Removed public modifier, affecting field usages with appropriate constraint"); myFuture.affectFieldUsages(field, propagated.get(), field.createUsage(myContext, it.name), usages, state.myDependants); state.myAffectedUsages.addAll(usages); for (final UsageRepr.Usage usage : usages) { if ((d.addedModifiers() & Opcodes.ACC_PROTECTED) != 0) { state.myUsageConstraints.put(usage, myFuture.new InheritanceConstraint(it)); } else { state.myUsageConstraints.put(usage, myFuture.new PackageConstraint(it.getPackageName())); } } } else if ((d.removedModifiers() & Opcodes.ACC_PROTECTED) != 0 && d.accessRestricted()) { debug("Removed protected modifier and the field became less accessible, affecting field usages with package constraint"); myFuture.affectFieldUsages(field, propagated.get(), field.createUsage(myContext, it.name), usages, state.myDependants); state.myAffectedUsages.addAll(usages); for (final UsageRepr.Usage usage : usages) { state.myUsageConstraints.put(usage, myFuture.new PackageConstraint(it.getPackageName())); } } } } if ((d.base() & Difference.ANNOTATIONS) != 0) { final Set<AnnotationsChangeTracker.Recompile> toRecompile = EnumSet.noneOf(AnnotationsChangeTracker.Recompile.class); for (AnnotationsChangeTracker extension : myAnnotationChangeTracker) { if (toRecompile.containsAll(AnnotationsChangeTracker.RECOMPILE_ALL)) { break; } final Set<AnnotationsChangeTracker.Recompile> res = extension.fieldAnnotationsChanged(myContext, (ProtoFieldEntity)field, d.annotations()); if (res.contains(AnnotationsChangeTracker.Recompile.USAGES)) { debug("Extension "+extension.getClass().getName()+" requested recompilation because of changes in annotations list --- affecting field usages"); } if (res.contains(AnnotationsChangeTracker.Recompile.SUBCLASSES)) { debug("Extension "+extension.getClass().getName()+" requested recompilation because of changes in field annotations list --- affecting subclasses"); } toRecompile.addAll(res); } if (toRecompile.contains(AnnotationsChangeTracker.Recompile.USAGES)) { final Set<UsageRepr.Usage> usages = new HashSet<>(); myFuture.affectFieldUsages(field, propagated.get(), field.createUsage(myContext, it.name), usages, state.myDependants); state.myAffectedUsages.addAll(usages); // remove any constraints to ensure all field usages are recompiled for (UsageRepr.Usage usage : usages) { state.myUsageConstraints.remove(usage); } } if (toRecompile.contains(AnnotationsChangeTracker.Recompile.SUBCLASSES)) { myFuture.affectSubclasses(it.name, myAffectedFiles, state.myAffectedUsages, state.myDependants, false, myCompiledFiles, null); } } } } debug("End of changed fields processing"); return true; }
processChangedFields
1,087
boolean (final DiffState state) { final Collection<Pair<ClassRepr, ClassRepr.Diff>> changedClasses = state.myClassDiff.changed(); if (!changedClasses.isEmpty()) { debug("Processing changed classes:"); assert myFuture != null; assert myPresent != null; final Util.FileFilterConstraint fileFilterConstraint = myFilter != null? myPresent.new FileFilterConstraint(myFilter) : null; for (final Pair<ClassRepr, ClassRepr.Diff> changed : changedClasses) { final ClassRepr changedClass = changed.first; final ClassRepr.Diff diff = changed.second; myDelta.addChangedClass(changedClass.name); debug("Changed: ", changedClass.name); final int addedModifiers = diff.addedModifiers(); final boolean superClassChanged = (diff.base() & Difference.SUPERCLASS) != 0; final boolean interfacesChanged = !diff.interfaces().unchanged(); final boolean signatureChanged = (diff.base() & Difference.SIGNATURE) != 0; if (superClassChanged) { myDelta.registerRemovedSuperClass(changedClass.name, changedClass.getSuperClass().className); for (ClassRepr newClass : myDelta.getReprsByName(changedClass.name, ClassRepr.class)) { myDelta.registerAddedSuperClass(changedClass.name, newClass.getSuperClass().className); } } if (interfacesChanged) { for (final TypeRepr.ClassType typ : diff.interfaces().removed()) { myDelta.registerRemovedSuperClass(changedClass.name, typ.className); } for (final TypeRepr.ClassType typ : diff.interfaces().added()) { myDelta.registerAddedSuperClass(changedClass.name, typ.className); } } if (myEasyMode) { continue; } final IntSet directDeps = myPresent.appendDependents(changedClass, state.myDependants); if (superClassChanged || interfacesChanged || signatureChanged) { debug("Superclass changed: ", superClassChanged); debug("Interfaces changed: ", interfacesChanged); debug("Signature changed ", signatureChanged); final boolean extendsChanged = superClassChanged && !diff.extendsAdded(); final boolean interfacesRemoved = interfacesChanged && !diff.interfaces().removed().isEmpty(); debug("Extends changed: ", extendsChanged); debug("Interfaces removed: ", interfacesRemoved); myFuture.affectSubclasses(changedClass.name, myAffectedFiles, state.myAffectedUsages, state.myDependants, extendsChanged || interfacesRemoved || signatureChanged, myCompiledFiles, null); if (extendsChanged && directDeps != null) { final TypeRepr.ClassType excClass = TypeRepr.createClassType(myContext, changedClass.name); directDeps.forEach(depClass -> { for (ClassRepr depClassRepr : myPresent.reprsByName(depClass, ClassRepr.class)) { myPresent.affectMethodUsagesThrowing(depClassRepr, excClass, state.myAffectedUsages, state.myDependants); } }); } if (!changedClass.isAnonymous()) { final IntSet parents = new IntOpenHashSet(); myPresent.collectSupersRecursively(changedClass.name, parents); final IntSet futureParents = new IntOpenHashSet(); myFuture.collectSupersRecursively(changedClass.name, futureParents); parents.removeAll(futureParents); parents.remove(myObjectClassName); if (!parents.isEmpty()) { parents.forEach(className -> { debug("Affecting usages in generic type parameter bounds of class: ", className); final UsageRepr.Usage usage = UsageRepr.createClassAsGenericBoundUsage(myContext, className); state.myAffectedUsages.add(usage); if (fileFilterConstraint != null) { state.myUsageConstraints.put(usage, fileFilterConstraint); } myPresent.appendDependents(className, state.myDependants); }); } } } if ((diff.addedModifiers() & Opcodes.ACC_INTERFACE) != 0 || (diff.removedModifiers() & Opcodes.ACC_INTERFACE) != 0) { debug("Class-to-interface or interface-to-class conversion detected, added class usage to affected usages"); state.myAffectedUsages.add(changedClass.createUsage()); } if (changedClass.isAnnotation() && changedClass.getRetentionPolicy() == RetentionPolicy.SOURCE) { debug("Annotation, retention policy = SOURCE => a switch to non-incremental mode requested"); if (!incrementalDecision(changedClass.getOuterClassName(), changedClass, myAffectedFiles, myFilesToCompile, myFilter)) { debug("End of Differentiate, returning false"); return false; } } if ((addedModifiers & Opcodes.ACC_PROTECTED) != 0) { debug("Introduction of 'protected' modifier detected, adding class usage + inheritance constraint to affected usages"); final UsageRepr.Usage usage = changedClass.createUsage(); state.myAffectedUsages.add(usage); state.myUsageConstraints.put(usage, myFuture.new InheritanceConstraint(changedClass)); } if (diff.packageLocalOn()) { debug("Introduction of 'package-private' access detected, adding class usage + package constraint to affected usages"); final UsageRepr.Usage usage = changedClass.createUsage(); state.myAffectedUsages.add(usage); state.myUsageConstraints.put(usage, myFuture.new PackageConstraint(changedClass.getPackageName())); } if ((addedModifiers & Opcodes.ACC_FINAL) != 0 || (addedModifiers & Opcodes.ACC_PRIVATE) != 0) { debug("Introduction of 'private' or 'final' modifier(s) detected, adding class usage to affected usages"); state.myAffectedUsages.add(changedClass.createUsage()); } if ((addedModifiers & Opcodes.ACC_ABSTRACT) != 0 || (addedModifiers & Opcodes.ACC_STATIC) != 0) { debug("Introduction of 'abstract' or 'static' modifier(s) detected, adding class new usage to affected usages"); state.myAffectedUsages.add(UsageRepr.createClassNewUsage(myContext, changedClass.name)); } if (!changedClass.isAnonymous() && !isEmpty(changedClass.getOuterClassName()) && !changedClass.isPrivate()) { if (addedModifiers != 0 || diff.removedModifiers() != 0) { debug("Some modifiers (access flags) were changed for non-private inner class, adding class usage to affected usages"); state.myAffectedUsages.add(changedClass.createUsage()); } } if (changedClass.isAnnotation()) { debug("Class is annotation, performing annotation-specific analysis"); if (diff.retentionChanged()) { debug("Retention policy change detected, adding class usage to affected usages"); state.myAffectedUsages.add(changedClass.createUsage()); } else if (diff.targetAttributeCategoryMightChange()) { debug("Annotation's attribute category in bytecode might be affected because of TYPE_USE or RECORD_COMPONENT target, adding class usage to affected usages"); state.myAffectedUsages.add(changedClass.createUsage()); } else { final Collection<ElemType> removedtargets = diff.targets().removed(); if (removedtargets.contains(ElemType.LOCAL_VARIABLE)) { debug("Removed target contains LOCAL_VARIABLE => a switch to non-incremental mode requested"); if (!incrementalDecision(changedClass.getOuterClassName(), changedClass, myAffectedFiles, myFilesToCompile, myFilter)) { debug("End of Differentiate, returning false"); return false; } } if (!removedtargets.isEmpty()) { debug("Removed some annotation targets, adding annotation query"); state.myAnnotationQuery.add((UsageRepr.AnnotationUsage)UsageRepr.createAnnotationUsage( myContext, TypeRepr.createClassType(myContext, changedClass.name), null, EnumSet.copyOf(removedtargets) )); } for (final MethodRepr m : diff.methods().added()) { if (!m.hasValue()) { debug("Added method with no default value: ", m.name); debug("Adding class usage to affected usages"); state.myAffectedUsages.add(changedClass.createUsage()); } } } debug("End of annotation-specific analysis"); } processAddedMethods(state, diff, changedClass); processRemovedMethods(state, diff, changedClass); processChangedMethods(state, diff, changedClass); if (!processAddedFields(state, diff, changedClass)) { return false; } if (!processRemovedFields(state, diff, changedClass)) { return false; } if (!processChangedFields(state, diff, changedClass)) { return false; } if ((diff.base() & Difference.ANNOTATIONS) != 0) { final Set<AnnotationsChangeTracker.Recompile> toRecompile = EnumSet.noneOf(AnnotationsChangeTracker.Recompile.class); for (AnnotationsChangeTracker extension : myAnnotationChangeTracker) { if (toRecompile.containsAll(AnnotationsChangeTracker.RECOMPILE_ALL)) { break; } final Set<AnnotationsChangeTracker.Recompile> res = extension.classAnnotationsChanged(myContext, changedClass, diff.annotations()); if (res.contains(AnnotationsChangeTracker.Recompile.USAGES)) { debug("Extension "+extension.getClass().getName()+" requested class usages recompilation because of changes in annotations list --- adding class usage to affected usages"); } if (res.contains(AnnotationsChangeTracker.Recompile.SUBCLASSES)) { debug("Extension "+extension.getClass().getName()+" requested subclasses recompilation because of changes in annotations list --- adding subclasses to affected usages"); } toRecompile.addAll(res); } final boolean recompileUsages = toRecompile.contains(AnnotationsChangeTracker.Recompile.USAGES); if (recompileUsages) { state.myAffectedUsages.add(changedClass.createUsage()); } if (toRecompile.contains(AnnotationsChangeTracker.Recompile.SUBCLASSES)) { myFuture.affectSubclasses(changedClass.name, myAffectedFiles, state.myAffectedUsages, state.myDependants, recompileUsages, myCompiledFiles, null); } } } debug("End of changed classes processing"); } return !myEasyMode; }
processChangedClasses
1,088
void (final DiffState state, @NotNull File fileName) { final Collection<ClassRepr> removed = state.myClassDiff.removed(); if (removed.isEmpty()) { return; } assert myPresent != null; assert myDelta.myChangedFiles != null; myDelta.myChangedFiles.add(fileName); debug("Processing removed classes:"); for (final ClassRepr c : removed) { myDelta.addDeletedClass(c, fileName); if (!myEasyMode) { myPresent.appendDependents(c, state.myDependants); debug("Adding usages of class ", c.name); state.myAffectedUsages.add(c.createUsage()); debug("Affecting usages of removed class ", c.name); affectAll(c.name, fileName, myAffectedFiles, myCompiledFiles, myFilter); } } debug("End of removed classes processing."); }
processRemovedClases
1,089
void (DiffState state) { final Collection<ClassRepr> addedClasses = state.myClassDiff.added(); if (addedClasses.isEmpty()) { return; } debug("Processing added classes:"); if (!myEasyMode && myFilter != null) { // checking if this newly added class duplicates already existing one assert myCompiledFiles != null; assert myAffectedFiles != null; for (ClassRepr c : addedClasses) { if (!c.isLocal() && !c.isAnonymous() && isEmpty(c.getOuterClassName())) { final Set<File> candidates = FileCollectionFactory.createCanonicalFileSet(); final Iterable<File> currentlyMapped = classToSourceFileGet(c.name); if (currentlyMapped != null) { ContainerUtil.addAll(candidates, currentlyMapped); } candidates.removeAll(myCompiledFiles); final Iterable<File> newSources = myDelta.classToSourceFileGet(c.name); if (newSources != null) { removeAll(candidates, newSources); } final Set<File> nonExistentOrOutOfScope = FileCollectionFactory.createCanonicalFileSet(); for (final File candidate : candidates) { if (!candidate.exists() || !myFilter.belongsToCurrentTargetChunk(candidate)) { nonExistentOrOutOfScope.add(candidate); } } candidates.removeAll(nonExistentOrOutOfScope); if (!candidates.isEmpty()) { // Possibly duplicate classes from different sets of source files // Schedule for recompilation both to make possible 'duplicate sources' error evident candidates.clear(); // just reusing the container if (currentlyMapped != null) { ContainerUtil.addAll(candidates, currentlyMapped); } if (newSources != null) { ContainerUtil.addAll(candidates, newSources); } candidates.removeAll(nonExistentOrOutOfScope); if (myDebugS.isDebugEnabled()) { final StringBuilder msg = new StringBuilder(); msg.append("Possibly duplicated classes; Scheduling for recompilation sources: "); for (File file : candidates) { msg.append(file.getPath()).append("; "); } debug(msg.toString()); } myAffectedFiles.addAll(candidates); return; // do not process this file because it should not be integrated } } } } for (final ClassRepr c : addedClasses) { debug("Class name: ", c.name); myDelta.addAddedClass(c); for (final TypeRepr.ClassType sup : c.getSuperTypes()) { myDelta.registerAddedSuperClass(c.name, sup.className); } if (!myEasyMode && !c.isAnonymous() && !c.isLocal()) { final IntSet toAffect = new IntOpenHashSet(); toAffect.add(c.name); final IntSet classes = myShortClassNameIndex.get(myContext.get(c.getShortName())); if (classes != null) { // affecting dependencies on all other classes with the same short name toAffect.addAll(classes); } toAffect.forEach(qName -> { final IntSet depClasses = myClassToClassDependency.get(qName); if (depClasses != null) { affectCorrespondingSourceFiles(depClasses); } }); } } debug("End of added classes processing."); }
processAddedClasses
1,090
void (IntSet toAffect) { assert myAffectedFiles != null; toAffect.forEach(depClass -> { final Iterable<File> fNames = classToSourceFileGet(depClass); if (fNames != null) { for (File fName : fNames) { if (myFilter == null || myFilter.accept(fName)) { debug("Adding dependent file ", fName); myAffectedFiles.add(fName); } } } }); }
affectCorrespondingSourceFiles
1,091
boolean (final DiffState state) { debug("Checking dependent classes:"); assert myAffectedFiles != null; assert myCompiledFiles != null; if (state.myDependants.isEmpty()) { return true; } BiFunction<ClassFileRepr, File, Boolean> dependentReprProcessor = new BiFunction<>() { private final Map<ClassFileRepr, Pair<Boolean, Boolean>> isAffected = new HashMap<>(); @Override public Boolean apply(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(); } }; for (IntIterator dependants = state.myDependants.iterator(); dependants.hasNext(); ) { int depName = dependants.nextInt(); Iterable<Pair<ClassFileRepr, File>> dependentReprs = Iterators.filter(Iterators.map(Iterators.map(myClassToRelativeSourceFilePath.get(depName), src -> Pair.create(myRelativeSourceFilePathToClasses.get(src), toFull(src))), p -> { Collection<ClassFileRepr> reprs = p.getFirst(); if (reprs != null) { for (ClassFileRepr repr : reprs) { if (repr.name == depName) { return Pair.create(repr, p.getSecond()); } } } return null; }), Iterators.notNullFilter()); for (Pair<ClassFileRepr, File> pair : dependentReprs) { if (!dependentReprProcessor.apply(pair.getFirst(), pair.getSecond())) { debug("Turning non-incremental for the BuildTarget because dependent class is annotation-processor generated"); return false; } } } return true; }
calculateAffectedFiles
1,092
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(); }
apply
1,093
void (final DiffState state, File fileName) { final Difference.Specifier<ModuleRepr, ModuleRepr.Diff> modulesDiff = state.myModulesDiff; if (modulesDiff.unchanged()) { return; } for (ModuleRepr moduleRepr : modulesDiff.added()) { myDelta.addChangedClass(moduleRepr.name); // need this for integrate // after module has been added, the whole target should be rebuilt // because necessary 'require' directives may be missing from the newly added module-info file myFuture.affectModule(moduleRepr, myAffectedFiles); } for (ModuleRepr removedModule : modulesDiff.removed()) { myDelta.addDeletedClass(removedModule, fileName); // need this for integrate myPresent.affectDependentModules(state, removedModule.name, null, true); } for (Pair<ModuleRepr, ModuleRepr.Diff> pair : modulesDiff.changed()) { final ModuleRepr moduleRepr = pair.first; final ModuleRepr.Diff d = pair.second; boolean affectSelf = false; boolean affectDeps = false; UsageConstraint constraint = null; myDelta.addChangedClass(moduleRepr.name); // need this for integrate if (d.versionChanged()) { final int version = moduleRepr.getVersion(); myPresent.affectDependentModules(state, moduleRepr.name, new UsageConstraint() { @Override public boolean checkResidence(int dep) { for (ModuleRequiresRepr requires : Iterators.flat(Iterators.map(myPresent.reprsByName(dep, ModuleRepr.class), depModule -> depModule.getRequires()))) { if (requires.name == moduleRepr.name && requires.getVersion() == version) { return true; } } return false; } }, false); } final Difference.Specifier<ModuleRequiresRepr, ModuleRequiresRepr.Diff> requiresDiff = d.requires(); for (ModuleRequiresRepr removed : requiresDiff.removed()) { affectSelf = true; if (removed.isTransitive()) { affectDeps = true; constraint = UsageConstraint.ANY; break; } } for (Pair<ModuleRequiresRepr, ModuleRequiresRepr.Diff> changed : requiresDiff.changed()) { affectSelf |= changed.second.versionChanged(); if (changed.second.becameNonTransitive()) { affectDeps = true; // we could have created more precise constraint here: analyze if required module (recursively) // has only qualified exports that include given module's name. But this seems to be excessive since // in most cases module's exports are unqualified, so that any other module can access the exported API. constraint = UsageConstraint.ANY; } } final Difference.Specifier<ModulePackageRepr, ModulePackageRepr.Diff> exportsDiff = d.exports(); if (!affectDeps) { for (ModulePackageRepr removedPackage : exportsDiff.removed()) { affectDeps = true; if (!removedPackage.isQualified()) { constraint = UsageConstraint.ANY; break; } for (Integer name : removedPackage.getModuleNames()) { final UsageConstraint matchName = UsageConstraint.exactMatch(name); if (constraint == null) { constraint = matchName; } else { constraint = constraint.or(matchName); } } } } if (!affectDeps || constraint != UsageConstraint.ANY) { for (Pair<ModulePackageRepr, ModulePackageRepr.Diff> p : exportsDiff.changed()) { final Collection<Integer> removedModuleNames = p.second.targetModules().removed(); affectDeps |= !removedModuleNames.isEmpty(); if (affectDeps) { for (Integer name : removedModuleNames) { final UsageConstraint matchName = UsageConstraint.exactMatch(name); if (constraint == null) { constraint = matchName; } else { constraint = constraint.or(matchName); } } } } } if (affectSelf) { myPresent.affectModule(moduleRepr, myAffectedFiles); } if (affectDeps) { myPresent.affectDependentModules(state, moduleRepr.name, constraint, true); } } }
processModules
1,094
boolean (int dep) { for (ModuleRequiresRepr requires : Iterators.flat(Iterators.map(myPresent.reprsByName(dep, ModuleRepr.class), depModule -> depModule.getRequires()))) { if (requires.name == moduleRepr.name && requires.getVersion() == version) { return true; } } return false; }
checkResidence
1,095
void (final Mappings delta) { new Differential(delta).differentiate(); }
differentiateOnRebuild
1,096
void (final Mappings delta, final Collection<String> removed, final Collection<? extends File> filesToCompile) { new Differential(delta, removed, filesToCompile).differentiate(); }
differentiateOnNonIncrementalMake
1,097
boolean (final Mappings delta, final Collection<String> removed, final Collection<? extends File> filesToCompile, final Collection<? extends File> compiledWithErrors, final Collection<? extends File> compiledFiles, final Collection<? super File> affectedFiles, final @NotNull DependentFilesFilter filter) { return new Differential(delta, removed, filesToCompile, compiledWithErrors, compiledFiles, affectedFiles, filter).differentiate(); }
differentiateOnIncrementalMake
1,098
void (final int className, @Nullable Iterable<? extends UsageRepr.Usage> usages, final IntIntMultiMaplet buffer) { if (usages == null) { usages = Iterators.flat(Iterators.map(getReprsByName(className, ClassFileRepr.class), repr -> repr.getUsages())); } for (Integer owner : Iterators.unique(Iterators.map(usages, usage -> usage.getOwner()))) { if (owner != className) { buffer.put(owner, className); } } }
cleanupBackDependency
1,099
void (final Mappings delta, final @NotNull ClassFileRepr cr, File sourceFile, final Set<? extends UsageRepr.Usage> usages, final IntIntMultiMaplet dependenciesTrashBin) { final int className = cr.name; // it is safe to cleanup class information if it is mapped to non-existing files only final Iterable<File> currentlyMapped = classToSourceFileGet(className); if (currentlyMapped != null) { for (File file : currentlyMapped) { if (!FileUtil.filesEqual(sourceFile, file) && file.exists()) { // if classname is already mapped to a different source, the class with such FQ name exists elsewhere, so we cannot destroy all these links // additionally ensure association with particular sourceFile is removed myClassToRelativeSourceFilePath.removeFrom(className, toRelative(sourceFile)); return; } } } if (cr instanceof ClassRepr) { for (final TypeRepr.ClassType superSomething : ((ClassRepr)cr).getSuperTypes()) { delta.registerRemovedSuperClass(className, superSomething.className); } } cleanupBackDependency(className, usages, dependenciesTrashBin); myClassToClassDependency.remove(className); myClassToSubclasses.remove(className); myClassToRelativeSourceFilePath.remove(className); if (cr instanceof ClassRepr) { final ClassRepr _cr = (ClassRepr)cr; if (!_cr.isLocal() && !_cr.isAnonymous()) { myShortClassNameIndex.removeFrom(myContext.get(_cr.getShortName()), className); } } }
cleanupRemovedClass