Java 类com.intellij.lang.html.HTMLLanguage 实例源码

项目:RtplPlugin    文件:BaseHtmlLexer.java   
@Nullable
protected static HtmlScriptContentProvider findScriptContentProvider(@Nullable String mimeType) {
  if (StringUtil.isEmpty(mimeType)) {
    return ourDefaultLanguage != null ? LanguageHtmlScriptContentProvider.getScriptContentProvider(ourDefaultLanguage) : null;
  }
  Collection<Language> instancesByMimeType = Language.findInstancesByMimeType(mimeType.trim());
  if (instancesByMimeType.isEmpty() && mimeType.contains("template")) {
    instancesByMimeType = Collections.<Language>singletonList(HTMLLanguage.INSTANCE);
  }
  for (Language language : instancesByMimeType) {
    HtmlScriptContentProvider scriptContentProvider = LanguageHtmlScriptContentProvider.getScriptContentProvider(language);
    if (scriptContentProvider != null) {
      return scriptContentProvider;
    }
  }
  return null;
}
项目:intellij-ce-playground    文件:HtmlClosingTagErrorFilter.java   
@Override
public boolean shouldHighlightErrorElement(@NotNull final PsiErrorElement element) {
  final PsiFile psiFile = element.getContainingFile();
  if (psiFile == null || psiFile.getViewProvider().getBaseLanguage() != HTMLLanguage.INSTANCE
                          && HTMLLanguage.INSTANCE != element.getLanguage()) return true;

  final PsiElement[] children = element.getChildren();
  if (children.length > 0) {
    if (children[0] instanceof XmlToken && XmlTokenType.XML_END_TAG_START == ((XmlToken)children[0]).getTokenType()) {
      if (XmlErrorMessages.message("xml.parsing.closing.tag.matches.nothing").equals(element.getErrorDescription())) {
        return false;
      }
    }
  }

  return true;
}
项目:intellij-ce-playground    文件:XmlUtil.java   
@Nullable
public static String getDtdUri(XmlDoctype doctype) {
  if (doctype != null) {
    String docType = doctype.getDtdUri();
    if (docType == null) {
      final String publicId = doctype.getPublicId();
      if (PsiTreeUtil.getParentOfType(doctype, XmlDocument.class) instanceof HtmlDocumentImpl &&
          publicId != null && publicId.contains("-//W3C//DTD ")) {
        return guessDtdByPublicId(publicId);
      }
      else if (HtmlUtil.isHtml5Doctype(doctype)) {
        docType = doctype.getLanguage() instanceof HTMLLanguage
                  ? Html5SchemaProvider.getHtml5SchemaLocation()
                  : Html5SchemaProvider.getXhtml5SchemaLocation();
      }
    }
    return docType;
  }
  return null;
}
项目:intellij-ce-playground    文件:BaseHtmlLexer.java   
@Nullable
protected static HtmlScriptContentProvider findScriptContentProvider(@Nullable String mimeType) {
  if (StringUtil.isEmpty(mimeType)) {
    return ourDefaultLanguage != null ? LanguageHtmlScriptContentProvider.getScriptContentProvider(ourDefaultLanguage) : null;
  }
  Collection<Language> instancesByMimeType = Language.findInstancesByMimeType(mimeType.trim());
  if (instancesByMimeType.isEmpty() && mimeType.contains("template")) {
    instancesByMimeType = Collections.<Language>singletonList(HTMLLanguage.INSTANCE);
  }
  for (Language language : instancesByMimeType) {
    HtmlScriptContentProvider scriptContentProvider = LanguageHtmlScriptContentProvider.getScriptContentProvider(language);
    if (scriptContentProvider != null) {
      return scriptContentProvider;
    }
  }
  return null;
}
项目:intellij-ce-playground    文件:XmlParsingTest.java   
public void testCustomMimeType() throws Exception {
  final Language language = new MyLanguage();
  addExplicitExtension(LanguageHtmlScriptContentProvider.INSTANCE, language, new HtmlScriptContentProvider() {
    @Override
    public IElementType getScriptElementType() {
      return new IElementType("MyElementType", language);
    }

    @Nullable
    @Override
    public Lexer getHighlightingLexer() {
      return null;
    }
  });
  addExplicitExtension(LanguageParserDefinitions.INSTANCE, HTMLLanguage.INSTANCE, new HTMLParserDefinition());
  addExplicitExtension(LanguageASTFactory.INSTANCE, HTMLLanguage.INSTANCE, new XmlASTFactory());
  registerExtensionPoint(new ExtensionPointName<HtmlEmbeddedTokenTypesProvider>("com.intellij.html.embeddedTokenTypesProvider"),
                         HtmlEmbeddedTokenTypesProvider.class);
  myLanguage = HTMLLanguage.INSTANCE;
  doTest("<script type=\"application/custom\">Custom Script</script>", "test.html");
}
项目:intellij-ce-playground    文件:TemplateToken.java   
@NotNull
private static XmlFile parseXmlFileInTemplate(@NotNull TemplateImpl template, @NotNull CustomTemplateCallback callback,
                                              @NotNull Map<String, String> attributes) {
  XmlTag dummyRootTag = null;
  String templateString = template.getString();
  final PsiFileFactory psiFileFactory = PsiFileFactory.getInstance(callback.getProject());
  if (!containsAttrsVar(template)) {
    XmlFile dummyFile = (XmlFile)psiFileFactory.createFileFromText("dummy.html", HTMLLanguage.INSTANCE, templateString, false, true);
    dummyRootTag = dummyFile.getRootTag();
    if (dummyRootTag != null) {
      addMissingAttributes(dummyRootTag, attributes);
    }
  }

  templateString = dummyRootTag != null ? dummyRootTag.getContainingFile().getText() : templateString;
  XmlFile xmlFile =
    (XmlFile)psiFileFactory.createFileFromText("dummy.xml", StdFileTypes.XML, templateString, LocalTimeCounter.currentTime(), true);
  VirtualFile vFile = xmlFile.getVirtualFile();
  if (vFile != null) {
    vFile.putUserData(UndoConstants.DONT_RECORD_UNDO, Boolean.TRUE);
  }
  return xmlFile;
}
项目:react-templates-plugin    文件:RTErrorFilter.java   
@Override
    public boolean shouldHighlightErrorElement(@NotNull PsiErrorElement error) {
        final Project project = error.getProject();
        final Language language = error.getLanguage();
//        if ("CSS".equals(language.getID()) && PsiTreeUtil.getParentOfType(error, XmlAttribute.class) != null &&
//                AngularIndexUtil.hasAngularJS(project)) {
//            final PsiFile file = error.getContainingFile();
//
//            PsiErrorElement nextError = error;
//            while (nextError != null) {
//                if (hasAngularInjectionAt(project, file, nextError.getTextOffset())) return false;
//                nextError = PsiTreeUtil.getNextSiblingOfType(nextError, PsiErrorElement.class);
//            }
//        }
        if (HTMLLanguage.INSTANCE.is(language) && error.getErrorDescription().endsWith("not closed")) {
            System.out.println(error.getErrorDescription());
            final PsiElement parent = error.getParent();
            final XmlElementDescriptor descriptor = parent instanceof XmlTag ? ((XmlTag) parent).getDescriptor() : null;
            return !(descriptor instanceof RTRequireTagDescriptor);
        }
        return true;
    }
