Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
305,200
boolean (final @NotNull Project project, final Editor editor, final PsiFile file) { if (file instanceof XmlFile) { if (editor != null) { final int offset = editor.getCaretModel().getOffset(); final PsiElement psiElement = file.findElementAt(offset); if (psiElement != null) { final PsiElement parent = psiElement.getParent(); if (parent instanceof XmlText && parent.getText().trim().length() > 0) { final PsiElement grandParent = parent.getParent(); if (grandParent != null && !isInsideUnsplittableElement(grandParent)) { return InjectedLanguageManager.getInstance(project).findInjectedElementAt(file, offset) == null; } } } } } return false; }
isAvailable
305,201
boolean (final PsiElement grandParent) { if (!(grandParent instanceof HtmlTag) && grandParent.getContainingFile().getLanguage() != XHTMLLanguage.INSTANCE) { return false; } final String name = ((XmlTag)grandParent).getName(); return "html".equals(name) || "body".equals(name) || "title".equals(name); }
isInsideUnsplittableElement
305,202
String (XmlTag xmlTag) { final StringBuilder attrsWoId = new StringBuilder(); for (XmlAttribute attribute : xmlTag.getAttributes()) { if (!HtmlUtil.ID_ATTRIBUTE_NAME.equals(attribute.getName())) { attrsWoId.append(attribute.getText()).append(" "); } } return attrsWoId.length() == 0 ? "" : " " + attrsWoId; }
getAttrsWithoutId
305,203
boolean () { return true; }
startInWriteAction
305,204
void (final @NotNull Project project, final @NotNull Editor editor, final @NotNull PsiFile file) { if (!EditorModificationUtil.checkModificationAllowed(editor)) return; try { final XmlTag contextTag = getContextTag(editor, file); if (contextTag == null) { throw new CommonRefactoringUtil.RefactoringErrorHintException("Caret should be positioned inside a tag"); } XmlElementDescriptor currentTagDescriptor = contextTag.getDescriptor(); assert currentTagDescriptor != null; final XmlElementDescriptor[] descriptors = currentTagDescriptor.getElementsDescriptors(contextTag); Arrays.sort(descriptors, Comparator.comparing(PsiMetaData::getName)); Consumer<XmlElementDescriptor> consumer = (selected) -> WriteCommandAction.writeCommandAction(project, file).withName(XmlBundle.message("generate.xml.tag")).run(() -> { if (selected == null) return; XmlTag newTag = createTag(contextTag, selected); PsiElement anchor = getAnchor(contextTag, editor, selected); if (anchor == null) { // insert it in the cursor position int offset = editor.getCaretModel().getOffset(); Document document = editor.getDocument(); document.insertString(offset, newTag.getText()); PsiDocumentManager.getInstance(project).commitDocument(document); newTag = PsiTreeUtil.getParentOfType(file.findElementAt(offset + 1), XmlTag.class, false); } else { newTag = (XmlTag)contextTag.addAfter(newTag, anchor); } if (newTag != null) { generateTag(newTag, editor); } }); if (ApplicationManager.getApplication().isUnitTestMode()) { XmlElementDescriptor descriptor = ContainerUtil.find(descriptors, xmlElementDescriptor -> xmlElementDescriptor.getName().equals(TEST_THREAD_LOCAL.get())); consumer.consume(descriptor); } else { JBPopupFactory.getInstance() .createPopupChooserBuilder(List.of(descriptors)) .setRenderer(new MyListCellRenderer()) .setTitle(XmlBundle.message("choose.tag.name")) .setItemChosenCallback(consumer) .setNamerForFiltering(o -> o.getName()) .createPopup() .showInBestPositionFor(editor); } } catch (CommonRefactoringUtil.RefactoringErrorHintException e) { HintManager.getInstance().showErrorHint(editor, e.getMessage()); } }
invoke
305,205
void (@NotNull XmlTag newTag, Editor editor) { generateRaw(newTag); final XmlTag restored = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(newTag); if (restored == null) { LOG.error("Could not restore tag: " + newTag.getText()); } TemplateBuilder builder = TemplateBuilderFactory.getInstance().createTemplateBuilder(restored); replaceElements(restored, builder); builder.run(editor, false); }
generateTag
305,206
void (final @NotNull XmlTag newTag) { XmlElementDescriptor selected = newTag.getDescriptor(); if (selected == null) return; switch (selected.getContentType()) { case XmlElementDescriptor.CONTENT_TYPE_EMPTY -> { newTag.collapseIfEmpty(); ASTNode node = newTag.getNode(); assert node != null; ASTNode elementEnd = node.findChildByType(XmlTokenType.XML_EMPTY_ELEMENT_END); if (elementEnd == null) { LeafElement emptyTagEnd = Factory.createSingleLeafElement(XmlTokenType.XML_EMPTY_ELEMENT_END, "/>", 0, 2, null, newTag.getManager()); node.addChild(emptyTagEnd); } } case XmlElementDescriptor.CONTENT_TYPE_MIXED -> newTag.getValue().setText(""); } for (XmlAttributeDescriptor descriptor : selected.getAttributesDescriptors(newTag)) { if (descriptor.isRequired()) { newTag.setAttribute(descriptor.getName(), ""); } } List<XmlElementDescriptor> tags = getRequiredSubTags(selected); for (XmlElementDescriptor descriptor : tags) { if (descriptor == null) { XmlTag tag = XmlElementFactory.getInstance(newTag.getProject()).createTagFromText("<", newTag.getLanguage()); newTag.addSubTag(tag, false); } else { XmlTag subTag = newTag.addSubTag(createTag(newTag, descriptor), false); generateRaw(subTag); } } }
generateRaw
305,207
List<XmlElementDescriptor> (XmlElementDescriptor selected) { XmlElementsGroup topGroup = selected.getTopGroup(); if (topGroup == null) return Collections.emptyList(); return computeRequiredSubTags(topGroup); }
getRequiredSubTags
305,208
void (XmlTag tag, TemplateBuilder builder) { for (XmlAttribute attribute : tag.getAttributes()) { XmlAttributeValue value = attribute.getValueElement(); if (value != null) { builder.replaceElement(value, TextRange.from(1, 0), new MacroCallNode(new CompleteMacro())); } } if ("<".equals(tag.getText())) { builder.replaceElement(tag, TextRange.from(1, 0), new MacroCallNode(new CompleteSmartMacro())); } else if (tag.getSubTags().length == 0) { int i = tag.getText().indexOf("></"); if (i > 0) { builder.replaceElement(tag, TextRange.from(i + 1, 0), new MacroCallNode(new CompleteMacro())); } } for (XmlTag subTag : tag.getSubTags()) { replaceElements(subTag, builder); } }
replaceElements
305,209
XmlTag (@NotNull XmlTag contextTag, @NotNull XmlElementDescriptor descriptor) { String namespace = getNamespace(descriptor); XmlTag tag = contextTag.createChildTag(descriptor.getName(), namespace, null, false); PsiElement lastChild = tag.getLastChild(); assert lastChild != null; lastChild.delete(); // remove XML_EMPTY_ELEMENT_END return tag; }
createTag
305,210
List<XmlElementDescriptor> (XmlElementsGroup group) { if (group.getMinOccurs() < 1) return Collections.emptyList(); switch (group.getGroupType()) { case LEAF -> { XmlElementDescriptor descriptor = group.getLeafDescriptor(); if (descriptor == null) return Collections.emptyList(); PsiElement declaration = descriptor.getDeclaration(); // don't add abstract elements to required sub tags list if (declaration instanceof XmlTag) { XmlTag tag = (XmlTag)descriptor.getDeclaration(); String abstractValue = tag.getAttributeValue("abstract", XMLConstants.W3C_XML_SCHEMA_NS_URI); if ("true".equals(abstractValue)) { return Collections.emptyList(); } } return Collections.singletonList(descriptor); } case CHOICE -> { LinkedHashSet<XmlElementDescriptor> set = null; for (XmlElementsGroup subGroup : group.getSubGroups()) { List<XmlElementDescriptor> descriptors = computeRequiredSubTags(subGroup); if (set == null) { set = new LinkedHashSet<>(descriptors); } else { set.retainAll(descriptors); } } if (set == null || set.isEmpty()) { return Collections.singletonList(null); // placeholder for smart completion } return new ArrayList<>(set); } default -> { ArrayList<XmlElementDescriptor> list = new ArrayList<>(); for (XmlElementsGroup subGroup : group.getSubGroups()) { list.addAll(computeRequiredSubTags(subGroup)); } return list; } } }
computeRequiredSubTags
305,211
boolean (XmlTag contextTag, @NotNull Editor editor) { return contextTag.getValue().getTextRange().contains(editor.getCaretModel().getOffset()); }
isInsideTagBody
305,212
boolean (@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) { if (!(file instanceof XmlFile)) return false; XmlTag contextTag = getContextTag(editor, file); return contextTag != null && isInsideTagBody(contextTag, editor) && contextTag.getDescriptor() != null; }
isValidForFile
305,213
boolean () { return false; }
startInWriteAction
305,214
Component (JList<? extends XmlElementDescriptor> list, XmlElementDescriptor value, int index, boolean isSelected, boolean cellHasFocus) { Color backgroundColor = isSelected ? list.getSelectionBackground() : list.getBackground(); myNameLabel.setText(value.getName()); myNameLabel.setForeground(isSelected ? list.getSelectionForeground() : list.getForeground()); myPanel.setBackground(backgroundColor); myNSLabel.setText(getNamespace(value)); myNSLabel.setForeground(LookupCellRenderer.getGrayedForeground(isSelected)); myNSLabel.setBackground(backgroundColor); return myPanel; }
getListCellRendererComponent
305,215
String (XmlFile file, Int2ObjectMap<String> map, String text, int start) { final StringBuilder result = new StringBuilder(); for (int i = 0; i < text.length(); i++) { char c = text.charAt(i); final PsiElement element = file.findElementAt(start + i); if (element != null && isCharacterElement(element)) { if (c == '<' || c == '>' || c == '&' || c == '"' || c == '\'' || c > 0x7f) { final String escape = map.get(c); if (escape != null) { result.append("&").append(escape).append(";"); continue; } } } result.append(c); } return result.toString(); }
escape
305,216
Int2ObjectMap<String> (XmlFile xmlFile) { final XmlFile file = XmlUtil.findXmlFile(xmlFile, Html5SchemaProvider.getCharsDtdLocation()); assert file != null; Int2ObjectMap<String> result = new Int2ObjectOpenHashMap<>(); XmlUtil.processXmlElements(file, element -> { if (element instanceof XmlEntityDecl) { final String value = ((XmlEntityDecl)element).getValueElement().getValue(); final int key = Integer.parseInt(value.substring(2, value.length() - 1)); if (!result.containsKey(key)) { result.put(key, ((XmlEntityDecl)element).getName()); } } return true; }, true); return result; }
computeMap
305,217
boolean (PsiElement element) { final IElementType type = element.getNode().getElementType(); if (type == XmlTokenType.XML_DATA_CHARACTERS) return true; if (type == XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN) { if (element.getParent().getParent() instanceof XmlAttribute) return true; } if (type == XmlTokenType.XML_BAD_CHARACTER) return true; if (type == XmlTokenType.XML_START_TAG_START) { if (element.getNextSibling() instanceof PsiErrorElement) return true; if (element.getParent() instanceof PsiErrorElement) return true; } return false; }
isCharacterElement
305,218
boolean (@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) { return file instanceof XmlFile; }
isValidForFile
305,219
CodeInsightActionHandler () { return this; }
getHandler
305,220
void (@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) { int[] starts = editor.getSelectionModel().getBlockSelectionStarts(); int[] ends = editor.getSelectionModel().getBlockSelectionEnds(); final Document document = editor.getDocument(); XmlFile xmlFile = (XmlFile)file; Int2ObjectMap<String> map = computeMap(xmlFile); for (int i = starts.length - 1; i >= 0; i--) { final int start = starts[i]; final int end = ends[i]; String oldText = document.getText(new TextRange(start, end)); final String newText = escape(xmlFile, map, oldText, start); if (!oldText.equals(newText)) { document.replaceString(start, end, newText); } } }
invoke
305,221
boolean () { return true; }
isStopOnUndeclaredResource
305,222
boolean (final Exception ex) { if (ex instanceof XmlResourceResolver.IgnoredResourceException) throw (XmlResourceResolver.IgnoredResourceException)ex; return errors.add(ex.getMessage()); }
filterValidationException
305,223
void (SAXParseException ex, ValidateXmlActionHandler.ProblemType warning) { errors.add(myHandler.buildMessageString(ex)); }
processError
305,224
List<String> () { return errors; }
getErrors
305,225
void () { final MyProcessController processController = new MyProcessController(); myErrorsView.setProcessController(processController); openMessageView(); processController.setFuture(ApplicationManager.getApplication().executeOnPooledThread( () -> ApplicationManager.getApplication().runReadAction(() -> super.startProcessing()))); ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.MESSAGES_WINDOW).activate(null); }
startProcessing
305,226
void () { CommandProcessor commandProcessor = CommandProcessor.getInstance(); commandProcessor.executeCommand( myProject, () -> { MessageView messageView = MessageView.getInstance(myProject); final Content content = ContentFactory.getInstance().createContent(myErrorsView.getComponent(), myContentName, true); content.putUserData(KEY, myErrorsView); messageView.getContentManager().addContent(content); messageView.getContentManager().setSelectedContent(content); messageView.getContentManager().addContentManagerListener(new CloseListener(content, messageView.getContentManager())); ContentManagerUtil.cleanupContents(content, myProject, myContentName); messageView.getContentManager().addContentManagerListener(new MyContentDisposer(content, messageView)); }, XmlBundle.message("xml.validate.open.message.view.command.name"), null ); }
openMessageView
305,227
void (final SAXParseException ex, final ValidateXmlActionHandler.ProblemType problemType) { if (LOG.isDebugEnabled()) { String error = myHandler.buildMessageString(ex); LOG.debug("enter: processError(error='" + error + "')"); } if (ApplicationManager.getApplication().isUnitTestMode()) { return; } ApplicationManager.getApplication().invokeLater(() -> { final VirtualFile file = myHandler.getProblemFile(ex); myErrorsView.addMessage( problemType == ValidateXmlActionHandler.ProblemType.WARNING ? MessageCategory.WARNING : MessageCategory.ERROR, new String[]{ex.getLocalizedMessage()}, file, ex.getLineNumber() - 1, ex.getColumnNumber() - 1, null ); } ); }
processError
305,228
void (@NotNull ContentManagerEvent event) { final Content eventContent = event.getContent(); if (!eventContent.equals(myContent)) { return; } myMessageView.getContentManager().removeContentManagerListener(this); NewErrorTreeViewPanel errorTreeView = eventContent.getUserData(KEY); if (errorTreeView != null) { Disposer.dispose(errorTreeView); } eventContent.putUserData(KEY, null); }
contentRemoved
305,229
void (@NotNull ContentManagerEvent event) { if (event.getContent() == myContent) { myErrorsView.stopProcess(); myContentManager.removeContentManagerListener(this); myContent.release(); myContent = null; } }
contentRemoved
305,230
void (@NotNull ContentManagerEvent event) { if (event.getContent() == myContent && !myErrorsView.isProcessStopped() && !MessageDialogBuilder.yesNo(XmlBundle.message("xml.validate.validation.is.running.terminate.confirmation.title"), XmlBundle.message("xml.validate.validation.is.running.terminate.confirmation.text")) .ask(myProject)) { event.consume(); } }
contentRemoveQuery
305,231
void (Future<?> future) { myFuture = future; }
setFuture
305,232
void () { if (myFuture != null) { myFuture.cancel(true); } }
stopProcess
305,233
boolean () { return myFuture != null && myFuture.isDone(); }
isProcessStopped
305,234
List<XmlElementArrangementEntry> () { return myEntries; }
getEntries
305,235
void (@NotNull XmlElementArrangementEntry entry) { myEntries.add(entry); }
addEntry
305,236
StdArrangementMatchRule (@NotNull String nameFilter, @NotNull String namespaceFilter, @NotNull ArrangementSettingsToken orderType) { return new StdArrangementMatchRule(new StdArrangementEntryMatcher(ArrangementUtil.combine( new ArrangementAtomMatchCondition(StdArrangementTokens.Regexp.NAME, nameFilter), new ArrangementAtomMatchCondition(StdArrangementTokens.Regexp.XML_NAMESPACE, namespaceFilter) )), orderType); }
attrArrangementRule
305,237
ArrangementSettingsSerializer () { return SETTINGS_SERIALIZER; }
getSerializer
305,238
boolean (@NotNull ArrangementSettingsToken token, @Nullable ArrangementMatchCondition current) { return SUPPORTED_TYPES.contains(token) || StdArrangementTokens.Regexp.NAME.equals(token) || StdArrangementTokens.Regexp.XML_NAMESPACE.equals(token) || KEEP.equals(token) || BY_NAME.equals(token); }
isEnabled
305,239
Collection<Set<ArrangementSettingsToken>> () { return Collections.singleton(SUPPORTED_TYPES); }
getMutexes
305,240
List<XmlElementArrangementEntry> (@NotNull PsiElement root, @Nullable Document document, @NotNull Collection<? extends TextRange> ranges, @NotNull ArrangementSettings settings) { final XmlArrangementParseInfo parseInfo = new XmlArrangementParseInfo(); root.accept(new XmlArrangementVisitor(parseInfo, ranges)); return parseInfo.getEntries(); }
parse
305,241
int (@NotNull CodeStyleSettings settings, @Nullable XmlElementArrangementEntry parent, @Nullable XmlElementArrangementEntry previous, @NotNull XmlElementArrangementEntry target) { return -1; }
getBlankLines
305,242
void (@NotNull XmlFile file) { XmlDocument document = file.getDocument(); List<XmlTag> tags = PsiTreeUtil.getChildrenOfTypeAsList(document, XmlTag.class); for (XmlTag tag : tags) { if (tag != null) { tag.accept(this); } } }
visitXmlFile
305,243
void (@NotNull XmlTag tag) { final XmlElementArrangementEntry entry = createNewEntry(tag, XML_TAG, tag.getName(), tag.getNamespace()); processEntry(entry, tag); if (entry != null) { postProcessTag(tag, entry); } }
visitXmlTag
305,244
void (@NotNull XmlTag xmlTagValue, @NotNull XmlElementArrangementEntry entry) { }
postProcessTag
305,245
void (@NotNull XmlAttribute attribute) { final XmlElementArrangementEntry entry = createNewEntry(attribute, XML_ATTRIBUTE, attribute.getName(), attribute.getNamespace()); processEntry(entry, null); }
visitXmlAttribute
305,246
void (@Nullable XmlElementArrangementEntry entry, @Nullable PsiElement nextElement) { if (entry == null || nextElement == null) { return; } myStack.push(entry); try { nextElement.acceptChildren(this); } finally { myStack.pop(); } }
processEntry
305,247
boolean (@NotNull TextRange range) { for (TextRange textRange : myRanges) { if (textRange.intersects(range)) { return true; } } return false; }
isWithinBounds
305,248
ArrangementSettingsSerializer () { return SETTINGS_SERIALIZER; }
getSerializer
305,249
List<XmlElementArrangementEntry> (@NotNull PsiElement root, @Nullable Document document, @NotNull Collection<? extends TextRange> ranges, @NotNull ArrangementSettings settings) { final XmlArrangementParseInfo parseInfo = new XmlArrangementParseInfo(); root.accept(new XmlArrangementVisitor(parseInfo, ranges) { @Override protected void postProcessTag(@NotNull XmlTag xmlTag, @NotNull XmlElementArrangementEntry xmlTagEntry) { addEntriesForEmbeddedContent(xmlTag, xmlTagEntry, document, ranges); } }); return parseInfo.getEntries(); }
parse
305,250
void (@NotNull XmlTag xmlTag, @NotNull XmlElementArrangementEntry xmlTagEntry) { addEntriesForEmbeddedContent(xmlTag, xmlTagEntry, document, ranges); }
postProcessTag
305,251
void (@NotNull XmlTag xmlTag, @NotNull XmlElementArrangementEntry xmlTagEntry, @Nullable Document document, @NotNull Collection<? extends TextRange> ranges) { if (!StringUtil.equals(xmlTag.getName(), HtmlUtil.SCRIPT_TAG_NAME) && !StringUtil.equals(xmlTag.getName(), HtmlUtil.STYLE_TAG_NAME)) { return; } for (XmlTagChild child : xmlTag.getValue().getChildren()) { Language childLanguage = child.getLanguage(); if (childLanguage.isKindOf(XMLLanguage.INSTANCE)) { continue; } Rearranger<?> rearranger = Rearranger.EXTENSION.forLanguage(childLanguage); ArrangementSettings arrangementSettingsForLanguage = ArrangementUtil.getArrangementSettings(CodeStyle.getSettings(child.getContainingFile()), childLanguage); if (arrangementSettingsForLanguage == null || rearranger == null) { continue; } List<? extends ArrangementEntry> foreignEntries = rearranger.parse(child, document, ranges, arrangementSettingsForLanguage); if (!foreignEntries.isEmpty()) { ForeignEntry foreignParent = new ForeignEntry(xmlTagEntry, child.getTextRange()); for (ArrangementEntry foreignEntry : foreignEntries) { foreignParent.addChild(foreignEntry); } xmlTagEntry.addChild(foreignParent); } } }
addEntriesForEmbeddedContent
305,252
boolean (final @NotNull PsiElement e) { return e instanceof XmlTag && e.isValid(); }
acceptElement
305,253
Language[] () { return new Language[]{XMLLanguage.INSTANCE, XHTMLLanguage.INSTANCE, HTMLLanguage.INSTANCE}; }
getLanguages
305,254
String (final @NotNull PsiElement e) { return getInfo(e); }
getElementInfo
305,255
String (@NotNull PsiElement e) { final XmlTag tag = (XmlTag)e; final boolean addHtmlInfo = e.getContainingFile().getLanguage() != XMLLanguage.INSTANCE; return addHtmlInfo ? HtmlUtil.getTagPresentation(tag) : tag.getName(); }
getInfo
305,256
String (@NotNull XmlTag tag) { final StringBuilder result = new StringBuilder("&lt;"); result.append(tag.getName()); final XmlAttribute[] attributes = tag.getAttributes(); for (final XmlAttribute each : attributes) { result.append(" ").append(each.getText()); } if (tag.isEmpty()) { result.append("/&gt;"); } else { result.append("&gt;...&lt;/").append(tag.getName()).append("&gt;"); } return result.toString(); }
getTooltip
305,257
boolean (@NotNull PsiElement element) { return false; }
canInlineElement
305,258
Settings (@NotNull PsiElement element, Editor editor, boolean invokedOnReference) { return null; }
prepareInlineElement
305,259
void (@NotNull PsiElement element, @NotNull Settings settings) { }
removeDefinition
305,260
Inliner (@NotNull PsiElement element, @NotNull Settings settings) { return null; }
createInliner
305,261
void (final Editor editor, final @NotNull XmlTag tag) { if (!ourRenamersStack.isEmpty()) { ourRenamersStack.peek().finish(); } final XmlTagInplaceRenamer renamer = new XmlTagInplaceRenamer(editor); ourRenamersStack.push(renamer); renamer.rename(tag); }
rename
305,262
void (final @NotNull XmlTag tag) { final Pair<ASTNode, ASTNode> pair = getNamePair(tag); if (pair == null) return; final Project project = myEditor.getProject(); if (project != null) { final List<TextRange> highlightRanges = new ArrayList<>(); highlightRanges.add(pair.first.getTextRange()); if (pair.second != null) { highlightRanges.add(pair.second.getTextRange()); } if (!CommonRefactoringUtil.checkReadOnlyStatus(project, tag)) { return; } myHighlighters = new ArrayList<>(); CommandProcessor.getInstance().executeCommand(project, () -> ApplicationManager.getApplication().runWriteAction(() -> { final int offset = myEditor.getCaretModel().getOffset(); myEditor.getCaretModel().moveToOffset(tag.getTextOffset()); final Template t = buildTemplate(tag, pair); TemplateManager.getInstance(project).startTemplate(myEditor, t, new TemplateEditingAdapter() { @Override public void templateFinished(final @NotNull Template template, boolean brokenOff) { finish(); } @Override public void templateCancelled(final Template template) { finish(); } }, (variableName, value) -> value.length() == 0 || value.charAt(value.length() - 1) != ' '); // restore old offset myEditor.getCaretModel().moveToOffset(offset); addHighlights(highlightRanges, myEditor, myHighlighters); }), RefactoringBundle.message("rename.title"), null); } }
rename
305,263
void (final @NotNull Template template, boolean brokenOff) { finish(); }
templateFinished
305,264
void (final Template template) { finish(); }
templateCancelled
305,265
void () { ourRenamersStack.pop(); if (myHighlighters != null) { Project project = myEditor.getProject(); if (project != null && !project.isDisposed()) { final HighlightManager highlightManager = HighlightManager.getInstance(project); for (final RangeHighlighter highlighter : myHighlighters) { highlightManager.removeSegmentHighlighter(myEditor, highlighter); } } } }
finish
305,266
Template (final @NotNull XmlTag tag, final @NotNull Pair<? extends ASTNode, ? extends ASTNode> pair) { final TemplateBuilderImpl builder = new TemplateBuilderImpl(tag); final ASTNode selected = pair.first; final ASTNode other = pair.second; builder.replaceElement(selected.getPsi(), PRIMARY_VARIABLE_NAME, new ConstantNode(selected.getText()), true); if (other != null) { builder.replaceElement(other.getPsi(), OTHER_VARIABLE_NAME, PRIMARY_VARIABLE_NAME, false); } return builder.buildInlineTemplate(); }
buildTemplate
305,267
void (List<? extends TextRange> ranges, Editor editor, ArrayList<RangeHighlighter> highlighters) { EditorColorsManager colorsManager = EditorColorsManager.getInstance(); final TextAttributes attributes = colorsManager.getGlobalScheme().getAttributes(EditorColors.WRITE_SEARCH_RESULT_ATTRIBUTES); final HighlightManager highlightManager = HighlightManager.getInstance(editor.getProject()); for (final TextRange range : ranges) { highlightManager.addOccurrenceHighlight(editor, range.getStartOffset(), range.getEndOffset(), attributes, 0, highlighters, null); } for (RangeHighlighter highlighter : highlighters) { highlighter.setGreedyToLeft(true); highlighter.setGreedyToRight(true); } }
addHighlights
305,268
boolean (@Nullable PsiElement element, @NotNull Editor editor, @NotNull PsiFile file) { PossiblePrefixReference ref = getReference(file, editor); return ref != null && ref.resolve() instanceof SchemaPrefix; }
isAvailable
305,269
VariableInplaceRenamer (@NotNull PsiElement elementToRename, @NotNull Editor editor) { PossiblePrefixReference reference = getReference(elementToRename.getContainingFile(), editor); if (reference != null) { PsiElement prefix = reference.resolve(); if (prefix instanceof SchemaPrefix) { return new VariableInplaceRenamer((PsiNamedElement)prefix, editor) { @Override protected void addReferenceAtCaret(Collection<? super PsiReference> refs) {} @Override protected boolean isReferenceAtCaret(PsiElement selectedElement, PsiReference ref) { return false; } }; } } return null; }
createRenamer
305,270
void (Collection<? super PsiReference> refs) {}
addReferenceAtCaret
305,271
boolean (PsiElement selectedElement, PsiReference ref) { return false; }
isReferenceAtCaret
305,272
boolean (final @NotNull DataContext dataContext) { final PsiElement element = getElement(dataContext); if (element == null || PsiElementRenameHandler.isVetoed(element)) return false; PsiElement parent = element.getParent(); if (!(parent instanceof XmlTag tag)) { return false; } String prefix = tag.getNamespacePrefix(); if (StringUtil.isNotEmpty(prefix)) { Editor editor = getEditor(dataContext); assert editor != null; int offset = editor.getCaretModel().getOffset(); if (offset <= element.getTextRange().getStartOffset() + prefix.length()) { return false; } } return isDeclarationOutOfProjectOrAbsent(element.getProject(), dataContext); }
isAvailableOnDataContext
305,273
String () { return XmlBundle.message("rename.xml.tag"); }
getActionTitle
305,274
boolean (final Editor editor) { return editor.getSettings().isVariableInplaceRenameEnabled(); }
isInplaceRenameAvailable
305,275
boolean (final @NotNull Project project, final DataContext context) { final PsiElement[] elements = BaseRefactoringAction.getPsiElementArray(context); return elements.length == 0 || elements.length == 1 && shouldBeRenamedInplace(project, elements); }
isDeclarationOutOfProjectOrAbsent
305,276
boolean (Project project, PsiElement[] elements) { boolean inProject = PsiManager.getInstance(project).isInProject(elements[0]); if (inProject && elements[0] instanceof XmlTag) { XmlElementDescriptor descriptor = ((XmlTag)elements[0]).getDescriptor(); return descriptor instanceof AnyXmlElementDescriptor; } return !inProject; }
shouldBeRenamedInplace
305,277
void (final @Nullable Editor editor, final @NotNull PsiElement element, final @Nullable DataContext context) { if (!isRenaming(context)) { return; } if (isInplaceRenameAvailable(editor)) { XmlTagInplaceRenamer.rename(editor, (XmlTag)element.getParent()); } else { XmlTagRenameDialog.renameXmlTag(editor, element, (XmlTag)element.getParent()); } }
invoke
305,278
void (final @NotNull Project project, final Editor editor, final PsiFile file, final @Nullable DataContext dataContext) { if (!isRenaming(dataContext)) { return; } final PsiElement element = getElement(dataContext); assert element != null; invoke(editor, element, dataContext); }
invoke
305,279
void (final @NotNull Project project, final PsiElement @NotNull [] elements, final @Nullable DataContext dataContext) { PsiElement element = elements.length == 1 ? elements[0] : null; if (element == null) { element = getElement(dataContext); } LOG.assertTrue(element != null); invoke(getEditor(dataContext), element, dataContext); }
invoke
305,280
void () { myNameSuggestionsField.removeDataChangedListener(myNameChangedListener); super.dispose(); }
dispose
305,281
boolean () { return false; }
hasHelpAction
305,282
String (final @NotNull XmlTag tag) { final String name = DescriptiveNameUtil.getDescriptiveName(tag); return (UsageViewUtil.getType(tag) + " " + name).trim(); }
getFullName
305,283
void (final Editor editor, final @NotNull PsiElement element, final @NotNull XmlTag tag) { final XmlTagRenameDialog dialog = new XmlTagRenameDialog(editor, element, tag); dialog.show(); }
renameXmlTag
305,284
void () { myNameSuggestionsField = new NameSuggestionsField(new String[] { myTag.getName() }, myProject, FileTypes.PLAIN_TEXT, myEditor); myNameChangedListener = () -> validateButtons(); myNameSuggestionsField.addDataChangedListener(myNameChangedListener); myNameSuggestionsField.getComponent().registerKeyboardAction(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { completeVariable(myNameSuggestionsField.getEditor()); } }, KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, InputEvent.CTRL_MASK), JComponent.WHEN_IN_FOCUSED_WINDOW); }
createNewNameComponent
305,285
void (ActionEvent e) { completeVariable(myNameSuggestionsField.getEditor()); }
actionPerformed
305,286
void (final Editor editor) { String prefix = myNameSuggestionsField.getEnteredName(); final PsiReference reference = myTag.getReference(); if (reference instanceof TagNameReference) { LookupElement[] lookupItems = TagNameReferenceCompletionProvider.getTagNameVariants(myTag, myTag.getNamespacePrefix()); editor.getCaretModel().moveToOffset(prefix.length()); editor.getSelectionModel().removeSelection(); LookupManager.getInstance(getProject()).showLookup(editor, lookupItems, prefix); } }
completeVariable
305,287
void () { LOG.assertTrue(myElement.isValid()); CommandProcessor.getInstance().executeCommand(myProject, () -> ApplicationManager.getApplication().runWriteAction(() -> { try { myTag.setName(getNewName()); } catch (IncorrectOperationException e) { LOG.error(e); } }), RefactoringBundle.message("rename.title"), null); close(DialogWrapper.OK_EXIT_CODE); }
doAction
305,288
JComponent () { return myNameSuggestionsField.getFocusableComponent(); }
getPreferredFocusedComponent
305,289
JComponent () { final JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); panel.setBorder(BorderFactory.createEmptyBorder(4, 8, 4, 8)); myTitleLabel = new JLabel(); panel.add(myTitleLabel); panel.add(Box.createVerticalStrut(8)); panel.add(myNameSuggestionsField.getComponent()); return panel; }
createNorthPanel
305,290
String () { return myNameSuggestionsField.getEnteredName().trim(); }
getNewName
305,291
void () { super.validateButtons(); getPreviewAction().setEnabled(false); }
validateButtons
305,292
boolean () { final String newName = getNewName(); return !StringUtil.containsAnyChar(newName, "\t ;*'\"\\/,()^&<>={}"); // RenameUtil.isValidName(myProject, myTag, newName); // IDEADEV-34531 }
areButtonsValid
305,293
int (@NotNull IElementType tokenType) { final Language l = tokenType.getLanguage(); PairedBraceMatcher matcher = getPairedBraceMatcher(tokenType); if (matcher != null) { BracePair[] pairs = matcher.getPairs(); for (BracePair pair : pairs) { if (pair.getLeftBraceType() == tokenType || pair.getRightBraceType() == tokenType ) { return l.hashCode(); } } } if (tokenType instanceof IXmlLeafElementType) { return tokenType == XmlTokenType.XML_ATTRIBUTE_VALUE_START_DELIMITER || tokenType == XmlTokenType.XML_ATTRIBUTE_VALUE_END_DELIMITER ? XML_VALUE_DELIMITER_GROUP : XML_TAG_TOKEN_GROUP; } else{ return BraceMatchingUtil.UNDEFINED_TOKEN_GROUP; } }
getBraceTokenGroupId
305,294
boolean (@NotNull HighlighterIterator iterator, @NotNull CharSequence fileText, @NotNull FileType fileType) { final IElementType tokenType = iterator.getTokenType(); PairedBraceMatcher matcher = getPairedBraceMatcher(tokenType); if (matcher != null) { BracePair[] pairs = matcher.getPairs(); for (BracePair pair : pairs) { if (pair.getLeftBraceType() == tokenType) return true; } } return tokenType == XmlTokenType.XML_START_TAG_START || tokenType == XmlTokenType.XML_ATTRIBUTE_VALUE_START_DELIMITER || tokenType == XmlTokenType.XML_CDATA_START; }
isLBraceToken
305,295
boolean (@NotNull HighlighterIterator iterator, @NotNull CharSequence fileText, @NotNull FileType fileType) { final IElementType tokenType = iterator.getTokenType(); PairedBraceMatcher matcher = getPairedBraceMatcher(tokenType); if (matcher != null) { BracePair[] pairs = matcher.getPairs(); for (BracePair pair : pairs) { if (pair.getRightBraceType() == tokenType) return true; } } if (tokenType == XmlTokenType.XML_EMPTY_ELEMENT_END || tokenType == XmlTokenType.XML_ATTRIBUTE_VALUE_END_DELIMITER || tokenType == XmlTokenType.XML_CDATA_END) { return true; } else if (tokenType == XmlTokenType.XML_TAG_END) { final boolean result = findEndTagStart(iterator); if (isFileTypeWithSingleHtmlTags(fileType)) { final String tagName = getTagName(fileText, iterator); if (tagName != null && HtmlUtil.isSingleHtmlTag(tagName, false)) { return !result; } } return result; } else { return false; } }
isRBraceToken
305,296
boolean (final FileType fileType) { return fileType == HtmlFileType.INSTANCE; }
isFileTypeWithSingleHtmlTags
305,297
boolean (@NotNull IElementType tokenType1, @NotNull IElementType tokenType2) { PairedBraceMatcher matcher = getPairedBraceMatcher(tokenType1); if (matcher != null) { BracePair[] pairs = matcher.getPairs(); for (BracePair pair : pairs) { if (pair.getLeftBraceType() == tokenType1 ) return pair.getRightBraceType() == tokenType2; if (pair.getRightBraceType() == tokenType1 ) return pair.getLeftBraceType() == tokenType2; } } if (tokenType2.equals(PAIRING_TOKENS.get(tokenType1))) return true; List<IElementType> keys = PAIRING_TOKENS.getKeysByValue(tokenType1); return keys != null && keys.contains(tokenType2); }
isPairBraces
305,298
boolean (@NotNull HighlighterIterator iterator, @NotNull CharSequence text, @NotNull FileType fileType) { IElementType tokenType = iterator.getTokenType(); PairedBraceMatcher matcher = getPairedBraceMatcher(tokenType); if (matcher != null) { BracePair[] pairs = matcher.getPairs(); for (BracePair pair : pairs) { if ((pair.getLeftBraceType() == tokenType || pair.getRightBraceType() == tokenType) && pair.isStructural()) return true; } } return isXmlStructuralBrace(tokenType); }
isStructuralBrace
305,299
boolean (IElementType tokenType) { return tokenType == XmlTokenType.XML_START_TAG_START || tokenType == XmlTokenType.XML_TAG_END || tokenType == XmlTokenType.XML_EMPTY_ELEMENT_END; }
isXmlStructuralBrace