Unnamed: 0
int64 0
305k
| body
stringlengths 7
52.9k
| name
stringlengths 1
185
|
---|---|---|
2,600 |
void (final String key, final String nsPrefix, final String nsURI, final String value, final String type) { }
|
addAttribute
|
2,601 |
void (final String name, final String nsPrefix, final String nsURI) { }
|
elementAttributesProcessed
|
2,602 |
void (final String name, final String nsPrefix, final String nsURI) { }
|
endElement
|
2,603 |
void (final Reader reader, final String systemID, final int lineNr) { }
|
addPCData
|
2,604 |
void () { throw new ParserStoppedException(); }
|
stop
|
2,605 |
void (ClassPostProcessor processor) { ourClassProcessors.add(processor); }
|
registerClassPostProcessor
|
2,606 |
String () { return StringUtil.capitalize(getBuilderName()); }
|
getPresentableName
|
2,607 |
void (CompileContext context) { final String compilerId = getUsedCompilerId(context); if (LOG.isDebugEnabled()) { LOG.debug("Java compiler ID: " + compilerId); } MODULE_PATH_SPLITTER.set(context, new ModulePathSplitter(new ExplodedModuleNameFinder(context))); JavaCompilingTool compilingTool = JavaBuilderUtil.findCompilingTool(compilerId); COMPILING_TOOL.set(context, compilingTool); SHOWN_NOTIFICATIONS.set(context, Collections.synchronizedSet(new HashSet<>())); COMPILER_USAGE_STATISTICS.set(context, new ConcurrentHashMap<>()); BuildDataManager dataManager = context.getProjectDescriptor().dataManager; if (!isJavac(compilingTool)) { dataManager.setProcessConstantsIncrementally(false); } JavaBackwardReferenceIndexWriter.initialize(context); for (JavacFileReferencesRegistrar registrar : JpsServiceManager.getInstance().getExtensions(JavacFileReferencesRegistrar.class)) { if (registrar.isEnabled()) { registrar.initialize(); myRefRegistrars.add(registrar); } } }
|
buildStarted
|
2,608 |
void (final CompileContext context, final ModuleChunk chunk) { // before the first compilation round starts: find and mark dirty all classes that depend on removed or moved classes so // that all such files are compiled in the first round. try { JavaBuilderUtil.markDirtyDependenciesForInitialRound(context, new DirtyFilesHolderBase<JavaSourceRootDescriptor, ModuleBuildTarget>(context) { @Override public void processDirtyFiles(@NotNull FileProcessor<JavaSourceRootDescriptor, ModuleBuildTarget> processor) throws IOException { FSOperations.processFilesToRecompile(context, chunk, processor); } }, chunk); } catch (IOException e) { throw new RuntimeException(e); } }
|
chunkBuildStarted
|
2,609 |
void (CompileContext context) { myRefRegistrars.clear(); final ConcurrentMap<String, Collection<String>> stats = COMPILER_USAGE_STATISTICS.get(context); if (stats.size() == 1) { final Map.Entry<String, Collection<String>> entry = stats.entrySet().iterator().next(); final String compilerName = entry.getKey(); context.processMessage(new CompilerMessage("", BuildMessage.Kind.JPS_INFO, JpsBuildBundle.message("build.message.0.was.used.to.compile.java.sources", compilerName))); LOG.info(compilerName + " was used to compile " + entry.getValue()); } else { for (Map.Entry<String, Collection<String>> entry : stats.entrySet()) { final String compilerName = entry.getKey(); final Collection<String> moduleNames = entry.getValue(); context.processMessage(new CompilerMessage("", BuildMessage.Kind.JPS_INFO, moduleNames.size() == 1 ? JpsBuildBundle.message("build.message.0.was.used.to.compile.1", compilerName, moduleNames.iterator().next()) : JpsBuildBundle.message("build.message.0.was.used.to.compile.1.modules", compilerName, moduleNames.size()) )); LOG.info(compilerName + " was used to compile " + moduleNames); } } }
|
buildFinished
|
2,610 |
List<String> () { return COMPILABLE_EXTENSIONS; }
|
getCompilableFileExtensions
|
2,611 |
Collection<String> (Iterable<String> options) { // --add-reads module=other-module(,other-module)* // The option specifies additional modules to be considered as required by a given module. final Set<String> result = new SmartHashSet<>(); for (Iterator<String> it = options.iterator(); it.hasNext(); ) { final String option = it.next(); if ("--add-reads".equalsIgnoreCase(option) && it.hasNext()) { final String moduleNames = StringUtil.substringAfter(it.next(), "="); if (moduleNames != null) { result.addAll(StringUtil.split(moduleNames, ",")); } } } return result; }
|
collectAdditionalRequires
|
2,612 |
void (ModuleChunk chunk, Iterable<String> options, final String mode) { if (LOG.isDebugEnabled()) { LOG.debug((Iterators.contains(options, PROC_ONLY_OPTION)? "Running processors for chunk" : "Compiling chunk") + " [" + chunk.getName() + "] with options: \"" + StringUtil.join(options, " ") + "\", mode=" + mode); } }
|
logJavacCall
|
2,613 |
boolean ( int compilerSdkVersion, CompileContext context, ModuleChunk chunk, @NotNull JavaCompilingTool compilingTool, Iterable<String> options, Iterable<? extends File> files, OutputFileConsumer outSink, JavacCaller javacCall ) { if (Iterators.contains(options, PROC_ONLY_OPTION)) { // make a dedicated javac call for annotation processing only final Collection<File> generated = new ArrayList<>(); final boolean processingSuccess = javacCall.invoke(options, files, fileObject -> { if (fileObject.getKind() == JavaFileObject.Kind.SOURCE) { generated.add(fileObject.getFile()); } outSink.save(fileObject); }); if (!processingSuccess) { return false; } // now call javac with processor-generated sources and without processing-related options final Iterable<String> compileOnlyOptions = getCompilationOptions(compilerSdkVersion, context, chunk, null, compilingTool).second; return javacCall.invoke(compileOnlyOptions, Iterators.flat(files, generated), outSink); } return javacCall.invoke(options, files, outSink); }
|
invokeJavac
|
2,614 |
void (CompileContext context, String compilerName, ModuleChunk chunk) { final ConcurrentMap<String, Collection<String>> map = COMPILER_USAGE_STATISTICS.get(context); Collection<String> names = map.get(compilerName); if (names == null) { names = Collections.synchronizedSet(new HashSet<>()); final Collection<String> prev = map.putIfAbsent(compilerName, names); if (prev != null) { names = prev; } } for (JpsModule module : chunk.getModules()) { names.add(module.getName()); } }
|
updateCompilerUsageStatistics
|
2,615 |
Set<String> (String str) { final Set<String> result = new SmartHashSet<>(); StringTokenizer t = new StringTokenizer(str, " \n\t", false); while (t.hasMoreTokens()) { result.add(t.nextToken()); } return result; }
|
parseOptions
|
2,616 |
boolean (JpsJavaCompilerConfiguration config, int compilerVersion, int chunkSdkVersion, int targetPlatformVersion) { if (!config.useReleaseOption()) { return false; } // --release option is supported in java9+ and higher if (compilerVersion >= 9 && chunkSdkVersion > 0 && targetPlatformVersion > 0) { if (chunkSdkVersion < 9) { // target sdk is set explicitly and differs from compiler SDK, so for consistency we should link against it return false; } // chunkSdkVersion >= 9, so we have no rt.jar anymore and '-release' is the only cross-compilation option available // Only specify '--release' when cross-compilation is indeed really required. // Otherwise '--release' may not be compatible with other compilation options, e.g. exporting a package from system module return compilerVersion != targetPlatformVersion; } return false; }
|
shouldUseReleaseOption
|
2,617 |
boolean (CompileContext context, ModuleChunk chunk, int chunkLanguageLevel, JavaCompilingTool compilingTool) { if (!isJavac(compilingTool)) { return false; // applicable to javac only } final int compilerSdkVersion = JavaVersion.current().feature; if (preferTargetJdkCompiler(context)) { final Pair<JpsSdk<JpsDummyElement>, Integer> sdkVersionPair = getAssociatedSdk(chunk); if (sdkVersionPair != null) { final Integer chunkSdkVersion = sdkVersionPair.second; if (chunkSdkVersion != compilerSdkVersion && chunkSdkVersion >= ExternalJavacProcess.MINIMUM_REQUIRED_JAVA_VERSION) { // there is a special case because of difference in type inference behavior between javac8 and javac6-javac7 // so if corresponding JDK is associated with the module chunk, prefer compiler from this JDK over the newer compiler version return true; } } } if (chunkLanguageLevel <= 0) { // was not able to determine jdk version, so assuming in-process compiler return false; } return !isTargetReleaseSupported(compilerSdkVersion, chunkLanguageLevel); }
|
shouldForkCompilerProcess
|
2,618 |
boolean (int compilerVersion, int targetPlatformVersion) { if (targetPlatformVersion > compilerVersion) { return false; } if (compilerVersion < 9) { return true; } if (compilerVersion <= 11) { return targetPlatformVersion >= 6; } return targetPlatformVersion >= 7; }
|
isTargetReleaseSupported
|
2,619 |
boolean (final JavaCompilingTool compilingTool) { return compilingTool != null && (compilingTool.getId().equals(JavaCompilers.JAVAC_ID) || compilingTool.getId().equals(JavaCompilers.JAVAC_API_ID)); }
|
isJavac
|
2,620 |
boolean (CompileContext context) { Boolean val = PREFER_TARGET_JDK_COMPILER.get(context); if (val == null) { JpsJavaCompilerConfiguration config = JpsJavaExtensionService.getInstance().getCompilerConfiguration(context.getProjectDescriptor().getProject()); // default PREFER_TARGET_JDK_COMPILER.set(context, val = config.getCompilerOptions(JavaCompilers.JAVAC_ID).PREFER_TARGET_JDK_COMPILER); } return val; }
|
preferTargetJdkCompiler
|
2,621 |
void (final CompileContext context, final Runnable taskRunnable) { Semaphore counter = COUNTER_KEY.get(context); assert counter != null; counter.down(); myTaskRunner.execute(() -> { try { taskRunnable.run(); } catch (Throwable e) { context.processMessage(new CompilerMessage(getBuilderName(), e)); } finally { counter.up(); } }); }
|
submitAsyncTask
|
2,622 |
ExternalJavacProcessHandler (UUID processId, @NotNull Process process, @NotNull String commandLine, boolean keepProcessAlive) { return new ExternalJavacProcessHandler(processId, process, commandLine, keepProcessAlive) { @Override public @NotNull Future<?> executeTask(@NotNull Runnable task) { return SharedThreadPool.getInstance().submit(task); } @Override protected @NotNull BaseOutputReader.Options readerOptions() { return BaseOutputReader.Options.NON_BLOCKING; } }; }
|
createProcessHandler
|
2,623 |
int () { try { final ServerSocket serverSocket = new ServerSocket(0); try { return serverSocket.getLocalPort(); } finally { //workaround for linux : calling close() immediately after opening socket //may result that socket is not closed synchronized (serverSocket) { try { serverSocket.wait(1); } catch (Throwable ignored) { } } serverSocket.close(); } } catch (IOException e) { e.printStackTrace(System.err); return ExternalJavacManager.DEFAULT_SERVER_PORT; } }
|
findFreePort
|
2,624 |
void (CompileContext context, String option, ModuleChunk chunk) { notifyMessage(context, BuildMessage.Kind.JPS_INFO, "build.message.user.specified.option.0.for.1.may.conflict.with.calculated.option", false, option, chunk.getPresentableShortName()); }
|
notifyOptionPossibleConflicts
|
2,625 |
void (CompileContext context, String option, ModuleChunk chunk) { notifyMessage(context, BuildMessage.Kind.JPS_INFO, "build.message.user.specified.option.0.is.ignored.for.1", false, option, chunk.getPresentableShortName()); }
|
notifyOptionIgnored
|
2,626 |
void (CompileContext context, final BuildMessage.Kind kind, final String messageKey, boolean notifyOnce, Object... params) { if (!notifyOnce || SHOWN_NOTIFICATIONS.get(context).add(messageKey)) { context.processMessage(new CompilerMessage(getBuilderName(), kind, JpsBuildBundle.message(messageKey, params))); } }
|
notifyMessage
|
2,627 |
void (List<? super String> options, CompileContext context, ModuleChunk chunk, @Nullable ProcessorConfigProfile profile) { addCompilationOptions(JavaVersion.current().feature, options, context, chunk, profile, false); }
|
addCompilationOptions
|
2,628 |
void (int compilerSdkVersion, List<? super String> options, CompileContext context, ModuleChunk chunk, @Nullable ProcessorConfigProfile profile, boolean procOnlySupported) { if (!options.contains(ENCODING_OPTION)) { final CompilerEncodingConfiguration config = context.getProjectDescriptor().getEncodingConfiguration(); final String encoding = config.getPreferredModuleChunkEncoding(chunk); if (config.getAllModuleChunkEncodings(chunk).size() > 1) { String message = JpsBuildBundle.message("build.message.multiple.encodings.set.for.module.chunk", chunk.getName(), encoding, encoding != null ? 0 : 1); context.processMessage(new CompilerMessage(getBuilderName(), BuildMessage.Kind.INFO, message)); } if (!StringUtil.isEmpty(encoding)) { options.add(ENCODING_OPTION); options.add(encoding); } } addCrossCompilationOptions(compilerSdkVersion, options, context, chunk); if (!options.contains(ENABLE_PREVIEW_OPTION)) { LanguageLevel level = JpsJavaExtensionService.getInstance().getLanguageLevel(chunk.representativeTarget().getModule()); if (level != null && level.isPreview()) { options.add(ENABLE_PREVIEW_OPTION); } } if (addAnnotationProcessingOptions(options, profile)) { assert profile != null; if (procOnlySupported && profile.isProcOnly()) { options.add(PROC_ONLY_OPTION); } final File srcOutput = ProjectPaths.getAnnotationProcessorGeneratedSourcesOutputDir( chunk.getModules().iterator().next(), chunk.containsTests(), profile ); if (srcOutput != null) { FileUtil.createDirectory(srcOutput); options.add("-s"); options.add(srcOutput.getPath()); } } }
|
addCompilationOptions
|
2,629 |
boolean (List<? super String> options, @Nullable AnnotationProcessingConfiguration profile) { if (profile == null || !profile.isEnabled()) { options.add(PROC_NONE_OPTION); return false; } // configuring annotation processing if (!profile.isObtainProcessorsFromClasspath()) { final String processorsPath = profile.getProcessorPath(); options.add(profile.isUseProcessorModulePath() ? PROCESSOR_MODULE_PATH_OPTION : PROCESSORPATH_OPTION); options.add(FileUtil.toSystemDependentName(processorsPath.trim())); } final Set<String> processors = profile.getProcessors(); if (!processors.isEmpty()) { options.add("-processor"); options.add(StringUtil.join(processors, ",")); } for (Map.Entry<String, String> optionEntry : profile.getProcessorOptions().entrySet()) { options.add("-A" + optionEntry.getKey() + "=" + optionEntry.getValue()); } return true; }
|
addAnnotationProcessingOptions
|
2,630 |
String (CompileContext context) { final JpsProject project = context.getProjectDescriptor().getProject(); return JpsJavaExtensionService.getInstance().getCompilerConfiguration(project).getJavaCompilerId(); }
|
getUsedCompilerId
|
2,631 |
void (int compilerSdkVersion, List<? super String> options, CompileContext context, ModuleChunk chunk) { final JpsJavaCompilerConfiguration compilerConfiguration = JpsJavaExtensionService.getInstance().getCompilerConfiguration( context.getProjectDescriptor().getProject() ); @NotNull JpsModule module = chunk.representativeTarget().getModule(); final LanguageLevel level = JpsJavaExtensionService.getInstance().getLanguageLevel(module); final int languageLevel = level != null ? level.toJavaVersion().feature : 0; final int chunkSdkVersion = getChunkSdkVersion(chunk); int bytecodeTarget = getModuleBytecodeTarget(context, chunk, compilerConfiguration, (level == LanguageLevel.JDK_X) ? chunkSdkVersion : languageLevel); if (shouldUseReleaseOption(compilerConfiguration, compilerSdkVersion, chunkSdkVersion, bytecodeTarget)) { options.add(RELEASE_OPTION); options.add(level == LanguageLevel.JDK_X ? complianceOption(chunkSdkVersion) : complianceOption(bytecodeTarget)); return; } // using older -source, -target and -bootclasspath options if (languageLevel > 0 && !options.contains(SOURCE_OPTION)) { options.add(SOURCE_OPTION); options.add(level == LanguageLevel.JDK_X ? complianceOption(chunkSdkVersion) : complianceOption(languageLevel)); } if (bytecodeTarget > 0) { if (chunkSdkVersion > 0 && compilerSdkVersion > chunkSdkVersion) { // if compiler is newer than module JDK if (compilerSdkVersion >= bytecodeTarget) { // if user-specified bytecode version can be determined and is supported by compiler if (bytecodeTarget > chunkSdkVersion) { // and user-specified bytecode target level is higher than the highest one supported by the target JDK, // force compiler to use highest-available bytecode target version that is supported by the chunk JDK. bytecodeTarget = chunkSdkVersion; } } // otherwise let compiler display compilation error about incorrectly set bytecode target version } } else { if (chunkSdkVersion > 0 && compilerSdkVersion > chunkSdkVersion) { // force lower bytecode target level to match the version of the chunk JDK bytecodeTarget = chunkSdkVersion; } } if (bytecodeTarget > 0) { options.add(TARGET_OPTION); options.add(complianceOption(bytecodeTarget)); } }
|
addCrossCompilationOptions
|
2,632 |
int (CompileContext context, ModuleChunk chunk, JpsJavaCompilerConfiguration compilerConfiguration) { return getModuleBytecodeTarget(context, chunk, compilerConfiguration, getLanguageLevel(chunk.representativeTarget().getModule())); }
|
getModuleBytecodeTarget
|
2,633 |
int (CompileContext context, ModuleChunk chunk, JpsJavaCompilerConfiguration compilerConfiguration, int languageLevel) { int bytecodeTarget = 0; for (JpsModule module : chunk.getModules()) { // use the lower possible target among modules that form the chunk final int moduleTarget = JpsJavaSdkType.parseVersion(compilerConfiguration.getByteCodeTargetLevel(module.getName())); if (moduleTarget > 0 && (bytecodeTarget == 0 || moduleTarget < bytecodeTarget)) { bytecodeTarget = moduleTarget; } } if (bytecodeTarget == 0) { if (languageLevel > 0) { // according to IDEA rule: if not specified explicitly, set target to be the same as source language level bytecodeTarget = languageLevel; } else { // last resort and backward compatibility: // check if user explicitly defined bytecode target in additional compiler options String value = USER_DEFINED_BYTECODE_TARGET.get(context); if (value != null) { bytecodeTarget = JpsJavaSdkType.parseVersion(value); } } } return bytecodeTarget; }
|
getModuleBytecodeTarget
|
2,634 |
String (int major) { return JpsJavaSdkType.complianceOption(JavaVersion.compose(major)); }
|
complianceOption
|
2,635 |
int (@NotNull JpsModule module) { final LanguageLevel level = JpsJavaExtensionService.getInstance().getLanguageLevel(module); return level != null ? level.toJavaVersion().feature : 0; }
|
getLanguageLevel
|
2,636 |
int (@NotNull JpsModule module) { final int level = getLanguageLevel(module); if (level > 0) { return level; } // when compiling, if language level is not explicitly set, it is assumed to be equal to // the highest possible language level supported by target JDK final JpsSdk<JpsDummyElement> sdk = module.getSdk(JpsJavaSdkType.INSTANCE); if (sdk != null) { return JpsJavaSdkType.getJavaVersion(sdk); } return 0; }
|
getTargetPlatformLanguageVersion
|
2,637 |
int (ModuleChunk chunk) { int chunkSdkVersion = -1; for (JpsModule module : chunk.getModules()) { final JpsSdk<JpsDummyElement> sdk = module.getSdk(JpsJavaSdkType.INSTANCE); if (sdk != null) { final int moduleSdkVersion = JpsJavaSdkType.getJavaVersion(sdk); if (moduleSdkVersion != 0 /*could determine the version*/ && (chunkSdkVersion < 0 || chunkSdkVersion > moduleSdkVersion)) { chunkSdkVersion = moduleSdkVersion; } } } return chunkSdkVersion; }
|
getChunkSdkVersion
|
2,638 |
void (CompileContext context, ModuleChunk chunk) { JavaBuilderUtil.cleanupChunkResources(context); ExternalJavacManager extJavacManager = ExternalJavacManager.KEY.get(context); if (extJavacManager != null) { extJavacManager.shutdownIdleProcesses(); } }
|
chunkBuildFinished
|
2,639 |
void (File file) { }
|
javaFileLoaded
|
2,640 |
void (JavacFileData data) { for (JavacFileReferencesRegistrar registrar : myRegistrars) { registrar.registerFile(myContext, data.getFilePath(), Iterators.map(data.getRefs().entrySet(), entry -> entry), data.getDefs(), data.getCasts(), data.getImplicitToStringRefs()); } }
|
registerJavacFileData
|
2,641 |
void (String pluginId, String dataName, byte[] data) { if (JavacFileData.CUSTOM_DATA_PLUGIN_ID.equals(pluginId) && JavacFileData.CUSTOM_DATA_KIND.equals(dataName)) { registerJavacFileData(JavacFileData.fromBytes(data)); } else { for (CustomOutputDataListener listener : JpsServiceManager.getInstance().getExtensions(CustomOutputDataListener.class)) { if (pluginId.equals(listener.getId())) { listener.processData(myContext, dataName, data); return; } } } }
|
customOutputData
|
2,642 |
void (@NlsSafe String line) { if (!StringUtil.isEmpty(line)) { if (line.startsWith(ExternalJavacManager.STDOUT_LINE_PREFIX)) { //noinspection UseOfSystemOutOrSystemErr System.out.println(line); if (LOG.isDebugEnabled()) { LOG.debug(line); } } else if (line.startsWith(ExternalJavacManager.STDERR_LINE_PREFIX)) { //noinspection UseOfSystemOutOrSystemErr System.err.println(line); if (LOG.isDebugEnabled()) { LOG.debug(line); } } else if (line.contains("java.lang.OutOfMemoryError")) { myContext.processMessage(new CompilerMessage(getBuilderName(), BuildMessage.Kind.ERROR, JpsBuildBundle.message("build.message.insufficient.memory"))); myErrorCount.incrementAndGet(); } else { myContext.processMessage(new CompilerMessage(getBuilderName(), BuildMessage.Kind.INFO, line)); } } }
|
outputLineAvailable
|
2,643 |
void (Diagnostic<? extends JavaFileObject> diagnostic) { final CompilerMessage.Kind kind; switch (diagnostic.getKind()) { case ERROR: kind = BuildMessage.Kind.ERROR; myErrorCount.incrementAndGet(); break; case MANDATORY_WARNING: case WARNING: kind = BuildMessage.Kind.WARNING; myWarningCount.incrementAndGet(); break; case NOTE: kind = BuildMessage.Kind.INFO; break; case OTHER: kind = diagnostic instanceof JpsInfoDiagnostic? BuildMessage.Kind.JPS_INFO : BuildMessage.Kind.OTHER; break; default: kind = BuildMessage.Kind.OTHER; } File sourceFile = null; try { // for eclipse compiler just an attempt to call getSource() may lead to an NPE, // so calling this method under try/catch to avoid induced compiler errors final JavaFileObject source = diagnostic.getSource(); sourceFile = source != null ? new File(source.toUri()) : null; } catch (Exception e) { LOG.info(e); } final String srcPath; if (sourceFile != null) { if (kind == BuildMessage.Kind.ERROR) { myFilesWithErrors.add(sourceFile); } srcPath = FileUtil.toSystemIndependentName(sourceFile.getPath()); } else { srcPath = null; } String message = diagnostic.getMessage(Locale.US); if (Utils.IS_TEST_MODE) { LOG.info(message); } final CompilerMessage compilerMsg = new CompilerMessage( getBuilderName(), kind, message, srcPath, diagnostic.getStartPosition(), diagnostic.getEndPosition(), diagnostic.getPosition(), diagnostic.getLineNumber(), diagnostic.getColumnNumber() ); if (LOG.isDebugEnabled()) { LOG.debug(compilerMsg.toString()); } myContext.processMessage(compilerMsg); }
|
report
|
2,644 |
String (File outputDir) { for (BuildTarget<?> target : myOutsIndex.getTargetsByOutputFile(outputDir)) { if (target instanceof ModuleBasedTarget) { return ((ModuleBasedTarget<?>)target).getModule().getName().trim(); } } return ModulePathSplitter.DEFAULT_MODULE_NAME_SEARCH.apply(outputDir); }
|
apply
|
2,645 |
void (final @NotNull OutputFileObject fileObject) { // generated files must be saved synchronously, because some compilers (e.g. eclipse) // may want to read them for further compilation try { final BinaryContent content = fileObject.getContent(); final File file = fileObject.getFile(); if (content != null) { content.saveToFile(file); } else { myContext.processMessage(new CompilerMessage( getBuilderName(), BuildMessage.Kind.WARNING, JpsBuildBundle.message("build.message.missing.content.for.file.0", file.getPath())) ); } } catch (IOException e) { myContext.processMessage(new CompilerMessage(getBuilderName(), BuildMessage.Kind.ERROR, e.getMessage())); } submitAsyncTask(myContext, () -> { try { for (ClassPostProcessor processor : ourClassProcessors) { processor.process(myContext, fileObject); } } finally { myDelegateOutputFileSink.save(fileObject); } }); }
|
save
|
2,646 |
long () { return 100; }
|
getExpectedBuildTime
|
2,647 |
String (String fName) { if (fName != null) { fName = NON_ALPHANUM.matcher(fName).replaceAll("."); // collapse repeating dots fName = REPEATING_DOTS.matcher(fName).replaceAll("."); // drop leading and trailing dots final int len = fName.length(); if (len > 0) { final int start = fName.startsWith(".") ? 1 : 0; final int end = fName.endsWith(".") ? len - 1 : len; if (start > 0 || end < len) { fName = fName.substring(start, end); } } } return fName; }
|
normalizeModuleName
|
2,648 |
Set<String> (File chunkModuleInfo, Iterable<? extends File> path) { final Set<String> result = new HashSet<>(); // first, add all requires from chunk module-info final JavaModuleDescriptor chunkDescr = new JavaProjectBuilder(new OrderedClassLibraryBuilder()).addSourceFolder(chunkModuleInfo.getParentFile()).getDescriptor(); for (JavaModuleDescriptor.JavaRequires require : chunkDescr.getRequires()) { final JavaModule rm = require.getModule(); if (rm != null) { result.add(rm.getName()); } } for (File file : path) { result.addAll(getModuleInfo(file).requires); } return result; }
|
collectRequired
|
2,649 |
ModuleInfo (File f) { ModuleInfo info = myCache.get(f); if (info != null) { return info; } info = ModuleInfo.EMPTY; try { Object mf = myModuleFinderCreateMethod.invoke(null, (Object)new Path[]{f.toPath()}); // ModuleFinder.of(f.toPath()); final Set<?> moduleRefs = (Set<?>)myFindAll.invoke(mf); // mf.findAll() if (!moduleRefs.isEmpty()) { for (Object moduleRef : moduleRefs) { final Object descriptor = myGetDescriptor.invoke(moduleRef); // moduleRef.descriptor() final String moduleName = (String)myDescriptorName.invoke(descriptor); // descriptor.name(); final Set<?> requires = (Set<?>)myDescriptorRequires.invoke(descriptor); //descriptor.requires(); if (requires.isEmpty()) { info = new ModuleInfo(moduleName, false); } else { final Set<String> req = new HashSet<>(); for (Object require : requires) { req.add((String)myRequiresName.invoke(require)/*require.name()*/); } info = new ModuleInfo(moduleName, req); } break; } } else { final String explodedModuleName = deriveAutomaticModuleName(f); if (explodedModuleName != null) { info = new ModuleInfo(explodedModuleName, true); } } } catch (Throwable ignored) { } myCache.put(f, info); return info; }
|
getModuleInfo
|
2,650 |
String (File dir) { if (dir.isDirectory()) { try (BufferedInputStream is = new BufferedInputStream(new FileInputStream(new File(dir, "META-INF/MANIFEST.MF")))) { final String name = new Manifest(is).getMainAttributes().getValue(AUTOMATIC_MODULE_NAME); return name != null ? name : normalizeModuleName(myModuleNameSearch.apply(dir)); } catch (FileNotFoundException e) { return normalizeModuleName(myModuleNameSearch.apply(dir)); // inferring the module name from the dir } catch (Throwable ignored) { } } return null; }
|
deriveAutomaticModuleName
|
2,651 |
void (final BuildRootDescriptor rd) { getDelta(rd.getTarget()).clearRecompile(rd); }
|
clearRecompile
|
2,652 |
long (File file) { synchronized (myRegistrationStamps) { return myRegistrationStamps.getLong(file); } }
|
getEventRegistrationStamp
|
2,653 |
boolean (BuildTarget<?> target) { if (!myInitialScanPerformed.contains(target)) { return true; } FilesDelta delta = myDeltas.get(target); return delta != null && delta.hasChanges(); }
|
hasWorkToDo
|
2,654 |
boolean (@NotNull CompileContext context, @NotNull BuildTarget<?> target) { if (!myInitialScanPerformed.contains(target)) { return false; } final FilesDelta delta = myDeltas.get(target); if (delta == null) { return false; } final long targetBuildStart = context.getCompilationStartStamp(target); if (targetBuildStart <= 0L) { return false; } final CompileScope scope = context.getScope(); final BuildRootIndex rootIndex = context.getProjectDescriptor().getBuildRootIndex(); try { delta.lockData(); final long now = System.currentTimeMillis(); for (Set<File> files : delta.getSourcesToRecompile().values()) { files_loop: for (File file : files) { final long fileStamp; if (getEventRegistrationStamp(file) > targetBuildStart || (fileStamp = FSOperations.lastModified(file)) > targetBuildStart && fileStamp < now) { if (scope.isAffected(target, file)) { for (BuildRootDescriptor rd : rootIndex.findAllParentDescriptors(file, context)) { if (rd.isGenerated()) { // do not send notification for generated sources continue files_loop; } } if (LOG.isDebugEnabled()) { LOG.debug("Unprocessed changes detected for target " + target + "; file: " + file.getPath() + "; targetBuildStart=" + targetBuildStart + "; eventRegistrationStamp=" + getEventRegistrationStamp(file) + "; lastModified=" + FSOperations.lastModified(file) ); } return true; } } } } } finally { delta.unlockData(); } return false; }
|
hasUnprocessedChanges
|
2,655 |
void (BuildTarget<?> target) { myInitialScanPerformed.add(target); }
|
markInitialScanPerformed
|
2,656 |
void (@Nullable CompileContext context, BuildTarget<?> target, final File file) { final FilesDelta currentDelta = getRoundDelta(CURRENT_ROUND_DELTA_KEY, context); if (currentDelta != null) { currentDelta.addDeleted(file); } final FilesDelta nextDelta = getRoundDelta(NEXT_ROUND_DELTA_KEY, context); if (nextDelta != null) { nextDelta.addDeleted(file); } getDelta(target).addDeleted(file); }
|
registerDeleted
|
2,657 |
void (BuildTarget<?> target) { final FilesDelta delta = myDeltas.get(target); if (delta != null) { delta.clearDeletedPaths(); } }
|
clearDeletedPaths
|
2,658 |
Collection<String> (BuildTarget<?> target) { final FilesDelta delta = myDeltas.get(target); if (delta != null) { return delta.getAndClearDeletedPaths(); } return Collections.emptyList(); }
|
getAndClearDeletedPaths
|
2,659 |
FilesDelta (BuildTarget<?> buildTarget) { synchronized (myDeltas) { FilesDelta delta = myDeltas.get(buildTarget); if (delta == null) { delta = new FilesDelta(); myDeltas.put(buildTarget, delta); } return delta; } }
|
getDelta
|
2,660 |
boolean (BuildTarget<?> target) { return !myAlwaysScanFS && myInitialScanPerformed.contains(target); }
|
isInitialScanPerformed
|
2,661 |
FilesDelta (@NotNull CompileContext context, BuildTarget<?> target) { if (target instanceof ModuleBuildTarget) { // multiple compilation rounds are applicable to ModuleBuildTarget only final FilesDelta lastRoundDelta = getRoundDelta(CURRENT_ROUND_DELTA_KEY, context); if (lastRoundDelta != null) { return lastRoundDelta; } } return getDelta(target); }
|
getEffectiveFilesDelta
|
2,662 |
boolean (@Nullable CompileContext context, CompilationRound round, BuildRootDescriptor rd, File file) { FilesDelta delta = getRoundDelta(round == CompilationRound.NEXT? NEXT_ROUND_DELTA_KEY : CURRENT_ROUND_DELTA_KEY, context); if (delta == null) { delta = getDelta(rd.getTarget()); } return delta.isMarkedRecompile(rd, file); }
|
isMarkedForRecompilation
|
2,663 |
boolean (CompileContext context, BuildRootDescriptor rd) { if (context == null) { return false; } Set<? extends BuildTarget<?>> targets = CONTEXT_TARGETS_KEY.get(context, Collections.emptySet()); return targets.contains(rd.getTarget()); }
|
isInCurrentContextTargets
|
2,664 |
void () { clearContextRoundData(null); clearContextChunk(null); myInitialScanPerformed.clear(); myDeltas.clear(); synchronized (myRegistrationStamps) { myRegistrationStamps.clear(); } }
|
clearAll
|
2,665 |
void (@Nullable CompileContext context) { setRoundDelta(NEXT_ROUND_DELTA_KEY, context, null); setRoundDelta(CURRENT_ROUND_DELTA_KEY, context, null); }
|
clearContextRoundData
|
2,666 |
void (@Nullable CompileContext context) { setContextTargets(context, null); }
|
clearContextChunk
|
2,667 |
void (@NotNull CompileContext context, BuildTargetChunk chunk) { setContextTargets(context, chunk.getTargets()); }
|
beforeChunkBuildStart
|
2,668 |
void (@NotNull CompileContext context, ModuleChunk chunk) { FilesDelta currentDelta = getRoundDelta(NEXT_ROUND_DELTA_KEY, context); if (currentDelta == null) { // this is the initial round. // Need to make a snapshot of the FS state so that all builders in the chain see the same picture final List<FilesDelta> deltas = new SmartList<>(); for (ModuleBuildTarget target : chunk.getTargets()) { deltas.add(getDelta(target)); } currentDelta = new FilesDelta(deltas); } setRoundDelta(CURRENT_ROUND_DELTA_KEY, context, currentDelta); setRoundDelta(NEXT_ROUND_DELTA_KEY, context, new FilesDelta()); }
|
beforeNextRoundStart
|
2,669 |
void (@Nullable CompileContext context, @Nullable Set<? extends BuildTarget<?>> targets) { if (context != null) { CONTEXT_TARGETS_KEY.set(context, targets); } }
|
setContextTargets
|
2,670 |
void (@NotNull Key<FilesDelta> key, @Nullable CompileContext context, @Nullable FilesDelta delta) { if (context != null) { key.set(context, delta); } }
|
setRoundDelta
|
2,671 |
void () { myDataLock.lock(); }
|
lockData
|
2,672 |
void () { myDataLock.unlock(); }
|
unlockData
|
2,673 |
void (FilesDelta other) { other.lockData(); try { myDeletedPaths.addAll(other.myDeletedPaths); for (Map.Entry<BuildRootDescriptor, Set<File>> entry : other.myFilesToRecompile.entrySet()) { _addToRecompiled(entry.getKey(), entry.getValue()); } } finally { other.unlockData(); } }
|
addAll
|
2,674 |
boolean () { lockData(); try { if (!myDeletedPaths.isEmpty()) { return true; } if(!myFilesToRecompile.isEmpty()) { for (Set<File> files : myFilesToRecompile.values()) { if (!files.isEmpty()) { return true; } } } return false; } finally { unlockData(); } }
|
hasChanges
|
2,675 |
boolean (BuildRootDescriptor root, File file) { lockData(); try { final boolean added = _addToRecompiled(root, file); if (added) { if (!myDeletedPaths.isEmpty()) { // optimization myDeletedPaths.remove(FileUtil.toCanonicalPath(file.getPath())); } } return added; } finally { unlockData(); } }
|
markRecompile
|
2,676 |
boolean (BuildRootDescriptor root, File file) { lockData(); try { String path = null; final boolean isMarkedDeleted = !myDeletedPaths.isEmpty() && myDeletedPaths.contains(path = FileUtil.toCanonicalPath(file.getPath())); if (!isMarkedDeleted) { if (!file.exists()) { // incorrect paths data recovery, so that the next make should not contain non-existing sources in 'recompile' list if (path == null) { path = FileUtil.toCanonicalPath(file.getPath()); } if (Utils.IS_TEST_MODE) { LOG.info("Marking deleted: " + path); } myDeletedPaths.add(path); return false; } _addToRecompiled(root, file); return true; } return false; } finally { unlockData(); } }
|
markRecompileIfNotDeleted
|
2,677 |
boolean (BuildRootDescriptor root, File file) { if (Utils.IS_TEST_MODE) { LOG.info("Marking dirty: " + file.getPath()); } return _addToRecompiled(root, Collections.singleton(file)); }
|
_addToRecompiled
|
2,678 |
boolean (BuildRootDescriptor root, Collection<? extends File> filesToAdd) { Set<File> files = myFilesToRecompile.get(root); if (files == null) { files = FileCollectionFactory.createCanonicalFileLinkedSet(); myFilesToRecompile.put(root, files); } return files.addAll(filesToAdd); }
|
_addToRecompiled
|
2,679 |
void (File file) { final String path = FileUtil.toCanonicalPath(file.getPath()); lockData(); try { // ensure the file is not marked to recompilation anymore for (Set<File> files : myFilesToRecompile.values()) { files.remove(file); } myDeletedPaths.add(path); if (Utils.IS_TEST_MODE) { LOG.info("Marking deleted: " + path); } } finally { unlockData(); } }
|
addDeleted
|
2,680 |
void () { lockData(); try { myDeletedPaths.clear(); } finally { unlockData(); } }
|
clearDeletedPaths
|
2,681 |
Set<String> () { lockData(); try { try { Set<String> result = CollectionFactory.createFilePathLinkedSet(); result.addAll(myDeletedPaths); return result; } finally { myDeletedPaths.clear(); } } finally { unlockData(); } }
|
getAndClearDeletedPaths
|
2,682 |
boolean (BuildRootDescriptor rd, File file) { lockData(); try { final Set<File> files = myFilesToRecompile.get(rd); return files != null && files.contains(file); } finally { unlockData(); } }
|
isMarkedRecompile
|
2,683 |
String () { return JpsBuildBundle.message("progress.message.generating.rmi.stubs"); }
|
getProgressMessage
|
2,684 |
void (CompileContext context) { super.buildStarted(context); final RmicCompilerOptions rmicOptions = getOptions(context); IS_ENABLED.set(context, rmicOptions != null && rmicOptions.IS_EANABLED); }
|
buildStarted
|
2,685 |
boolean (CompileContext context, ModuleChunk chunk) { return IS_ENABLED.get(context, Boolean.FALSE); }
|
isEnabled
|
2,686 |
ExitCode (CompileContext context, ModuleChunk chunk, InstrumentationClassFinder finder, OutputConsumer outputConsumer) { ExitCode exitCode = ExitCode.NOTHING_DONE; if (!outputConsumer.getCompiledClasses().isEmpty()) { final Map<ModuleBuildTarget, Collection<ClassItem>> remoteClasses = new HashMap<>(); for (ModuleBuildTarget target : chunk.getTargets()) { for (CompiledClass compiledClass : outputConsumer.getTargetCompiledClasses(target)) { try { if (isRemote(compiledClass, finder)) { Collection<ClassItem> list = remoteClasses.get(target); if (list == null) { list = new ArrayList<>(); remoteClasses.put(target, list); } list.add(new ClassItem(compiledClass)); } } catch (IOException e) { context.processMessage(new CompilerMessage(getPresentableName(), e)); } } } if (!remoteClasses.isEmpty()) { exitCode = generateRmiStubs(context, remoteClasses, chunk, outputConsumer); } } return exitCode; }
|
performBuild
|
2,687 |
ExitCode (final CompileContext context, Map<ModuleBuildTarget, Collection<ClassItem>> remoteClasses, ModuleChunk chunk, OutputConsumer outputConsumer) { ExitCode exitCode = ExitCode.NOTHING_DONE; final Collection<File> classpath = ProjectPaths.getCompilationClasspath(chunk, false); final StringBuilder buf = new StringBuilder(); for (File file : classpath) { if (buf.length() > 0) { buf.append(File.pathSeparator); } buf.append(file.getPath()); } final String classpathString = buf.toString(); final String rmicPath = getPathToRmic(chunk); final RmicCompilerOptions options = getOptions(context); final List<ModuleBuildTarget> targetsProcessed = new ArrayList<>(remoteClasses.size()); for (Map.Entry<ModuleBuildTarget, Collection<ClassItem>> entry : remoteClasses.entrySet()) { try { final ModuleBuildTarget target = entry.getKey(); final Collection<String> cmdLine = createStartupCommand( target, rmicPath, classpathString, options, entry.getValue() ); final Process process = Runtime.getRuntime().exec(ArrayUtilRt.toStringArray(cmdLine)); final BaseOSProcessHandler handler = new BaseOSProcessHandler(process, StringUtil.join(cmdLine, " "), null) { @Override public @NotNull Future<?> executeTask(@NotNull Runnable task) { return SharedThreadPool.getInstance().submit(task); } }; final RmicOutputParser stdOutParser = new RmicOutputParser(context, getPresentableName()); final RmicOutputParser stdErrParser = new RmicOutputParser(context, getPresentableName()); handler.addProcessListener(new ProcessAdapter() { @Override public void onTextAvailable(@NotNull ProcessEvent event, @NotNull Key outputType) { if (outputType == ProcessOutputTypes.STDOUT) { stdOutParser.append(event.getText()); } else if (outputType == ProcessOutputTypes.STDERR) { stdErrParser.append(event.getText()); } } }); handler.startNotify(); handler.waitFor(); targetsProcessed.add(target); if (stdErrParser.isErrorsReported() || stdOutParser.isErrorsReported()) { break; } else { final int exitValue = handler.getProcess().exitValue(); if (exitValue != 0) { context.processMessage(new CompilerMessage(getPresentableName(), BuildMessage.Kind.ERROR, JpsBuildBundle.message("build.message.rmi.stub.generation.failed"))); break; } } } catch (IOException e) { context.processMessage(new CompilerMessage(getPresentableName(), e)); break; } } // registering generated files final Map<File, File[]> fsCache = FileCollectionFactory.createCanonicalFileMap(); for (ModuleBuildTarget target : targetsProcessed) { final Collection<ClassItem> items = remoteClasses.get(target); for (ClassItem item : items) { File[] children = fsCache.get(item.parentDir); if (children == null) { children = item.parentDir.listFiles(); if (children == null) { children = EMPTY_FILE_ARRAY; } fsCache.put(item.parentDir, children); } final Collection<File> files = item.selectGeneratedFiles(children); if (!files.isEmpty()) { final Collection<String> sources = item.compiledClass.getSourceFilesPaths(); for (File generated : files) { try { outputConsumer.registerOutputFile(target, generated, sources); } catch (IOException e) { context.processMessage(new CompilerMessage(getPresentableName(), e)); } } } } } return exitCode; }
|
generateRmiStubs
|
2,688 |
void (@NotNull ProcessEvent event, @NotNull Key outputType) { if (outputType == ProcessOutputTypes.STDOUT) { stdOutParser.append(event.getText()); } else if (outputType == ProcessOutputTypes.STDERR) { stdErrParser.append(event.getText()); } }
|
onTextAvailable
|
2,689 |
Collection<String> (final ModuleBuildTarget target, final String compilerPath, final String classpath, final RmicCompilerOptions config, final Collection<ClassItem> items) { final List<String> commandLine = new ArrayList<>(); commandLine.add(compilerPath); if (config.DEBUGGING_INFO) { commandLine.add("-g"); } if(config.GENERATE_IIOP_STUBS) { commandLine.add("-iiop"); } final StringTokenizer tokenizer = new StringTokenizer(config.ADDITIONAL_OPTIONS_STRING, " \t\r\n"); while(tokenizer.hasMoreTokens()) { final String token = tokenizer.nextToken(); commandLine.add(token); } commandLine.add("-classpath"); commandLine.add(classpath); commandLine.add("-d"); final File outputDir = target.getOutputDir(); assert outputDir != null; commandLine.add(outputDir.getPath()); for (ClassItem item : items) { commandLine.add(item.compiledClass.getClassName()); } return commandLine; }
|
createStartupCommand
|
2,690 |
String (ModuleChunk chunk) { final JpsSdk<?> sdk = chunk.representativeTarget().getModule().getSdk(JpsJavaSdkType.INSTANCE); if (sdk != null) { final String executable = JpsJavaSdkType.getJavaExecutable(sdk); final int idx = FileUtil.toSystemIndependentName(executable).lastIndexOf("/"); if (idx >= 0) { return executable.substring(0, idx) + "/rmic"; } } return SystemProperties.getJavaHome() + "/bin/rmic"; }
|
getPathToRmic
|
2,691 |
Collection<File> (File[] candidates) { if (candidates == null || candidates.length == 0) { return Collections.emptyList(); } final Collection<File> result = new SmartList<>(); final String[] suffixes = new String[GEN_SUFFIXES.length]; for (int i = 0; i < GEN_SUFFIXES.length; i++) { suffixes[i] = baseName + GEN_SUFFIXES[i]; } for (File candidate : candidates) { final String name = candidate.getName(); for (String suffix : suffixes) { if (name.endsWith(suffix)) { result.add(candidate); break; } } } return result; }
|
selectGeneratedFiles
|
2,692 |
boolean () { return myErrorsReported; }
|
isErrorsReported
|
2,693 |
void (@NlsSafe String line) { if (!StringUtil.isEmpty(line)) { BuildMessage.Kind kind = BuildMessage.Kind.INFO; if (line.contains("error")) { kind = BuildMessage.Kind.ERROR; myErrorsReported = true; } else if (line.contains("warning")) { kind = BuildMessage.Kind.WARNING; } myContext.processMessage(new CompilerMessage(myCompilerName, kind, line)); } }
|
lineAvailable
|
2,694 |
void (CompileContext context) { final ProjectDescriptor pd = context.getProjectDescriptor(); final JpsJavaCompilerConfiguration config = JpsJavaExtensionService.getInstance().getCompilerConfiguration(pd.getProject()); myIsEnabled = config.isAddNotNullAssertions(); myNotNulls = ArrayUtilRt.toStringArray(config.getNotNullAnnotations()); }
|
buildStarted
|
2,695 |
String () { return JpsBuildBundle.message("builder.name.notnull.instrumentation"); }
|
getPresentableName
|
2,696 |
String () { return JpsBuildBundle.message("progress.message.adding.notnull.assertions"); }
|
getProgressMessage
|
2,697 |
boolean (CompileContext context, ModuleChunk chunk) { return myIsEnabled; }
|
isEnabled
|
2,698 |
boolean (CompiledClass compiledClass, int classFileVersion) { return (classFileVersion & 0xFFFF) >= Opcodes.V1_5 && !"module-info".equals(compiledClass.getClassName()); }
|
canInstrument
|
2,699 |
void (CompileContext context, ModuleChunk chunk) { final InstrumentationClassFinder finder = CLASS_FINDER.get(context); if (finder != null) { CLASS_FINDER.set(context, null); finder.releaseResources(); } }
|
chunkBuildFinished
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.