Changeset 459
- Timestamp:
- Jul 7, 2010 1:22:08 AM (14 years ago)
- Location:
- trunk/magnolia-eclipse
- Files:
-
- 3 added
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/magnolia-eclipse/build.properties
r370 r459 8 8 icons/,\ 9 9 mglib/ 10 src.includes = src/,\ 11 META-INF/,\ 12 plugin.xml,\ 13 mglib/,\ 10 src.includes = mglib/,\ 14 11 lang/,\ 15 12 icons/ -
trunk/magnolia-eclipse/plugin.xml
r453 r459 229 229 </persistent> 230 230 </extension> 231 231 <extension 232 232 id="ambiguityMarker" 233 233 name="Ambiguity" -
trunk/magnolia-eclipse/src/org/magnolialang/eclipse/builders/MagnoliaBuilder.java
r453 r459 26 26 import org.magnolialang.errors.SyntaxError; 27 27 import org.magnolialang.load.ProjectURIResolver; 28 import org.magnolialang.magnolia.StaticChecker; 28 29 import org.magnolialang.manager.IModuleInfo; 29 30 import org.magnolialang.manager.MagnoliaProjectManager; … … 147 148 IModuleInfo module = manager.getModule(manager.getModuleName(file)); 148 149 module.getEnv(); 150 StaticChecker.getInstance().checkModule(module, manager); 149 151 } catch(CompilationError ce) { 150 152 manager.reportError(ce, "Compiler"); -
trunk/magnolia-eclipse/src/org/magnolialang/eclipse/commands/SelectConstruct.java
r453 r459 37 37 long diffTime = 0; 38 38 39 IValue term = RascalInterpreter.getInstance().call("tryme", "import MagnoliaCompile;", tree); 40 39 41 startTime = System.nanoTime(); 40 42 imploded = TreeImploder.implodeTree(tree); 41 43 diffTime = System.nanoTime()-startTime; 42 44 /* 43 45 System.out.printf("Java tree imploder: %fms\n", diffTime/1000000.0); 44 46 System.out.println("Ready."); … … 74 76 //MessageDialog.openInformation( 75 77 // HandlerUtil.getActiveShell(event),"Inline","You selected:\n" + TreeAdapter.yield(tree)); 78 * 79 */ 76 80 } 77 81 return null; -
trunk/magnolia-eclipse/src/org/magnolialang/eclipse/editor/AmbiguityMarkerModelListener.java
r453 r459 7 7 import org.eclipse.imp.parser.IParseController; 8 8 import org.eclipse.imp.pdb.facts.IConstructor; 9 import org.eclipse.imp.pdb.facts.INode; 9 10 import org.eclipse.imp.pdb.facts.ISet; 10 11 import org.eclipse.imp.pdb.facts.ISourceLocation; 12 import org.eclipse.imp.pdb.facts.IString; 11 13 import org.eclipse.imp.pdb.facts.IValue; 12 14 import org.eclipse.imp.pdb.facts.visitors.VisitorException; 15 import org.rascalmpl.values.uptr.Factory; 13 16 import org.rascalmpl.values.uptr.ParsetreeAdapter; 14 17 import org.rascalmpl.values.uptr.ProductionAdapter; … … 27 30 28 31 public static void annotateAmbiguities(IConstructor tree, IMessageHandler handler) { 29 try {32 /*try { 30 33 if(ParsetreeAdapter.isParseTree(tree)) 31 34 ParsetreeAdapter.getTop(tree).accept(new AmbiguityVisitor(handler)); … … 33 36 tree.accept(new AmbiguityVisitor(handler)); 34 37 } catch (VisitorException e) { 35 } 38 }*/ 36 39 } 37 40 … … 94 97 } 95 98 99 @Override 100 public IConstructor visitTreeAppl(IConstructor tree) throws VisitorException { 96 101 97 @Override 98 public IConstructor visitTreeAppl(IConstructor arg) throws VisitorException { 99 for(IValue v : TreeAdapter.getArgs(arg)) 102 for(IValue v : TreeAdapter.getArgs(tree)) 100 103 v.accept(this); 101 104 return null; 102 105 } 106 103 107 104 108 -
trunk/magnolia-eclipse/src/org/magnolialang/eclipse/editor/MagnoliaParseController.java
r453 r459 109 109 110 110 public Object parse(String input, IProgressMonitor monitor) { 111 parseTree = null;111 parseTree = null; 112 112 113 113 try{ -
trunk/magnolia-eclipse/src/org/magnolialang/eclipse/preferences/MagnoliaInstanceTab.java
r453 r459 3 3 import java.util.List; 4 4 import java.util.ArrayList; 5 import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; 6 import org.eclipse.core.runtime.preferences.IEclipsePreferences; 5 7 import org.eclipse.swt.widgets.Composite; 6 8 import org.eclipse.swt.widgets.Link; 7 9 import org.eclipse.imp.preferences.*; 8 10 import org.eclipse.imp.preferences.fields.*; 11 import org.osgi.service.prefs.Preferences; 9 12 10 13 -
trunk/magnolia-eclipse/src/org/magnolialang/eclipse/preferences/MagnoliaProjectTab.java
r453 r459 3 3 import java.util.List; 4 4 import java.util.ArrayList; 5 import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; 5 6 import org.eclipse.core.runtime.preferences.IEclipsePreferences; 6 7 import org.eclipse.swt.widgets.Composite; -
trunk/magnolia-eclipse/src/org/magnolialang/magnolia/StaticChecker.java
r448 r459 1 1 package org.magnolialang.magnolia; 2 2 3 import org.eclipse.core.resources.IMarker; 4 import org.eclipse.core.resources.IResource; 5 import org.eclipse.imp.parser.IMessageHandler; 3 6 import org.eclipse.imp.pdb.facts.IConstructor; 7 import org.eclipse.imp.pdb.facts.INode; 8 import org.eclipse.imp.pdb.facts.ISet; 9 import org.eclipse.imp.pdb.facts.ISourceLocation; 10 import org.eclipse.imp.pdb.facts.IString; 11 import org.eclipse.imp.pdb.facts.IValue; 12 import org.eclipse.imp.pdb.facts.visitors.VisitorException; 4 13 import org.magnolialang.env.MagnoliaEnvironment; 14 import org.magnolialang.errors.ErrorMarkers; 15 import org.magnolialang.manager.IModuleInfo; 16 import org.magnolialang.manager.MagnoliaProjectManager; 17 import org.rascalmpl.values.uptr.Factory; 18 import org.rascalmpl.values.uptr.ProductionAdapter; 19 import org.rascalmpl.values.uptr.TreeAdapter; 20 import org.rascalmpl.values.uptr.visitors.TreeVisitor; 5 21 6 22 public class StaticChecker { … … 13 29 } 14 30 15 public void checkModule(IConstructor tree, MagnoliaEnvironment env) { 16 // TODO Auto-generated method stub 31 public void checkModule(IModuleInfo module, MagnoliaProjectManager manager) { 32 try { 33 module.getParseTreeTop().accept(new StaticCheckVisitor(manager)); 34 } catch (VisitorException e) { 35 // TODO Auto-generated catch block 36 e.printStackTrace(); 37 } 38 } 39 40 41 private static class StaticCheckVisitor extends TreeVisitor { 42 private MagnoliaProjectManager manager; 43 44 public StaticCheckVisitor(MagnoliaProjectManager manager) { 45 this.manager = manager; 46 /* if(file != null) 47 try { 48 file.deleteMarkers(AMB_MARKER, true, IResource.DEPTH_INFINITE); 49 } catch (CoreException e) { 50 }*/ 51 } 52 53 54 @Override 55 public IConstructor visitTreeAmb(IConstructor tree) throws VisitorException { 56 IConstructor child = (IConstructor)TreeAdapter.getAlternatives(tree).iterator().next(); 57 ISourceLocation loc = TreeAdapter.getLocation(child); 58 59 60 ISet alts = TreeAdapter.getAlternatives(tree); 61 StringBuffer message = new StringBuffer("<p>Ambiguity:\n<ul>\n"); 62 for(IValue alt : alts) { 63 IConstructor prod = TreeAdapter.getProduction((IConstructor)alt); 64 message.append(" <li>" + ProductionAdapter.getSortName(prod) + " ::= " + ProductionAdapter.getLhs(prod) + "</li>\n"); 17 65 66 } 67 message.append("</ul></p>"); 68 69 manager.reportError(message.toString(), loc, ErrorMarkers.SYNTAX_ERROR, IMarker.SEVERITY_WARNING); 70 return null; 71 } 72 73 @Override 74 public IConstructor visitTreeAppl(IConstructor tree) throws VisitorException { 75 IConstructor prod = TreeAdapter.getProduction(tree); 76 if(prod != null) 77 for (IValue attr : ProductionAdapter.getAttributes(prod)) { 78 if (attr != null && attr.getType().isAbstractDataType() && ((IConstructor) attr).getConstructorType() == Factory.Attr_Term) { 79 IValue value = ((IConstructor)attr).get("term"); 80 if (value.getType().isNodeType() && ((INode) value).getName().equals("todo")) { 81 ISourceLocation loc = TreeAdapter.getLocation(tree); 82 manager.reportError("TODO: " + ((IString) ((INode) value).get(0)).getValue(), loc, ErrorMarkers.COMPILATION_ERROR, IMarker.SEVERITY_INFO); 83 } 84 else if (value.getType().isNodeType() && ((INode) value).getName().equals("deprecated")) { 85 INode node = (INode)value; 86 String message = "Deprecated construct or syntax"; 87 if(node.arity() > 0) 88 message = message + ": " + ((IString)node.get(0)).getValue(); 89 ISourceLocation loc = TreeAdapter.getLocation(tree); 90 manager.reportError(message, loc, ErrorMarkers.COMPILATION_ERROR, IMarker.SEVERITY_WARNING); 91 } 92 } 93 } 94 for(IValue v : TreeAdapter.getArgs(tree)) 95 v.accept(this); 96 return null; 97 } 98 99 100 101 @Override 102 public IConstructor visitTreeChar(IConstructor arg) throws VisitorException { 103 return null; 104 } 105 106 107 @Override 108 public IConstructor visitTreeCycle(IConstructor arg) 109 throws VisitorException { 110 return null; 111 } 18 112 } 19 113 -
trunk/magnolia-eclipse/src/org/magnolialang/manager/FileModuleInfo.java
r453 r459 8 8 import org.eclipse.core.resources.IResource; 9 9 import org.eclipse.core.runtime.CoreException; 10 import org.eclipse.imp.pdb.facts.IConstructor; 10 11 import org.magnolialang.errors.ImplementationError; 11 12 import org.magnolialang.errors.ModuleNotFoundError; -
trunk/magnolia-eclipse/src/org/magnolialang/manager/IModuleInfo.java
r452 r459 12 12 public abstract IConstructor getTree(); 13 13 14 public abstract IConstructor getParseTree(); 15 16 public abstract IConstructor getParseTreeTop(); 17 14 18 public abstract MagnoliaEnvironment getEnv(); 15 19 -
trunk/magnolia-eclipse/src/org/magnolialang/manager/MagnoliaModuleInfo.java
r453 r459 100 100 return tree; 101 101 } 102 103 public IConstructor getParseTree() { 104 if(parseTree == null || isModified()) 105 if(!loadTree()) { 106 throw new ImplementationError("Loading tree failed for module " + getModuleName()); 107 } 108 assert parseTree != null; 109 return parseTree; 110 } 102 111 112 public IConstructor getParseTreeTop() { 113 IConstructor pt = getParseTree(); 114 if(pt != null && ParsetreeAdapter.isParseTree(pt)) 115 return ParsetreeAdapter.getTop(pt); 116 else 117 return pt; 118 } 119 103 120 public MagnoliaEnvironment getEnv() { 104 121 getTree(); -
trunk/magnolia-eclipse/src/org/magnolialang/manager/MagnoliaProjectManager.java
r453 r459 146 146 public void reportError(CompilationError ce, String prefix) { 147 147 ISourceLocation loc = ce.getLocation(); 148 if(prefix == null) 149 prefix = ""; 150 else 151 prefix = prefix + ": "; 152 reportError(prefix + ce.getMarkerMessage(), loc, ce.getMarkerType()); 153 ce.printStackTrace(); 154 } 155 156 public void reportError(String message, ISourceLocation loc, String markerType) { 157 reportError(message, loc, markerType, IMarker.SEVERITY_ERROR); 158 } 159 public void reportError(String message, ISourceLocation loc, String markerType, int severity) { 148 160 if(loc != null) { 149 if(prefix == null)150 prefix = "";151 else152 prefix = prefix + ": ";153 161 URI uri = loc.getURI(); 154 162 IFile file = ProjectURIResolver.getFile(uri); … … 156 164 int start = loc.getOffset(); 157 165 int end = loc.getOffset()+loc.getLength(); 158 for(IMarker m : file.findMarkers( ce.getMarkerType(), false, IResource.DEPTH_INFINITE)) {166 for(IMarker m : file.findMarkers(markerType, false, IResource.DEPTH_INFINITE)) { 159 167 if(m.getAttribute(IMarker.CHAR_START, -1) == start 160 168 && m.getAttribute(IMarker.CHAR_END, -1) == end 161 && m.getAttribute(IMarker.MESSAGE, "").equals( prefix + ce.getMarkerMessage()));169 && m.getAttribute(IMarker.MESSAGE, "").equals(message)) 162 170 return; 163 171 } 164 IMarker marker = file.createMarker( ce.getMarkerType());172 IMarker marker = file.createMarker(markerType); 165 173 marker.setAttribute(IMarker.CHAR_START, start); 166 174 marker.setAttribute(IMarker.CHAR_END, end); 167 marker.setAttribute(IMarker.MESSAGE, prefix + ce.getMarkerMessage());175 marker.setAttribute(IMarker.MESSAGE, message); 168 176 marker.setAttribute(IMarker.LOCATION, "Line " + loc.getBeginLine() + ", column " + loc.getBeginColumn()); 169 marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);177 marker.setAttribute(IMarker.SEVERITY, severity); 170 178 marker.setAttribute(IMarker.TRANSIENT, true); 171 179 return; … … 173 181 } 174 182 } 175 ce.printStackTrace();176 183 } 177 184 } -
trunk/magnolia-eclipse/src/org/magnolialang/xatree/TreeImplodeVisitor.java
r453 r459 47 47 IConstructor result = (IConstructor)TreeAdapter.getAlternatives(tree).iterator().next(); 48 48 49 return result;49 return (IConstructor) result.accept(this); 50 50 } 51 51
Note:
See TracChangeset
for help on using the changeset viewer.