use of com.intellij.psi.JavaPsiFacade in project intellij-plugins by JetBrains.
the class CucumberConfigUtil method getSimpleVersionFromMainClass.
private static String getSimpleVersionFromMainClass(Module module) {
final JavaPsiFacade facade = JavaPsiFacade.getInstance(module.getProject());
final PsiClass oldMain = facade.findClass(CUCUMBER_CLI_MAIN_1_0, module.getModuleWithLibrariesScope());
if (oldMain != null)
return CUCUMBER_VERSION_1_0;
final PsiClass newMain = facade.findClass(CUCUMBER_API_CLI_MAIN_1_1, module.getModuleWithLibrariesScope());
if (newMain != null)
return CUCUMBER_VERSION_1_1;
return null;
}
use of com.intellij.psi.JavaPsiFacade in project android by JetBrains.
the class DataBindingScopeTest method testAccessFromInaccessibleScope.
public void testAccessFromInaccessibleScope() throws Exception {
loadProject(PROJECT_WITH_DATA_BINDING_AND_SIMPLE_LIB);
// temporary fix until test model can detect dependencies properly
GradleInvocationResult assembleDebug = invokeGradleTasks(getProject(), "assembleDebug");
GradleSyncState syncState = GradleSyncState.getInstance(getProject());
assertFalse(syncState.isSyncNeeded().toBoolean());
assertTrue(myAndroidFacet.isDataBindingEnabled());
assertTrue(myModules.hasModule("lib"));
assertTrue(myModules.hasModule("lib2"));
// app depends on lib depends on lib2
// trigger initialization
myAndroidFacet.getModuleResources(true);
JavaPsiFacade javaPsiFacade = JavaPsiFacade.getInstance(getProject());
String appBindingClassName = "com.android.example.appwithdatabinding.databinding.ActivityMainBinding";
assertNotNull(javaPsiFacade.findClass(appBindingClassName, myAndroidFacet.getModule().getModuleWithDependenciesScope()));
assertNull(javaPsiFacade.findClass(appBindingClassName, myModules.getModule("lib").getModuleWithDependenciesScope()));
assertNull(javaPsiFacade.findClass(appBindingClassName, myModules.getModule("lib2").getModuleWithDependenciesScope()));
// only exists in lib
String libLayoutBindingClassName = "com.foo.bar.databinding.LibLayoutBinding";
assertNotNull(javaPsiFacade.findClass(libLayoutBindingClassName, myAndroidFacet.getModule().getModuleWithDependenciesScope()));
assertNotNull(javaPsiFacade.findClass(libLayoutBindingClassName, myModules.getModule("lib").getModuleWithDependenciesScope()));
assertNull(javaPsiFacade.findClass(libLayoutBindingClassName, myModules.getModule("lib2").getModuleWithDependenciesScope()));
// only exists in lib2
String lib2LayoutBindingClassName = "com.foo.bar2.databinding.Lib2LayoutBinding";
assertNotNull(javaPsiFacade.findClass(lib2LayoutBindingClassName, myAndroidFacet.getModule().getModuleWithDependenciesScope()));
assertNotNull(javaPsiFacade.findClass(lib2LayoutBindingClassName, myModules.getModule("lib").getModuleWithDependenciesScope()));
assertNotNull(javaPsiFacade.findClass(lib2LayoutBindingClassName, myModules.getModule("lib2").getModuleWithDependenciesScope()));
}
use of com.intellij.psi.JavaPsiFacade in project android by JetBrains.
the class AndroidXmlTagDescriptor method getContentType.
@Override
public int getContentType() {
if (myDeclarationClass != null) {
final GlobalSearchScope scope = myDeclarationClass.getResolveScope();
final JavaPsiFacade facade = JavaPsiFacade.getInstance(myDeclarationClass.getProject());
final PsiClass view = facade.findClass(SdkConstants.CLASS_VIEW, scope);
if (view != null && myDeclarationClass.isInheritor(view, true)) {
final PsiClass viewGroup = facade.findClass(SdkConstants.CLASS_VIEWGROUP, scope);
if (viewGroup != null) {
return myDeclarationClass.isInheritor(viewGroup, true) ? CONTENT_TYPE_MIXED : CONTENT_TYPE_EMPTY;
}
}
}
return myParentDescriptor.getContentType();
}
use of com.intellij.psi.JavaPsiFacade in project android by JetBrains.
the class AndroidConfigurationProducer method getActivityClass.
@Nullable
private static PsiClass getActivityClass(Location location, ConfigurationContext context) {
final Module module = context.getModule();
if (module == null)
return null;
location = JavaExecutionUtil.stepIntoSingleClass(location);
if (location == null) {
return null;
}
PsiElement element = location.getPsiElement();
JavaPsiFacade facade = JavaPsiFacade.getInstance(element.getProject());
GlobalSearchScope scope = module.getModuleWithDependenciesAndLibrariesScope(true);
PsiClass activityClass = facade.findClass(AndroidUtils.ACTIVITY_BASE_CLASS_NAME, scope);
if (activityClass == null)
return null;
PsiClass elementClass = PsiTreeUtil.getParentOfType(element, PsiClass.class, false);
while (elementClass != null) {
if (elementClass.isInheritor(activityClass, true)) {
return elementClass;
}
elementClass = PsiTreeUtil.getParentOfType(elementClass, PsiClass.class);
}
return null;
}
use of com.intellij.psi.JavaPsiFacade in project android by JetBrains.
the class AndroidInheritingClassVisibilityChecker method isVisible.
@Override
protected boolean isVisible(@NotNull Module module, @NotNull PsiClass aClass) {
final JavaPsiFacade facade = JavaPsiFacade.getInstance(myProject);
final PsiClass baseClass = facade.findClass(myBaseClassName, module.getModuleWithDependenciesAndLibrariesScope(true));
return baseClass != null && (aClass).isInheritor(baseClass, true);
}
Aggregations