當前位置: 首頁>>代碼示例>>Java>>正文


Java PlatformPatterns類代碼示例

本文整理匯總了Java中com.intellij.patterns.PlatformPatterns的典型用法代碼示例。如果您正苦於以下問題:Java PlatformPatterns類的具體用法?Java PlatformPatterns怎麽用?Java PlatformPatterns使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


PlatformPatterns類屬於com.intellij.patterns包,在下文中一共展示了PlatformPatterns類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: registerReferenceProviders

import com.intellij.patterns.PlatformPatterns; //導入依賴的package包/類
@Override
public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar) {
    // follow, redirect
    registrar.registerReferenceProvider(
            PlatformPatterns.psiElement(StringLiteralExpression.class),
            new PsiReferenceProvider() {
                @NotNull
                @Override
                public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {
                    if (!(element instanceof StringLiteralExpression)) {
                        return new PsiReference[0];
                    }

                    StringLiteralExpression stringLiteralExpression = (StringLiteralExpression) element;

                    String methodName = PhpLangUtil.getMethodName(element);
                    int parameterPosition = PhpLangUtil.getParameterPosition(stringLiteralExpression);
                    if (methodName != null && isDirectingActionName(methodName) && parameterPosition == 0) {
                        return new PsiReference[]{new ControllerActionReference(stringLiteralExpression)};
                    }

                    return new PsiReference[0];
                }
            }
    );
}
 
開發者ID:cedricziel,項目名稱:idea-php-typo3-plugin,代碼行數:27,代碼來源:ControllerActionReferenceContributor.java

示例2: registerReferenceProviders

import com.intellij.patterns.PlatformPatterns; //導入依賴的package包/類
@Override
public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar) {
    registrar.registerReferenceProvider(
            PlatformPatterns.psiElement(StringLiteralExpression.class),
            new PsiReferenceProvider() {
                @NotNull
                @Override
                public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {
                    if (isGenerator(element)) {
                        return new PsiReference[]{new RouteReference((StringLiteralExpression) element)};
                    }

                    return new PsiReference[0];
                }
            }
    );
}
 
開發者ID:cedricziel,項目名稱:idea-php-typo3-plugin,代碼行數:18,代碼來源:RouteReferenceContributor.java

示例3: isGenerator

import com.intellij.patterns.PlatformPatterns; //導入依賴的package包/類
private boolean isGenerator(@NotNull PsiElement element) {
    if (!PlatformPatterns
            .psiElement(StringLiteralExpression.class).withParent(
                    PlatformPatterns.psiElement(ParameterList.class).withParent(
                            PlatformPatterns.psiElement(MethodReference.class))
            )
            .accepts(element)) {

        return false;
    }

    PsiElement methodRef = element.getParent().getParent();
    if (methodRef instanceof MethodReference) {
        Method method = (Method) ((MethodReference) methodRef).resolve();
        if (method != null) {
            return isClassMethodCombination(method, "\\TYPO3\\CMS\\Backend\\Routing\\UriBuilder", "buildUriFromRoutePath")
                    || isClassMethodCombination(method, "\\TYPO3\\CMS\\Backend\\Routing\\UriBuilder", "buildUriFromRoute")
                    || isClassMethodCombination(method, "\\TYPO3\\CMS\\Backend\\Routing\\UriBuilder", "buildUriFromAjaxId")
                    || isClassMethodCombination(method, "\\TYPO3\\CMS\\Backend\\Utility\\BackendUtility", "getAjaxUrl");
        }
    }

    return false;
}
 
開發者ID:cedricziel,項目名稱:idea-php-typo3-plugin,代碼行數:25,代碼來源:RouteReferenceContributor.java

示例4: registerReferenceProviders

import com.intellij.patterns.PlatformPatterns; //導入依賴的package包/類
@Override
public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar) {
    // "EXT:" strings
    registrar.registerReferenceProvider(
            PlatformPatterns.psiElement(StringLiteralExpression.class),
            new PsiReferenceProvider() {
                @NotNull
                @Override
                public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {

                    StringLiteralExpression stringLiteralExpression = (StringLiteralExpression)element;
                    if (!stringLiteralExpression.getContents().startsWith("EXT:")) {
                        return new PsiReference[0];
                    }

                    return new PsiReference[]{new ResourceReference(stringLiteralExpression)};
                }
            }
    );
}
 
開發者ID:cedricziel,項目名稱:idea-php-typo3-plugin,代碼行數:21,代碼來源:ResourceReferenceContributor.java

示例5: buildVisitor

import com.intellij.patterns.PlatformPatterns; //導入依賴的package包/類
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder problemsHolder, boolean b) {
    return new PhpElementVisitor() {
        @Override
        public void visitPhpElement(PhpPsiElement element) {

            if (!PlatformPatterns.psiElement(PhpElementTypes.CONSTANT_REF).accepts(element)) {
                return;
            }

            ConstantReference constantReference = (ConstantReference) element;
            Set<String> constants = getRemovedConstantsFQNs(constantReference);
            if (constants.contains(constantReference.getFQN())) {
                problemsHolder.registerProblem(element, "Constant removed with TYPO3 9, consider using an alternative");
            }
        }
    };
}
 
開發者ID:cedricziel,項目名稱:idea-php-typo3-plugin,代碼行數:20,代碼來源:ConstantMatcherInspection.java

示例6: getRemovedConstantsFQNs

import com.intellij.patterns.PlatformPatterns; //導入依賴的package包/類
private Set<String> getRemovedConstantsFQNs(ConstantReference element) {
    Set<PsiElement> elements = new HashSet<>();
    PsiFile[] constantMatcherFiles = FilenameIndex.getFilesByName(element.getProject(), "ConstantMatcher.php", GlobalSearchScope.allScope(element.getProject()));
    for (PsiFile file : constantMatcherFiles) {

        Collections.addAll(
                elements,
                PsiTreeUtil.collectElements(file, el -> PlatformPatterns
                        .psiElement(StringLiteralExpression.class)
                        .withParent(
                                PlatformPatterns.psiElement(PhpElementTypes.ARRAY_KEY)
                                        .withAncestor(
                                                4,
                                                PlatformPatterns.psiElement(PhpElementTypes.RETURN)
                                        )
                        )
                        .accepts(el)
                )
        );
    }

    return elements.stream()
            .map(stringLiteral -> "\\" + ((StringLiteralExpression)stringLiteral).getContents())
            .collect(Collectors.toSet());
}
 
開發者ID:cedricziel,項目名稱:idea-php-typo3-plugin,代碼行數:26,代碼來源:ConstantMatcherInspection.java

示例7: buildVisitor

import com.intellij.patterns.PlatformPatterns; //導入依賴的package包/類
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder problemsHolder, boolean b) {
    return new PhpElementVisitor() {
        @Override
        public void visitPhpElement(PhpPsiElement element) {

            if (!PlatformPatterns.psiElement(PhpElementTypes.FUNCTION_CALL).accepts(element)) {
                return;
            }

            Set<String> constants = getRemovedGlobalFuntions(element);
            FunctionReference constantReference = (FunctionReference) element;
            if (constants.contains(constantReference.getFQN())) {
                problemsHolder.registerProblem(element, "Global function removed with TYPO3 9, consider using an alternative");
            }
        }
    };
}
 
開發者ID:cedricziel,項目名稱:idea-php-typo3-plugin,代碼行數:20,代碼來源:FunctionCallMatcherInspection.java

示例8: getRemovedGlobalFuntions

import com.intellij.patterns.PlatformPatterns; //導入依賴的package包/類
private Set<String> getRemovedGlobalFuntions(PhpPsiElement element) {
    Set<PsiElement> elements = new HashSet<>();
    PsiFile[] constantMatcherFiles = FilenameIndex.getFilesByName(element.getProject(), "FunctionCallMatcher.php", GlobalSearchScope.allScope(element.getProject()));
    for (PsiFile file : constantMatcherFiles) {

        Collections.addAll(
                elements,
                PsiTreeUtil.collectElements(file, el -> PlatformPatterns
                        .psiElement(StringLiteralExpression.class)
                        .withParent(
                                PlatformPatterns.psiElement(PhpElementTypes.ARRAY_KEY)
                                        .withAncestor(
                                                4,
                                                PlatformPatterns.psiElement(PhpElementTypes.RETURN)
                                        )
                        )
                        .accepts(el)
                )
        );
    }

    return elements.stream()
            .map(stringLiteral -> "\\" + ((StringLiteralExpression) stringLiteral).getContents())
            .collect(Collectors.toSet());
}
 
開發者ID:cedricziel,項目名稱:idea-php-typo3-plugin,代碼行數:26,代碼來源:FunctionCallMatcherInspection.java

示例9: buildVisitor

import com.intellij.patterns.PlatformPatterns; //導入依賴的package包/類
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder problemsHolder, boolean b) {
    return new PhpElementVisitor() {
        @Override
        public void visitPhpElement(PhpPsiElement element) {

            if (!PlatformPatterns.psiElement(PhpElementTypes.CLASS_CONSTANT_REFERENCE).accepts(element)) {
                return;
            }

            Set<String> constants = getDeprecatedClassConstants(element);
            ClassConstantReference classConstantReference = (ClassConstantReference) element;
            if (constants.contains(classConstantReference.getText())) {
                problemsHolder.registerProblem(element, "Deprecated class constant");
            }
        }
    };
}
 
開發者ID:cedricziel,項目名稱:idea-php-typo3-plugin,代碼行數:20,代碼來源:ClassConstantMatcherInspection.java

示例10: getDeprecatedClassConstants

import com.intellij.patterns.PlatformPatterns; //導入依賴的package包/類
private Set<String> getDeprecatedClassConstants(PhpPsiElement element) {
    Set<PsiElement> elements = new HashSet<>();
    PsiFile[] classConstantMatcherFiles = FilenameIndex.getFilesByName(element.getProject(), "ClassConstantMatcher.php", GlobalSearchScope.allScope(element.getProject()));
    for (PsiFile file : classConstantMatcherFiles) {

        Collections.addAll(
                elements,
                PsiTreeUtil.collectElements(file, el -> PlatformPatterns
                        .psiElement(StringLiteralExpression.class)
                        .withParent(
                                PlatformPatterns.psiElement(PhpElementTypes.ARRAY_KEY)
                                        .withAncestor(
                                                4,
                                                PlatformPatterns.psiElement(PhpElementTypes.RETURN)
                                        )
                        )
                        .accepts(el)
                )
        );
    }

    return elements.stream().map(stringLiteral -> ((StringLiteralExpression)stringLiteral).getContents()).collect(Collectors.toSet());
}
 
開發者ID:cedricziel,項目名稱:idea-php-typo3-plugin,代碼行數:24,代碼來源:ClassConstantMatcherInspection.java

示例11: buildVisitor

import com.intellij.patterns.PlatformPatterns; //導入依賴的package包/類
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder problemsHolder, boolean b) {
    return new PhpElementVisitor() {
        @Override
        public void visitPhpElement(PhpPsiElement element) {

            if (!PlatformPatterns.psiElement(PhpElementTypes.CLASS_REFERENCE).accepts(element)) {
                return;
            }

            Set<String> constants = getDeprecatedClasses(element);
            ClassReference classReference = (ClassReference) element;
            if (constants.contains(classReference.getFQN())) {
                problemsHolder.registerProblem(element, "Class removed with TYPO3 9, consider using an alternative");
            }
        }
    };
}
 
開發者ID:cedricziel,項目名稱:idea-php-typo3-plugin,代碼行數:20,代碼來源:ClassNameMatcherInspection.java

示例12: getDeprecatedClasses

import com.intellij.patterns.PlatformPatterns; //導入依賴的package包/類
private Set<String> getDeprecatedClasses(PhpPsiElement element) {
    Set<PsiElement> elements = new HashSet<>();
    PsiFile[] classNameMatcherFiles = FilenameIndex.getFilesByName(element.getProject(), "ClassNameMatcher.php", GlobalSearchScope.allScope(element.getProject()));
    for (PsiFile file : classNameMatcherFiles) {

        Collections.addAll(
                elements,
                PsiTreeUtil.collectElements(file, el -> PlatformPatterns
                        .psiElement(StringLiteralExpression.class)
                        .withParent(
                                PlatformPatterns.psiElement(PhpElementTypes.ARRAY_KEY)
                                        .withAncestor(
                                                4,
                                                PlatformPatterns.psiElement(PhpElementTypes.RETURN)
                                        )
                        )
                        .accepts(el)
                )
        );
    }

    return elements.stream()
            .map(stringLiteral -> "\\" + ((StringLiteralExpression)stringLiteral).getContents())
            .collect(Collectors.toSet());
}
 