项目:react-templates-plugin    文件:RTErrorFilter.java   
@Override
    public boolean shouldHighlightErrorElement(@NotNull PsiErrorElement error) {
        final Project project = error.getProject();
        final Language language = error.getLanguage();
//        if ("CSS".equals(language.getID()) && PsiTreeUtil.getParentOfType(error, XmlAttribute.class) != null &&
//                AngularIndexUtil.hasAngularJS(project)) {
//            final PsiFile file = error.getContainingFile();
//
//            PsiErrorElement nextError = error;
//            while (nextError != null) {
//                if (hasAngularInjectionAt(project, file, nextError.getTextOffset())) return false;
//                nextError = PsiTreeUtil.getNextSiblingOfType(nextError, PsiErrorElement.class);
//            }
//        }
        if (HTMLLanguage.INSTANCE.is(language) && error.getErrorDescription().endsWith("not closed")) {
            System.out.println(error.getErrorDescription());
            final PsiElement parent = error.getParent();
            final XmlElementDescriptor descriptor = parent instanceof XmlTag ? ((XmlTag) parent).getDescriptor() : null;
            return !(descriptor instanceof RTRequireTagDescriptor);
        }
        return true;
    }
项目:tools-idea    文件:XmlUtil.java   
@Nullable
public static String getDtdUri(XmlDoctype doctype) {
  if (doctype != null) {
    String docType = doctype.getDtdUri();
    if (docType == null) {
      final String publicId = doctype.getPublicId();
      if (PsiTreeUtil.getParentOfType(doctype, XmlDocument.class) instanceof HtmlDocumentImpl &&
          publicId != null &&
          publicId.indexOf("-//W3C//DTD HTML") != -1) {
        return HTML4_LOOSE_URI;
      }
      else if (HtmlUtil.isHtml5Doctype(doctype)) {
        docType = doctype.getLanguage() instanceof HTMLLanguage
                  ? Html5SchemaProvider.getHtml5SchemaLocation()
                  : Html5SchemaProvider.getXhtml5SchemaLocation();
      }
    }
    return docType;
  }
  return null;
}
项目:tools-idea    文件:XmlParsingTest.java   
public void testCustomMimeType() throws Exception {
  final Language language = new MyLanguage();
  addExplicitExtension(LanguageHtmlScriptContentProvider.INSTANCE, language, new HtmlScriptContentProvider() {
    @Override
    public IElementType getScriptElementType() {
      return new IElementType("MyElementType", language);
    }

    @Nullable
    @Override
    public Lexer getHighlightingLexer() {
      return null;
    }
  });
  addExplicitExtension(LanguageParserDefinitions.INSTANCE, HTMLLanguage.INSTANCE, new HTMLParserDefinition());
  addExplicitExtension(LanguageASTFactory.INSTANCE, HTMLLanguage.INSTANCE, new XmlASTFactory());
  registerExtensionPoint(new ExtensionPointName<HtmlEmbeddedTokenTypesProvider>("com.intellij.html.embeddedTokenTypesProvider"),
                         HtmlEmbeddedTokenTypesProvider.class);
  myLanguage = HTMLLanguage.INSTANCE;
  doTest("<script type=\"application/custom\">Custom Script</script>", "test.html");
}
项目:tools-idea    文件:HtmlClosingTagErrorFilter.java   
public boolean shouldHighlightErrorElement(@NotNull final PsiErrorElement element) {
  final PsiFile psiFile = element.getContainingFile();
  if (psiFile == null || (psiFile.getViewProvider().getBaseLanguage() != HTMLLanguage.INSTANCE
                          && HTMLLanguage.INSTANCE != element.getLanguage())) return true;

  final PsiElement[] children = element.getChildren();
  if (children.length > 0) {
    if (children[0] instanceof XmlToken && XmlTokenType.XML_END_TAG_START == ((XmlToken)children[0]).getTokenType()) {
      if (XmlErrorMessages.message("xml.parsing.closing.tag.matches.nothing").equals(element.getErrorDescription())) {
        return false;
      }
    }
  }

  return true;
}
项目:emberjs-plugin    文件:EmberJSErrorFilter.java   
@Override
public boolean shouldHighlightErrorElement(@NotNull PsiErrorElement error) {
    final Project project = error.getProject();
    final Language language = error.getLanguage();
    if ("CSS".equals(language.getID()) && PsiTreeUtil.getParentOfType(error, XmlAttribute.class) != null &&
            EmberIndexUtil.hasEmberJS(project)) {
        final PsiFile file = error.getContainingFile();

        PsiErrorElement nextError = error;
        while (nextError != null) {
            nextError = PsiTreeUtil.getNextSiblingOfType(nextError, PsiErrorElement.class);
        }
    }
    if (HTMLLanguage.INSTANCE.is(language) && error.getErrorDescription().endsWith("not closed")) {
        final PsiElement parent = error.getParent();
        final XmlElementDescriptor descriptor = parent instanceof XmlTag ? ((XmlTag)parent).getDescriptor() : null;
        return !(descriptor instanceof EmberJSTagDescriptor);
    }
    return true;
}
项目:consulo-xml    文件:XmlUtil.java   
@Nullable
public static String getDtdUri(XmlDoctype doctype)
{
    if(doctype != null)
    {
        String docType = doctype.getDtdUri();
        if(docType == null)
        {
            final String publicId = doctype.getPublicId();
            if(PsiTreeUtil.getParentOfType(doctype, XmlDocument.class) instanceof HtmlDocumentImpl && publicId != null && publicId.contains("-//W3C//DTD "))
            {
                return guessDtdByPublicId(publicId);
            }
            else if(HtmlUtil.isHtml5Doctype(doctype))
            {
                docType = doctype.getLanguage() instanceof HTMLLanguage ? Html5SchemaProvider.getHtml5SchemaLocation() : Html5SchemaProvider.getXhtml5SchemaLocation();
            }
        }
        return docType;
    }
    return null;
}
项目:consulo-xml    文件:HtmlUtil.java   
public static boolean isHtmlTag(@NotNull XmlTag tag)
{
    if(tag.getLanguage() != HTMLLanguage.INSTANCE)
    {
        return false;
    }

    XmlDocument doc = PsiTreeUtil.getParentOfType(tag, XmlDocument.class);

    String doctype = null;
    if(doc != null)
    {
        doctype = XmlUtil.getDtdUri(doc);
    }
    doctype = doctype == null ? ExternalResourceManagerEx.getInstanceEx().getDefaultHtmlDoctype(tag.getProject()) : doctype;
    return XmlUtil.XHTML4_SCHEMA_LOCATION.equals(doctype) || !StringUtil.containsIgnoreCase(doctype, "xhtml");
}
项目:consulo-xml    文件:BaseHtmlLexer.java   
@Nullable
protected HtmlScriptContentProvider findScriptContentProvider(@Nullable String mimeType)
{
    if(StringUtil.isEmpty(mimeType))
    {
        return ourDefaultLanguage != null ? LanguageHtmlScriptContentProvider.getScriptContentProvider(ourDefaultLanguage) : null;
    }
    Collection<Language> instancesByMimeType = Language.findInstancesByMimeType(mimeType.trim());
    if(instancesByMimeType.isEmpty() && mimeType.contains("template"))
    {
        instancesByMimeType = Collections.singletonList(HTMLLanguage.INSTANCE);
    }
    for(Language language : instancesByMimeType)
    {
        HtmlScriptContentProvider scriptContentProvider = LanguageHtmlScriptContentProvider.getScriptContentProvider(language);
        if(scriptContentProvider != null)
        {
            return scriptContentProvider;
        }
    }
    return null;
}
项目:consulo-xml    文件:HtmlClosingTagErrorFilter.java   
public boolean shouldHighlightErrorElement(@NotNull final PsiErrorElement element) {
  final PsiFile psiFile = element.getContainingFile();
  if (psiFile == null || (psiFile.getViewProvider().getBaseLanguage() != HTMLLanguage.INSTANCE
                          && HTMLLanguage.INSTANCE != element.getLanguage())) return true;

  final PsiElement[] children = element.getChildren();
  if (children.length > 0) {
    if (children[0] instanceof XmlToken && XmlTokenType.XML_END_TAG_START == ((XmlToken)children[0]).getTokenType()) {
      if (XmlErrorMessages.message("xml.parsing.closing.tag.matches.nothing").equals(element.getErrorDescription())) {
        return false;
      }
    }
  }

  return true;
}
项目:consulo-apache-velocity    文件:VtlFileViewProvider.java   
@NotNull
private static Language getTemplateDataLanguageByExtention(VirtualFile virtualFile) {
    String name = virtualFile.getName();
    int index2 = name.lastIndexOf('.');
    if (index2 < 3) {
        return HTMLLanguage.INSTANCE;
    }
    int index1 = 1 + name.lastIndexOf('.', index2 - 1);
    if (index1 < 1) {
        return HTMLLanguage.INSTANCE;
    }
    String dataLanguageFileExtension = name.substring(index1, index2).toUpperCase();
    FileType fileType = FileTypeManager.getInstance().getStdFileType(dataLanguageFileExtension);
    if (fileType instanceof LanguageFileType) {
        return ((LanguageFileType) fileType).getLanguage();
    }
    return HTMLLanguage.INSTANCE;
}
项目:intellij-ce-playground    文件:CheckEmptyTagInspection.java   
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;
}
项目:intellij-ce-playground    文件:XmlCoreEnvironment.java   
public ApplicationEnvironment(CoreApplicationEnvironment appEnvironment) {
  appEnvironment.registerFileType(HtmlFileType.INSTANCE, "html;htm;sht;shtm;shtml");
  appEnvironment.registerFileType(XHtmlFileType.INSTANCE, "xhtml");
  appEnvironment.registerFileType(DTDFileType.INSTANCE, "dtd;ent;mod;elt");

  appEnvironment.registerFileType(XmlFileType.INSTANCE, "xml;xsd;tld;xsl;jnlp;wsdl;jhm;ant;xul;xslt;rng;fxml");

  SyntaxHighlighterFactory.LANGUAGE_FACTORY.addExplicitExtension(XMLLanguage.INSTANCE, new XmlSyntaxHighlighterFactory());
  SyntaxHighlighterFactory.LANGUAGE_FACTORY.addExplicitExtension(DTDLanguage.INSTANCE, new DtdSyntaxHighlighterFactory());
  SyntaxHighlighterFactory.LANGUAGE_FACTORY.addExplicitExtension(HTMLLanguage.INSTANCE, new HtmlSyntaxHighlighterFactory());
  SyntaxHighlighterFactory.LANGUAGE_FACTORY.addExplicitExtension(XHTMLLanguage.INSTANCE, new XhtmlSyntaxHighlighterFactory());

  appEnvironment.addExplicitExtension(LanguageParserDefinitions.INSTANCE, XMLLanguage.INSTANCE, new XMLParserDefinition());
  appEnvironment.addExplicitExtension(LanguageParserDefinitions.INSTANCE, DTDLanguage.INSTANCE, new DTDParserDefinition());
  appEnvironment.addExplicitExtension(LanguageParserDefinitions.INSTANCE, HTMLLanguage.INSTANCE, new HTMLParserDefinition());
  appEnvironment.addExplicitExtension(LanguageParserDefinitions.INSTANCE, XHTMLLanguage.INSTANCE, new XHTMLParserDefinition());

  appEnvironment.addExplicitExtension(IdIndexers.INSTANCE, XmlFileType.INSTANCE, new XmlIdIndexer());
  appEnvironment.addExplicitExtension(IdIndexers.INSTANCE, DTDFileType.INSTANCE, new XmlIdIndexer());
  appEnvironment.addExplicitExtension(TodoIndexers.INSTANCE, XmlFileType.INSTANCE, new XmlTodoIndexer());
  appEnvironment.addExplicitExtension(TodoIndexers.INSTANCE, DTDFileType.INSTANCE, new XmlTodoIndexer());
  appEnvironment.addExplicitExtension(TodoIndexers.INSTANCE, XHtmlFileType.INSTANCE, new XHtmlTodoIndexer());

  appEnvironment.addExtension(MetaDataContributor.EP_NAME, new XmlApplicationComponent());
  appEnvironment.addExtension(FileBasedIndexExtension.EXTENSION_POINT_NAME, new XmlNamespaceIndex());
  appEnvironment.addExtension(FileBasedIndexExtension.EXTENSION_POINT_NAME, new SchemaTypeInheritanceIndex());
  appEnvironment.addExtension(FileBasedIndexExtension.EXTENSION_POINT_NAME, new XmlTagNamesIndex());
  appEnvironment.addExtension(StandardResourceProvider.EP_NAME, new InternalResourceProvider());

  appEnvironment.registerApplicationComponent(PathMacros.class, new PathMacrosImpl());
  appEnvironment.registerApplicationService(ExternalResourceManager.class, new ExternalResourceManagerExImpl());
  appEnvironment.registerApplicationService(XmlFoldingSettings.class, new XmlFoldingSettings());
  Language[] myLanguages = new Language[]{XMLLanguage.INSTANCE, HTMLLanguage.INSTANCE, XHTMLLanguage.INSTANCE, DTDLanguage.INSTANCE};
  for (Language myLanguage : myLanguages) {
    appEnvironment.addExplicitExtension(LanguageFolding.INSTANCE, myLanguage, new XmlFoldingBuilder());
    appEnvironment.addExplicitExtension(LanguageFindUsages.INSTANCE, myLanguage, new XmlFindUsagesProvider());
    appEnvironment.addExplicitExtension(LanguageASTFactory.INSTANCE, myLanguage, new XmlASTFactory());
  }
}
项目:intellij-ce-playground    文件:HtmlUtil.java   
public static boolean isHtmlTag(@NotNull XmlTag tag) {
  if (tag.getLanguage() != HTMLLanguage.INSTANCE) return false;

  XmlDocument doc = PsiTreeUtil.getParentOfType(tag, XmlDocument.class);

  String doctype = null;
  if (doc != null) {
     doctype = XmlUtil.getDtdUri(doc);
  }
  doctype = doctype == null ? ExternalResourceManagerEx.getInstanceEx().getDefaultHtmlDoctype(tag.getProject()) : doctype;
  return XmlUtil.XHTML4_SCHEMA_LOCATION.equals(doctype) ||
         !StringUtil.containsIgnoreCase(doctype, "xhtml");
}
项目:intellij-ce-playground    文件:HtmlGotoRelatedProvider.java   
private static boolean isAvailable(@NotNull PsiFile psiFile) {
  for (PsiFile file : psiFile.getViewProvider().getAllFiles()) {
    Language language = file.getLanguage();
    if (language.isKindOf(HTMLLanguage.INSTANCE) || language.isKindOf(XHTMLLanguage.INSTANCE)) {
      return true;
    }
  }
  return false;
}
项目:intellij-ce-playground    文件:DtdReferencesProvider.java   
private static boolean canHaveAdequateFix(PsiElement element) {
  final PsiFile containingFile = element.getContainingFile();

  if (containingFile.getLanguage() == HTMLLanguage.INSTANCE ||
      containingFile.getLanguage() == XHTMLLanguage.INSTANCE ||
      containingFile.getViewProvider() instanceof TemplateLanguageFileViewProvider
    ) {
    return false;
  }
  return true;
}
项目:intellij-ce-playground    文件:Html5CustomAttributesIndex.java   
@Override
@NotNull
public Map<String, Void> map(@NotNull FileContent inputData) {
  CharSequence input = inputData.getContentAsText();
  Language language = ((LanguageFileType)inputData.getFileType()).getLanguage();
  if (language == HTMLLanguage.INSTANCE || language == XHTMLLanguage.INSTANCE) {
    final Lexer lexer = (language == HTMLLanguage.INSTANCE ? new HtmlHighlightingLexer(FileTypeManager.getInstance().getStdFileType("CSS")) : new XHtmlHighlightingLexer());
    lexer.start(input);
    Map<String, Void> result = new HashMap<String, Void>();
    IElementType tokenType = lexer.getTokenType();
    while (tokenType != null) {
      if (tokenType == XmlTokenType.XML_NAME) {
        String xmlName = input.subSequence(lexer.getTokenStart(), lexer.getTokenEnd()).toString();
        if (HtmlUtil.isCustomHtml5Attribute(xmlName)) {
          result.put(xmlName, null);
        }
      }
      else if (tokenType == XmlTokenType.XML_DOCTYPE_PUBLIC || tokenType == XmlTokenType.XML_DOCTYPE_SYSTEM) {
        // this is not an HTML5 context
        break;
      }
      lexer.advance();
      tokenType = lexer.getTokenType();
    }
    return result;
  }
  return Collections.emptyMap();
}
项目:tools-idea    文件:XmlCoreEnvironment.java   
public ApplicationEnvironment(CoreApplicationEnvironment appEnvironment) {
  appEnvironment.registerFileType(HtmlFileType.INSTANCE, "html;htm;sht;shtm;shtml");
  appEnvironment.registerFileType(XHtmlFileType.INSTANCE, "xhtml");
  appEnvironment.registerFileType(DTDFileType.INSTANCE, "dtd;ent;mod;elt");

  appEnvironment.registerFileType(XmlFileType.INSTANCE, "xml;xsd;tld;xsl;jnlp;wsdl;jhm;ant;xul;xslt;rng;fxml");

  appEnvironment.addExplicitExtension(LanguageParserDefinitions.INSTANCE, XMLLanguage.INSTANCE, new XMLParserDefinition());
  appEnvironment.addExplicitExtension(LanguageParserDefinitions.INSTANCE, DTDLanguage.INSTANCE, new DTDParserDefinition());
  appEnvironment.addExplicitExtension(LanguageParserDefinitions.INSTANCE, HTMLLanguage.INSTANCE, new HTMLParserDefinition());
  appEnvironment.addExplicitExtension(LanguageParserDefinitions.INSTANCE, XHTMLLanguage.INSTANCE, new XHTMLParserDefinition());

  XmlASTFactory astFactory = new XmlASTFactory();
  appEnvironment.addExplicitExtension(LanguageASTFactory.INSTANCE, XMLLanguage.INSTANCE, astFactory);
  appEnvironment.addExplicitExtension(LanguageASTFactory.INSTANCE, HTMLLanguage.INSTANCE, astFactory);
  appEnvironment.addExplicitExtension(LanguageASTFactory.INSTANCE, XHTMLLanguage.INSTANCE, astFactory);
  appEnvironment.addExplicitExtension(LanguageASTFactory.INSTANCE, DTDLanguage.INSTANCE, astFactory);

  appEnvironment.addExplicitExtension(IdIndexers.INSTANCE, XmlFileType.INSTANCE, new XmlIdIndexer());
  appEnvironment.addExplicitExtension(IdIndexers.INSTANCE, DTDFileType.INSTANCE, new XmlIdIndexer());

  CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), StartTagEndTokenProvider.EP_NAME, StartTagEndTokenProvider.class);
  CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), XmlSuppressionProvider.EP_NAME, XmlSuppressionProvider.class);
  CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), XmlFileNSInfoProvider.EP_NAME, XmlFileNSInfoProvider.class);
  CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), XmlSchemaProvider.EP_NAME, XmlSchemaProvider.class);
  CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), ImplicitNamespaceDescriptorProvider.EP_NAME, ImplicitNamespaceDescriptorProvider.class);
  CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), XmlElementDescriptorProvider.EP_NAME, XmlElementDescriptorProvider.class);
  CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), Html5SchemaProvider.EP_NAME, Html5SchemaProvider.class);
  CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), XmlAttributeDescriptorsProvider.EP_NAME, XmlAttributeDescriptorsProvider.class);
  CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), XmlExtension.EP_NAME, XmlExtension.class);
  CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), HtmlEmbeddedTokenTypesProvider.EXTENSION_POINT_NAME, HtmlEmbeddedTokenTypesProvider.class);
  CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), StandardResourceProvider.EP_NAME, StandardResourceProvider.class);
  CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), StandardResourceEP.EP_NAME, StandardResourceEP.class);

  appEnvironment.addExtension(MetaDataContributor.EP_NAME, new XmlApplicationComponent());
  appEnvironment.addExtension(FileBasedIndexExtension.EXTENSION_POINT_NAME, new XmlNamespaceIndex());
  appEnvironment.addExtension(StandardResourceProvider.EP_NAME, new InternalResourceProvider());

  appEnvironment.registerApplicationService(ExternalResourceManager.class, createExternalResourceManager());
}
项目:tools-idea    文件:XmlWrongClosingTagNameInspection.java   
@Override
public void annotate(final PsiElement psiElement, final AnnotationHolder holder) {
  if (psiElement instanceof XmlToken) {
    final PsiElement parent = psiElement.getParent();
    if (parent instanceof XmlTag) {
      final XmlTag tag = (XmlTag)parent;
      final XmlToken start = XmlTagUtil.getStartTagNameElement(tag);
      XmlToken endTagName = XmlTagUtil.getEndTagNameElement(tag);
      if (endTagName != null && !(tag instanceof HtmlTag) && !tag.getName().equals(endTagName.getText())) {
        registerProblem(holder, tag, start, endTagName);
      }
      else if (endTagName == null && !(tag instanceof HtmlTag && HtmlUtil.isSingleHtmlTag(tag.getName()))) {
        final PsiErrorElement errorElement = PsiTreeUtil.getChildOfType(tag, PsiErrorElement.class);
        endTagName = findEndTagName(errorElement);
        if (endTagName != null) {
          registerProblem(holder, tag, start, endTagName);
        }
      }
    }
    else if (parent instanceof PsiErrorElement) {
      if (XmlTokenType.XML_NAME == ((XmlToken)psiElement).getTokenType()) {
        final PsiFile psiFile = psiElement.getContainingFile();

        if (psiFile != null && (HTMLLanguage.INSTANCE == psiFile.getViewProvider().getBaseLanguage() || HTMLLanguage.INSTANCE == parent.getLanguage())) {
          final String message = XmlErrorMessages.message("xml.parsing.closing.tag.matches.nothing");

          if (message.equals(((PsiErrorElement)parent).getErrorDescription()) &&
              psiFile.getContext() == null
             ) {
            final Annotation annotation = holder.createWarningAnnotation(parent, message);
            annotation.registerFix(new RemoveExtraClosingTagIntentionAction());
          }
        }
      }
    }
  }
}
项目:tools-idea    文件:HtmlGotoRelatedProvider.java   
private static boolean isAvailable(@NotNull PsiFile psiFile) {
  for (PsiFile file : psiFile.getViewProvider().getAllFiles()) {
    Language language = file.getLanguage();
    if (language.isKindOf(HTMLLanguage.INSTANCE) || language.isKindOf(XHTMLLanguage.INSTANCE)) {
      return true;
    }
  }
  return false;
}
项目:tools-idea    文件:CheckEmptyTagInspection.java   
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;
}
项目:tools-idea    文件:DtdReferencesProvider.java   
private static boolean canHaveAdequateFix(PsiElement element) {
  final PsiFile containingFile = element.getContainingFile();

  if (containingFile.getLanguage() == HTMLLanguage.INSTANCE ||
      containingFile.getLanguage() == XHTMLLanguage.INSTANCE ||
      containingFile.getViewProvider() instanceof TemplateLanguageFileViewProvider
    ) {
    return false;
  }
  return true;
}
项目:tools-idea    文件:Html5CustomAttributesIndex.java   
@Override
@NotNull
public Map<String, Void> map(FileContent inputData) {
  CharSequence input = inputData.getContentAsText();
  Language language = ((LanguageFileType)inputData.getFileType()).getLanguage();
  if (language == HTMLLanguage.INSTANCE || language == XHTMLLanguage.INSTANCE) {
    final Lexer lexer = (language == HTMLLanguage.INSTANCE ? new HtmlHighlightingLexer() : new XHtmlHighlightingLexer());
    lexer.start(input);
    Map<String, Void> result = new HashMap<String, Void>();
    IElementType tokenType = lexer.getTokenType();
    while (tokenType != null) {
      if (tokenType == XmlTokenType.XML_NAME) {
        String xmlName = input.subSequence(lexer.getTokenStart(), lexer.getTokenEnd()).toString();
        if (HtmlUtil.isCustomHtml5Attribute(xmlName)) {
          result.put(xmlName, null);
        }
      }
      else if (tokenType == XmlTokenType.XML_DOCTYPE_PUBLIC || tokenType == XmlTokenType.XML_DOCTYPE_SYSTEM) {
        // this is not an HTML5 context
        break;
      }
      lexer.advance();
      tokenType = lexer.getTokenType();
    }
    return result;
  }
  return Collections.emptyMap();
}
项目:intellij-latte    文件:LatteFileViewProvider.java   
@Nullable
protected PsiFile createFile(@NotNull Language lang) {
    ParserDefinition parser = LanguageParserDefinitions.INSTANCE.forLanguage(lang);
    if (parser == null) {
        return null;
    } else if (lang == XMLLanguage.INSTANCE || lang == HTMLLanguage.INSTANCE) {
        PsiFileImpl file = (PsiFileImpl) parser.createFile(this);
        file.setContentElementType(templateDataElement);
        return file;
    } else {
        return lang == this.getBaseLanguage() ? parser.createFile(this) : null;
    }
}
项目:idea-php-symfony2-plugin    文件:ProfilerUtil.java   
/**
 * "_controller" and "_route"
 * "/_profiler/242e61?panel=request"
 *
 * <tr>
 *  <th>_route</th>
 *  <td>foo_route</td>
 * </tr>
 */
