de.espend.idea.php.annotation.extension.parameter.AnnotationPropertyParameter Java Examples

The following examples show how to use de.espend.idea.php.annotation.extension.parameter.AnnotationPropertyParameter. 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: ClassCompletionProviderAbstract.java    From idea-php-annotation-plugin with MIT License 6 votes vote down vote up
@Nullable
@Override
public PsiReference[] getPropertyReferences(AnnotationPropertyParameter parameter, PhpAnnotationReferenceProviderParameter referencesByElementParameter) {
    if(!supports(parameter)) {
        return new PsiReference[0];
    }

    PsiElement element = parameter.getElement();
    if(!(element instanceof StringLiteralExpression) || StringUtils.isBlank(((StringLiteralExpression) element).getContents())) {
        return new PsiReference[0];
    }

    return new PsiReference[] {
        new PhpClassReference((StringLiteralExpression) element)
    };
}
 
Example #2
Source File: AnnotationClassProvider.java    From idea-php-annotation-plugin with MIT License 6 votes vote down vote up
@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 #3
Source File: AnnotationPropertyValueReferenceContributor.java    From idea-php-annotation-plugin with MIT License 6 votes vote down vote up
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement psiElement, @NotNull ProcessingContext processingContext) {
    PhpClass phpClass = getValidAnnotationClass(psiElement);
    if(phpClass == null) {
        return new PsiReference[0];
    }

    PsiElement propertyName = PhpElementsUtil.getPrevSiblingOfPatternMatch(psiElement, PlatformPatterns.psiElement(PhpDocTokenTypes.DOC_IDENTIFIER));
    if(propertyName == null) {
        return new PsiReference[0];
    }

    AnnotationPropertyParameter annotationPropertyParameter = new AnnotationPropertyParameter(psiElement, phpClass, propertyName.getText(), AnnotationPropertyParameter.Type.PROPERTY_VALUE);
    return addPsiReferences(psiElement, processingContext, annotationPropertyParameter);

}
 
Example #4
Source File: AnnotationCompletionContributor.java    From idea-php-annotation-plugin with MIT License 6 votes vote down vote up
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result) {
    PsiElement psiElement = parameters.getOriginalPosition();
    if(psiElement == null) {
        return;
    }

    PhpDocTag phpDocTag = PsiTreeUtil.getParentOfType(parameters.getOriginalPosition(), PhpDocTag.class);
    PhpClass phpClass = AnnotationUtil.getAnnotationReference(phpDocTag);
    if(phpClass == null) {
        return;
    }

    AnnotationPropertyParameter annotationPropertyParameter = new AnnotationPropertyParameter(parameters.getOriginalPosition(), phpClass, AnnotationPropertyParameter.Type.DEFAULT);
    providerWalker(parameters, context, result, annotationPropertyParameter);

}
 
Example #5
Source File: DoctrineAnnotationTypeProvider.java    From idea-php-annotation-plugin with MIT License 6 votes vote down vote up
@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: DoctrineAnnotationFieldTypeProvider.java    From idea-php-annotation-plugin with MIT License 6 votes vote down vote up
@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 #7
Source File: ColumnNameCompletionProvider.java    From idea-php-annotation-plugin with MIT License 6 votes vote down vote up
@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 #8
Source File: DoctrineAnnotationStaticCompletionProvider.java    From idea-php-annotation-plugin with MIT License 6 votes vote down vote up
@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 #9
Source File: TemplateAnnotationReferences.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
@Nullable
@Override
public PsiReference[] getPropertyReferences(AnnotationPropertyParameter annotationPropertyParameter, PhpAnnotationReferenceProviderParameter phpAnnotationReferenceProviderParameter) {

    if(!Symfony2ProjectComponent.isEnabled(annotationPropertyParameter.getProject()) || !(annotationPropertyParameter.getElement() instanceof StringLiteralExpression) || !PhpElementsUtil.isEqualClassName(annotationPropertyParameter.getPhpClass(), TwigUtil.TEMPLATE_ANNOTATION_CLASS)) {
        return new PsiReference[0];
    }

    if(annotationPropertyParameter.getType() == AnnotationPropertyParameter.Type.DEFAULT) {
        // @Foo("template.html.twig")
        return new PsiReference[]{ new TemplateReference((StringLiteralExpression) annotationPropertyParameter.getElement()) };
    } else if(annotationPropertyParameter.getType() == AnnotationPropertyParameter.Type.PROPERTY_VALUE || "template".equals(annotationPropertyParameter.getPropertyName())) {
        // @Foo(template="template.html.twig")
        return new PsiReference[]{ new TemplateReference((StringLiteralExpression) annotationPropertyParameter.getElement()) };
    }

    return new PsiReference[0];
}
 
