Changeset 452
- Timestamp:
- Jul 5, 2010 3:57:08 AM (14 years ago)
- Location:
- trunk/MagnoliaPlugin
- Files:
-
- 12 added
- 1 deleted
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagnoliaPlugin/plugin.xml
r451 r452 204 204 </extension> 205 205 <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 206 239 id="ambiguityMarker" 207 240 name="Ambiguity" -
trunk/MagnoliaPlugin/src/org/magnolialang/eclipse/builders/MagnoliaBuilder.java
r397 r452 1 1 package org.magnolialang.eclipse.builders; 2 3 import java.net.URI; 2 4 3 5 import org.eclipse.core.resources.IFile; … … 19 21 20 22 import org.magnolialang.eclipse.MagnoliaPlugin; 23 import org.magnolialang.eclipse.editor.ImplementationError; 21 24 import org.magnolialang.eclipse.editor.ParseController; 25 import org.magnolialang.errors.CompilationError; 26 import org.magnolialang.errors.ErrorMarkers; 27 import org.magnolialang.errors.SyntaxError; 28 import org.magnolialang.load.ProjectURIResolver; 29 import org.magnolialang.manager.IModuleInfo; 30 import org.magnolialang.manager.MagnoliaProjectManager; 22 31 23 32 /** … … 40 49 * A marker ID that identifies problems detected by the builder 41 50 */ 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; 44 52 45 53 public static final String LANGUAGE_NAME = "Magnolia"; … … 106 114 */ 107 115 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 } 118 130 } 119 131 … … 129 141 */ 130 142 protected void compile(final IFile file, IProgressMonitor monitor) { 143 MagnoliaProjectManager manager = MagnoliaProjectManager.getProjectManager(file.getProject()); 131 144 try { 132 145 getPlugin().writeInfoMsg( 133 146 "Building Magnolia file: " + file.getName()); 134 147 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"); 144 152 } catch (Exception e) { 145 153 // catch Exception, because any exception could break the … … 183 191 protected void runParserForCompiler(final IFile file, 184 192 IProgressMonitor monitor) { 193 185 194 try { 186 195 IParseController parseController = new ParseController(); … … 210 219 e); 211 220 } 212 } 221 222 } 213 223 } -
trunk/MagnoliaPlugin/src/org/magnolialang/eclipse/editor/ParseController.java
r448 r452 20 20 import org.magnolialang.eclipse.MagnoliaPlugin; 21 21 import org.magnolialang.env.MagnoliaEnvironment; 22 import org.magnolialang.errors.SyntaxError; 22 23 import org.magnolialang.load.ModuleLoader; 23 24 import org.magnolialang.load.ProjectURIResolver; 24 import org.magnolialang.manager.MagnoliaProjectManager; 25 import org.magnolialang.xatree.TreeImploder; 26 import org.rascalmpl.interpreter.staticErrors.SyntaxError; 25 import org.magnolialang.manager.EditedProjectManager; 27 26 import org.rascalmpl.values.errors.SummaryAdapter; 28 27 import org.rascalmpl.values.uptr.Factory; … … 37 36 private IConstructor parseTree; 38 37 private IPath path; 39 private MagnoliaProjectManager manager;38 private EditedProjectManager manager; 40 39 private String languageName; 41 40 … … 104 103 this.handler = handler; 105 104 this.project = project; 106 this.manager = MagnoliaProjectManager.getProjectManager(project);105 this.manager = EditedProjectManager.getProjectManager(project); 107 106 108 107 this.loader = new ModuleLoader(languageName, manager); … … 119 118 URI uri = ProjectURIResolver.constructProjectURI(project, path); 120 119 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); 129 121 monitor.worked(1); 130 return result;122 return parseTree; 131 123 } 132 124 catch(FactTypeUseException e){ … … 138 130 catch(SyntaxError e){ 139 131 ISourceLocation loc = e.getLocation(); 140 e.printStackTrace();141 132 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()); 143 134 } 144 135 else { 145 handler.handleSimpleMessage( e.getMessage(), 0, 0, 0, 0, 1, 1);136 handler.handleSimpleMessage("Editor: " + e.getMessage(), 0, 0, 0, 0, 1, 1); 146 137 } 147 138 } … … 166 157 } 167 158 168 public MagnoliaProjectManager getManager() {159 public EditedProjectManager getManager() { 169 160 return manager; 170 161 } -
trunk/MagnoliaPlugin/src/org/magnolialang/eclipse/editor/StaticCheckModelListener.java
r449 r452 17 17 import org.magnolialang.errors.CompilationError; 18 18 import org.magnolialang.magnolia.StaticChecker; 19 import org.magnolialang.manager.EditedProjectManager; 19 20 import org.magnolialang.manager.MagnoliaProjectManager; 20 21 … … 28 29 public void update(final IParseController parseController, 29 30 final IProgressMonitor monitor) { 30 Thread x = new Thread("Magnolia Static Checker") {31 /* Thread x = new Thread("Magnolia Static Checker") { 31 32 @Override 32 33 public void run() { … … 48 49 49 50 private void doUpdate(ParseController ctrl, IProgressMonitor monitor) { 50 MagnoliaProjectManager manager = ctrl.getManager(); 51 EditedProjectManager manager = ctrl.getManager(); 52 51 53 try { 52 54 String moduleName = manager.findEditedModule(ctrl); … … 56 58 MagnoliaEnvironment env = manager.getModuleEnv(moduleName); 57 59 monitor.worked(1); 58 59 60 checker.checkModule(tree, env); 60 61 monitor.worked(1); … … 81 82 } 82 83 }; 83 x.start(); 84 x.start();*/ 84 85 } 85 86 -
trunk/MagnoliaPlugin/src/org/magnolialang/env/MagnoliaEnvironment.java
r439 r452 2 2 import static org.magnolialang.xatree.XaTreeFactory.*; 3 3 4 import java.net.URI; 4 5 import java.util.Iterator; 6 import java.util.LinkedList; 7 import java.util.List; 5 8 import java.util.Map.Entry; 6 9 … … 14 17 15 18 private IMap imports = vf.map(tf.stringType(), Type_XaTree); 19 private List<URI> deps = new LinkedList<URI>(); 16 20 17 21 public void addImport(String name, IValue tree) { … … 49 53 return buf.toString(); 50 54 } 55 public void addDependency(URI uri) { 56 deps.add(uri); 57 } 58 59 public List<URI> getDependencies() { 60 return deps; 61 } 51 62 } -
trunk/MagnoliaPlugin/src/org/magnolialang/errors/CompilationError.java
r428 r452 106 106 } 107 107 108 public String getMarkerType() { 109 return ErrorMarkers.COMPILATION_ERROR; 110 } 111 108 112 public String getErrorType() { 109 113 return "compilation error"; -
trunk/MagnoliaPlugin/src/org/magnolialang/errors/ModuleLoadError.java
r428 r452 32 32 return errorType; 33 33 } 34 35 @Override 36 public String getMarkerType() { 37 return ErrorMarkers.LOAD_ERROR; 38 } 34 39 } -
trunk/MagnoliaPlugin/src/org/magnolialang/errors/ModuleNotFoundError.java
r442 r452 41 41 return moduleName; 42 42 } 43 44 @Override 45 public String getMarkerType() { 46 return ErrorMarkers.LOAD_ERROR; 47 } 43 48 } -
trunk/MagnoliaPlugin/src/org/magnolialang/load/ModuleLoader.java
r446 r452 18 18 import org.magnolialang.env.MagnoliaEnvironment; 19 19 import org.magnolialang.errors.ModuleLoadError; 20 import org.magnolialang.errors.SyntaxError; 21 import org.magnolialang.manager.IModuleInfo; 20 22 import org.magnolialang.manager.MagnoliaProjectManager; 21 23 import org.magnolialang.xatree.TreeImploder; 22 import org.rascalmpl.interpreter.staticErrors.SyntaxError;23 24 import org.rascalmpl.values.ValueFactoryFactory; 24 25 import org.rascalmpl.values.errors.SubjectAdapter; … … 91 92 return tree; 92 93 } 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 } 93 100 94 101 public IConstructor parseModule(URI location) { … … 135 142 IConstructor iTree; 136 143 try { 137 iTree = manager.getModuleTree(name); 144 IModuleInfo info = manager.getModule(name); 145 env.addDependency(info.getURI()); 146 iTree = info.getTree(); 138 147 } 139 148 catch(Exception e) { -
trunk/MagnoliaPlugin/src/org/magnolialang/load/ProjectURIResolver.java
r442 r452 25 25 // making sure that spaces in 'path' are properly escaped 26 26 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); 27 40 }catch(URISyntaxException usex){ 28 41 throw new BadURIException(usex); -
trunk/MagnoliaPlugin/src/org/magnolialang/manager/MagnoliaProjectManager.java
r448 r452 10 10 import org.eclipse.core.resources.IFile; 11 11 import org.eclipse.core.resources.IMarker; 12 import org.eclipse.core.resources.IProject; 12 13 import org.eclipse.core.resources.IResource; 14 import org.eclipse.core.resources.ResourcesPlugin; 13 15 import org.eclipse.core.runtime.CoreException; 14 16 import org.eclipse.core.runtime.Path; … … 17 19 import org.eclipse.imp.pdb.facts.ISourceLocation; 18 20 import org.eclipse.imp.utils.Pair; 19 import org.magnolialang.eclipse.MagnoliaPlugin;20 21 import org.magnolialang.eclipse.editor.ImplementationError; 21 import org.magnolialang.eclipse.editor.ParseController;22 22 import org.magnolialang.env.MagnoliaEnvironment; 23 23 import org.magnolialang.errors.CompilationError; … … 29 29 import org.magnolialang.programs.MagnoliaAdapter; 30 30 import org.magnolialang.xatree.CxxSkin; 31 import org.magnolialang.xatree.TreeImploder;32 31 import org.magnolialang.xatree.XaTreeAdapter; 33 import org.rascalmpl.values.uptr.ParsetreeAdapter;34 32 33 /** 34 * @author anya 35 * 36 */ 35 37 @SuppressWarnings("deprecation") 36 public class MagnoliaProjectManager implements IProjectManager{38 public class MagnoliaProjectManager { 37 39 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; 45 45 46 public MagnoliaProjectManager(I SourceProject project) {46 public MagnoliaProjectManager(IProject project) { 47 47 this.project = project; 48 48 this.loader = new ModuleLoader(this); 49 49 this.buildPath = new MagnoliaBuildPath(null); 50 50 if(project != null) 51 this.buildPath.addPath(ProjectURIResolver.constructProjectURI(project , new Path("")));52 this.moduleMap = new HashMap<String, M oduleInfo>();51 this.buildPath.addPath(ProjectURIResolver.constructProjectURI(project.getName(), new Path(""))); 52 this.moduleMap = new HashMap<String, MagnoliaModuleInfo>(); 53 53 this.uriMap = new HashMap<URI, String>(); 54 this.ctrlMap = new IdentityHashMap<ParseController, ModuleInfo>();55 54 } 56 55 57 public static MagnoliaProjectManager getProjectManager( ISourceProjectproject) {56 public static MagnoliaProjectManager getProjectManager(String project) { 58 57 if(managerMap == null) 59 58 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); 62 61 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); 65 64 return manager; 66 65 } 67 66 } 68 67 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 69 76 public void createModule(String moduleName, IConstructor moduleTree) { 70 77 … … 72 79 73 80 public void createModule(String moduleName, String sourceModuleName, IConstructor moduleTree) { 74 M oduleInfo srcInfo = getModuleInfo(sourceModuleName);75 ModuleInfo info =moduleMap.get(moduleName);81 MagnoliaModuleInfo srcInfo = (MagnoliaModuleInfo) getModule(sourceModuleName); 82 FileModuleInfo info = (FileModuleInfo) moduleMap.get(moduleName); 76 83 URI uri = srcInfo.dir.resolve(moduleName.replace('.', '/') + ".mg"); 77 84 if(info == null) { 78 info = new ModuleInfo(); 79 info.moduleName = moduleName; 80 info.uri = uri; 85 info = new FileModuleInfo(this, moduleName, uri, srcInfo.dir); 81 86 } 82 87 else if(!info.uri.equals(uri)) … … 84 89 85 90 moduleTree = MagnoliaAdapter.setModuleName(moduleTree, moduleName); 86 info.dir = srcInfo.dir; // should be same87 info.tree = moduleTree;88 info.parseTree = null;89 91 String result = XaTreeAdapter.yield(moduleTree, new CxxSkin(), true); 90 92 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; 103 96 } 104 97 } 105 98 106 99 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(); 124 101 } 102 125 103 public MagnoliaEnvironment getModuleEnv(URI uri) { 126 104 return getModuleEnv(getModuleName(uri)); 127 105 } 128 106 129 public IConstructor getModuleTree(String moduleName) {130 return getModuleTree(moduleName, false);131 }132 133 107 public IConstructor getModuleTree(URI uri) { 134 108 return getModuleTree(getModuleName(uri)); 135 109 } 136 110 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(); 144 113 } 145 114 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) { 147 120 if(moduleMap.containsKey(moduleName)) { 148 121 return moduleMap.get(moduleName); 149 122 } 150 123 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); 157 126 return info; 158 127 } … … 165 134 return name; 166 135 } 136 137 public String getModuleName(IFile file) { 138 return getModuleName(ProjectURIResolver.constructProjectURI(file.getProject().getName(), file.getProjectRelativePath())); 139 } 167 140 168 public I SourceProject getProject() {141 public IProject getProject() { 169 142 return project; 170 143 } 171 144 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 module189 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 module205 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 else213 return null;214 }215 216 145 public boolean dataInvariant() { 217 146 return loader != null && buildPath != null; 218 147 } 219 148 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); 267 151 } 268 269 public void reportError(CompilationError ce) { 152 public void reportError(CompilationError ce, String prefix) { 270 153 ISourceLocation loc = ce.getLocation(); 271 154 if(loc != null) { 155 if(prefix == null) 156 prefix = ""; 157 else 158 prefix = prefix + ": "; 272 159 URI uri = loc.getURI(); 273 274 160 IFile file = ProjectURIResolver.getFile(uri); 275 161 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()); 280 174 marker.setAttribute(IMarker.LOCATION, "Line " + loc.getBeginLine() + ", column " + loc.getBeginColumn()); 281 175 marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR); … … 288 182 } 289 183 184 public Object getImports(String moduleName) { 185 MagnoliaEnvironment env = getModuleEnv(moduleName); 186 return null; 187 } 188 290 189 }
Note:
See TracChangeset
for help on using the changeset viewer.