開發者ID:cedricziel,項目名稱:idea-php-typo3-plugin,代碼行數:26,代碼來源:ClassNameMatcherInspection.java

示例13: isMethodWithFirstStringOrFieldReference

import com.intellij.patterns.PlatformPatterns; //導入依賴的package包/類
public static boolean isMethodWithFirstStringOrFieldReference(PsiElement psiElement, String... methodName) {
    if (!PlatformPatterns
            .psiElement(PhpElementTypes.METHOD_REFERENCE)
            .withChild(PlatformPatterns
                    .psiElement(PhpElementTypes.PARAMETER_LIST)
                    .withFirstChild(PlatformPatterns.or(
                            PlatformPatterns.psiElement(PhpElementTypes.STRING),
                            PlatformPatterns.psiElement(PhpElementTypes.FIELD_REFERENCE),
                            PlatformPatterns.psiElement(PhpElementTypes.CLASS_CONSTANT_REFERENCE)
                    ))
            ).accepts(psiElement)) {

        return false;
    }

    // cant we move it up to PlatformPatterns? withName condition dont looks working
    String methodRefName = ((MethodReference) psiElement).getName();

    return null != methodRefName && Arrays.asList(methodName).contains(methodRefName);
}
 
開發者ID:cedricziel,項目名稱:idea-php-typo3-plugin,代碼行數:21,代碼來源:PhpElementsUtil.java

示例14: registerReferenceProviders

import com.intellij.patterns.PlatformPatterns; //導入依賴的package包/類
@Override
public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar) {
    registrar.registerReferenceProvider(PlatformPatterns.psiElement(StringLiteralExpression.class), new PsiReferenceProvider() {
        @NotNull
        @Override
        public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {
            if (!(element instanceof StringLiteralExpression)) {
                return new PsiReference[0];
            }

            StringLiteralExpression stringLiteralExpression = (StringLiteralExpression) element;
            if (!stringLiteralExpression.getContents().startsWith("LLL:")) {
                return new PsiReference[0];
            }

            return new PsiReference[]{new TranslationReference(stringLiteralExpression)};
        }
    });
}
 
開發者ID:cedricziel,項目名稱:idea-php-typo3-plugin,代碼行數:20,代碼來源:TranslationReferenceContributor.java

示例15: getGotoDeclarationTargets

import com.intellij.patterns.PlatformPatterns; //導入依賴的package包/類
@Nullable
@Override
public PsiElement[] getGotoDeclarationTargets(@Nullable PsiElement psiElement, int i, Editor editor) {
    if (psiElement == null) {
        return PsiElement.EMPTY_ARRAY;
    }
    Project project = psiElement.getProject();
    if (!PlatformPatterns
            .psiElement(StringLiteralExpression.class)
            .withLanguage(PhpLanguage.INSTANCE)
            .accepts(psiElement.getContext())
    ) {
        return PsiElement.EMPTY_ARRAY;
    }
    PsiFile containingFile = psiElement.getContainingFile();
    PsiDirectory appDir = PsiUtil.getAppDirectoryFromFile(containingFile);
    String elementFilename = String.format("View/Elements/%s.ctp", psiElement.getText());
    VirtualFile relativeFile = VfsUtil.findRelativeFile(appDir, elementFilename);
    if (relativeFile != null) {
        Collection<VirtualFile> files = new HashSet<>();
        files.add(relativeFile);
        return PsiUtil.convertVirtualFilesToPsiFiles(project, files).toArray(new PsiElement[files.size()]);
    }
    return PsiElement.EMPTY_ARRAY;
}
 
開發者ID:dmeybohm,項目名稱:chocolate-cakephp,代碼行數:26,代碼來源:ElementGotoDeclarationHandler.java


注:本文中的com.intellij.patterns.PlatformPatterns類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。