use of com.intellij.psi.PsiPackage in project intellij-community by JetBrains.
the class PackageWrapper method getDirectories.
public PsiDirectory[] getDirectories() {
String qName = myQualifiedName;
while (qName.endsWith(".")) {
qName = StringUtil.trimEnd(qName, ".");
}
final PsiPackage aPackage = JavaPsiFacade.getInstance(myManager.getProject()).findPackage(qName);
if (aPackage != null) {
return aPackage.getDirectories();
} else {
return PsiDirectory.EMPTY_ARRAY;
}
}
use of com.intellij.psi.PsiPackage in project intellij-plugins by JetBrains.
the class JamConventionLightTestCase method getPackageJam.
/**
* Gets the JAM-element for the given package.
*
* @param packageName FQN of package.
* @param meta JAM-Meta.
* @param <Jam> JAM-Type.
* @return JAM.
*/
@NotNull
protected <Jam extends JamElement> Jam getPackageJam(final String packageName, final JamPackageMeta<Jam> meta) {
final PsiPackage myPackage = myFixture.findPackage(packageName);
assertNotNull(packageName, myPackage);
final Jam jam = meta.getJamElement(myPackage);
assertNotNull("JAM was null for " + meta + " in '" + packageName + "'", jam);
return jam;
}
use of com.intellij.psi.PsiPackage in project ServiceStack.Java by ServiceStack.
the class AddServiceStackRefHandler method getDtoPath.
private static String getDtoPath(Module module, String qualifiedPackageName, String selectedDirectory, String fileName, StringBuilder errorMessage) throws FileNotFoundException {
VirtualFile moduleFile = module.getModuleFile();
if (moduleFile == null) {
throw new FileNotFoundException("Module file not found. Unable to add DTO to project.");
}
String fullDtoPath;
PsiPackage mainPackage = JavaPsiFacade.getInstance(module.getProject()).findPackage(qualifiedPackageName);
if (mainPackage != null && mainPackage.isValid() && mainPackage.getDirectories().length > 0) {
File file = new File(selectedDirectory);
VirtualFile selectedFolder = LocalFileSystem.getInstance().findFileByIoFile(file);
if (selectedFolder == null) {
errorMessage.append("Unable to determine path for DTO file.");
throw new FileNotFoundException();
}
PsiDirectory rootPackageDir = PsiManager.getInstance(module.getProject()).findDirectory(selectedFolder);
if (rootPackageDir == null) {
errorMessage.append("Unable to determine path for DTO file.");
throw new FileNotFoundException();
}
fullDtoPath = rootPackageDir.getVirtualFile().getPath() + File.separator + getDtoFileName(fileName);
} else {
String moduleSourcePath;
if (moduleFile.getParent() == null) {
moduleSourcePath = moduleFile.getPath() + "/main/java";
} else {
moduleSourcePath = moduleFile.getParent().getPath() + "/src/main/java";
}
fullDtoPath = moduleSourcePath + File.separator + getDtoFileName(fileName);
}
return fullDtoPath;
}
use of com.intellij.psi.PsiPackage in project moe-ide-integration by multi-os-engine.
the class MOEJUnitUtil method checkConfiguration.
public static void checkConfiguration(Module module, int TESTING_TYPE, String PACKAGE_NAME, String CLASS_NAME) throws RuntimeConfigurationException {
JavaPsiFacade facade = JavaPsiFacade.getInstance(module.getProject());
switch(TESTING_TYPE) {
case TEST_ALL_IN_PACKAGE:
if (PACKAGE_NAME == null || PACKAGE_NAME.isEmpty()) {
throw new RuntimeConfigurationWarning("No test package specified");
}
final PsiPackage testPackage = facade.findPackage(PACKAGE_NAME);
if (testPackage == null) {
throw new RuntimeConfigurationWarning(ExecutionBundle.message("package.does.not.exist.error.message", PACKAGE_NAME));
}
Vector<PsiClass> packageTestClasses = MOEJUnitUtil.getTestClasses(module, PACKAGE_NAME);
if (packageTestClasses == null || packageTestClasses.size() == 0) {
throw new RuntimeConfigurationWarning("Not found test class in package: " + PACKAGE_NAME);
}
break;
case TEST_CLASS:
JavaRunConfigurationModule configurationModule = new JavaRunConfigurationModule(module.getProject(), false);
configurationModule.setModule(module);
final PsiClass testClass = configurationModule.checkModuleAndClassName(CLASS_NAME, ExecutionBundle.message("no.test.class.specified.error.text"));
if (!JUnitUtil.isTestClass(testClass)) {
throw new RuntimeConfigurationWarning(ExecutionBundle.message("class.isnt.test.class.error.message", CLASS_NAME));
}
break;
case TEST_METHOD:
// Already not used
break;
}
}
use of com.intellij.psi.PsiPackage in project google-cloud-intellij by GoogleCloudPlatform.
the class AppEngineWebSchemaProvider method getSchema.
@Override
public XmlFile getSchema(@NotNull @NonNls String url, @Nullable Module module, @NotNull PsiFile baseFile) {
if (module == null) {
return null;
}
if (url.startsWith("http://appengine.google.com/ns/")) {
AppEngineStandardFacet facet = AppEngineStandardFacet.getAppEngineFacetByModule(module);
if (facet != null) {
final File file = CloudSdkInternals.getInstance().getWebSchemeFile();
if (file == null) {
return null;
}
final VirtualFile virtualFile = LocalFileSystem.getInstance().findFileByIoFile(file);
if (virtualFile != null) {
final PsiFile psiFile = PsiManager.getInstance(module.getProject()).findFile(virtualFile);
if (psiFile instanceof XmlFile) {
return (XmlFile) psiFile;
}
}
}
} else if (url.startsWith("http://java.sun.com/xml/ns/jdo/jdoconfig")) {
final PsiPackage jdoPackage = JavaPsiFacade.getInstance(module.getProject()).findPackage("javax.jdo");
final GlobalSearchScope scope = GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module);
if (jdoPackage != null) {
for (PsiDirectory directory : jdoPackage.getDirectories(scope)) {
final PsiFile file = directory.findFile("jdoconfig_2_3.xsd");
if (file instanceof XmlFile) {
return (XmlFile) file;
}
}
}
}
return null;
}
Aggregations