• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java HtmlFileImpl类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.intellij.psi.impl.source.html.HtmlFileImpl的典型用法代码示例。如果您正苦于以下问题:Java HtmlFileImpl类的具体用法?Java HtmlFileImpl怎么用?Java HtmlFileImpl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



HtmlFileImpl类属于com.intellij.psi.impl.source.html包,在下文中一共展示了HtmlFileImpl类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: isAvailable

import com.intellij.psi.impl.source.html.HtmlFileImpl; //导入依赖的package包/类
@Override
public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement element) {
    if (!element.isWritable()) return false;
    boolean isTwigFile = GravFileTemplateUtil.isTwigTemplateFile(element.getContainingFile()) || element.getContainingFile() instanceof HtmlFileImpl;
    boolean isXmlAttribute = false;
    if (!isTwigFile) return false;
    if (element.getParent() instanceof XmlAttributeValueImpl) {
        XmlAttributeValueImpl parent0 = ((XmlAttributeValueImpl) element.getParent());
        boolean hasTwigElement = PsiTreeUtil.findChildOfType(parent0, OuterLanguageElement.class) != null;
        if (!hasTwigElement && parent0.getParent() instanceof XmlAttributeImpl) {
            XmlAttributeImpl parent1 = (XmlAttributeImpl) parent0.getParent();
            if (parent1.getName().equalsIgnoreCase("href") || parent1.getName().equalsIgnoreCase("src"))
                isXmlAttribute = true;
        }
    }
    return isXmlAttribute;
}
 
开发者ID:PioBeat,项目名称:GravSupport,代码行数:18,代码来源:ConvertTwigResource.java


示例2: findInDataContext

import com.intellij.psi.impl.source.html.HtmlFileImpl; //导入依赖的package包/类
@Nullable
@Override
public BpGraphNode findInDataContext(final DataContext dataContext) {
    final Project project = CommonDataKeys.PROJECT.getData(dataContext);
    final CommonIdeaService commonIdeaService = ServiceManager.getService(CommonIdeaService.class);
    if (!commonIdeaService.isHybrisProject(project)) {
        return null;
    }

    final VirtualFile virtualFile = CommonDataKeys.VIRTUAL_FILE.getData(dataContext);

    if (null == virtualFile) {
        return null;
    }

    if (!virtualFile.getName().endsWith("process.xml")) {
        return null;
    }

    final PsiFile psiFile = CommonDataKeys.PSI_FILE.getData(dataContext);

    if (!(psiFile instanceof XmlFile) ||
        psiFile instanceof HtmlFileImpl) { // but psiFile must not be html.
        return null;
    }

    final BpGraphService bpGraphService = ServiceManager.getService(BpGraphService.class);

    try {
        return bpGraphService.buildGraphFromXmlFile(virtualFile);
    } catch (UnmarshalException e) {
        return null;
    }
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:35,代码来源:BpDiagramElementManagerIml.java


示例3: getRequestAttributes

import com.intellij.psi.impl.source.html.HtmlFileImpl; //导入依赖的package包/类
/**
 * "_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;
}
 
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:48,代码来源:ProfilerUtil.java


示例4: isValidForFile

import com.intellij.psi.impl.source.html.HtmlFileImpl; //导入依赖的package包/类
@Override
protected boolean isValidForFile(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
    return Symfony2ProjectComponent.isEnabled(project) && (
        file instanceof TwigFile
        || (file instanceof HtmlFileImpl && file.getName().toLowerCase().endsWith(".twig"))
        || getInjectedTwigElement(file, editor) != null
    );
}
 
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:9,代码来源:TwigTranslationGeneratorAction.java


示例5: isAttributeShouldBeFolded

import com.intellij.psi.impl.source.html.HtmlFileImpl; //导入依赖的package包/类
private static boolean isAttributeShouldBeFolded(XmlAttribute child) {
  return child.getContainingFile() instanceof HtmlFileImpl &&
         HtmlUtil.STYLE_ATTRIBUTE_NAME.equalsIgnoreCase(child.getName());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:XmlCodeFoldingBuilder.java


示例6: createFile

import com.intellij.psi.impl.source.html.HtmlFileImpl; //导入依赖的package包/类
@Override
public PsiFile createFile(FileViewProvider viewProvider) {
  return new HtmlFileImpl(viewProvider);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:HTMLParserDefinition.java


示例7: isAttributeShouldBeFolded

import com.intellij.psi.impl.source.html.HtmlFileImpl; //导入依赖的package包/类
private static boolean isAttributeShouldBeFolded(XmlAttribute child) {
  return child.getContainingFile() instanceof HtmlFileImpl &&
         STYLE_ATTRIBUTE.equalsIgnoreCase(child.getName());
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:5,代码来源:XmlCodeFoldingBuilder.java


示例8: createFile

import com.intellij.psi.impl.source.html.HtmlFileImpl; //导入依赖的package包/类
public PsiFile createFile(FileViewProvider viewProvider) {
  return new HtmlFileImpl(viewProvider);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:4,代码来源:HTMLParserDefinition.java


示例9: getRenderedElementTwigTemplates

import com.intellij.psi.impl.source.html.HtmlFileImpl; //导入依赖的package包/类
/**
 * ["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;
}
 
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:72,代码来源:ProfilerUtil.java



注:本文中的com.intellij.psi.impl.source.html.HtmlFileImpl类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PGPPrivateKey类代码示例发布时间:2022-05-23
下一篇:
Java SigarInvokerJMX类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap