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


Java PhpPsiElement类代码示例

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


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

示例1: buildVisitor

import com.jetbrains.php.lang.psi.elements.PhpPsiElement; //导入依赖的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

示例2: buildVisitor

import com.jetbrains.php.lang.psi.elements.PhpPsiElement; //导入依赖的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

示例3: getRemovedGlobalFuntions

import com.jetbrains.php.lang.psi.elements.PhpPsiElement; //导入依赖的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

示例4: buildVisitor

import com.jetbrains.php.lang.psi.elements.PhpPsiElement; //导入依赖的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

示例5: getDeprecatedClassConstants

import com.jetbrains.php.lang.psi.elements.PhpPsiElement; //导入依赖的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

示例6: buildVisitor

import com.jetbrains.php.lang.psi.elements.PhpPsiElement; //导入依赖的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

示例7: getDeprecatedClasses

import com.jetbrains.php.lang.psi.elements.PhpPsiElement; //导入依赖的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

示例8: buildVisitor

import com.jetbrains.php.lang.psi.elements.PhpPsiElement; //导入依赖的package包/类
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder problemsHolder, boolean b) {
    return new PhpElementVisitor() {
        @Override
        public void visitPhpElement(PhpPsiElement element) {

            boolean isArrayStringValue = PhpElementsUtil.isStringArrayValue().accepts(element);
            if (!isArrayStringValue || !insideTCAColumnDefinition(element)) {
                return;
            }

            String arrayIndex = extractArrayIndexFromValue(element);
            if (arrayIndex != null && Arrays.asList(TCAUtil.TCA_NUMERIC_CONFIG_KEYS).contains(arrayIndex)) {
                if (element instanceof StringLiteralExpression) {
                    problemsHolder.registerProblem(element, "Config key only accepts integer values");
                }
            }
        }
    };
}
 
开发者ID:cedricziel,项目名称:idea-php-typo3-plugin,代码行数:22,代码来源:InvalidQuantityInspection.java

示例9: isModuleKeyInFlatArray

import com.jetbrains.php.lang.psi.elements.PhpPsiElement; //导入依赖的package包/类
public static boolean isModuleKeyInFlatArray(@NotNull StringLiteralExpression psiElement, @NotNull String key) {
    PsiElement arrayKey = psiElement.getParent();
    if(arrayKey != null && arrayKey.getNode().getElementType() == PhpElementTypes.ARRAY_VALUE) {
        PsiElement hashElement = arrayKey.getParent();
        if(hashElement instanceof ArrayHashElement) {
            PsiElement arrayCreation = hashElement.getParent();
            if(arrayCreation instanceof ArrayCreationExpression) {
                PsiElement arrayValue = arrayCreation.getParent();
                if(arrayValue != null && arrayValue.getNode().getElementType() == PhpElementTypes.ARRAY_VALUE) {
                    PsiElement hashArray = arrayValue.getParent();
                    if(hashArray instanceof ArrayHashElement) {
                        PhpPsiElement keyString = ((ArrayHashElement) hashArray).getKey();
                        if(keyString instanceof StringLiteralExpression) {
                            String contents = ((StringLiteralExpression) keyString).getContents();
                            if(key.equals(contents)) {
                                return true;
                            }
                        }
                    }
                }
            }
        }
    }

    return false;
}
 
开发者ID:Haehnchen,项目名称:idea-php-oxid-plugin,代码行数:27,代码来源:PhpMetadataUtil.java

示例10: isExtendKey

