public void _testLexerPerformance1() throws Exception { final String text = loadFile("pallada.xml"); XmlLexer lexer = new XmlLexer(); doLex(lexer, text); final FilterLexer filterLexer = new FilterLexer(new XmlLexer(), new FilterLexer.SetFilter( LanguageParserDefinitions.INSTANCE.forLanguage(XMLLanguage.INSTANCE) .getWhitespaceTokens())); doLex(filterLexer, text); doLex(lexer, text); doLex(filterLexer, text); doLex(filterLexer, text); }
public static boolean isInXmlContext(Lookup lookup) { if (!lookup.isCompletion()) return false; PsiElement psiElement = lookup.getPsiElement(); PsiFile file = lookup.getPsiFile(); if (!(file instanceof XmlFile) && psiElement != null) { file = psiElement.getContainingFile(); } if (file instanceof XmlFile) { if (psiElement != null) { PsiElement elementToTest = psiElement; if (elementToTest instanceof PsiWhiteSpace) { elementToTest = elementToTest.getParent(); // JSPX has whitespace with language Java } final Language language = elementToTest.getLanguage(); if (!(language instanceof XMLLanguage)) { return false; } } return true; } return false; }
private static boolean isLanguageRelevant(final PsiElement element, final PsiFile file, final Ref<Boolean> isRelevantLanguage, final Ref<Boolean> isAnt) { Boolean isAntFile = isAnt.get(); if (isAntFile == null) { isAntFile = XmlUtil.isAntFile(file); isAnt.set(isAntFile); } Boolean result = isRelevantLanguage.get(); if (result == null) { Language language = element.getLanguage(); PsiElement parent = element.getParent(); if (element instanceof PsiWhiteSpace && parent != null) { language = parent.getLanguage(); } result = language instanceof XMLLanguage || HtmlUtil.supportsXmlTypedHandlers(file) || isAntFile.booleanValue(); isRelevantLanguage.set(result); } return result.booleanValue(); }
@Override public Result charTyped(char c, Project project, @NotNull Editor editor, @NotNull PsiFile file) { if (c == '?' && file.getLanguage() == XMLLanguage.INSTANCE) { int offset = editor.getCaretModel().getOffset(); if (offset >= 2 && editor.getDocument().getCharsSequence().charAt(offset - 2) == '<') { PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument()); PsiElement at = file.findElementAt(offset - 2); if (at != null && at.getNode().getElementType() == XmlTokenType.XML_PI_START && editor.getDocument().getText().indexOf("?>", offset) == -1) { editor.getDocument().insertString(offset, " ?>"); AutoPopupController.getInstance(project).scheduleAutoPopup(editor); } } } return super.charTyped(c, project, editor, file); }
@NotNull private static XmlTag expandEmptyTagIfNecessary(@NotNull XmlTag tag) { StringBuilder builder = new StringBuilder(); boolean flag = false; for (PsiElement child : tag.getChildren()) { if (child instanceof XmlToken && XmlTokenType.XML_EMPTY_ELEMENT_END.equals(((XmlToken)child).getTokenType())) { flag = true; break; } builder.append(child.getText()); } if (flag) { builder.append("></").append(tag.getName()).append('>'); return XmlElementFactory.getInstance(tag.getProject()).createTagFromText(builder.toString(), XMLLanguage.INSTANCE); } return tag; }
private List<Block> splitAttribute(ASTNode node, XmlFormattingPolicy formattingPolicy) { final ArrayList<Block> result = new ArrayList<Block>(3); ASTNode child = node.getFirstChildNode(); while (child != null) { if (child.getElementType() == XmlTokenType.XML_ATTRIBUTE_VALUE_START_DELIMITER || child.getElementType() == XmlTokenType.XML_ATTRIBUTE_VALUE_END_DELIMITER) { result.add(new XmlBlock(child, null, null, formattingPolicy, null, null, isPreserveSpace())); } else if (!child.getPsi().getLanguage().isKindOf(XMLLanguage.INSTANCE) && containsOuterLanguageElement(child)) { // Fix for EA-20311: // In case of another embedded language create a splittable XML block which can be // merged with other language's code blocks. createLeafBlocks(child, result); } else if (child.getElementType() != TokenType.ERROR_ELEMENT || child.getFirstChildNode() != null) { result.add(new ReadOnlyBlock(child)); } child = child.getTreeNext(); } return result; }
private static void doRenameXmlAttributeValue(@NotNull XmlAttributeValue value, String newName, UsageInfo[] infos, @Nullable RefactoringElementListener listener) throws IncorrectOperationException { LOG.assertTrue(value.isValid()); renameAll(value, infos, newName, value.getValue()); PsiManager psiManager = value.getManager(); LOG.assertTrue(psiManager != null); XmlFile file = (XmlFile)PsiFileFactory.getInstance(psiManager.getProject()).createFileFromText("dummy.xml", XMLLanguage.INSTANCE, "<a attr=\"" + newName + "\"/>"); @SuppressWarnings("ConstantConditions") PsiElement element = value.replace(file.getRootTag().getAttributes()[0].getValueElement()); if (listener != null) { listener.elementRenamed(element); } }
public Result checkAutoPopup(final char charTyped, final Project project, final Editor editor, final PsiFile file) { final boolean isXmlLikeFile = file.getLanguage() instanceof XMLLanguage || file.getViewProvider().getBaseLanguage() instanceof XMLLanguage; boolean spaceInTag = isXmlLikeFile && charTyped == ' '; if (spaceInTag) { spaceInTag = false; final PsiElement at = file.findElementAt(editor.getCaretModel().getOffset()); if (at != null) { final PsiElement parent = at.getParent(); if (parent instanceof XmlTag) { spaceInTag = true; } } } if ((charTyped == '<' || charTyped == '{' || charTyped == '/' || spaceInTag) && isXmlLikeFile) { autoPopupXmlLookup(project, editor); return Result.STOP; } return Result.CONTINUE; }
private static boolean isLanguageRelevant(final PsiElement element, final PsiFile file, final Ref<Boolean> isRelevantLanguage, final Ref<Boolean> isAnt) { Boolean isAntFile = isAnt.get(); if (isAntFile == null) { isAntFile = XmlUtil.isAntFile(file); isAnt.set(isAntFile); } Boolean result = isRelevantLanguage.get(); if (result == null) { Language language = element.getLanguage(); PsiElement parent = element.getParent(); if (element instanceof PsiWhiteSpace && parent != null) { language = parent.getLanguage(); } result = language instanceof XMLLanguage || isAntFile.booleanValue(); isRelevantLanguage.set(result); } return result.booleanValue(); }
@Override public Result beforeCharTyped(char c, Project project, Editor editor, PsiFile file, FileType fileType) { boolean inXml = file.getLanguage() instanceof XMLLanguage || file.getViewProvider().getBaseLanguage() instanceof XMLLanguage; if (c == '=' && inXml) { int offset = editor.getCaretModel().getOffset(); PsiElement at = file.findElementAt(offset - 1); PsiElement atParent = at != null ? at.getParent() : null; needToInsertQuotes = atParent instanceof XmlAttribute && ((XmlAttribute)atParent).getValueElement() == null; } return super.beforeCharTyped(c, project, editor, file, fileType); }
@NotNull private static XmlTag expandEmptyTagIfNeccessary(@NotNull XmlTag tag) { StringBuilder builder = new StringBuilder(); boolean flag = false; for (PsiElement child : tag.getChildren()) { if (child instanceof XmlToken && XmlTokenType.XML_EMPTY_ELEMENT_END.equals(((XmlToken)child).getTokenType())) { flag = true; break; } builder.append(child.getText()); } if (flag) { builder.append("></").append(tag.getName()).append('>'); return XmlElementFactory.getInstance(tag.getProject()).createTagFromText(builder.toString(), XMLLanguage.INSTANCE); } return tag; }
@Override public void initComponent() { super.initComponent(); new PsiTreeChangePreprocessorBase(myPsiManager) { @Override protected boolean isInsideCodeBlock(PsiElement element) { if (element instanceof PsiFileSystemItem) { return false; } if (element == null || element.getParent() == null) return true; final boolean isXml = element.getLanguage() instanceof XMLLanguage; // any xml element isn't inside a "code block" // cause we display even attributes and tag values in structure view return !isXml; } }; }
@NotNull public String getElementInfo(@NotNull final PsiElement e) { final XmlTag tag = (XmlTag)e; final StringBuffer sb = new StringBuffer(); sb.append(tag.getName()); final boolean addHtmlInfo = e.getContainingFile().getLanguage() != XMLLanguage.INSTANCE; if (addHtmlInfo) { final String id_value = tag.getAttributeValue(ID_ATTRIBUTE_NAME); if (null != id_value) { sb.append("#").append(id_value); } final String class_value = tag.getAttributeValue(CLASS_ATTRIBUTE_NAME); if (null != class_value) { final StringTokenizer tokenizer = new StringTokenizer(class_value, " "); while (tokenizer.hasMoreTokens()) { sb.append(".").append(tokenizer.nextToken()); } } } return sb.toString(); }
@Nullable public static BreadcrumbsInfoProvider findInfoProvider(@Nullable FileViewProvider viewProvider) { BreadcrumbsInfoProvider provider = null; if (viewProvider != null) { final WebEditorOptions webEditorOptions = WebEditorOptions.getInstance(); final Language baseLang = viewProvider.getBaseLanguage(); provider = getInfoProvider(baseLang); if (!webEditorOptions.isBreadcrumbsEnabledInXml() && baseLang == XMLLanguage.INSTANCE) return null; if (!webEditorOptions.isBreadcrumbsEnabled() && baseLang != XMLLanguage.INSTANCE) return null; if (provider == null) { for (final Language language : viewProvider.getLanguages()) { provider = getInfoProvider(language); if (provider != null) { break; } } } } return provider; }
private List<Block> splitAttribute(ASTNode node, XmlFormattingPolicy formattingPolicy) { final ArrayList<Block> result = new ArrayList<Block>(3); ASTNode child = node.getFirstChildNode(); while (child != null) { if (child.getElementType() == XmlElementType.XML_ATTRIBUTE_VALUE_START_DELIMITER || child.getElementType() == XmlElementType.XML_ATTRIBUTE_VALUE_END_DELIMITER) { result.add(new XmlBlock(child, null, null, formattingPolicy, null, null, isPreserveSpace())); } else if (!child.getPsi().getLanguage().isKindOf(XMLLanguage.INSTANCE) && containsOuterLanguageElement(child)) { // Fix for EA-20311: // In case of another embedded language create a splittable XML block which can be // merged with other language's code blocks. createLeafBlocks(child, result); } else if (child.getElementType() != TokenType.ERROR_ELEMENT || child.getFirstChildNode() != null) { result.add(new ReadOnlyBlock(child)); } child = child.getTreeNext(); } return result; }
public XmlHaxelibCompletionContributor() { HaxelibCache haxelibCache = HaxelibCache.getInstance(); availableHaxelibs = haxelibCache.getAvailableHaxelibs(); localHaxelibs = haxelibCache.getLocalHaxelibs(); extend(CompletionType.BASIC, PlatformPatterns.psiElement().inside( XmlPatterns.xmlAttributeValue().withParent(XmlPatterns.xmlAttribute("name")) .withSuperParent(2, XmlPatterns.xmlTag().withName("haxelib")).withLanguage(XMLLanguage.INSTANCE)), new CompletionProvider<CompletionParameters>() { @Override protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result) { for (int i = 0; i < availableHaxelibs.size(); i++) { result.addElement(LookupElementBuilder.create(availableHaxelibs.get(i)) .withTailText(" available at haxelib", true)); } for (int i = 0; i < localHaxelibs.size(); i++) { result.addElement(LookupElementBuilder.create(localHaxelibs.get(i)) .withTailText(" installed", true)); } } }); }
public void testGetTargetForXlfAsXmlFileInVersion12() { PsiFile fileFromText = PsiFileFactory.getInstance(getProject()).createFileFromText(XMLLanguage.INSTANCE, "" + "<?xml version=\"1.0\"?>\n" + "<xliff version=\"1.2\" xmlns=\"urn:oasis:names:tc:xliff:document:1.2\">\n" + " <file source-language=\"en\" datatype=\"plaintext\" original=\"file.ext\">\n" + " <body>\n" + " <trans-unit id=\"1\">\n" + " <source>This value should be false.</source>\n" + " </trans-unit>\n" + " </body>\n" + " </file>\n" + "</xliff>\n" ); Collection<PsiElement> files = TranslationUtil.getTargetForXlfAsXmlFile((XmlFile) fileFromText, "This value should be false."); assertNotNull(ContainerUtil.find(files, psiElement -> psiElement instanceof XmlTag && "This value should be false.".equals(((XmlTag) psiElement).getValue().getText())) ); }
public void testGetTargetForXlfAsXmlFileInVersion20() { PsiFile fileFromText = PsiFileFactory.getInstance(getProject()).createFileFromText(XMLLanguage.INSTANCE, "" + "<?xml version=\"1.0\"?>\n" + "<xliff xmlns=\"urn:oasis:names:tc:xliff:document:2.0\"\n" + " version=\"2.0\" srcLang=\"en-US\" trgLang=\"ja-JP\">\n" + " <file id=\"f1\" original=\"Graphic Example.psd\">\n" + " <skeleton href=\"Graphic Example.psd.skl\"/>\n" + " <group id=\"1\">\n" + " <unit id=\"1\">\n" + " <segment>\n" + " <source>foo</source>\n" + " </segment>\n" + " </unit>\n" + " </group>\n" + " </file>\n" + "</xliff>" ); Collection<PsiElement> files = TranslationUtil.getTargetForXlfAsXmlFile((XmlFile) fileFromText, "foo"); assertNotNull(ContainerUtil.find(files, psiElement -> psiElement instanceof XmlTag && "foo".equals(((XmlTag) psiElement).getValue().getText())) ); }
public void testGetTargetForXlfAsXmlFileInVersion20Shortcut() { PsiFile fileFromText = PsiFileFactory.getInstance(getProject()).createFileFromText(XMLLanguage.INSTANCE, "" + "<xliff xmlns=\"urn:oasis:names:tc:xliff:document:2.0\" version=\"2.0\"\n" + " srcLang=\"en-US\" trgLang=\"ja-JP\">\n" + " <file id=\"f1\" original=\"Graphic Example.psd\">\n" + " <skeleton href=\"Graphic Example.psd.skl\"/>\n" + " <unit id=\"1\">\n" + " <segment>\n" + " <source>foo</source>\n" + " </segment>\n" + " </unit>\n" + " </file>\n" + "</xliff>" ); Collection<PsiElement> files = TranslationUtil.getTargetForXlfAsXmlFile((XmlFile) fileFromText, "foo"); assertNotNull(ContainerUtil.find(files, psiElement -> psiElement instanceof XmlTag && "foo".equals(((XmlTag) psiElement).getValue().getText())) ); }
public void testGetTargetForXlfAsXmlFileInVersion12AndResname() { PsiFile fileFromText = PsiFileFactory.getInstance(getProject()).createFileFromText(XMLLanguage.INSTANCE, "" + "<?xml version=\"1.0\"?>\n" + "<xliff version=\"1.2\" xmlns=\"urn:oasis:names:tc:xliff:document:1.2\">\n" + " <file source-language=\"en\" datatype=\"plaintext\" original=\"file.ext\">\n" + " <body>\n" + " <trans-unit id=\"1\" resname=\"index.hello_world\">\n" + " <source>foo</source>\n" + " </trans-unit>\n" + " </body>\n" + " </file>\n" + "</xliff>\n" ); Collection<PsiElement> files = TranslationUtil.getTargetForXlfAsXmlFile((XmlFile) fileFromText, "index.hello_world"); assertNotNull(ContainerUtil.find(files, psiElement -> psiElement instanceof XmlTag && "index.hello_world".equals(((XmlTag) psiElement).getAttributeValue("resname"))) ); }
@SuppressWarnings({ "StringEquality" }) public void initComponent() { final Language xmlLang = XMLLanguage.INSTANCE; // intentionManager.addAction(new DeleteUnusedParameterFix()); // intentionManager.addAction(new DeleteUnusedVariableFix()); final XsltFormattingModelBuilder builder = new XsltFormattingModelBuilder(LanguageFormatting.INSTANCE.forLanguage(xmlLang)); LanguageFormatting.INSTANCE.addExplicitExtension(xmlLang, builder); try { // TODO: put this into com.intellij.refactoring.actions.IntroduceParameterAction, just like IntroduceVariableAction ActionManager.getInstance().getAction("IntroduceParameter").setInjectedContext(true); } catch (Exception e) { Logger.getInstance(XsltConfigImpl.class.getName()).error(e); } }
@Override @Nullable public UsageType getUsageType(PsiElement element) { final PsiFile psiFile = element.getContainingFile(); if (psiFile != null && XMLLanguage.INSTANCE.equals(psiFile.getLanguage()) && DomManager.getDomManager(element.getProject()).getFileElement((XmlFile)psiFile, DomElement.class) != null) { return DOM_USAGE_TYPE; } return null; }
static boolean isTagWithEmptyEndNotAllowed(final XmlTag tag) { String tagName = tag.getName(); if (tag instanceof HtmlTag) tagName = tagName.toLowerCase(); Language language = tag.getLanguage(); return ourTagsWithEmptyEndsNotAllowed.contains(tagName) && language != XMLLanguage.INSTANCE || language == HTMLLanguage.INSTANCE && !HtmlUtil.isSingleHtmlTagL(tagName) && tagName.indexOf(':') == -1; }
@Override public PsiElement getChangeHighlightingDirtyScopeFor(@NotNull PsiElement changedElement) { // rehighlight everything when inspection suppress comment changed if (changedElement.getLanguage() instanceof XMLLanguage && changedElement instanceof PsiComment && changedElement.getText().contains(DefaultXmlSuppressionProvider.SUPPRESS_MARK)) { return changedElement.getContainingFile(); } return null; }
@Override protected boolean isInsideCodeBlock(PsiElement element) { if (element instanceof PsiFileSystemItem) { return false; } if (element == null || element.getParent() == null) return true; final boolean isXml = element.getLanguage() instanceof XMLLanguage; // any xml element isn't inside a "code block" // cause we display even attributes and tag values in structure view return !isXml; }
protected void doAddForChildren(final XmlElement tag, final List<FoldingDescriptor> foldings, final Document document) { final PsiElement[] children = tag.getChildren(); for (PsiElement child : children) { ProgressManager.checkCanceled(); if (child instanceof XmlTag || child instanceof XmlConditionalSection) { addElementsToFold(foldings, (XmlElement)child, document); } else if (child instanceof XmlComment) { addToFold(foldings, child, document); } else if (child instanceof XmlText || child instanceof XmlProlog) { final PsiElement[] grandChildren = child.getChildren(); for (PsiElement grandChild : grandChildren) { ProgressManager.checkCanceled(); if (grandChild instanceof XmlComment) { addToFold(foldings, grandChild, document); } } } else if(child instanceof XmlAttribute && isAttributeShouldBeFolded((XmlAttribute)child)) { addToFold(foldings, child, document); } else { final Language language = child.getLanguage(); if (!(language instanceof XMLLanguage) && language != Language.ANY) { final FoldingBuilder foldingBuilder = LanguageFolding.INSTANCE.forLanguage(language); if (foldingBuilder != null) { final FoldingDescriptor[] foldingDescriptors = foldingBuilder.buildFoldRegions(child.getNode(), document); ContainerUtil.addAll(foldings, foldingDescriptors); } } } } }
@Override public void advance() { final IElementType tokenType = myDelegate.getTokenType(); if (tokenType == XmlTokenType.XML_COMMENT_CHARACTERS) { scanWordsInToken(UsageSearchContext.IN_COMMENTS, false, false); advanceTodoItemCountsInToken(); } else if (tokenType == XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN || tokenType == XmlTokenType.XML_NAME || tokenType == XmlTokenType.XML_TAG_NAME ) { scanWordsInToken(UsageSearchContext.IN_PLAIN_TEXT | UsageSearchContext.IN_FOREIGN_LANGUAGES, tokenType == XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN, false); } else if (tokenType.getLanguage() != XMLLanguage.INSTANCE && tokenType.getLanguage() != Language.ANY ) { boolean inComments = CacheUtil.isInComments(tokenType); scanWordsInToken((inComments)?UsageSearchContext.IN_COMMENTS:UsageSearchContext.IN_PLAIN_TEXT | UsageSearchContext.IN_FOREIGN_LANGUAGES, true, false); if (inComments) advanceTodoItemCountsInToken(); } else if (!XmlFilterLexer.ourNoWordsTokenSet.contains(tokenType)) { scanWordsInToken(UsageSearchContext.IN_PLAIN_TEXT, false, false); } myDelegate.advance(); }
@Override protected void setUp() throws Exception { super.setUp(); addExplicitExtension(LanguageParserDefinitions.INSTANCE, XMLLanguage.INSTANCE, new XMLParserDefinition()); addExplicitExtension(LanguageParserDefinitions.INSTANCE, DTDLanguage.INSTANCE, new DTDParserDefinition()); addExplicitExtension(LanguageASTFactory.INSTANCE, XMLLanguage.INSTANCE, new XmlASTFactory()); addExplicitExtension(LanguageASTFactory.INSTANCE, DTDLanguage.INSTANCE, new XmlASTFactory()); registerExtensionPoint(StartTagEndTokenProvider.EP_NAME, StartTagEndTokenProvider.class); }
public void _testLexerPerformance2() throws Exception { final String text = loadFile("performance2.xml"); XmlLexer lexer = new XmlLexer(); doLex(lexer, text); final FilterLexer filterLexer = new FilterLexer(new XmlLexer(), new FilterLexer.SetFilter( LanguageParserDefinitions.INSTANCE.forLanguage(XMLLanguage.INSTANCE) .getWhitespaceTokens())); doLex(filterLexer, text); doLex(lexer, text); for (int i = 0; i < 20; i++) { doLex(filterLexer, text); } }
@Override public Result beforeCharTyped(final char c, final Project project, final Editor editor, final PsiFile editedFile, final FileType fileType) { if (c == '/' && XmlGtTypedHandler.fileContainsXmlLanguage(editedFile)) { PsiDocumentManager.getInstance(project).commitAllDocuments(); PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument()); final int offset = editor.getCaretModel().getOffset(); if (file == null) return Result.CONTINUE; FileViewProvider provider = file.getViewProvider(); PsiElement element = provider.findElementAt(offset, XMLLanguage.class); if (element instanceof XmlToken) { final IElementType tokenType = ((XmlToken)element).getTokenType(); if (tokenType == XmlTokenType.XML_EMPTY_ELEMENT_END && offset == element.getTextOffset() ) { editor.getCaretModel().moveToOffset(offset + 1); editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE); return Result.STOP; } else if (tokenType == XmlTokenType.XML_TAG_END && offset == element.getTextOffset() ) { final ASTNode parentNode = element.getParent().getNode(); final ASTNode child = XmlChildRole.CLOSING_TAG_START_FINDER.findChild(parentNode); if (child != null && offset + 1 == child.getTextRange().getStartOffset()) { editor.getDocument().replaceString(offset + 1, parentNode.getTextRange().getEndOffset(),""); } } } } return Result.CONTINUE; }
static boolean fileContainsXmlLanguage(PsiFile editedFile) { if (editedFile.getLanguage() instanceof XMLLanguage) { return true; } if (HtmlUtil.supportsXmlTypedHandlers(editedFile)) { return true; } final FileViewProvider provider = editedFile.getViewProvider(); if (provider.getBaseLanguage() instanceof XMLLanguage) { return true; } return provider instanceof TemplateLanguageFileViewProvider && ((TemplateLanguageFileViewProvider)provider).getTemplateDataLanguage() instanceof XMLLanguage; }
static boolean isApplicableFile(PsiFile file) { if (file == null) return false; for (Language language : file.getViewProvider().getLanguages()) { if (language.isKindOf(XMLLanguage.INSTANCE) || "JavaScript".equals(language.getID())) return true; } return false; }
@Override protected void initTabs(CodeStyleSettings settings) { addIndentOptionsTab(settings); addTab(new CodeStyleXmlPanel(settings)); addTab(new XmlArrangementPanel(settings)); for (CodeStyleSettingsProvider provider : Extensions.getExtensions(CodeStyleSettingsProvider.EXTENSION_POINT_NAME)) { if (provider.getLanguage() == XMLLanguage.INSTANCE && !provider.hasSettingsPage()) { createTab(provider); } } }
@Override public void createFileTypes(@NotNull final FileTypeConsumer consumer) { consumer.consume(HtmlFileType.INSTANCE, "html;htm;sht;shtm;shtml"); consumer.consume(XHtmlFileType.INSTANCE, "xhtml"); consumer.consume(DTDFileType.INSTANCE, "dtd;ent;mod;elt"); consumer.consume(XmlFileType.INSTANCE, "xml;xsd;tld;xsl;jnlp;wsdl;jhm;ant;xul;xslt;rng;fxml;jrxml"); TypedHandler.registerBaseLanguageQuoteHandler(XMLLanguage.class, TypedHandler.getQuoteHandlerForType(XmlFileType.INSTANCE)); }
@Override @NotNull public String getElementInfo(@NotNull final PsiElement e) { final XmlTag tag = (XmlTag)e; final StringBuilder sb = new StringBuilder(); sb.append(tag.getName()); final boolean addHtmlInfo = e.getContainingFile().getLanguage() != XMLLanguage.INSTANCE; if (addHtmlInfo) { final String id_value = tag.getAttributeValue(HtmlUtil.ID_ATTRIBUTE_NAME); if (null != id_value) { sb.append("#").append(id_value); } final String class_value = tag.getAttributeValue(HtmlUtil.CLASS_ATTRIBUTE_NAME); if (null != class_value) { final StringTokenizer tokenizer = new StringTokenizer(class_value, " "); while (tokenizer.hasMoreTokens()) { sb.append(".").append(tokenizer.nextToken()); } } } return sb.toString(); }