当前位置: 首页>>代码示例>>Java>>正文


Java FileReferenceSet类代码示例

本文整理汇总了Java中com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceSet的典型用法代码示例。如果您正苦于以下问题:Java FileReferenceSet类的具体用法?Java FileReferenceSet怎么用?Java FileReferenceSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FileReferenceSet类属于com.intellij.psi.impl.source.resolve.reference.impl.providers包,在下文中一共展示了FileReferenceSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isAvailable

import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceSet; //导入依赖的package包/类
@Override
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
  final int offset = editor.getCaretModel().getOffset();
  final PsiElement element = file.findElementAt(offset);
  if (element == null ||
      element instanceof PsiWhiteSpace) {
    return false;
  }

  final PsiReference reference = file.findReferenceAt(offset);
  final FileReference fileReference = reference == null ? null : FileReference.findFileReference(reference);

  if (fileReference != null) {
    final FileReferenceSet set = fileReference.getFileReferenceSet();
    final FileReference lastReference = set.getLastReference();
    return set.couldBeConvertedTo(isConvertToRelative()) && lastReference != null &&
           (!isConvertToRelative() && !set.isAbsolutePathReference() || isConvertToRelative() && set.isAbsolutePathReference()) &&
           lastReference.resolve() != null;
  }

  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:ConvertAbsolutePathToRelativeIntentionAction.java

示例2: createReferences

