Unnamed: 0
int64 0
305k
| body
stringlengths 7
52.9k
| name
stringlengths 1
185
|
|---|---|---|
292,300
|
void (@NotNull Collection<? extends Usage> usages, @NotNull Collection<? extends Usage> excluded) { final List<Usage> sortedUsages = myUsageView.getSortedUsages(); if (sortedUsages.size() == usages.size()) { myUsageView.close(); } else { Usage firstValid = null; Usage select = null; for (Usage usage : sortedUsages) { if (usages.contains(usage)) { select = null; continue; } if (excluded.contains(usage) || !isValid((UsageInfo2UsageAdapter)usage)) { continue; } if (select == null) { select = usage; } if (firstValid == null) { firstValid = usage; } } myUsageView.removeUsagesBulk(usages); myUsageView.selectUsages(new Usage[]{ ObjectUtils.coalesce(select, firstValid, myUsageView.getSortedUsages().get(0)) }); } }
|
removeUsagesAndSelectNext
|
292,301
|
UsageViewContext () { final Runnable searchStarter = () -> new ReplaceCommand(myConfiguration, mySearchContext).startSearching(); myReplaceUsageViewContext = new ReplaceUsageViewContext(mySearchContext, myConfiguration, searchStarter); return myReplaceUsageViewContext; }
|
createUsageViewContext
|
292,302
|
void (MatchResult result, Usage usage) { super.foundUsage(result, usage); myReplaceUsageViewContext.addReplaceUsage(usage, result); }
|
foundUsage
|
292,303
|
void (VirtualFile file, int start, int end) { removeHighlighter(); editor = FileEditorManager.getInstance(project).openTextEditor(new OpenFileDescriptor(project, file), false); if (editor == null) { return; } myHighlighter = editor.getMarkupModel().addRangeHighlighter( EditorColors.SEARCH_RESULT_ATTRIBUTES, start, end, HighlighterLayer.SELECTION - 100, HighlighterTargetArea.EXACT_RANGE ); }
|
highlight
|
292,304
|
void () { if (myHighlighter != null && myHighlighter.isValid()) { myHighlighter.dispose(); myHighlighter = null; editor = null; } }
|
removeHighlighter
|
292,305
|
String () { return "#com.intellij.strucuturalsearch.plugin.replace.ReplacementPreviewDialog"; }
|
getDimensionServiceKey
|
292,306
|
JComponent () { final JComponent centerPanel = new JPanel(new BorderLayout()); final StructuralSearchProfile profile = StructuralSearchUtil.getProfileByFileType(myFileType); assert profile != null; replacement = UIUtil.createEditor(project, myFileType, null, "", false, profile); centerPanel.add(BorderLayout.NORTH, new JLabel(SSRBundle.message("replacement.code"))); centerPanel.add(BorderLayout.CENTER, replacement.getComponent()); centerPanel.setMaximumSize(new Dimension(640, 480)); return centerPanel; }
|
createCenterPanel
|
292,307
|
void () { final PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(replacement.getDocument()); if (file != null) { DaemonCodeAnalyzer.getInstance(project).setHighlightingEnabled(file, true); } EditorFactory.getInstance().releaseEditor(replacement); removeHighlighter(); super.dispose(); }
|
dispose
|
292,308
|
ReplaceConfiguration () { return new ReplaceConfiguration(this); }
|
copy
|
292,309
|
ReplaceOptions () { return myReplaceOptions; }
|
getReplaceOptions
|
292,310
|
MatchOptions () { return myReplaceOptions.getMatchOptions(); }
|
getMatchOptions
|
292,311
|
NamedScriptableDefinition (@NotNull String name) { return ObjectUtils.chooseNotNull(myReplaceOptions.getVariableDefinition(name), getMatchOptions().getVariableConstraint(name)); }
|
findVariable
|
292,312
|
void () { myReplaceOptions.removeUnusedVariables(); myReplaceOptions.getMatchOptions().removeUnusedVariables(); }
|
removeUnusedVariables
|
292,313
|
void (Element element) { super.readExternal(element); myReplaceOptions.readExternal(element); }
|
readExternal
|
292,314
|
void (Element element) { super.writeExternal(element); myReplaceOptions.writeExternal(element); }
|
writeExternal
|
292,315
|
boolean (Object configuration) { if (this == configuration) return true; if (!(configuration instanceof ReplaceConfiguration)) return false; if (!super.equals(configuration)) return false; return myReplaceOptions.equals(((ReplaceConfiguration)configuration).myReplaceOptions); }
|
equals
|
292,316
|
int () { return 31 * super.hashCode() + myReplaceOptions.hashCode(); }
|
hashCode
|
292,317
|
String (final String type) { return type.substring(1, type.length() - 1); }
|
stripTypedVariableDecoration
|
292,318
|
int (StringBuilder result, int offset, final ParameterInfo info, String image) { if (!image.isEmpty()) { result.insert(offset + info.getStartIndex(), image); offset += image.length(); } return offset; }
|
insertSubstitution
|
292,319
|
String (String in, String what, String by, ReplaceOptions options, Project project) { return testReplace(in, what, by, options, project, false); }
|
testReplace
|
292,320
|
String (String in, String what, String by, ReplaceOptions options, Project project, boolean sourceIsFile) { final LanguageFileType fileType = options.getMatchOptions().getFileType(); assert fileType != null; return testReplace(in, what, by, options, project, sourceIsFile, false, fileType, fileType.getLanguage()); }
|
testReplace
|
292,321
|
String (String in, String what, String by, ReplaceOptions replaceOptions, Project project, boolean sourceIsFile, boolean createPhysicalFile, @NotNull LanguageFileType sourceFileType, @NotNull Language sourceDialect) { replaceOptions.setReplacement(by); final MatchOptions matchOptions = replaceOptions.getMatchOptions(); matchOptions.fillSearchCriteria(what); Matcher.validate(project, matchOptions); checkReplacementPattern(project, replaceOptions); final Replacer replacer = new Replacer(project, replaceOptions); final Matcher matcher = new Matcher(project, matchOptions); try { final PsiElement firstElement; final PsiElement lastElement; final PsiElement parent; if (matchOptions.getScope() == null) { final PsiElement[] elements = MatcherImplUtil.createTreeFromText( in, new PatternContextInfo(sourceIsFile ? PatternTreeContext.File : PatternTreeContext.Block), sourceFileType, sourceDialect, project, createPhysicalFile ); firstElement = elements[0]; lastElement = elements[elements.length-1]; parent = firstElement.getParent(); matchOptions.setScope(new LocalSearchScope(elements)); } else { parent = ((LocalSearchScope)matchOptions.getScope()).getScope()[0]; firstElement = parent.getFirstChild(); lastElement = parent.getLastChild(); } final CollectingMatchResultSink sink = new CollectingMatchResultSink(); matcher.testFindMatches(sink); final List<ReplacementInfo> replacements = new SmartList<>(); for (final MatchResult result : sink.getMatches()) { replacements.add(replacer.buildReplacement(result)); } int startOffset = firstElement.getTextRange().getStartOffset(); int endOffset = sourceIsFile ? 0 : (parent.getTextLength() - lastElement.getTextRange().getEndOffset()); // get nodes from text may contain final PsiElement prevSibling = firstElement.getPrevSibling(); if (prevSibling instanceof PsiWhiteSpace) { startOffset -= prevSibling.getTextLength(); } final PsiElement nextSibling = lastElement.getNextSibling(); if (nextSibling instanceof PsiWhiteSpace) { endOffset -= nextSibling.getTextLength(); } replacer.replaceAll(replacements); if (firstElement == lastElement && firstElement instanceof PsiFile) { return firstElement.getText(); } final String result = parent.getText(); return result.substring(startOffset, result.length() - endOffset); } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new IncorrectOperationException(e); } finally { matchOptions.setScope(null); } }
|
testReplace
|
292,322
|
void (final List<? extends ReplacementInfo> infos) { for (ReplacementInfo info : infos) { replaceHandler.prepare(info); } if (IntentionPreviewUtils.isIntentionPreviewActive()) { doReplaceAll(infos, new EmptyProgressIndicator()); } else { ((ApplicationEx)ApplicationManager.getApplication()).runWriteActionWithCancellableProgressInDispatchThread( SSRBundle.message("structural.replace.title"), project, null, indicator -> doReplaceAll(infos, indicator) ); } }
|
replaceAll
|
292,323
|
void (@NotNull List<? extends ReplacementInfo> infos, @NotNull ProgressIndicator indicator) { indicator.setIndeterminate(false); try { final int size = infos.size(); VirtualFile lastFile = null; for (int i = 0; i < size; i++) { indicator.checkCanceled(); indicator.setFraction((float)(i + 1) / size); final ReplacementInfo info = infos.get(i); final PsiElement element = info.getMatch(0); if (element == null) { continue; } final VirtualFile vFile = element.getContainingFile().getVirtualFile(); if (vFile != null && !vFile.equals(lastFile)) { indicator.setText2(vFile.getPresentableUrl()); lastFile = vFile; } ProgressManager.getInstance().executeNonCancelableSection(() -> { final PsiElement affectedElement = doReplace(info); if (affectedElement != lastAffectedElement) { if (lastAffectedElement != null) reformatAndPostProcess(lastAffectedElement); lastAffectedElement = affectedElement; } }); } } finally { ProgressManager.getInstance().executeNonCancelableSection(() -> reformatAndPostProcess(lastAffectedElement)); } }
|
doReplaceAll
|
292,324
|
void (@NotNull ReplacementInfo info) { replaceHandler.prepare(info); reformatAndPostProcess(doReplace(info)); }
|
replace
|
292,325
|
PsiElement (@NotNull ReplacementInfo info) { final PsiElement element = info.getMatch(0); if (element==null || !element.isWritable() || !element.isValid()) return null; final PsiElement elementParent = StructuralSearchUtil.getPresentableElement(element).getParent(); CodeStyleManager.getInstance(project).performActionWithFormatterDisabled( (Runnable)() -> replaceHandler.replace(info, options) ); if (!elementParent.isValid() || !elementParent.isWritable()) { return null; } return elementParent; }
|
doReplace
|
292,326
|
void (final PsiElement elementParent) { if (elementParent == null || !elementParent.isValid()) return; final PsiFile containingFile = elementParent.getContainingFile(); replaceHandler.postProcess(elementParent, options); if (containingFile != null && options.isToReformatAccordingToStyle()) { final VirtualFile file = containingFile.getVirtualFile(); if (file != null) { final Document document = FileDocumentManager.getInstance().getDocument(file); if (document != null) { PsiDocumentManager.getInstance(project).commitDocument(document); } } final int parentOffset = elementParent.getTextRange().getStartOffset(); CodeStyleManager.getInstance(project).reformatRange(containingFile, parentOffset, parentOffset + elementParent.getTextLength(), true); } }
|
reformatAndPostProcess
|
292,327
|
void (final PsiElement el, final PsiElement replacement, ReplacementInfo replacementInfo) { final PsiElement lastChild = el.getLastChild(); if (lastChild instanceof PsiComment && replacementInfo.getVariableName(lastChild) == null && !(replacement.getLastChild() instanceof PsiComment)) { PsiElement firstElementAfterStatementEnd = lastChild; for(PsiElement curElement=firstElementAfterStatementEnd.getPrevSibling();curElement!=null;curElement = curElement.getPrevSibling()) { if (!(curElement instanceof PsiWhiteSpace) && !(curElement instanceof PsiComment)) break; firstElementAfterStatementEnd = curElement; } replacement.addRangeAfter(firstElementAfterStatementEnd,lastChild,replacement.getLastChild()); } final PsiElement firstChild = el.getFirstChild(); if (firstChild instanceof PsiComment && !(firstChild instanceof PsiDocCommentBase) && replacementInfo.getVariableName(firstChild) == null) { PsiElement lastElementBeforeStatementStart = firstChild; for(PsiElement curElement=lastElementBeforeStatementStart.getNextSibling();curElement!=null;curElement = curElement.getNextSibling()) { if (!(curElement instanceof PsiWhiteSpace) && !(curElement instanceof PsiComment)) break; lastElementBeforeStatementStart = curElement; } replacement.addRangeBefore(firstChild,lastElementBeforeStatementStart,replacement.getFirstChild()); } }
|
handleComments
|
292,328
|
void (@NotNull Project project, @NotNull ReplaceOptions options) { try { final String search = options.getMatchOptions().getSearchPattern(); final String replacement = options.getReplacement(); final Template searchTemplate = TemplateManager.getInstance(project).createTemplate("" , "", search); final Template replaceTemplate = TemplateManager.getInstance(project).createTemplate("", "", replacement); final int segmentCount = replaceTemplate.getSegmentsCount(); for(int i = 0; i < segmentCount; i++) { final String replacementSegmentName = replaceTemplate.getSegmentName(i); final int segmentCount2 = searchTemplate.getSegmentsCount(); int j = 0; while (j < segmentCount2) { final String searchSegmentName = searchTemplate.getSegmentName(j); if (replacementSegmentName.equals(searchSegmentName)) break; // Reference to if (replacementSegmentName.startsWith(searchSegmentName) && replacementSegmentName.charAt(searchSegmentName.length()) == '_') { try { Integer.parseInt(replacementSegmentName.substring(searchSegmentName.length() + 1)); break; } catch (NumberFormatException ignore) {} } j++; } if (j == segmentCount2) { final ReplacementVariableDefinition definition = options.getVariableDefinition(replacementSegmentName); if (definition == null || definition.getScriptCodeConstraint().length() <= 2 /*empty quotes*/) { throw new MalformedPatternException(SSRBundle.message("replacement.variable.is.not.defined.message", replacementSegmentName)); } else { final String scriptText = StringUtil.unquoteString(definition.getScriptCodeConstraint()); try { ScriptSupport.buildScript(definition.getName(), scriptText, options.getMatchOptions()); } catch (MalformedPatternException e) { throw new MalformedPatternException( SSRBundle.message("replacement.variable.is.not.valid", replacementSegmentName, e.getLocalizedMessage()) ); } } } } final LanguageFileType fileType = options.getMatchOptions().getFileType(); final StructuralSearchProfile profile = StructuralSearchUtil.getProfileByFileType(fileType); if (profile != null) { ReadAction.run(() -> profile.checkReplacementPattern(project, options)); } } catch (IncorrectOperationException ex) { throw new MalformedPatternException(SSRBundle.message("incorrect.pattern.message")); } }
|
checkReplacementPattern
|
292,329
|
ReplacementInfo (@NotNull MatchResult result) { final ReplacementInfoImpl replacementInfo = new ReplacementInfoImpl(result, project); final LanguageFileType fileType = options.getMatchOptions().getFileType(); assert fileType != null; replacementInfo.setReplacement(replacementBuilder.process(result, replacementInfo, fileType)); return replacementInfo; }
|
buildReplacement
|
292,330
|
PsiElement (@NotNull PsiElement elementToReplace, PsiElement @NotNull [] patternElements, @NotNull String replacementToMake, @NotNull PsiElement elementParent) { int i = 0; while (true) { // if it goes out of bounds then deep error happens if (!(patternElements[i] instanceof PsiComment || patternElements[i] instanceof PsiWhiteSpace)) { break; } ++i; if (patternElements.length == i) { break; } } if (patternElements.length == i) { Logger logger = Logger.getInstance(StructuralSearchProfile.class.getName()); logger.error("Unexpected replacement structure:" + replacementToMake); } if (i != 0) { elementParent.addRangeBefore(patternElements[0], patternElements[i - 1], elementToReplace); } return patternElements[i]; }
|
copySpacesAndCommentsBefore
|
292,331
|
void (@NotNull PsiElement element) { final String text = element.getText(); if (MatchUtil.isTypedVariable(text)) { final Collection<ParameterInfo> infos = findParameterization(Replacer.stripTypedVariableDecoration(text)); for (ParameterInfo info : infos) { if (info.getElement() == null) { info.setElement(element); return; } } } super.visitElement(element); }
|
visitElement
|
292,332
|
Object (@NotNull ParameterInfo info, @NotNull MatchResult match) { ScriptSupport scriptSupport = replacementVarsMap.get(info.getName()); if (scriptSupport == null) { final String constraint = options.getVariableDefinition(info.getName()).getScriptCodeConstraint(); final List<String> variableNames = ContainerUtil.map(options.getVariableDefinitions(), o -> o.getName()); final String name = info.getName(); final String scriptText = StringUtil.unquoteString(constraint); try { final Script script = ScriptSupport.buildScript(name, scriptText, options.getMatchOptions()); scriptSupport = new ScriptSupport(myProject, script, name, variableNames); replacementVarsMap.put(info.getName(), scriptSupport); } catch (MalformedPatternException e) { return null; } } return scriptSupport.evaluate(match, null); }
|
generateReplacement
|
292,333
|
Collection<ParameterInfo> (String name) { return parameterizations.get(name); }
|
findParameterization
|
292,334
|
ParameterInfo (PsiElement element) { if (element == null) return null; final String text = element.getText(); if (!MatchUtil.isTypedVariable(text)) return null; return ContainerUtil.find(findParameterization(Replacer.stripTypedVariableDecoration(text)), info -> info.getElement() == element); }
|
findParameterization
|
292,335
|
void (@NotNull Project project) { fillPointerList(project); fillVariableMap(matchResult.getRoot()); for(Map.Entry<String, MatchResult> entry : variableMap.entrySet()) { fillElementToVariableNameMap(entry.getKey(), entry.getValue()); } }
|
init
|
292,336
|
String () { return replacement; }
|
getReplacement
|
292,337
|
void (@NotNull String replacement) { this.replacement = replacement; }
|
setReplacement
|
292,338
|
PsiElement (int index) { return matchesPtrList.get(index).getElement(); }
|
getMatch
|
292,339
|
int () { return matchesPtrList.size(); }
|
getMatchesCount
|
292,340
|
MatchResult (@NotNull String name) { return variableMap.get(name); }
|
getNamedMatchResult
|
292,341
|
MatchResult () { return matchResult; }
|
getMatchResult
|
292,342
|
String (@NotNull PsiElement element) { return elementToVariableNameMap.get(element); }
|
getVariableName
|
292,343
|
String (@NotNull String sourceName) { return sourceNameToSearchPatternNameMap.get(sourceName); }
|
getSearchPatternName
|
292,344
|
void (@NotNull Project project) { final SmartPointerManager manager = SmartPointerManager.getInstance(project); if (MatchResult.MULTI_LINE_MATCH.equals(matchResult.getName())) { final Iterator<MatchResult> i = matchResult.getChildren().iterator(); while (i.hasNext()) { final MatchResult r = i.next(); if (MatchResult.LINE_MATCH.equals(r.getName())) { PsiElement element = r.getMatch(); if (element instanceof PsiDocCommentBase) { // doc comment is not collapsed when created in block if (i.hasNext()) { final MatchResult son = i.next(); if (!MatchResult.LINE_MATCH.equals(son.getName()) || !StructuralSearchUtil.isDocCommentOwner(son.getMatch())) { matchesPtrList.add(manager.createSmartPsiElementPointer(element)); } element = son.getMatch(); } } matchesPtrList.add(manager.createSmartPsiElementPointer(element)); } } } else { matchesPtrList.add(manager.createSmartPsiElementPointer(matchResult.getMatch())); } }
|
fillPointerList
|
292,345
|
void (final String name, final MatchResult matchResult) { final boolean multiMatch = matchResult.isMultipleMatch() || matchResult.isScopeMatch(); if (matchResult.hasChildren() && multiMatch) { for (MatchResult r : matchResult.getChildren()) { fillElementToVariableNameMap(name, r); } } else if (!multiMatch) { final PsiElement match = matchResult.getMatch(); if (match != null) { elementToVariableNameMap.put(match, name); } } }
|
fillElementToVariableNameMap
|
292,346
|
void (MatchResult r) { final String name = r.getName(); if (name != null) { variableMap.putIfAbsent(name, r); sourceNameToSearchPatternNameMap.put(r.getMatchImage(), name); } if (!r.isScopeMatch() || !r.isMultipleMatch()) { for (final MatchResult matchResult : r.getChildren()) { fillVariableMap(matchResult); } } else if (r.hasChildren()) { fillVariableMap(r.getChildren().get(0)); } }
|
fillVariableMap
|
292,347
|
String () { return name; }
|
getName
|
292,348
|
int () { return startIndex; }
|
getStartIndex
|
292,349
|
boolean () { return argumentContext; }
|
isArgumentContext
|
292,350
|
void (boolean argumentContext) { this.argumentContext = argumentContext; }
|
setArgumentContext
|
292,351
|
boolean () { return statementContext; }
|
isStatementContext
|
292,352
|
void (boolean statementContext) { this.statementContext = statementContext; }
|
setStatementContext
|
292,353
|
int () { return afterDelimiterPos; }
|
getAfterDelimiterPos
|
292,354
|
void (int afterDelimiterPos) { this.afterDelimiterPos = afterDelimiterPos; }
|
setAfterDelimiterPos
|
292,355
|
boolean () { return hasCommaBefore; }
|
isHasCommaBefore
|
292,356
|
void (boolean hasCommaBefore) { this.hasCommaBefore = hasCommaBefore; }
|
setHasCommaBefore
|
292,357
|
int () { return beforeDelimiterPos; }
|
getBeforeDelimiterPos
|
292,358
|
void (int beforeDelimiterPos) { this.beforeDelimiterPos = beforeDelimiterPos; }
|
setBeforeDelimiterPos
|
292,359
|
boolean () { return hasCommaAfter; }
|
isHasCommaAfter
|
292,360
|
void (boolean hasCommaAfter) { this.hasCommaAfter = hasCommaAfter; }
|
setHasCommaAfter
|
292,361
|
boolean () { return replacementVariable; }
|
isReplacementVariable
|
292,362
|
PsiElement () { return myElement; }
|
getElement
|
292,363
|
void (@NotNull PsiElement element) { myElement = element; }
|
setElement
|
292,364
|
void (@NotNull AnActionEvent e) { Configuration configuration = myConfigurationProducer.get(); if (ConfigurationManager.getInstance(project).showSaveTemplateAsDialog(configuration)) { reloadUserTemplates(configurationManager); DefaultMutableTreeNode node = TreeUtil.findNodeWithObject(myUserTemplatesNode, configuration); if (node != null) { TreeUtil.selectNode(patternTree, node); } } }
|
actionPerformed
|
292,365
|
void (@NotNull AnActionEvent e) { StructuralSearchProfileActionProvider.createNewInspection(myConfigurationProducer.get(), project); }
|
actionPerformed
|
292,366
|
void (@NotNull AnActionEvent e) { final DefaultMutableTreeNode selectedNode = getSelectedNode(); boolean enabled = selectedNode != null && selectedNode.getUserObject() instanceof Configuration && selectedNode.isNodeAncestor(myUserTemplatesNode); e.getPresentation().setEnabled(enabled); }
|
update
|
292,367
|
ActionUpdateThread () { return ActionUpdateThread.EDT; }
|
getActionUpdateThread
|
292,368
|
void (@NotNull AnActionEvent e) { removeTemplate(project); }
|
actionPerformed
|
292,369
|
TreeState () { return TreeState.createOn(patternTree, true, true); }
|
getTreeState
|
292,370
|
void (TreeState treeState) { if (treeState == null) { TreeUtil.expandAll(patternTree); } else { treeState.applyTo(patternTree); } }
|
setTreeState
|
292,371
|
void (ConfigurationManager configurationManager) { myProjectTemplatesNode.removeAllChildren(); myUserTemplatesNode.removeAllChildren(); for (Configuration config : configurationManager.getIdeConfigurations()) { myUserTemplatesNode.add(new DefaultMutableTreeNode(config)); } List<Configuration> projectConfigurations = configurationManager.getProjectConfigurations(); if (!projectConfigurations.isEmpty()) { myUserTemplatesNode.insert(myProjectTemplatesNode, 0); for (Configuration config : projectConfigurations) { myProjectTemplatesNode.add(new DefaultMutableTreeNode(config)); } } patternTreeModel.reload(myUserTemplatesNode); }
|
reloadUserTemplates
|
292,372
|
void (Project project) { final Object selection = patternTree.getLastSelectedPathComponent(); if (!(selection instanceof DefaultMutableTreeNode node)) { return; } if (!(node.getUserObject() instanceof Configuration configuration)) { return; } if (configuration.isPredefined()) { return; } if (((DefaultMutableTreeNode)selection).isNodeAncestor(myRecentNode)) { return; } final String configurationName = configuration.getName(); outer: for (Configuration otherConfiguration : ConfigurationManager.getInstance(project).getAllConfigurations()) { MatchOptions matchOptions = otherConfiguration.getMatchOptions(); for (String name : matchOptions.getVariableConstraintNames()) { MatchVariableConstraint constraint = matchOptions.getVariableConstraint(name); if (constraint == null) { continue; } if (configurationName.equals(constraint.getWithinConstraint()) || configurationName.equals(constraint.getContainsConstraint()) || configurationName.equals(constraint.getReferenceConstraint())) { if (Messages.CANCEL == Messages.showOkCancelDialog( project, SSRBundle.message("template.in.use.message", configurationName, otherConfiguration.getName()), SSRBundle.message("template.in.use.title", configurationName), CommonBundle.message("button.remove"), Messages.getCancelButton(), AllIcons.General.WarningDialog )) { return; } break outer; } } } DefaultMutableTreeNode sibling = node.getNextSibling(); if (sibling == null) { sibling = node.getPreviousSibling(); } if (sibling == null) { sibling = myUserTemplatesNode; } TreeUtil.selectNode(patternTree, sibling); TreeNode parent = node.getParent(); patternTreeModel.removeNodeFromParent(node); if (parent == myProjectTemplatesNode && parent.getChildCount() == 0) { // hide project-templates node when there are no project templates anymore patternTreeModel.removeNodeFromParent((MutableTreeNode)parent); } ConfigurationManager.getInstance(project).removeConfiguration(configuration, parent == myUserTemplatesNode); }
|
removeTemplate
|
292,373
|
void (LanguageFileType fileType) { final var root = (DefaultMutableTreeNode) patternTreeModel.getRoot(); final Enumeration<TreeNode> children = root.children(); while (children.hasMoreElements()) { final var node = (DefaultMutableTreeNode) children.nextElement(); for (String lang : node.toString().split("/")) { if (lang.equalsIgnoreCase(fileType.getName())) { TreeUtil.selectInTree(node, false, patternTree, true); return; } } } }
|
selectFileType
|
292,374
|
void () { if (!myTemplateChanged) { myTemplateChanged = true; if (!myDraftTemplateNode.equals(getSelectedNode())) { myDraftTemplateAutoselect = true; TreeUtil.selectInTree(myDraftTemplateNode, false, patternTree, true); myDraftTemplateAutoselect = false; } } }
|
templateChanged
|
292,375
|
DefaultMutableTreeNode (@NotNull DefaultMutableTreeNode root, String[] path) { DefaultMutableTreeNode result = root; outer: for (String step : path) { step = StringUtil.replace(step, "//", "/"); DefaultMutableTreeNode child = (result.getChildCount() == 0) ? null : (DefaultMutableTreeNode)result.getLastChild(); while (child != null) { if (step.equals(child.getUserObject())) { result = child; continue outer; } else child = child.getPreviousSibling(); } final DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(step); result.add(newNode); result = newNode; } return result; }
|
getOrCreateCategoryNode
|
292,376
|
DefaultMutableTreeNode () { final Object selection = patternTree.getLastSelectedPathComponent(); if (!(selection instanceof DefaultMutableTreeNode)) { return null; } return (DefaultMutableTreeNode)selection; }
|
getSelectedNode
|
292,377
|
Tree (TreeModel treeModel) { final Tree tree = new Tree(treeModel); tree.setRootVisible(false); tree.setShowsRootHandles(true); tree.setDragEnabled(false); tree.setEditable(false); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); tree.setTransferHandler(new TransferHandler() { @Nullable @Override protected Transferable createTransferable(JComponent c) { final Object selection = tree.getLastSelectedPathComponent(); if (!(selection instanceof DefaultMutableTreeNode node)) { return null; } if (!(node.getUserObject() instanceof Configuration)) { return null; } return new TextTransferable(ConfigurationUtil.toXml((Configuration)node.getUserObject())); } @Override public int getSourceActions(JComponent c) { return COPY; } }); final TreeSpeedSearch speedSearch = TreeSpeedSearch.installOn( tree, false, treePath -> { final DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode)treePath.getLastPathComponent(); if (treeNode == myDraftTemplateNode) return SSRBundle.message("draft.template.node"); final Object userObject = treeNode.getUserObject(); return (userObject instanceof Configuration) ? ((Configuration)userObject).getName() : userObject.toString(); } ); tree.setCellRenderer(new ExistingTemplatesTreeCellRenderer(speedSearch, myDraftTemplateNode)); return tree; }
|
createTree
|
292,378
|
Transferable (JComponent c) { final Object selection = tree.getLastSelectedPathComponent(); if (!(selection instanceof DefaultMutableTreeNode node)) { return null; } if (!(node.getUserObject() instanceof Configuration)) { return null; } return new TextTransferable(ConfigurationUtil.toXml((Configuration)node.getUserObject())); }
|
createTransferable
|
292,379
|
int (JComponent c) { return COPY; }
|
getSourceActions
|
292,380
|
JComponent () { return panel; }
|
getTemplatesPanel
|
292,381
|
void (@NotNull JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { final DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode)value; final Object userObject = treeNode.getUserObject(); if (userObject == null && treeNode != myDraftNode) return; final Color background = UIUtil.getTreeBackground(selected, hasFocus); final Color foreground = UIUtil.getTreeForeground(selected, hasFocus); final String text; final int style; if (treeNode == myDraftNode) { text = SSRBundle.message("draft.template.node"); style = SimpleTextAttributes.STYLE_BOLD; } else if (userObject instanceof Configuration) { text = ((Configuration)userObject).getName(); style = SimpleTextAttributes.STYLE_PLAIN; } else { text = userObject.toString(); style = SimpleTextAttributes.STYLE_BOLD; } SearchUtil.appendFragments(mySpeedSearch.getEnteredPrefix(), text, style, foreground, background, this); }
|
customizeCellRenderer
|
292,382
|
void (Consumer<? super Configuration> consumer) { patternTree.addTreeSelectionListener(event -> { final var selection = patternTree.getLastSelectedPathComponent(); if (!(selection instanceof DefaultMutableTreeNode) || myDraftTemplateAutoselect) { return; } if (myTemplateChanged) { myDraftTemplateNode.setUserObject(myConfigurationProducer.get()); myTemplateChanged = false; } final var configuration = ((DefaultMutableTreeNode)selection).getUserObject(); if (configuration instanceof Configuration) { consumer.accept((Configuration)configuration); } }); }
|
onConfigurationSelected
|
292,383
|
void (Supplier<? extends Configuration> configurationProducer) { myConfigurationProducer = configurationProducer; }
|
setConfigurationProducer
|
292,384
|
void () { myScrollPane.setBorder(JBUI.Borders.customLineTop(JBUI.CurrentTheme.Editor.BORDER_COLOR)); }
|
updateColors
|
292,385
|
void (@NotNull UsageView usageView) { myUsageView = usageView; final MessageBusConnection connection = mySearchContext.getProject().getMessageBus().connect(usageView); connection.subscribe(DynamicPluginListener.TOPIC, new DynamicPluginListener() { @Override public void beforePluginUnload(@NotNull IdeaPluginDescriptor pluginDescriptor, boolean isUpdate) { myUsageView.close(); } }); }
|
setUsageView
|
292,386
|
void (@NotNull IdeaPluginDescriptor pluginDescriptor, boolean isUpdate) { myUsageView.close(); }
|
beforePluginUnload
|
292,387
|
ConfigurableUsageTarget () { return myTarget; }
|
getTarget
|
292,388
|
void (@NotNull UsageViewPresentation presentation) { final String pattern = myConfiguration.getMatchOptions().getSearchPattern(); final SearchScope scope = myConfiguration.getMatchOptions().getScope(); assert scope != null; final String scopeText = scope.getDisplayName(); presentation.setScopeText(scopeText); final String usagesString = SSRBundle.message("occurrences.of", pattern); presentation.setUsagesString(usagesString); presentation.setTabText(StringUtil.shortenTextWithEllipsis(usagesString, 60, 0, false)); presentation.setCodeUsagesString(SSRBundle.message("found.occurrences", scopeText)); presentation.setTargetsNodeText(SSRBundle.message("targets.node.text")); presentation.setCodeUsages(false); presentation.setUsageTypeFilteringAvailable(true); }
|
configure
|
292,389
|
void () { myUsageView.addButtonToLowerPane(new AbstractAction(SSRBundle.message("create.inspection.from.template.action.text")) { @Override public void actionPerformed(ActionEvent e) { StructuralSearchProfileActionProvider.createNewInspection(myConfiguration.copy(), mySearchContext.getProject()); } }); }
|
configureActions
|
292,390
|
void (ActionEvent e) { StructuralSearchProfileActionProvider.createNewInspection(myConfiguration.copy(), mySearchContext.getProject()); }
|
actionPerformed
|
292,391
|
PsiElement (PsiManager psiManager, Object object, PsiElement element) { if (object instanceof Configuration) { return new ConfigurationElement((Configuration)object, psiManager); } return null; }
|
getDocumentationElementForLookupItem
|
292,392
|
Configuration () { return myConfiguration; }
|
getConfiguration
|
292,393
|
PsiElement () { return myDummyHolder; }
|
getParent
|
292,394
|
ItemPresentation () { return new ItemPresentation() { @Override public String getPresentableText() { return myConfiguration.getName(); } @Nullable @Override public Icon getIcon(boolean unused) { return null; } }; }
|
getPresentation
|
292,395
|
String () { return myConfiguration.getName(); }
|
getPresentableText
|
292,396
|
Icon (boolean unused) { return null; }
|
getIcon
|
292,397
|
PsiManager () { return myPsiManager; }
|
getManager
|
292,398
|
void (@Nullable Consumer<? super FileTypeInfo> consumer) { myConsumer = consumer; }
|
setFileTypeInfoConsumer
|
292,399
|
void (@Nullable Consumer<? super FileTypeInfo> consumer) { myUserActionConsumer = consumer; }
|
setUserActionFileTypeInfoConsumer
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.