Example #10
Source File: IsGrantedAnnotationReferences.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
@Nullable
@Override
public PsiReference[] getPropertyReferences(AnnotationPropertyParameter annotationPropertyParameter, PhpAnnotationReferenceProviderParameter phpAnnotationReferenceProviderParameter) {
    Project project = annotationPropertyParameter.getProject();
    if(!Symfony2ProjectComponent.isEnabled(project) || !(annotationPropertyParameter.getElement() instanceof StringLiteralExpression) || !PhpElementsUtil.isEqualClassName(annotationPropertyParameter.getPhpClass(), IS_GRANTED_CLASS)) {
        return new PsiReference[0];
    }

    if(annotationPropertyParameter.getType() != AnnotationPropertyParameter.Type.DEFAULT) {
        return new PsiReference[0];
    }

    return new PsiReference[] {
        new VoterReference(((StringLiteralExpression) annotationPropertyParameter.getElement()))
    };
}
 
Example #11
Source File: ConfigEntityTypeAnnotation.java    From idea-php-drupal-symfony2-bridge with MIT License 6 votes vote down vote up
@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 #12
Source File: DoctrineAnnotationTargetEntityReferences.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
@Nullable
@Override
public PsiReference[] getPropertyReferences(AnnotationPropertyParameter annotationPropertyParameter, PhpAnnotationReferenceProviderParameter phpAnnotationReferenceProviderParameter) {

    if(!Symfony2ProjectComponent.isEnabled(annotationPropertyParameter.getProject()) || !(annotationPropertyParameter.getElement() instanceof StringLiteralExpression) || !PhpElementsUtil.isEqualClassName(annotationPropertyParameter.getPhpClass(),
        "\\Doctrine\\ORM\\Mapping\\ManyToOne",
        "\\Doctrine\\ORM\\Mapping\\ManyToMany",
        "\\Doctrine\\ORM\\Mapping\\OneToOne",
        "\\Doctrine\\ORM\\Mapping\\OneToMany")
        )
    {
        return new PsiReference[0];
    }

    // @Foo(targetEntity="Foo\Class")
    if(annotationPropertyParameter.getType() == AnnotationPropertyParameter.Type.PROPERTY_VALUE && "targetEntity".equals(annotationPropertyParameter.getPropertyName())) {
        return new PsiReference[]{ new EntityReference((StringLiteralExpression) annotationPropertyParameter.getElement(), true) };
    }

    return new PsiReference[0];
}
 
