KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > aspectj > ajde > internal > AjdeCompiler


1
2 /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
3  *
4  * This file is part of the IDE support for the AspectJ(tm)
5  * programming language; see http://aspectj.org
6  *
7  * The contents of this file are subject to the Mozilla Public License
8  * Version 1.1 (the "License"); you may not use this file except in
9  * compliance with the License. You may obtain a copy of the License at
10  * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
11  *
12  * Software distributed under the License is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14  * for the specific language governing rights and limitations under the
15  * License.
16  *
17  * The Original Code is AspectJ.
18  *
19  * The Initial Developer of the Original Code is Xerox Corporation. Portions
20  * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation.
21  * All Rights Reserved.
22  *
23  * Contributor(s):
24  */

25
26 package org.aspectj.ajde.internal;
27
28 import java.util.*;
29 import java.io.*;
30 import org.aspectj.compiler.base.*;
31 import org.aspectj.compiler.base.parser.*;
32 import org.aspectj.compiler.base.ast.*;
33 import org.aspectj.compiler.base.cst.*;
34 import org.aspectj.compiler.crosscuts.*;
35 import org.aspectj.compiler.crosscuts.joinpoints.SuperCallJp;
36 import org.aspectj.asm.*;
37 import org.aspectj.ajde.Ajde;
38 import org.aspectj.ajde.BuildProgressMonitor;
39 import org.aspectj.asm.StructureModelManager;
40
41 /**
42  * Adds the <CODE>StructureManager.UpdateStructurePass</CODE> pass to the
43  * compile process and displays a <CODE>CompileProgressPanel</CODE> to inform
44  * the user of the compile status.
45  *
46  * @author Mik Kersten
47  */

48 public class AjdeCompiler extends AspectJCompiler {
49
50     boolean structureDirty = true;
51     private boolean doPostSymbolPasses = true;
52     private String JavaDoc configFile = null;
53     private StructureModelManager structureManager;
54     private BuildProgressMonitor progressMonitor;
55     private static final int MAX_PROGRESS_VAL = 100;
56
57     public AjdeCompiler(StructureModelManager structureManager) {
58         this.structureManager = structureManager;
59     }
60
61     public AjdeCompiler(StructureModelManager structureManager,
62                          BuildProgressMonitor progressMonitor) {
63         super(new AjdeBuildErrorHandler(Ajde.getDefault().getTaskListManager()));
64         ((AjdeBuildErrorHandler)super.errorHandler).setCompiler(this);
65         this.structureManager = structureManager;
66         this.progressMonitor = progressMonitor;
67         this.progressMonitor.setProgressBarMax(MAX_PROGRESS_VAL);
68     }
69
70     public void setDoPostSymbolPasses(boolean doPostSymbolPasses) {
71         this.doPostSymbolPasses = doPostSymbolPasses;
72     }
73
74     public void setConfigFile(String JavaDoc configFile) {
75         this.configFile = configFile;
76     }
77
78     public String JavaDoc getBuildConfigFile() {
79         return configFile;
80     }
81
82     public void abort() {
83         this.clearState();
84     }
85
86     public void addPostSymbolPasses() {
87         addPass(new StructureModelManager.UpdateStructurePass(getCompiler(), structureManager));
88         if (doPostSymbolPasses) {
89             super.addPostSymbolPasses();
90         }
91     }
92
93     protected void addBytecodeGenerationPasses() {
94         if (doPostSymbolPasses) {
95             super.addBytecodeGenerationPasses();
96         }
97     }
98
99     protected void updateCompileState(String JavaDoc section, String JavaDoc subSection, double pct) {
100         if (progressMonitor != null) {
101             progressMonitor.setProgressBarVal((int)(pct*100.0));
102             progressMonitor.setProgressText(section + ":" + subSection);
103         }
104     }
105
106     protected void initializeWorld(List filenames) {
107         super.initializeWorld(filenames);
108         structureDirty = true;
109     }
110     
111     protected void warnNoRuntime(boolean foundOld) {
112         if (foundOld) {
113             throw new BadRuntimeError();
114         } else {
115             throw new MissingRuntimeError();
116         }
117     }
118     
119     public AjdeBuildErrorHandler getAjdeBuildErrorHandler() {
120         return (AjdeBuildErrorHandler)super.errorHandler;
121     }
122 }
123
124 class MissingRuntimeError extends Error JavaDoc { }
125
126 class BadRuntimeError extends Error JavaDoc { }
127
128
Popular Tags