com.intellij.lang.html.HTMLLanguage Java Examples
The following examples show how to use
com.intellij.lang.html.HTMLLanguage.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HtmlNSNamespaceProvider.java From idea-php-typo3-plugin with MIT License | 6 votes |
private synchronized Collection<FluidNamespace> doProvide(@NotNull PsiElement element) { FileViewProvider viewProvider = element.getContainingFile().getViewProvider(); if (!viewProvider.getLanguages().contains(HTMLLanguage.INSTANCE)) { return ContainerUtil.emptyList(); } PsiFile htmlFile = viewProvider.getPsi(HTMLLanguage.INSTANCE); CachedValue userData = htmlFile.getUserData(HTML_NS_KEY); if (userData != null) { return (Collection<FluidNamespace>) userData.getValue(); } CachedValue<Collection<FluidNamespace>> cachedValue = CachedValuesManager.getManager(element.getProject()).createCachedValue(() -> { HtmlNSVisitor visitor = new HtmlNSVisitor(); htmlFile.accept(visitor); return CachedValueProvider.Result.createSingleDependency(visitor.namespaces, htmlFile); }, false); htmlFile.putUserData(HTML_NS_KEY, cachedValue); return cachedValue.getValue(); }
Example #2
Source File: InlineNSNamespaceProvider.java From idea-php-typo3-plugin with MIT License | 6 votes |
@NotNull @Override public Collection<FluidNamespace> provideForElement(@NotNull PsiElement element) { FileViewProvider viewProvider = element.getContainingFile().getViewProvider(); if (!viewProvider.getLanguages().contains(HTMLLanguage.INSTANCE)) { return ContainerUtil.emptyList(); } PsiFile htmlFile = viewProvider.getPsi(FluidLanguage.INSTANCE); if (htmlFile == null) { return ContainerUtil.emptyList(); } FluidInlineNsVisitor visitor = new FluidInlineNsVisitor(); htmlFile.accept(visitor); return visitor.namespaces; }
Example #3
Source File: RTErrorFilter.java From react-templates-plugin with MIT License | 6 votes |
@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; }
Example #4
Source File: RTErrorFilter.java From react-templates-plugin with MIT License | 6 votes |
@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; }
Example #5
Source File: InTemplateDeclarationVariableProvider.java From idea-php-typo3-plugin with MIT License | 5 votes |
private Map<String, FluidVariable> collectXmlViewHelperSetVariables(@NotNull PsiElement psiElement) { if (!containsLanguage(HTMLLanguage.INSTANCE, psiElement)) { return new THashMap<>(); } PsiFile psi = extractLanguagePsiForElement(HTMLLanguage.INSTANCE, psiElement); if (psi == null) { return new THashMap<>(); } XmlVariableVisitor visitor = new XmlVariableVisitor(); psi.accept(visitor); return visitor.variables; }
Example #6
Source File: InTemplateDeclarationVariableProvider.java From idea-php-typo3-plugin with MIT License | 5 votes |
private Map<String, FluidVariable> collectXmlMapViewHelperSetVariables(PsiElement psiElement) { if (!containsLanguage(HTMLLanguage.INSTANCE, psiElement)) { return new THashMap<>(); } PsiFile psi = extractLanguagePsiForElement(HTMLLanguage.INSTANCE, psiElement); if (psi == null) { return new THashMap<>(); } XmlFAliasVisitor visitor = new XmlFAliasVisitor(); psi.accept(visitor); return visitor.variables; }
Example #7
Source File: ProfilerUtil.java From idea-php-symfony2-plugin with MIT License | 5 votes |
/** * "_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; }
Example #8
Source File: LatteFileViewProvider.java From intellij-latte with MIT License | 5 votes |
@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; } }
Example #9
Source File: ProfilerUtil.java From idea-php-symfony2-plugin with MIT License | 4 votes |
/** * ["foo/foo.html.twig": 1] * * <tr> * <td>@Twig/Exception/traces_text.html.twig</td> * <td class="font-normal">1</td> * </tr> */ public static Map<String, Integer> getRenderedElementTwigTemplates(@NotNull Project project, @NotNull String html) { HtmlFileImpl htmlFile = (HtmlFileImpl) PsiFileFactory.getInstance(project).createFileFromText(HTMLLanguage.INSTANCE, html); final XmlTag[] xmlTag = new XmlTag[1]; PsiTreeUtil.processElements(htmlFile, psiElement -> { if(!(psiElement instanceof XmlTag) || !"h2".equals(((XmlTag) psiElement).getName())) { return true; } XmlTagValue keyTag = ((XmlTag) psiElement).getValue(); String contents = StringUtils.trim(keyTag.getText()); if(!"Rendered Templates".equalsIgnoreCase(contents)) { return true; } xmlTag[0] = (XmlTag) psiElement; return true; }); if(xmlTag[0] == null) { return Collections.emptyMap(); } XmlTag tableTag = PsiTreeUtil.getNextSiblingOfType(xmlTag[0], XmlTag.class); if(tableTag == null || !"table".equals(tableTag.getName())) { return Collections.emptyMap(); } XmlTag tbody = tableTag.findFirstSubTag("tbody"); if(tbody == null) { return Collections.emptyMap(); } Map<String, Integer> templates = new HashMap<>(); for (XmlTag tag : PsiTreeUtil.getChildrenOfTypeAsList(tbody, XmlTag.class)) { if(!"tr".equals(tag.getName())) { continue; } XmlTag[] tds = tag.findSubTags("td"); if(tds.length < 2) { continue; } String template = stripHtmlTags(StringUtils.trim(tds[0].getValue().getText())); if(StringUtils.isBlank(template)) { continue; } Integer count; try { count = Integer.valueOf(stripHtmlTags(StringUtils.trim(tds[1].getValue().getText()))); } catch (NumberFormatException e) { count = 0; } templates.put(template, count); } return templates; }
Example #10
Source File: LatteFileViewProvider.java From intellij-latte with MIT License | 4 votes |
@NotNull @Override public Language getTemplateDataLanguage() { return isXml() ? XMLLanguage.INSTANCE : HTMLLanguage.INSTANCE; }
Example #11
Source File: RTFileType.java From react-templates-plugin with MIT License | 4 votes |
private RTFileType() { super(HTMLLanguage.INSTANCE); }
Example #12
Source File: ISMLFileType.java From intellij-demandware with MIT License | 4 votes |
private ISMLFileType() { super(HTMLLanguage.INSTANCE); }
Example #13
Source File: VueFileType.java From vue-for-idea with BSD 3-Clause "New" or "Revised" License | 4 votes |
protected VueFileType() { super(HTMLLanguage.INSTANCE); }
Example #14
Source File: RTFileType.java From react-templates-plugin with MIT License | 4 votes |
private RTFileType() { super(HTMLLanguage.INSTANCE); }
Example #15
Source File: WeexFileType.java From weex-language-support with MIT License | 4 votes |
private WeexFileType() { super(HTMLLanguage.INSTANCE); }
Example #16
Source File: SoyLanguageCodeStyleSettingsProvider.java From bamboo-soy with Apache License 2.0 | 4 votes |
@Override public CommonCodeStyleSettings getDefaultCommonSettings() { return XmlLanguageCodeStyleSettingsProvider.getDefaultCommonSettings(HTMLLanguage.INSTANCE); }
Example #17
Source File: FluidConfig.java From idea-php-typo3-plugin with MIT License | 4 votes |
@NotNull public static Language getCommenterLanguage() { final Language id = Language.findLanguageByID(getStringPropertyValue(COMMENTER_LANGUAGE_ID)); return id == null ? HTMLLanguage.INSTANCE : id; }