Java Code Examples for com.intellij.psi.PsiElementResolveResult#createResults()

The following examples show how to use com.intellij.psi.PsiElementResolveResult#createResults() . 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: ConstraintPropertyReference.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
@NotNull
@Override
public ResolveResult[] multiResolve(boolean b) {

    List<PsiElement> psiElements = new ArrayList<>();

    String content = ((StringLiteralExpression) getElement()).getContents();
    for(Field field: constraintPhpClass.getFields()) {
        String name = field.getName();
        if(!field.isConstant() && field.getModifier().isPublic() && content.equals(name)) {
            psiElements.add(field);
        }
    }

    return PsiElementResolveResult.createResults(psiElements);
}
 
Example 2
Source File: ViewHelperReference.java    From idea-php-typo3-plugin with MIT License 6 votes vote down vote up
@NotNull
@Override
public ResolveResult[] multiResolve(boolean incompleteCode) {
    if (myElement instanceof FluidViewHelperReference) {
        FluidViewHelperExpr viewHelperExpr = (FluidViewHelperExpr) PsiTreeUtil.findFirstParent(myElement, e -> e instanceof FluidViewHelperExpr);
        String presentableName = viewHelperExpr.getPresentableName();
        ViewHelper viewHelperByName = ViewHelperUtil.getViewHelperByName(myElement, presentableName);
        if (viewHelperByName == null) {

            return ResolveResult.EMPTY_ARRAY;
        }

        return PsiElementResolveResult.createResults(PhpIndex.getInstance(myElement.getProject()).getClassesByFQN(viewHelperByName.fqn));
    }

    return ResolveResult.EMPTY_ARRAY;
}
 
Example 3
Source File: ContextReference.java    From idea-php-typo3-plugin with MIT License 5 votes vote down vote up
@NotNull
@Override
public ResolveResult[] multiResolve(boolean incompleteCode) {
    if (myElement instanceof StringLiteralExpression) {
        String aspectFQN = TYPO3Utility.getFQNByAspectName(((StringLiteralExpression) myElement).getContents());
        if (aspectFQN == null) {
            return ResolveResult.EMPTY_ARRAY;
        }

        return PsiElementResolveResult.createResults(PhpIndex.getInstance(myElement.getProject()).getClassesByFQN(aspectFQN));
    }

    return ResolveResult.EMPTY_ARRAY;
}
 
Example 4
Source File: ParameterXmlReference.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
@NotNull
@Override
public ResolveResult[] multiResolve(boolean incompleteCode) {
    Collection<PsiElement> targets = new ArrayList<>();

    targets.addAll(
        DotEnvUtil.getEnvironmentVariableTargetsForParameter(getElement().getProject(), this.parameterName)
    );

    targets.addAll(ServiceUtil.getServiceClassTargets(getElement().getProject(), this.parameterName));

    return PsiElementResolveResult.createResults(targets);
}
 
Example 5
Source File: AbstractServiceReference.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
@NotNull
@Override
public ResolveResult[] multiResolve(boolean incompleteCode) {
    ContainerCollectionResolver.ServiceCollector collector = ContainerCollectionResolver
        .ServiceCollector.create(getElement().getProject());

    // Return the PsiElement for the class corresponding to the serviceId
    String serviceClass = collector.resolve(serviceId);
    if (serviceClass == null) {
        return new ResolveResult[0];
    }

    return PsiElementResolveResult.createResults(PhpIndex.getInstance(getElement().getProject()).getAnyByFQN(serviceClass));
}
 
Example 6
Source File: FormUnderscoreMethodReference.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
@NotNull
@Override
public ResolveResult[] multiResolve(boolean incompleteCode) {
    String contents = getElement().getContents();
    if(org.apache.commons.lang.StringUtils.isBlank(contents)) {
        return new ResolveResult[0];
    }

    Collection<PsiElement> psiElements = new ArrayList<>();

    Set<String> methods = getCamelizeAndUnderscoreString(contents);

    // provide setter fallback for non model class or or unknown methods
    for (String value : methods) {
        Method method = phpClass.findMethodByName("set" + value);
        if (method != null) {
            psiElements.add(method);
        }
    }

    // property path
    psiElements.addAll(this.phpClass.getFields().stream()
        .filter(field -> !field.isConstant() && field.getModifier().isPublic() && methods.contains(field.getName()))
        .collect(Collectors.toList())
    );

    return PsiElementResolveResult.createResults(psiElements);
}
 
Example 7
Source File: ControllerReferenceProvider.java    From idea-php-shopware-plugin with MIT License 5 votes vote down vote up
@NotNull
@Override
public ResolveResult[] multiResolve(boolean b) {
    final List<PsiElement> targets = new ArrayList<>();

    ShopwareUtil.collectControllerClass(getElement().getProject(), (phpClass, moduleName1, controllerName) -> {
        if (controllerName.equalsIgnoreCase(content)) {
            targets.add(phpClass);
        }
    }, moduleName);

    return PsiElementResolveResult.createResults(targets);
}
 
