Java Code Examples for de.espend.idea.php.annotation.extension.parameter.AnnotationPropertyParameter#getPropertyName()
The following examples show how to use
de.espend.idea.php.annotation.extension.parameter.AnnotationPropertyParameter#getPropertyName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConfigEntityTypeAnnotation.java From idea-php-drupal-symfony2-bridge with MIT License | 6 votes |
@Nullable @Override public PsiReference[] getPropertyReferences(AnnotationPropertyParameter parameter, PhpAnnotationReferenceProviderParameter phpAnnotationReferenceProviderParameter) { if(!isSupported(parameter)) { return new PsiReference[0]; } String propertyName = parameter.getPropertyName(); if("admin_permission".equalsIgnoreCase(propertyName)) { String contents = getContents(parameter.getElement()); if(StringUtils.isBlank(contents)) { return new PsiReference[0]; } return new PsiReference[] {new ContentEntityTypeAnnotation.MyPermissionPsiPolyVariantReferenceBase(parameter.getElement(), contents)}; } return new PsiReference[0]; }
Example 2
Source File: DoctrineAnnotationStaticCompletionProvider.java From idea-php-annotation-plugin with MIT License | 6 votes |
@Override public void getPropertyValueCompletions(AnnotationPropertyParameter annotationPropertyParameter, AnnotationCompletionProviderParameter completionParameter) { String propertyName = annotationPropertyParameter.getPropertyName(); if(propertyName == null) { return; } if(propertyName.equals("type") && PhpLangUtil.equalsClassNames(annotationPropertyParameter.getPhpClass().getPresentableFQN(), "Doctrine\\ORM\\Mapping\\Column")) { completionParameter.getResult().addAllElements(DoctrineUtil.getTypes(annotationPropertyParameter.getProject())); } if(propertyName.equals("onDelete") && PhpLangUtil.equalsClassNames(annotationPropertyParameter.getPhpClass().getPresentableFQN(), "Doctrine\\ORM\\Mapping\\JoinColumn")) { for(String s: Arrays.asList("CASCADE", "SET NULL")) { completionParameter.getResult().addElement(LookupElementBuilder.create(s)); } } }
Example 3
Source File: ColumnNameCompletionProvider.java From idea-php-annotation-plugin with MIT License | 6 votes |
@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))); } } } } } }
Example 4
Source File: DoctrineAnnotationFieldTypeProvider.java From idea-php-annotation-plugin with MIT License | 6 votes |
@Nullable @Override public PsiReference[] getPropertyReferences(AnnotationPropertyParameter annotationPropertyParameter, PhpAnnotationReferenceProviderParameter referencesByElementParameter) { if(annotationPropertyParameter.getType() != AnnotationPropertyParameter.Type.PROPERTY_VALUE) { return null; } String propertyName = annotationPropertyParameter.getPropertyName(); if(propertyName == null || !propertyName.equals("type")) { return null; } String presentableFQN = annotationPropertyParameter.getPhpClass().getPresentableFQN(); if(!presentableFQN.startsWith("\\")) { presentableFQN = "\\" + presentableFQN; } if(!presentableFQN.equals("\\Doctrine\\ORM\\Mapping\\Column")) { return null; } return new PsiReference[] { new DoctrineColumnTypeReference((StringLiteralExpression) annotationPropertyParameter.getElement()) }; }
Example 5
Source File: DoctrineAnnotationTypeProvider.java From idea-php-annotation-plugin with MIT License | 6 votes |
@Nullable @Override public PsiReference[] getPropertyReferences(AnnotationPropertyParameter annotationPropertyParameter, PhpAnnotationReferenceProviderParameter referencesByElementParameter) { if(annotationPropertyParameter.getType() != AnnotationPropertyParameter.Type.PROPERTY_VALUE) { return null; } String propertyName = annotationPropertyParameter.getPropertyName(); if(propertyName == null || !propertyName.equals("repositoryClass")) { return null; } String presentableFQN = annotationPropertyParameter.getPhpClass().getPresentableFQN(); if(!PhpLangUtil.equalsClassNames("Doctrine\\ORM\\Mapping\\Entity", presentableFQN)) { return null; } return new PsiReference[] { new DoctrineRepositoryReference((StringLiteralExpression) annotationPropertyParameter.getElement()) }; }
Example 6
Source File: AnnotationClassProvider.java From idea-php-annotation-plugin with MIT License | 6 votes |
@Nullable @Override public PsiReference[] getPropertyReferences(AnnotationPropertyParameter annotationPropertyParameter, PhpAnnotationReferenceProviderParameter referencesByElementParameter) { if(annotationPropertyParameter.getType() != AnnotationPropertyParameter.Type.PROPERTY_VALUE) { return null; } String propertyName = annotationPropertyParameter.getPropertyName(); if(propertyName == null || !propertyName.equals("targetEntity")) { return null; } return new PsiReference[] { new PhpClassReference((StringLiteralExpression) annotationPropertyParameter.getElement()) }; }
Example 7
Source File: DoctrineAnnotationFieldProvider.java From idea-php-annotation-plugin with MIT License | 5 votes |
@Nullable @Override public PsiReference[] getPropertyReferences(AnnotationPropertyParameter annotationPropertyParameter, PhpAnnotationReferenceProviderParameter referencesByElementParameter) { if(annotationPropertyParameter.getType() != AnnotationPropertyParameter.Type.PROPERTY_VALUE) { return null; } String propertyName = annotationPropertyParameter.getPropertyName(); if(propertyName == null || !(propertyName.equals("mappedBy") || propertyName.equals("inversedBy"))) { return null; } PsiElement parent = annotationPropertyParameter.getElement().getParent(); StringLiteralExpression targetEntity = PhpElementsUtil.getChildrenOnPatternMatch(parent, AnnotationPattern.getPropertyIdentifierValue("targetEntity")); if(targetEntity == null) { return null; } PhpClass phpClass = PhpElementsUtil.getClassInsideAnnotation(targetEntity); if(phpClass == null) { return null; } return new PsiReference[] { new DoctrinePhpClassFieldReference((StringLiteralExpression) annotationPropertyParameter.getElement(), phpClass) }; }
Example 8
Source File: PhpAnnotationTypeCompletionProvider.java From idea-php-annotation-plugin with MIT License | 4 votes |
@Override public void getPropertyValueCompletions(AnnotationPropertyParameter annotationPropertyParameter, AnnotationCompletionProviderParameter completionParameter) { String propertyName = annotationPropertyParameter.getPropertyName(); if(!annotationPropertyParameter.getType().equals(AnnotationPropertyParameter.Type.PROPERTY_VALUE) && propertyName == null) { return; } Set<String> values = new HashSet<>(); AnnotationUtil.visitAttributes(annotationPropertyParameter.getPhpClass(), (attributeName, type, target) -> { if(!attributeName.equals(propertyName)) { return null; } if (AnnotationPropertyEnum.fromString(type) == AnnotationPropertyEnum.BOOLEAN) { values.addAll(Arrays.asList("false", "true")); } // @Enum({"AUTO", "SEQUENCE"}) if (target instanceof Field) { PhpDocComment docComment = ((Field) target).getDocComment(); if(docComment != null) { PhpDocTag[] phpDocTags = docComment.getTagElementsByName("@Enum"); for(PhpDocTag phpDocTag: phpDocTags) { PhpPsiElement phpDocAttrList = phpDocTag.getFirstPsiChild(); if(phpDocAttrList != null) { String enumArrayString = phpDocAttrList.getText(); Pattern targetPattern = Pattern.compile("\"(\\w+)\""); Matcher matcher = targetPattern.matcher(enumArrayString); while (matcher.find()) { values.add(matcher.group(1)); } } } } } return null; }); for(String s: values) { completionParameter.getResult().addElement(LookupElementBuilder.create(s)); } }