Example #13
Source File: SymfonyAnnotationReferences.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
@Nullable
@Override
public PsiReference[] getPropertyReferences(AnnotationPropertyParameter annotationPropertyParameter, PhpAnnotationReferenceProviderParameter phpAnnotationReferenceProviderParameter) {

    if(!Symfony2ProjectComponent.isEnabled(annotationPropertyParameter.getProject()) || !(annotationPropertyParameter.getElement() instanceof StringLiteralExpression)) {
        return new PsiReference[0];
    }

    if("service".equals(annotationPropertyParameter.getPropertyName()) && PhpElementsUtil.isEqualClassName(annotationPropertyParameter.getPhpClass(), "\\Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\Route")) {
        return new PsiReference[]{ new ServiceReference((StringLiteralExpression) annotationPropertyParameter.getElement(), false) };
    }

    // JMSDiExtraBundle; @TODO: provide config
    if((annotationPropertyParameter.getType() == AnnotationPropertyParameter.Type.DEFAULT || "id".equals(annotationPropertyParameter.getPropertyName())) && PhpElementsUtil.isEqualClassName(annotationPropertyParameter.getPhpClass(), "\\JMS\\DiExtraBundle\\Annotation\\Service")) {
        return new PsiReference[]{ new ServiceReference((StringLiteralExpression) annotationPropertyParameter.getElement(), false) };
    }

    if((annotationPropertyParameter.getType() == AnnotationPropertyParameter.Type.DEFAULT) && PhpElementsUtil.isEqualClassName(annotationPropertyParameter.getPhpClass(), "\\JMS\\DiExtraBundle\\Annotation\\Inject")) {
        return new PsiReference[]{ new ServiceReference((StringLiteralExpression) annotationPropertyParameter.getElement(), false) };
    }

    if("class".equals(annotationPropertyParameter.getPropertyName()) && PhpElementsUtil.isEqualClassName(annotationPropertyParameter.getPhpClass(), "\\Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\ParamConverter")) {
        return new PsiReference[]{ new PhpClassReference((StringLiteralExpression) annotationPropertyParameter.getElement(), true).setUseClasses(true).setUseInterfaces(true) };
    }

    return new PsiReference[0];
}
 
Example #14
Source File: AnnotationPropertyValueReferenceContributor.java    From idea-php-annotation-plugin with MIT License 5 votes vote down vote up
private PsiReference[] addPsiReferences(PsiElement psiElement, ProcessingContext processingContext, AnnotationPropertyParameter annotationPropertyParameter) {
    ArrayList<PsiReference> psiReferences = new ArrayList<>();

    PhpAnnotationReferenceProviderParameter referencesByElementParameter = new PhpAnnotationReferenceProviderParameter(psiElement, processingContext);

    for(PhpAnnotationReferenceProvider phpAnnotationExtension : AnnotationUtil.EXTENSION_POINT_REFERENCES.getExtensions()) {
        PsiReference[] references = phpAnnotationExtension.getPropertyReferences(annotationPropertyParameter, referencesByElementParameter);
        if(references != null && references.length > 0) {
            psiReferences.addAll(Arrays.asList(references));
        }
    }

    return psiReferences.toArray(new PsiReference[psiReferences.size()]);
}
 
Example #15
Source File: AnnotationPropertyValueReferenceContributor.java    From idea-php-annotation-plugin with MIT License 5 votes vote down vote up
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement psiElement, @NotNull ProcessingContext processingContext) {
    PhpClass phpClass = getValidAnnotationClass(psiElement);
    if(phpClass == null) {
        return new PsiReference[0];
    }

    AnnotationPropertyParameter annotationPropertyParameter = new AnnotationPropertyParameter(psiElement, phpClass, AnnotationPropertyParameter.Type.DEFAULT);
    return addPsiReferences(psiElement, processingContext, annotationPropertyParameter);

}
 
Example #16
Source File: AnnotationCompletionContributor.java    From idea-php-annotation-plugin with MIT License 5 votes vote down vote up
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result) {
    PsiElement psiElement = parameters.getOriginalPosition();
    if(psiElement == null) {
        return;
    }

    PsiElement phpDocString = psiElement.getContext();
    if(!(phpDocString instanceof StringLiteralExpression)) {
        return;
    }

    PsiElement propertyName = PhpElementsUtil.getPrevSiblingOfPatternMatch(phpDocString, PlatformPatterns.psiElement(PhpDocTokenTypes.DOC_IDENTIFIER));
    if(propertyName == null) {
        return;
    }

    PhpDocTag phpDocTag = PsiTreeUtil.getParentOfType(parameters.getOriginalPosition(), PhpDocTag.class);
    PhpClass phpClass = AnnotationUtil.getAnnotationReference(phpDocTag);
    if(phpClass == null) {
        return;
    }

    AnnotationPropertyParameter annotationPropertyParameter = new AnnotationPropertyParameter(parameters.getOriginalPosition(), phpClass, propertyName.getText(), AnnotationPropertyParameter.Type.PROPERTY_VALUE);
    providerWalker(parameters, context, result, annotationPropertyParameter);

}
 