@NotNull
public static Map<String, String> getRequestAttributes(@NotNull Project project, @NotNull String html) {
    HtmlFileImpl htmlFile = (HtmlFileImpl) PsiFileFactory.getInstance(project).createFileFromText(HTMLLanguage.INSTANCE, html);

    String[] keys = new String[] {"_controller", "_route"};

    Map<String, String> map = new HashMap<>();
    PsiTreeUtil.processElements(htmlFile, psiElement -> {
        if(!(psiElement instanceof XmlTag) || !"th".equals(((XmlTag) psiElement).getName())) {
            return true;
        }

        XmlTagValue keyTag = ((XmlTag) psiElement).getValue();
        String key = StringUtils.trim(keyTag.getText());
        if(!ArrayUtils.contains(keys, key)) {
            return true;
        }

        XmlTag tdTag = PsiTreeUtil.getNextSiblingOfType(psiElement, XmlTag.class);
        if(tdTag == null || !"td".equals(tdTag.getName())) {
            return true;
        }

        XmlTagValue valueTag = tdTag.getValue();
        String value = valueTag.getText();
        if(StringUtils.isBlank(value)) {
            return true;
        }

        // Symfony 3.2 profiler debug? strip html
        map.put(key, stripHtmlTags(value));

        // exit if all item found
        return map.size() != keys.length;
    });

    return map;
}
项目:consulo-play    文件:PlayBaseTemplateFileViewProvider.java   
@Override
@NotNull
public Set<Language> getLanguages()
{
    //TODO [VISTALL] uncomment then groovy ill supported
    return new HashSet<Language>(Arrays.asList(PlayBaseTemplateLanguage.INSTANCE, HTMLLanguage.INSTANCE, GroovyFileType.GROOVY_LANGUAGE));
}
项目:consulo-play    文件:PlayBaseTemplateEditorHighlighter.java   
public PlayBaseTemplateEditorHighlighter(@NotNull EditorColorsScheme scheme, @Nullable Project project, @Nullable VirtualFile virtualFile)
{
    super(new PlayBaseTemplateSyntaxHighlighter(), scheme);

    SyntaxHighlighter htmlHighlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(HTMLLanguage.INSTANCE, project, virtualFile);
    LayerDescriptor htmlLayer = new LayerDescriptor(new TemplateDataHighlighterWrapper(htmlHighlighter), "\n");
    registerLayer(PlayBaseTemplateTokens.TEMPLATE_TEXT, htmlLayer);

    SyntaxHighlighter groovyHighlighter = new GroovySyntaxHighlighter();
    LayerDescriptor groovyLayer = new LayerDescriptor(groovyHighlighter, "\n", DefaultLanguageHighlighterColors.TEMPLATE_LANGUAGE_COLOR);

    registerLayer(PlayBaseTemplateTokens.GROOVY_EXPRESSION_OLD, groovyLayer);
}
项目:consulo-xml    文件:XmlWrongClosingTagNameInspection.java   
@Override
public void annotate(final PsiElement psiElement, final AnnotationHolder holder) {
  if (psiElement instanceof XmlToken) {
    final PsiElement parent = psiElement.getParent();
    if (parent instanceof XmlTag) {
      final XmlTag tag = (XmlTag)parent;
      final XmlToken start = XmlTagUtil.getStartTagNameElement(tag);
      XmlToken endTagName = XmlTagUtil.getEndTagNameElement(tag);
      if (endTagName != null && !(tag instanceof HtmlTag) && !tag.getName().equals(endTagName.getText())) {
        registerProblem(holder, tag, start, endTagName);
      }
      else if (endTagName == null && !(tag instanceof HtmlTag && HtmlUtil.isSingleHtmlTag(tag.getName()))) {
        final PsiErrorElement errorElement = PsiTreeUtil.getChildOfType(tag, PsiErrorElement.class);
        endTagName = findEndTagName(errorElement);
        if (endTagName != null) {
          registerProblem(holder, tag, start, endTagName);
        }
      }
    }
    else if (parent instanceof PsiErrorElement) {
      if (XmlTokenType.XML_NAME == ((XmlToken)psiElement).getTokenType()) {
        final PsiFile psiFile = psiElement.getContainingFile();

        if (psiFile != null && (HTMLLanguage.INSTANCE == psiFile.getViewProvider().getBaseLanguage() || HTMLLanguage.INSTANCE == parent.getLanguage())) {
          final String message = XmlErrorMessages.message("xml.parsing.closing.tag.matches.nothing");

          if (message.equals(((PsiErrorElement)parent).getErrorDescription()) &&
              psiFile.getContext() == null
             ) {
            final Annotation annotation = holder.createWarningAnnotation(parent, message);
            annotation.registerFix(new RemoveExtraClosingTagIntentionAction());
          }
        }
      }
    }
  }
}
项目:consulo-xml    文件:HtmlGotoRelatedProvider.java   
private static boolean isAvailable(@NotNull PsiFile psiFile) {
  for (PsiFile file : psiFile.getViewProvider().getAllFiles()) {
    Language language = file.getLanguage();
    if (language.isKindOf(HTMLLanguage.INSTANCE) || language.isKindOf(XHTMLLanguage.INSTANCE)) {
      return true;
    }
  }
  return false;
}
项目:consulo-xml    文件:CheckEmptyTagInspection.java   
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;
}
项目:consulo-xml    文件:AbstractXmlBlock.java   
protected boolean useMyFormatter(final Language myLanguage, final Language childLanguage, final PsiElement childPsi) {
  if (myLanguage == childLanguage ||
      childLanguage == HTMLLanguage.INSTANCE ||
      childLanguage == XHTMLLanguage.INSTANCE ||
      childLanguage == XMLLanguage.INSTANCE) {
    return true;
  }
  final FormattingModelBuilder childFormatter = LanguageFormatting.INSTANCE.forLanguage(childLanguage);
  return childFormatter == null ||
         childFormatter instanceof DelegatingFormattingModelBuilder &&
         ((DelegatingFormattingModelBuilder)childFormatter).dontFormatMyModel();
}
项目:consulo-xml    文件:DtdReferencesProvider.java   
private static boolean canHaveAdequateFix(PsiElement element)
{
    final PsiFile containingFile = element.getContainingFile();

    if(containingFile.getLanguage() == HTMLLanguage.INSTANCE || containingFile.getLanguage() == XHTMLLanguage.INSTANCE || containingFile.getViewProvider() instanceof
            TemplateLanguageFileViewProvider)
    {
        return false;
    }
    return true;
}
项目:consulo-xml    文件:Html5CustomAttributesIndex.java   
@Override
@NotNull
public Map<String, Void> map(FileContent inputData) {
  CharSequence input = inputData.getContentAsText();
  Language language = ((LanguageFileType)inputData.getFileType()).getLanguage();
  if (language == HTMLLanguage.INSTANCE || language == XHTMLLanguage.INSTANCE) {
    final Lexer lexer = (language == HTMLLanguage.INSTANCE ? new HtmlHighlightingLexer() : new XHtmlHighlightingLexer());
    lexer.start(input);
    Map<String, Void> result = new HashMap<String, Void>();
    IElementType tokenType = lexer.getTokenType();
    while (tokenType != null) {
      if (tokenType == XmlTokenType.XML_NAME) {
        String xmlName = input.subSequence(lexer.getTokenStart(), lexer.getTokenEnd()).toString();
        if (HtmlUtil.isCustomHtml5Attribute(xmlName)) {
          result.put(xmlName, null);
        }
      }
      else if (tokenType == XmlTokenType.XML_DOCTYPE_PUBLIC || tokenType == XmlTokenType.XML_DOCTYPE_SYSTEM) {
        // this is not an HTML5 context
        break;
      }
      lexer.advance();
      tokenType = lexer.getTokenType();
    }
    return result;
  }
  return Collections.emptyMap();
}
项目:bamboo-soy    文件:SoyLanguageCodeStyleSettingsProvider.java   
@Override
public CommonCodeStyleSettings getDefaultCommonSettings() {
  return XmlLanguageCodeStyleSettingsProvider.getDefaultCommonSettings(HTMLLanguage.INSTANCE);
}