import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceSet; //导入依赖的package包/类
@Override
public boolean createReferences(@NotNull final PsiElement psiElement,
                                final int offset,
                                final String text,
                                final @NotNull 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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:StaticPathReferenceProvider.java

示例3: doResolve

import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceSet; //导入依赖的package包/类
@Nullable
private PsiFileSystemItem doResolve(@NotNull final FileIncludeInfo info, @NotNull 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", FileTypes.PLAIN_TEXT, info.path);
  psiFile.setOriginalFile(context);
  return new FileReferenceSet(psiFile) {
    @Override
    protected boolean useIncludingFileAsContext() {
      return false;
    }
  }.resolve();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:FileIncludeManagerImpl.java

示例4: collectRefs

import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceSet; //导入依赖的package包/类
private static PsiReference[] collectRefs(@NotNull PsiElement element, String value, final int startInElement, final FileType... acceptedFileTypes) {
  final FileReferenceSet set = new FileReferenceSet(value, element, startInElement, null, true){
    @Override
    protected Condition<PsiFileSystemItem> getReferenceCompletionFilter() {
      return new Condition<PsiFileSystemItem>() {
        @Override
        public boolean value(PsiFileSystemItem item) {
          if (item instanceof PsiDirectory) return true;
          final VirtualFile virtualFile = item.getVirtualFile();
          if (virtualFile == null) return false;
          final FileType fileType = virtualFile.getFileType();
          return ArrayUtilRt.find(acceptedFileTypes, fileType) >= 0;
        }
      };
    }
  };
  if (value.startsWith("/")) {
    set.addCustomization(FileReferenceSet.DEFAULT_PATH_EVALUATOR_OPTION, FileReferenceSet.ABSOLUTE_TOP_LEVEL);
  }
  return set.getAllReferences();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:JavaFxLocationReferenceProvider.java

示例5: getReferencesByElement

import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceSet; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:hsz,项目名称:idea-latex,代码行数:23,代码来源:LatexReferenceContributor.java

示例6: collectRefs

import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceSet; //导入依赖的package包/类
private static PsiReference[] collectRefs(PsiElement element, String value, final int startInElement, final FileType... acceptedFileTypes) {
  final FileReferenceSet set = new FileReferenceSet(value, element, startInElement, null, true){
    @Override
    protected Condition<PsiFileSystemItem> getReferenceCompletionFilter() {
      return new Condition<PsiFileSystemItem>() {
        @Override
        public boolean value(PsiFileSystemItem item) {
          if (item instanceof PsiDirectory) return true;
          final VirtualFile virtualFile = item.getVirtualFile();
          if (virtualFile == null) return false;
          final FileType fileType = virtualFile.getFileType();
          return ArrayUtilRt.find(acceptedFileTypes, fileType) >= 0;
        }
      };
    }
  };
  if (value.startsWith("/")) {
    set.addCustomization(FileReferenceSet.DEFAULT_PATH_EVALUATOR_OPTION, FileReferenceSet.ABSOLUTE_TOP_LEVEL);
  }
  return set.getAllReferences();
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:22,代码来源:JavaFxLocationReferenceProvider.java

示例7: createReferences

import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceSet; //导入依赖的package包/类
@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;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:25,代码来源:StaticPathReferenceProvider.java

示例8: getReferencesByElement

import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceSet; //导入依赖的package包/类
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement psiElement, @NotNull ProcessingContext processingContext)
{
	XmlAttributeValue xmlAttributeValue = (XmlAttributeValue) psiElement;
	ASTNode value = xmlAttributeValue.getNode().findChildByType(XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN);
	if(value == null)
	{
		return PsiReference.EMPTY_ARRAY;
	}
	FileReferenceSet fileReferenceSet = new FileReferenceSet(value.getPsi())
	{
		@Override
		protected Condition<PsiFileSystemItem> getReferenceCompletionFilter()
		{
			return item -> item instanceof XStyleSheetFile || item instanceof PsiDirectory;
		}
	};
	fileReferenceSet.setEmptyPathAllowed(false);

	return fileReferenceSet.getAllReferences();
}
 
开发者ID:consulo,项目名称:consulo-css,代码行数:23,代码来源:HtmlHrefToCssFileReferenceProvider.java

示例9: resolveXIncludeFile

import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceSet; //导入依赖的package包/类
@Nullable
public static XmlFile resolveXIncludeFile(XmlTag xincludeTag) {
  final XmlAttribute hrefAttribute = xincludeTag.getAttribute("href", null);
  if (hrefAttribute == null) return null;

  final XmlAttributeValue xmlAttributeValue = hrefAttribute.getValueElement();
  if (xmlAttributeValue == null) return null;

  final FileReferenceSet referenceSet = FileReferenceSet.createSet(xmlAttributeValue, false, true, false);

  final PsiReference reference = referenceSet.getLastReference();
  if (reference == null) return null;

  final PsiElement target = reference.resolve();

  if (!(target instanceof XmlFile)) return null;
  return (XmlFile)target;
}
 
开发者ID:consulo,项目名称:consulo-xml,代码行数:19,代码来源:XmlIncludeHandler.java

示例10: resolveFile

import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceSet; //导入依赖的package包/类
@Override
public PsiFile resolveFile()
{
	final String includeText = getIncludeText();
	if(includeText == null)
	{
		return null;
	}
	final FileReference[] references = new FileReferenceSet(includeText, this, 0, null, SystemInfo.isFileSystemCaseSensitive).getAllReferences();

	if(references != null && references.length > 0)
	{
		final PsiElement element = references[references.length - 1].resolve();
		if(element instanceof PsiFile)
		{
			return (PsiFile) element;
		}
	}
	return null;
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:21,代码来源:JSIncludeDirectiveImpl.java

示例11: isAvailable

import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceSet; //导入依赖的package包/类
@Override
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file)
{
	final int offset = editor.getCaretModel().getOffset();
	final PsiElement element = file.findElementAt(offset);
	if(element == null || element instanceof PsiWhiteSpace)
	{
		return false;
	}

	final PsiReference reference = file.findReferenceAt(offset);
	final FileReference fileReference = reference == null ? null : FileReference.findFileReference(reference);

	if(fileReference != null)
	{
		final FileReferenceSet set = fileReference.getFileReferenceSet();
		final FileReference lastReference = set.getLastReference();
		return set.couldBeConvertedTo(isConvertToRelative()) && lastReference != null &&
				(!isConvertToRelative() && !set.isAbsolutePathReference() || isConvertToRelative() && set.isAbsolutePathReference()) &&
				lastReference.resolve() != null;
	}

	return false;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:25,代码来源:ConvertAbsolutePathToRelativeIntentionAction.java

示例12: getReferences

import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceSet; //导入依赖的package包/类
@NotNull
@Override
@SuppressWarnings({ "SSBasedInspection" })
public PsiReference[] getReferences() {
  final ASTNode literal = getNode().findChildByType(RncTokenTypes.LITERAL);
  if (literal == null) return PsiReference.EMPTY_ARRAY;

  final String s = literal.getText();
  final FileReferenceSet set =
          new FileReferenceSet(s.substring(1, s.length() - 1), this,
                  getReferenceRange().getStartOffset(),
                  null, true, false);

  return FileReferenceUtil.restrict(set, FileReferenceUtil.byType(RncFileType.getInstance()));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:RncFileReferenceImpl.java

示例13: createReferences

import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceSet; //导入依赖的package包/类
@Override
@NotNull
public PsiReference[] createReferences(GenericDomValue<XmlFile> genericDomValue, PsiElement element, ConvertContext context) {
  final String s = genericDomValue.getStringValue();
  if (s == null || element == null) {
    return PsiReference.EMPTY_ARRAY;
  }
  final FileReferenceSet set = FileReferenceSet.createSet(element, false, false, false);
  if (set != null) {
    return FileReferenceUtil.restrict(set, FileReferenceUtil.byNamespace(ApplicationLoader.RNG_NAMESPACE), true);
  } else {
    return PsiReference.EMPTY_ARRAY;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:RngHrefConverter.java

示例14: restrict

import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceSet; //导入依赖的package包/类
public static PsiReference[] restrict(FileReferenceSet set, final Condition<PsiFile> cond, final Boolean soft) {
  final FileReference[] references = set.getAllReferences();

  return ContainerUtil.map2Array(references, PsiReference.class, new NotNullFunction<FileReference, PsiReference>() {
    @Override
    @NotNull
    public PsiReference fun(FileReference fileReference) {
      return new MyFileReference(fileReference, cond, soft);
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:FileReferenceUtil.java

示例15: getReferences

import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceSet; //导入依赖的package包/类
@NotNull
@Override
public PsiReference[] getReferences(@NotNull PsiElement element, @NotNull ProcessingContext context, @NotNull TextRange range) {
  String text = range.substring(element.getText());
  return new FileReferenceSet(text, element, range.getStartOffset(), null, true) {
    @Override
    protected boolean isSoft() {
      return true;
    }
  }.getAllReferences();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:FileReferenceInjector.java


注:本文中的com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceSet类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。