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

The following examples show how to use com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceSet. These examples are extracted from open source projects. 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 Project: idea-latex   Source File: LatexReferenceContributor.java    License: 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 Project: consulo   Source File: StaticPathReferenceProvider.java    License: 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 Project: consulo   Source File: FileIncludeManagerImpl.java    License: 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 Project: intellij-thrift   Source File: ThriftPsiUtil.java    License: 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
@NotNull
public PsiReference[] getReferencesByElement(@NotNull PsiElement element,
                                             String text,
                                             int offset) {
    return new FileReferenceSet(text, element, offset, this, true, myEndingSlashNotAllowed).getAllReferences();
}
 
Example 6
Source Project: idea-gitignore   Source File: IgnoreReferenceSet.java    License: 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();
}