use of com.intellij.psi.PsiPackage in project intellij-community by JetBrains.
the class AbstractTestNGPackageConfigurationProducer method setupConfigurationFromContext.
@Override
protected boolean setupConfigurationFromContext(TestNGConfiguration configuration, ConfigurationContext context, Ref<PsiElement> sourceElement) {
final PsiElement element = context.getPsiLocation();
PsiPackage aPackage = JavaRuntimeConfigurationProducerBase.checkPackage(element);
if (aPackage == null) {
return false;
}
final Location location = context.getLocation();
if (location == null) {
return false;
}
if (!LocationUtil.isJarAttached(location, aPackage, TestNGUtil.TEST_ANNOTATION_FQN)) {
return false;
}
final TestData data = configuration.data;
data.PACKAGE_NAME = aPackage.getQualifiedName();
data.TEST_OBJECT = TestType.PACKAGE.getType();
data.setScope(setupPackageConfiguration(context, configuration, data.getScope()));
configuration.setGeneratedName();
sourceElement.set(aPackage);
return true;
}
use of com.intellij.psi.PsiPackage in project intellij-community by JetBrains.
the class TestData method setMainClass.
public Module setMainClass(PsiClass psiclass) {
MAIN_CLASS_NAME = JavaExecutionUtil.getRuntimeQualifiedName(psiclass);
PsiPackage psipackage = JUnitUtil.getContainingPackage(psiclass);
PACKAGE_NAME = psipackage == null ? "" : psipackage.getQualifiedName();
return JavaExecutionUtil.findModule(psiclass);
}
use of com.intellij.psi.PsiPackage in project intellij-community by JetBrains.
the class PackageBrowser method showDialog.
@Override
protected String showDialog() {
PackageChooserDialog chooser = new PackageChooserDialog("Choose Package", getProject());
chooser.show();
PsiPackage psiPackage = chooser.getSelectedPackage();
String packageName = psiPackage == null ? null : psiPackage.getQualifiedName();
return packageName;
}
use of com.intellij.psi.PsiPackage in project intellij-community by JetBrains.
the class CompletionTestBase method doTest.
protected void doTest(String directory) {
CamelHumpMatcher.forceStartMatching(myFixture.getTestRootDisposable());
final List<String> stringList = TestUtils.readInput(getTestDataPath() + "/" + getTestName(true) + ".test");
if (directory.length() != 0)
directory += "/";
final String fileName = directory + getTestName(true) + "." + getExtension();
myFixture.addFileToProject(fileName, stringList.get(0));
myFixture.configureByFile(fileName);
boolean old = CodeInsightSettings.getInstance().AUTOCOMPLETE_COMMON_PREFIX;
CodeInsightSettings.getInstance().AUTOCOMPLETE_COMMON_PREFIX = false;
CodeInsightSettings.getInstance().AUTOCOMPLETE_ON_CODE_COMPLETION = false;
String result = "";
try {
myFixture.completeBasic();
final LookupImpl lookup = (LookupImpl) LookupManager.getActiveLookup(myFixture.getEditor());
if (lookup != null) {
List<LookupElement> items = lookup.getItems();
if (!addReferenceVariants()) {
items = ContainerUtil.findAll(items, lookupElement -> {
final Object o = lookupElement.getObject();
return !(o instanceof PsiMember) && !(o instanceof GrVariable) && !(o instanceof GroovyResolveResult) && !(o instanceof PsiPackage);
});
}
Collections.sort(items, (o1, o2) -> o1.getLookupString().compareTo(o2.getLookupString()));
result = "";
for (LookupElement item : items) {
result = result + "\n" + item.getLookupString();
}
result = result.trim();
LookupManager.getInstance(myFixture.getProject()).hideActiveLookup();
}
} finally {
CodeInsightSettings.getInstance().AUTOCOMPLETE_ON_CODE_COMPLETION = true;
CodeInsightSettings.getInstance().AUTOCOMPLETE_COMMON_PREFIX = old;
}
assertEquals(StringUtil.trimEnd(stringList.get(1), "\n"), result);
}
use of com.intellij.psi.PsiPackage in project intellij-community by JetBrains.
the class AbstractAllInDirectoryConfigurationProducer method setupConfigurationFromContext.
@Override
protected boolean setupConfigurationFromContext(JUnitConfiguration configuration, ConfigurationContext context, Ref<PsiElement> sourceElement) {
final Project project = configuration.getProject();
final PsiElement element = context.getPsiLocation();
if (!(element instanceof PsiDirectory))
return false;
final PsiPackage aPackage = JavaRuntimeConfigurationProducerBase.checkPackage(element);
if (aPackage == null)
return false;
final VirtualFile virtualFile = ((PsiDirectory) element).getVirtualFile();
final Module module = ModuleUtilCore.findModuleForFile(virtualFile, project);
if (module == null)
return false;
if (!ModuleRootManager.getInstance(module).getFileIndex().isInTestSourceContent(virtualFile))
return false;
int testRootCount = ModuleRootManager.getInstance(module).getSourceRoots(JavaSourceRootType.TEST_SOURCE).size();
if (testRootCount < 2)
return false;
if (!LocationUtil.isJarAttached(context.getLocation(), aPackage, JUnitUtil.TESTCASE_CLASS))
return false;
setupConfigurationModule(context, configuration);
final JUnitConfiguration.Data data = configuration.getPersistentData();
data.setDirName(virtualFile.getPath());
data.TEST_OBJECT = JUnitConfiguration.TEST_DIRECTORY;
configuration.setGeneratedName();
return true;
}
Aggregations