use of com.intellij.psi.JavaPsiFacade in project android by JetBrains.
the class NlProperties method currentActivityIfFoundIsDerivedFromAppCompatActivity.
private static boolean currentActivityIfFoundIsDerivedFromAppCompatActivity(@NotNull List<NlComponent> components) {
assert !components.isEmpty();
NlModel model = components.get(0).getModel();
Configuration configuration = model.getConfiguration();
String activityClassName = configuration.getActivity();
if (activityClassName == null) {
// Assume we are since this is how the default activities are created.
return true;
}
if (activityClassName.startsWith(".")) {
MergedManifest manifest = MergedManifest.get(model.getModule());
String pkg = StringUtil.notNullize(manifest.getPackage());
activityClassName = pkg + activityClassName;
}
JavaPsiFacade facade = JavaPsiFacade.getInstance(model.getProject());
PsiClass activityClass = facade.findClass(activityClassName, model.getModule().getModuleScope());
while (activityClass != null && !CLASS_APP_COMPAT_ACTIVITY.equals(activityClass.getQualifiedName())) {
activityClass = activityClass.getSuperClass();
}
return activityClass != null;
}
use of com.intellij.psi.JavaPsiFacade in project intellij-community by JetBrains.
the class DescriptionCheckerUtil method getDescriptionsDirs.
public static PsiDirectory[] getDescriptionsDirs(Module module, DescriptionType descriptionType) {
final JavaPsiFacade javaPsiFacade = JavaPsiFacade.getInstance(module.getProject());
final PsiPackage psiPackage = javaPsiFacade.findPackage(descriptionType.getDescriptionFolder());
if (psiPackage != null) {
return psiPackage.getDirectories(GlobalSearchScope.moduleWithDependenciesScope(module));
}
return PsiDirectory.EMPTY_ARRAY;
}
use of com.intellij.psi.JavaPsiFacade in project intellij-community by JetBrains.
the class FindClassUtil method findModulesWithClass.
/**
* Searches the project for modules that contain the class with the specified full-qualified name within
* the module dependencies or libraries.
*
* @param qualifiedName the full-qualified name of the class to find.
* @return the modules that contain the given class in dependencies or libraries.
*/
@NotNull
public static Collection<Module> findModulesWithClass(@NotNull Project project, @NonNls @NotNull String qualifiedName) {
GlobalSearchScope allScope = GlobalSearchScope.allScope(project);
JavaPsiFacade facade = JavaPsiFacade.getInstance(project);
PsiClass[] possibleClasses = facade.findClasses(qualifiedName, allScope);
if (possibleClasses.length == 0) {
return Collections.emptyList();
}
Set<Module> relevantModules = ContainerUtil.newLinkedHashSet();
ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
for (PsiClass aClass : possibleClasses) {
VirtualFile classFile = aClass.getContainingFile().getVirtualFile();
for (OrderEntry orderEntry : fileIndex.getOrderEntriesForFile(classFile)) {
relevantModules.add(orderEntry.getOwnerModule());
}
}
return relevantModules;
}
use of com.intellij.psi.JavaPsiFacade in project intellij-community by JetBrains.
the class JavaFormatterTest method testAssertStatementWrapping2.
public void testAssertStatementWrapping2() throws Exception {
getSettings().BINARY_OPERATION_WRAP = CommonCodeStyleSettings.DO_NOT_WRAP;
getSettings().ASSERT_STATEMENT_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
getSettings().RIGHT_MARGIN = 37;
final CommonCodeStyleSettings.IndentOptions options = getSettings().getRootSettings().getIndentOptions(StdFileTypes.JAVA);
options.INDENT_SIZE = 2;
options.CONTINUATION_INDENT_SIZE = 2;
getSettings().ASSERT_STATEMENT_COLON_ON_NEXT_LINE = true;
final JavaPsiFacade facade = getJavaFacade();
final LanguageLevel effectiveLanguageLevel = LanguageLevelProjectExtension.getInstance(facade.getProject()).getLanguageLevel();
LanguageLevelProjectExtension.getInstance(facade.getProject()).setLanguageLevel(LanguageLevel.JDK_1_5);
try {
doTextTest("class Foo {\n" + " void foo() {\n" + " assert i + j + k + l + n + m <= 2 : \"assert description\";" + " }\n" + "}", "class Foo {\n" + " void foo() {\n" + " assert i + j + k + l + n + m <= 2\n" + " : \"assert description\";\n" + " }\n" + "}");
getSettings().ASSERT_STATEMENT_COLON_ON_NEXT_LINE = false;
doTextTest("class Foo {\n" + " void foo() {\n" + " assert i + j + k + l + n + m <= 2 : \"assert description\";" + " }\n" + "}", "class Foo {\n" + " void foo() {\n" + " assert\n" + " i + j + k + l + n + m <= 2 :\n" + " \"assert description\";\n" + " }\n" + "}");
} finally {
LanguageLevelProjectExtension.getInstance(facade.getProject()).setLanguageLevel(effectiveLanguageLevel);
}
}
use of com.intellij.psi.JavaPsiFacade in project intellij-community by JetBrains.
the class JavaFormatterTest method testAssertStatementWrapping.
public void testAssertStatementWrapping() throws Exception {
getSettings().ASSERT_STATEMENT_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
getSettings().BINARY_OPERATION_WRAP = CommonCodeStyleSettings.DO_NOT_WRAP;
getSettings().RIGHT_MARGIN = 40;
final JavaPsiFacade facade = getJavaFacade();
final LanguageLevel effectiveLanguageLevel = LanguageLevelProjectExtension.getInstance(facade.getProject()).getLanguageLevel();
try {
LanguageLevelProjectExtension.getInstance(facade.getProject()).setLanguageLevel(LanguageLevel.JDK_1_5);
getSettings().ASSERT_STATEMENT_COLON_ON_NEXT_LINE = false;
doTextTest("class Foo {\n" + " void foo() {\n" + " assert methodWithVeryVeryLongName() : foo;\n" + " assert i + j + k + l + n + m <= 2 : \"assert description\";\n" + " }\n" + "}\n", "class Foo {\n" + " void foo() {\n" + " assert methodWithVeryVeryLongName() :\n" + " foo;\n" + " assert i + j + k + l + n + m <= 2 :\n" + " \"assert description\";\n" + " }\n" + "}\n");
getSettings().ASSERT_STATEMENT_COLON_ON_NEXT_LINE = true;
doTextTest("class Foo {\n" + " void foo() {\n" + " assert methodWithVeryVeryLongName() : foo;\n" + " assert i + j + k + l + n + m <= 2 : \"assert description\";\n" + " }\n" + "}\n", "class Foo {\n" + " void foo() {\n" + " assert methodWithVeryVeryLongName()\n" + " : foo;\n" + " assert i + j + k + l + n + m <= 2\n" + " : \"assert description\";\n" + " }\n" + "}\n");
} finally {
LanguageLevelProjectExtension.getInstance(facade.getProject()).setLanguageLevel(effectiveLanguageLevel);
}
}
Aggregations