当前位置: 首页>>代码示例>>Java>>正文


Java SmartyFile类代码示例

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


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

示例1: collectSlowLineMarkers

import com.jetbrains.smarty.SmartyFile; //导入依赖的package包/类
@Override
public void collectSlowLineMarkers(@NotNull List<PsiElement> psiElements, @NotNull Collection<LineMarkerInfo> collection) {

    if(psiElements.size() == 0 || !OxidProjectComponent.isValidForProject(psiElements.get(0))) {
        return;
    }

    for(PsiElement psiElement: psiElements) {

        if (psiElement instanceof SmartyFile) {
            attachFileContextMaker((SmartyFile) psiElement, collection);
        }

        if(SmartyPattern.getBlockPattern().accepts(psiElement)) {
            attachBlocks(psiElement, collection);
        }

    }
}
 
开发者ID:Haehnchen,项目名称:idea-php-oxid-plugin,代码行数:20,代码来源:SmartyTemplateLineMarkerProvider.java

示例2: getSingleLineMarker

import com.jetbrains.smarty.SmartyFile; //导入依赖的package包/类
public static RelatedItemLineMarkerInfo<PsiElement> getSingleLineMarker(SmartyFile smartyFile, Collection<LineMarkerInfo> lineMarkerInfos, GotoRelatedItem gotoRelatedItem) {

        // hell: find any possible small icon
        Icon icon = null;
        if(gotoRelatedItem instanceof RelatedPopupGotoLineMarker.PopupGotoRelatedItem) {
            icon = ((RelatedPopupGotoLineMarker.PopupGotoRelatedItem) gotoRelatedItem).getSmallIcon();
        }

        if(icon == null) {
            icon = OxidPluginIcons.OXID_LINEMARKER;
        }

        NavigationGutterIconBuilder<PsiElement> builder = NavigationGutterIconBuilder.create(icon).
                setTargets(gotoRelatedItem.getElement());

        String customName = gotoRelatedItem.getCustomName();
        if(customName != null) {
            builder.setTooltipText(customName);
        }

        return builder.createLineMarkerInfo(smartyFile);
    }
 
开发者ID:Haehnchen,项目名称:idea-php-oxid-plugin,代码行数:23,代码来源:SmartyTemplateLineMarkerProvider.java

示例3: getPresentableTemplateName

import com.jetbrains.smarty.SmartyFile; //导入依赖的package包/类
private String getPresentableTemplateName(SmartyFile smartyFile, VirtualFile file) {
    String templateName = file.getPath();

    String relativePath = VfsUtil.getRelativePath(file, smartyFile.getProject().getBaseDir());
    if(relativePath != null) {
        templateName = relativePath;
    }

    int i = templateName.indexOf("/views/");
    if(i > 0) {
        templateName = templateName.substring(i + "/views/".length());
    }

    if(templateName.length() > 50) {
        templateName = "..." + templateName.substring(templateName.length() - 50);
    }
    return templateName;
}
 
开发者ID:Haehnchen,项目名称:idea-php-oxid-plugin,代码行数:19,代码来源:SmartyTemplateLineMarkerProvider.java

示例4: attachControllerVariableGoto

import com.jetbrains.smarty.SmartyFile; //导入依赖的package包/类
private void attachControllerVariableGoto(PsiElement sourceElement, final List<PsiElement> psiElements) {

        final String finalText = normalizeFilename(sourceElement.getText());

        PsiFile psiFile = sourceElement.getContainingFile();
        if(!(psiFile instanceof SmartyFile)) {
            return;
        }

        Method method = ShopwareUtil.getControllerActionOnSmartyFile((SmartyFile) psiFile);
        if(method == null) {
            return;
        }

        ShopwareUtil.collectControllerViewVariable(method, (variableName, sourceType, typeElement) -> {
            if (variableName.equals(finalText)) {
                psiElements.add(typeElement != null ? typeElement : sourceType);
            }
        });

    }
 
开发者ID:Haehnchen,项目名称:idea-php-shopware-plugin,代码行数:22,代码来源:SmartyFileGoToDeclarationHandler.java

示例5: attachFileContextMaker

import com.jetbrains.smarty.SmartyFile; //导入依赖的package包/类
private void attachFileContextMaker(SmartyFile smartyFile, @NotNull Collection<LineMarkerInfo> lineMarkerInfos) {
    List<GotoRelatedItem> gotoRelatedItems = new ArrayList<>();

    attachController(smartyFile, gotoRelatedItems);
    attachInclude(smartyFile, gotoRelatedItems);
    attachExtends(smartyFile, gotoRelatedItems);

    if(gotoRelatedItems.size() == 0) {
        return;
    }

    // only one item dont need popover
    if(gotoRelatedItems.size() == 1) {
        lineMarkerInfos.add(RelatedPopupGotoLineMarker.getSingleLineMarker(smartyFile, lineMarkerInfos, gotoRelatedItems.get(0)));
        return;
    }

    lineMarkerInfos.add(getRelatedPopover("Related Files", "", smartyFile, gotoRelatedItems));

}
 
