Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
20,000
MavenIndexHolder () { if (isDisposed) { throw new AlreadyDisposedException("Index was already disposed"); } return myIndexHolder; }
getIndexHolder
20,001
File (File parent) { return createNewDir(parent, "Index", 1000); }
createNewIndexDir
20,002
File (File parent, String prefix, int max) { synchronized (ourDirectoryLock) { for (int i = 0; i < max; i++) { String name = prefix + i; File f = new File(parent, name); if (!f.exists()) { boolean createSuccessFull = f.mkdirs(); if (createSuccessFull) { return f; } } } throw new RuntimeException("No available dir found"); } }
createNewDir
20,003
void () { isDisposed = true; closeIndices(myIndexHolder.getIndices()); myIndexHolder = null; }
dispose
20,004
boolean () { return isDisposed; }
isDisposed
20,005
void (@NotNull List<MavenIndex> indices) { List<MavenIndex> list = new ArrayList<>(indices); for (MavenIndex each : list) { try { each.close(false); } catch (Exception e) { MavenLog.LOG.error("indices dispose error", e); } } }
closeIndices
20,006
RepositoryDiff<MavenIndex> (@NotNull MavenRepositoryInfo localRepo, @NotNull RepositoryDiffContext context, @Nullable MavenIndex currentLocalIndex) { if (currentLocalIndex != null && FileUtil.pathsEqual(localRepo.getUrl(), currentLocalIndex.getRepositoryPathOrUrl())) { return new RepositoryDiff<>(currentLocalIndex, null); } MavenIndex index = createMavenIndex(LOCAL_REPOSITORY_ID, localRepo.getUrl(), IndexKind.LOCAL); return new RepositoryDiff<>(index, currentLocalIndex); }
getLocalDiff
20,007
RepositoryDiff<List<MavenIndex>> ( @NotNull Map<String, Set<String>> remoteRepositoryIdsByUrl, @NotNull List<MavenIndex> currentRemoteIndex, @NotNull RepositoryDiffContext context) { Map<String, MavenIndex> currentRemoteIndicesByUrls = currentRemoteIndex.stream() .collect(Collectors.toMap(i -> i.getRepositoryPathOrUrl(), Function.identity())); if (currentRemoteIndicesByUrls.keySet().equals(remoteRepositoryIdsByUrl.keySet())) { return new RepositoryDiff<>(currentRemoteIndex, Collections.emptyList()); } List<MavenIndex> oldIndices = ContainerUtil .filter(currentRemoteIndex, i -> !remoteRepositoryIdsByUrl.containsKey(i.getRepositoryPathOrUrl())); List<MavenIndex> newMavenIndices = ContainerUtil.map(remoteRepositoryIdsByUrl .entrySet(), e -> { MavenIndex oldIndex = currentRemoteIndicesByUrls.get(e.getKey()); if (oldIndex != null) return oldIndex; String id = e.getValue().iterator().next(); return createMavenIndex(id, e.getKey(), IndexKind.REMOTE); }); return new RepositoryDiff<>(newMavenIndices, oldIndices); }
getRemoteDiff
20,008
void (@NotNull Project project) { try { DependencySearchService.getInstance(project).clearCache(); } catch (AlreadyDisposedException ignored) { } }
clearDependencySearchCache
20,009
MavenIndex (@NotNull String id, @NotNull String repositoryPathOrUrl, IndexKind indexKind) { return MavenSystemIndicesManager.getInstance() .getIndexForRepoSync(new MavenRepositoryInfo(id, id, repositoryPathOrUrl, indexKind)); }
createMavenIndex
20,010
List<MavenId> (Project project, String className) { if (MavenUtil.isMavenUnitTestModeEnabled()) { assert ourResultForTest != null; List<MavenId> res = ourResultForTest; ourResultForTest = null; return res; } MavenArtifactSearchDialog d = new MavenArtifactSearchDialog(project, className, true); if (!d.showAndGet()) { return Collections.emptyList(); } return d.getResult(); }
searchForClass
20,011
List<MavenId> (Project project, Collection<MavenDomDependency> managedDependencies) { if (MavenUtil.isMavenUnitTestModeEnabled()) { assert ourResultForTest != null; List<MavenId> res = ourResultForTest; ourResultForTest = null; return res; } MavenArtifactSearchDialog d = new MavenArtifactSearchDialog(project, "", false); d.setManagedDependencies(managedDependencies); if (!d.showAndGet()) { return Collections.emptyList(); } return d.getResult(); }
searchForArtifact
20,012
void (Collection<MavenDomDependency> managedDependencies) { myManagedDependenciesMap.clear(); for (MavenDomDependency dependency : managedDependencies) { String groupId = dependency.getGroupId().getStringValue(); String artifactId = dependency.getArtifactId().getStringValue(); String version = dependency.getVersion().getStringValue(); if (StringUtil.isNotEmpty(groupId) && StringUtil.isNotEmpty(artifactId) && StringUtil.isNotEmpty(version)) { myManagedDependenciesMap.put(Pair.create(groupId, artifactId), version); } } }
setManagedDependencies
20,013
void (Project project, @NlsSafe String initialText, boolean classMode) { myTabbedPane = new TabbedPaneWrapper(getDisposable()); MavenArtifactSearchPanel.Listener listener = new MavenArtifactSearchPanel.Listener() { @Override public void itemSelected() { clickDefaultButton(); } @Override public void canSelectStateChanged(@NotNull MavenArtifactSearchPanel from, boolean canSelect) { myOkButtonStates.put(from, canSelect); updateOkButtonState(); } }; myArtifactsPanel = new MavenArtifactSearchPanel(project, !classMode ? initialText : "", false, listener, this, myManagedDependenciesMap); myClassesPanel = new MavenArtifactSearchPanel(project, classMode ? initialText : "", true, listener, this, myManagedDependenciesMap); myTabbedPane.addTab(MavenDomBundle.message("maven.search.for.artifact.tab.title"), myArtifactsPanel); myTabbedPane.addTab(MavenDomBundle.message("maven.search.for.class.tab.title"), myClassesPanel); myTabbedPane.setSelectedIndex(classMode ? 1 : 0); myTabbedPane.getComponent().setPreferredSize(JBUI.size(900, 600)); myTabbedPane.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { updateOkButtonState(); } }); updateOkButtonState(); }
initComponents
20,014
void () { clickDefaultButton(); }
itemSelected
20,015
void (@NotNull MavenArtifactSearchPanel from, boolean canSelect) { myOkButtonStates.put(from, canSelect); updateOkButtonState(); }
canSelectStateChanged
20,016
void (ChangeEvent e) { updateOkButtonState(); }
stateChanged
20,017
void () { Boolean canSelect = myOkButtonStates.get(myTabbedPane.getSelectedComponent()); if (canSelect == null) canSelect = false; setOKActionEnabled(canSelect); }
updateOkButtonState
20,018
Action () { Action result = super.getOKAction(); result.putValue(Action.NAME, MavenDomBundle.message("maven.artifact.pom.search.add")); return result; }
getOKAction
20,019
JComponent () { return myTabbedPane.getComponent(); }
createCenterPanel
20,020
JComponent () { return myTabbedPane.getSelectedIndex() == 0 ? myArtifactsPanel.getSearchField() : myClassesPanel.getSearchField(); }
getPreferredFocusedComponent
20,021
String () { return "Maven.ArtifactSearchDialog"; }
getDimensionServiceKey
20,022
List<MavenId> () { return myResult; }
getResult
20,023
void () { MavenArtifactSearchPanel panel = myTabbedPane.getSelectedIndex() == 0 ? myArtifactsPanel : myClassesPanel; myResult = panel.getResult(); super.doOKAction(); }
doOKAction
20,024
List<MavenIndex> () { return myRemoteIndices; }
getRemoteIndices
20,025
List<MavenGAVIndex> () { if (myLocalIndex == null) { return ContainerUtil.filter(myRemoteIndices, idx -> idx != null); } else { ArrayList<MavenGAVIndex> result = new ArrayList<>(getRemoteIndices()); result.add(myLocalIndex); return result; } }
getGAVIndices
20,026
List<MavenIndex> () { return myIndices; }
getIndices
20,027
boolean (@NotNull Set<String> remoteUrls, @Nullable String localPath) { if (!FileUtilRt.pathsEqual(myLocalIndex != null ? myLocalIndex.getRepositoryPathOrUrl() : null, localPath)) return false; if (remoteUrls.size() != myRemoteIndices.size()) return false; for (MavenSearchIndex index : myRemoteIndices) { if (!remoteUrls.contains(index.getRepositoryPathOrUrl())) return false; } return true; }
isEquals
20,028
String () { return "MavenIndexHolder{" + myIndices + '}'; }
toString
20,029
void (MavenIndexImpl index) { Properties props = new Properties(); props.setProperty(KIND_KEY, index.getKind().toString()); props.setProperty(ID_KEY, index.getRepositoryId()); props.setProperty(PATH_OR_URL_KEY, index.getRepositoryPathOrUrl()); props.setProperty(INDEX_VERSION_KEY, CURRENT_VERSION); props.setProperty(TIMESTAMP_KEY, String.valueOf(index.getUpdateTimestamp())); if (index.getDataDirName() != null) props.setProperty(DATA_DIR_NAME_KEY, index.getDataDirName()); if (index.getFailureMessage() != null) props.setProperty(FAILURE_MESSAGE_KEY, index.getFailureMessage()); try (FileOutputStream s = new FileOutputStream(new File(index.getDir(), INDEX_INFO_FILE))) { props.store(s, null); } catch (IOException e) { MavenLog.LOG.warn(e); } }
saveIndexProperty
20,030
MavenRepositoryInfo (Project project) { if (project.isDisposed()) return null; File repository = MavenProjectsManager.getInstance(project).getLocalRepository(); return repository == null ? null : new MavenRepositoryInfo(LOCAL_REPOSITORY_ID, LOCAL_REPOSITORY_ID, repository.getPath(), IndexKind.LOCAL); }
getLocalRepository
20,031
String (@NotNull String pathOrUrl) { pathOrUrl = pathOrUrl.trim(); pathOrUrl = FileUtil.toSystemIndependentName(pathOrUrl); while (pathOrUrl.endsWith("/")) { pathOrUrl = pathOrUrl.substring(0, pathOrUrl.length() - 1); } return pathOrUrl; }
normalizePathOrUrl
20,032
MavenIndicesManager (@NotNull Project project) { return project.getService(MavenIndicesManager.class); }
getInstance
20,033
void () { myIndexFixer.stop(); deleteIndicesDirInUnitTests(); }
dispose
20,034
void () { if (MavenUtil.isMavenUnitTestModeEnabled()) { if (!myMavenIndices.isDisposed()) { var localIndex = myMavenIndices.getIndexHolder().getLocalIndex(); if (localIndex instanceof MavenIndexImpl impl) { impl.closeAndClean(); } } Path dir = MavenSystemIndicesManager.getInstance().getIndicesDir(); try { PathKt.delete(dir); } catch (Exception e) { // if some files haven't been deleted in the index directory, report them try (Stream<Path> stream = Files.walk(dir)) { var files = stream.map(Path::toString).toList(); var message = files.isEmpty() ? "Failed to delete the index directory" : "Failed to delete files in the index directory: " + String.join(", ", files); throw new RuntimeException(message, e); } catch (IOException ex) { throw new RuntimeException(ex); } } } }
deleteIndicesDirInUnitTests
20,035
MavenIndexHolder () { if (myMavenIndices.isNotInit() && !ApplicationManager.getApplication().isUnitTestMode()) { myIndexUpdateManager.scheduleUpdateIndicesList(myProject, null); } return myMavenIndices.getIndexHolder(); }
getIndex
20,036
boolean () { return myMavenIndices.isIndicesInit(); }
isInit
20,037
void () { ApplicationManager.getApplication().getMessageBus().connect(this) .subscribe(MavenServerConnector.DOWNLOAD_LISTENER_TOPIC, myDownloadListener); ApplicationManager.getApplication().getMessageBus().connect(this) .subscribe(MavenIndex.INDEX_IS_BROKEN, new MavenSearchIndexListener(this)); if (ApplicationManager.getApplication().isUnitTestMode()) { MavenProjectsManager.getInstance(myProject).addProjectsTreeListener(new MavenProjectsTree.Listener() { @Override public void projectsUpdated(@NotNull List<Pair<MavenProject, MavenProjectChanges>> updated, @NotNull List<MavenProject> deleted) { DependencySearchService.getInstance(myProject).clearCache(); } @Override public void projectResolved(@NotNull Pair<MavenProject, MavenProjectChanges> projectWithChanges, @Nullable NativeMavenProjectHolder nativeMavenProject) { DependencySearchService.getInstance(myProject).clearCache(); } }, this); return; } MavenRepositoryProvider.EP_NAME.addChangeListener(() -> scheduleUpdateIndicesList(null), this); MavenProjectsManager projectsManager = MavenProjectsManager.getInstance(myProject); projectsManager.addProjectsTreeListener(new MavenProjectsTree.Listener() { @Override public void projectResolved(@NotNull Pair<MavenProject, MavenProjectChanges> projectWithChanges, @Nullable NativeMavenProjectHolder nativeMavenProject) { scheduleUpdateIndicesList(null); } }, this); }
initListeners
20,038
void (@NotNull List<Pair<MavenProject, MavenProjectChanges>> updated, @NotNull List<MavenProject> deleted) { DependencySearchService.getInstance(myProject).clearCache(); }
projectsUpdated
20,039
void (@NotNull Pair<MavenProject, MavenProjectChanges> projectWithChanges, @Nullable NativeMavenProjectHolder nativeMavenProject) { DependencySearchService.getInstance(myProject).clearCache(); }
projectResolved
20,040
void (@NotNull Pair<MavenProject, MavenProjectChanges> projectWithChanges, @Nullable NativeMavenProjectHolder nativeMavenProject) { scheduleUpdateIndicesList(null); }
projectResolved
20,041
void (@NotNull MavenArchetype archetype) { MavenArchetypeManager.addArchetype(archetype, getUserArchetypesFile()); }
addArchetype
20,042
boolean (@NotNull String groupId) { MavenIndex localIndex = getIndex().getLocalIndex(); return localIndex != null && localIndex.hasGroupId(groupId); }
hasLocalGroupId
20,043
boolean (@Nullable String groupId, @Nullable String artifactId) { MavenIndex localIndex = getIndex().getLocalIndex(); return localIndex != null && localIndex.hasArtifactId(groupId, artifactId); }
hasLocalArtifactId
20,044
boolean (@Nullable String groupId, @Nullable String artifactId, @Nullable String version) { MavenIndex localIndex = getIndex().getLocalIndex(); return localIndex != null && localIndex.hasVersion(groupId, artifactId, version); }
hasLocalVersion
20,045
boolean (@Nullable MavenId mavenId, @NotNull File artifactFile) { if (myMavenIndices.isNotInit()) return false; try { MavenIndex localIndex = myMavenIndices.getIndexHolder().getLocalIndex(); if (localIndex == null) { return false; } if (mavenId != null) { if (mavenId.getGroupId() == null || mavenId.getArtifactId() == null || mavenId.getVersion() == null) { return false; } if (localIndex.hasVersion(mavenId.getGroupId(), mavenId.getArtifactId(), mavenId.getVersion())) return false; } AppExecutorUtil.getAppExecutorService().execute(() -> { myIndexFixer.fixIndex(artifactFile); }); } catch (AlreadyDisposedException ignore) { return false; } return true; }
scheduleArtifactIndexing
20,046
void () { myIndexUpdateManager.scheduleUpdateContent(myProject, IndicesContentUpdateRequest.explicit( ContainerUtil.map(myMavenIndices.getIndices(), MavenIndex::getRepository))); }
scheduleUpdateContentAll
20,047
void (@Nullable Consumer<? super List<MavenIndex>> consumer) { myIndexUpdateManager.scheduleUpdateIndicesList(myProject, consumer); }
scheduleUpdateIndicesList
20,048
Path () { return MavenSystemIndicesManager.getInstance().getIndicesDir().resolve("UserArchetypes.xml"); }
getUserArchetypesFile
20,049
void (@NotNull File file) { if (stopped.get()) return; queueToAdd.add(file); myMergingUpdateQueue.queue(new Update(this) { @Override public void run() { taskConsumer.run(); } @Override public boolean isDisposed() { return myMavenIndices.isDisposed(); } }); }
fixIndex
20,050
void () { taskConsumer.run(); }
run
20,051
boolean () { return myMavenIndices.isDisposed(); }
isDisposed
20,052
void () { stopped.set(true); }
stop
20,053
void () { MavenIndex localIndex = myMavenIndices.getIndexHolder().getLocalIndex(); if (localIndex == null) return; Set<File> addedFiles = new TreeSet<>(); Set<File> failedToAddFiles = new TreeSet<>(); synchronized (queueToAdd) { if (stopped.get()) return; if (queueToAdd.isEmpty()) return; Set<File> filesToAddNow = new TreeSet<>(); File elementToAdd; while ((elementToAdd = queueToAdd.poll()) != null) { filesToAddNow.add(elementToAdd); } if (filesToAddNow.isEmpty()) return; Set<File> retryElements = new TreeSet<>(); var addArtifactResponses = localIndex.tryAddArtifacts(filesToAddNow); for (var addArtifactResponse : addArtifactResponses) { var file = addArtifactResponse.artifactFile(); var added = addArtifactResponse.indexedMavenId() != null; if (added) { addedFiles.add(file); } else { retryElements.add(file); } } if (!retryElements.isEmpty()) { if (retryElements.size() < 10_000) { queueToAdd.addAll(retryElements); } else { MavenLog.LOG.error("Failed to index artifacts: " + retryElements.size()); failedToAddFiles.addAll(retryElements); } } } fireUpdated(addedFiles, failedToAddFiles); }
run
20,054
void (Set<File> added, Set<File> failedToAdd) { if (stopped.get()) return; if (!added.isEmpty() || !failedToAdd.isEmpty()) { ApplicationManager.getApplication().getMessageBus().syncPublisher(INDEXER_TOPIC).indexUpdated(added, failedToAdd); } }
fireUpdated
20,055
void (File file, String relativePath) { myManager.scheduleArtifactIndexing(null, file); }
artifactDownloaded
20,056
void (@NotNull MavenSearchIndex index) { if (index instanceof MavenUpdatableIndex) { myManager.myIndexUpdateManager.scheduleUpdateContent(myManager.myProject, IndicesContentUpdateRequest.explicit(List.of(index.getRepository()))); } }
indexIsBroken
20,057
void () { myIndexUpdateManager.waitForBackgroundTasksInTests(); }
waitForBackgroundTasksInTests
20,058
JComponent () { return myMainPanel; }
createCenterPanel
20,059
String () { String result = myUrlField.getText(); if (VirtualFileManager.extractProtocol(result) == null) { result = "http://" + result; } return result; }
getUrl
20,060
JComponent () { return myUrlField; }
getPreferredFocusedComponent
20,061
List<MavenClassSearchResult> (Project project, String pattern, int maxResult) { String patternForQuery = preparePattern(pattern); MavenIndicesManager m = MavenIndicesManager.getInstance(project); Set<MavenArtifactInfo> infos = m.getIndex() .getIndices().stream() .flatMap(i -> i.search(patternForQuery, 50).stream()) .collect(Collectors.toSet()); ArrayList<MavenClassSearchResult> results = new ArrayList<>(processResults(infos, patternForQuery, maxResult)); results.sort(Comparator.comparing(MavenClassSearchResult::getClassName)); return results; }
searchImpl
20,062
String (String pattern) { pattern = pattern.toLowerCase(); if (pattern.trim().isEmpty()) { return ""; } List<String> parts = StringUtil.split(pattern, "."); StringBuilder newPattern = new StringBuilder(); for (int i = 0; i < parts.size() - 1; i++) { String each = parts.get(i); newPattern.append(each.trim()); newPattern.append("*."); } String className = parts.get(parts.size() - 1); boolean exactSearch = className.endsWith(" "); newPattern.append(className.trim()); if (!exactSearch) newPattern.append("*"); return newPattern.toString(); }
preparePattern
20,063
Collection<MavenClassSearchResult> (Set<MavenArtifactInfo> infos, String pattern, int maxResult) { if (pattern.isEmpty() || pattern.equals("*")) { pattern = "^/(.*)$"; } else { pattern = pattern.replace(".", "/"); int lastDot = pattern.lastIndexOf("/"); String packagePattern = lastDot == -1 ? "" : (pattern.substring(0, lastDot) + "/"); String classNamePattern = lastDot == -1 ? pattern : pattern.substring(lastDot + 1); packagePattern = packagePattern.replaceAll("\\*", ".*?"); classNamePattern = classNamePattern.replaceAll("\\*", "[^/]*?"); pattern = packagePattern + classNamePattern; pattern = ".*?/" + pattern; pattern = "^(" + pattern + ")$"; } Pattern p; try { p = Pattern.compile(pattern, Pattern.CASE_INSENSITIVE | Pattern.MULTILINE); } catch (PatternSyntaxException e) { return Collections.emptyList(); } Map<String, MavenClassSearchResult> result = new HashMap<>(); for (MavenArtifactInfo each : infos) { if (each.getClassNames() == null) continue; Matcher matcher = p.matcher(each.getClassNames()); while (matcher.find()) { String classFQName = matcher.group(1); classFQName = classFQName.replace("/", "."); classFQName = StringUtil.trimStart(classFQName, "."); String key = classFQName; MavenClassSearchResult classResult = result.get(key); if (classResult == null) { int pos = classFQName.lastIndexOf("."); MavenRepositoryArtifactInfo artifactInfo = new MavenRepositoryArtifactInfo( each.getGroupId(), each.getArtifactId(), Collections.singletonList(each.getVersion())); if (pos == -1) { result.put(key, new MavenClassSearchResult(artifactInfo, classFQName, "default package")); } else { result.put(key, new MavenClassSearchResult(artifactInfo, classFQName.substring(pos + 1), classFQName.substring(0, pos))); } } else { List<String> versions = ContainerUtil.append(ContainerUtil.map(classResult.getSearchResults().getItems(), i -> i.getVersion()), each.getVersion()); MavenRepositoryArtifactInfo artifactInfo = new MavenRepositoryArtifactInfo( each.getGroupId(), each.getArtifactId(), versions); result.put(key, new MavenClassSearchResult(artifactInfo, classResult.getClassName(), classResult.getPackageName())); } if (result.size() > maxResult) break; } } result.values().forEach(a -> Arrays.sort(a.getSearchResults().getItems(), Comparator.comparing(MavenDependencyCompletionItem::getVersion, VersionComparatorUtil.COMPARATOR) .reversed()) ); return result.values(); }
processResults
20,064
void () { myUpdatingQueue.clear(); }
dispose
20,065
void (@NotNull ProgressIndicator indicator) { try { indicator.setIndeterminate(false); doUpdateIndicesContent(project, request, new MavenProgressIndicator(null, indicator, null)); } catch (MavenProcessCanceledException ignore) { } finally { promise.complete(null); } }
run
20,066
String () { return className; }
getClassName
20,067
String () { return packageName; }
getPackageName
20,068
List<MavenArtifactSearchResult> (Project project, String pattern, int maxResult) { if (StringUtil.isEmpty(pattern)) { return Collections.emptyList(); } List<MavenRepositoryArtifactInfo> searchResults = new ArrayList<>(); DependencySearchService searchService = DependencySearchService.getInstance(project); boolean useLocalProvidersOnly = ApplicationManager.getApplication().isUnitTestMode(); SearchParameters parameters = new SearchParameters(false, useLocalProvidersOnly); Promise<Integer> asyncPromise = searchService.fulltextSearch(pattern, parameters, mdci -> { if (mdci instanceof MavenRepositoryArtifactInfo) { searchResults.add((MavenRepositoryArtifactInfo)mdci); } }); new WaitFor(1000) { @Override protected boolean condition() { return asyncPromise.getState() != Promise.State.PENDING; } }; return processResults(searchResults); }
searchImpl
20,069
boolean () { return asyncPromise.getState() != Promise.State.PENDING; }
condition
20,070
List<MavenArtifactSearchResult> (List<MavenRepositoryArtifactInfo> searchResults) { return ContainerUtil.map(searchResults, MavenArtifactSearchResult::new); }
processResults
20,071
MavenRepositoryArtifactInfo () { return myInfo; }
getSearchResults
20,072
LogMessageType (@NotNull String line) { for (LogMessageType type : LogMessageType.values()) { if (line.startsWith(type.myPrefix)) { return type; } } return null; }
determine
20,073
String (@NotNull String line) { int i = line.lastIndexOf("\r"); if (i == -1) return line; return line.substring(i + 1); }
clearProgressCarriageReturns
20,074
String (@Nullable LogMessageType type, @NotNull String line) { return type == null ? line : type.clearLine(line); }
clearLine
20,075
LogMessageType () { return myType; }
getType
20,076
String () { return myLine; }
getLine
20,077
String () { return myType == null ? myLine : "[" + myType.toString() + "] " + myLine; }
toString
20,078
boolean (Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; MavenLogEntry entry = (MavenLogEntry)o; return myType == entry.myType && myLine.equals(entry.myLine); }
equals
20,079
int () { return Objects.hash(myType, myLine); }
hashCode
20,080
MavenParsingContext () { return myParsingContext; }
getParsingContext
20,081
void (Consumer<? super BuildEvent> messageConsumer) { for (MavenLoggedEventParser parser : myRegisteredEvents) { parser.finish(myTaskId, messageConsumer); } }
completeParsers
20,082
boolean (String line, BuildOutputInstantReader reader, Consumer<? super BuildEvent> messageConsumer) { if (myParsingContext.getSessionEnded()) { checkErrorAfterMavenSessionEnded(line, messageConsumer); return false; } if (line == null || StringUtil.isEmptyOrSpaces(line)) { return false; } if (MavenSpyOutputParser.isSpyLog(line)) { mavenSpyOutputParser.processLine(line, messageConsumer); if (myParsingContext.getSessionEnded()) completeParsers(messageConsumer); return true; } else { sendMessageToAllParents(line, messageConsumer); MavenLogEntryReader.MavenLogEntry logLine = nextLine(line); MavenLogEntryReader mavenLogReader = wrapReader(reader); for (MavenLoggedEventParser event : myRegisteredEvents) { if (!event.supportsType(logLine.myType)) { continue; } if (event.checkLogLine(myParsingContext.getLastId(), myParsingContext, logLine, mavenLogReader, messageConsumer)) { return true; } } } return false; }
parse
20,083
void (String line, Consumer<? super BuildEvent> messageConsumer) { if (!myParsingContext.getProjectFailure()) { if (line.contains("[ERROR]")) { myParsingContext.setProjectFailure(true); messageConsumer.accept(new FinishBuildEventImpl(myTaskId, null, System.currentTimeMillis(), "", new FailureResultImpl())); } } }
checkErrorAfterMavenSessionEnded
20,084
void (@NlsSafe String line, Consumer<? super BuildEvent> messageConsumer) { List<MavenParsingContext.MavenExecutionEntry> ids = myParsingContext.getAllEntriesReversed(); for (MavenParsingContext.MavenExecutionEntry entry : ids) { if (entry.getId() == myTaskId) { return; } messageConsumer.accept(new OutputBuildEventImpl(entry.getId(), withSeparator(line), true)); } }
sendMessageToAllParents
20,085
String (@NotNull String line) { if (line.endsWith("\n")) { return line; } return line + "\n"; }
withSeparator
20,086
MavenLogEntryReader (BuildOutputInstantReader reader) { return new MavenLogEntryReader() { @Override public void pushBack() { reader.pushBack(); } @Nullable @Override public MavenLogEntry readLine() { return nextLine(reader.readLine()); } }; }
wrapReader
20,087
void () { reader.pushBack(); }
pushBack
20,088
MavenLogEntry () { return nextLine(reader.readLine()); }
readLine
20,089
ProjectSystemId () { return MavenUtil.SYSTEM_ID; }
getExternalSystemId
20,090
List<BuildOutputParser> (@NotNull ExternalSystemTaskId taskId) { throw new UnsupportedOperationException(); }
getBuildOutputParsers
20,091
MavenLogOutputParser (@NotNull MavenRunConfiguration runConfiguration, @NotNull ExternalSystemTaskId taskId, @NotNull Function<String, String> targetFileMapper) { return new MavenLogOutputParser(runConfiguration, taskId, targetFileMapper, MavenLoggedEventParser.EP_NAME.getExtensionList()); }
createMavenOutputParser
20,092
boolean (String s) { return s != null && s.startsWith(PREFIX); }
isSpyLog
20,093
void (@NotNull String spyLine, @NotNull Consumer<? super BuildEvent> messageConsumer) { String line = spyLine.substring(PREFIX.length()); try { int threadSeparatorIdx = line.indexOf('-'); if (threadSeparatorIdx < 0) { return; } int threadId; try { threadId = Integer.parseInt(line.substring(0, threadSeparatorIdx)); } catch (NumberFormatException ignore) { return; } if (threadId < 0) { return; } int typeSeparatorIdx = line.indexOf(SEPARATOR, threadSeparatorIdx + 1); if (typeSeparatorIdx < 0) { return; } String type = line.substring(threadSeparatorIdx + 1, typeSeparatorIdx); List<String> data = StringUtil.split(line.substring(typeSeparatorIdx + SEPARATOR.length()), SEPARATOR); Map<String, String> parameters = data.stream().map(d -> d.split("=")).filter(d -> d.length == 2).peek(d -> d[1] = d[1].replace(NEWLINE, "\n")) .collect(Collectors.toMap(d -> d[0], d -> d[1])); MavenEventType eventType = MavenEventType.valueByName(type); if (eventType == null) { return; } processErrorLogLine(parameters.get("error"), eventType, messageConsumer); parse(threadId, eventType, parameters, messageConsumer); } catch (Exception e) { MavenLog.LOG.error(e); } }
processLine
20,094
void (int threadId, MavenEventType type, Map<String, String> parameters, Consumer<? super BuildEvent> messageConsumer) { switch (type) { case SESSION_STARTED -> { List<String> projectsInReactor = getProjectsInReactor(parameters); myContext.setProjectsInReactor(projectsInReactor); } case SESSION_ENDED -> doFinishSession(messageConsumer, myContext); case PROJECT_STARTED -> { MavenParsingContext.ProjectExecutionEntry execution = myContext.getProject(threadId, parameters, true); if (execution == null) { MavenLog.LOG.debug("Not found for " + parameters); } else { messageConsumer .accept(new StartEventImpl(execution.getId(), execution.getParentId(), System.currentTimeMillis(), execution.getName())); } } case MOJO_STARTED -> { MavenParsingContext.MojoExecutionEntry mojoExecution = myContext.getMojo(threadId, parameters, true); doStart(messageConsumer, mojoExecution); } case MOJO_SUCCEEDED -> { stopFakeDownloadNode(threadId, parameters, messageConsumer); MavenParsingContext.MojoExecutionEntry mojoExecution = myContext.getMojo(threadId, parameters, false); doComplete(messageConsumer, mojoExecution); } case MOJO_FAILED -> { stopFakeDownloadNode(threadId, parameters, messageConsumer); MavenParsingContext.MojoExecutionEntry mojoExecution = myContext.getMojo(threadId, parameters, false); if (mojoExecution == null) { MavenLog.LOG.debug("Not found id for " + parameters); } else { messageConsumer.accept( new FinishEventImpl(mojoExecution.getId(), mojoExecution.getParentId(), System.currentTimeMillis(), mojoExecution.getName(), new MavenTaskFailedResultImpl(parameters.get("error")))); mojoExecution.complete(); } } case MOJO_SKIPPED -> { stopFakeDownloadNode(threadId, parameters, messageConsumer); MavenParsingContext.MojoExecutionEntry mojoExecution = myContext.getMojo(threadId, parameters, false); doSkip(messageConsumer, mojoExecution); } case PROJECT_SUCCEEDED -> { stopFakeDownloadNode(threadId, parameters, messageConsumer); MavenParsingContext.ProjectExecutionEntry execution = myContext.getProject(threadId, parameters, false); doComplete(messageConsumer, execution); } case PROJECT_SKIPPED -> { MavenParsingContext.ProjectExecutionEntry execution = myContext.getProject(threadId, parameters, false); doSkip(messageConsumer, execution); } case PROJECT_FAILED -> { stopFakeDownloadNode(threadId, parameters, messageConsumer); MavenParsingContext.ProjectExecutionEntry execution = myContext.getProject(threadId, parameters, false); myContext.setProjectFailure(true); doError(messageConsumer, execution, parameters.get("error")); } case ARTIFACT_RESOLVED -> artifactResolved(threadId, parameters, messageConsumer); case ARTIFACT_DOWNLOADING -> artifactDownloading(threadId, parameters, messageConsumer); } }
parse
20,095
void (String errorLine, MavenEventType eventType, Consumer<? super BuildEvent> messageConsumer) { if (errorLine == null) return; for (MavenSpyLoggedEventParser eventParser : MavenSpyLoggedEventParser.EP_NAME.getExtensionList()) { if (eventParser.supportsType(eventType) && eventParser.processLogLine(myContext.getLastId(), myContext, errorLine, messageConsumer)) { return; } } }
processErrorLogLine
20,096
List<String> (Map<String, String> parameters) { String joined = parameters.get("projects"); if (StringUtil.isEmptyOrSpaces(joined)) { return Collections.emptyList(); } List<String> result = new ArrayList<>(); for (String project : joined.split("&&")) { if (StringUtil.isEmptyOrSpaces(project)) { continue; } result.add(project); } return result; }
getProjectsInReactor
20,097
void (int threadId, Map<String, String> parameters, Consumer<? super BuildEvent> messageConsumer) { @NlsSafe String artifactCoord = parameters.get("artifactCoord"); if (artifactCoord == null || !downloadingMap.add(artifactCoord)) { return; } MavenParsingContext.MavenExecutionEntry parent = startFakeDownloadNodeIfNotStarted(threadId, parameters, messageConsumer); messageConsumer .accept( new StartEventImpl(getDownloadId(artifactCoord), parent.getId(), System.currentTimeMillis(), artifactCoord)); }
artifactDownloading
20,098
void (int threadId, Map<String, String> parameters, Consumer<? super BuildEvent> messageConsumer) { @NlsSafe String artifactCoord = parameters.get("artifactCoord"); if (artifactCoord == null) { return; } @NlsSafe String error = parameters.get("error"); if (error != null || downloadingMap.contains(artifactCoord)) { MavenParsingContext.MavenExecutionEntry parent = startFakeDownloadNodeIfNotStarted(threadId, parameters, messageConsumer); if (error != null) { if (downloadingMap.remove(artifactCoord)) { messageConsumer .accept(new FinishEventImpl(getDownloadId(artifactCoord), parent.getId(), System.currentTimeMillis(), artifactCoord, new FailureResultImpl(error, null))); } else { Object eventId = new Object(); messageConsumer .accept(new StartEventImpl(eventId, parent.getId(), System.currentTimeMillis(), error)); messageConsumer .accept(new FinishEventImpl(eventId, parent.getId(), System.currentTimeMillis(), error, new FailureResultImpl())); } } else { messageConsumer .accept(new FinishEventImpl(getDownloadId(artifactCoord), parent.getId(), System.currentTimeMillis(), artifactCoord, new SuccessResultImpl(false))); } } }
artifactResolved
20,099
String (String artifactCoord) { return "download" + artifactCoord; }
getDownloadId