use of com.intellij.openapi.application.Result in project intellij-community by JetBrains.
the class DomFileDescriptionTest method testCheckNamespace.
public void testCheckNamespace() throws Throwable {
getDomManager().registerFileDescription(new DomFileDescription<NamespacedElement>(NamespacedElement.class, "xxx", "bar") {
@Override
protected void initializeFileDescription() {
registerNamespacePolicy("foo", "bar");
}
}, myDisposable);
final PsiFile file = createFile("xxx.xml", "<xxx/>");
assertFalse(getDomManager().isDomFile(file));
new WriteCommandAction(getProject()) {
@Override
protected void run(@NotNull Result result) throws Throwable {
((XmlFile) file).getDocument().getRootTag().setAttribute("xmlns", "bar");
}
}.execute();
assertTrue(getDomManager().isDomFile(file));
}
use of com.intellij.openapi.application.Result in project intellij-community by JetBrains.
the class DomFileDescriptionTest method testChangeCustomDomness.
public void testChangeCustomDomness() throws Throwable {
getDomManager().registerFileDescription(new DomFileDescription<MyElement>(MyElement.class, "xxx") {
@Override
public boolean isMyFile(@NotNull final XmlFile file, @Nullable final Module module) {
return file.getText().contains("foo");
}
}, myDisposable);
final XmlFile file = (XmlFile) createFile("xxx.xml", "<xxx zzz=\"foo\"><boy/><boy/><xxx/>");
final MyElement boy = getDomManager().getFileElement(file, MyElement.class).getRootElement().getBoys().get(0);
new WriteCommandAction(getProject()) {
@Override
protected void run(@NotNull Result result) throws Throwable {
file.getDocument().getRootTag().setAttribute("zzz", "bar");
}
}.execute();
assertFalse(getDomManager().isDomFile(file));
assertFalse(boy.isValid());
}
use of com.intellij.openapi.application.Result in project intellij-community by JetBrains.
the class DomBasicsTest method testCopyingFromNonEmptyToEmpty.
public void testCopyingFromNonEmptyToEmpty() throws Throwable {
Module module = new MockModule(getTestRootDisposable());
final MyElement element1 = getDomManager().createMockElement(MyElement.class, module, false);
final MyElement element2 = getDomManager().createMockElement(MyElement.class, module, false);
element2.ensureTagExists();
assertNull(element2.getChild().getChild().getGenericValue().getStringValue());
element1.getChild().getChild().getGenericValue().setStringValue("abc");
new WriteCommandAction(getProject()) {
@Override
protected void run(@NotNull Result result) throws Throwable {
element2.copyFrom(element1);
}
}.execute();
assertEquals("abc", element2.getChild().getChild().getGenericValue().getStringValue());
}
use of com.intellij.openapi.application.Result in project intellij-community by JetBrains.
the class GrabDependencies method prepareQueries.
static Map<String, String> prepareQueries(PsiFile file) {
final Set<GrAnnotation> grabs = new LinkedHashSet<>();
final Set<GrAnnotation> excludes = new THashSet<>();
final Set<GrAnnotation> resolvers = new THashSet<>();
file.acceptChildren(new PsiRecursiveElementWalkingVisitor() {
@Override
public void visitElement(PsiElement element) {
if (element instanceof GrAnnotation) {
GrAnnotation anno = (GrAnnotation) element;
String qname = anno.getQualifiedName();
if (GrabAnnos.GRAB_ANNO.equals(qname))
grabs.add(anno);
else if (GrabAnnos.GRAB_EXCLUDE_ANNO.equals(qname))
excludes.add(anno);
else if (GrabAnnos.GRAB_RESOLVER_ANNO.equals(qname))
resolvers.add(anno);
}
super.visitElement(element);
}
});
Function<GrAnnotation, String> mapper = grAnnotation -> grAnnotation.getText();
String common = StringUtil.join(excludes, mapper, " ") + " " + StringUtil.join(resolvers, mapper, " ");
LinkedHashMap<String, String> result = new LinkedHashMap<>();
for (GrAnnotation grab : grabs) {
String grabText = grab.getText();
result.put(grabText, (grabText + " " + common).trim());
}
return result;
}
use of com.intellij.openapi.application.Result in project intellij-community by JetBrains.
the class StructureImportingTest method testParentInLocalRepository.
public void testParentInLocalRepository() throws Exception {
if (!hasMavenInstallation())
return;
final VirtualFile parent = createModulePom("parent", "<groupId>test</groupId>" + "<artifactId>parent</artifactId>" + "<version>1</version>" + "<packaging>pom</packaging>" + "<dependencies>" + " <dependency>" + " <groupId>junit</groupId>" + " <artifactId>junit</artifactId>" + " <version>4.0</version>" + " </dependency>" + "</dependencies>");
executeGoal("parent", "install");
new WriteAction() {
protected void run(@NotNull Result result) throws Throwable {
parent.delete(null);
}
}.execute();
createProjectPom("<groupId>test</groupId>" + "<artifactId>m</artifactId>" + "<version>1</version>" + "<parent>" + " <groupId>test</groupId>" + " <artifactId>parent</artifactId>" + " <version>1</version>" + "</parent>");
importProject();
assertModules("m");
assertModuleLibDeps("m", "Maven: junit:junit:4.0");
}
Aggregations