开发者ID:Haehnchen,项目名称:idea-php-shopware-plugin,代码行数:21,代码来源:SmartyTemplateLineMarkerProvider.java

示例6: attachExtends

import com.jetbrains.smarty.SmartyFile; //导入依赖的package包/类
public void attachExtends(final SmartyFile smartyFile, final List<GotoRelatedItem> gotoRelatedItems) {

        final String templateName = TemplateUtil.getTemplateName(smartyFile.getProject(), smartyFile.getVirtualFile());
        if(templateName == null) {
            return;
        }

        FileBasedIndexImpl.getInstance().getFilesWithKey(SmartyExtendsStubIndex.KEY, new HashSet<>(Arrays.asList(templateName)), virtualFile -> {

            PsiFile psiFile = PsiManager.getInstance(smartyFile.getProject()).findFile(virtualFile);
            if(psiFile != null) {
                gotoRelatedItems.add(new RelatedPopupGotoLineMarker.PopupGotoRelatedItem(psiFile, TemplateUtil.getTemplateName(psiFile.getProject(), psiFile.getVirtualFile())).withIcon(PhpIcons.IMPLEMENTED, PhpIcons.IMPLEMENTED));
            }

            return true;
        }, GlobalSearchScope.getScopeRestrictedByFileTypes(GlobalSearchScope.allScope(smartyFile.getProject()), SmartyFileType.INSTANCE));

    }
 
开发者ID:Haehnchen,项目名称:idea-php-shopware-plugin,代码行数:19,代码来源:SmartyTemplateLineMarkerProvider.java

示例7: getSingleLineMarker

import com.jetbrains.smarty.SmartyFile; //导入依赖的package包/类
public static RelatedItemLineMarkerInfo<PsiElement> getSingleLineMarker(SmartyFile smartyFile, Collection<LineMarkerInfo> lineMarkerInfos, GotoRelatedItem gotoRelatedItem) {

        // hell: find any possible small icon
        Icon icon = null;
        if(gotoRelatedItem instanceof RelatedPopupGotoLineMarker.PopupGotoRelatedItem) {
            icon = ((RelatedPopupGotoLineMarker.PopupGotoRelatedItem) gotoRelatedItem).getSmallIcon();
        }

        if(icon == null) {
            icon = ShopwarePluginIcons.SHOPWARE_LINEMARKER;
        }

        NavigationGutterIconBuilder<PsiElement> builder = NavigationGutterIconBuilder.create(icon).
            setTargets(gotoRelatedItem.getElement());

        String customName = gotoRelatedItem.getCustomName();
        if(customName != null) {
            builder.setTooltipText(customName);
        }

        return builder.createLineMarkerInfo(smartyFile);
    }
 
开发者ID:Haehnchen,项目名称:idea-php-shopware-plugin,代码行数:23,代码来源:RelatedPopupGotoLineMarker.java

示例8: getFileNamespace

import com.jetbrains.smarty.SmartyFile; //导入依赖的package包/类
/**
 * {namespace name='frontend/plugins/payment/sepa'}
 */
@Nullable
public static String getFileNamespace(@NotNull SmartyFile file) {
    for (PsiElement psiElement : file.getChildren()) {
        if(psiElement instanceof SmartyTag && "namespace".equals(((SmartyTag) psiElement).getTagName())) {
            String name = TemplateUtil.getTagAttributeValueByName((SmartyTag) psiElement, "name");
            if(StringUtils.isBlank(name)) {
                return null;
            }

            return name;
        }
    }

    return null;
}
 
开发者ID:Haehnchen,项目名称:idea-php-shopware-plugin,代码行数:19,代码来源:SnippetUtil.java

示例9: collectSlowLineMarkers