Example 8
Source File: ControllerActionReferenceProvider.java    From idea-php-shopware-plugin with MIT License 5 votes vote down vote up
@NotNull
@Override
public ResolveResult[] multiResolve(boolean b) {
    final List<PsiElement> targets = new ArrayList<>();

    ShopwareUtil.collectControllerAction(getElement().getProject(), this.controllerName, (method, methodStripped, moduleName1, controllerName1) -> {
        if (methodStripped.equalsIgnoreCase(content)) {
            targets.add(method);
        }
    }, moduleName);

    return PsiElementResolveResult.createResults(targets);
}
 
Example 9
Source File: TemplateDefinitionReference.java    From bamboo-soy with Apache License 2.0 5 votes vote down vote up
@NotNull
@Override
public ResolveResult[] multiResolve(boolean incompleteCode) {
  return PsiElementResolveResult.createResults(
      TemplateNameUtils.findTemplateDeclarations(this.getElement(), templateName)
          .stream()
          .map(SoyTemplateBlock::getDefinitionIdentifier)
          .collect(Collectors.toList()));
}
 
Example 10
Source File: ClassPublicMethodReference.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
@NotNull
@Override
public ResolveResult[] multiResolve(boolean incompleteCode) {
    PhpClass phpClass = ServiceUtil.getResolvedClassDefinition(getElement().getProject(), this.className);
    if(phpClass == null) {
        return new ResolveResult[0];
    }

    Method targetMethod = phpClass.findMethodByName(this.method);
    if(targetMethod == null) {
        return new ResolveResult[0];
    }

    return PsiElementResolveResult.createResults(targetMethod);
}
 
Example 11
Source File: DoctrinePhpClassFieldReference.java    From idea-php-annotation-plugin with MIT License 5 votes vote down vote up
@NotNull
@Override
public ResolveResult[] multiResolve(boolean b) {
    List<PsiElement> psiElementList = this.phpClass.getFields().stream()
        .filter(field -> !field.isConstant() && content.equals(field.getName()))
        .collect(Collectors.toList());

    return PsiElementResolveResult.createResults(psiElementList);
}
 
Example 12
Source File: ConstantXmlReference.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
@NotNull
@Override
public ResolveResult[] multiResolve(boolean incompleteCode) {
    String contents = getElement().getValue();
    if(StringUtils.isBlank(contents)) {
        return new ResolveResult[0];
    }

    return PsiElementResolveResult.createResults(
        ServiceContainerUtil.getTargetsForConstant(getElement().getProject(), contents)
    );
}
 
Example 13
Source File: IconReference.java    From idea-php-typo3-plugin with MIT License 4 votes vote down vote up
@NotNull
@Override
public ResolveResult[] multiResolve(boolean incompleteCode) {
    return PsiElementResolveResult.createResults(IconIndex.getIconDefinitionElements(myElement.getProject(), iconName));
}
 
Example 14
Source File: SQFCommandReference.java    From arma-intellij-plugin with MIT License 4 votes vote down vote up
public SQFCommandReference(@NotNull SQFCommand command, @NotNull List<SQFCommand> targets) {
	this.command = command;
	this.targets = targets;

	resolveResults = PsiElementResolveResult.createResults(targets);
}
 
Example 15
Source File: SQFCommandReference.java    From arma-intellij-plugin with MIT License 4 votes vote down vote up
public SQFCommandReference(@NotNull SQFCommand command, @NotNull List<SQFCommand> targets) {
	this.command = command;
	this.targets = targets;

	resolveResults = PsiElementResolveResult.createResults(targets);
}
 
Example 16
Source File: TableReference.java    From idea-php-typo3-plugin with MIT License 4 votes vote down vote up
@NotNull
@Override
public ResolveResult[] multiResolve(boolean incompleteCode) {
    return PsiElementResolveResult.createResults(getTableDefinitionElements(tablename, myElement.getProject()));
}
 
Example 17
Source File: TranslationReference.java    From idea-php-typo3-plugin with MIT License 4 votes vote down vote up
@NotNull
@Override
public ResolveResult[] multiResolve(boolean incompleteCode) {
    return PsiElementResolveResult.createResults(TranslationUtil.findDefinitionElements(myElement.getProject(), translationId));
}
 
Example 18
Source File: EntityReference.java    From idea-php-symfony2-plugin with MIT License 4 votes vote down vote up
@NotNull
@Override
public ResolveResult[] multiResolve(boolean incompleteCode) {
    return PsiElementResolveResult.createResults(EntityHelper.getModelPsiTargets(getElement().getProject(), this.entityName));
}
 
Example 19
Source File: TagReference.java    From idea-php-symfony2-plugin with MIT License 4 votes vote down vote up
@NotNull
@Override
public ResolveResult[] multiResolve(boolean incompleteCode) {
    return PsiElementResolveResult.createResults(ServiceUtil.getTaggedClassesWithCompiled(getElement().getProject(), this.tagName));
}
 
Example 20
Source File: RouteReference.java    From idea-php-typo3-plugin with MIT License 4 votes vote down vote up
@NotNull
@Override
public ResolveResult[] multiResolve(boolean incompleteCode) {
    return PsiElementResolveResult.createResults(RouteHelper.getRouteDefinitionElements(myElement.getProject(), routeName));
}