本文整理汇总了Java中com.intellij.psi.search.EverythingGlobalScope类的典型用法代码示例。如果您正苦于以下问题:Java EverythingGlobalScope类的具体用法?Java EverythingGlobalScope怎么用?Java EverythingGlobalScope使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EverythingGlobalScope类属于com.intellij.psi.search包,在下文中一共展示了EverythingGlobalScope类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCachedClassesByName
import com.intellij.psi.search.EverythingGlobalScope; //导入依赖的package包/类
@NotNull
private PsiClass[] getCachedClassesByName(@NotNull String name, GlobalSearchScope scope) {
if (DumbService.getInstance(getProject()).isDumb()) {
return getCachedClassInDumbMode(name, scope);
}
Map<String, PsiClass[]> map = SoftReference.dereference(myClassCache);
if (map == null) {
myClassCache = new SoftReference<Map<String, PsiClass[]>>(map = ContainerUtil.createConcurrentSoftValueMap());
}
PsiClass[] classes = map.get(name);
if (classes != null) {
return classes;
}
final String qName = getQualifiedName();
final String classQName = !qName.isEmpty() ? qName + "." + name : name;
map.put(name, classes = getFacade().findClasses(classQName, new EverythingGlobalScope(getProject())));
return classes;
}
示例2: elementHasSourceCode
import com.intellij.psi.search.EverythingGlobalScope; //导入依赖的package包/类
private boolean elementHasSourceCode() {
PsiFileSystemItem[] items;
if (myElement instanceof PsiDirectory) {
final PsiPackage aPackage = JavaDirectoryService.getInstance().getPackage((PsiDirectory)myElement);
if (aPackage == null) return false;
items = aPackage.getDirectories(new EverythingGlobalScope(myProject));
}
else if (myElement instanceof PsiPackage) {
items = ((PsiPackage)myElement).getDirectories(new EverythingGlobalScope(myProject));
}
else {
PsiFile containingFile = myElement.getNavigationElement().getContainingFile();
if (containingFile == null) return false;
items = new PsiFileSystemItem[] {containingFile};
}
ProjectFileIndex projectFileIndex = ProjectFileIndex.SERVICE.getInstance(myProject);
for (PsiFileSystemItem item : items) {
VirtualFile file = item.getVirtualFile();
if (file != null && projectFileIndex.isInSource(file)) return true;
}
return false;
}
示例3: setSelectedPatch
import com.intellij.psi.search.EverythingGlobalScope; //导入依赖的package包/类
public void setSelectedPatch(Patch selectedPatch) {
System.out.println(selectedPatch.asString() + " selected! ");
this.selectedPatch = selectedPatch;
final SourceLocation location = this.selectedPatch.getSourceLocation();
PsiClass classToBeFix = JavaPsiFacade.getInstance(this.project).findClass(this.selectedPatch.getRootClassName(), new EverythingGlobalScope(this.project));
classToBeFix.accept(new JavaRecursiveElementVisitor() {
@Override
public void visitStatement(PsiStatement statement) {
if (location.getBeginSource() == statement.getTextOffset() &&
location.getEndSource() == statement.getTextOffset() + statement.getTextLength() - 1) {
buggyElement = statement;
}
super.visitStatement(statement);
}
});
}
示例4: addInit
import com.intellij.psi.search.EverythingGlobalScope; //导入依赖的package包/类
private void addInit(@Nullable String rootViewStr) {
PsiClass activityClass = JavaPsiFacade.getInstance(mProject).findClass(
"android.app.Activity", new EverythingGlobalScope(mProject));
PsiClass fragmentClass = JavaPsiFacade.getInstance(mProject).findClass(
"android.app.Fragment", new EverythingGlobalScope(mProject));
PsiClass supportFragmentClass = JavaPsiFacade.getInstance(mProject).findClass(
"android.support.v4.app.Fragment", new EverythingGlobalScope(mProject));
// Check for Activity class
if (activityClass != null && mClass.isInheritor(activityClass, true)) {
addInitViewAfterOnCreate(rootViewStr);
// Check for Fragment class
} else if ((fragmentClass != null && mClass.isInheritor(fragmentClass, true)) || (supportFragmentClass != null && mClass.isInheritor(supportFragmentClass, true))) {
addInitViewAfterOnCreateView(rootViewStr);
} else {
Utils.showInfoNotification(mEditor.getProject(), "Add " + getInitViewStatementAsString(rootViewStr) + " where relevant!");
}
}
示例5: resolveLayoutResourceFile
import com.intellij.psi.search.EverythingGlobalScope; //导入依赖的package包/类
private static PsiFile resolveLayoutResourceFile(PsiElement element, Project project, String name) {
// restricting the search to the current module - searching the whole project could return wrong layouts
Module module = ModuleUtil.findModuleForPsiElement(element);
PsiFile[] files = null;
if (module != null) {
GlobalSearchScope moduleScope = module.getModuleWithDependenciesAndLibrariesScope(false);
files = FilenameIndex.getFilesByName(project, name, moduleScope);
}
if (files == null || files.length <= 0) {
// fallback to search through the whole project
// useful when the project is not properly configured - when the resource directory is not configured
files = FilenameIndex.getFilesByName(project, name, new EverythingGlobalScope(project));
if (files.length <= 0) {
return null; //no matching files
}
}
// TODO - we have a problem here - we still can have multiple layouts (some coming from a dependency)
// we need to resolve R class properly and find the proper layout for the R class
return files[0];
}
示例6: findLayoutResource
import com.intellij.psi.search.EverythingGlobalScope; //导入依赖的package包/类
/**
* Try to find layout XML file in selected element
*
* @param element
* @return
*/
public static PsiFile findLayoutResource(PsiElement element) {
if (element == null) {
return null; // nothing to be used
}
if (!(element instanceof PsiIdentifier)) {
return null; // nothing to be used
}
PsiElement layout = element.getParent().getFirstChild();
if (layout == null) {
return null; // no file to process
}
if (!"R.layout".equals(layout.getText())) {
return null; // not layout file
}
Project project = element.getProject();
String name = String.format("%s.xml", element.getText());
PsiFile[] files = FilenameIndex.getFilesByName(project, name, new EverythingGlobalScope(project));
if (files.length <= 0) {
return null; //no matching files
}
return files[0];
}
示例7: run
import com.intellij.psi.search.EverythingGlobalScope; //导入依赖的package包/类
@Override
public void run() throws Throwable {
PsiClass injectViewClass = JavaPsiFacade.getInstance(mProject).findClass("net.tsz.afinal.annotation.view.ViewInject", new EverythingGlobalScope(mProject));
if (injectViewClass == null) {
return; // Butterknife library is not available for project
}
if (mCreateHolder) {
generateAdapter();
} else {
generateFields();
}
// reformat class
JavaCodeStyleManager styleManager = JavaCodeStyleManager.getInstance(mProject);
styleManager.optimizeImports(mFile);
styleManager.shortenClassReferences(mClass);
new ReformatAndOptimizeImportsProcessor(mProject, mClass.getContainingFile(), false).runWithoutProgress();
}
示例8: generateInjects
import com.intellij.psi.search.EverythingGlobalScope; //导入依赖的package包/类
protected void generateInjects(@NotNull IButterKnife butterKnife) {
PsiClass activityClass = JavaPsiFacade.getInstance(mProject).findClass(
"android.app.Activity", new EverythingGlobalScope(mProject));
PsiClass fragmentClass = JavaPsiFacade.getInstance(mProject).findClass(
"android.app.Fragment", new EverythingGlobalScope(mProject));
PsiClass supportFragmentClass = JavaPsiFacade.getInstance(mProject).findClass(
"android.support.v4.app.Fragment", new EverythingGlobalScope(mProject));
// Check for Activity class
if (activityClass != null && mClass.isInheritor(activityClass, true)) {
generateActivityBind(butterKnife);
// Check for Fragment class
} else if ((fragmentClass != null && mClass.isInheritor(fragmentClass, true)) || (supportFragmentClass != null && mClass.isInheritor(supportFragmentClass, true))) {
generateFragmentBindAndUnbind(butterKnife);
}
}
示例9: generatePackageJavaDoc
import com.intellij.psi.search.EverythingGlobalScope; //导入依赖的package包/类
private void generatePackageJavaDoc(final StringBuilder buffer, final PsiPackage psiPackage, boolean generatePrologueAndEpilogue) {
for (PsiDirectory directory : psiPackage.getDirectories(new EverythingGlobalScope(myProject))) {
final PsiFile packageInfoFile = directory.findFile(PsiPackage.PACKAGE_INFO_FILE);
if (packageInfoFile != null) {
final ASTNode node = packageInfoFile.getNode();
if (node != null) {
final ASTNode docCommentNode = node.findChildByType(JavaDocElementType.DOC_COMMENT);
if (docCommentNode != null) {
final PsiDocComment docComment = (PsiDocComment)docCommentNode.getPsi();
if (generatePrologueAndEpilogue)
generatePrologue(buffer);
generateCommonSection(buffer, docComment);
if (generatePrologueAndEpilogue)
generateEpilogue(buffer);
break;
}
}
}
PsiFile packageHtmlFile = directory.findFile("package.html");
if (packageHtmlFile != null) {
generatePackageHtmlJavaDoc(buffer, packageHtmlFile, generatePrologueAndEpilogue);
break;
}
}
}
示例10: findClass
import com.intellij.psi.search.EverythingGlobalScope; //导入依赖的package包/类
@Override
public PsiClass findClass(@NotNull String qualifiedName, @NotNull GlobalSearchScope scope) {
PsiClass aClass = super.findClass(qualifiedName, scope);
if (aClass == null || scope instanceof ExternalModuleBuildGlobalSearchScope || scope instanceof EverythingGlobalScope) {
return aClass;
}
PsiFile containingFile = aClass.getContainingFile();
VirtualFile file = containingFile != null ? containingFile.getVirtualFile() : null;
return (file != null && !ProjectFileIndex.SERVICE.getInstance(myProject).isInContent(file)) ? aClass : null;
}
示例11: getScopeToExclude
import com.intellij.psi.search.EverythingGlobalScope; //导入依赖的package包/类
@Nullable
@Override
public GlobalSearchScope getScopeToExclude(PsiElement element) {
if (element instanceof PsiFileSystemItem) {
return GlobalSearchScope.getScopeRestrictedByFileTypes(
new EverythingGlobalScope(), BuildFileType.INSTANCE);
}
return null;
}
示例12: getGradleSettingsFile
import com.intellij.psi.search.EverythingGlobalScope; //导入依赖的package包/类
private static PsiFile getGradleSettingsFile(Project project) {
PsiFile[] files = FilenameIndex.getFilesByName(project, "settings.gradle", new EverythingGlobalScope(project));
if (files.length <= 0) {
return null; //no matching files
}
return files[0];// 根目录下的
}
示例13: AppendHTMLCommandAction
import com.intellij.psi.search.EverythingGlobalScope; //导入依赖的package包/类
public AppendHTMLCommandAction(Project project, PsiFile file, List<XmlItem> content, Module module) {
super(project, file);
this.content = content;
this.module = module;
String indexPath="index.html";
PsiFile[] files = FilenameIndex.getFilesByName(project,indexPath , new EverythingGlobalScope(project));
if (files != null && files.length > 0) {
for (PsiFile psiFile:files){
if (ModuleUtil.findModuleForFile(psiFile.getVirtualFile(), project).getModuleFilePath().equals(module.getModuleFilePath())) {
htmlIndexFile =psiFile;
}
}
}
}
示例14: generateMainClass
import com.intellij.psi.search.EverythingGlobalScope; //导入依赖的package包/类
public void generateMainClass(){
// VirtualFile mainClassFile=project.getProjectFile().findChild(Util.getEnterClassNameByProjectName(project.getName())+".java");
String mainClassName=Util.getEnterClassNameByProjectName(module.getName());
PsiFile[] files= FilenameIndex.getFilesByName(project,mainClassName+".java",new EverythingGlobalScope(project));
if (files.length<=0){
return;
}
PsiJavaFile mainClassFile=(PsiJavaFile)files[0];
PsiFile[] jsFiles= FilenameIndex.getFilesByName(project,"JsConst.java",new EverythingGlobalScope(project));
if (files.length<=0){
return;
}
PsiJavaFile jsJavaFile=(PsiJavaFile)jsFiles[0];
PsiClass jsClass=JavaPsiFacade.getInstance(project).findClass(mainClassFile.getPackageName() + "." + "JsConst", GlobalSearchScope.allScope(project));
psiClass= JavaPsiFacade.getInstance(project).findClass(mainClassFile.getPackageName() + "." + mainClassName, GlobalSearchScope.allScope(project));
int index=getIndex(psiClass);
for (XmlItem method:content){
if (method.getType()==2||method.getType()==1){
//添加JS 回调
if (!hasJsConst(jsClass,method)){
addJSConst(jsClass,method,module.getName());
}
}
if (method.getType()==0||method.getType()==1){
//添加方法
if (hasMethod(psiClass, method.getMethodName())){
continue;
}
addMethodAndFiled(psiClass, method, index);
index++;
}
}
}
示例15: resolveLayoutResourceFile
import com.intellij.psi.search.EverythingGlobalScope; //导入依赖的package包/类
private static PsiFile resolveLayoutResourceFile(PsiElement element, Project project, String name) {
// restricting the search to the current module - searching the whole project could return wrong layouts
Module module = ModuleUtil.findModuleForPsiElement(element);
PsiFile[] files = null;
if (module != null) {
// first omit libraries, it might cause issues like (#103)
GlobalSearchScope moduleScope = module.getModuleWithDependenciesScope();
files = FilenameIndex.getFilesByName(project, name, moduleScope);
if (files == null || files.length <= 0) {
// now let's do a fallback including the libraries
moduleScope = module.getModuleWithDependenciesAndLibrariesScope(false);
files = FilenameIndex.getFilesByName(project, name, moduleScope);
}
}
if (files == null || files.length <= 0) {
// fallback to search through the whole project
// useful when the project is not properly configured - when the resource directory is not configured
files = FilenameIndex.getFilesByName(project, name, new EverythingGlobalScope(project));
if (files.length <= 0) {
return null; //no matching files
}
}
// TODO - we have a problem here - we still can have multiple layouts (some coming from a dependency)
// we need to resolve R class properly and find the proper layout for the R class
for (PsiFile file : files) {
log.info("Resolved layout resource file for name [" + name + "]: " + file.getVirtualFile());
}
return files[0];
}