From 819bf9673845f57d744df90c6944ad86a6acba46 Mon Sep 17 00:00:00 2001 From: mkersten Date: Fri, 25 Jul 2003 15:13:55 +0000 Subject: [PATCH] Refactored singleton reference to be accessed via getDefault() in order to be consistent with the rest of AJDE. --- asm/src/org/aspectj/asm/StructureModelManager.java | 6 +++++- .../aspectj/ajdt/internal/core/builder/AjBuildManager.java | 6 +++--- .../internal/core/builder/EmacsStructureModelManager.java | 4 ++-- .../ajdt/internal/core/builder/AjBuildManagerTest.java | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/asm/src/org/aspectj/asm/StructureModelManager.java b/asm/src/org/aspectj/asm/StructureModelManager.java index 1dbf2981d..59f32b98d 100644 --- a/asm/src/org/aspectj/asm/StructureModelManager.java +++ b/asm/src/org/aspectj/asm/StructureModelManager.java @@ -27,7 +27,7 @@ public class StructureModelManager { /** * Singleton instance. */ - public static StructureModelManager INSTANCE = new StructureModelManager(); + private static StructureModelManager INSTANCE = new StructureModelManager(); private boolean shouldSaveModel = true; protected StructureModel model = new StructureModel(); private List structureListeners = new ArrayList(); @@ -165,5 +165,9 @@ public class StructureModelManager { public void setShouldSaveModel(boolean shouldSaveModel) { this.shouldSaveModel = shouldSaveModel; } + + public static StructureModelManager getDefault() { + return INSTANCE; + } } diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java index 973be83e1..436fda9d0 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java @@ -127,7 +127,7 @@ public class AjBuildManager { if (batch) { // System.err.println("XXXX batch: " + buildConfig.getFiles()); if (buildConfig.isEmacsSymMode() || buildConfig.isGenerateModelMode()) { - bcelWorld.setModel(StructureModelManager.INSTANCE.getStructureModel()); + bcelWorld.setModel(StructureModelManager.getDefault().getStructureModel()); // in incremental build, only get updated model? } performCompilation(buildConfig.getFiles()); @@ -166,7 +166,7 @@ public class AjBuildManager { // but always returns true // XXX weaved not in Mik's incremental if (buildConfig.isGenerateModelMode()) { - StructureModelManager.INSTANCE.fireModelUpdated(); + StructureModelManager.getDefault().fireModelUpdated(); } return !handler.hasErrors(); } finally { @@ -176,7 +176,7 @@ public class AjBuildManager { private void setupModel() { String rootLabel = ""; - StructureModel model = StructureModelManager.INSTANCE.getStructureModel(); + StructureModel model = StructureModelManager.getDefault().getStructureModel(); ProgramElementNode.Kind kind = ProgramElementNode.Kind.FILE_JAVA; if (buildConfig.getConfigFile() != null) { rootLabel = buildConfig.getConfigFile().getName(); diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/EmacsStructureModelManager.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/EmacsStructureModelManager.java index 1b6283086..8f662e160 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/EmacsStructureModelManager.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/EmacsStructureModelManager.java @@ -42,11 +42,11 @@ public class EmacsStructureModelManager { } public void externalizeModel() { - if (!StructureModelManager.INSTANCE.getStructureModel().isValid()) return; + if (!StructureModelManager.getDefault().getStructureModel().isValid()) return; try { //Set fileSet = StructureModelManager.INSTANCE.getStructureModel().getFileMap().entrySet(); - Set fileSet = StructureModelManager.INSTANCE.getStructureModel().getFileMapEntrySet(); + Set fileSet = StructureModelManager.getDefault().getStructureModel().getFileMapEntrySet(); for (Iterator it = fileSet.iterator(); it.hasNext(); ) { ProgramElementNode peNode = (ProgramElementNode)((Map.Entry)it.next()).getValue(); dumpStructureToFile(peNode); diff --git a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/core/builder/AjBuildManagerTest.java b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/core/builder/AjBuildManagerTest.java index 9f65892a5..4a2fa7567 100644 --- a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/core/builder/AjBuildManagerTest.java +++ b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/core/builder/AjBuildManagerTest.java @@ -73,7 +73,7 @@ public class AjBuildManagerTest extends TestCase { }, messageWriter); String err = parser.getOtherMessages(true); assertTrue(err, null == err); - manager.setStructureModel(StructureModelManager.INSTANCE.getStructureModel()); + manager.setStructureModel(StructureModelManager.getDefault().getStructureModel()); MessageHandler handler = new MessageHandler(); manager.batchBuild(buildConfig, handler); assertCompileMessagesValid(handler); -- 2.39.5