本文整理汇总了Java中com.jetbrains.php.lang.psi.elements.PhpPsiElement类的典型用法代码示例。如果您正苦于以下问题:Java PhpPsiElement类的具体用法?Java PhpPsiElement怎么用?Java PhpPsiElement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PhpPsiElement类属于com.jetbrains.php.lang.psi.elements包,在下文中一共展示了PhpPsiElement类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: registerReferenceProviders
import com.jetbrains.php.lang.psi.elements.PhpPsiElement; //导入依赖的package包/类
@Override
public void registerReferenceProviders(PsiReferenceRegistrar registrar) {
registrar.registerReferenceProvider(StandardPatterns.instanceOf(PhpPsiElement.class), new YiiPsiReferenceProvider());
registrar.registerReferenceProvider(
PlatformPatterns.psiElement(PsiElement.class).withParent(isParamListInMethodWithName(".+?widget\\(.+"))
, new WidgetCallReferenceProvider());
//View-to-view
registrar.registerReferenceProvider(
PlatformPatterns.psiElement(PhpPsiElement.class)
.withParent(isParamListInMethodWithName(".+?render(Partial)*\\(.+"))
.andNot(inFile(PlatformPatterns.string().endsWith("Controller.php")))
, new ViewRenderViewReferenceProvider());
//Controller-to-view
registrar.registerReferenceProvider(
PlatformPatterns.psiElement(PhpPsiElement.class)
.withParent(isParamListInMethodWithName("(?sim).+?render(Partial)*\\(.+"))
.and(inFile(PlatformPatterns.string().endsWith("Controller.php")))
, new ControllerRenderViewReferenceProvider());
}
开发者ID:cmazx,项目名称:yiistorm,代码行数:20,代码来源:YiiReferenceContributor.java
示例17: withHashKey
import com.jetbrains.php.lang.psi.elements.PhpPsiElement; //导入依赖的package包/类
public static Capture<PhpPsiElement> withHashKey() {
return new Capture<>(new InitialPatternCondition<PhpPsiElement>(PhpPsiElement.class) {
@Override
public boolean accepts(@Nullable Object o, ProcessingContext context) {
return o != null && o.toString().equals("Array key");
}
});
}
开发者ID:nvlad,项目名称:yii2support,代码行数:9,代码来源:Patterns.java
示例18: applyFix
import com.jetbrains.php.lang.psi.elements.PhpPsiElement; //导入依赖的package包/类
@Override
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
final PsiElement expression = descriptor.getPsiElement();
if (null != expression && expression.getParent() instanceof ArrayCreationExpression) {
final ArrayCreationExpression container = (ArrayCreationExpression) expression.getParent();
final PsiElement closingBracket = container.getLastChild();
if (null == closingBracket) {
return;
}
for (String translation : missing) {
/* reach or create a comma */
PsiElement last = closingBracket.getPrevSibling();
if (last instanceof PsiWhiteSpace) {
last = last.getPrevSibling();
}
if (null != last && PhpTokenTypes.opCOMMA != last.getNode().getElementType()) {
last.getParent().addAfter(PhpPsiElementFactory.createComma(project), last);
last = last.getNextSibling();
}
/* add a new translation */
final String escaped = PhpStringUtil.escapeText(translation, true, '\n', '\t');
final String pairPattern = "array('%s%' => '%s%')".replace("%s%", escaped).replace("%s%", escaped);
final ArrayCreationExpression array = PhpPsiElementFactory.createFromText(project, ArrayCreationExpression.class, pairPattern);
final PhpPsiElement pair = null == array ? null : array.getHashElements().iterator().next();
final PsiWhiteSpace space = PhpPsiElementFactory.createFromText(project, PsiWhiteSpace.class, " ");
if (null == last || null == pair || null == space) {
continue;
}
last.getParent().addAfter(pair, last);
last.getParent().addAfter(space, last);
}
}
}
开发者ID:kalessil,项目名称:yii2inspections,代码行数:36,代码来源:MissingTranslationsInspector.java
示例19: 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 && arrayIndex.equals("type")) {
if (element instanceof StringLiteralExpression) {
String tableName = ((StringLiteralExpression) element).getContents();
boolean isValidRenderType = TCAUtil.getAvailableColumnTypes(element).contains(tableName);
if (!isValidRenderType) {
problemsHolder.registerProblem(element, "Missing column type definition");
}
}
}
}
};
}
开发者ID:cedricziel,项目名称:idea-php-typo3-plugin,代码行数:28,代码来源:MissingColumnTypeInspection.java
示例20: 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 (element instanceof PhpDocTag) {
PhpDocTag tag = (PhpDocTag) element;
if ("@inject".equals(tag.getName())) {
problemsHolder.registerProblem(element, "Extbase property injection", new CreateInjectorQuickFix(element));
}
}
}
};
}
开发者ID:cedricziel,项目名称:idea-php-typo3-plugin,代码行数:16,代码来源:ExtbasePropertyInjectionInspection.java
注:本文中的com.jetbrains.php.lang.psi.elements.PhpPsiElement类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论