本文整理匯總了Java中com.intellij.psi.ResolveResult類的典型用法代碼示例。如果您正苦於以下問題:Java ResolveResult類的具體用法?Java ResolveResult怎麽用?Java ResolveResult使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ResolveResult類屬於com.intellij.psi包,在下文中一共展示了ResolveResult類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testReferenceCanResolveDefinition
import com.intellij.psi.ResolveResult; //導入依賴的package包/類
public void testReferenceCanResolveDefinition() {
PsiFile file = myFixture.configureByText(PhpFileType.INSTANCE, "<?php \n" +
"class ActionController {" +
"public function action() {" +
" $this->forward('<caret>baz');" +
"}" +
"}"
);
PsiElement elementAtCaret = file.findElementAt(myFixture.getCaretOffset()).getParent();
PsiReference[] references = elementAtCaret.getReferences();
for (PsiReference reference : references) {
if (reference instanceof ControllerActionReference) {
ResolveResult[] resolveResults = ((ControllerActionReference) reference).multiResolve(false);
for (ResolveResult resolveResult : resolveResults) {
assertInstanceOf(resolveResult.getElement(), Method.class);
return;
}
}
}
fail("No TranslationReference found");
}
示例2: testReferenceCanResolveDefinition
import com.intellij.psi.ResolveResult; //導入依賴的package包/類
public void testReferenceCanResolveDefinition() {
PsiFile file = myFixture.configureByText(PhpFileType.INSTANCE, "<?php \n" +
"\"LLL:EXT:foo/sample.xlf:sys_<caret>language.language_isocode.ab\";");
PsiElement elementAtCaret = file.findElementAt(myFixture.getCaretOffset()).getParent();
PsiReference[] references = elementAtCaret.getReferences();
for (PsiReference reference : references) {
if (reference instanceof TranslationReference) {
ResolveResult[] resolveResults = ((TranslationReference) reference).multiResolve(false);
for (ResolveResult resolveResult : resolveResults) {
assertInstanceOf(resolveResult.getElement(), XmlTag.class);
return;
}
}
}
fail("No TranslationReference found");
}
示例3: getResolvedProperty
import com.intellij.psi.ResolveResult; //導入依賴的package包/類
@Nullable
private static IProperty getResolvedProperty(@NotNull final XmlAttributeValue codeValue) {
return CachedValuesManager.getCachedValue(codeValue, KEY, () -> {
List<IProperty> allProperties = new SmartList<>();
for (PsiReference nextRef : codeValue.getReferences()) {
if (nextRef instanceof PsiPolyVariantReference) {
Arrays.stream(((PsiPolyVariantReference) nextRef).multiResolve(false))
.filter(ResolveResult::isValidResult)
.map(ResolveResult::getElement)
.map(o -> ObjectUtils.tryCast(o, IProperty.class))
.filter(Objects::nonNull)
.forEach(allProperties::add);
} else {
Optional.ofNullable(nextRef.resolve())
.map(o -> ObjectUtils.tryCast(o, IProperty.class))
.ifPresent(allProperties::add);
}
}
IProperty theChosenOne = chooseForLocale(allProperties);
return new CachedValueProvider.Result<>(theChosenOne, PsiModificationTracker.MODIFICATION_COUNT);
});
}
開發者ID:AlexanderBartash,項目名稱:hybris-integration-intellij-idea-plugin,代碼行數:24,代碼來源:JspPropertyFoldingBuilder.java
示例4: multiResolve
import com.intellij.psi.ResolveResult; //導入依賴的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
示例5: multiResolve
import com.intellij.psi.ResolveResult; //導入依賴的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
示例6: multiResolve
import com.intellij.psi.ResolveResult; //導入依賴的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
示例7: multiResolve
import com.intellij.psi.ResolveResult; //導入依賴的package包/類
@NotNull
public ResolveResult[] multiResolve(boolean incompleteCode) {
final String name = getName();
if (name == null) return ResolveResult.EMPTY_ARRAY;
ArrayList<LuaResolveResult> candidates = new ArrayList<LuaResolveResult>();
final PsiElement owner = LuaDocCommentUtil.findDocOwner(this);
if (owner instanceof LuaFunctionDefinition) {
final LuaFunctionDefinition method = (LuaFunctionDefinition)owner;
final LuaParameter[] parameters = method.getParameters().getLuaParameters();
for (LuaParameter parameter : parameters) {
if (name.equals(parameter.getName())) {
candidates.add(new LuaResolveResultImpl(parameter, true));
}
}
return candidates.toArray(new ResolveResult[candidates.size()]);
}
return ResolveResult.EMPTY_ARRAY;
}
示例8: multiResolve
import com.intellij.psi.ResolveResult; //導入依賴的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);
}
示例9: getPsiElement
import com.intellij.psi.ResolveResult; //導入依賴的package包/類
@Nullable
public PsiElement getPsiElement() {
Object o = getObject();
if (o instanceof PsiElement) {
return (PsiElement)o;
}
if (o instanceof ResolveResult) {
return ((ResolveResult)o).getElement();
}
if (o instanceof PsiElementNavigationItem) {
return ((PsiElementNavigationItem)o).getTargetElement();
}
if (o instanceof SmartPsiElementPointer) {
return ((SmartPsiElementPointer)o).getElement();
}
return null;
}
示例10: multiResolve
import com.intellij.psi.ResolveResult; //導入依賴的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) };
}
示例11: testToConstructorInherited
import com.intellij.psi.ResolveResult; //導入依賴的package包/類
public void testToConstructorInherited() {
ResolveResult[] targets = multiResolve();
assertEquals(2, targets.length); // to class, to init
PsiElement elt;
// class
elt = targets[0].getElement();
assertTrue(elt instanceof PyClass);
assertEquals("Bar", ((PyClass)elt).getName());
// init
elt = targets[1].getElement();
assertTrue(elt instanceof PyFunction);
PyFunction fun = (PyFunction)elt;
assertEquals(PyNames.INIT, fun.getName());
PyClass cls = fun.getContainingClass();
assertNotNull(cls);
assertEquals("Foo", cls.getName());
}
示例12: testResolveIncludedRef2
import com.intellij.psi.ResolveResult; //導入依賴的package包/類
public void testResolveIncludedRef2() throws Throwable {
myTestFixture.copyFileToProject("include.rng");
final PsiReference ref = myTestFixture.getReferenceAtCaretPositionWithAssertion("resolve-include-ref-2.rng");
assertTrue("PolyVariantRef", ref instanceof PsiPolyVariantReference);
final PsiElement element = ref.resolve();
assertNull(element);
final ResolveResult[] results = ((PsiPolyVariantReference)ref).multiResolve(false);
assertEquals(2, results.length);
for (ResolveResult result : results) {
PsiElement e = result.getElement();
assertTrue(e instanceof XmlTag);
final int contentLength = ((XmlTag)e).getSubTags().length;
if (e.getContainingFile() == ref.getElement().getContainingFile()) {
assertEquals(1, contentLength);
} else {
assertEquals(0, contentLength);
}
}
}
示例13: createResolveResult
import com.intellij.psi.ResolveResult; //導入依賴的package包/類
@NotNull
public ResolveResult createResolveResult() {
return new ResolveResult() {
@Nullable
@Override
public PsiElement getElement() {
// TODO: Try to find the item in the Gradle files
return null;
}
@Override
public boolean isValidResult() {
return false;
}
};
}
示例14: resolve
import com.intellij.psi.ResolveResult; //導入依賴的package包/類
@NotNull
public ResolveResult[] resolve(@NotNull AntDomPropertyReference antDomPropertyReference, boolean incompleteCode) {
final List<ResolveResult> result = new ArrayList<ResolveResult>();
final AntDomProject project = antDomPropertyReference.myInvocationContextElement.getParentOfType(AntDomProject.class, true);
if (project != null) {
final AntDomProject contextAntProject = project.getContextAntProject();
final String propertyName = antDomPropertyReference.getCanonicalText();
final Trinity<PsiElement,Collection<String>,PropertiesProvider> resolved =
PropertyResolver.resolve(contextAntProject, propertyName, antDomPropertyReference.myInvocationContextElement);
final PsiElement mainDeclaration = resolved.getFirst();
if (mainDeclaration != null) {
result.add(new MyResolveResult(mainDeclaration, resolved.getThird()));
}
final List<PsiElement> antCallParams = AntCallParamsFinder.resolve(project, propertyName);
for (PsiElement param : antCallParams) {
result.add(new MyResolveResult(param, null));
}
}
return ContainerUtil.toArray(result, new ResolveResult[result.size()]);
}
示例15: weigh
import com.intellij.psi.ResolveResult; //導入依賴的package包/類
@Override
public Integer weigh(@NotNull LookupElement element, @NotNull CompletionLocation location) {
if (!(location.getCompletionParameters().getPosition().getContainingFile() instanceof GroovyFileBase)) {
return null;
}
Object o = element.getObject();
if (o instanceof ResolveResult) {
o = ((ResolveResult)o).getElement();
}
if (o instanceof PsiMethod &&
(GroovyPropertyUtils.isSimplePropertyAccessor((PsiMethod)o) || "setProperty".equals(((PsiMethod)o).getName()))) {
return 1;
}
return 0;
}