本文整理汇总了Java中com.intellij.psi.impl.source.resolve.reference.impl.PsiMultiReference类的典型用法代码示例。如果您正苦于以下问题:Java PsiMultiReference类的具体用法?Java PsiMultiReference怎么用?Java PsiMultiReference使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PsiMultiReference类属于com.intellij.psi.impl.source.resolve.reference.impl包,在下文中一共展示了PsiMultiReference类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: findFileReference
import com.intellij.psi.impl.source.resolve.reference.impl.PsiMultiReference; //导入依赖的package包/类
@Nullable
public static FileReference findFileReference(@NotNull final PsiReference original) {
if (original instanceof PsiMultiReference) {
final PsiMultiReference multiReference = (PsiMultiReference)original;
for (PsiReference reference : multiReference.getReferences()) {
if (reference instanceof FileReference) {
return (FileReference)reference;
}
}
}
else if (original instanceof FileReferenceOwner) {
final PsiFileReference fileReference = ((FileReferenceOwner)original).getLastFileReference();
if (fileReference instanceof FileReference) {
return (FileReference)fileReference;
}
}
return null;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:FileReference.java
示例2: findReferenceAt
import com.intellij.psi.impl.source.resolve.reference.impl.PsiMultiReference; //导入依赖的package包/类
@Nullable
public static PsiReference findReferenceAt(PsiElement thisElement, int offset, @Nullable Language lang) {
if (thisElement == null) return null;
PsiElement element = lang != null ? thisElement.getContainingFile().getViewProvider().findElementAt(offset, lang) :
thisElement.findElementAt(offset);
if (element == null || element instanceof OuterLanguageElement) return null;
offset = thisElement.getTextRange().getStartOffset() + offset - element.getTextRange().getStartOffset();
List<PsiReference> referencesList = new ArrayList<PsiReference>();
while (element != null) {
addReferences(offset, element, referencesList);
offset = element.getStartOffsetInParent() + offset;
if (element instanceof PsiFile) break;
element = element.getParent();
}
if (referencesList.isEmpty()) return null;
if (referencesList.size() == 1) return referencesList.get(0);
return new PsiMultiReference(referencesList.toArray(new PsiReference[referencesList.size()]),
referencesList.get(referencesList.size() - 1).getElement());
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:SharedPsiElementImplUtil.java
示例3: getReference
import com.intellij.psi.impl.source.resolve.reference.impl.PsiMultiReference; //导入依赖的package包/类
@Nullable
private static Pair<FileReference, Boolean> getReference(final PsiReference original) {
if (original == null) {
return null;
}
if (original instanceof PsiMultiReference) {
final PsiMultiReference multiReference = (PsiMultiReference)original;
for (PsiReference reference : multiReference.getReferences()) {
if (reference instanceof FileReference) {
return Pair.create((FileReference) reference, false);
}
}
}
else if (original instanceof FileReferenceOwner) {
final PsiFileReference fileReference = ((FileReferenceOwner)original).getLastFileReference();
if (fileReference instanceof FileReference) {
return Pair.create((FileReference) fileReference, true);
}
}
return null;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:FilePathCompletionContributor.java
示例4: addReferenceAtCaret
import com.intellij.psi.impl.source.resolve.reference.impl.PsiMultiReference; //导入依赖的package包/类
protected void addReferenceAtCaret(Collection<PsiReference> refs) {
PsiFile myEditorFile = PsiDocumentManager.getInstance(myProject).getPsiFile(myEditor.getDocument());
// Note, that myEditorFile can be different from myElement.getContainingFile() e.g. in injections: myElement declaration in one
// file / usage in another !
final PsiReference reference = (myEditorFile != null ?
myEditorFile : myElementToRename.getContainingFile())
.findReferenceAt(myEditor.getCaretModel().getOffset());
if (reference instanceof PsiMultiReference) {
final PsiReference[] references = ((PsiMultiReference)reference).getReferences();
for (PsiReference ref : references) {
addReferenceIfNeeded(refs, ref);
}
}
else {
addReferenceIfNeeded(refs, reference);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:InplaceRefactoring.java
示例5: findReferenceAt
import com.intellij.psi.impl.source.resolve.reference.impl.PsiMultiReference; //导入依赖的package包/类
/**
* Overrides the findReferenceAt() logic in order to provide a resolve context with origin file for returned references.
* The findReferenceAt() is usually invoked from UI operations, and it helps to be able to do deeper analysis in the
* current file for such operations.
*
* @param offset the offset to find the reference at
* @return the reference or null.
*/
@Override
public PsiReference findReferenceAt(int offset) {
// copy/paste from SharedPsiElementImplUtil
PsiElement element = findElementAt(offset);
if (element == null || element instanceof OuterLanguageElement) return null;
offset = getTextRange().getStartOffset() + offset - element.getTextRange().getStartOffset();
List<PsiReference> referencesList = new ArrayList<PsiReference>();
final PsiFile file = element.getContainingFile();
final PyResolveContext resolveContext = file != null ?
PyResolveContext.defaultContext().withTypeEvalContext(TypeEvalContext.codeAnalysis(file.getProject(), file)) :
PyResolveContext.defaultContext();
while (element != null) {
addReferences(offset, element, referencesList, resolveContext);
offset = element.getStartOffsetInParent() + offset;
if (element instanceof PsiFile) break;
element = element.getParent();
}
if (referencesList.isEmpty()) return null;
if (referencesList.size() == 1) return referencesList.get(0);
return new PsiMultiReference(referencesList.toArray(new PsiReference[referencesList.size()]),
referencesList.get(referencesList.size() - 1).getElement());
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:33,代码来源:PyBaseElementImpl.java
示例6: findFileReference
import com.intellij.psi.impl.source.resolve.reference.impl.PsiMultiReference; //导入依赖的package包/类
@Nullable
private static FileReference findFileReference(@NotNull final PsiReference original) {
if (original instanceof PsiMultiReference) {
final PsiMultiReference multiReference = (PsiMultiReference)original;
for (PsiReference reference : multiReference.getReferences()) {
if (reference instanceof FileReference) {
return (FileReference)reference;
}
}
}
else if (original instanceof FileReferenceOwner) {
final PsiFileReference fileReference = ((FileReferenceOwner)original).getLastFileReference();
if (fileReference instanceof FileReference) {
return (FileReference)fileReference;
}
}
return null;
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:20,代码来源:ConvertAbsolutePathToRelativeIntentionAction.java
示例7: assertReference
import com.intellij.psi.impl.source.resolve.reference.impl.PsiMultiReference; //导入依赖的package包/类
protected void assertReference(PsiReference reference, String expectedText, String expectedFileName) {
assertNotNull("wrong cursor position", reference);
if (reference instanceof PsiMultiReference) {
for (PsiReference ref : ((PsiMultiReference)reference).getReferences()) {
if (ref instanceof RequirejsReference) {
reference = ref;
break;
}
}
}
if (!expectedText.startsWith("'")) {
expectedText = "'".concat(expectedText).concat("'");
}
assertInstanceOf(reference, RequirejsReference.class);
assertEquals(expectedText, reference.getCanonicalText());
PsiElement referenceElement = reference.resolve();
if (null == expectedFileName) {
assertNull(referenceElement);
} else {
assertNotNull("Not resolved", referenceElement);
assertInstanceOf(referenceElement, PsiFile.class);
assertEquals(expectedFileName, ((PsiFile) referenceElement).getName());
}
}
开发者ID:Fedott,项目名称:WebStormRequireJsPlugin,代码行数:27,代码来源:RequirejsTestCase.java
示例8: findFileReference
import com.intellij.psi.impl.source.resolve.reference.impl.PsiMultiReference; //导入依赖的package包/类
@Nullable
public static FileReference findFileReference(@Nonnull final PsiReference original) {
if (original instanceof PsiMultiReference) {
final PsiMultiReference multiReference = (PsiMultiReference)original;
for (PsiReference reference : multiReference.getReferences()) {
if (reference instanceof FileReference) {
return (FileReference)reference;
}
}
}
else if (original instanceof FileReferenceOwner) {
final PsiFileReference fileReference = ((FileReferenceOwner)original).getLastFileReference();
if (fileReference instanceof FileReference) {
return (FileReference)fileReference;
}
}
return null;
}
开发者ID:consulo,项目名称:consulo,代码行数:20,代码来源:FileReference.java
示例9: findReferenceAt
import com.intellij.psi.impl.source.resolve.reference.impl.PsiMultiReference; //导入依赖的package包/类
@Nullable
@RequiredReadAction
public static PsiReference findReferenceAt(PsiElement thisElement, int offset, @Nullable Language lang) {
if (thisElement == null) return null;
PsiElement element = lang != null ? thisElement.getContainingFile().getViewProvider().findElementAt(offset, lang) :
thisElement.findElementAt(offset);
if (element == null || element instanceof OuterLanguageElement) return null;
offset = thisElement.getTextRange().getStartOffset() + offset - element.getTextRange().getStartOffset();
List<PsiReference> referencesList = new ArrayList<PsiReference>();
while (element != null) {
addReferences(offset, element, referencesList);
if (element instanceof PsiFile) break;
if (element instanceof HintedReferenceHost &&
!((HintedReferenceHost)element).shouldAskParentForReferences(new PsiReferenceService.Hints(null, offset))) {
break;
}
offset = element.getStartOffsetInParent() + offset;
element = element.getParent();
}
if (referencesList.isEmpty()) return null;
if (referencesList.size() == 1) return referencesList.get(0);
return new PsiMultiReference(referencesList.toArray(new PsiReference[referencesList.size()]),
referencesList.get(referencesList.size() - 1).getElement());
}
开发者ID:consulo,项目名称:consulo,代码行数:27,代码来源:SharedPsiElementImplUtil.java
示例10: findJavaReference
import com.intellij.psi.impl.source.resolve.reference.impl.PsiMultiReference; //导入依赖的package包/类
@Nullable
private static PsiJavaReference findJavaReference(final PsiFile file, final int offset)
{
PsiReference reference = file.findReferenceAt(offset);
if(reference instanceof PsiMultiReference)
{
for(final PsiReference psiReference : ((PsiMultiReference) reference).getReferences())
{
if(psiReference instanceof PsiJavaReference)
{
return (PsiJavaReference) psiReference;
}
}
}
return reference instanceof PsiJavaReference ? (PsiJavaReference) reference : null;
}
开发者ID:consulo,项目名称:consulo-java,代码行数:17,代码来源:JavadocCompletionConfidence.java
示例11: findJavaReference
import com.intellij.psi.impl.source.resolve.reference.impl.PsiMultiReference; //导入依赖的package包/类
@Nullable
private static PsiJavaReference findJavaReference(final PsiFile file, final int offset) {
PsiReference reference = file.findReferenceAt(offset);
if (reference instanceof PsiMultiReference) {
for (final PsiReference psiReference : ((PsiMultiReference)reference).getReferences()) {
if (psiReference instanceof PsiJavaReference) {
return (PsiJavaReference)psiReference;
}
}
}
return reference instanceof PsiJavaReference ? (PsiJavaReference)reference : null;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:JavadocCompletionConfidence.java
示例12: findJavaClassReference
import com.intellij.psi.impl.source.resolve.reference.impl.PsiMultiReference; //导入依赖的package包/类
@Nullable
public static JavaClassReference findJavaClassReference(final PsiFile file, final int offset) {
PsiReference reference = file.findReferenceAt(offset);
if (reference instanceof PsiMultiReference) {
for (final PsiReference psiReference : ((PsiMultiReference)reference).getReferences()) {
if (psiReference instanceof JavaClassReference) {
return (JavaClassReference)psiReference;
}
}
}
return reference instanceof JavaClassReference ? (JavaClassReference)reference : null;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:JavaClassReferenceCompletionContributor.java
示例13: getReferences
import com.intellij.psi.impl.source.resolve.reference.impl.PsiMultiReference; //导入依赖的package包/类
protected static PsiReference[] getReferences(final PsiMultiReference multiReference) {
final PsiReference[] references = multiReference.getReferences();
final List<PsiReference> hard = ContainerUtil.findAll(references, new Condition<PsiReference>() {
@Override
public boolean value(final PsiReference object) {
return !object.isSoft();
}
});
if (!hard.isEmpty()) {
return hard.toArray(new PsiReference[hard.size()]);
}
return references;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:CompletionData.java
示例14: assertNoReferences
import com.intellij.psi.impl.source.resolve.reference.impl.PsiMultiReference; //导入依赖的package包/类
protected void assertNoReferences(VirtualFile file, Class refClass) throws IOException {
PsiReference ref = getReferenceAtCaret(file);
if (ref == null) return;
PsiReference[] refs = ref instanceof PsiMultiReference ? ((PsiMultiReference)ref).getReferences() : new PsiReference[]{ref};
for (PsiReference each : refs) {
assertFalse(each.toString(), refClass.isInstance(each));
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:MavenDomTestCase.java
示例15: getReference
import com.intellij.psi.impl.source.resolve.reference.impl.PsiMultiReference; //导入依赖的package包/类
@Nullable
@Override
public PsiReference getReference() {
final PsiReference[] references = getReferences();
if (references.length == 1) {
return references[0];
}
if (references.length > 1) {
return new PsiMultiReference(references, this);
}
return null;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:GrLiteralImpl.java
示例16: getElementByReference
import com.intellij.psi.impl.source.resolve.reference.impl.PsiMultiReference; //导入依赖的package包/类
/** Returns null in the cases where we're happy with the default behavior. */
@Nullable
@Override
public PsiElement getElementByReference(PsiReference ref, int flags) {
if (!(ref instanceof PsiMultiReference) || !(ref.getElement() instanceof StringLiteral)) {
return null;
}
// choose the outer-most reference
PsiReference[] refs = ((PsiMultiReference) ref).getReferences().clone();
Arrays.sort(refs, COMPARATOR);
return refs[0].resolve();
}
开发者ID:bazelbuild,项目名称:intellij,代码行数:13,代码来源:BuildTargetElementEvaluator.java
示例17: findReferencedClassForId
import com.intellij.psi.impl.source.resolve.reference.impl.PsiMultiReference; //导入依赖的package包/类
/**
* Given a PSI id element, find out if it -- or one of its parents --
* references a class, and, if so, returns the PSI element for the class.
*
* @param id A PSI element for an identifier (e.g. variable name).
* @return A PSI class element, or null if not found.
*/
@Nullable
public static HaxeClass findReferencedClassForId(@NotNull LeafPsiElement id) {
if (null == id) {
return null;
}
PsiReference found = id.findReferenceAt(0);
PsiElement resolved = null;
if (found instanceof PsiMultiReference) {
for (PsiReference ref : ((PsiMultiReference)found).getReferences()) {
PsiElement target = ref.resolve();
if (null != target && target instanceof PsiClass) {
resolved = target;
break;
}
}
}
else {
resolved = found.resolve();
}
if (LOG.isDebugEnabled()) {
LOG.debug("findReferencedClassForID found " + resolved);
}
return ((resolved instanceof HaxeClass) ? ((HaxeClass) resolved) : null);
}
开发者ID:HaxeFoundation,项目名称:intellij-haxe,代码行数:35,代码来源:HaxeHierarchyUtils.java
示例18: getReferences
import com.intellij.psi.impl.source.resolve.reference.impl.PsiMultiReference; //导入依赖的package包/类
protected static PsiReference[] getReferences(final PsiMultiReference multiReference) {
final PsiReference[] references = multiReference.getReferences();
final List<PsiReference> hard = ContainerUtil.findAll(references, object -> !object.isSoft());
if (!hard.isEmpty()) {
return hard.toArray(new PsiReference[hard.size()]);
}
return references;
}
开发者ID:consulo,项目名称:consulo,代码行数:9,代码来源:CompletionData.java
示例19: getReference
import com.intellij.psi.impl.source.resolve.reference.impl.PsiMultiReference; //导入依赖的package包/类
@Nullable
private static Pair<FileReference, Boolean> getReference(final PsiReference original) {
if (original == null) {
return null;
}
if (original instanceof PsiMultiReference) {
final PsiMultiReference multiReference = (PsiMultiReference)original;
for (PsiReference reference : multiReference.getReferences()) {
if (reference instanceof FileReference) {
if (((FileReference)reference).getFileReferenceSet().supportsExtendedCompletion()) {
return Pair.create((FileReference)reference, false);
}
}
}
}
else if (original instanceof FileReferenceOwner) {
final PsiFileReference fileReference = ((FileReferenceOwner)original).getLastFileReference();
if (fileReference instanceof FileReference) {
if (((FileReference)fileReference).getFileReferenceSet().supportsExtendedCompletion()) {
return Pair.create((FileReference)fileReference, true);
}
}
}
return null;
}
开发者ID:consulo,项目名称:consulo,代码行数:28,代码来源:FilePathCompletionContributor.java
示例20: getRealReference
import com.intellij.psi.impl.source.resolve.reference.impl.PsiMultiReference; //导入依赖的package包/类
@NotNull
private PsiPolyVariantReference getRealReference() {
PsiReference[] otherReferences = ReferenceProvidersRegistry.getReferencesFromProviders(this, PsiReferenceService.Hints.NO_HINTS);
PsiPolyVariantReference reference = getReferenceFromNamedArgumentProviders();
if (otherReferences.length == 0) {
if (reference != null) {
return reference;
}
else {
return new PsiPolyVariantReferenceBase<PsiElement>(this) {
@NotNull
@Override
public Object[] getVariants() {
return ArrayUtil.EMPTY_OBJECT_ARRAY;
}
@NotNull
@Override
public ResolveResult[] multiResolve(boolean incompleteCode) {
return ResolveResult.EMPTY_ARRAY;
}
};
}
}
else {
if (reference != null) {
PsiReference[] refs = new PsiReference[otherReferences.length + 1];
refs[0] = reference;
//noinspection ManualArrayCopy
for (int i = 0; i < otherReferences.length; i++) {
refs[i + 1] = otherReferences[i];
}
otherReferences = refs;
}
return new PsiMultiReference(otherReferences, this);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:42,代码来源:GrArgumentLabelImpl.java
注:本文中的com.intellij.psi.impl.source.resolve.reference.impl.PsiMultiReference类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论