diff options
author | aclement <aclement> | 2010-07-14 21:04:17 +0000 |
---|---|---|
committer | aclement <aclement> | 2010-07-14 21:04:17 +0000 |
commit | ddd395e47b211e9988018f26e0684640c8f67471 (patch) | |
tree | d2a5d7446a28b30a2a41ab9314b3d21762aa0243 | |
parent | 8a156a38d994a9de5bb65e29b78ef00cd8b66be9 (diff) | |
download | aspectj-ddd395e47b211e9988018f26e0684640c8f67471.tar.gz aspectj-ddd395e47b211e9988018f26e0684640c8f67471.zip |
278496: model deletion
3 files changed, 114 insertions, 50 deletions
diff --git a/tests/src/org/aspectj/systemtest/incremental/tools/AbstractMultiProjectIncrementalAjdeInteractionTestbed.java b/tests/src/org/aspectj/systemtest/incremental/tools/AbstractMultiProjectIncrementalAjdeInteractionTestbed.java index 871e44404..eea4d8a68 100644 --- a/tests/src/org/aspectj/systemtest/incremental/tools/AbstractMultiProjectIncrementalAjdeInteractionTestbed.java +++ b/tests/src/org/aspectj/systemtest/incremental/tools/AbstractMultiProjectIncrementalAjdeInteractionTestbed.java @@ -17,12 +17,14 @@ import java.io.File; import java.io.FileOutputStream; import java.io.FileReader; import java.io.IOException; +import java.io.PrintWriter; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Set; import org.aspectj.ajdt.internal.core.builder.AjState; +import org.aspectj.asm.IProgramElement; import org.aspectj.asm.IRelationship; import org.aspectj.asm.IRelationshipMap; import org.aspectj.testing.util.FileUtil; @@ -31,6 +33,40 @@ public class AbstractMultiProjectIncrementalAjdeInteractionTestbed extends AjdeI public static boolean VERBOSE = false; + public static void dumptree(IProgramElement node, int indent) { + for (int i = 0; i < indent; i++) { + System.out.print(" "); + } + String loc = ""; + if (node != null) { + if (node.getSourceLocation() != null) { + loc = Integer.toString(node.getSourceLocation().getLine()); + } + } + // System.out.println(node + " [" + (node == null ? "null" : node.getKind().toString()) + "] " + loc); + System.out.println(node + " [" + (node == null ? "null" : node.getKind().toString()) + "] " + loc + + (node == null ? "" : " hid:" + node.getHandleIdentifier())); + if (node != null) { + // for (int i = 0; i < indent; i++) + // System.out.print(" "); + // System.out.println(" hid is " + node.getHandleIdentifier()); + // Map m = ((ProgramElement) node).kvpairs; + // if (m != null) { + // Set keys = m.keySet(); + // for (Iterator iterator = keys.iterator(); iterator.hasNext();) { + // Object object = (Object) iterator.next(); + // + // for (int i = 0; i < indent; i++) + // System.out.print(" "); + // System.out.println("kvp: " + object + " = " + m.get(object)); + // } + // } + for (Iterator i = node.getChildren().iterator(); i.hasNext();) { + dumptree((IProgramElement) i.next(), indent + 2); + } + } + } + protected void setUp() throws Exception { super.setUp(); AjdeInteractionTestbed.VERBOSE = VERBOSE; @@ -210,4 +246,12 @@ public class AbstractMultiProjectIncrementalAjdeInteractionTestbed extends AjdeI fail("Expected to find '" + expectedSubstring + "' in '" + actualString + "'"); } } + + /** @return the number of relationship pairs */ + protected void printModel(String projectName) throws Exception { + dumptree(getModelFor(projectName).getHierarchy().getRoot(), 0); + PrintWriter pw = new PrintWriter(System.out); + getModelFor(projectName).dumprels(pw); + pw.flush(); + } } diff --git a/tests/src/org/aspectj/systemtest/incremental/tools/IncrementalCompilationTests.java b/tests/src/org/aspectj/systemtest/incremental/tools/IncrementalCompilationTests.java index a89b78c9e..891580200 100644 --- a/tests/src/org/aspectj/systemtest/incremental/tools/IncrementalCompilationTests.java +++ b/tests/src/org/aspectj/systemtest/incremental/tools/IncrementalCompilationTests.java @@ -1,15 +1,20 @@ /******************************************************************** - * Copyright (c) 2010 Contributors. All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: + * Copyright (c) 2010 Contributors. All rights reserved. + * This program and the accompanying materials are made available + * under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution and is available at + * http://eclipse.org/legal/epl-v10.html + * + * Contributors: * Andy Clement (SpringSource) initial implementation *******************************************************************/ package org.aspectj.systemtest.incremental.tools; +import junit.framework.Assert; + +import org.aspectj.asm.IProgramElement; +import org.aspectj.asm.internal.AspectJElementHierarchy; + /** * Incremental compilation tests. MultiProjectIncrementalTests was getting unwieldy - started this new test class for 1.6.10. * @@ -140,7 +145,6 @@ public class IncrementalCompilationTests extends AbstractMultiProjectIncremental // removing class public void testInnerClassChanges_318884_10() throws Exception { - AjdeInteractionTestbed.VERBOSE = true; String p = "pr318884_10"; initialiseProject(p); build(p); @@ -152,4 +156,62 @@ public class IncrementalCompilationTests extends AbstractMultiProjectIncremental assertEquals(2, getErrorMessages(p).size()); assertContains("B cannot be resolved to a type", getErrorMessages(p).get(0)); } + + // deleting unaffected model entries + public void testDeletion_278496() throws Exception { + String p = "PR278496_1"; + initialiseProject(p); + configureNonStandardCompileOptions(p, "-Xset:minimalModel=true"); + build(p); + checkWasFullBuild(); + printModel(p); + // Here is the model without deletion. The node for 'Code.java' can safely be deleted as it contains + // no types that are the target of relationships. + // PR278496_1 [build configuration file] hid:=PR278496_1 + // a.b.c [package] hid:=PR278496_1<a.b.c + // Azpect.java [java source file] 1 hid:=PR278496_1<a.b.c{Azpect.java + // a.b.c [package declaration] 1 hid:=PR278496_1<a.b.c{Azpect.java%a.b.c + // [import reference] hid:=PR278496_1<a.b.c{Azpect.java# + // Azpect [aspect] 3 hid:=PR278496_1<a.b.c{Azpect.java}Azpect + // before(): <anonymous pointcut> [advice] 4 hid:=PR278496_1<a.b.c{Azpect.java}Azpect&before + // Code.java [java source file] 1 hid:=PR278496_1<a.b.c{Code.java + // a.b.c [package declaration] 1 hid:=PR278496_1<a.b.c{Code.java%a.b.c + // [import reference] hid:=PR278496_1<a.b.c{Code.java# + // java.util.ArrayList [import reference] 3 hid:=PR278496_1<a.b.c{Code.java#java.util.ArrayList + // java.util.List [import reference] 2 hid:=PR278496_1<a.b.c{Code.java#java.util.List + // Code [class] 5 hid:=PR278496_1<a.b.c{Code.java[Code + // m() [method] 6 hid:=PR278496_1<a.b.c{Code.java[Code~m + // Code2.java [java source file] 1 hid:=PR278496_1<a.b.c{Code2.java + // a.b.c [package declaration] 1 hid:=PR278496_1<a.b.c{Code2.java%a.b.c + // [import reference] hid:=PR278496_1<a.b.c{Code2.java# + // java.util.ArrayList [import reference] 3 hid:=PR278496_1<a.b.c{Code2.java#java.util.ArrayList + // java.util.List [import reference] 2 hid:=PR278496_1<a.b.c{Code2.java#java.util.List + // Code2 [class] 5 hid:=PR278496_1<a.b.c{Code2.java[Code2 + // m() [method] 6 hid:=PR278496_1<a.b.c{Code2.java[Code2~m + // Hid:1:(targets=1) =PR278496_1<a.b.c{Azpect.java}Azpect&before (advises) =PR278496_1<a.b.c{Code2.java[Code2 + // Hid:2:(targets=1) =PR278496_1<a.b.c{Code2.java[Code2 (advised by) =PR278496_1<a.b.c{Azpect.java}Azpect&before + + // deletion turned on: + // PR278496_1 [build configuration file] hid:=PR278496_1 + // a.b.c [package] hid:<a.b.c + // Azpect.java [java source file] 1 hid:<a.b.c{Azpect.java + // a.b.c [package declaration] 1 hid:<a.b.c{Azpect.java%a.b.c + // [import reference] hid:<a.b.c{Azpect.java# + // Azpect [aspect] 3 hid:<a.b.c{Azpect.java}Azpect + // before(): <anonymous pointcut> [advice] 4 hid:<a.b.c{Azpect.java}Azpect&before + // Code2.java [java source file] 1 hid:<a.b.c{Code2.java + // a.b.c [package declaration] 1 hid:<a.b.c{Code2.java%a.b.c + // [import reference] hid:<a.b.c{Code2.java# + // java.util.ArrayList [import reference] 3 hid:<a.b.c{Code2.java#java.util.ArrayList + // java.util.List [import reference] 2 hid:<a.b.c{Code2.java#java.util.List + // Code2 [class] 5 hid:<a.b.c{Code2.java[Code2 + // m() [method] 6 hid:<a.b.c{Code2.java[Code2~m + // Hid:1:(targets=1) <a.b.c{Azpect.java}Azpect&before (advises) <a.b.c{Code2.java[Code2 + // Hid:2:(targets=1) <a.b.c{Code2.java[Code2 (advised by) <a.b.c{Azpect.java}Azpect&before + + AspectJElementHierarchy model = (AspectJElementHierarchy) getModelFor(p).getHierarchy(); + // Node for "Code.java" should not be there: + IProgramElement ipe = model.findElementForHandleOrCreate("=PR278496_1<a.b.c{Code.java",false); + Assert.assertNull(ipe); + } } diff --git a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java index ef5301b99..ce598dfeb 100644 --- a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java +++ b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java @@ -1489,40 +1489,6 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa // dumptree(AsmManager.getDefault().getHierarchy().getRoot(), 0); } - public static void dumptree(IProgramElement node, int indent) { - for (int i = 0; i < indent; i++) { - System.out.print(" "); - } - String loc = ""; - if (node != null) { - if (node.getSourceLocation() != null) { - loc = Integer.toString(node.getSourceLocation().getLine()); - } - } - // System.out.println(node + " [" + (node == null ? "null" : node.getKind().toString()) + "] " + loc); - System.out.println(node + " [" + (node == null ? "null" : node.getKind().toString()) + "] " + loc - + (node == null ? "" : " hid:" + node.getHandleIdentifier())); - if (node != null) { - // for (int i = 0; i < indent; i++) - // System.out.print(" "); - // System.out.println(" hid is " + node.getHandleIdentifier()); - // Map m = ((ProgramElement) node).kvpairs; - // if (m != null) { - // Set keys = m.keySet(); - // for (Iterator iterator = keys.iterator(); iterator.hasNext();) { - // Object object = (Object) iterator.next(); - // - // for (int i = 0; i < indent; i++) - // System.out.print(" "); - // System.out.println("kvp: " + object + " = " + m.get(object)); - // } - // } - for (Iterator i = node.getChildren().iterator(); i.hasNext();) { - dumptree((IProgramElement) i.next(), indent + 2); - } - } - } - public void testIncrementalItdsWithMultipleAspects_pr173729() { initialiseProject("PR173729"); build("PR173729"); @@ -1597,14 +1563,6 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa // assertEquals("=AspectPathTwo/binaries<(Asp2.class}Asp2&before", findElementAtLine(root, 16).getHandleIdentifier()); } - /** @return the number of relationship pairs */ - private void printModel(String projectName) throws Exception { - dumptree(getModelFor(projectName).getHierarchy().getRoot(), 0); - PrintWriter pw = new PrintWriter(System.out); - getModelFor(projectName).dumprels(pw); - pw.flush(); - } - public void testAspectPath_pr265693() throws IOException { String bug = "AspectPath3"; String bug2 = "AspectPath4"; |