Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
2,800
String () { return String.valueOf(myRootIndex); }
getRootId
2,801
SourceFileFilter () { return myFilter; }
getFilter
2,802
DestinationInfo () { return myDestinationInfo; }
getDestinationInfo
2,803
int () { return myRootIndex; }
getRootIndex
2,804
String () { return getOutputPath(); }
toString
2,805
SourceFileFilter (SourceFileFilter baseFilter, FileFilter filter) { return filter == FileFilters.EVERYTHING ? baseFilter : new CompositeSourceFileFilter(baseFilter, filter); }
createCompositeFilter
2,806
String () { return myRoot.getPath(); }
getFullPath
2,807
void (PrintWriter out, PathRelativizerService relativizer) { super.writeConfiguration(out, relativizer); myCopyingHandler.writeConfiguration(out); }
writeConfiguration
2,808
boolean (@NotNull String fullFilePath) { return myFilter.accept(new File(fullFilePath)) && myBaseFilter.accept(fullFilePath); }
accept
2,809
void (String pathInJar, ArtifactRootDescriptor descriptor) { myContent.add(Pair.create(pathInJar, descriptor)); }
addContent
2,810
void (String pathInJar, JarInfo jarInfo) { myContent.add(Pair.create(pathInJar, jarInfo)); }
addJar
2,811
DestinationInfo () { return myDestination; }
getDestination
2,812
String () { return myDestination.getOutputPath(); }
getPresentableDestination
2,813
FileFilter () { return FileFilters.EVERYTHING; }
createFileFilter
2,814
void (final JarInfo jarInfo) { if (myJars.add(jarInfo)) { final DestinationInfo destination = jarInfo.getDestination(); if (destination instanceof JarDestinationInfo) { addJarWithDependencies(((JarDestinationInfo)destination).getJarInfo()); } for (Pair<String, Object> pair : jarInfo.getContent()) { if (pair.getSecond() instanceof JarInfo) { addJarWithDependencies((JarInfo)pair.getSecond()); } } } }
addJarWithDependencies
2,815
Set<JarInfo> () { return myJars; }
getJars
2,816
Collection<JpsArtifact> (JpsModel model, boolean includeSynthetic) { List<JpsArtifact> artifacts = JpsArtifactService.getInstance().getArtifacts(model.getProject()); if (!includeSynthetic) { return artifacts; } return ContainerUtil.concat(artifacts, getSyntheticArtifacts(model)); }
getArtifacts
2,817
List<JpsArtifact> (final JpsModel model) { JpsElementCollection<JpsArtifact> artifactsCollection = model.getProject().getContainer().getChild(SYNTHETIC_ARTIFACTS); if (artifactsCollection == null) { List<JpsArtifact> artifactList = computeSyntheticArtifacts(model); artifactsCollection = model.getProject().getContainer().setChild(SYNTHETIC_ARTIFACTS); for (JpsArtifact artifact : artifactList) { artifactsCollection.addChild(artifact); } } return artifactsCollection.getElements(); }
getSyntheticArtifacts
2,818
List<JpsArtifact> (JpsModel model) { List<JpsArtifact> artifacts = new ArrayList<>(); for (JpsSyntheticArtifactProvider provider : JpsServiceManager.getInstance().getExtensions(JpsSyntheticArtifactProvider.class)) { artifacts.addAll(provider.createArtifacts(model)); } return artifacts; }
computeSyntheticArtifacts
2,819
boolean (@NotNull JpsPackagingElement element, @NotNull Processor<? super JpsPackagingElement> processor) { return processPackagingElements(element, processor, new HashSet<>()); }
processPackagingElements
2,820
boolean (@NotNull JpsPackagingElement element, @NotNull Processor<? super JpsPackagingElement> processor, final Set<? super JpsPackagingElement> processed) { if (!processed.add(element)) { return false; } if (!processor.process(element)) { return false; } if (element instanceof JpsCompositePackagingElement) { for (JpsPackagingElement child : ((JpsCompositePackagingElement)element).getChildren()) { processPackagingElements(child, processor, processed); } } else if (element instanceof JpsComplexPackagingElement) { for (JpsPackagingElement child : ((JpsComplexPackagingElement)element).getSubstitution()) { processPackagingElements(child, processor, processed); } } return true; }
processPackagingElements
2,821
boolean (String name) { return name.length() >= 4 && name.charAt(name.length() - 4) == '.' && StringUtil.endsWithIgnoreCase(name, "ar"); }
isArchiveName
2,822
Set<JpsModule> (final @NotNull Collection<? extends JpsArtifact> artifacts) { final Set<JpsModule> modules = new HashSet<>(); for (JpsArtifact artifact : artifacts) { processPackagingElements(artifact.getRootElement(), element -> { if (element instanceof JpsModuleOutputPackagingElement) { ContainerUtil.addIfNotNull(modules, ((JpsModuleOutputPackagingElement)element).getModuleReference().resolve()); } return true; }); } return modules; }
getModulesIncludedInArtifacts
2,823
List<JpsArtifact> () { if (mySortedArtifacts == null) { mySortedArtifacts = doGetSortedArtifacts(); } return mySortedArtifacts; }
getArtifactsSortedByInclusion
2,824
List<JpsArtifact> () { Graph<JpsArtifact> graph = createArtifactsGraph(); DFSTBuilder<JpsArtifact> builder = new DFSTBuilder<>(graph); List<JpsArtifact> names = new ArrayList<>(graph.getNodes()); names.sort(builder.comparator()); return names; }
doGetSortedArtifacts
2,825
Set<JpsArtifact> (@NotNull Collection<? extends JpsArtifact> artifacts) { Set<JpsArtifact> result = new HashSet<>(); for (JpsArtifact artifact : artifacts) { collectIncludedArtifacts(artifact, new HashSet<>(), result, true); } return result; }
addIncludedArtifacts
2,826
void (JpsArtifact artifact, final Set<? super JpsArtifact> processed, final Set<? super JpsArtifact> result, final boolean withOutputPathOnly) { if (!processed.add(artifact)) { return; } if (!withOutputPathOnly || !StringUtil.isEmpty(artifact.getOutputPath())) { result.add(artifact); } processIncludedArtifacts(artifact, included -> collectIncludedArtifacts(included, processed, result, withOutputPathOnly)); }
collectIncludedArtifacts
2,827
Graph<JpsArtifact> () { return GraphGenerator.generate(CachingSemiGraph.cache(new ArtifactsGraph(myModel))); }
createArtifactsGraph
2,828
void (JpsArtifact artifact, final Consumer<? super JpsArtifact> consumer) { JpsArtifactUtil.processPackagingElements(artifact.getRootElement(), element -> { if (element instanceof JpsArtifactOutputPackagingElement) { JpsArtifact included = ((JpsArtifactOutputPackagingElement)element).getArtifactReference().resolve(); if (included != null) { consumer.consume(included); } return false; } return true; }); }
processIncludedArtifacts
2,829
Collection<JpsArtifact> () { return myArtifactNodes; }
getNodes
2,830
Iterator<JpsArtifact> (JpsArtifact artifact) { final Set<JpsArtifact> included = new LinkedHashSet<>(); processIncludedArtifacts(artifact, includedArtifact -> { if (myArtifactNodes.contains(includedArtifact)) { included.add(includedArtifact); } }); return included.iterator(); }
getIn
2,831
String (@NotNull String path) { while (path.length() != 0 && (path.charAt(0) == '/' || path.charAt(0) == File.separatorChar)) { path = path.substring(1); } return path; }
trimForwardSlashes
2,832
String (@NotNull String basePath, @NotNull String relativePath) { final boolean endsWithSlash = StringUtilRt.endsWithChar(basePath, '/') || StringUtilRt.endsWithChar(basePath, '\\'); final boolean startsWithSlash = StringUtil.startsWithChar(relativePath, '/') || StringUtil.startsWithChar(relativePath, '\\'); String tail; if (endsWithSlash && startsWithSlash) { tail = trimForwardSlashes(relativePath); } else if (!endsWithSlash && !startsWithSlash && basePath.length() > 0 && relativePath.length() > 0) { tail = "/" + relativePath; } else { tail = relativePath; } return basePath + tail; }
appendToPath
2,833
void () { for (File file : myBuiltJars.values()) { FileUtil.delete(file); } }
deleteTemporaryJars
2,834
void () { for (Map.Entry<JarInfo, File> entry : myBuiltJars.entrySet()) { File fromFile = entry.getValue(); final JarInfo jarInfo = entry.getKey(); DestinationInfo destination = jarInfo.getDestination(); if (destination instanceof ExplodedDestinationInfo) { File toFile = new File(FileUtil.toSystemDependentName(destination.getOutputPath())); try { FileUtil.rename(fromFile, toFile); } catch (IOException e) { myContext.processMessage(new CompilerMessage(IncArtifactBuilder.getBuilderName(), BuildMessage.Kind.ERROR, CompilerMessage.getTextFromThrowable(e))); } } } }
copyJars
2,835
Collection<JarInfo> () { return myJarsToBuild; }
getNodes
2,836
Iterator<JarInfo> (final JarInfo n) { Set<JarInfo> ins = new HashSet<>(); final DestinationInfo destination = n.getDestination(); if (destination instanceof JarDestinationInfo) { ins.add(((JarDestinationInfo)destination).getJarInfo()); } return ins.iterator(); }
getIn
2,837
void (StandardResourceBuilderEnabler enabler) { ourEnablers.add(enabler); }
registerEnabler
2,838
boolean (JpsModule module) { synchronized (ourEnablers) { for (StandardResourceBuilderEnabler enabler : ourEnablers) { if (!enabler.isResourceProcessingEnabled(module)) { return false; } } } return true; }
isResourceProcessingEnabled
2,839
void (CompileContext context, ResourceRootDescriptor rd, File file, BuildOutputConsumer outputConsumer) { final File outputRoot = rd.getTarget().getOutputDir(); if (outputRoot == null) { return; } final String sourceRootPath = FileUtil.toCanonicalPath(rd.getRootFile().getAbsolutePath()); final String relativePath = FileUtil.getRelativePath(sourceRootPath, FileUtil.toCanonicalPath(file.getPath()), '/'); final String prefix = rd.getPackagePrefix(); final StringBuilder targetPath = new StringBuilder(); targetPath.append(FileUtil.toCanonicalPath(outputRoot.getPath())); if (prefix.length() > 0) { targetPath.append('/').append(prefix.replace('.', '/')); } targetPath.append('/').append(relativePath); context.processMessage( new ProgressMessage(JpsBuildBundle.message("progress.message.copying.resources.0", rd.getTarget().getModule().getName())) ); try { final File targetFile = new File(targetPath.toString()); FSOperations.copy(file, targetFile); outputConsumer.registerOutputFile(targetFile, Collections.singletonList(file.getPath())); } catch (Exception e) { context.processMessage( new CompilerMessage(getBuilderName(), BuildMessage.Kind.ERROR, CompilerMessage.getTextFromThrowable(e)) ); } }
copyResource
2,840
String () { return getBuilderName(); }
getPresentableName
2,841
void () { try { final String path = (String)myControllerClass.getMethod("capturePerformanceSnapshot").invoke(myController); String message = "CPU Snapshot captured: " + path; LOG.warn(message); System.err.println(message); myControllerClass.getMethod("stopCpuProfiling").invoke(myController); } catch (Throwable e) { e.printStackTrace(); LOG.error(e); } }
stopProfiling
2,842
void (Class<?> aClass, Set<String> result) { Path path = PathManager.getJarForClass(aClass); if (path == null) { return; } final String pathString = path.toString(); if (result.add(pathString) && pathString.endsWith("app.jar") && path.getFileName().toString().equals("app.jar")) { if (path.getParent().equals(Paths.get(PathManager.getLibPath()))) { LOG.error("Due to " + aClass.getName() + " requirement, inappropriate " + pathString + " is added to build process classpath"); } } }
addToClassPath
2,843
void (Set<String> cp, @NotNull Class<?> @NotNull [] classes) { for (Class<?> aClass : classes) { addToClassPath(aClass, cp); } }
addToClassPath
2,844
Collection<String> () { // predictable order Set<String> cp = new LinkedHashSet<>(); addToClassPath(BuildMain.class, cp); addToClassPath(ExternalJavacProcess.class, cp); // intellij.platform.jps.build.javac.rt part addToClassPath(JavacReferenceCollector.class, cp); // jps-javac-extension library // intellij.platform.util addToClassPath(cp, ClassPathUtil.getUtilClasses()); ClassPathUtil.addKotlinStdlib(cp); addToClassPath(cp, COMMON_REQUIRED_CLASSES); addToClassPath(ClassWriter.class, cp); // asm addToClassPath(ClassVisitor.class, cp); // asm-commons addToClassPath(RuntimeModuleRepository.class, cp); // intellij.platform.runtime.repository addToClassPath(JpsModel.class, cp); // intellij.platform.jps.model addToClassPath(JpsModelImpl.class, cp); // intellij.platform.jps.model.impl addToClassPath(JpsProjectLoader.class, cp); // intellij.platform.jps.model.serialization addToClassPath(AlienFormFileException.class, cp); // intellij.java.guiForms.compiler addToClassPath(GridConstraints.class, cp); // intellij.java.guiForms.rt addToClassPath(CellConstraints.class, cp); // jGoodies-forms cp.addAll(getInstrumentationUtilRoots()); addToClassPath(IXMLBuilder.class, cp); // nano-xml addToClassPath(JavaProjectBuilder.class, cp); // QDox lightweight java parser addToClassPath(Gson.class, cp); // gson addToClassPath(Xxh3.class, cp); // caffeine addToClassPath(Caffeine.class, cp); addToClassPath(cp, ArtifactRepositoryManager.getClassesFromDependencies()); addToClassPath(Tracer.class, cp); // tracing infrastructure try { Class<?> cmdLineWrapper = Class.forName("com.intellij.rt.execution.CommandLineWrapper"); addToClassPath(cmdLineWrapper, cp); // idea_rt.jar } catch (Throwable ignored) { } return cp; }
getBuildProcessApplicationClasspath
2,845
void (Collection<? super String> cp, boolean includeEcj) { if (includeEcj) { File file = EclipseCompilerTool.findEcjJarFile(); if (file != null) { cp.add(file.getAbsolutePath()); } } }
appendJavaCompilerClasspath
2,846
List<File> (String sdkHome, JavaCompilingTool compilingTool) { // Important! All dependencies must be java 6 compatible (the oldest supported javac to be launched) final Set<File> cp = new LinkedHashSet<>(); cp.add(getResourceFile(ExternalJavacProcess.class)); // self cp.add(getResourceFile(JavacReferenceCollector.class)); // jps-javac-extension library cp.add(getResourceFile(SystemInfoRt.class)); // util_rt for (Class<?> aClass : COMMON_REQUIRED_CLASSES) { cp.add(getResourceFile(aClass)); } try { final Class<?> cmdLineWrapper = Class.forName("com.intellij.rt.execution.CommandLineWrapper"); cp.add(getResourceFile(cmdLineWrapper)); // idea_rt.jar } catch (Throwable th) { LOG.info(th); } try { final String localJavaHome = FileUtilRt.toSystemIndependentName(SystemProperties.getJavaHome()); // sdkHome is not the same as the sdk used to run this process final File candidate = new File(sdkHome, "lib/tools.jar"); if (candidate.exists()) { cp.add(candidate); } else { // last resort final JavaCompiler systemCompiler = ToolProvider.getSystemJavaCompiler(); Class<?> compilerClass; if (systemCompiler != null) { compilerClass = systemCompiler.getClass(); } else { compilerClass = Class.forName("com.sun.tools.javac.api.JavacTool", false, ClasspathBootstrap.class.getClassLoader()); } final File resourceFile = getResourceFile(compilerClass); if (resourceFile != null) { String localJarPath = FileUtilRt.toSystemIndependentName(resourceFile.getPath()); String relPath = FileUtilRt.getRelativePath(localJavaHome, localJarPath, '/'); if (relPath != null) { if (relPath.contains("..")) { relPath = FileUtilRt.getRelativePath(FileUtilRt.toSystemIndependentName(new File(localJavaHome).getParent()), localJarPath, '/'); } if (relPath != null) { final File targetFile = new File(sdkHome, relPath); cp.add(targetFile); // tools.jar } } } } } catch (Throwable th) { LOG.info(th); } cp.addAll(compilingTool.getAdditionalClasspath()); for (JavaSourceTransformer t : JavaSourceTransformer.getTransformers()) { cp.add(getResourceFile(t.getClass())); } return new ArrayList<>(cp); }
getExternalJavacProcessClasspath
2,847
void (Consumer<? super String> paramConsumer) { for (String aPackage : REFLECTION_OPEN_PACKAGES) { paramConsumer.accept("--add-opens"); paramConsumer.accept(aPackage); } }
configureReflectionOpenPackages
2,848
List<String> () { String instrumentationUtilPath = getResourcePath(NotNullVerifyingInstrumenter.class); File instrumentationUtil = new File(instrumentationUtilPath); if (instrumentationUtil.isDirectory()) { //running from sources: load classes from .../out/production/intellij.java.compiler.instrumentationUtil.java8 return Arrays.asList(instrumentationUtilPath, new File(instrumentationUtil.getParentFile(), "intellij.java.compiler.instrumentationUtil.java8").getAbsolutePath()); } else { //running from jars: intellij.java.compiler.instrumentationUtil.java8 is located in the same jar return Collections.singletonList(instrumentationUtilPath); } }
getInstrumentationUtilRoots
2,849
BuildRootIndex () { return myBuildRootIndex; }
getBuildRootIndex
2,850
BuildTargetIndex () { return myBuildTargetIndex; }
getBuildTargetIndex
2,851
IgnoredFileIndex () { return myIgnoredFileIndex; }
getIgnoredFileIndex
2,852
BuildTargetsState () { return dataManager.getTargetsState(); }
getTargetsState
2,853
CompilerEncodingConfiguration () { return myEncodingConfiguration; }
getEncodingConfiguration
2,854
BuildLoggingManager () { return myLoggingManager; }
getLoggingManager
2,855
void () { boolean shouldClose; synchronized (this) { --myUseCounter; shouldClose = myUseCounter == 0; } if (shouldClose) { try { myProjectStamps.close(); } finally { try { dataManager.close(); } catch (IOException e) { e.printStackTrace(System.err); } } } }
release
2,856
ModuleExcludeIndex () { return myModuleExcludeIndex; }
getModuleExcludeIndex
2,857
JpsModel () { return myModel; }
getModel
2,858
JpsProject () { return myProject; }
getProject
2,859
ProjectStamps () { return myProjectStamps; }
getProjectStamps
2,860
void (String[] args) { try { final long processStart = System.nanoTime(); final String startMessage = "Build process started. Classpath: " + System.getProperty("java.class.path"); System.out.println(startMessage); LOG.info("=================================================="); LOG.info(startMessage); final String host = args[HOST_ARG]; final int port = Integer.parseInt(args[PORT_ARG]); final UUID sessionId = UUID.fromString(args[SESSION_ID_ARG]); final File systemDir = new File(FileUtilRt.toCanonicalPath(args[SYSTEM_DIR_ARG], File.separatorChar, true)); Utils.setSystemRoot(systemDir); final long connectStart = System.nanoTime(); // IDEA-123132, let's try again for (int attempt = 0; ; attempt++) { try { ourEventLoopGroup = new NioEventLoopGroup(1, (ThreadFactory)r -> new Thread(r, "JPS event loop")); break; } catch (IllegalStateException e) { if (attempt == 2) { printErrorAndExit(host, port, e); return; } else { LOG.warn("Cannot create event loop, attempt #" + attempt, e); TimeoutUtil.sleep(10L * (attempt + 1)); } } } final Bootstrap bootstrap = new Bootstrap().group(ourEventLoopGroup).channel(NioSocketChannel.class).handler(new ChannelInitializer<>() { @Override protected void initChannel(Channel channel) { channel.pipeline().addLast(new ProtobufVarint32FrameDecoder(), new ProtobufDecoder(CmdlineRemoteProto.Message.getDefaultInstance()), new ProtobufVarint32LengthFieldPrepender(), new ProtobufEncoder(), new MyMessageHandler(sessionId)); } }).option(ChannelOption.TCP_NODELAY, true).option(ChannelOption.SO_KEEPALIVE, true); final ChannelFuture future = bootstrap.connect(new InetSocketAddress(host, port)).awaitUninterruptibly(); final boolean success = future.isSuccess(); if (success) { LOG.info("Connection to IDE established in " + TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - connectStart) + " ms"); final String projectPathToPreload = System.getProperty(PRELOAD_PROJECT_PATH, null); final String globalsPathToPreload = System.getProperty(PRELOAD_CONFIG_PATH, null); if (projectPathToPreload != null && globalsPathToPreload != null) { final PreloadedData data = new PreloadedData(); ourPreloadedData = data; try { final BuildRunner runner = new BuildRunner(new JpsModelLoaderImpl(projectPathToPreload, globalsPathToPreload, false, null)); data.setRunner(runner); final File dataStorageRoot = Utils.getDataStorageRoot(projectPathToPreload); final BuildFSState fsState = new BuildFSState(false); final ProjectDescriptor pd = runner.load(new MessageHandler() { @Override public void processMessage(BuildMessage msg) { data.addMessage(msg); } }, dataStorageRoot, fsState); data.setProjectDescriptor(pd); final File fsStateFile = new File(dataStorageRoot, BuildSession.FS_STATE_FILE); try (DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(fsStateFile)))) { final int version = in.readInt(); if (version == BuildFSState.VERSION) { final long savedOrdinal = in.readLong(); final boolean hasWorkToDo = in.readBoolean(); fsState.load(in, pd.getModel(), pd.getBuildRootIndex()); data.setFsEventOrdinal(savedOrdinal); data.setHasHasWorkToDo(hasWorkToDo); } } catch (FileNotFoundException ignored) { } catch (IOException e) { LOG.info("Error pre-loading FS state", e); fsState.clearAll(); } // preloading target configurations and pre-calculating target dirty state final BuildTargetsState targetsState = pd.getTargetsState(); for (BuildTarget<?> target : pd.getBuildTargetIndex().getAllTargets()) { targetsState.getTargetConfiguration(target).isTargetDirty(pd); } //noinspection ResultOfMethodCallIgnored BuilderRegistry.getInstance(); JpsServiceManager.getInstance().getExtensions(PreloadedDataExtension.class).forEach(ext-> ext.preloadData(data)); LOG.info("Pre-loaded process ready in " + TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - processStart) + " ms"); } catch (Throwable e) { LOG.info("Failed to pre-load project " + projectPathToPreload, e); // failed to preload the project; the situation will be handled later, when real build starts } } else if (projectPathToPreload != null || globalsPathToPreload != null){ LOG.info("Skipping project pre-loading step: both paths to project configuration files and path to global settings must be specified"); } future.channel().writeAndFlush(CmdlineProtoUtil.toMessage(sessionId, CmdlineProtoUtil.createParamRequest())); } else { printErrorAndExit(host, port, future.cause()); } } catch (Throwable e) { LOG.error(e); throw e; } }
main
2,861
void (Channel channel) { channel.pipeline().addLast(new ProtobufVarint32FrameDecoder(), new ProtobufDecoder(CmdlineRemoteProto.Message.getDefaultInstance()), new ProtobufVarint32LengthFieldPrepender(), new ProtobufEncoder(), new MyMessageHandler(sessionId)); }
initChannel
2,862
void (BuildMessage msg) { data.addMessage(msg); }
processMessage
2,863
void (String host, int port, Throwable reason) { System.err.println("Error connecting to " + host + ":" + port + "; reason: " + (reason != null ? reason.getMessage() : "unknown")); if (reason != null) { reason.printStackTrace(System.err); } System.err.println("Exiting."); System.exit(-1); }
printErrorAndExit
2,864
void (final ChannelHandlerContext context, CmdlineRemoteProto.Message message) { final CmdlineRemoteProto.Message.Type type = message.getType(); final Channel channel = context.channel(); if (type == CmdlineRemoteProto.Message.Type.CONTROLLER_MESSAGE) { final CmdlineRemoteProto.Message.ControllerMessage controllerMessage = message.getControllerMessage(); switch (controllerMessage.getType()) { case BUILD_PARAMETERS: { if (mySession == null) { final CmdlineRemoteProto.Message.ControllerMessage.FSEvent delta = controllerMessage.hasFsEvent()? controllerMessage.getFsEvent() : null; final BuildSession session = new BuildSession(mySessionId, channel, controllerMessage.getParamsMessage(), delta, ourPreloadedData); mySession = session; SharedThreadPool.getInstance().execute(() -> { //noinspection finally try { try { session.run(); } finally { channel.close(); } } finally { System.exit(0); } }); } else { LOG.info("Cannot start another build session because one is already running"); } return; } case FS_EVENT: { final BuildSession session = mySession; if (session != null) { session.processFSEvent(controllerMessage.getFsEvent()); } return; } case CONSTANT_SEARCH_RESULT: { // ignored, functionality deprecated return; } case CANCEL_BUILD_COMMAND: { final BuildSession session = mySession; if (session != null) { session.cancel(); } else { LOG.info("Build canceled, but no build session is running. Exiting."); try { final CmdlineRemoteProto.Message.BuilderMessage canceledEvent = CmdlineProtoUtil .createBuildCompletedEvent("build completed", CmdlineRemoteProto.Message.BuilderMessage.BuildEvent.Status.CANCELED); channel.writeAndFlush(CmdlineProtoUtil.toMessage(mySessionId, canceledEvent)).await(); channel.close(); } catch (Throwable e) { LOG.info(e); } Thread.interrupted(); // to clear the 'interrupted' flag final PreloadedData preloaded = ourPreloadedData; final ProjectDescriptor pd = preloaded != null? preloaded.getProjectDescriptor() : null; if (pd != null) { pd.release(); } JpsServiceManager.getInstance().getExtensions(PreloadedDataExtension.class).forEach(ext-> ext.discardPreloadedData(preloaded)); System.exit(0); } return; } } } channel.writeAndFlush( CmdlineProtoUtil.toMessage(mySessionId, CmdlineProtoUtil.createFailure(JpsBuildBundle.message("build.message.unsupported.message.type.0", type.name()), null))); }
channelRead0
2,865
void () { //noinspection finally try { ourEventLoopGroup.shutdownGracefully(0, 15, TimeUnit.SECONDS); } finally { System.exit(0); } }
run
2,866
void (@Nullable List<String> filePaths) { myFilePaths = filePaths != null? filePaths : Collections.emptyList(); }
setFilePaths
2,867
void (@Nullable Map<String, String> builderParams) { myBuilderParams = builderParams != null? builderParams : Collections.emptyMap(); }
setBuilderParams
2,868
void (boolean forceCleanCaches) { myForceCleanCaches = forceCleanCaches; }
setForceCleanCaches
2,869
void (Set<? extends BuildTargetType<?>> targetTypes, Set<BuildTarget<?>> targets, Set<? super BuildTargetType<?>> targetTypesToForceBuild, ProjectDescriptor descriptor) { //todo get rid of CompileContext parameter for BuildTargetIndex.getDependencies() and use it here TargetOutputIndex dummyIndex = new TargetOutputIndex() { @Override public Collection<BuildTarget<?>> getTargetsByOutputFile(@NotNull File file) { return Collections.emptyList(); } }; List<BuildTarget<?>> current = new ArrayList<>(targets); while (!current.isEmpty()) { List<BuildTarget<?>> next = new ArrayList<>(); for (BuildTarget<?> target : current) { for (BuildTarget<?> depTarget : target.computeDependencies(descriptor.getBuildTargetIndex(), dummyIndex)) { if (!targets.contains(depTarget) && !targetTypes.contains(depTarget.getTargetType())) { next.add(depTarget); if (targetTypesToForceBuild.contains(target.getTargetType())) { targetTypesToForceBuild.add(depTarget.getTargetType()); } } } } targets.addAll(next); current = next; } }
includeDependenciesToScope
2,870
boolean () { return SystemProperties.getBooleanProperty(GlobalOptions.COMPILE_PARALLEL_OPTION, false); }
isParallelBuildEnabled
2,871
boolean () { return isParallelBuildEnabled() && SystemProperties.getBooleanProperty(GlobalOptions.ALLOW_PARALLEL_AUTOMAKE_OPTION, true); }
isParallelBuildAutomakeEnabled
2,872
void () { if (!Boolean.parseBoolean(System.getProperty(GlobalOptions.USE_DEFAULT_FILE_LOGGING_OPTION, "true"))) { return; } try { String logDir = System.getProperty(GlobalOptions.LOG_DIR_OPTION, null); Path configFile = logDir == null ? Paths.get(LOG_CONFIG_FILE_NAME) : Paths.get(logDir, LOG_CONFIG_FILE_NAME); ensureLogConfigExists(configFile); Path logFilePath = logDir != null ? Paths.get(logDir, LOG_FILE_NAME) : Paths.get(LOG_FILE_NAME); JulLogger.clearHandlers(); try (InputStream in = new BufferedInputStream(Files.newInputStream(configFile))) { LogManager.getLogManager().readConfiguration(in); } JulLogger.configureLogFileAndConsole(logFilePath, true, true, true, null); } catch (IOException e) { //noinspection UseOfSystemOutOrSystemErr System.err.println("Failed to configure logging: "); //noinspection UseOfSystemOutOrSystemErr e.printStackTrace(System.err); } Logger.setFactory(category -> new JulLogger(java.util.logging.Logger.getLogger(category))); }
initLoggers
2,873
InputStream () { return LogSetup.class.getResourceAsStream("/defaultLogConfig.properties"); }
readDefaultLogConfig
2,874
void (@Nullable BuildRunner runner) { this.runner = runner; }
setRunner
2,875
void (@Nullable ProjectDescriptor projectDescriptor) { this.projectDescriptor = projectDescriptor; }
setProjectDescriptor
2,876
long () { return fsEventOrdinal; }
getFsEventOrdinal
2,877
void (long fsEventOrdinal) { this.fsEventOrdinal = fsEventOrdinal; }
setFsEventOrdinal
2,878
List<BuildMessage> () { return loadMessages; }
getLoadMessages
2,879
void (BuildMessage msg) { loadMessages.add(msg); }
addMessage
2,880
boolean () { return hasWorkFlag; }
hasWorkToDo
2,881
void (boolean hasWorkFlag) { this.hasWorkFlag = hasWorkFlag; }
setHasHasWorkToDo
2,882
String () { return "PreloadedData(fsEventOrdinal=" + fsEventOrdinal + ", hasWorkFlag=" + hasWorkFlag + ")"; }
toString
2,883
void () { final LowMemoryWatcherManager memWatcher = new LowMemoryWatcherManager(SharedThreadPool.getInstance()); Throwable error = null; final Ref<Boolean> hasErrors = new Ref<>(false); final Ref<Boolean> doneSomething = new Ref<>(false); try { ProfilingHelper profilingHelper; try { Utils.ProfilingMode profilingMode = Utils.getProfilingMode(); switch (profilingMode) { case NONE: profilingHelper = null; break; case YOURKIT_SAMPLING: profilingHelper = new ProfilingHelper(); profilingHelper.startSamplingProfiling(); break; case YOURKIT_TRACING: profilingHelper = new ProfilingHelper(); profilingHelper.startTracingProfiling(); break; default: throw new IllegalArgumentException("Unsupported profiling mode: " + profilingMode); } } catch (Throwable t) { LOG.warn("Unable to start build process profiling: " + t.getMessage(), t); //noinspection CallToPrintStackTrace t.printStackTrace(); profilingHelper = null; } myCacheLoadManager = null; if (ProjectStamps.PORTABLE_CACHES && myCacheDownloadSettings != null) { LOG.info("Cache download settings: disableDownload=" + myCacheDownloadSettings.getDisableDownload() + "; forceUpdate=" + myCacheDownloadSettings.getForceDownload() + "; cleanupAsynchronously=" + myCacheDownloadSettings.getCleanupAsynchronously()); if (myCacheDownloadSettings.getDisableDownload()) { LOG.info("Cache download is disabled"); } else { LOG.info("Trying to download JPS caches before build"); myCacheLoadManager = new JpsOutputLoaderManager(myBuildRunner.loadModelAndGetJpsProject(), this, myProjectPath, myChannel, mySessionId, myCacheDownloadSettings); myCacheLoadManager.load(myBuildRunner, true, myScopes, () -> { if (myPreloadedData != null) { LOG.info("Releasing old project description..."); ProjectDescriptor projectDescriptor = myPreloadedData.getProjectDescriptor(); if (projectDescriptor != null) { projectDescriptor.release(); myPreloadedData.setProjectDescriptor(null); } JpsServiceManager.getInstance().getExtensions(PreloadedDataExtension.class).forEach(ext -> ext.discardPreloadedData(myPreloadedData)); myPreloadedData = null; } }); } } runBuild(new MessageHandler() { @Override public void processMessage(BuildMessage buildMessage) { final CmdlineRemoteProto.Message.BuilderMessage response; if (buildMessage instanceof FileGeneratedEvent) { final Collection<Pair<String, String>> paths = ((FileGeneratedEvent)buildMessage).getPaths(); response = !paths.isEmpty() ? CmdlineProtoUtil.createFileGeneratedEvent(paths) : null; } else if (buildMessage instanceof DoneSomethingNotification) { doneSomething.set(true); response = null; } else if (buildMessage instanceof CompilerMessage) { doneSomething.set(true); final CompilerMessage compilerMessage = (CompilerMessage)buildMessage; final String compilerName = compilerMessage.getCompilerName(); final String text = !StringUtil.isEmptyOrSpaces(compilerName)? compilerName + ": " + compilerMessage.getMessageText() : compilerMessage.getMessageText(); final BuildMessage.Kind kind = compilerMessage.getKind(); if (kind == BuildMessage.Kind.ERROR) { hasErrors.set(true); } response = CmdlineProtoUtil.createCompileMessage( kind, text, compilerMessage.getSourcePath(), compilerMessage.getProblemBeginOffset(), compilerMessage.getProblemEndOffset(), compilerMessage.getProblemLocationOffset(), compilerMessage.getLine(), compilerMessage.getColumn(), -1.0f, compilerMessage.getModuleNames()); } else if (buildMessage instanceof CustomBuilderMessage) { CustomBuilderMessage builderMessage = (CustomBuilderMessage)buildMessage; response = CmdlineProtoUtil.createCustomBuilderMessage(builderMessage.getBuilderId(), builderMessage.getMessageType(), builderMessage.getMessageText()); } else if (buildMessage instanceof BuilderStatisticsMessage) { final BuilderStatisticsMessage message = (BuilderStatisticsMessage)buildMessage; final boolean worthReporting = message.getNumberOfProcessedSources() != 0 || message.getElapsedTimeMs() > 50; if (worthReporting) { LOG.info(message.getMessageText()); } //noinspection HardCodedStringLiteral response = worthReporting && REPORT_BUILD_STATISTICS ? CmdlineProtoUtil.createCompileMessage(BuildMessage.Kind.JPS_INFO, message.getMessageText(), null, -1, -1, -1, -1, -1, -1.0f, Collections.emptyList()) : null; } else if (!(buildMessage instanceof BuildingTargetProgressMessage)) { float done = -1.0f; if (buildMessage instanceof ProgressMessage) { done = ((ProgressMessage)buildMessage).getDone(); } //noinspection HardCodedStringLiteral response = CmdlineProtoUtil.createCompileProgressMessageResponse(buildMessage.getMessageText(), done); } else { response = null; } if (response != null) { myChannel.writeAndFlush(CmdlineProtoUtil.toMessage(mySessionId, response)); } } }, this); if (profilingHelper != null) { profilingHelper.stopProfiling(); } } catch (Throwable e) { LOG.info(e); error = e; } finally { logStorageDiagnostic(); finishBuild(error, hasErrors.get(), doneSomething.get()); memWatcher.shutdown(); } }
run
2,884
void (BuildMessage buildMessage) { final CmdlineRemoteProto.Message.BuilderMessage response; if (buildMessage instanceof FileGeneratedEvent) { final Collection<Pair<String, String>> paths = ((FileGeneratedEvent)buildMessage).getPaths(); response = !paths.isEmpty() ? CmdlineProtoUtil.createFileGeneratedEvent(paths) : null; } else if (buildMessage instanceof DoneSomethingNotification) { doneSomething.set(true); response = null; } else if (buildMessage instanceof CompilerMessage) { doneSomething.set(true); final CompilerMessage compilerMessage = (CompilerMessage)buildMessage; final String compilerName = compilerMessage.getCompilerName(); final String text = !StringUtil.isEmptyOrSpaces(compilerName)? compilerName + ": " + compilerMessage.getMessageText() : compilerMessage.getMessageText(); final BuildMessage.Kind kind = compilerMessage.getKind(); if (kind == BuildMessage.Kind.ERROR) { hasErrors.set(true); } response = CmdlineProtoUtil.createCompileMessage( kind, text, compilerMessage.getSourcePath(), compilerMessage.getProblemBeginOffset(), compilerMessage.getProblemEndOffset(), compilerMessage.getProblemLocationOffset(), compilerMessage.getLine(), compilerMessage.getColumn(), -1.0f, compilerMessage.getModuleNames()); } else if (buildMessage instanceof CustomBuilderMessage) { CustomBuilderMessage builderMessage = (CustomBuilderMessage)buildMessage; response = CmdlineProtoUtil.createCustomBuilderMessage(builderMessage.getBuilderId(), builderMessage.getMessageType(), builderMessage.getMessageText()); } else if (buildMessage instanceof BuilderStatisticsMessage) { final BuilderStatisticsMessage message = (BuilderStatisticsMessage)buildMessage; final boolean worthReporting = message.getNumberOfProcessedSources() != 0 || message.getElapsedTimeMs() > 50; if (worthReporting) { LOG.info(message.getMessageText()); } //noinspection HardCodedStringLiteral response = worthReporting && REPORT_BUILD_STATISTICS ? CmdlineProtoUtil.createCompileMessage(BuildMessage.Kind.JPS_INFO, message.getMessageText(), null, -1, -1, -1, -1, -1, -1.0f, Collections.emptyList()) : null; } else if (!(buildMessage instanceof BuildingTargetProgressMessage)) { float done = -1.0f; if (buildMessage instanceof ProgressMessage) { done = ((ProgressMessage)buildMessage).getDone(); } //noinspection HardCodedStringLiteral response = CmdlineProtoUtil.createCompileProgressMessageResponse(buildMessage.getMessageText(), done); } else { response = null; } if (response != null) { myChannel.writeAndFlush(CmdlineProtoUtil.toMessage(mySessionId, response)); } }
processMessage
2,885
void () { LOG.info("FilePageCache stats: " + StorageLockContext.getStatistics().dumpInfoImportantForBuildProcess()); }
logStorageDiagnostic
2,886
boolean (List<TargetTypeBuildScope> scopes) { TargetTypeRegistry typeRegistry = null; for (TargetTypeBuildScope scope : scopes) { if (scope.getForceBuild()) { LOG.debug("Build scope forces compilation for targets of type " + scope.getTypeId()); return false; } final String typeId = scope.getTypeId(); if (isJavaModuleBuildType(typeId)) { // fast check continue; } if (typeRegistry == null) { // lazy init typeRegistry = TargetTypeRegistry.getInstance(); } final BuildTargetType<?> targetType = typeRegistry.getTargetType(typeId); if (targetType != null && !(targetType instanceof ModuleInducedTargetType)) { if (LOG.isDebugEnabled()) { LOG.debug("Build scope contains target of type " + targetType + " which isn't eligible for fast up-to-date check"); } return false; } } return true; }
scopeContainsModulesOnlyForIncrementalMake
2,887
boolean (String typeId) { for (JavaModuleBuildTargetType moduleBuildTargetType : JavaModuleBuildTargetType.ALL_TYPES) { if (moduleBuildTargetType.getTypeId().equals(typeId)) { return true; } } return false; }
isJavaModuleBuildType
2,888
void (final BuildFSState fsState, File dataStorageRoot) { final boolean wasInterrupted = Thread.interrupted(); try { saveFsState(dataStorageRoot, fsState); final ProjectDescriptor pd = myProjectDescriptor; if (pd != null) { pd.release(); } } finally { if (wasInterrupted) { Thread.currentThread().interrupt(); } } }
saveData
2,889
void (final CmdlineRemoteProto.Message.ControllerMessage.FSEvent event) { myEventsProcessor.execute(() -> { try { applyFSEvent(myProjectDescriptor, event, true); myLastEventOrdinal.addAndGet(1); } catch (IOException e) { LOG.error(e); } }); }
processFSEvent
2,890
void (File dataStorageRoot, DataInputStream original, final long ordinal) { if (LOG.isDebugEnabled()) { LOG.debug("updateFsStateOnDisk, ordinal=" + ordinal); } final File file = new File(dataStorageRoot, FS_STATE_FILE); try { final BufferExposingByteArrayOutputStream bytes = new BufferExposingByteArrayOutputStream(); try (DataOutputStream out = new DataOutputStream(bytes)) { out.writeInt(BuildFSState.VERSION); out.writeLong(ordinal); out.writeBoolean(false); while (true) { final int b = original.read(); if (b == -1) { break; } out.write(b); } } saveOnDisk(bytes, file); } catch (Throwable e) { LOG.error(e); FileUtil.delete(file); } }
updateFsStateOnDisk
2,891
void (File dataStorageRoot, BuildFSState state) { final ProjectDescriptor pd = myProjectDescriptor; final File file = new File(dataStorageRoot, FS_STATE_FILE); try { final BufferExposingByteArrayOutputStream bytes = new BufferExposingByteArrayOutputStream(); try (DataOutputStream out = new DataOutputStream(bytes)) { out.writeInt(BuildFSState.VERSION); out.writeLong(myLastEventOrdinal.get()); out.writeBoolean(hasWorkToDo(state, pd)); state.save(out); } saveOnDisk(bytes, file); } catch (Throwable e) { LOG.error(e); FileUtil.delete(file); } }
saveFsState
2,892
boolean (BuildFSState state, @Nullable ProjectDescriptor pd) { if (pd == null) { return true; // assuming the worst case } final BuildTargetIndex targetIndex = pd.getBuildTargetIndex(); for (JpsModule module : pd.getProject().getModules()) { for (ModuleBasedTarget<?> target : targetIndex.getModuleBasedTargets(module, BuildTargetRegistry.ModuleTargetSelector.ALL)) { if (!pd.getBuildTargetIndex().isDummy(target) && state.hasWorkToDo(target)) { if (LOG.isDebugEnabled()) { LOG.debug("Has work to do in " + target); } return true; } } } return false; }
hasWorkToDo
2,893
boolean (CmdlineRemoteProto.Message.ControllerMessage.FSEvent event) { return event.getChangedPathsCount() != 0 || event.getDeletedPathsCount() != 0; }
containsChanges
2,894
void (final Throwable error, boolean hadBuildErrors, boolean doneSomething) { CmdlineRemoteProto.Message lastMessage = null; try { if (error instanceof CannotLoadJpsModelException) { String text = JpsBuildBundle.message("build.message.failed.to.load.project.configuration.0", StringUtil.decapitalize(error.getMessage())); String path = ((CannotLoadJpsModelException)error).getFile().getAbsolutePath(); lastMessage = CmdlineProtoUtil.toMessage(mySessionId, CmdlineProtoUtil.createCompileMessage(BuildMessage.Kind.ERROR, text, path, -1, -1, -1, -1, -1, -1.0f, Collections.emptyList())); } else if (error != null) { Throwable cause = error.getCause(); if (cause == null) { cause = error; } @Nls StringBuilder messageText = new StringBuilder(); messageText.append(JpsBuildBundle.message("build.message.internal.error.0.1", cause.getClass().getName(),cause.getMessage())); String trace = ExceptionUtil.getThrowableText(cause); if (!trace.isEmpty()) { messageText.append("\n").append(trace); } if (error instanceof RebuildRequestedException || cause instanceof IOException) { messageText.append("\n").append(JpsBuildBundle.message("build.message.perform.full.project.rebuild")); } lastMessage = CmdlineProtoUtil.toMessage(mySessionId, CmdlineProtoUtil.createFailure(messageText.toString(), cause)); } else { CmdlineRemoteProto.Message.BuilderMessage.BuildEvent.Status status = CmdlineRemoteProto.Message.BuilderMessage.BuildEvent.Status.SUCCESS; if (myCanceled) { status = CmdlineRemoteProto.Message.BuilderMessage.BuildEvent.Status.CANCELED; } else if (hadBuildErrors) { status = CmdlineRemoteProto.Message.BuilderMessage.BuildEvent.Status.ERRORS; } else if (!doneSomething){ status = CmdlineRemoteProto.Message.BuilderMessage.BuildEvent.Status.UP_TO_DATE; } if (ProjectStamps.PORTABLE_CACHES) { JpsOutputLoaderManager.saveLatestBuiltCommitId(status, myChannel, mySessionId); } lastMessage = CmdlineProtoUtil.toMessage(mySessionId, CmdlineProtoUtil.createBuildCompletedEvent("build completed", status)); } } catch (Throwable e) { lastMessage = CmdlineProtoUtil.toMessage(mySessionId, CmdlineProtoUtil.createFailure(e.getMessage(), e)); } finally { try { myChannel.writeAndFlush(lastMessage).await(); } catch (InterruptedException e) { LOG.info(e); } } }
finishBuild
2,895
void () { myCanceled = true; }
cancel
2,896
boolean () { return myCanceled; }
isCanceled
2,897
BuildType (CmdlineRemoteProto.Message.ControllerMessage.ParametersMessage.Type compileType) { switch (compileType) { case CLEAN: return BuildType.CLEAN; case BUILD: return BuildType.BUILD; case UP_TO_DATE_CHECK: return BuildType.UP_TO_DATE_CHECK; } return BuildType.BUILD; }
convertCompileType
2,898
void () { myProcessingEnabled.up(); }
startProcessing
2,899
void (@NotNull Runnable task) { myExecutorService.execute(task); }
execute