diff options
author | aclement <aclement> | 2004-08-03 12:31:29 +0000 |
---|---|---|
committer | aclement <aclement> | 2004-08-03 12:31:29 +0000 |
commit | 2982b4cc622a2a95429b16f0aa3c55b7e20d798a (patch) | |
tree | a1453e59e3356d36b7bacaf272298f91f6fa1407 /ajde/src | |
parent | fe049bdf23ae91b938e64fc2106aebf72be34e3b (diff) | |
download | aspectj-2982b4cc622a2a95429b16f0aa3c55b7e20d798a.tar.gz aspectj-2982b4cc622a2a95429b16f0aa3c55b7e20d798a.zip |
The BIG commit.
- Enhanced structure model support.
- *Incremental* structure model support written and tested (currently switched off, see incModelTests.xml)
- -showWeaveInfo compiler option
- existence of a 'runtimetest' surfaced through relationships
- UI can determine if errors/warnings came from DEOWs.
- Code to enable type mungers to remember source locations written (currently switched off)
Diffstat (limited to 'ajde/src')
3 files changed, 86 insertions, 10 deletions
diff --git a/ajde/src/org/aspectj/ajde/internal/CompilerAdapter.java b/ajde/src/org/aspectj/ajde/internal/CompilerAdapter.java index 34637e24f..f98e08c0e 100644 --- a/ajde/src/org/aspectj/ajde/internal/CompilerAdapter.java +++ b/ajde/src/org/aspectj/ajde/internal/CompilerAdapter.java @@ -432,6 +432,16 @@ public class CompilerAdapter { } + /** Local helper method for splitting option strings */ + private static List tokenizeString(String str) { + List tokens = new ArrayList(); + StringTokenizer tok = new StringTokenizer(str); + while ( tok.hasMoreTokens() ) { + tokens.add(tok.nextToken()); + } + return tokens; + } + /** * Helper method for configure build options. * This reads all command-line options specified @@ -448,13 +458,25 @@ public class CompilerAdapter { return true; } - StringTokenizer tok = new StringTokenizer( nonStdOptions ); - String[] args = new String[ tok.countTokens() ]; - int argCount = 0; - while ( tok.hasMoreTokens() ) { - args[argCount++] = tok.nextToken(); + // Break a string into a string array of non-standard options. + // Allows for one option to include a ' '. i.e. assuming it has been quoted, it + // won't accidentally get treated as a pair of options (can be needed for xlint props file option) + List tokens = new ArrayList(); + int ind = nonStdOptions.indexOf('\"'); + int ind2 = nonStdOptions.indexOf('\"',ind+1); + if ((ind > -1) && (ind2 > -1)) { // dont tokenize within double quotes + String pre = nonStdOptions.substring(0,ind); + String quoted = nonStdOptions.substring(ind+1,ind2); + String post = nonStdOptions.substring(ind2+1,nonStdOptions.length()); + tokens.addAll(tokenizeString(pre)); + tokens.add(quoted); + tokens.addAll(tokenizeString(post)); + } else { + tokens.addAll(tokenizeString(nonStdOptions)); } - + String[] args = (String[])tokens.toArray(new String[]{}); + + // set the non-standard options in an alternate build config // (we don't want to lose the settings we already have) CountingMessageHandler counter diff --git a/ajde/src/org/aspectj/ajde/ui/StructureModelUtil.java b/ajde/src/org/aspectj/ajde/ui/StructureModelUtil.java index fcc039e21..d9b1e8c97 100644 --- a/ajde/src/org/aspectj/ajde/ui/StructureModelUtil.java +++ b/ajde/src/org/aspectj/ajde/ui/StructureModelUtil.java @@ -14,17 +14,69 @@ package org.aspectj.ajde.ui; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.Set; +import java.util.StringTokenizer; import org.aspectj.ajde.Ajde; -import org.aspectj.asm.*; +import org.aspectj.asm.AsmManager; +import org.aspectj.asm.IHierarchy; +import org.aspectj.asm.IProgramElement; +import org.aspectj.asm.IRelationshipMap; //import org.aspectj.asm.internal.*; /** * Prototype functionality for package view clients. */ public class StructureModelUtil { - + + public static class ModelIncorrectException extends Exception { + public ModelIncorrectException(String s) { + super(s); + } + } + + /** + * Check the properties of the current model. The parameter string lists properties of the model + * that should be correct. If any of the properties are incorrect, a ModelIncorrectException is + * thrown. + * + * @param toCheck comma separated list of name=value pairs that should be found in the ModelInfo object + * @throws ModelIncorrectException thrown if any of the name=value pairs in toCheck are not found + */ + public static void checkModel(String toCheck) throws ModelIncorrectException { + Properties modelProperties = AsmManager.ModelInfo.summarizeModel().getProperties(); + + // Break toCheck into pieces and check each exists + StringTokenizer st = new StringTokenizer(toCheck,",="); + while (st.hasMoreTokens()) { + String key = st.nextToken(); + String expValue = st.nextToken(); + boolean expectingZero = false; + try { + expectingZero = (Integer.parseInt(expValue)==0); + } catch (NumberFormatException nfe) { + // this is ok as expectingZero will be false + } + String value = modelProperties.getProperty(key); + if (value == null) { + if (!expectingZero) + throw new ModelIncorrectException("Couldn't find '"+key+"' property for the model"); + } else if (!value.equals(expValue)) { + throw new ModelIncorrectException("Model property '"+key+"' incorrect: Expected "+expValue+" but found "+value); + } + } + } + /** * This method returns a map from affected source lines in a class to * a List of aspects affecting that line. diff --git a/ajde/src/org/aspectj/ajde/ui/StructureViewNodeFactory.java b/ajde/src/org/aspectj/ajde/ui/StructureViewNodeFactory.java index 4f32eedc7..2e6693d56 100644 --- a/ajde/src/org/aspectj/ajde/ui/StructureViewNodeFactory.java +++ b/ajde/src/org/aspectj/ajde/ui/StructureViewNodeFactory.java @@ -38,7 +38,9 @@ public abstract class StructureViewNodeFactory { IStructureViewNode svNode = createDeclaration(node, icon, children); String nodeHandle = node.getHandleIdentifier(); - if (nodeHandle != null) { + // Don't put relationships on fields as they can then appear twice when building the outline - + // once under clinit field-set nodes and once under the field declaration. + if (nodeHandle != null && !node.getKind().equals(IProgramElement.Kind.FIELD)) { List relationships = AsmManager.getDefault().getRelationshipMap().get(nodeHandle); if (relationships != null) { for (Iterator it = relationships.iterator(); it.hasNext(); ) { |