Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
287,000
boolean () { PsiElement element = getElement(); if (element == null || !element.isValid()) { return false; } for (UsageInfo usageInfo : getMergedInfos()) { if (usageInfo.isValid()) return true; } return false; }
isValid
287,001
boolean () { PsiFile psiFile = getPsiFile(); return psiFile == null || psiFile.isValid() && !psiFile.isWritable(); }
isReadOnly
287,002
FileEditorLocation () { VirtualFile virtualFile = getFile(); if (virtualFile == null) return null; FileEditor editor = FileEditorManager.getInstance(getProject()).getSelectedEditor(virtualFile); if (!(editor instanceof TextEditor)) return null; Segment segment = getUsageInfo().getSegment(); if (segment == null) return null; return new TextEditorLocation(segment.getStartOffset(), (TextEditor)editor); }
getLocation
287,003
void () { if (!isValid()) return; Editor editor = openTextEditor(true); Segment marker = getFirstSegment(); if (marker != null) { editor.getSelectionModel().setSelection(marker.getStartOffset(), marker.getEndOffset()); } }
selectInEditor
287,004
void () { if (!isValid()) return; Segment marker = getFirstSegment(); if (marker != null) { SelectInEditorManager.getInstance(getProject()).selectInEditor(getFile(), marker.getStartOffset(), marker.getEndOffset(), false, false); } }
highlightInEditor
287,005
Segment () { return getUsageInfo().getSegment(); }
getFirstSegment
287,006
boolean (@NotNull Processor<? super Segment> processor) { for (UsageInfo usageInfo : getMergedInfos()) { Segment segment = usageInfo.getSegment(); if (segment != null && !processor.process(segment)) { return false; } } return true; }
processRangeMarkers
287,007
Document () { PsiFile file = getUsageInfo().getFile(); if (file == null) return null; return PsiDocumentManager.getInstance(getProject()).getDocument(file); }
getDocument
287,008
void (boolean focus) { if (canNavigate()) { UsageViewStatisticsCollector.logUsageNavigate(getProject(), this); openTextEditor(focus); } }
navigate
287,009
Editor (boolean focus) { OpenFileDescriptor descriptor = getDescriptor(); if (descriptor == null) return null; return FileEditorManager.getInstance(getProject()).openTextEditor(descriptor, focus); }
openTextEditor
287,010
boolean () { VirtualFile file = getFile(); return file != null && file.isValid(); }
canNavigate
287,011
boolean () { return canNavigate(); }
canNavigateToSource
287,012
OpenFileDescriptor () { VirtualFile file = getFile(); if(file == null) return null; Segment range = getNavigationRange(); if (range != null && file instanceof VirtualFileWindow && range.getStartOffset() >= 0) { // have to use injectedToHost(TextRange) to calculate right offset in case of multiple shreds range = ((VirtualFileWindow)file).getDocumentWindow().injectedToHost(TextRange.create(range)); file = ((VirtualFileWindow)file).getDelegate(); } return new OpenFileDescriptor(getProject(), file, range == null ? getNavigationOffset() : range.getStartOffset()); }
getDescriptor
287,013
int () { Document document = getDocument(); if (document == null) return -1; int offset = getUsageInfo().getNavigationOffset(); if (offset == -1) offset = myOffset; if (offset >= document.getTextLength()) { int line = Math.max(0, Math.min(myLineNumber, document.getLineCount() - 1)); offset = document.getLineStartOffset(line); } return offset; }
getNavigationOffset
287,014
Segment () { Document document = getDocument(); if (document == null) return null; Segment range = getUsageInfo().getNavigationRange(); if (range == null) { ProperTextRange rangeInElement = getUsageInfo().getRangeInElement(); range = myOffset < 0 ? new UnfairTextRange(-1,-1) : rangeInElement == null ? TextRange.from(myOffset,1) : rangeInElement.shiftRight(myOffset); } if (range.getEndOffset() >= document.getTextLength()) { int line = Math.max(0, Math.min(myLineNumber, document.getLineCount() - 1)); range = TextRange.from(document.getLineStartOffset(line),1); } return range; }
getNavigationRange
287,015
Project () { return getUsageInfo().getProject(); }
getProject
287,016
String () { TextChunk[] textChunks = getPresentation().getText(); StringBuilder result = new StringBuilder(); for (int j = 0; j < textChunks.length; j++) { if (j > 0) result.append("|"); TextChunk textChunk = textChunks[j]; result.append(textChunk); } return result.toString(); }
toString
287,017
Module () { if (!isValid()) return null; VirtualFile virtualFile = getFile(); return virtualFile != null ? ProjectFileIndex.getInstance(getProject()).getModuleForFile(virtualFile) : null; }
getModule
287,018
OrderEntry () { if (!isValid()) return null; VirtualFile virtualFile = getFile(); if (virtualFile == null) return null; ProjectFileIndex fileIndex = ProjectFileIndex.getInstance(getProject()); if (virtualFile.getFileType().isBinary() || fileIndex.isInLibrarySource(virtualFile)) { List<OrderEntry> orders = fileIndex.getOrderEntriesForFile(virtualFile); for (OrderEntry order : orders) { if (order instanceof LibraryOrderEntry || order instanceof JdkOrderEntry) { return order; } } } return null; }
getLibraryEntry
287,019
List<SyntheticLibrary> () { if (!isValid()) return Collections.emptyList(); VirtualFile virtualFile = getFile(); if (virtualFile == null) return Collections.emptyList(); Project project = getProject(); ProjectFileIndex fileIndex = ProjectFileIndex.getInstance(project); if (!fileIndex.isInLibrarySource(virtualFile)) return Collections.emptyList(); VirtualFile sourcesRoot = fileIndex.getSourceRootForFile(virtualFile); if (sourcesRoot != null) { List<SyntheticLibrary> list = new ArrayList<>(); for (AdditionalLibraryRootsProvider e : AdditionalLibraryRootsProvider.EP_NAME.getExtensionList()) { for (SyntheticLibrary library : e.getAdditionalProjectLibraries(project)) { if (library.getSourceRoots().contains(sourcesRoot)) { Condition<VirtualFile> excludeFileCondition = library.getUnitedExcludeCondition(); if (excludeFileCondition == null || !excludeFileCondition.value(virtualFile)) { list.add(library); } } } } return list; } return Collections.emptyList(); }
getSyntheticLibraries
287,020
VirtualFile () { return myVirtualFile; }
getFile
287,021
PsiFile () { return getUsageInfo().getFile(); }
getPsiFile
287,022
String () { VirtualFile file = getFile(); return file != null ? file.getPath() : ""; }
getPath
287,023
int () { return myLineNumber; }
getLine
287,024
boolean (@NotNull MergeableUsage other) { if (!(other instanceof UsageInfo2UsageAdapter u2)) return false; assert u2 != this; if (myLineNumber != u2.myLineNumber || !Comparing.equal(getFile(), u2.getFile())) return false; UsageInfo[] merged = ArrayUtil.mergeArrays(getMergedInfos(), u2.getMergedInfos()); myMergedUsageInfos = merged.length == 1 ? merged[0] : merged; Arrays.sort(getMergedInfos(), BY_NAVIGATION_OFFSET); // Invalidate cached presentation, so it'll be updated later // Do not reset it to still have something to present myModificationStamp = Long.MIN_VALUE; return true; }
merge
287,025
void () { ThreadingAssertions.assertEventDispatchThread(); myMergedUsageInfos = myUsageInfo; resetCachedPresentation(); }
reset
287,026
void () { // Invalidate cached presentation, so it'll be updated later // Do not clear it to still have something to present myModificationStamp = Long.MIN_VALUE; }
resetCachedPresentation
287,027
boolean () { return getUsageInfo().isNonCodeUsage; }
isNonCodeUsage
287,028
UsageInfo () { return myUsageInfo; }
getUsageInfo
287,029
int (@NotNull UsageInfo2UsageAdapter o) { int byPath = VfsUtilCore.compareByPath(myVirtualFile, o.myVirtualFile); if (byPath != 0) { return byPath; } return Integer.compare(myOffsetToCompareUsages, o.myOffsetToCompareUsages); }
compareTo
287,030
Object (@NotNull String dataId) { if (UsageView.USAGE_INFO_KEY.is(dataId)) { return getUsageInfo(); } if (UsageView.USAGE_INFO_LIST_KEY.is(dataId)) { return Arrays.asList(getMergedInfos()); } return null; }
getData
287,031
long () { PsiFile containingFile = getPsiFile(); return containingFile == null ? -1L : containingFile.getViewProvider().getModificationStamp(); }
getCurrentModificationStamp
287,032
void () { if (!ApplicationManager.getApplication().isUnitTestMode()) { ApplicationManager.getApplication().assertIsNonDispatchThread(); } UsageNodePresentation cachedPresentation = getCachedPresentation(); long currentModificationStamp = getCurrentModificationStamp(); boolean isModified = currentModificationStamp != myModificationStamp; if (cachedPresentation == null || isModified && isValid()) { myCachedPresentation = new UsageNodePresentation(computeIcon(), computeText(), computeBackgroundColor()); myModificationStamp = currentModificationStamp; } }
updateCachedPresentation
287,033
UsageNodePresentation () { // Presentation is expected to be always externally updated by calling updateCachedPresentation // Here we just return cached result because it must be always available for painting or speed search UsageNodePresentation cachedPresentation = getCachedPresentation(); return cachedPresentation != null ? cachedPresentation : UsageNodePresentation.EMPTY; }
getNotNullCachedPresentation
287,034
String (@NotNull PsiElement psiElement) { String type = LanguageFindUsages.getType(psiElement); if (!type.isEmpty()) return type; return ObjectUtils.notNull(TypePresentationService.getService().getTypePresentableName(psiElement.getClass()), ""); }
clsType
287,035
String (@NotNull PsiElement psiElement) { String name = LanguageFindUsages.getNodeText(psiElement, false); if (!name.isEmpty()) return name; return ObjectUtils.notNull(psiElement instanceof PsiNamedElement ? ((PsiNamedElement)psiElement).getName() : null, ""); }
clsName
287,036
String () { PsiElement element = getElement(); PsiFile psiFile = getPsiFile(); boolean isNullOrBinary = psiFile == null || psiFile.getFileType().isBinary(); if (element != null && isNullOrBinary) { return clsType(element) + " " + clsName(element); } int startOffset; if (element != null && (startOffset = getNavigationOffset()) != -1) { Document document = getDocument(); if (document != null) { int lineNumber = document.getLineNumber(startOffset); int lineStart = document.getLineStartOffset(lineNumber); int lineEnd = document.getLineEndOffset(lineNumber); String prefixSuffix = null; if (lineEnd - lineStart > ChunkExtractor.MAX_LINE_LENGTH_TO_SHOW) { prefixSuffix = "..."; lineStart = Math.max(startOffset - ChunkExtractor.OFFSET_BEFORE_TO_SHOW_WHEN_LONG_LINE, lineStart); lineEnd = Math.min(startOffset + ChunkExtractor.OFFSET_AFTER_TO_SHOW_WHEN_LONG_LINE, lineEnd); } String s = document.getCharsSequence().subSequence(lineStart, lineEnd).toString(); if (prefixSuffix != null) s = prefixSuffix + s + prefixSuffix; return s; } } return UsageViewBundle.message("node.invalid"); }
getPlainText
287,037
Icon () { return getNotNullCachedPresentation().getIcon(); }
getIcon
287,038
Icon () { Icon icon = myUsageInfo.getIcon(); if (icon != null) { return icon; } PsiElement psiElement = getElement(); return psiElement != null && psiElement.isValid() && !isFindInPathUsage(psiElement) ? psiElement.getIcon(0) : null; }
computeIcon
287,039
boolean (PsiElement psiElement) { return psiElement instanceof PsiFile && getUsageInfo().getPsiFileRange() != null; }
isFindInPathUsage
287,040
String () { return myUsageInfo.getTooltipText(); }
getTooltipText
287,041
UsageType () { UsageType usageType = myUsageType; if (usageType == null) { usageType = computeUsageType(); if (usageType == null) { usageType = UsageType.UNCLASSIFIED; } myUsageType = usageType; } return usageType; }
getUsageType
287,042
void (Runnable block) { boolean old = ourAutomaticallyCalculatePresentationInTests; ourAutomaticallyCalculatePresentationInTests = false; try { block.run(); } finally { ourAutomaticallyCalculatePresentationInTests = old; } }
disableAutomaticPresentationCalculationInTests
287,043
List<PsiElement> () { List<PsiElement> result = new ArrayList<>(myPrimarySearchedElements.size() + myAdditionalSearchedElements.size()); for (SmartPsiElementPointer pointer : myPrimarySearchedElements) { PsiElement element = pointer.getElement(); if (element != null) { result.add(element); } } for (SmartPsiElementPointer pointer : myAdditionalSearchedElements) { PsiElement element = pointer.getElement(); if (element != null) { result.add(element); } } return result; }
getAllElements
287,044
List<SmartPsiElementPointer<PsiElement>> () { return ContainerUtil.concat(myPrimarySearchedElements, myAdditionalSearchedElements); }
getAllElementPointers
287,045
Usage (@NotNull TargetElementsDescriptor descriptor, @NotNull UsageInfo usageInfo) { PsiElement[] primaryElements = descriptor.getPrimaryElements(); return convert(primaryElements, usageInfo); }
convert
287,046
Usage (PsiElement @NotNull [] primaryElements, @NotNull UsageInfo usageInfo) { PsiElement usageElement = usageInfo.getElement(); if (usageElement != null && primaryElements.length != 0) { ReadWriteAccessDetector.Access rwAccess = ReadWriteUtil.getReadWriteAccess(primaryElements, usageElement); if (rwAccess != null) { return new ReadWriteAccessUsageInfo2UsageAdapter(usageInfo, rwAccess); } } return new UsageInfo2UsageAdapter(usageInfo); }
convert
287,047
Usage (PsiElement @NotNull [] primaryElements, @NotNull UsageInfo usageInfo, @NotNull ClusteringSearchSession session) { PsiElement usageElement = usageInfo.getElement(); if (usageElement != null && primaryElements.length != 0) { Bag features = new Bag(); UsageSimilarityFeaturesProvider.EP_NAME.forEachExtensionSafe(provider -> { features.addAll(provider.getFeatures(usageElement)); }); if (!features.isEmpty()) { final ReadWriteAccessDetector.Access readWriteAccess = ReadWriteUtil.getReadWriteAccess(primaryElements, usageElement); final SimilarUsage similarUsageAdapter; if (readWriteAccess != null) { similarUsageAdapter = new SimilarReadWriteUsageInfo2UsageAdapter(usageInfo, readWriteAccess, features, session); } else { similarUsageAdapter = new SimilarUsageInfo2UsageAdapter(usageInfo, features, session); } return session.clusterUsage(similarUsageAdapter); } } return convert(primaryElements, usageInfo); }
convertToSimilarUsage
287,048
UsageViewManager (Project project) { return project.getService(UsageViewManager.class); }
getInstance
287,049
boolean (@NotNull final Usage usage, final UsageTarget @NotNull [] searchForTarget) { if (!(usage instanceof PsiElementUsage)) return false; return ReadAction.compute(() -> { final PsiElement element = ((PsiElementUsage)usage).getElement(); if (element == null) return false; for (UsageTarget ut : searchForTarget) { if (ut instanceof PsiElementUsageTarget) { if (isSelfUsage(element, ((PsiElementUsageTarget)ut).getElement())) { return true; } } } return false; }); }
isSelfUsage
287,050
boolean (@NotNull PsiElement element, PsiElement psiElement) { return element.getParent() == psiElement; // self usage might be configurable }
isSelfUsage
287,051
UsageTarget[] (@NotNull DataProvider dataProvider) { Editor editor = CommonDataKeys.EDITOR.getData(dataProvider); PsiFile file = CommonDataKeys.PSI_FILE.getData(dataProvider); List<UsageTarget> result = new ArrayList<>(); if (file != null && editor != null) { UsageTarget[] targets = findUsageTargets(editor, file); Collections.addAll(result, targets); } PsiElement psiElement = CommonDataKeys.PSI_ELEMENT.getData(dataProvider); if (psiElement != null) { UsageTarget[] targets = findUsageTargets(psiElement); Collections.addAll(result, targets); } return result.isEmpty() ? null : result.toArray(UsageTarget.EMPTY_ARRAY); }
findUsageTargets
287,052
List<UsageTargetProvider> (@NotNull Project project) { return DumbService.getDumbAwareExtensions(project, EP_NAME); }
getProviders
287,053
int () { return Registry.intValue("ide.find.result.count.warning.limit", 1000); }
getResultCountLimit
287,054
Result (@NotNull final Project project, @NotNull final @NlsContexts.DialogMessage String message) { boolean result = runOrInvokeAndWait(() -> { String title = UsageViewBundle.message("find.excessive.usages.title"); return MessageDialogBuilder.okCancel(title, message).yesText(UsageViewBundle.message("button.text.continue")) .noText(UsageViewBundle.message("button.text.abort")).icon(UIUtil.getWarningIcon()).ask(project); }); return result ? Result.CONTINUE : Result.ABORT; }
showTooManyUsagesWarning
287,055
boolean (@NotNull final Computable<Boolean> f) { final boolean[] answer = new boolean[1]; try { ApplicationManager.getApplication().invokeAndWait(() -> answer[0] = f.compute()); } catch (Exception e) { answer[0] = true; } return answer[0]; }
runOrInvokeAndWait
287,056
UsagePresentation () { throw new IllegalAccessError(); }
getPresentation
287,057
boolean () { return false; }
isValid
287,058
boolean () { return false; }
isReadOnly
287,059
FileEditorLocation () { return null; }
getLocation
287,060
void () { }
selectInEditor
287,061
void () { }
highlightInEditor
287,062
Lexer () { return lexer; }
getHighlightingLexer
287,063
void (@NotNull CharSequence text) { lexer.start(text); if (lexer instanceof LexerEditorHighlighterLexer) { HighlighterIterator iterator = ((LexerEditorHighlighterLexer)lexer).getHighlighterIterator(); if (iterator instanceof LayeredHighlighterIterator) { layeredHighlighterIterator = (LayeredHighlighterIterator)iterator; } else { layeredHighlighterIterator = null; } } }
restart
287,064
void (int startOffset) { if (lexer instanceof LexerEditorHighlighterLexer) { ((LexerEditorHighlighterLexer)lexer).resetPosition(startOffset); HighlighterIterator iterator = ((LexerEditorHighlighterLexer)lexer).getHighlighterIterator(); if (iterator instanceof LayeredHighlighterIterator) { layeredHighlighterIterator = (LayeredHighlighterIterator)iterator; } else { layeredHighlighterIterator = null; } } else { CharSequence text = lexer.getBufferSequence(); lexer.start(text, startOffset, text.length()); } }
resetPosition
287,065
UsagePresentation () { return new UsagePresentation() { @Override public TextChunk @NotNull [] getText() { return new TextChunk[] {new TextChunk(SimpleTextAttributes.REGULAR_ATTRIBUTES.toTextAttributes(), myExplanationText)}; } @NotNull @Override public String getPlainText() { return myExplanationText; } @Override public Icon getIcon() { return AllIcons.General.Warning; } @Override public String getTooltipText() { return null; } }; }
getPresentation
287,066
String () { return myExplanationText; }
getPlainText
287,067
Icon () { return AllIcons.General.Warning; }
getIcon
287,068
String () { return null; }
getTooltipText
287,069
boolean () { return true; }
isValid
287,070
List<UsageGroup> (@NotNull Usage usage, UsageTarget @NotNull [] targets) { return ContainerUtil.createMaybeSingletonList(getParentGroupFor(usage, targets)); }
getParentGroupsFor
287,071
UsageGroup (@NotNull Usage usage) { return getParentGroupFor(usage, UsageTarget.EMPTY_ARRAY); }
groupUsage
287,072
boolean (@NotNull Usage usage, @NotNull UsageTarget @NotNull [] targets) { return isVisible(usage); }
isVisible
287,073
boolean (@NotNull Usage usage) { throw new AbstractMethodError("isVisible(Usage) or isVisible(Usage, UsageTarget[]) must be implemented"); }
isVisible
287,074
void (@NotNull AnActionEvent e) { Editor editor = e.getData(CommonDataKeys.EDITOR); if (editor == null) return; final PsiFile file = e.getData(CommonDataKeys.PSI_FILE); if (file == null) return; final Project project = e.getProject(); assert project != null; final VirtualFile projectDir = ProjectUtil.guessProjectDir(project); assert projectDir != null; PsiDirectory directory = PsiManager.getInstance(project).findDirectory(projectDir); assert directory != null; final Ref<PsiFile> featuresDump = new Ref<>(); calculateFeaturesForUsage(editor, file, project, featuresDump); }
actionPerformed
287,075
ActionUpdateThread () { return ActionUpdateThread.BGT; }
getActionUpdateThread
287,076
void (@NotNull Editor editor, @NotNull PsiFile file, @NotNull Project project, @NotNull Ref<? super PsiFile> featuresDump) { ProgressManager.getInstance().run(new Task.Modal(project, UsageViewBundle.message( "similar.usages.show.usage.features.action.calculating.usage.features.progress.title"), true) { @Override public void run(@NotNull ProgressIndicator indicator) { final Bag features = new Bag(); Ref<PsiElement> element = new Ref<>(); ApplicationManager.getApplication().runReadAction(() -> { PsiReference referenceAt = file.findReferenceAt(editor.getCaretModel().getOffset()); if (referenceAt == null) return; element.set(referenceAt.getElement()); if (!element.isNull()) { UsageSimilarityFeaturesProvider.EP_NAME.forEachExtensionSafe(provider -> { features.addAll(provider.getFeatures(element.get())); } ); } }); if (element.isNull()) { return; } writeCommandAction(project).compute(() -> { ScratchFileService fileService = ScratchFileService.getInstance(); try { VirtualFile scratchFile = fileService.findFile(RootType.findById("scratches"), getFeaturesFileName(file, element.get(), editor), ScratchFileService.Option.create_new_always); PsiFile psiFile = PsiManager.getInstance(project).findFile(scratchFile); featuresDump.set(psiFile); final Document document = psiFile != null ? PsiDocumentManager.getInstance(project).getDocument(psiFile) : null; if (document != null) { document.insertString(document.getTextLength(), StringUtil.join(features.getBag().object2IntEntrySet().stream().sorted( Map.Entry.comparingByKey()).collect(Collectors.toList()), ",\n")); PsiDocumentManager.getInstance(project).commitDocument(document); psiFile.navigate(true); } } catch (IOException e) { throw new RuntimeException(e); } return true; }); } }); }
calculateFeaturesForUsage
287,077
void (@NotNull ProgressIndicator indicator) { final Bag features = new Bag(); Ref<PsiElement> element = new Ref<>(); ApplicationManager.getApplication().runReadAction(() -> { PsiReference referenceAt = file.findReferenceAt(editor.getCaretModel().getOffset()); if (referenceAt == null) return; element.set(referenceAt.getElement()); if (!element.isNull()) { UsageSimilarityFeaturesProvider.EP_NAME.forEachExtensionSafe(provider -> { features.addAll(provider.getFeatures(element.get())); } ); } }); if (element.isNull()) { return; } writeCommandAction(project).compute(() -> { ScratchFileService fileService = ScratchFileService.getInstance(); try { VirtualFile scratchFile = fileService.findFile(RootType.findById("scratches"), getFeaturesFileName(file, element.get(), editor), ScratchFileService.Option.create_new_always); PsiFile psiFile = PsiManager.getInstance(project).findFile(scratchFile); featuresDump.set(psiFile); final Document document = psiFile != null ? PsiDocumentManager.getInstance(project).getDocument(psiFile) : null; if (document != null) { document.insertString(document.getTextLength(), StringUtil.join(features.getBag().object2IntEntrySet().stream().sorted( Map.Entry.comparingByKey()).collect(Collectors.toList()), ",\n")); PsiDocumentManager.getInstance(project).commitDocument(document); psiFile.navigate(true); } } catch (IOException e) { throw new RuntimeException(e); } return true; }); }
run
287,078
String (@NotNull PsiFile file, @NotNull PsiElement element, @NotNull Editor editor) { Document document = PsiDocumentManager.getInstance(file.getProject()).getDocument(file); String fileName = file.getName(); return "features" + fileName.substring(0, fileName.lastIndexOf('.')) + (document != null ? document.getLineNumber(editor.getCaretModel().getOffset()) : "") + "-" + element.getText() + "-" + ".txt"; }
getFeaturesFileName
287,079
void (@NotNull SimilarUsage usage) { myUsages.add(usage); }
addUsage
287,080
boolean (@Nullable UsageInfo usageInfo) { for (SimilarUsage usage : myUsages) { if (usage.getUsageInfo().equals(usageInfo)) { return true; } } return false; }
contains
287,081
String () { return "{\n" + myUsages.stream().map(usage -> usage.toString()).collect(Collectors.joining(",\n")) + "}\n"; }
toString
287,082
void (@NotNull Collection<? extends @NotNull UsageCluster> clusters) { synchronized (myClusters) { myClusters.clear(); myClusters.addAll(clusters); } }
updateClusters
287,083
UsageCluster () { final UsageCluster newCluster = new UsageCluster(); myClusters.add(newCluster); return newCluster; }
createNewCluster
287,084
boolean () { return AdvancedSettings.getBoolean("ide.similar.usages.clustering.enable"); }
isSimilarUsagesClusteringEnabled
287,085
boolean (double similarity) { return MathUtil.equals(similarity, MAXIMUM_SIMILARITY, PRECISION); }
isCompleteMatch
287,086
boolean (double similarity1, double similarity2) { return similarity1 < similarity2 && !MathUtil.equals(similarity1, similarity2, PRECISION); }
lessThen
287,087
double (@NotNull Bag bag1, @NotNull Bag bag2, double similarityThreshold, boolean isOptimised) { final int cardinality1 = bag1.getCardinality(); final int cardinality2 = bag2.getCardinality(); if (!isOptimised && lessThen(Math.min(cardinality1, cardinality2), Math.max(cardinality1, cardinality2) * similarityThreshold)) { return 0; } int intersectionSize = Bag.intersectionSize(bag1, bag2); return intersectionSize / (double)(cardinality1 + cardinality2 - intersectionSize); }
jaccardSimilarity
287,088
double (@NotNull Bag bag1, @NotNull Bag bag2, double similarityThreshold) { return jaccardSimilarity(bag1, bag2, similarityThreshold, false); }
jaccardSimilarityWithThreshold
287,089
double (@NotNull Bag bag1, @NotNull Bag bag2) { return 1 - jaccardSimilarity(bag1, bag2, 0, true); }
jaccardDistanceExact
287,090
boolean (@NotNull PsiElement expression) { return PsiTreeUtil.findFirstParent( expression, false, element -> element == myUsage || element == myInitialContext) == myUsage || PsiTreeUtil.findFirstParent( myUsage, false, element -> element == expression || element == myInitialContext) == expression; }
isInSameTreeAsUsage
287,091
Bag () { return myFeatures; }
getFeatures
287,092
void (@NotNull String tokenFeature) { myFeatures.add(tokenFeature); }
addFeature
287,093
void (@NotNull PsiElement element, @Nullable String tokenFeature) { if (tokenFeature == null) { tokenFeature = PsiUtilCore.getElementType(element).toString(); } if (Registry.is("similarity.distinguish.usages.in.one.statement")) { tokenFeature = (isInSameTreeAsUsage(element) ? "USAGE: " : "CONTEXT: ") + tokenFeature; } myFeatures.add(tokenFeature); if (element == myInitialContext) { return; } PsiElement parent = element.getParent(); if (parent != myInitialContext) { addParentFeatures(parent, tokenFeature, "GP:"); } addParentFeatures(element, tokenFeature, "P:"); addSiblingFeatures(element, tokenFeature); }
addAllFeatures
287,094
void (@NotNull PsiElement element, @Nullable String tokenFeature, @NotNull String prefix) { if (!Registry.is("similarity.find.usages.use.parent.features")) { return; } PsiElement parent = element.getParent(); if (parent != null) { myFeatures.add(tokenFeature + " " + prefix + " " + PsiUtilCore.getElementType(parent) + " " + getChildNumber(parent, element)); } }
addParentFeatures
287,095
void (@NotNull PsiElement element, @Nullable String tokenFeature) { if (!Registry.is("similarity.find.usages.use.sibling.features")) { return; } myFeatures.add(tokenFeature + " PREV: " + getPrevMeaningfulSibling(element)); myFeatures.add(tokenFeature + " NEXT: " + getNextMeaningfulSibling(element)); }
addSiblingFeatures
287,096
int (@NotNull PsiElement parent, @NotNull PsiElement child) { if (!Registry.is("similarity.find.usages.use.parent.features.with.child.number")) return -1; PsiElement[] children = Arrays.stream(parent.getChildren()).filter(e -> !(e instanceof PsiWhiteSpace)).toArray(PsiElement[]::new); for (int i = 0; i < children.length; i++) { if (children[i] == child) { return i; } } return -1; }
getChildNumber
287,097
Object2IntMap<String> () { return myBag; }
getBag
287,098
void (@NotNull Bag bag) { for (Object2IntMap.Entry<String> entry : bag.myBag.object2IntEntrySet()) { final String key = entry.getKey(); myBag.put(key, myBag.getInt(key) + entry.getIntValue()); myCardinality += entry.getIntValue(); } }
addAll
287,099
int () { return myCardinality; }
getCardinality