com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceSet Java Examples

The following examples show how to use com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceSet. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LatexReferenceContributor.java    From idea-latex with MIT License 6 votes vote down vote up
/**
 * Returns references for given @{link PsiElement}.
 *
 * @param psiElement        current element
 * @param processingContext context
 * @return {@link PsiReference} list
 */
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement psiElement, @NotNull ProcessingContext processingContext) {
    if (psiElement instanceof LatexInstruction) {
        LatexInstructionExtImpl instruction = (LatexInstructionExtImpl) psiElement;
        String identifier = instruction.getIdentifier().getText();
        if (Arrays.asList(IDENTIFIERS).contains(identifier)) {
            LatexArgument arg = instruction.getArgument();
            if (arg != null && arg.getValue() != null) {
                return new FileReferenceSet(arg.getValue(), instruction, arg.getStartOffsetInParent() + 1, this, true).getAllReferences();
            }
        }
    }
    return PsiReference.EMPTY_ARRAY;
}
 
Example #2
Source File: StaticPathReferenceProvider.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public boolean createReferences(@Nonnull final PsiElement psiElement,
                                final int offset,
                                final String text,
                                final @Nonnull List<PsiReference> references,
                                final boolean soft) {

  FileReferenceSet set = new FileReferenceSet(text, psiElement, offset, null, true, myEndingSlashNotAllowed, mySuitableFileTypes) {
    @Override
    protected boolean isUrlEncoded() {
      return true;
    }

    @Override
    protected boolean isSoft() {
      return soft;
    }
  };
  if (!myRelativePathsAllowed) {
    set.addCustomization(FileReferenceSet.DEFAULT_PATH_EVALUATOR_OPTION, FileReferenceSet.ABSOLUTE_TOP_LEVEL);
  }
  Collections.addAll(references, set.getAllReferences());
  return true;
}
 
Example #3
Source File: FileIncludeManagerImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nullable
private PsiFileSystemItem doResolve(@Nonnull final FileIncludeInfo info, @Nonnull final PsiFile context) {
  if (info instanceof FileIncludeInfoImpl) {
    String id = ((FileIncludeInfoImpl)info).providerId;
    FileIncludeProvider provider = id == null ? null : myProviderMap.get(id);
    final PsiFileSystemItem resolvedByProvider = provider == null ? null : provider.resolveIncludedFile(info, context);
    if (resolvedByProvider != null) {
      return resolvedByProvider;
    }
  }

  PsiFileImpl psiFile = (PsiFileImpl)myPsiFileFactory.createFileFromText("dummy.txt", PlainTextFileType.INSTANCE, info.path);
  psiFile.setOriginalFile(context);
  return new FileReferenceSet(psiFile) {
    @Override
    protected boolean useIncludingFileAsContext() {
      return false;
    }
  }.resolve();
}
 
Example #4
Source File: ThriftPsiUtil.java    From intellij-thrift with Apache License 2.0 5 votes vote down vote up
@NotNull
private static FileReferenceSet getReferenceSet(@NotNull ThriftInclude include) {
  final PsiElement element = include.getLastChild();
  final String path = getPath(include);
  return new FileReferenceSet(
    path, include, element.getStartOffsetInParent() + 1, null, true, true, new FileType[]{ThriftFileType.INSTANCE}
  );
}
 
Example #5
Source File: IncludeFilePathReferenceProvider.java    From mule-intellij-plugins with Apache License 2.0 4 votes vote down vote up
@NotNull
public PsiReference[] getReferencesByElement(@NotNull PsiElement element,
                                             String text,
                                             int offset) {
    return new FileReferenceSet(text, element, offset, this, true, myEndingSlashNotAllowed).getAllReferences();
}
 
Example #6
Source File: IgnoreReferenceSet.java    From idea-gitignore with MIT License 4 votes vote down vote up
/**
 * Builds an instance of {@link IgnoreReferenceSet.IgnoreReference}.
 */
public IgnoreReference(@NotNull FileReferenceSet fileReferenceSet, TextRange range, int index, String text) {
    super(fileReferenceSet, range, index, text);
    cacheMap = ContainerUtil.newConcurrentMap();
}