use of com.intellij.psi.JavaPsiFacade in project oxy-template-support-plugin by mutant-industries.
the class InnerJsReferenceExpressionResolver method getResultsFromProcessor.
/**
* !! TEMP CODE - https://youtrack.jetbrains.com/issue/IDEA-138078 !!
*
* duplicated code to {@link NashornJSReferenceExpressionResolver#getResultsFromProcessor(WalkUpResolveProcessor)}
* - {@link super#resolveInPsiClass(PsiClass, boolean)} will one day (hopefully) be protected
*/
// --------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------
protected ResolveResult[] getResultsFromProcessor(WalkUpResolveProcessor processor) {
List<JSTaggedResolveResult> taggedResolveResults = processor.getTaggedResolveResults();
if (taggedResolveResults.isEmpty() || (taggedResolveResults.get(0)).hasTag(JSTaggedResolveResult.ResolveResultTag.PARTIAL)) {
Module module;
if (JSSymbolUtil.isAccurateReferenceExpression(this.myRef)) {
if (this.myQualifier instanceof JSReferenceExpression) {
PsiElement qualifierResolve = ((JSReferenceExpression) this.myQualifier).resolve();
if (qualifierResolve instanceof PsiClass) {
List<ResolveResult> results = this.resolveInPsiClass((PsiClass) qualifierResolve, true);
return results.isEmpty() ? ResolveResult.EMPTY_ARRAY : results.toArray(new ResolveResult[results.size()]);
}
}
JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(this.myContainingFile.getProject());
module = ModuleUtilCore.findModuleForPsiElement(this.myContainingFile);
JSQualifiedName qualifiedName = JSSymbolUtil.getAccurateReferenceName(this.myRef);
if (qualifiedName != null) {
qualifiedName = ((JSQualifiedNameImpl) qualifiedName).withoutInnermostComponent("Packages");
}
if (qualifiedName != null) {
String qName = qualifiedName.getQualifiedName();
if (module != null) {
PsiClass aClass = psiFacade.findClass(qName, GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module));
if (aClass != null) {
return new ResolveResult[] { new JSResolveResult(aClass) };
}
}
PsiPackage aPackage = psiFacade.findPackage(qName);
if (aPackage != null) {
return new ResolveResult[] { new JSResolveResult(aPackage) };
}
}
}
JSTypeInfo typeInfo = processor.getTypeInfo();
if (!typeInfo.myContextLevels.isEmpty() && (module = ModuleUtilCore.findModuleForPsiElement(this.myContainingFile)) != null) {
JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(this.myContainingFile.getProject());
GlobalSearchScope scope = GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module);
List<ResolveResult> javaResults = new SmartList();
boolean contextResolvesToJavaClass = false;
Iterator var9 = typeInfo.myContextLevels.iterator();
while (var9.hasNext()) {
JSContextLevel level = (JSContextLevel) var9.next();
JSQualifiedName qualifiedName = level.myNamespace.getQualifiedName();
if (level.myRelativeLevel == 0 && qualifiedName != null) {
PsiClass aClass = psiFacade.findClass(qualifiedName.getQualifiedName(), scope);
if (aClass != null) {
contextResolvesToJavaClass = true;
List<ResolveResult> results = this.resolveInPsiClass(aClass, level.myNamespace.getJSContext() == JSContext.STATIC);
javaResults.addAll(results);
}
}
}
if (contextResolvesToJavaClass) {
return javaResults.toArray(ResolveResult.EMPTY_ARRAY);
}
}
}
return processor.getResults();
}
use of com.intellij.psi.JavaPsiFacade in project AndroidPermissionsUsage by RomainPiel.
the class FindPermissionsUsageAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent event) {
final VirtualFile file = event.getData(PlatformDataKeys.VIRTUAL_FILE);
if (file == null) {
return;
}
final Project project = event.getProject();
if (project == null) {
return;
}
final Module module = ModuleUtil.findModuleForFile(file, project);
JavaPsiFacade psi = JavaPsiFacade.getInstance(project);
final PsiClass manifestClass = psi.findClass("android.Manifest.permission", AndroidSDKScope.getScope(module));
ProgressManager.getInstance().run(new FindPermissionUsagesTask(file, module, manifestClass));
}
Aggregations