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


Java FileIndexFacade.isInSource方法代码示例

本文整理汇总了Java中com.intellij.openapi.roots.FileIndexFacade.isInSource方法的典型用法代码示例。如果您正苦于以下问题:Java FileIndexFacade.isInSource方法的具体用法?Java FileIndexFacade.isInSource怎么用?Java FileIndexFacade.isInSource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.roots.FileIndexFacade的用法示例。


在下文中一共展示了FileIndexFacade.isInSource方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: mapClass

import com.intellij.openapi.roots.FileIndexFacade; //导入方法依赖的package包/类
@Nullable
private PsiClass mapClass(@NotNull PsiClass psiClass) {
  String qualifiedName = psiClass.getQualifiedName();
  if (qualifiedName == null) {
    return psiClass;
  }

  PsiFile file = psiClass.getContainingFile();
  if (file == null || !file.getViewProvider().isPhysical()) {
    return psiClass;
  }

  final VirtualFile vFile = file.getVirtualFile();
  if (vFile == null) {
    return psiClass;
  }
  
  final FileIndexFacade index = FileIndexFacade.getInstance(file.getProject());
  if (!index.isInSource(vFile) && !index.isInLibrarySource(vFile) && !index.isInLibraryClasses(vFile)) {
    return psiClass;
  }

  return JavaPsiFacade.getInstance(psiClass.getProject()).findClass(qualifiedName, myResolveScope);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:TypeCorrector.java

示例2: createFile

import com.intellij.openapi.roots.FileIndexFacade; //导入方法依赖的package包/类
@Override
protected PsiFile createFile(@NotNull final Project project, @NotNull final VirtualFile vFile, @NotNull final FileType fileType) {
  final FileIndexFacade fileIndex = ServiceManager.getService(project, FileIndexFacade.class);
  if (fileIndex.isInLibraryClasses(vFile) || !fileIndex.isInSource(vFile)) {
    String name = vFile.getName();

    // skip inners & anonymous (todo: read actual class name from file)
    int dotIndex = name.lastIndexOf('.');
    if (dotIndex < 0) dotIndex = name.length();
    int index = name.lastIndexOf('$', dotIndex);
    if (index <= 0 || index == dotIndex - 1) {
      return new ClsFileImpl((PsiManagerImpl)PsiManager.getInstance(project), this);
    }
  }

  return null;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:18,代码来源:ClassFileViewProvider.java

示例3: createFile

import com.intellij.openapi.roots.FileIndexFacade; //导入方法依赖的package包/类
@Override
protected PsiFile createFile(@NotNull Project project, @NotNull VirtualFile file, @NotNull FileType fileType)
{
	FileIndexFacade fileIndex = ServiceManager.getService(project, FileIndexFacade.class);
	if(!fileIndex.isInLibraryClasses(file) && fileIndex.isInSource(file) || fileIndex.isExcludedFile(file))
	{
		return new PsiBinaryFileImpl((PsiManagerImpl) getManager(), this);
	}

	// skip inner, anonymous, missing and corrupted classes
	try
	{
		if(!isInnerClass(file))
		{
			return new ClsFileImpl(this);
		}
	}
	catch(Exception e)
	{
		Logger.getInstance(ClassFileViewProvider.class).debug(file.getPath(), e);
	}

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

示例4: createFile

import com.intellij.openapi.roots.FileIndexFacade; //导入方法依赖的package包/类
@Override
protected PsiFile createFile(@NotNull final Project project, @NotNull final VirtualFile vFile, @NotNull final FileType fileType) {
  FileIndexFacade fileIndex = ServiceManager.getService(project, FileIndexFacade.class);
  if (!fileIndex.isInLibraryClasses(vFile) && fileIndex.isInSource(vFile)) {
    return null;
  }

  // skip inners & anonymous
  if (isInnerClass(vFile)) return null;

  return new ClsFileImpl(this);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:ClassFileViewProvider.java

示例5: checkClassUnderSources

import com.intellij.openapi.roots.FileIndexFacade; //导入方法依赖的package包/类
private boolean checkClassUnderSources(final PsiElement element, final Project project) {
  final PsiFile file = element.getContainingFile();
  if (file != null && file.getVirtualFile() != null) {
    final FileIndexFacade indexFacade = FileIndexFacade.getInstance(project);
    final VirtualFile vf = file.getVirtualFile();
    return indexFacade.isInSource(vf) || indexFacade.isInSourceContent(vf);
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:PsiClassFavoriteNodeProvider.java

示例6: isInSourceFiles

import com.intellij.openapi.roots.FileIndexFacade; //导入方法依赖的package包/类
private static boolean isInSourceFiles(@Nullable VirtualFile file, @NotNull Project project) {
  if (file != null && !(file instanceof LightVirtualFile)) {
    final FileIndexFacade index = FileIndexFacade.getInstance(project);
    if (index.isInSource(file) || index.isInLibraryClasses(file)) {
      return true;
    }
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:GrFileIndexUtil.java

示例7: getResolveScope

import com.intellij.openapi.roots.FileIndexFacade; //导入方法依赖的package包/类
@NotNull
@Override
public GlobalSearchScope getResolveScope() {
  final VirtualFile file = getVirtualFile();
  if (file != null && !(file instanceof LightVirtualFile)) {
    final FileIndexFacade index = ServiceManager.getService(getProject(), FileIndexFacade.class);
    if (!index.isInSource(file) && !index.isInLibraryClasses(file)) {
      return GlobalSearchScope.fileScope(this);
    }
  }
  return super.getResolveScope();
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:13,代码来源:PsiJavaFileImpl.java

示例8: correctClassByScope

import com.intellij.openapi.roots.FileIndexFacade; //导入方法依赖的package包/类
@Nullable
public static PsiClass correctClassByScope(PsiClass psiClass, final GlobalSearchScope resolveScope)
{
	if(psiClass == null)
	{
		return null;
	}
	String qualifiedName = psiClass.getQualifiedName();
	if(qualifiedName == null)
	{
		return psiClass;
	}

	PsiFile file = psiClass.getContainingFile();
	if(file == null || !file.getViewProvider().isPhysical())
	{
		return psiClass;
	}

	final VirtualFile vFile = file.getVirtualFile();
	if(vFile == null)
	{
		return psiClass;
	}

	final FileIndexFacade index = FileIndexFacade.getInstance(file.getProject());
	if(!index.isInSource(vFile) && !index.isInLibrarySource(vFile) && !index.isInLibraryClasses(vFile))
	{
		return psiClass;
	}

	return JavaPsiFacade.getInstance(psiClass.getProject()).findClass(qualifiedName, resolveScope);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:34,代码来源:PsiSuperMethodUtil.java

示例9: isClassEquivalentTo

import com.intellij.openapi.roots.FileIndexFacade; //导入方法依赖的package包/类
public static boolean isClassEquivalentTo(@NotNull PsiClass aClass, PsiElement another) {
  if (aClass == another) return true;
  if (!(another instanceof PsiClass)) return false;
  String name1 = aClass.getName();
  if (name1 == null) return false;
  if (!another.isValid()) return false;
  String name2 = ((PsiClass)another).getName();
  if (name2 == null) return false;
  if (name1.hashCode() != name2.hashCode()) return false;
  if (!name1.equals(name2)) return false;
  String qName1 = aClass.getQualifiedName();
  String qName2 = ((PsiClass)another).getQualifiedName();
  if (qName1 == null || qName2 == null) {
    //noinspection StringEquality
    if (qName1 != qName2) return false;

    if (aClass instanceof PsiTypeParameter && another instanceof PsiTypeParameter) {
      PsiTypeParameter p1 = (PsiTypeParameter)aClass;
      PsiTypeParameter p2 = (PsiTypeParameter)another;

      return p1.getIndex() == p2.getIndex() &&
             (aClass.getManager().areElementsEquivalent(p1.getOwner(), p2.getOwner()) || InferenceSession.areSameFreshVariables(p1, p2));
    }
    else {
      return false;
    }
  }
  if (qName1.hashCode() != qName2.hashCode() || !qName1.equals(qName2)) {
    return false;
  }

  if (aClass.getOriginalElement().equals(another.getOriginalElement())) {
    return true;
  }

  final PsiFile file1 = aClass.getContainingFile().getOriginalFile();
  final PsiFile file2 = another.getContainingFile().getOriginalFile();

  //see com.intellij.openapi.vcs.changes.PsiChangeTracker
  //see com.intellij.psi.impl.PsiFileFactoryImpl#createFileFromText(CharSequence,PsiFile)
  final PsiFile original1 = file1.getUserData(PsiFileFactory.ORIGINAL_FILE);
  final PsiFile original2 = file2.getUserData(PsiFileFactory.ORIGINAL_FILE);
  if (original1 == original2 && original1 != null || original1 == file2 || original2 == file1 || file1 == file2) {
    return compareClassSeqNumber(aClass, (PsiClass)another);
  }

  final FileIndexFacade fileIndex = ServiceManager.getService(file1.getProject(), FileIndexFacade.class);
  final VirtualFile vfile1 = file1.getViewProvider().getVirtualFile();
  final VirtualFile vfile2 = file2.getViewProvider().getVirtualFile();
  boolean lib1 = fileIndex.isInLibraryClasses(vfile1);
  boolean lib2 = fileIndex.isInLibraryClasses(vfile2);

  return (fileIndex.isInSource(vfile1) || lib1) && (fileIndex.isInSource(vfile2) || lib2);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:55,代码来源:PsiClassImplUtil.java

示例10: isClassEquivalentTo

import com.intellij.openapi.roots.FileIndexFacade; //导入方法依赖的package包/类
public static boolean isClassEquivalentTo(@NotNull PsiClass aClass, PsiElement another) {
  if (aClass == another) return true;
  if (!(another instanceof PsiClass)) return false;
  String name1 = aClass.getName();
  if (name1 == null) return false;
  if (!another.isValid()) return false;
  String name2 = ((PsiClass)another).getName();
  if (name2 == null) return false;
  if (name1.hashCode() != name2.hashCode()) return false;
  if (!name1.equals(name2)) return false;
  String qName1 = aClass.getQualifiedName();
  String qName2 = ((PsiClass)another).getQualifiedName();
  if (qName1 == null || qName2 == null) {
    //noinspection StringEquality
    if (qName1 != qName2) return false;

    if (aClass instanceof PsiTypeParameter && another instanceof PsiTypeParameter) {
      PsiTypeParameter p1 = (PsiTypeParameter)aClass;
      PsiTypeParameter p2 = (PsiTypeParameter)another;

      return p1.getIndex() == p2.getIndex() &&
             aClass.getManager().areElementsEquivalent(p1.getOwner(), p2.getOwner());
    }
    else {
      return false;
    }
  }
  if (qName1.hashCode() != qName2.hashCode() || !qName1.equals(qName2)) {
    return false;
  }

  if (originalElement(aClass).equals(originalElement((PsiClass)another))) {
    return true;
  }

  final PsiFile file1 = aClass.getContainingFile().getOriginalFile();
  final PsiFile file2 = another.getContainingFile().getOriginalFile();

  //see com.intellij.openapi.vcs.changes.PsiChangeTracker
  //see com.intellij.psi.impl.PsiFileFactoryImpl#createFileFromText(CharSequence,PsiFile)
  final PsiFile original1 = file1.getUserData(PsiFileFactory.ORIGINAL_FILE);
  final PsiFile original2 = file2.getUserData(PsiFileFactory.ORIGINAL_FILE);
  if (original1 == original2 && original1 != null || original1 == file2 || original2 == file1 || file1 == file2) {
    return compareClassSeqNumber(aClass, (PsiClass)another);
  }

  final FileIndexFacade fileIndex = ServiceManager.getService(file1.getProject(), FileIndexFacade.class);
  final VirtualFile vfile1 = file1.getViewProvider().getVirtualFile();
  final VirtualFile vfile2 = file2.getViewProvider().getVirtualFile();
  boolean lib1 = fileIndex.isInLibraryClasses(vfile1);
  boolean lib2 = fileIndex.isInLibraryClasses(vfile2);

  return (fileIndex.isInSource(vfile1) || lib1) && (fileIndex.isInSource(vfile2) || lib2);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:55,代码来源:PsiClassImplUtil.java

示例11: getPresentation

import com.intellij.openapi.roots.FileIndexFacade; //导入方法依赖的package包/类
@Override
public ItemPresentation getPresentation(@NotNull final PsiJavaModule item)
{
	return new ItemPresentation()
	{
		@Nullable
		@Override
		public String getPresentableText()
		{
			return item.getName();
		}

		@Nullable
		@Override
		public String getLocationString()
		{
			VirtualFile file = PsiImplUtil.getModuleVirtualFile(item);
			FileIndexFacade index = FileIndexFacade.getInstance(item.getProject());
			if(index.isInLibraryClasses(file))
			{
				Matcher matcher = JAR_NAME.matcher(file.getPath());
				if(matcher.find())
				{
					return matcher.group(1);
				}
			}
			else if(index.isInSource(file))
			{
				Module module = index.getModuleForFile(file);
				if(module != null)
				{
					return '[' + module.getName() + ']';
				}
			}
			return null;
		}

		@Nullable
		@Override
		public Icon getIcon(boolean unused)
		{
			return JavaIcons.Nodes.JavaModule;
		}
	};
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:46,代码来源:JavaModulePresentationProvider.java


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