Changeset 452


Ignore:
Timestamp:
Jul 5, 2010 3:57:08 AM (14 years ago)
Author:
Anya Helene Bagge
Message:
Location:
trunk/MagnoliaPlugin
Files:
12 added
1 deleted
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagnoliaPlugin/plugin.xml

    r451 r452  
    204204   </extension>
    205205   <extension
     206         id="compilationError"
     207         name="Compilation Error"
     208         point="org.eclipse.core.resources.markers">
     209      <super
     210            type="org.eclipse.core.resources.problemmarker">
     211      </super>
     212      <persistent
     213            value="false">
     214      </persistent>
     215   </extension>
     216   <extension
     217         id="syntaxError"
     218         name="Syntax Error"
     219         point="org.eclipse.core.resources.markers">
     220      <super
     221            type="magnolia_eclipse.compilationError">
     222      </super>
     223      <persistent
     224            value="false">
     225      </persistent>
     226   </extension>
     227   <extension
     228         id="loadError"
     229         name="Load Error"
     230         point="org.eclipse.core.resources.markers">
     231      <super
     232            type="magnolia_eclipse.compilationError">
     233      </super>
     234      <persistent
     235            value="false">
     236      </persistent>
     237   </extension>
     238    <extension
    206239         id="ambiguityMarker"
    207240         name="Ambiguity"
  • trunk/MagnoliaPlugin/src/org/magnolialang/eclipse/builders/MagnoliaBuilder.java

    r397 r452  
    11package org.magnolialang.eclipse.builders;
     2
     3import java.net.URI;
    24
    35import org.eclipse.core.resources.IFile;
     
    1921
    2022import org.magnolialang.eclipse.MagnoliaPlugin;
     23import org.magnolialang.eclipse.editor.ImplementationError;
    2124import org.magnolialang.eclipse.editor.ParseController;
     25import org.magnolialang.errors.CompilationError;
     26import org.magnolialang.errors.ErrorMarkers;
     27import org.magnolialang.errors.SyntaxError;
     28import org.magnolialang.load.ProjectURIResolver;
     29import org.magnolialang.manager.IModuleInfo;
     30import org.magnolialang.manager.MagnoliaProjectManager;
    2231
    2332/**
     
    4049         * A marker ID that identifies problems detected by the builder
    4150         */
    42         public static final String PROBLEM_MARKER_ID = MagnoliaPlugin.kPluginID
    43                         + ".magnolia.imp.builder.problem";
     51        public static final String PROBLEM_MARKER_ID = ErrorMarkers.COMPILATION_ERROR;
    4452
    4553        public static final String LANGUAGE_NAME = "Magnolia";
     
    106114         */
    107115        protected void collectDependencies(IFile file) {
    108                 String fromPath = file.getFullPath().toString();
    109 
    110                 getPlugin()
    111                                 .writeInfoMsg(
    112                                                 "Collecting dependencies from Magnolia file: "
    113                                                                 + file.getName());
    114 
    115                 // TODO: implement dependency collector
    116                 // E.g. for each dependency:
    117                 // fDependencyInfo.addDependency(fromPath, uponPath);
     116                getPlugin().writeInfoMsg("Collecting dependencies from Magnolia file: " + file.getName());
     117                MagnoliaProjectManager manager = MagnoliaProjectManager.getProjectManager(file.getProject());
     118                try {
     119                        IModuleInfo module = manager.getModule(manager.getModuleName(file));
     120                        IPath fromPath = ProjectURIResolver.getFile(module.getURI()).getFullPath();
     121                        for(URI uri : module.getEnv().getDependencies()) {
     122                                fDependencyInfo.addDependency(fromPath.toString(), ProjectURIResolver.getFile(uri).getFullPath().toString());
     123                        }
     124                }
     125                catch(SyntaxError e) {
     126                }
     127                catch(CompilationError ce) {
     128                        manager.reportError(ce, "Dependency Checker");
     129                }
    118130        }
    119131
     
    129141         */
    130142        protected void compile(final IFile file, IProgressMonitor monitor) {
     143                MagnoliaProjectManager manager = MagnoliaProjectManager.getProjectManager(file.getProject());
    131144                try {
    132145                        getPlugin().writeInfoMsg(
    133146                                        "Building Magnolia file: " + file.getName());
    134147
    135                         // START_HERE
    136                         //MagnoliaCompiler compiler= new MagnoliaCompiler(PROBLEM_MARKER_ID);
    137                         //compiler.compile(file, monitor);
    138                         // Here we provide a substitute for the compile method that simply
    139                         // runs the parser in place of the compiler but creates problem
    140                         // markers for errors that will show up in the problems view
    141                         runParserForCompiler(file, monitor);
    142 
    143                         doRefresh(file.getParent()); // N.B.: Assumes all generated files go into parent folder
     148                        IModuleInfo module = manager.getModule(manager.getModuleName(file));
     149                        module.getEnv();
     150                } catch(CompilationError ce) {
     151                        manager.reportError(ce, "Compiler");
    144152                } catch (Exception e) {
    145153                        // catch Exception, because any exception could break the
     
    183191        protected void runParserForCompiler(final IFile file,
    184192                        IProgressMonitor monitor) {
     193               
    185194                try {
    186195                        IParseController parseController = new ParseController();
     
    210219                                                        e);
    211220                }
    212         }
     221
     222                        }
    213223}
  • trunk/MagnoliaPlugin/src/org/magnolialang/eclipse/editor/ParseController.java

    r448 r452  
    2020import org.magnolialang.eclipse.MagnoliaPlugin;
    2121import org.magnolialang.env.MagnoliaEnvironment;
     22import org.magnolialang.errors.SyntaxError;
    2223import org.magnolialang.load.ModuleLoader;
    2324import org.magnolialang.load.ProjectURIResolver;
    24 import org.magnolialang.manager.MagnoliaProjectManager;
    25 import org.magnolialang.xatree.TreeImploder;
    26 import org.rascalmpl.interpreter.staticErrors.SyntaxError;
     25import org.magnolialang.manager.EditedProjectManager;
    2726import org.rascalmpl.values.errors.SummaryAdapter;
    2827import org.rascalmpl.values.uptr.Factory;
     
    3736        private IConstructor parseTree;
    3837        private IPath path;
    39         private MagnoliaProjectManager manager;
     38        private EditedProjectManager manager;
    4039        private String languageName;
    4140
     
    104103                this.handler = handler;
    105104                this.project = project;
    106                 this.manager = MagnoliaProjectManager.getProjectManager(project);
     105                this.manager = EditedProjectManager.getProjectManager(project);
    107106
    108107                this.loader = new ModuleLoader(languageName, manager);
     
    119118                        URI uri = ProjectURIResolver.constructProjectURI(project, path);
    120119                        IConstructor result = loader.parseModule(uri, input, new MagnoliaEnvironment());
    121                        
    122                         if (result.getConstructorType() == Factory.ParseTree_Summary) {
    123                                 ISourceLocation location = new SummaryAdapter(result).getInitialSubject().getLocation();
    124                                 handler.handleSimpleMessage("parse error: " + location, location.getOffset(), location.getOffset() + location.getLength(), location.getBeginColumn(), location.getEndColumn(), location.getBeginLine(), location.getEndLine());
    125                         } else {
    126                                 parseTree = ParsetreeAdapter.addPositionInformation(result, uri);
    127                         }
    128                        
     120                        parseTree = ParsetreeAdapter.addPositionInformation(result, uri);
    129121                        monitor.worked(1);
    130                         return result;
     122                        return parseTree;
    131123                }
    132124                catch(FactTypeUseException e){
     
    138130                catch(SyntaxError e){
    139131                        ISourceLocation loc = e.getLocation();
    140                         e.printStackTrace();
    141132                        if (loc.getOffset() >= 0) {
    142                                 handler.handleSimpleMessage(e.getMessage(), loc.getOffset(), loc.getOffset() + loc.getLength(), loc.getBeginColumn(), loc.getEndColumn(), loc.getBeginLine(), loc.getEndLine());
     133                                handler.handleSimpleMessage("Editor: " + e.getMessage(), loc.getOffset(), loc.getOffset() + loc.getLength(), loc.getBeginColumn(), loc.getEndColumn(), loc.getBeginLine(), loc.getEndLine());
    143134                        }
    144135                        else {
    145                                 handler.handleSimpleMessage(e.getMessage(), 0, 0, 0, 0, 1, 1);
     136                                handler.handleSimpleMessage("Editor: " + e.getMessage(), 0, 0, 0, 0, 1, 1);
    146137                        }
    147138                }
     
    166157        }
    167158
    168         public MagnoliaProjectManager getManager() {
     159        public EditedProjectManager getManager() {
    169160                return manager;
    170161        }
  • trunk/MagnoliaPlugin/src/org/magnolialang/eclipse/editor/StaticCheckModelListener.java

    r449 r452  
    1717import org.magnolialang.errors.CompilationError;
    1818import org.magnolialang.magnolia.StaticChecker;
     19import org.magnolialang.manager.EditedProjectManager;
    1920import org.magnolialang.manager.MagnoliaProjectManager;
    2021
     
    2829        public void update(final IParseController parseController,
    2930                        final IProgressMonitor monitor) {
    30                 Thread x = new Thread("Magnolia Static Checker") {
     31        /*      Thread x = new Thread("Magnolia Static Checker") {
    3132                        @Override
    3233                        public void run() {
     
    4849
    4950                        private void doUpdate(ParseController ctrl, IProgressMonitor monitor) {
    50                                 MagnoliaProjectManager manager = ctrl.getManager();
     51                                EditedProjectManager manager = ctrl.getManager();
     52
    5153                                try {
    5254                                        String moduleName = manager.findEditedModule(ctrl);
     
    5658                                                MagnoliaEnvironment env = manager.getModuleEnv(moduleName);
    5759                                                monitor.worked(1);
    58 
    5960                                                checker.checkModule(tree, env);
    6061                                                monitor.worked(1);
     
    8182                        }
    8283                };
    83                 x.start();
     84                x.start();*/
    8485        }
    8586
  • trunk/MagnoliaPlugin/src/org/magnolialang/env/MagnoliaEnvironment.java

    r439 r452  
    22import static org.magnolialang.xatree.XaTreeFactory.*;
    33
     4import java.net.URI;
    45import java.util.Iterator;
     6import java.util.LinkedList;
     7import java.util.List;
    58import java.util.Map.Entry;
    69
     
    1417
    1518        private IMap imports = vf.map(tf.stringType(), Type_XaTree);
     19        private List<URI> deps = new LinkedList<URI>();
    1620       
    1721        public void addImport(String name, IValue tree) {
     
    4953                return buf.toString();
    5054        }
     55        public void addDependency(URI uri) {
     56                deps.add(uri);
     57        }
     58       
     59        public List<URI> getDependencies() {
     60                return deps;
     61        }
    5162}
  • trunk/MagnoliaPlugin/src/org/magnolialang/errors/CompilationError.java

    r428 r452  
    106106        }
    107107       
     108        public String getMarkerType() {
     109                return ErrorMarkers.COMPILATION_ERROR;
     110        }
     111       
    108112        public String getErrorType() {
    109113                return "compilation error";
  • trunk/MagnoliaPlugin/src/org/magnolialang/errors/ModuleLoadError.java

    r428 r452  
    3232                        return errorType;
    3333        }
     34       
     35        @Override
     36        public String getMarkerType() {
     37                return ErrorMarkers.LOAD_ERROR;
     38        }
    3439}
  • trunk/MagnoliaPlugin/src/org/magnolialang/errors/ModuleNotFoundError.java

    r442 r452  
    4141                return moduleName;
    4242        }
     43       
     44        @Override
     45        public String getMarkerType() {
     46                return ErrorMarkers.LOAD_ERROR;
     47        }
    4348}
  • trunk/MagnoliaPlugin/src/org/magnolialang/load/ModuleLoader.java

    r446 r452  
    1818import org.magnolialang.env.MagnoliaEnvironment;
    1919import org.magnolialang.errors.ModuleLoadError;
     20import org.magnolialang.errors.SyntaxError;
     21import org.magnolialang.manager.IModuleInfo;
    2022import org.magnolialang.manager.MagnoliaProjectManager;
    2123import org.magnolialang.xatree.TreeImploder;
    22 import org.rascalmpl.interpreter.staticErrors.SyntaxError;
    2324import org.rascalmpl.values.ValueFactoryFactory;
    2425import org.rascalmpl.values.errors.SubjectAdapter;
     
    9192                return tree;
    9293        }
     94       
     95        public IConstructor parseModuleNoError(URI location, String moduleString, MagnoliaEnvironment env) throws IOException{
     96                byte[] data = moduleString.getBytes();
     97               
     98                return parser.parseModule(location, data);
     99        }
    93100
    94101        public IConstructor parseModule(URI location) {
     
    135142                                                                IConstructor iTree;
    136143                                                                try {
    137                                                                         iTree = manager.getModuleTree(name);
     144                                                                        IModuleInfo info = manager.getModule(name);
     145                                                                        env.addDependency(info.getURI());
     146                                                                        iTree = info.getTree();
    138147                                                                }
    139148                                                                catch(Exception e) {
  • trunk/MagnoliaPlugin/src/org/magnolialang/load/ProjectURIResolver.java

    r442 r452  
    2525                        // making sure that spaces in 'path' are properly escaped
    2626                        return new URI("project", project.getName(), path.makeAbsolute().toString(), null);
     27                }catch(URISyntaxException usex){
     28                        throw new BadURIException(usex);
     29                }
     30        //      } catch (UnsupportedEncodingException e) {
     31        //              MagnoliaPlugin.getInstance().logException(e.getMessage(), e);
     32        //              return null;
     33        //      }
     34        }
     35
     36        public static URI constructProjectURI(String project, IPath path){
     37                try{
     38                        // making sure that spaces in 'path' are properly escaped
     39                        return new URI("project", project, path.makeAbsolute().toString(), null);
    2740                }catch(URISyntaxException usex){
    2841                        throw new BadURIException(usex);
  • trunk/MagnoliaPlugin/src/org/magnolialang/manager/MagnoliaProjectManager.java

    r448 r452  
    1010import org.eclipse.core.resources.IFile;
    1111import org.eclipse.core.resources.IMarker;
     12import org.eclipse.core.resources.IProject;
    1213import org.eclipse.core.resources.IResource;
     14import org.eclipse.core.resources.ResourcesPlugin;
    1315import org.eclipse.core.runtime.CoreException;
    1416import org.eclipse.core.runtime.Path;
     
    1719import org.eclipse.imp.pdb.facts.ISourceLocation;
    1820import org.eclipse.imp.utils.Pair;
    19 import org.magnolialang.eclipse.MagnoliaPlugin;
    2021import org.magnolialang.eclipse.editor.ImplementationError;
    21 import org.magnolialang.eclipse.editor.ParseController;
    2222import org.magnolialang.env.MagnoliaEnvironment;
    2323import org.magnolialang.errors.CompilationError;
     
    2929import org.magnolialang.programs.MagnoliaAdapter;
    3030import org.magnolialang.xatree.CxxSkin;
    31 import org.magnolialang.xatree.TreeImploder;
    3231import org.magnolialang.xatree.XaTreeAdapter;
    33 import org.rascalmpl.values.uptr.ParsetreeAdapter;
    3432
     33/**
     34 * @author anya
     35 *
     36 */
    3537@SuppressWarnings("deprecation")
    36 public class MagnoliaProjectManager implements IProjectManager {
     38public class MagnoliaProjectManager {
    3739        private static Map<String, MagnoliaProjectManager> managerMap;
    38 
    39         private ModuleLoader loader;
    40         private IBuildPath buildPath;
    41         private ISourceProject project;
    42         private Map<String, ModuleInfo> moduleMap;
    43         private Map<URI, String> uriMap;
    44         private Map<ParseController, ModuleInfo> ctrlMap;
     40        protected final IProject project;
     41        protected final ModuleLoader loader;
     42        protected final IBuildPath buildPath;
     43        protected final Map<String, MagnoliaModuleInfo> moduleMap;
     44        protected final Map<URI, String> uriMap;
    4545       
    46         public MagnoliaProjectManager(ISourceProject project) {
     46        public MagnoliaProjectManager(IProject project) {
    4747                this.project = project;
    4848                this.loader = new ModuleLoader(this);
    4949                this.buildPath = new MagnoliaBuildPath(null);
    5050                if(project != null)
    51                         this.buildPath.addPath(ProjectURIResolver.constructProjectURI(project, new Path("")));
    52                 this.moduleMap = new HashMap<String, ModuleInfo>();
     51                        this.buildPath.addPath(ProjectURIResolver.constructProjectURI(project.getName(), new Path("")));
     52                this.moduleMap = new HashMap<String, MagnoliaModuleInfo>();
    5353                this.uriMap = new HashMap<URI, String>();
    54                 this.ctrlMap = new IdentityHashMap<ParseController, ModuleInfo>();
    5554        }
    5655       
    57         public static MagnoliaProjectManager getProjectManager(ISourceProject project) {
     56        public static MagnoliaProjectManager getProjectManager(String project) {
    5857                if(managerMap == null)
    5958                        managerMap = new HashMap<String, MagnoliaProjectManager>();
    60                 if(managerMap.containsKey(project.getName()))
    61                         return managerMap.get(project.getName());
     59                if(managerMap.containsKey(project))
     60                        return managerMap.get(project);
    6261                else {
    63                         MagnoliaProjectManager manager = new MagnoliaProjectManager(project);
    64                         managerMap.put(project.getName(), manager);
     62                        MagnoliaProjectManager manager = new MagnoliaProjectManager(ResourcesPlugin.getWorkspace().getRoot().getProject(project));
     63                        managerMap.put(project, manager);
    6564                        return manager;
    6665                }
    6766        }
    6867
     68        public static MagnoliaProjectManager getProjectManager(IProject project) {
     69                return getProjectManager(project.getName());
     70        }
     71       
     72        public static MagnoliaProjectManager getProjectManager(ISourceProject project) {
     73                return getProjectManager(project.getName());
     74        }
     75       
    6976        public void createModule(String moduleName, IConstructor moduleTree) {
    7077
     
    7279
    7380        public void createModule(String moduleName, String sourceModuleName, IConstructor moduleTree) {
    74                 ModuleInfo srcInfo = getModuleInfo(sourceModuleName);
    75                 ModuleInfo info = moduleMap.get(moduleName);
     81                MagnoliaModuleInfo srcInfo = (MagnoliaModuleInfo) getModule(sourceModuleName);
     82                FileModuleInfo info = (FileModuleInfo) moduleMap.get(moduleName);
    7683                URI uri = srcInfo.dir.resolve(moduleName.replace('.', '/') + ".mg");
    7784                if(info == null) {
    78                         info = new ModuleInfo();
    79                         info.moduleName = moduleName;
    80                         info.uri = uri;
     85                        info = new FileModuleInfo(this, moduleName, uri, srcInfo.dir);
    8186                }
    8287                else if(!info.uri.equals(uri))
     
    8489               
    8590                moduleTree = MagnoliaAdapter.setModuleName(moduleTree, moduleName);
    86                 info.dir = srcInfo.dir; // should be same
    87                 info.tree = moduleTree;
    88                 info.parseTree = null;
    8991                String result = XaTreeAdapter.yield(moduleTree, new CxxSkin(), true);
    9092                if(result != null) {
    91                         try {
    92                                 IFile file = ProjectURIResolver.getFile(info.uri);
    93                        
    94                                 if(file.exists())
    95                                         file.setContents(new StringBufferInputStream(result), false, true, null);
    96                                 else
    97                                         file.create(new StringBufferInputStream(result), false, null);
    98                                
    99                                 info.file = file;
    100                         } catch (Exception e) {
    101                                 throw new ImplementationError("Error creating module " + moduleName, e);
    102                         }
     93                        info.setContents(result);
     94                        info.tree = moduleTree;
     95                        info.parseTree = null;
    10396                }
    10497        }
    10598
    10699        public MagnoliaEnvironment getModuleEnv(String moduleName) {
    107                 if(moduleMap.containsKey(moduleName)) {
    108                         ModuleInfo info = moduleMap.get(moduleName);
    109                         if(info.tree == null)
    110                                 getModuleTree(moduleName);
    111                         if(info.env == null) {
    112                                 info.env = new MagnoliaEnvironment();
    113                                 try {
    114                                         loader.loadModule(info.tree, info.env);
    115                                 } catch (IOException e) {
    116                                         info.env = null;
    117                                         e.printStackTrace();
    118                                 }
    119                         }
    120                         return info.env;
    121                 }
    122                 else
    123                         return null;
     100                return getModule(moduleName).getEnv();
    124101        }
     102       
    125103        public MagnoliaEnvironment getModuleEnv(URI uri) {
    126104                return getModuleEnv(getModuleName(uri));
    127105        }
    128106
    129         public IConstructor getModuleTree(String moduleName) {
    130                 return getModuleTree(moduleName, false);
    131         }
    132        
    133107        public IConstructor getModuleTree(URI uri) {
    134108                return getModuleTree(getModuleName(uri));
    135109        }
    136110       
    137         public IConstructor getModuleTree(String moduleName, boolean loadFromEditor)  {
    138                 ModuleInfo info = getModuleInfo(moduleName);
    139                 if(info.tree == null || info.isModified() || (loadFromEditor && info.parseTreeHasChanged())) {
    140                         info.loadTree(true);
    141                 }
    142                 return info.tree;
    143                
     111        public IConstructor getModuleTree(String moduleName)  {
     112                return getModule(moduleName).getTree();
    144113        }
    145114       
    146         private ModuleInfo getModuleInfo(String moduleName) {
     115        /**
     116         * @param moduleName
     117         * @return Module info for the module (never null)
     118         */
     119        public IModuleInfo getModule(String moduleName) {
    147120                if(moduleMap.containsKey(moduleName)) {
    148121                        return moduleMap.get(moduleName);
    149122                }
    150123                else {
    151                         ModuleInfo info = new ModuleInfo();
    152                         info.uri = buildPath.find(moduleName);
    153                         if(info.uri == null)
    154                                 throw new ModuleNotFoundError(moduleName);
    155                         info.dir = buildPath.getModuleName(info.uri).first;
    156                         info.moduleName = moduleName;
     124                        MagnoliaModuleInfo info = new FileModuleInfo(this, moduleName);
     125                        moduleMap.put(moduleName, info);
    157126                        return info;
    158127                }
     
    165134                return name;
    166135        }
     136       
     137        public String getModuleName(IFile file) {
     138                return getModuleName(ProjectURIResolver.constructProjectURI(file.getProject().getName(), file.getProjectRelativePath()));
     139        }
    167140
    168         public ISourceProject getProject() {
     141        public IProject getProject() {
    169142                return project;
    170143        }
    171144       
    172         public void addEditedModule(ParseController ctrl) {
    173                 ModuleInfo info = new ModuleInfo();
    174                 info.ctrl = ctrl;
    175                 info.file = ctrl.getProject().getRawProject().getFile(ctrl.getPath());
    176                 info.uri = ProjectURIResolver.constructProjectURI(ctrl.getProject(), ctrl.getPath());
    177                 Pair<URI, String> tmp = buildPath.getModuleName(info.uri);
    178                 info.dir = tmp.first;
    179                 info.moduleName = tmp.second;
    180                 if(info.moduleName != null) {
    181                         moduleMap.put(info.moduleName, info);
    182                         uriMap.put(info.uri, info.moduleName);
    183                 }
    184                 ctrlMap.put(ctrl, info);
    185         }
    186        
    187         public void removeEditedModule(ParseController ctrl) {
    188                 // TODO: Handle multiple editors for same module
    189                 ModuleInfo info = ctrlMap.get(ctrl);
    190                 if(info != null) {
    191                         ModuleInfo info2 = moduleMap.get(info.moduleName);
    192                         if(info2 == info) {
    193                                 moduleMap.remove(info.moduleName);
    194                                 uriMap.remove(info.uri);
    195                         }
    196                         else if(info2 != null && info2.ctrl == ctrl) {
    197                                 info2.ctrl = null;
    198                         }
    199                         ctrlMap.remove(ctrl);
    200                 }
    201         }
    202 
    203         public String findEditedModule(ParseController ctrl) {
    204                 // TODO: Handle multiple editors for same module
    205                 ModuleInfo info = ctrlMap.get(ctrl);
    206                 if(info != null) {
    207                         ModuleInfo info2 = moduleMap.get(info.moduleName);
    208                         if(info2 != info)
    209                                 throw new ImplementationError("Find-by-controller does not match find-by-name");
    210                         return info.moduleName;
    211                 }
    212                 else
    213                         return null;
    214         }
    215 
    216145        public boolean dataInvariant() {
    217146                return loader != null && buildPath != null;
    218147        }
    219148       
    220         protected class ModuleInfo {
    221                 long modStamp;
    222                 ParseController ctrl;
    223                 IConstructor tree;
    224                 IConstructor parseTree;
    225                 URI uri;
    226                 URI dir;
    227                 IFile file;
    228                 String moduleName;
    229                 MagnoliaEnvironment env;
    230                
    231                 boolean loadTree(boolean force) {
    232                         env = null;
    233                         modStamp = IResource.NULL_STAMP;
    234 
    235                         if(ctrl != null && ctrl.getCurrentAst() != null) {
    236                                 parseTree = ctrl.getCurrentAst();
    237                                 modStamp = file.getModificationStamp();
    238                         }
    239                         else if(force) {
    240                                 modStamp = MagnoliaPlugin.getResolverRegistry().lastModified(uri);
    241                                 parseTree = loader.parseModule(uri);
    242                         }
    243                        
    244        
    245                         if(parseTree != null) {
    246                                 tree = (IConstructor) TreeImploder.implodeTree(ParsetreeAdapter.getTop(parseTree));
    247                                 if(file != null)
    248                                         try {
    249                                                 file.deleteMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
    250                                         } catch (CoreException e) {}
    251                                 return true;
    252                         }
    253                         else {
    254                                 tree = null;
    255                                 return false;
    256                         }
    257                 }
    258                
    259                 boolean parseTreeHasChanged() {
    260                         return ctrl != null && ctrl.getCurrentAst() != parseTree;
    261                 }
    262                
    263                 boolean isModified() {
    264                         return (file != null && file.getModificationStamp() != modStamp) ||
    265                                 (uri != null && MagnoliaPlugin.getResolverRegistry().lastModified(uri) != modStamp);
    266                 }
     149        public void reportError(CompilationError ce) {
     150                reportError(ce, null);
    267151        }
    268 
    269         public void reportError(CompilationError ce) {
     152        public void reportError(CompilationError ce, String prefix) {
    270153                ISourceLocation loc = ce.getLocation();
    271154                if(loc != null) {
     155                        if(prefix == null)
     156                                prefix = "";
     157                        else
     158                                prefix = prefix + ": ";
    272159                        URI uri = loc.getURI();
    273 
    274160                        IFile file = ProjectURIResolver.getFile(uri);
    275161                        try {
    276                                 IMarker marker = file.createMarker(IMarker.PROBLEM);
    277                                 marker.setAttribute(IMarker.CHAR_START, loc.getOffset());
    278                                 marker.setAttribute(IMarker.CHAR_END, loc.getOffset()+loc.getLength());
    279                                 marker.setAttribute(IMarker.MESSAGE, ce.getMarkerMessage());
     162                                int start = loc.getOffset();
     163                                int end = loc.getOffset()+loc.getLength();
     164                                for(IMarker m : file.findMarkers(ce.getMarkerType(), false, IResource.DEPTH_INFINITE)) {
     165                                        if(m.getAttribute(IMarker.CHAR_START, -1) == start
     166                                                        && m.getAttribute(IMarker.CHAR_END, -1) == end
     167                                                        && m.getAttribute(IMarker.MESSAGE, "").equals(prefix + ce.getMarkerMessage()));
     168                                                return;
     169                                }
     170                                IMarker marker = file.createMarker(ce.getMarkerType());
     171                                marker.setAttribute(IMarker.CHAR_START, start);
     172                                marker.setAttribute(IMarker.CHAR_END, end);
     173                                marker.setAttribute(IMarker.MESSAGE, prefix + ce.getMarkerMessage());
    280174                                marker.setAttribute(IMarker.LOCATION, "Line " + loc.getBeginLine() + ", column " + loc.getBeginColumn());
    281175                                marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
     
    288182        }
    289183
     184        public Object getImports(String moduleName) {
     185                MagnoliaEnvironment env = getModuleEnv(moduleName);
     186                return null;
     187        }
     188
    290189}
Note: See TracChangeset for help on using the changeset viewer.