Example #17
Source File: AnnotationCompletionContributor.java    From idea-php-annotation-plugin with MIT License 5 votes vote down vote up
private void providerWalker(CompletionParameters parameters, ProcessingContext context, CompletionResultSet result, AnnotationPropertyParameter annotationPropertyParameter) {
    AnnotationCompletionProviderParameter completionParameter = new AnnotationCompletionProviderParameter(parameters, context, result);

    for(PhpAnnotationCompletionProvider phpAnnotationExtension : AnnotationUtil.EXTENSION_POINT_COMPLETION.getExtensions()) {
        phpAnnotationExtension.getPropertyValueCompletions(annotationPropertyParameter, completionParameter);
    }
}
 
Example #18
Source File: AnnotationCompletionContributor.java    From idea-php-annotation-plugin with MIT License 5 votes vote down vote up
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result) {
    PsiElement psiElement = parameters.getOriginalPosition();
    if(psiElement == null) {
        return;
    }

    PsiElement parent = psiElement.getParent();
    if(!(parent instanceof StringLiteralExpression)) {
        return;
    }

    PhpDocTag phpDocTag = PsiTreeUtil.getParentOfType(parameters.getOriginalPosition(), PhpDocTag.class);
    PhpClass phpClass = AnnotationUtil.getAnnotationReference(phpDocTag);
    if(phpClass == null) {
        return;
    }

    PsiElement propertyForEnum = AnnotationUtil.getPropertyForArray((StringLiteralExpression) parent);
    if(propertyForEnum == null) {
        return;
    }

    AnnotationPropertyParameter annotationPropertyParameter = new AnnotationPropertyParameter(
        parameters.getOriginalPosition(),
        phpClass,
        propertyForEnum.getText(),
        AnnotationPropertyParameter.Type.PROPERTY_ARRAY
    );

    providerWalker(parameters, context, result, annotationPropertyParameter);
}
 
Example #19
Source File: TranslationAnnotationReference.java    From idea-php-drupal-symfony2-bridge with MIT License 5 votes vote down vote up
@Override
public void getPropertyValueCompletions(AnnotationPropertyParameter parameter, AnnotationCompletionProviderParameter annotationCompletionProviderParameter) {
    if(!isSupported(parameter)) {
        return;
    }

    TranslationUtil.attachGetTextLookupKeys(annotationCompletionProviderParameter.getResult(), parameter.getProject());
}
 
Example #20
Source File: EmbeddedClassCompletionProvider.java    From idea-php-annotation-plugin with MIT License 5 votes vote down vote up
@Override
boolean supports(AnnotationPropertyParameter parameter) {
    return
        parameter.getType() == AnnotationPropertyParameter.Type.PROPERTY_VALUE &&
        "class".equals(parameter.getPropertyName()) &&
        PhpLangUtil.equalsClassNames(StringUtils.stripStart(parameter.getPhpClass().getFQN(), "\\"), "Doctrine\\ORM\\Mapping\\Embedded");
}
 
Example #21
Source File: DoctrineAnnotationFieldProvider.java    From idea-php-annotation-plugin with MIT License 5 votes vote down vote up
@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 #22
Source File: ContentEntityTypeAnnotation.java    From idea-php-drupal-symfony2-bridge with MIT License 5 votes vote down vote up
@Override
public void getPropertyValueCompletions(AnnotationPropertyParameter parameter, AnnotationCompletionProviderParameter completionProviderParameter) {
    if(!isSupported(parameter)) {
        return;
    }

    if("field_ui_base_route".equalsIgnoreCase(parameter.getPropertyName())) {
        completionProviderParameter.getResult().addAllElements(RouteHelper.getRoutesLookupElements(parameter.getProject()));
    }

    if("admin_permission".equalsIgnoreCase(parameter.getPropertyName())) {
        completionProviderParameter.getResult().addAllElements(IndexUtil.getIndexedKeyLookup(parameter.getProject(), PermissionIndex.KEY));
    }
}
 
