本文整理汇总了Java中com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceSet.addCustomization方法的典型用法代码示例。如果您正苦于以下问题:Java FileReferenceSet.addCustomization方法的具体用法?Java FileReferenceSet.addCustomization怎么用?Java FileReferenceSet.addCustomization使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceSet
的用法示例。
在下文中一共展示了FileReferenceSet.addCustomization方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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();
}
示例3: 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();
}
示例4: 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;
}
示例5: getReferences
import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceSet; //导入方法依赖的package包/类
public static PsiReference[] getReferences(@NotNull PsiElement element, String value, final String acceptedExtension) {
final PsiDirectory directory = element.getContainingFile().getOriginalFile().getParent();
if (directory == null) return PsiReference.EMPTY_ARRAY;
final boolean startsWithSlash = value.startsWith("/");
final VirtualFileSystem fs = directory.getVirtualFile().getFileSystem();
final FileReferenceSet fileReferenceSet = new FileReferenceSet(value, element, 1, null, fs.isCaseSensitive()) {
@NotNull
@Override
public Collection<PsiFileSystemItem> getDefaultContexts() {
if (startsWithSlash || !directory.isValid()) {
return super.getDefaultContexts();
}
return Collections.<PsiFileSystemItem>singletonList(directory);
}
@Override
protected Condition<PsiFileSystemItem> getReferenceCompletionFilter() {
return new Condition<PsiFileSystemItem>() {
@Override
public boolean value(PsiFileSystemItem item) {
if (item instanceof PsiDirectory) return true;
final VirtualFile virtualFile = PsiUtilCore.getVirtualFile(item);
return virtualFile != null && acceptedExtension.equals(virtualFile.getExtension());
}
};
}
};
if (startsWithSlash) {
fileReferenceSet.addCustomization(FileReferenceSet.DEFAULT_PATH_EVALUATOR_OPTION, FileReferenceSet.ABSOLUTE_TOP_LEVEL);
}
return fileReferenceSet.getAllReferences();
}
示例6: getReferences
import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceSet; //导入方法依赖的package包/类
public static PsiReference[] getReferences(final PsiElement element, String value, final String acceptedExtension) {
final PsiDirectory directory = element.getContainingFile().getOriginalFile().getParent();
if (directory == null) return PsiReference.EMPTY_ARRAY;
final boolean startsWithSlash = value.startsWith("/");
final VirtualFileSystem fs = directory.getVirtualFile().getFileSystem();
final FileReferenceSet fileReferenceSet = new FileReferenceSet(value, element, 1, null, fs.isCaseSensitive()) {
@NotNull
@Override
public Collection<PsiFileSystemItem> getDefaultContexts() {
if (startsWithSlash || !directory.isValid()) {
return super.getDefaultContexts();
}
return Collections.<PsiFileSystemItem>singletonList(directory);
}
@Override
protected Condition<PsiFileSystemItem> getReferenceCompletionFilter() {
return new Condition<PsiFileSystemItem>() {
@Override
public boolean value(PsiFileSystemItem item) {
if (item instanceof PsiDirectory) return true;
final VirtualFile virtualFile = PsiUtilCore.getVirtualFile(item);
return virtualFile != null && acceptedExtension.equals(virtualFile.getExtension());
}
};
}
};
if (startsWithSlash) {
fileReferenceSet.addCustomization(FileReferenceSet.DEFAULT_PATH_EVALUATOR_OPTION, FileReferenceSet.ABSOLUTE_TOP_LEVEL);
}
return fileReferenceSet.getAllReferences();
}
示例7: getFileRefs
import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceSet; //导入方法依赖的package包/类
public static PsiReference[] getFileRefs(final PsiElement elt, final int offset, String str, final LookupOptions lookupOptions)
{
if(lookupOptions.IGNORE_TEXT_ARTER_HASH)
{
int hashIndex = str.indexOf('#');
if(hashIndex != -1)
{
str = str.substring(0, hashIndex);
}
}
final FileReferenceSet base = new FileReferenceSet(str, elt, offset, null, SystemInfo.isFileSystemCaseSensitive);
final boolean lookForAbsolutePath = lookupOptions.ABSOLUTE && new File(str).isAbsolute();
final boolean startsWithSlash = str.startsWith("/");
base.addCustomization(FileReferenceSet.DEFAULT_PATH_EVALUATOR_OPTION, new Function<PsiFile, Collection<PsiFileSystemItem>>()
{
@Override
public Collection<PsiFileSystemItem> fun(PsiFile psiFile)
{
final PsiElement context = psiFile.getContext();
if(context instanceof PsiLanguageInjectionHost)
{
psiFile = context.getContainingFile();
}
PsiFile originalFile = psiFile.getOriginalFile();
if(originalFile != null)
{
psiFile = originalFile;
}
final List<VirtualFile> dirs = new ArrayList<VirtualFile>();
// paths relative to file should not start with slash
if(lookupOptions.RELATIVE_TO_FILE && !startsWithSlash)
{
appendFileLocation(dirs, psiFile);
}
if((lookupOptions.RELATIVE_TO_SOURCE_ROOTS_START_WITH_SLASH && startsWithSlash) || (lookupOptions.RELATIVE_TO_SOURCE_ROOTS_START_WITHOUT_SLASH
&& !startsWithSlash))
{
appendSourceRoots(dirs, psiFile);
}
if(lookForAbsolutePath)
{
appendFileSystemRoot(dirs, psiFile.getProject());
}
if(lookupOptions.RELATIVE_TO_PROJECT_BASE_DIR)
{
dirs.add(psiFile.getProject().getBaseDir());
}
if(lookupOptions.IN_SDK_AND_LIBRARY_CLASS_ROOTS)
{
appendSdkAndLibraryClassRoots(dirs, psiFile);
}
final Collection<PsiFileSystemItem> result = new ArrayList<PsiFileSystemItem>();
final PsiManager psiManager = PsiManager.getInstance(psiFile.getProject());
for(final VirtualFile dir : dirs)
{
if(dir != null)
{
final PsiDirectory psiDir = psiManager.findDirectory(dir);
if(psiDir != null)
{
result.add(psiDir);
}
}
}
return result;
}
});
return base.getAllReferences();
}