import com.jetbrains.smarty.SmartyFile; //导入依赖的package包/类
@Override
public void collectSlowLineMarkers(@NotNull List<PsiElement> psiElements, @NotNull Collection<LineMarkerInfo> lineMarkerInfos) {

    if(psiElements.size() == 0 || !ShopwareProjectComponent.isValidForProject(psiElements.get(0))) {
        return;
    }

    Set<VirtualFile> extendsPathFiles = null;

    for(PsiElement psiElement: psiElements) {

        if(psiElement instanceof SmartyFile) {
            attachFileContextMaker((SmartyFile) psiElement, lineMarkerInfos);
        }

        if(SmartyPattern.getBlockPattern().accepts(psiElement)) {
            attachTemplateBlocks(psiElement, lineMarkerInfos);
        }

        if(SmartyPattern.getBlockPattern().accepts(psiElement)) {

            // cache template extends path
            if(extendsPathFiles == null) {
                extendsPathFiles = new HashSet<>();
                getImplementedBlocks(psiElement.getProject(), psiElement.getContainingFile().getVirtualFile(), extendsPathFiles, 10);
            }

            attachImplementsBlocks(psiElement, lineMarkerInfos, extendsPathFiles);
        }

    }

}
 
开发者ID:Haehnchen,项目名称:idea-php-shopware-plugin,代码行数:34,代码来源:SmartyTemplateLineMarkerProvider.java

示例10: attachController

import com.jetbrains.smarty.SmartyFile; //导入依赖的package包/类
public void attachController(SmartyFile smartyFile, final List<GotoRelatedItem> gotoRelatedItems) {

        String relativeFilename = TemplateUtil.getTemplateName(smartyFile.getProject(), smartyFile.getVirtualFile());
        if(relativeFilename == null) {
            return;
        }

        Pattern pattern = Pattern.compile(".*[/]*(frontend|backend|core)/(\\w+)/(\\w+)\\.tpl");
        Matcher matcher = pattern.matcher(relativeFilename);

        if(!matcher.find()) {
            return;
        }

        // Shopware_Controllers_Frontend_Account
        String moduleName = ShopwareUtil.toCamelCase(matcher.group(1), false);
        String controller = ShopwareUtil.toCamelCase(matcher.group(2), false);
        String action = ShopwareUtil.toCamelCase(matcher.group(3), true);

        // build class name
        String className = String.format("\\Shopware_Controllers_%s_%s", moduleName, controller);
        PhpClass phpClass = PhpElementsUtil.getClassInterface(smartyFile.getProject(), className);
        if(phpClass == null) {
            return;
        }

        Method method = phpClass.findMethodByName(action + "Action");
        if(method != null) {
            gotoRelatedItems.add(new RelatedPopupGotoLineMarker.PopupGotoRelatedItem(method, "Navigate to action").withIcon(PhpIcons.METHOD, PhpIcons.METHOD));
            return;
        }

        // fallback to class
        gotoRelatedItems.add(new RelatedPopupGotoLineMarker.PopupGotoRelatedItem(phpClass, "Navigate to class").withIcon(PhpIcons.CLASS, PhpIcons.CLASS));

    }
 
开发者ID:Haehnchen,项目名称:idea-php-shopware-plugin,代码行数:37,代码来源:SmartyTemplateLineMarkerProvider.java

示例11: getControllerActionOnSmartyFile

import com.jetbrains.smarty.SmartyFile; //导入依赖的package包/类
@Nullable
public static Method getControllerActionOnSmartyFile(SmartyFile smartyFile, String... modules) {

    String relativeFilename = TemplateUtil.getTemplateName(smartyFile.getProject(), smartyFile.getVirtualFile());
    if(relativeFilename == null) {
        return null;
    }

    Pattern pattern = Pattern.compile(".*[/]*(" + StringUtils.join(modules, "|") + ")/(\\w+)/(\\w+)\\.tpl");
    Matcher matcher = pattern.matcher(relativeFilename);

    if(!matcher.find()) {
        return null;
    }

    // Shopware_Controllers_Frontend_Account
    String moduleName = toCamelCase(matcher.group(1), false);
    String controller = toCamelCase(matcher.group(2), false);
    String action = toCamelCase(matcher.group(3), true);

    // build class name
    String className = String.format("\\Shopware_Controllers_%s_%s", moduleName, controller);
    PhpClass phpClass = PhpElementsUtil.getClassInterface(smartyFile.getProject(), className);
    if(phpClass == null) {
        return null;
    }

    return phpClass.findMethodByName(action + "Action");

}
 
开发者ID:Haehnchen,项目名称:idea-php-shopware-plugin,代码行数:31,代码来源:ShopwareUtil.java

示例12: getSnippetNamespaceByScope

import com.jetbrains.smarty.SmartyFile; //导入依赖的package包/类
/**
 * Find snippet namespace by tag scope and with file scope fallback
 *
 * {s namespace="foobar"}
 * {namespace="foobar"}
 */
