當前位置: 首頁>>代碼示例>>Java>>正文


Java PsiReferenceBase類代碼示例

本文整理匯總了Java中com.intellij.psi.PsiReferenceBase的典型用法代碼示例。如果您正苦於以下問題:Java PsiReferenceBase類的具體用法?Java PsiReferenceBase怎麽用?Java PsiReferenceBase使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


PsiReferenceBase類屬於com.intellij.psi包,在下文中一共展示了PsiReferenceBase類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getReferencesByElement

import com.intellij.psi.PsiReferenceBase; //導入依賴的package包/類
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element,
                                             @NotNull MavenDomConfiguration domCfg,
                                             @NotNull ProcessingContext context) {
  return new PsiReference[] {
    new PsiReferenceBase<PsiElement>(element, true) {
      @Override
      public PsiElement resolve() {
        return null;
      }

      @NotNull
      @Override
      public Object[] getVariants() {
        return MavenCompletionReferenceProvider.this.getVariants(this);
      }
    }
  };
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:20,代碼來源:MavenCompletionReferenceProvider.java

示例2: getReferencesByElement

import com.intellij.psi.PsiReferenceBase; //導入依賴的package包/類
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {
  return new PsiReference[]{
    new PsiReferenceBase<PsiElement>(element, mySoft) {
      @Nullable
      @Override
      public PsiElement resolve() {
        return null;
      }

      @NotNull
      @Override
      public Object[] getVariants() {
        return myValues;
      }
    }
  };
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:20,代碼來源:FixedValuesReferenceProvider.java

示例3: getReferencesByElement

import com.intellij.psi.PsiReferenceBase; //導入依賴的package包/類
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement psiElement, @NotNull ProcessingContext processingContext) {
    if (!isApplicable(psiElement)) {
        return new PsiReference[]{};
    }

    PhpIndex phpIndex = PhpIndex.getInstance(psiElement.getProject());
    Collection<PhpClass> phpClasses = phpIndex.getClassesByFQN(OuzoUtils.OUZO_MODEL_NAMESPACE + PsiUtils.getContent(psiElement));
    PhpClass phpClass = Iterables.getLast(phpClasses, null);

    if (phpClass == null) {
        return new PsiReference[]{};
    }

    PsiReferenceBase.Immediate reference = new PsiReferenceBase.Immediate(psiElement, phpClass);
    return new PsiReference[]{reference};
}
 
開發者ID:letsdrink,項目名稱:ouzo-phpstorm-plugin,代碼行數:19,代碼來源:RelationClassReferenceProvider.java

示例4: getReference

import com.intellij.psi.PsiReferenceBase; //導入依賴的package包/類
@Override
@Nullable
public PsiReference getReference() {
    final ASTNode foreachNode = findForeachNode();
    if (foreachNode == null) {
        return null;
    }
    return new PsiReferenceBase<PsiElement>(this) {
        public PsiElement resolve() {
            return foreachNode.getLastChildNode().getPsi();
        }

        public Object[] getVariants() {
            return EMPTY_ARRAY;
        }
    };
}
 
開發者ID:consulo,項目名稱:consulo-apache-velocity,代碼行數:18,代碼來源:VtlBreak.java

示例5: testLinksInJavaDoc

import com.intellij.psi.PsiReferenceBase; //導入依賴的package包/類
public void testLinksInJavaDoc() {
  configureByFile(BASE_PATH + "/" + getTestName(false) + ".java");
  @SuppressWarnings("SpellCheckingInspection") Set<String> expected = ContainerUtil.newHashSet(
    "http://www.unicode.org/unicode/standard/standard.html",
    "http://docs.oracle.com/javase/7/docs/technotes/guides/lang/cl-mt.html",
    "https://youtrack.jetbrains.com/issue/IDEA-131621",
    "mailto:[email protected]");
  Set<String> actual = collectWebReferences().stream().map(PsiReferenceBase::getCanonicalText).collect(Collectors.toSet());
  assertEquals(expected, actual);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:11,代碼來源:JavadocHighlightingTest.java

示例6: collectWebReferences

import com.intellij.psi.PsiReferenceBase; //導入依賴的package包/類
@NotNull
public static List<WebReference> collectWebReferences() {
  final List<WebReference> refs = new ArrayList<>();
  myFile.accept(new PsiRecursiveElementWalkingVisitor() {
    @Override
    public void visitElement(PsiElement element) {
      for (PsiReference ref : element.getReferences()) {
        if (ref instanceof WebReference) refs.add((WebReference)ref);
      }
      super.visitElement(element);
    }
  });
  assertTrue(refs.stream().allMatch(PsiReferenceBase::isSoft));
  return refs;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:16,代碼來源:JavadocHighlightingTest.java

示例7: getReference

import com.intellij.psi.PsiReferenceBase; //導入依賴的package包/類
@Override
public PsiReference getReference() {
  if (getParent() instanceof RncInclude) {
    final TextRange range = TextRange.from(0, getNameNode().getTextLength());
    return new PsiReferenceBase<RncDefine>(this, range, true) {
      @Override
      public PsiElement resolve() {
        return RncDefineImpl.this;
      }

      @Override
      @NotNull
      public Object[] getVariants() {
        final RncInclude parent = (RncInclude)getParent();
        final RncFile referencedFile = parent.getReferencedFile();
        if (referencedFile == null) {
          return EMPTY_ARRAY;
        }
        final RncGrammar grammar = referencedFile.getGrammar();
        if (grammar == null) {
          return EMPTY_ARRAY;
        }

        final Map<String, Set<Define>> map = DefinitionResolver.getAllVariants(grammar);
        if (map != null) {
          return map.keySet().toArray();
        }
        return EMPTY_ARRAY;
      }
    };
  }
  return super.getReference();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:34,代碼來源:RncDefineImpl.java

示例8: getVariants

import com.intellij.psi.PsiReferenceBase; //導入依賴的package包/類
@Override
protected Object[] getVariants(@NotNull PsiReferenceBase reference) {
  Charset[] charsets = CharsetToolkit.getAvailableCharsets();

  LookupElement[] res = new LookupElement[charsets.length];
  for (int i = 0; i < charsets.length; i++) {
    res[i] = LookupElementBuilder.create(charsets[i].name()).withCaseSensitivity(false);
  }

  return res;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:12,代碼來源:MavenCommonParamReferenceProviders.java

示例9: globReference

import com.intellij.psi.PsiReferenceBase; //導入依賴的package包/類
private static PsiReference globReference(GlobExpression glob, PsiFileSystemItem file) {
  return new PsiReferenceBase.Immediate<GlobExpression>(
      glob, glob.getReferenceTextRange(), file) {
    @Override
    public PsiElement bindToElement(@NotNull PsiElement element)
        throws IncorrectOperationException {
      return glob;
    }
  };
}
 
開發者ID:bazelbuild,項目名稱:intellij,代碼行數:11,代碼來源:GlobReferenceSearcher.java

示例10: getReference

import com.intellij.psi.PsiReferenceBase; //導入依賴的package包/類
public PsiReference getReference() {
  if (getParent() instanceof RncInclude) {
    final TextRange range = TextRange.from(0, getNameNode().getTextLength());
    return new PsiReferenceBase<RncDefine>(this, range, true) {
      public PsiElement resolve() {
        return RncDefineImpl.this;
      }

      @NotNull
      public Object[] getVariants() {
        final RncInclude parent = (RncInclude)getParent();
        final RncFile referencedFile = parent.getReferencedFile();
        if (referencedFile == null) {
          return EMPTY_ARRAY;
        }
        final RncGrammar grammar = referencedFile.getGrammar();
        if (grammar == null) {
          return EMPTY_ARRAY;
        }

        final Map<String, Set<Define>> map = DefinitionResolver.getAllVariants(grammar);
        if (map != null) {
          return map.keySet().toArray();
        }
        return EMPTY_ARRAY;
      }
    };
  }
  return super.getReference();
}
 
開發者ID:lshain-android-source,項目名稱:tools-idea,代碼行數:31,代碼來源:RncDefineImpl.java

示例11: getReferencesByElement

import com.intellij.psi.PsiReferenceBase; //導入依賴的package包/類
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement psiElement, @NotNull ProcessingContext processingContext) {
    if (!isApplicable(psiElement)) {
        return new PsiReference[]{};
    }
    String controller = extractController(PsiUtils.getContent(psiElement));
    String action = extractAction(PsiUtils.getContent(psiElement));

    PsiReferenceBase.Immediate reference = new PsiReferenceBase.Immediate(psiElement, OuzoUtils.getControllerAction(psiElement.getProject(), controller, action));
    return new PsiReference[]{reference};
}
 
開發者ID:letsdrink,項目名稱:ouzo-phpstorm-plugin,代碼行數:13,代碼來源:ControllerActionReferenceProvider.java

示例12: getPsiReferenceBase

import com.intellij.psi.PsiReferenceBase; //導入依賴的package包/類
private PsiReference[] getPsiReferenceBase(PsiElement psiElement) {

        try {
            PsiReferenceBase referenceClassInstance = (PsiReferenceBase) this.referenceClass.getDeclaredConstructor(StringLiteralExpression.class).newInstance((StringLiteralExpression) psiElement);
            return new PsiReference[]{  referenceClassInstance };
        } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException ignored) {
        }

        return new PsiReference[0];
    }
 
開發者ID:Haehnchen,項目名稱:idea-php-symfony2-plugin,代碼行數:11,代碼來源:PhpStringLiteralExpressionReference.java

示例13: testCustomReferenceProvider

import com.intellij.psi.PsiReferenceBase; //導入依賴的package包/類
public void testCustomReferenceProvider() throws Exception {
  PsiReferenceRegistrarImpl registrar =
    (PsiReferenceRegistrarImpl) ReferenceProvidersRegistry.getInstance().getRegistrar(JavaLanguage.INSTANCE);
  PsiReferenceProvider provider = new PsiReferenceProvider() {
    @Override
    @NotNull
    public PsiReference[] getReferencesByElement(@NotNull final PsiElement element, @NotNull final ProcessingContext context) {
      return new PsiReference[]{new PsiReferenceBase<PsiElement>(element) {

        @Override
        public PsiElement resolve() {
          return element;
        }

        @Override
        @NotNull
        public Object[] getVariants() {
          return new Object[]{"1", "2", "3"};
        }
      }};
    }
  };
  try {
    registrar.registerReferenceProvider(PsiDocTag.class, provider);
    configureByFile("ReferenceProvider.java");
    assertStringItems("1", "2", "3");
  }
  finally {
    registrar.unregisterReferenceProvider(PsiDocTag.class, provider);
  }
}
 
開發者ID:consulo,項目名稱:consulo-java,代碼行數:32,代碼來源:JavadocCompletionTest.java

示例14: createReferences

import com.intellij.psi.PsiReferenceBase; //導入依賴的package包/類
@Override
  @NotNull
  public PsiReference[] createReferences(GenericDomValue genericDomValue, PsiElement element, ConvertContext context) {
    final GenericAttributeValue<String> e = (GenericAttributeValue<String>)genericDomValue;

    if (genericDomValue.getParent() instanceof RngDefine) {
      final XmlAttributeValue value = e.getXmlAttributeValue();
      if (value == null) {
        return PsiReference.EMPTY_ARRAY;
      }

      return new PsiReference[]{
              new PsiReferenceBase<XmlAttributeValue>(value, true) {
                @Override
                public PsiElement resolve() {
//                  final XmlTag tag = PsiTreeUtil.getParentOfType(value, XmlTag.class);
//                  final XmlTag include = getAncestorTag(tag, "include", ProjectLoader.RNG_NAMESPACE);
//                  final XmlTag grammar = getAncestorTag(tag, "grammar", ProjectLoader.RNG_NAMESPACE);
//
//                  if (include != null && (grammar == null || PsiTreeUtil.isAncestor(grammar, include, true))) {
//                    final ResolveResult[] e = new DefinitionReference(getElement(), false).multiResolve(false);
//                  }
                  return myElement.getParent().getParent();
                }

                @Override
                @NotNull
                public Object[] getVariants() {
                  final RngInclude include = e.getParentOfType(RngInclude.class, true);
                  final RngGrammar scope = e.getParentOfType(RngGrammar.class, true);
                  if (scope != null && include != null && DomUtil.isAncestor(scope, include, true)) {
                    final XmlFile file = include.getIncludedFile().getValue();
                    if (file != null) {
                      final DomFileElement<DomElement> fileElement = scope.getManager().getFileElement(file, DomElement.class);
                      if (fileElement == null) {
                        return EMPTY_ARRAY;
                      }
                      
                      final Ref<Object[]> ref = new Ref<Object[]>(ArrayUtil.EMPTY_STRING_ARRAY);
                      fileElement.acceptChildren(new RngDomVisitor(){
                        @Override
                        public void visit(RngGrammar grammar) {
                          final Map<String, Set<Define>> map = DefinitionResolver.getAllVariants(grammar);
                          if (map != null) {
                            ref.set(map.keySet().toArray());
                          }
                        }
                      });
                      return ref.get();
                    }
                  }
                  return ArrayUtil.EMPTY_STRING_ARRAY; // TODO: look for unresolved refs;
                }
              }
      };
    }

    return new PsiReference[]{
            new DefinitionReference(e)
    };
  }
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:62,代碼來源:RngReferenceConverter.java

示例15: getReference

import com.intellij.psi.PsiReferenceBase; //導入依賴的package包/類
@Override
public PsiReference getReference() {
	final JSGraphQLEndpointNamedTypePsiElement self = this;
	final PsiElement nameIdentifier = getNameIdentifier();
	if(nameIdentifier != null) {
		if(JSGraphQLScalars.SCALAR_TYPES.contains(nameIdentifier.getText())) {
			return new PsiReferenceBase.Immediate<PsiElement>(this, TextRange.allOf(nameIdentifier.getText()), getFirstChild());
		}
		return new PsiReferenceBase<PsiElement>(this, TextRange.from(nameIdentifier.getTextOffset() - self.getTextOffset(), nameIdentifier.getTextLength())) {
			@Nullable
			@Override
			public PsiElement resolve() {
				final Collection<JSGraphQLEndpointNamedTypeDefinition> definitions = JSGraphQLEndpointPsiUtil.getKnownDefinitions(
						self.getContainingFile(),
						JSGraphQLEndpointNamedTypeDefinition.class,
						false,
						null
				);
				final JSGraphQLEndpointNamedTypeDefinition resolvedElement = definitions.stream()
						.filter(d -> d.getNamedTypeDef() != null && d.getNamedTypeDef().getText().equals(nameIdentifier.getText()))
						.findFirst().orElse(null);
				if(resolvedElement != null) {
					return resolvedElement.getNamedTypeDef();
				}
				return null;
			}

			@NotNull
			@Override
			public Object[] getVariants() {
				return NO_VARIANTS;
			}

			@Override
			public PsiElement handleElementRename(String newElementName) throws IncorrectOperationException {
				return self.setName(newElementName);
			}
		};
	}
	return null;
}
 
開發者ID:jimkyndemeyer,項目名稱:js-graphql-intellij-plugin,代碼行數:42,代碼來源:JSGraphQLEndpointNamedTypePsiElement.java


注:本文中的com.intellij.psi.PsiReferenceBase類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。