Example #23
Source File: DoctrineCustomIdGenerator.java    From idea-php-annotation-plugin with MIT License 5 votes vote down vote up
@Override
boolean supports(AnnotationPropertyParameter parameter) {
    return
        parameter.getType() == AnnotationPropertyParameter.Type.PROPERTY_VALUE &&
        "class".equals(parameter.getPropertyName()) &&
        PhpLangUtil.equalsClassNames(StringUtils.stripStart(parameter.getPhpClass().getFQN(), "\\"), "Doctrine\\ORM\\Mapping\\CustomIdGenerator");
}
 
Example #24
Source File: ClassCompletionProviderAbstract.java    From idea-php-annotation-plugin with MIT License 5 votes vote down vote up
@Override
public void getPropertyValueCompletions(AnnotationPropertyParameter parameter, AnnotationCompletionProviderParameter completionParameter) {
    if(!supports(parameter)) {
        return;
    }

    String className = "";
    PsiElement element = parameter.getElement();
    if(element instanceof StringLiteralExpression) {
        className = ((StringLiteralExpression) element).getContents();
    }

    PhpIndex phpIndex = PhpIndex.getInstance(parameter.getProject());
    PhpCompletionUtil.addClasses(className, completionParameter.getResult(), phpIndex, null);
}
 
Example #25
Source File: ConfigEntityTypeAnnotation.java    From idea-php-drupal-symfony2-bridge with MIT License 5 votes vote down vote up
@Override
public void getPropertyValueCompletions(AnnotationPropertyParameter parameter, AnnotationCompletionProviderParameter completionProviderParameter) {
    if(!isSupported(parameter)) {
        return;
    }

    if("admin_permission".equalsIgnoreCase(parameter.getPropertyName())) {
        completionProviderParameter.getResult().addAllElements(IndexUtil.getIndexedKeyLookup(parameter.getProject(), PermissionIndex.KEY));
    }
}
 
Example #26
Source File: SymfonyCompletionProvider.java    From idea-php-annotation-plugin with MIT License 5 votes vote down vote up
@Override
public void getPropertyValueCompletions(AnnotationPropertyParameter parameter, AnnotationCompletionProviderParameter completion) {
    if(parameter.getType() != AnnotationPropertyParameter.Type.PROPERTY_ARRAY) {
        return;
    }

    if("methods".equals(parameter.getPropertyName()) && PhpLangUtil.equalsClassNames(StringUtils.stripStart(parameter.getPhpClass().getFQN(), "\\"), "Symfony\\Component\\Routing\\Annotation\\Route")) {
        for (String s : new String[]{"HEAD", "GET", "POST", "PUT", "PATCH", "DELETE", "PURGE", "OPTIONS", "TRACE", "CONNECT"}) {
            completion.getResult().addElement(LookupElementBuilder.create(s));
        }
    }
}
 
Example #27
Source File: TranslationAnnotationReference.java    From idea-php-drupal-symfony2-bridge with MIT License 4 votes vote down vote up
private boolean isSupported(@NotNull AnnotationPropertyParameter parameter) {
    return parameter.getType() == AnnotationPropertyParameter.Type.DEFAULT &&
        PhpLangUtil.equalsClassNames(StringUtils.stripStart(parameter.getPhpClass().getFQN(), "\\"), "Drupal\\Core\\Annotation\\Translation");
}
 
Example #28
Source File: PhpAnnotationTypeCompletionProvider.java    From idea-php-annotation-plugin with MIT License 4 votes vote down vote up
@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));
    }
}
 
Example #29
Source File: ContentEntityTypeAnnotation.java    From idea-php-drupal-symfony2-bridge with MIT License 4 votes vote down vote up
private boolean isSupported(@NotNull AnnotationPropertyParameter parameter) {
    return parameter.getType() != AnnotationPropertyParameter.Type.DEFAULT &&
        PhpLangUtil.equalsClassNames(StringUtils.stripStart(parameter.getPhpClass().getFQN(), "\\"), "Drupal\\Core\\Entity\\Annotation\\ContentEntityType");
}
 
Example #30
Source File: PhpAnnotationReferenceProvider.java    From idea-php-annotation-plugin with MIT License 4 votes vote down vote up
@Nullable
PsiReference[] getPropertyReferences(AnnotationPropertyParameter annotationPropertyParameter, PhpAnnotationReferenceProviderParameter referencesByElementParameter);