@Nullable
public static String getSnippetNamespaceByScope(@NotNull SmartyTag smartyTag) {
    String namespace = TemplateUtil.getTagAttributeValueByName(smartyTag, "namespace");
    if(namespace != null) {
        return namespace;
    }

    PsiFile containingFile = smartyTag.getContainingFile();
    if(containingFile instanceof SmartyFile) {
        return SnippetUtil.getFileNamespace((SmartyFile) containingFile);
    }

    return null;
}
 
开发者ID:Haehnchen,项目名称:idea-php-shopware-plugin,代码行数:21,代码来源:TemplateUtil.java

示例13: visitSnippets

import com.jetbrains.smarty.SmartyFile; //导入依赖的package包/类
/**
 * {s name="foobar" namespace ="foobar/foobar"}{/s}
 */
private static void visitSnippets(@NotNull SmartyFile file, @NotNull Consumer<ShopwareSnippet> consumer) {
    LazySmartyFileNamespace lazyFileNamespace = new LazySmartyFileNamespace(file);

    file.acceptChildren(new PsiRecursiveElementVisitor() {
        @Override
        public void visitElement(PsiElement element) {
            if(!SmartyPattern.getTagAttributePattern("s", "name").accepts(element)) {
                super.visitElement(element);
                return;
            }

            String text = element.getText();
            if(StringUtils.isBlank(text)) {
                super.visitElement(element);
                return;
            }

            PsiElement parent = element.getParent();
            String namespace = TemplateUtil.getTagAttributeValueByName((SmartyTag) parent, "namespace");
            if(namespace == null) {
                namespace = lazyFileNamespace.getNamespace();
            }

            if(namespace != null) {
                consumer.accept(new ShopwareSnippet(element, namespace, text));
            }

            super.visitElement(element);
        }
    });
}
 
开发者ID:Haehnchen,项目名称:idea-php-shopware-plugin,代码行数:35,代码来源:SnippetUtil.java

示例14: testGetSnippetsInFile

import com.jetbrains.smarty.SmartyFile; //导入依赖的package包/类
public void testGetSnippetsInFile() {
    PsiFile psiFile = myFixture.configureByFile("snippets.tpl");

    Collection<ShopwareSnippet> snippets = SnippetUtil.getSnippetsInFile((SmartyFile) psiFile);

    assertNotNull(ContainerUtil.find(snippets, snippet ->
        "DetailLinkNotepad".equals(snippet.getName()) && "frontend/detail/actions".equals(snippet.getNamespace()))
    );

    assertNotNull(ContainerUtil.find(snippets, snippet ->
        "FO-O/BAR".equals(snippet.getName()) && "frontend/foobar".equals(snippet.getNamespace()))
    );
}
 
开发者ID:Haehnchen,项目名称:idea-php-shopware-plugin,代码行数:14,代码来源:SnippetUtilTest.java

示例15: attachFileContextMaker

import com.jetbrains.smarty.SmartyFile; //导入依赖的package包/类
private void attachFileContextMaker(SmartyFile smartyFile, @NotNull Collection<LineMarkerInfo> lineMarkerInfo) {

        final VirtualFile virtualFile = smartyFile.getVirtualFile();

        final Set<String> templates = TemplateUtil.getTemplateNames(smartyFile.getProject(), virtualFile);
        if(templates.size() == 0) {
            return;
        }

        List<GotoRelatedItem> gotoRelatedItems = new ArrayList<GotoRelatedItem>();

        for (String template : templates) {
            for (VirtualFile file : TemplateUtil.getFilesByTemplateName(smartyFile.getProject(), template)) {

                if(file.equals(virtualFile)) {
                   continue;
                }

                PsiFile psiFile = PsiManager.getInstance(smartyFile.getProject()).findFile(file);
                if(psiFile != null) {
                    String templateName = getPresentableTemplateName(smartyFile, file);
                    gotoRelatedItems.add(new RelatedPopupGotoLineMarker.PopupGotoRelatedItem(psiFile, templateName).withIcon(file.getFileType().getIcon(), OxidPluginIcons.OXID_LINEMARKER));
                }
            }
        }

        if(gotoRelatedItems.size() == 0) {
            return;
        }

        // only one item dont need popover
        if(gotoRelatedItems.size() == 1) {
            lineMarkerInfo.add(getSingleLineMarker(smartyFile, lineMarkerInfo, gotoRelatedItems.get(0)));
            return;
        }

        if(gotoRelatedItems.size() == 0) {
            return;
        }

        lineMarkerInfo.add(getRelatedPopover("Overwrite", "Overwrites", smartyFile, gotoRelatedItems));
    }
 
开发者ID:Haehnchen,项目名称:idea-php-oxid-plugin,代码行数:43,代码来源:SmartyTemplateLineMarkerProvider.java


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