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


Java PsiElementResolveResult类代码示例

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


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

示例1: multiResolve

import com.intellij.psi.PsiElementResolveResult; //导入依赖的package包/类
@NotNull
@Override
public ResolveResult[] multiResolve(final boolean incompleteCode) {
    Project project = myElement.getProject();
    final String enumLiteralJavaModelName = myElement.getText().replaceAll("\"", "").toUpperCase();

    final PsiShortNamesCache psiShortNamesCache = PsiShortNamesCache.getInstance(project);
    final PsiField[] javaEnumLiteralFields = psiShortNamesCache.getFieldsByName(
        enumLiteralJavaModelName, GlobalSearchScope.allScope(project)
    );

    final Set<PsiField> enumFields = stream(javaEnumLiteralFields)
        .filter(literal -> literal.getParent() != null)
        .filter(literal -> literal.getParent() instanceof ClsClassImpl)
        .filter(literal -> ((ClsClassImpl) literal.getParent()).isEnum())
        .collect(Collectors.toSet());

    return PsiElementResolveResult.createResults(enumFields);
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:20,代码来源:HybrisEnumLiteralItemReference.java

示例2: multiResolve

import com.intellij.psi.PsiElementResolveResult; //导入依赖的package包/类
@NotNull
@Override
public ResolveResult[] multiResolve(final boolean incompleteCode) {
    final Project project = myElement.getProject();
    final String modelName = PATTERN.matcher(myElement.getText()).replaceAll("");

    final String javaModelName = modelName + JAVA_MODEL_SUFFIX;
    final String jaloModelName = modelName;

    final PsiClass[] javaModelClasses = PsiShortNamesCache.getInstance(project).getClassesByName(
        javaModelName, GlobalSearchScope.allScope(project)
    );

    final PsiClass[] jaloModelClasses = PsiShortNamesCache.getInstance(project).getClassesByName(
        jaloModelName, GlobalSearchScope.projectScope(project)
    );

    final PsiClass[] psiClasses = ArrayUtil.mergeArrays(javaModelClasses, jaloModelClasses);
    return PsiElementResolveResult.createResults(psiClasses);
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:21,代码来源:HybrisModelItemReference.java

示例3: multiResolve

import com.intellij.psi.PsiElementResolveResult; //导入依赖的package包/类
@NotNull
@Override
public ResolveResult[] multiResolve(final boolean incompleteCode) {
    final PsiFile originalFile = getElement().getContainingFile();

    final Collection<ImpexMacroDeclaration> macroDeclarations =
        PsiTreeUtil.findChildrenOfType(
            originalFile,
            ImpexMacroDeclaration.class
        );

    if (!macroDeclarations.isEmpty()) {
        final ArrayList<PsiElement> references = ContainerUtil.newArrayList();
        for (final ImpexMacroDeclaration declaration : macroDeclarations) {
            if (getElement().textMatches(declaration.getFirstChild())) {
                references.add(declaration.getFirstChild());
            }
        }
        return PsiElementResolveResult.createResults(references);
    }
    return ResolveResult.EMPTY_ARRAY;
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:23,代码来源:ImpexMacrosReferenceBase.java

示例4: multiResolve

import com.intellij.psi.PsiElementResolveResult; //导入依赖的package包/类
@NotNull
@Override
public ResolveResult[] multiResolve(boolean incompleteCode) {
    String nodeTypeNameToFindReferenceFor = yamlElement.getKeyText();

    // files which contain the NodeType definition
    Collection<VirtualFile> files = FileBasedIndex.getInstance().getContainingFiles(NodeTypesYamlFileIndex.KEY, nodeTypeNameToFindReferenceFor, GlobalSearchScope.allScope(yamlElement.getProject()));

    return files
            .stream()
            // get the PSI for each file
            .map(file -> PsiManager.getInstance(yamlElement.getProject()).findFile(file))
            // ensure we only have YAML files
            .filter(psiFile -> psiFile instanceof YAMLFile)
            .map(psiFile -> (YAMLFile) psiFile)
            // get all YAML keys in these files
            .flatMap(yamlFile -> YAMLUtil.getTopLevelKeys(yamlFile).stream())
            // get the correct YAML key
            .filter(yamlKeyValue -> yamlKeyValue.getKeyText().equals(nodeTypeNameToFindReferenceFor))
            // remove "current" element if it exists
            .filter(yamlKeyValue -> yamlElement != yamlKeyValue)
            // build up the result object
            .map(yamlKeyValue -> new PsiElementResolveResult(yamlKeyValue, true))
            .toArray(PsiElementResolveResult[]::new);
}
 
开发者ID:cvette,项目名称:intellij-neos,代码行数:26,代码来源:NodeTypeReference.java

示例5: multiResolve

import com.intellij.psi.PsiElementResolveResult; //导入依赖的package包/类
@NotNull
@Override
public ResolveResult[] multiResolve(boolean incompleteCode) {
  final ResolveResult[] results = super.multiResolve(incompleteCode);
  boolean shadowed = false;
  for (ResolveResult result : results) {
    final PsiElement element = result.getElement();
    if (element != null && (element.getContainingFile() != myElement.getContainingFile() ||
                            element instanceof PyFunction || element instanceof PyClass)) {
      shadowed = true;
      break;
    }
  }
  if (results.length > 0 && !shadowed) {
    return results;
  }
  // resolve to self if no other target found
  return new ResolveResult[] { new PsiElementResolveResult(myElement) };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:PyTargetReference.java

示例6: multiResolve

import com.intellij.psi.PsiElementResolveResult; //导入依赖的package包/类
@NotNull
public ResolveResult[] multiResolve(@NotNull Project project) {
  List<ResolveResult> typeDefs =
      SchemaIndexUtil.findTypeDefs(project, prefixes, suffix, searchScope).stream()
      .filter(Objects::nonNull)
      .map(PsiElementResolveResult::new)
      .collect(Collectors.toList());

  // see comment in `resolve` above re. namespace declaration reference

  Qn prefix = input;
  int prefixLength = prefix.size();
  List<SchemaNamespaceDecl> namespaceDecls = resolveNamespaces(project, prefix);

  ResolveResult[] namespaces = namespaceDecls.stream()
      .map(ns -> new PsiElementResolveResult(getTargetSegment(ns, prefixLength)))
      .toArray(ResolveResult[]::new);

  return ArrayUtil.mergeArrays(typeDefs.toArray(new ResolveResult[typeDefs.size()]), namespaces);
}
 
开发者ID:SumoLogic,项目名称:epigraph,代码行数:21,代码来源:SchemaQnReferenceResolver.java

示例7: updateUI

import com.intellij.psi.PsiElementResolveResult; //导入依赖的package包/类
@Override
public void updateUI(Object p, @NotNull ParameterInfoUIContext context) {
    if (p instanceof PsiElementResolveResult) p = ((PsiElementResolveResult) p).getElement();
    if (!(p instanceof GLSLFunctionDeclaration)) return;
    GLSLFunctionDeclaration declaration = (GLSLFunctionDeclaration) p;
    GLSLParameterDeclaration[] parameters = declaration.getParameters();

    StringBuilder buffer = new StringBuilder();
    buffer.append(declaration.getType().getReturnType().getTypename())
            .append(' ').append(declaration.getName()).append('(');

    final int currentParameter = context.getCurrentParameterIndex();
    int highlightStartOffset = -1, highlightEndOffset = -1;

    for (int i = 0; i < parameters.length; i++) {
        if (i == currentParameter) highlightStartOffset = buffer.length();
        buffer.append(parameters[i].getText());
        if (i == currentParameter) highlightEndOffset = buffer.length();
        if (i < parameters.length - 1) buffer.append(", ");
    }
    buffer.append(')');

    context.setupUIComponentPresentation(buffer.toString(), highlightStartOffset, highlightEndOffset, false, false, false, context.getDefaultParameterColor());
}
 
开发者ID:Darkyenus,项目名称:glsl4idea,代码行数:25,代码来源:GLSLParameterInfoHandler.java

示例8: multiResolve

import com.intellij.psi.PsiElementResolveResult; //导入依赖的package包/类
@NotNull
@Override
public ResolveResult[] multiResolve(boolean incompleteCode) {
    XQueryFile file = (XQueryFile) myElement.getContainingFile();
    List<ResolveResult> results = new ArrayList<ResolveResult>();
    Collection<ResolveResult> primaryReferences = getPrimaryReferences();
    results.addAll(primaryReferences);
    if (shouldAddOtherReferences(primaryReferences)) {
        results.addAll(getReferencesFromNamespaceDeclarations(file.getNamespaceDeclarations()));
        results.addAll(getReferencesFromModuleImports(file.getModuleImports()));
        results.addAll(getReferencesFromModuleName(file.getModuleNamespaceName()));
    }
    if (results.isEmpty() && file.isPredeclaredNamespacePrefix(myElement.getText())) {
        results.add(new PsiElementResolveResult(getElement()));
    }
    return results.toArray(new ResolveResult[results.size()]);
}
 
开发者ID:ligasgr,项目名称:intellij-xquery,代码行数:18,代码来源:XQueryPrefixReference.java

示例9: multiResolve

import com.intellij.psi.PsiElementResolveResult; //导入依赖的package包/类
@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);
}
 
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:17,代码来源:ConstraintPropertyReference.java

示例10: getClassInterfaceResolveResult

import com.intellij.psi.PsiElementResolveResult; //导入依赖的package包/类
static public List<ResolveResult> getClassInterfaceResolveResult(Project project, String FQNClassOrInterfaceName) {

        PhpIndex phpIndex = PhpIndex.getInstance(project);
        Collection<PhpClass> phpClasses = phpIndex.getClassesByFQN(FQNClassOrInterfaceName);
        Collection<PhpClass> phpInterfaces = phpIndex.getInterfacesByFQN(FQNClassOrInterfaceName);

        List<ResolveResult> results = new ArrayList<ResolveResult>();
        for (PhpClass phpClass : phpClasses) {
            results.add(new PsiElementResolveResult(phpClass));
        }
        for (PhpClass phpInterface : phpInterfaces) {
            results.add(new PsiElementResolveResult(phpInterface));
        }

        return results;
    }
 
开发者ID:cmazx,项目名称:yiistorm,代码行数:17,代码来源:PhpElementsUtil.java

示例11: resolve

import com.intellij.psi.PsiElementResolveResult; //导入依赖的package包/类
@NotNull
@Override
public ResolveResult[] resolve(@NotNull PsiJavaModuleReference reference, boolean incompleteCode)
{
	PsiFile file = reference.getElement().getContainingFile();
	String moduleName = reference.getCanonicalText();
	Collection<PsiJavaModule> modules = findModules(file, moduleName, incompleteCode);
	if(!modules.isEmpty())
	{
		ResolveResult[] result = new ResolveResult[modules.size()];
		int i = 0;
		for(PsiJavaModule module : modules)
		{
			result[i++] = new PsiElementResolveResult(module);
		}
		return result;
	}
	else
	{
		return ResolveResult.EMPTY_ARRAY;
	}
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:23,代码来源:PsiJavaModuleReference.java

示例12: toCandidateInfoArray

import com.intellij.psi.PsiElementResolveResult; //导入依赖的package包/类
@NotNull
public static ResolveResult[] toCandidateInfoArray(@Nullable List<? extends PsiElement> elements) {
  if (elements == null) {
    return ResolveResult.EMPTY_ARRAY;
  }
  elements = ContainerUtil.filter(elements, (Condition<PsiElement>) Objects::nonNull);
  final ResolveResult[] result = new ResolveResult[elements.size()];
  for (int i = 0, size = elements.size(); i < size; i++) {
    result[i] = new PsiElementResolveResult(elements.get(i));
  }
  return result;
}
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:13,代码来源:AppleScriptResolveUtil.java

示例13: multiResolve

import com.intellij.psi.PsiElementResolveResult; //导入依赖的package包/类
@NotNull
@Override
public ResolveResult[] multiResolve(boolean incompleteCode) {
    ResolveResult[] resolveResults = new ResolveResult[targets.size()];

    int i = 0;
    for (PsiElement target : targets) {
        resolveResults[i++] = new PsiElementResolveResult(target);
    }
    return resolveResults;
}
 
开发者ID:magento,项目名称:magento2-phpstorm-plugin,代码行数:12,代码来源:PolyVariantReferenceBase.java

示例14: multiResolve

import com.intellij.psi.PsiElementResolveResult; //导入依赖的package包/类
@NotNull
private ResolveResult[] multiResolve() {
  final Collection<Variable> definitions =
      Scope.getScopeOrEmpty(this.getElement()).getVariables();
  List<ResolveResult> results = new ArrayList<>();
  for (Variable definition : definitions) {
    if (definition.name.equals(this.identifier)) {
      results.add(new PsiElementResolveResult(definition.element));
    }
  }

  return results.toArray(new ResolveResult[results.size()]);
}
 
开发者ID:google,项目名称:bamboo-soy,代码行数:14,代码来源:VariableReference.java

示例15: multiResolve

import com.intellij.psi.PsiElementResolveResult; //导入依赖的package包/类
@NotNull
@Override
public ResolveResult[] multiResolve(boolean incompleteCode) {
  return PsiElementResolveResult.createResults(
      TemplateNameUtils.findTemplateDeclarations(this.getElement(), templateName)
          .stream()
          .map(SoyTemplateBlock::getDefinitionIdentifier)
          .collect(Collectors.toList()));
}
 
开发者ID:google,项目名称:bamboo-soy,代码行数:10,代码来源:TemplateDefinitionReference.java


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