本文整理汇总了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);
}
示例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) };
}
示例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);
}
示例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());
}
示例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()]);
}
示例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);
}
示例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;
}
示例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;
}
}
示例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;
}
示例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;
}
示例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()]);
}
示例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()));
}