Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
2,400
List<String> (String javaExecutable, String mainClass, List<String> bootClasspath, List<String> classpath, List<String> vmParams, List<String> programParams) { return buildJavaCommandLine(javaExecutable, mainClass, bootClasspath, classpath, vmParams, programParams, true); }
buildJavaCommandLine
2,401
List<String> (String javaExecutable, String mainClass, List<String> bootClasspath, List<String> classpath, List<String> vmParams, List<String> programParams, boolean shortenClasspath) { return buildJavaCommandLine(javaExecutable, mainClass, bootClasspath, classpath, vmParams, programParams, shortenClasspath, true); }
buildJavaCommandLine
2,402
List<String> (String javaExecutable, String mainClass, List<String> bootClasspath, List<String> classpath, List<String> vmParams, List<String> programParams, boolean shortenClasspath, boolean preferClasspathJar) { List<String> cmdLine = new ArrayList<>(); cmdLine.add(javaExecutable); cmdLine.addAll(vmParams); if (!bootClasspath.isEmpty()) { cmdLine.add("-bootclasspath"); cmdLine.add(StringUtil.join(bootClasspath, File.pathSeparator)); } if (!classpath.isEmpty()) { List<String> shortenedCp = null; if (shortenClasspath) { try { Charset cs = Charset.defaultCharset(); // todo detect JNU charset from VM options? if (isModularRuntime(javaExecutable)) { List<String> args = Arrays.asList("-classpath", StringUtil.join(classpath, File.pathSeparator)); File argFile = CommandLineWrapperUtil.createArgumentFile(args, cs); shortenedCp = Collections.singletonList('@' + argFile.getAbsolutePath()); } else if (preferClasspathJar) { File classpathJar = CommandLineWrapperUtil.createClasspathJarFile(new Manifest(), classpath); shortenedCp = Arrays.asList("-classpath", classpathJar.getAbsolutePath()); } else { Class<?> wrapperClass = CommandLineWrapperClassHolder.ourWrapperClass; if (wrapperClass != null) { File classpathFile = CommandLineWrapperUtil.createWrapperFile(classpath, cs); shortenedCp = Arrays.asList( "-classpath", ClasspathBootstrap.getResourcePath(wrapperClass), wrapperClass.getName(), classpathFile.getAbsolutePath()); } else { LOG.info("CommandLineWrapper class not found; classpath shortening won't be used"); } } } catch (IOException e) { LOG.warn("can't create temp file; classpath shortening won't be used", e); } } // classpath if (shortenedCp != null) { cmdLine.addAll(shortenedCp); } else { cmdLine.add("-classpath"); cmdLine.add(StringUtil.join(classpath, File.pathSeparator)); } } // main class and params cmdLine.add(mainClass); cmdLine.addAll(programParams); return cmdLine; }
buildJavaCommandLine
2,403
boolean (String javaExec) { File jreHome = new File(javaExec).getParentFile().getParentFile(); return jreHome != null && (new File(jreHome, "lib/jrt-fs.jar").isFile() || new File(jreHome, "modules/java.base").isDirectory()); }
isModularRuntime
2,404
void (CompileContext context) { }
buildStarted
2,405
void (CompileContext context) { }
buildFinished
2,406
long () { return 10; }
getExpectedBuildTime
2,407
Throwable () { return this; }
fillInStackTrace
2,408
Throwable () { return this; }
fillInStackTrace
2,409
String () { String path = JpsMavenSettings.getMavenRepositoryPath(); if (path != null) { return PathRelativizerService.normalizePath(path); } return null; }
getNormalizedMavenRepositoryPath
2,410
void (@Nullable String projectPath, @Nullable String buildDirPath, @Nullable Set<? extends JpsSdk<?>> javaSdks) { String normalizedProjectPath = projectPath != null ? normalizePath(projectPath) : null; String normalizedBuildDirPath = buildDirPath != null ? normalizePath(buildDirPath) : null; myRelativizers.add(new SubPathRelativizer(normalizedBuildDirPath, BUILD_DIR_IDENTIFIER)); myRelativizers.add(new SubPathRelativizer(normalizedProjectPath, PROJECT_DIR_FOR_SUB_PATH_IDENTIFIER)); myRelativizers.add(new JavaSdkPathRelativizer(javaSdks)); myRelativizers.add(new MavenPathRelativizer()); myRelativizers.add(new GradlePathRelativizer()); myRelativizers.add(new AnyPathRelativizer(normalizedProjectPath, PROJECT_DIR_FOR_ANY_PATH_IDENTIFIER)); }
initialize
2,411
String (@NotNull String path) { String systemIndependentPath = toSystemIndependentName(path); String relativePath; for (PathRelativizer relativizer : myRelativizers) { relativePath = relativizer.toRelativePath(systemIndependentPath); if (relativePath != null) return relativePath; } if (LOG.isDebugEnabled()) { myUnhandledPaths.add(path); } return systemIndependentPath; }
toRelative
2,412
String (@NotNull String path) { String systemIndependentPath = toSystemIndependentName(path); String fullPath; for (PathRelativizer relativizer : myRelativizers) { fullPath = relativizer.toAbsolutePath(systemIndependentPath); if (fullPath != null) return fullPath; } return systemIndependentPath; }
toFull
2,413
void () { if (LOG.isDebugEnabled()) { final StringBuilder logBuilder = new StringBuilder(); myUnhandledPaths.forEach(it -> logBuilder.append(it).append("\n")); LOG.debug("Unhandled by relativizer paths:" + "\n" + logBuilder); myUnhandledPaths.clear(); } }
reportUnhandledPaths
2,414
String (@NotNull String path) { return StringUtil.trimTrailing(toSystemIndependentName(path), '/'); }
normalizePath
2,415
int (File value) { return FileUtil.fileHashCode(value); }
getHashCode
2,416
boolean (File val1, File val2) { return FileUtil.filesEqual(val1, val2); }
isEqual
2,417
void (boolean memoryCachesOnly) { myMapping.flush(memoryCachesOnly); }
flush
2,418
File (File dataStorageRoot) { return new File(dataStorageRoot, "timestamps"); }
calcStorageRoot
2,419
File () { return myTimestampsRoot; }
getStorageRoot
2,420
Timestamp (File file) { return Timestamp.fromLong(FSOperations.lastModified(file)); }
getCurrentStamp
2,421
boolean (@NotNull Stamp stamp, File file) { if (!(stamp instanceof Timestamp)) return true; return ((Timestamp) stamp).myTimestamp != FSOperations.lastModified(file); }
isDirtyStamp
2,422
boolean (Stamp stamp, File file, @NotNull BasicFileAttributes attrs) { if (!(stamp instanceof Timestamp)) return true; Timestamp timestamp = (Timestamp) stamp; // for symlinks the attr structure reflects the symlink's timestamp and not symlink's target timestamp return attrs.isRegularFile() ? attrs.lastModifiedTime().toMillis() != timestamp.myTimestamp : isDirtyStamp(timestamp, file); }
isDirtyStamp
2,423
Timestamp (long l) { return new Timestamp(l); }
fromLong
2,424
String () { return "Timestamp{" + "myTimestamp=" + myTimestamp + '}'; }
toString
2,425
void (boolean processInc) { myProcessConstantsIncrementally = processInc; Mappings mappings = myMappings; if (mappings != null) { mappings.setProcessConstantsIncrementally(processInc); } }
setProcessConstantsIncrementally
2,426
boolean () { return myProcessConstantsIncrementally; }
isProcessConstantsIncrementally
2,427
BuildTargetsState () { return myTargetsState; }
getTargetsState
2,428
OutputToTargetRegistry () { return myOutputToTargetRegistry; }
getOutputToTargetRegistry
2,429
OneToManyPathsMapping () { return mySrcToFormMap; }
getSourceToFormMap
2,430
Mappings () { return myMappings; }
getMappings
2,431
DependencyGraph () { synchronized (myGraphLock) { return myDepGraph; } }
getDependencyGraph
2,432
void (boolean memoryCachesOnly) { allTargetStorages().flush(memoryCachesOnly); myOutputToTargetRegistry.flush(memoryCachesOnly); mySrcToFormMap.flush(memoryCachesOnly); final Mappings mappings = myMappings; if (mappings != null) { synchronized (mappings) { mappings.flush(memoryCachesOnly); } } }
flush
2,433
File (BuildTarget<?> target) { return new File(myDataPaths.getTargetDataRoot(target), SRC_TO_OUTPUT_STORAGE); }
getSourceToOutputMapRoot
2,434
File (BuildTargetType<?> targetType, String targetId) { return new File(myDataPaths.getTargetDataRoot(targetType, targetId), SRC_TO_OUTPUT_STORAGE); }
getSourceToOutputMapRoot
2,435
File () { return new File(myDataPaths.getDataStorageRoot(), SRC_TO_FORM_STORAGE); }
getSourceToFormsRoot
2,436
File () { return new File(myDataPaths.getDataStorageRoot(), OUT_TARGET_STORAGE); }
getOutputToSourceRegistryRoot
2,437
BuildDataPaths () { return myDataPaths; }
getDataPaths
2,438
PathRelativizerService () { return myRelativizer; }
getRelativizer
2,439
File (final File dataStorageRoot) { return new File(dataStorageRoot, JavaBuilderUtil.isDepGraphEnabled()? MAPPINGS_STORAGE + "-graph" : MAPPINGS_STORAGE); }
getMappingsRoot
2,440
void (File root, @Nullable AbstractStateStorage<?, ?> storage) { if (storage != null) { synchronized (storage) { storage.wipe(); } } else { FileUtil.delete(root); } }
wipeStorage
2,441
boolean () { final Boolean cached = myVersionDiffers; if (cached != null) { return cached; } try (DataInputStream is = new DataInputStream(new FileInputStream(myVersionFile))) { final boolean diff = is.readInt() != VERSION; myVersionDiffers = diff; return diff; } catch (FileNotFoundException ignored) { return false; // treat it as a new dir } catch (IOException ex) { LOG.info(ex); } return true; }
versionDiffers
2,442
void () { final Boolean differs = myVersionDiffers; if (differs == null || differs) { FileUtil.createIfDoesntExist(myVersionFile); try (DataOutputStream os = new DataOutputStream(new FileOutputStream(myVersionFile))) { os.writeInt(VERSION); myVersionDiffers = Boolean.FALSE; } catch (IOException ignored) { } } }
saveVersion
2,443
void () { myRelativizer.reportUnhandledPaths(); }
reportUnhandledRelativizerPaths
2,444
int () { return BuildRunner.isParallelBuildEnabled() ? IncProjectBuilder.MAX_BUILDER_THREADS : 1; }
getConcurrencyLevel
2,445
StorageOwner () { return allTargetStorages(f -> {}); }
allTargetStorages
2,446
StorageOwner (Consumer<Future<?>> asyncTaskCollector) { return new CompositeStorageOwner() { @Override public void clean() throws IOException { try { close(); } finally { asyncTaskCollector.accept(FileUtil.asyncDelete(myDataPaths.getTargetsDataRoot())); } } @Override protected Iterable<BuildTargetStorages> getChildStorages() { return () -> myTargetStorages.values().iterator(); } }; }
allTargetStorages
2,447
Iterable<BuildTargetStorages> () { return () -> myTargetStorages.values().iterator(); }
getChildStorages
2,448
DependencyGraph (DependencyGraph graph, Object lock) { return new DependencyGraph() { @Override public Delta createDelta(Iterable<NodeSource> sourcesToProcess, Iterable<NodeSource> deletedSources) throws IOException { synchronized (lock) { return graph.createDelta(sourcesToProcess, deletedSources); } } @Override public DifferentiateResult differentiate(Delta delta, DifferentiateParameters params) { synchronized (lock) { return graph.differentiate(delta, params); } } @Override public void integrate(@NotNull DifferentiateResult diffResult) { synchronized (lock) { graph.integrate(diffResult); } } @Override public Iterable<BackDependencyIndex> getIndices() { return graph.getIndices(); } @Override public @Nullable BackDependencyIndex getIndex(String name) { return graph.getIndex(name); } @Override public Iterable<NodeSource> getSources(@NotNull ReferenceID id) { return graph.getSources(id); } @Override public Iterable<ReferenceID> getRegisteredNodes() { return graph.getRegisteredNodes(); } @Override public Iterable<NodeSource> getSources() { return graph.getSources(); } @Override public Iterable<Node<?, ?>> getNodes(@NotNull NodeSource source) { return graph.getNodes(source); } @Override public <T extends Node<T, ?>> Iterable<T> getNodes(NodeSource src, Class<T> nodeSelector) { return graph.getNodes(src, nodeSelector); } @Override public @NotNull Iterable<ReferenceID> getDependingNodes(@NotNull ReferenceID id) { return graph.getDependingNodes(id); } @Override public void close() throws IOException { synchronized (lock) { graph.close(); } } }; }
asSynchronizableGraph
2,449
DifferentiateResult (Delta delta, DifferentiateParameters params) { synchronized (lock) { return graph.differentiate(delta, params); } }
differentiate
2,450
void (@NotNull DifferentiateResult diffResult) { synchronized (lock) { graph.integrate(diffResult); } }
integrate
2,451
Iterable<BackDependencyIndex> () { return graph.getIndices(); }
getIndices
2,452
Iterable<NodeSource> (@NotNull ReferenceID id) { return graph.getSources(id); }
getSources
2,453
Iterable<ReferenceID> () { return graph.getRegisteredNodes(); }
getRegisteredNodes
2,454
Iterable<NodeSource> () { return graph.getSources(); }
getSources
2,455
Iterable<ReferenceID> (@NotNull ReferenceID id) { return graph.getDependingNodes(id); }
getDependingNodes
2,456
void () { if (reportStateUnavailable()) { return; } long start = System.nanoTime(); Map<String, Map<String, BuildTargetState>> targetTypeHashMap = loadCurrentTargetState(); List<BuildTarget<?>> buildTargets; if (targetTypeHashMap.isEmpty()) { buildTargets = myBuildTargetIndex.getAllTargets(); } else { List<BuildTarget<?>> changedBuildTargets = new ArrayList<>(myChangedBuildTargets.values()); LOG.info("List of changed build targets: " + changedBuildTargets); buildTargets = changedBuildTargets; } @Unmodifiable @NotNull List<? extends Future<?>> result; if (buildTargets.isEmpty()) { result = Collections.emptyList(); } else { List<Future<?>> list = new ArrayList<>(buildTargets.size()); for (BuildTarget<?> t : buildTargets) { list.add(myParallelBuildExecutor.submit(() -> { String targetTypeId = t.getTargetType().getTypeId(); getBuildTargetHash(t, myContext).ifPresent(buildTargetHash -> { // now in a project, each build target has a single output root String relativePath = ""; for (File file : t.getOutputRoots(myContext)) { relativePath = myRelativizer.toRelative(file.getAbsolutePath()); break; } synchronized (targetTypeHashMap) { targetTypeHashMap.computeIfAbsent(targetTypeId, key -> new HashMap<>()) .put(t.getId(), new BuildTargetState(buildTargetHash.toString(), relativePath)); } }); })); } result = list; } // now in a project, each build target has a single output root for (Future<?> future : result) { try { future.get(); } catch (InterruptedException | ExecutionException e) { LOG.warn("Unable to get the result from future", e); } } clearRemovedBuildTargets(targetTypeHashMap); try { FileUtil.writeToFile(myTargetStateStorage, gson.toJson(targetTypeHashMap)); } catch (IOException e) { LOG.warn("Unable to save sources state", e); } LOG.info("Build target sources report took: " + TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start) + " ms"); }
reportSourcesState
2,457
void (Map<String, Map<String, BuildTargetState>> targetsMap) { Map<String, List<String>> allTargets = new HashMap<>(); for (BuildTarget<?> it : myBuildTargetIndex.getAllTargets()) { String id = it.getId(); allTargets.computeIfAbsent(it.getTargetType().getTypeId(), k -> new ArrayList<>()).add(id); } targetsMap.keySet().removeIf(targetTypeId -> !allTargets.containsKey(targetTypeId)); for (Map.Entry<String, Map<String, BuildTargetState>> entry : targetsMap.entrySet()) { String targetTypeId = entry.getKey(); Map<String, BuildTargetState> targetStates = entry.getValue(); targetStates.keySet().removeIf(targetId -> !allTargets.get(targetTypeId).contains(targetId)); } }
clearRemovedBuildTargets
2,458
void () { if (reportStateUnavailable()) { return; } if (myTargetStateStorage.exists()) { LOG.info("Clear build target sources report"); FileUtilRt.delete(myTargetStateStorage); } }
clearSourcesState
2,459
void (@NotNull FileGeneratedEvent event) { if (reportStateUnavailable()) { return; } BuildTarget<?> sourceTarget = event.getSourceTarget(); String key = sourceTarget.getTargetType().getTypeId() + " " +sourceTarget.getId(); myChangedBuildTargets.put(key, sourceTarget); }
filesGenerated
2,460
void (@NotNull FileDeletedEvent event) { if (reportStateUnavailable()) { return; } for (String path : event.getFilePaths()) { File file = new File(FileUtilRt.toSystemDependentName(path)); Collection<BuildRootDescriptor> collection = myBuildRootIndex.findAllParentDescriptors(file, myContext); for (BuildRootDescriptor buildRootDesc : collection) { BuildTarget<?> target = buildRootDesc.getTarget(); String key = target.getTargetType().getTypeId() + target.getId(); myChangedBuildTargets.put(key, target); } } }
filesDeleted
2,461
List<Long> (File rootFile, BuildTarget<?> target) { try { if (!rootFile.exists()) { return null; } List<Long> targetRootHashes = new ArrayList<>(); Files.walkFileTree(rootFile.toPath(), EnumSet.of(FileVisitOption.FOLLOW_LINKS), Integer.MAX_VALUE, new SimpleFileVisitor<>() { @Override public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) { return FileVisitResult.CONTINUE; } @Override public FileVisitResult visitFile(Path path, BasicFileAttributes attrs) throws IOException { String filePathString = path.toString(); if (filePathString.endsWith(".class")) { Long calculatedHash = myCalculatedHashes.get(filePathString); if (calculatedHash != null) { targetRootHashes.add(calculatedHash); } else { File file = path.toFile(); long hash = getOutputFileHash(file, rootFile); targetRootHashes.add(hash); myCalculatedHashes.put(filePathString, hash); } } return FileVisitResult.CONTINUE; } }); return targetRootHashes; } catch (IOException e) { LOG.warn("Couldn't calculate build target hash for : " + target.getPresentableName(), e); return null; } }
compilationOutputHash
2,462
FileVisitResult (Path dir, BasicFileAttributes attrs) { return FileVisitResult.CONTINUE; }
preVisitDirectory
2,463
List<Long> (BuildRootDescriptor rootDescriptor, BuildTarget<?> target) { try { File rootFile = rootDescriptor.getRootFile(); if (!rootFile.exists() || rootFile.getAbsolutePath().startsWith(myOutputFolderPath)) { return null; } List<Long> targetRootHashes = new ArrayList<>(); Files.walkFileTree(rootFile.toPath(), EnumSet.of(FileVisitOption.FOLLOW_LINKS), Integer.MAX_VALUE, new SimpleFileVisitor<>() { @Override public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) { return myBuildRootIndex.isDirectoryAccepted(dir.toFile(), rootDescriptor) ? FileVisitResult.CONTINUE : FileVisitResult.SKIP_SUBTREE; } @Override public FileVisitResult visitFile(Path path, BasicFileAttributes attrs) throws IOException { final File file = path.toFile(); if (!myBuildRootIndex.isFileAccepted(file, rootDescriptor)) return FileVisitResult.CONTINUE; getFileHash(target, file, rootFile).ifPresent(targetRootHashes::add); return FileVisitResult.CONTINUE; } }); return targetRootHashes; } catch (IOException e) { LOG.warn("Couldn't calculate build target hash for : " + target.getPresentableName(), e); return null; } }
sourceRootHash
2,464
FileVisitResult (Path dir, BasicFileAttributes attrs) { return myBuildRootIndex.isDirectoryAccepted(dir.toFile(), rootDescriptor) ? FileVisitResult.CONTINUE : FileVisitResult.SKIP_SUBTREE; }
preVisitDirectory
2,465
Optional<Long> (@NotNull BuildTarget<?> target, @NotNull CompileContext context) { long[] longs = Stream.concat(target.getOutputRoots(context).stream().map(it -> compilationOutputHash(it, target)), myBuildRootIndex.getTargetRoots(target, context).stream().map(it -> sourceRootHash(it, target))) .filter(it -> it != null && !it.isEmpty()) .flatMap(List::stream) .mapToLong(x -> x) .toArray(); if (longs.length == 0) return Optional.empty(); return Optional.of(Xxh3HashingService.hashLongs(longs)); }
getBuildTargetHash
2,466
boolean () { return !PORTABLE_CACHES || myProjectStamps == null; }
reportStateUnavailable
2,467
String (@NotNull File target, @NotNull File rootPath) { return FileUtilRt.toSystemIndependentName(Path.of(rootPath.getPath()).relativize(Path.of(target.getPath())).toString()); }
toRelative
2,468
String (JpsProject project) { JpsJavaProjectExtension projectExtension = JpsJavaExtensionService.getInstance().getProjectExtension(project); if (projectExtension == null) { return ""; } String url = projectExtension.getOutputUrl(); if (url == null || url.isEmpty()) { return ""; } return JpsPathUtil.urlToFile(url).getAbsolutePath(); }
getOutputFolderPath
2,469
int (String value) { if (!PORTABLE_CACHES) return FileUtil.pathHashCode(value); // On case insensitive OS hash calculated from value converted to lower case return StringUtil.isEmpty(value) ? 0 : FileUtil.toCanonicalPath(value).hashCode(); }
getHashCode
2,470
boolean (String val1, String val2) { if (!PORTABLE_CACHES) return FileUtil.pathsEqual(val1, val2); // On case insensitive OS hash calculated from path converted to lower case if (Strings.areSameInstance(val1, val2)) return true; if (val1 == null || val2 == null) return false; String path1 = FileUtil.toCanonicalPath(val1); String path2 = FileUtil.toCanonicalPath(val2); return path1.equals(path2); }
isEqual
2,471
String (@NotNull String path) { return myRelativizer.toRelative(path); }
normalizePath
2,472
Collection<String> (Collection<String> outputs) { Collection<String> normalized = new ArrayList<>(outputs.size()); for (String out : outputs) { normalized.add(normalizePath(out)); } return normalized; }
normalizePaths
2,473
void () { synchronized (myDataLock) { myMap.force(); } }
force
2,474
boolean () { synchronized (myDataLock) { try { myMap.closeAndClean(); } catch (IOException ignored) { } try { myMap = createMap(myBaseFile); } catch (IOException ignored) { return false; } return true; } }
wipe
2,475
void (boolean memoryCachesOnly) { if (!memoryCachesOnly) { force(); } }
flush
2,476
String () { File configFile = getConfigFile(); if (configFile.exists()) { try { return new String(FileUtil.loadFileText(configFile)); } catch (IOException e) { LOG.info("Cannot load configuration of " + myTarget); } } return ""; }
load
2,477
boolean (@NotNull ProjectDescriptor pd) { return DIRTY_MARK.equals(myConfiguration) || !getCurrentState(pd).equals(myConfiguration); }
isTargetDirty
2,478
void (CompileContext context) { if (DIRTY_MARK.equals(myConfiguration)) { if (LOG.isDebugEnabled()) { LOG.debug(myTarget + " has been marked dirty in the previous compilation session"); } } else { final String currentState = getCurrentState(context.getProjectDescriptor()); if (!currentState.equals(myConfiguration)) { if (LOG.isDebugEnabled()) { LOG.debug(myTarget + " configuration was changed:"); LOG.debug("Old:"); LOG.debug(myConfiguration); LOG.debug("New:"); LOG.debug(currentState); LOG.debug(myTarget + " will be recompiled"); } if (myTarget instanceof ModuleBuildTarget) { final JpsModule module = ((ModuleBuildTarget)myTarget).getModule(); synchronized (MODULES_WITH_TARGET_CONFIG_CHANGED_KEY) { Set<JpsModule> modules = MODULES_WITH_TARGET_CONFIG_CHANGED_KEY.get(context); if (modules == null) { MODULES_WITH_TARGET_CONFIG_CHANGED_KEY.set(context, modules = new HashSet<>()); } modules.add(module); } } } } }
logDiagnostics
2,479
void (CompileContext context) { persist(getCurrentState(context.getProjectDescriptor())); }
save
2,480
void () { persist(DIRTY_MARK); }
invalidate
2,481
void (final String data) { try { File configFile = getConfigFile(); FileUtil.createParentDirs(configFile); try (Writer out = new BufferedWriter(new FileWriter(configFile))) { out.write(data); myConfiguration = data; } } catch (IOException e) { LOG.info("Cannot save configuration of " + myConfiguration, e); } }
persist
2,482
File () { return new File(myTargetsState.getDataPaths().getTargetDataRoot(myTarget), "config.dat"); }
getConfigFile
2,483
File () { return new File(myTargetsState.getDataPaths().getTargetDataRoot(myTarget), "nonexistent-outputs.dat"); }
getNonexistentOutputsFile
2,484
String (@NotNull ProjectDescriptor pd) { String state = myCurrentState; if (state == null) { myCurrentState = state = saveToString(pd); } return state; }
getCurrentState
2,485
String (@NotNull ProjectDescriptor pd) { StringWriter out = new StringWriter(); myTarget.writeConfiguration(pd, new PrintWriter(out)); return out.toString(); }
saveToString
2,486
boolean () { if (!myTargetsFile.exists()) { return false; } try (DataInputStream input = new DataInputStream(new BufferedInputStream(new FileInputStream(myTargetsFile)))) { int version = input.readInt(); int size = input.readInt(); BuildTargetLoader<?> loader = myTargetType.createLoader(myTargetsState.getModel()); while (size-- > 0) { String stringId = IOUtil.readString(input); int intId = input.readInt(); myTargetsState.markUsedId(intId); BuildTarget<?> target = loader.createTarget(stringId); if (target != null) { myTargetIds.put(target, intId); } else { myStaleTargetIds.add(Pair.create(stringId, intId)); } } if (version >= 1) { myAverageTargetBuildTimeMs = input.readLong(); } return true; } catch (IOException e) { LOG.info("Cannot load " + myTargetType.getTypeId() + " targets data: " + e.getMessage(), e); return false; } }
load
2,487
void (long timeInMs) { myAverageTargetBuildTimeMs = timeInMs; }
setAverageTargetBuildTime
2,488
long () { return myAverageTargetBuildTimeMs; }
getAverageTargetBuildTime
2,489
BuildTargetConfiguration (BuildTarget<?> target) { BuildTargetConfiguration configuration = myConfigurations.get(target); if (configuration == null) { configuration = new BuildTargetConfiguration(target, myTargetsState); final BuildTargetConfiguration existing = myConfigurations.putIfAbsent(target, configuration); if (existing != null) { configuration = existing; } } return configuration; }
getConfiguration
2,490
File () { return new File(myDataPaths.getTargetsDataRoot(), "targetTypes.dat"); }
getTargetTypesFile
2,491
void () { try { File targetTypesFile = getTargetTypesFile(); FileUtil.createParentDirs(targetTypesFile); try (DataOutputStream output = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(targetTypesFile)))) { output.writeInt(myMaxTargetId.get()); output.writeLong(myLastSuccessfulRebuildDuration); } } catch (IOException e) { LOG.info("Cannot save targets info: " + e.getMessage(), e); } for (BuildTargetTypeState state : myTypeStates.values()) { state.save(); } }
save
2,492
int (@NotNull BuildTarget<?> target) { return getTypeState(target.getTargetType()).getTargetId(target); }
getBuildTargetId
2,493
long () { return myLastSuccessfulRebuildDuration; }
getLastSuccessfulRebuildDuration
2,494
void (long duration) { myLastSuccessfulRebuildDuration = duration; }
setLastSuccessfulRebuildDuration
2,495
BuildTargetConfiguration (@NotNull BuildTarget<?> target) { return getTypeState(target.getTargetType()).getConfiguration(target); }
getTargetConfiguration
2,496
void (BuildTargetType<?> type, String targetId) { getTypeState(type).removeStaleTarget(targetId); }
cleanStaleTarget
2,497
void (BuildTargetType<?> type, long time) { getTypeState(type).setAverageTargetBuildTime(time); }
setAverageBuildTime
2,498
long (BuildTargetType<?> type) { return getTypeState(type).getAverageTargetBuildTime(); }
getAverageBuildTime
2,499
BuildTargetTypeState (BuildTargetType<?> type) { BuildTargetTypeState state = myTypeStates.get(type); if (state == null) { final BuildTargetTypeState newState = new BuildTargetTypeState(type, this); state = myTypeStates.putIfAbsent(type, newState); if (state == null) { state = newState; } } return state; }
getTypeState