@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; }
@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; }
@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; }
public static void addHtmlSpecificCompletions(final XmlElementDescriptor descriptor, final XmlTag element, final List<XmlElementDescriptor> variants) { // add html block completions for tags with optional ends! String name = descriptor.getName(element); if (name != null && isOptionalEndForHtmlTag(name)) { PsiElement parent = element.getParent(); if (parent != null) { // we need grand parent since completion already uses parent's descriptor parent = parent.getParent(); } if (parent instanceof HtmlTag) { final XmlElementDescriptor parentDescriptor = ((HtmlTag)parent).getDescriptor(); if (parentDescriptor != descriptor && parentDescriptor != null) { for (final XmlElementDescriptor elementsDescriptor : parentDescriptor.getElementsDescriptors((XmlTag)parent)) { if (isHtmlBlockTag(elementsDescriptor.getName())) { variants.add(elementsDescriptor); } } } } else if (parent instanceof HtmlDocumentImpl) { final XmlNSDescriptor nsDescriptor = descriptor.getNSDescriptor(); for (XmlElementDescriptor elementDescriptor : nsDescriptor.getRootElementsDescriptors((XmlDocument)parent)) { if (isHtmlBlockTag(elementDescriptor.getName()) && !variants.contains(elementDescriptor)) { variants.add(elementDescriptor); } } } } }
public static boolean isHtmlTagContainingFile(PsiElement element) { if (element == null) { return false; } final PsiFile containingFile = element.getContainingFile(); if (containingFile != null) { final XmlTag tag = PsiTreeUtil.getParentOfType(element, XmlTag.class, false); if (tag instanceof HtmlTag) { return true; } final XmlDocument document = PsiTreeUtil.getParentOfType(element, XmlDocument.class, false); if (document instanceof HtmlDocumentImpl) { return true; } final FileViewProvider provider = containingFile.getViewProvider(); Language language; if (provider instanceof TemplateLanguageFileViewProvider) { language = ((TemplateLanguageFileViewProvider)provider).getTemplateDataLanguage(); } else { language = provider.getBaseLanguage(); } return language == XHTMLLanguage.INSTANCE; } return false; }
public static boolean isHtmlTagContainingFile(PsiElement element) { if(element == null) { return false; } final PsiFile containingFile = element.getContainingFile(); if(containingFile != null) { final XmlTag tag = PsiTreeUtil.getParentOfType(element, XmlTag.class, false); if(tag instanceof HtmlTag) { return true; } final XmlDocument document = PsiTreeUtil.getParentOfType(element, XmlDocument.class, false); if(document instanceof HtmlDocumentImpl) { return true; } final FileViewProvider provider = containingFile.getViewProvider(); Language language; if(provider instanceof TemplateLanguageFileViewProvider) { language = ((TemplateLanguageFileViewProvider) provider).getTemplateDataLanguage(); } else { language = provider.getBaseLanguage(); } return language == XHTMLLanguage.INSTANCE; } return false; }
@Override public CompositeElement createComposite(final IElementType type) { if (type == XML_TAG) { return new XmlTagImpl(); } else if (type == XML_CONDITIONAL_SECTION) { return new XmlConditionalSectionImpl(); } else if (type == HTML_TAG) { return new HtmlTagImpl(); } else if (type == XML_TEXT) { return new XmlTextImpl(); } else if (type == XML_PROCESSING_INSTRUCTION) { return new XmlProcessingInstructionImpl(); } else if (type == XML_DOCUMENT) { return new XmlDocumentImpl(); } else if (type == HTML_DOCUMENT) { return new HtmlDocumentImpl(); } else if (type == XML_PROLOG) { return new XmlPrologImpl(); } else if (type == XML_DECL) { return new XmlDeclImpl(); } else if (type == XML_ATTRIBUTE) { return new XmlAttributeImpl(); } else if (type == XML_ATTRIBUTE_VALUE) { return new XmlAttributeValueImpl(); } else if (type == XML_COMMENT) { return new XmlCommentImpl(); } else if (type == XML_DOCTYPE) { return new XmlDoctypeImpl(); } else if (type == XML_MARKUP_DECL) { return new XmlMarkupDeclImpl(); } else if (type == XML_ELEMENT_DECL) { return new XmlElementDeclImpl(); } else if (type == XML_ENTITY_DECL) { return new XmlEntityDeclImpl(); } else if (type == XML_ATTLIST_DECL) { return new XmlAttlistDeclImpl(); } else if (type == XML_ATTRIBUTE_DECL) { return new XmlAttributeDeclImpl(); } else if (type == XML_NOTATION_DECL) { return new XmlNotationDeclImpl(); } else if (type == XML_ELEMENT_CONTENT_SPEC) { return new XmlElementContentSpecImpl(); } else if (type == XML_ELEMENT_CONTENT_GROUP) { return new XmlElementContentGroupImpl(); } else if (type == XML_ENTITY_REF) { return new XmlEntityRefImpl(); } else if (type == XML_ENUMERATED_TYPE) { return new XmlEnumeratedTypeImpl(); } else if (type == XML_CDATA) { return new CompositePsiElement(XML_CDATA) {}; } else if (type instanceof ITemplateDataElementType) { return new XmlFileElement(type, null); } return null; }
public CompositeElement createComposite(final IElementType type) { if (type == XML_TAG) { return new XmlTagImpl(); } else if (type == XML_CONDITIONAL_SECTION) { return new XmlConditionalSectionImpl(); } else if (type == HTML_TAG) { return new HtmlTagImpl(); } else if (type == XML_TEXT) { return new XmlTextImpl(); } else if (type == XML_PROCESSING_INSTRUCTION) { return new XmlProcessingInstructionImpl(); } else if (type == XML_DOCUMENT) { return new XmlDocumentImpl(); } else if (type == HTML_DOCUMENT) { return new HtmlDocumentImpl(); } else if (type == XML_PROLOG) { return new XmlPrologImpl(); } else if (type == XML_DECL) { return new XmlDeclImpl(); } else if (type == XML_ATTRIBUTE) { return new XmlAttributeImpl(); } else if (type == XML_ATTRIBUTE_VALUE) { return new XmlAttributeValueImpl(); } else if (type == XML_COMMENT) { return new XmlCommentImpl(); } else if (type == XML_DOCTYPE) { return new XmlDoctypeImpl(); } else if (type == XML_MARKUP_DECL) { return new XmlMarkupDeclImpl(); } else if (type == XML_ELEMENT_DECL) { return new XmlElementDeclImpl(); } else if (type == XML_ENTITY_DECL) { return new XmlEntityDeclImpl(); } else if (type == XML_ATTLIST_DECL) { return new XmlAttlistDeclImpl(); } else if (type == XML_ATTRIBUTE_DECL) { return new XmlAttributeDeclImpl(); } else if (type == XML_NOTATION_DECL) { return new XmlNotationDeclImpl(); } else if (type == XML_ELEMENT_CONTENT_SPEC) { return new XmlElementContentSpecImpl(); } else if (type == XML_ELEMENT_CONTENT_GROUP) { return new XmlElementContentGroupImpl(); } else if (type == XML_ENTITY_REF) { return new XmlEntityRefImpl(); } else if (type == XML_ENUMERATED_TYPE) { return new XmlEnumeratedTypeImpl(); } else if (type == XML_CDATA) { return new CompositePsiElement(XML_CDATA) {}; } else if (type instanceof ITemplateDataElementType) { return new XmlFileElement(type, null); } return null; }
public static void addHtmlSpecificCompletions(final XmlElementDescriptor descriptor, final XmlTag element, final List<XmlElementDescriptor> variants) { // add html block completions for tags with optional ends! String name = descriptor.getName(element); if(name != null && isOptionalEndForHtmlTag(name)) { PsiElement parent = element.getParent(); if(parent != null) { // we need grand parent since completion already uses parent's descriptor parent = parent.getParent(); } if(parent instanceof HtmlTag) { final XmlElementDescriptor parentDescriptor = ((HtmlTag) parent).getDescriptor(); if(parentDescriptor != descriptor && parentDescriptor != null) { for(final XmlElementDescriptor elementsDescriptor : parentDescriptor.getElementsDescriptors((XmlTag) parent)) { if(isHtmlBlockTag(elementsDescriptor.getName())) { variants.add(elementsDescriptor); } } } } else if(parent instanceof HtmlDocumentImpl) { final XmlNSDescriptor nsDescriptor = descriptor.getNSDescriptor(); for(XmlElementDescriptor elementDescriptor : nsDescriptor.getRootElementsDescriptors((XmlDocument) parent)) { if(isHtmlBlockTag(elementDescriptor.getName()) && !variants.contains(elementDescriptor)) { variants.add(elementDescriptor); } } } } }
@NotNull @Override public CompositeElement createComposite(IElementType type) { if (type == XML_TAG) { return new XmlTagImpl(); } else if (type == XML_CONDITIONAL_SECTION) { return new XmlConditionalSectionImpl(); } else if (type == HTML_TAG) { return new HtmlTagImpl(); } else if (type == XML_TEXT) { return new XmlTextImpl(); } else if (type == XML_PROCESSING_INSTRUCTION) { return new XmlProcessingInstructionImpl(); } else if (type == XML_DOCUMENT) { return new XmlDocumentImpl(); } else if (type == HTML_DOCUMENT) { return new HtmlDocumentImpl(); } else if (type == XML_PROLOG) { return new XmlPrologImpl(); } else if (type == XML_DECL) { return new XmlDeclImpl(); } else if (type == XML_ATTRIBUTE) { return new XmlAttributeImpl(); } else if (type == XML_ATTRIBUTE_VALUE) { return new XmlAttributeValueImpl(); } else if (type == XML_COMMENT) { return new XmlCommentImpl(); } else if (type == XML_DOCTYPE) { return new XmlDoctypeImpl(); } else if (type == XML_MARKUP_DECL) { return new XmlMarkupDeclImpl(); } else if (type == XML_ELEMENT_DECL) { return new XmlElementDeclImpl(); } else if (type == XML_ENTITY_DECL) { return new XmlEntityDeclImpl(); } else if (type == XML_ATTLIST_DECL) { return new XmlAttlistDeclImpl(); } else if (type == XML_ATTRIBUTE_DECL) { return new XmlAttributeDeclImpl(); } else if (type == XML_NOTATION_DECL) { return new XmlNotationDeclImpl(); } else if (type == XML_ELEMENT_CONTENT_SPEC) { return new XmlElementContentSpecImpl(); } else if (type == XML_ELEMENT_CONTENT_GROUP) { return new XmlElementContentGroupImpl(); } else if (type == XML_ENTITY_REF) { return new XmlEntityRefImpl(); } else if (type == XML_ENUMERATED_TYPE) { return new XmlEnumeratedTypeImpl(); } else if (type == XML_CDATA) { return new CompositePsiElement(XML_CDATA) {}; } else if (type instanceof TemplateDataElementType) { return new XmlFileElement(type, null); } return null; }