import com.jetbrains.php.lang.psi.elements.PhpPsiElement; //导入依赖的package包/类
public static boolean isExtendKey(@NotNull StringLiteralExpression parent) {

        ArrayCreationExpression arrayCreation = PhpElementsUtil.getCompletableArrayCreationElement(parent);
        if(arrayCreation == null) {
            return false;
        }

        PsiElement arrayValue = arrayCreation.getParent();
        if(arrayValue != null && arrayValue.getNode().getElementType() == PhpElementTypes.ARRAY_VALUE) {
            PsiElement hashArray = arrayValue.getParent();
            if(hashArray instanceof ArrayHashElement) {
                PhpPsiElement key = ((ArrayHashElement) hashArray).getKey();
                if(key instanceof StringLiteralExpression && "extend".equals(((StringLiteralExpression) key).getContents())) {
                    return true;
                }
            }
        }

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

示例11: visitMetadataKey

import com.jetbrains.php.lang.psi.elements.PhpPsiElement; //导入依赖的package包/类
private static void visitMetadataKey(@NotNull PsiFile psiFile, @NotNull String key, @NotNull MetadataKeyVisitor visitor) {

        PsiElement childOfType = PsiTreeUtil.getChildOfType(psiFile, GroupStatement.class);
        if(childOfType == null) {
            return;
        }

        for (Statement statement : PsiTreeUtil.getChildrenOfTypeAsList(childOfType, Statement.class)) {
            PsiElement assignmentExpr = statement.getFirstPsiChild();
            if(assignmentExpr instanceof AssignmentExpressionImpl) {
                PhpPsiElement variable = ((AssignmentExpressionImpl) assignmentExpr).getVariable();
                if(variable != null && "aModule".equals(variable.getName())) {

                    PhpPsiElement value = ((AssignmentExpressionImpl) assignmentExpr).getValue();
                    if(value instanceof ArrayCreationExpression) {
                        PhpPsiElement arrayCreationKeyMap = PhpElementsUtil.getArrayValue((ArrayCreationExpression) value, key);
                        if(arrayCreationKeyMap instanceof ArrayCreationExpression) {
                            visitor.visit((ArrayCreationExpression) arrayCreationKeyMap);
                        }
                    }
                }
            }
        }
    }
 
开发者ID:Haehnchen,项目名称:idea-php-oxid-plugin,代码行数:25,代码来源:MetadataUtil.java

示例12: insertUse

import com.jetbrains.php.lang.psi.elements.PhpPsiElement; //导入依赖的package包/类
public static void insertUse(InsertionContext context, String fqnAnnotation) {
    PsiElement element = PsiUtilCore.getElementAtOffset(context.getFile(), context.getStartOffset());
    PhpPsiElement scopeForUseOperator = PhpCodeInsightUtil.findScopeForUseOperator(element);

    if(null == scopeForUseOperator) {
        return;
    }

    // PhpCodeInsightUtil.canImport:
    // copied from PhpReferenceInsertHandler; throws an error on PhpContractUtil because of "fully qualified names only"
    // but that is catch on phpstorm side already; looks fixed now so use fqn

    if(!fqnAnnotation.startsWith("\\")) {
        fqnAnnotation = "\\" + fqnAnnotation;
    }

    // this looks suitable! :)
    if(PhpCodeInsightUtil.alreadyImported(scopeForUseOperator, fqnAnnotation) == null) {
        PsiDocumentManager.getInstance(context.getProject()).commitDocument(context.getDocument());
        PhpAliasImporter.insertUseStatement(fqnAnnotation, scopeForUseOperator);
        PsiDocumentManager.getInstance(context.getProject()).doPostponedOperationsAndUnblockDocument(context.getDocument());
    }
}
 
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:24,代码来源:AnnotationUseImporter.java

示例13: getPropertyValueCompletions

import com.jetbrains.php.lang.psi.elements.PhpPsiElement; //导入依赖的package包/类
@Override
public void getPropertyValueCompletions(AnnotationPropertyParameter annotationPropertyParameter, AnnotationCompletionProviderParameter completionParameter) {

    String propertyName = annotationPropertyParameter.getPropertyName();
    if(propertyName == null) {
        return;
    }

    if(propertyName.equals("name") && PhpLangUtil.equalsClassNames(annotationPropertyParameter.getPhpClass().getPresentableFQN(), "Doctrine\\ORM\\Mapping\\Column")) {
        PhpDocComment phpDocComment = PsiTreeUtil.getParentOfType(annotationPropertyParameter.getElement(), PhpDocComment.class);
        if(phpDocComment != null) {
            PhpPsiElement classField = phpDocComment.getNextPsiSibling();
            if(classField != null && classField.getNode().getElementType() == PhpElementTypes.CLASS_FIELDS) {
                Field field = PsiTreeUtil.getChildOfType(classField, Field.class);
                if(field != null) {
                    String name = field.getName();
                    if(StringUtils.isNotBlank(name)) {
                        completionParameter.getResult().addElement(LookupElementBuilder.create(underscore(name)));
                    }
                }
            }
        }
    }

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

示例14: importOrmUseAliasIfNotExists

import com.jetbrains.php.lang.psi.elements.PhpPsiElement; //导入依赖的package包/类
public static void importOrmUseAliasIfNotExists(@NotNull PhpClassMember field) {

        // check for already imported class aliases
        String qualifiedName = PhpDocUtil.getQualifiedName(field, DOCTRINE_ORM_MAPPING);
        if(qualifiedName == null || !qualifiedName.equals(DOCTRINE_ORM_MAPPING.substring(1))) {
            return;
        }

        // try to import:
        // use Doctrine\ORM\Mapping as ORM;
        PhpClass phpClass = field.getContainingClass();
        if(phpClass == null) {
            return;
        }

        PhpPsiElement scopeForUseOperator = PhpCodeInsightUtil.findScopeForUseOperator(phpClass);
        if(scopeForUseOperator == null) {
            return;
        }

        PhpElementsUtil.insertUseIfNecessary(scopeForUseOperator, DOCTRINE_ORM_MAPPING, "ORM");
    }
 
开发者ID:Haehnchen,项目名称:idea-php-annotation-plugin,代码行数:23,代码来源:DoctrineUtil.java

示例15: getDefaultPropertyValue

import com.jetbrains.php.lang.psi.elements.PhpPsiElement; //导入依赖的package包/类
/**
 * Get default property value from annotation "@Template("foo");
 *
 * @return Content of property value literal
 */
@Nullable
public String getDefaultPropertyValue() {
    PhpPsiElement phpDocAttrList = phpDocTag.getFirstPsiChild();

    if(phpDocAttrList != null) {
        if(phpDocAttrList.getNode().getElementType() == PhpDocElementTypes.phpDocAttributeList) {
            PhpPsiElement phpPsiElement = phpDocAttrList.getFirstPsiChild();
            if(phpPsiElement instanceof StringLiteralExpression) {
                return ((StringLiteralExpression) phpPsiElement).getContents();
            }
        }
    }

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


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