Search in sources :

Example 6 with XMLLanguage

use of com.intellij.lang.xml.XMLLanguage in project intellij-community by JetBrains.

the class HtmlLineMarkerProvider method collectSlowLineMarkers.

@Override
public void collectSlowLineMarkers(@NotNull final List<PsiElement> elements, @NotNull final Collection<LineMarkerInfo> result) {
    Map<Language, LineMarkerProvider> localEmbeddedLanguagesLineMarkerProviders = null;
    Map<LineMarkerProvider, List<PsiElement>> embeddedLineMarkersWorkItems = null;
    for (PsiElement element : elements) {
        if (element instanceof PsiWhiteSpace)
            continue;
        final Language language = element.getLanguage();
        if (!(language instanceof XMLLanguage)) {
            if (localEmbeddedLanguagesLineMarkerProviders == null) {
                localEmbeddedLanguagesLineMarkerProviders = new THashMap<>();
            }
            final LineMarkerProvider lineMarkerProvider = getLineMarkerProviderFromLanguage(language, localEmbeddedLanguagesLineMarkerProviders);
            if (lineMarkerProvider != null) {
                if (embeddedLineMarkersWorkItems == null)
                    embeddedLineMarkersWorkItems = new THashMap<>();
                List<PsiElement> elementList = embeddedLineMarkersWorkItems.get(lineMarkerProvider);
                if (elementList == null) {
                    elementList = new ArrayList<>(5);
                    embeddedLineMarkersWorkItems.put(lineMarkerProvider, elementList);
                }
                elementList.add(element);
            }
        }
    }
    if (embeddedLineMarkersWorkItems != null) {
        for (Map.Entry<LineMarkerProvider, List<PsiElement>> entry : embeddedLineMarkersWorkItems.entrySet()) {
            entry.getKey().collectSlowLineMarkers(entry.getValue(), result);
        }
    }
}
Also used : LineMarkerProvider(com.intellij.codeInsight.daemon.LineMarkerProvider) Language(com.intellij.lang.Language) XMLLanguage(com.intellij.lang.xml.XMLLanguage) THashMap(gnu.trove.THashMap) ArrayList(java.util.ArrayList) List(java.util.List) XMLLanguage(com.intellij.lang.xml.XMLLanguage) THashMap(gnu.trove.THashMap) Map(java.util.Map) PsiElement(com.intellij.psi.PsiElement) PsiWhiteSpace(com.intellij.psi.PsiWhiteSpace)

Example 7 with XMLLanguage

use of com.intellij.lang.xml.XMLLanguage in project intellij-community by JetBrains.

the class XmlElementFactoryImpl method createTagFromText.

@Override
@NotNull
public XmlTag createTagFromText(@NotNull @NonNls CharSequence text, @NotNull Language language) throws IncorrectOperationException {
    assert language instanceof XMLLanguage : "Tag can be created only for xml language";
    FileType type = language.getAssociatedFileType();
    if (type == null)
        type = XmlFileType.INSTANCE;
    final XmlDocument document = createXmlDocument(text, "dummy." + type.getDefaultExtension(), type);
    final XmlTag tag = document.getRootTag();
    if (tag == null)
        throw new IncorrectOperationException("Incorrect tag text");
    return tag;
}
Also used : XHtmlFileType(com.intellij.ide.highlighter.XHtmlFileType) XmlFileType(com.intellij.ide.highlighter.XmlFileType) FileType(com.intellij.openapi.fileTypes.FileType) HtmlFileType(com.intellij.ide.highlighter.HtmlFileType) LanguageFileType(com.intellij.openapi.fileTypes.LanguageFileType) IncorrectOperationException(com.intellij.util.IncorrectOperationException) XMLLanguage(com.intellij.lang.xml.XMLLanguage) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

XMLLanguage (com.intellij.lang.xml.XMLLanguage)7 PsiElement (com.intellij.psi.PsiElement)5 Language (com.intellij.lang.Language)3 PsiWhiteSpace (com.intellij.psi.PsiWhiteSpace)3 ArrayList (java.util.ArrayList)2 LineMarkerProvider (com.intellij.codeInsight.daemon.LineMarkerProvider)1 HtmlFileType (com.intellij.ide.highlighter.HtmlFileType)1 XHtmlFileType (com.intellij.ide.highlighter.XHtmlFileType)1 XmlFileType (com.intellij.ide.highlighter.XmlFileType)1 ASTNode (com.intellij.lang.ASTNode)1 FileType (com.intellij.openapi.fileTypes.FileType)1 LanguageFileType (com.intellij.openapi.fileTypes.LanguageFileType)1 PsiFile (com.intellij.psi.PsiFile)1 XmlRecursiveElementVisitor (com.intellij.psi.XmlRecursiveElementVisitor)1 XmlRecursiveElementWalkingVisitor (com.intellij.psi.XmlRecursiveElementWalkingVisitor)1 FileIncludeInfo (com.intellij.psi.impl.include.FileIncludeInfo)1 OuterLanguageElement (com.intellij.psi.templateLanguages.OuterLanguageElement)1 XmlFile (com.intellij.psi.xml.XmlFile)1 XmlTag (com.intellij.psi.xml.XmlTag)1 IncorrectOperationException (com.intellij.util.IncorrectOperationException)1