Changeset 448
- Timestamp:
- Jun 24, 2010 3:43:46 PM (14 years ago)
- Location:
- trunk/MagnoliaPlugin
- Files:
-
- 6 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagnoliaPlugin/META-INF/MANIFEST.MF
r442 r448 25 25 org.eclipse.imp.smapifier, 26 26 lpg.runtime 27 Import-Package: org.junit28 27 Bundle-RequiredExecutionEnvironment: JavaSE-1.6 28 Import-Package: org.junit;version="4.5.0";resolution:=optional -
trunk/MagnoliaPlugin/plugin.xml
r446 r448 17 17 point="org.eclipse.imp.runtime.languageDescription"> 18 18 <language 19 extensions="mxa" 19 20 description="Experimental language specification language" 20 extensions="mxa"21 21 language="MetaXa"> 22 22 </language> … … 211 211 </page> 212 212 </extension> 213 <extension 214 id="ambiguityMarker" 215 name="Ambiguity" 216 point="org.eclipse.core.resources.markers"> 217 <super 218 type="org.eclipse.core.resources.problemmarker"> 219 </super> 220 <persistent 221 value="false"> 222 </persistent> 223 </extension> 224 <extension 225 id="hoverHelper" 226 name="Magnolia Hover Helper" 227 point="org.eclipse.imp.runtime.hoverHelper"> 228 <hoverHelper 229 class="org.magnolialang.eclipse.hoverHelper.MagnoliaHoverHelper" 230 language="MetaXa"> 231 </hoverHelper> 232 </extension> 233 <extension 234 id="referenceResolver" 235 name="Magnolia Reference Resolver" 236 point="org.eclipse.imp.runtime.referenceResolvers"> 237 <referenceResolver 238 class="org.magnolialang.eclipse.hoverHelper.HelperReferenceResolver" 239 language="Magnolia"> 240 </referenceResolver> 241 </extension> 242 <extension 243 point="org.eclipse.imp.runtime.editorService"> 244 <editorService 245 class="org.magnolialang.eclipse.editor.StaticCheckModelListener" 246 language="Magnolia"> 247 </editorService> 248 </extension> 249 <extension 250 point="org.eclipse.imp.runtime.editorService"> 251 <editorService 252 class="org.magnolialang.eclipse.editor.AmbiguityMarkerModelListener" 253 language="Magnolia"> 254 </editorService> 255 </extension> 256 <extension 257 point="org.eclipse.imp.runtime.editorService"> 258 <editorService 259 class="org.magnolialang.eclipse.editor.AmbiguityMarkerModelListener" 260 language="MetaXa"> 261 </editorService> 262 </extension> 213 263 214 264 </plugin> -
trunk/MagnoliaPlugin/src/org/magnolialang/eclipse/MagnoliaPlugin.java
r426 r448 13 13 import org.osgi.framework.Bundle; 14 14 import org.osgi.framework.BundleContext; 15 import org.magnolialang.uri.*;16 15 import sglr.LegacySGLRInvoker; 17 16 import sglr.SGLRInvoker; -
trunk/MagnoliaPlugin/src/org/magnolialang/eclipse/editor/MagnoliaEditor.java
r428 r448 11 11 public MagnoliaEditor() { 12 12 super(); 13 // ((ParseController)getParseController()).setEditor(this); 13 14 // used for the expression breakpoints management 14 15 //setEditorContextMenuId("rascal.editor.contextMenu"); -
trunk/MagnoliaPlugin/src/org/magnolialang/eclipse/editor/ParseController.java
r446 r448 23 23 import org.magnolialang.load.ProjectURIResolver; 24 24 import org.magnolialang.manager.MagnoliaProjectManager; 25 import org.magnolialang.xatree.TreeImploder; 25 26 import org.rascalmpl.interpreter.staticErrors.SyntaxError; 26 27 import org.rascalmpl.values.errors.SummaryAdapter; … … 40 41 41 42 private Language language; 43 44 45 private MagnoliaEditor editor; 42 46 43 47 public ParseController() { … … 73 77 } 74 78 79 public IMessageHandler getMessageHandler() { 80 return handler; 81 } 82 75 83 public ILanguageSyntaxProperties getSyntaxProperties() { 76 84 return new MagnoliaSyntaxProperties(); … … 149 157 } 150 158 159 public void setEditor(MagnoliaEditor magnoliaEditor) { 160 this.editor = magnoliaEditor; 161 162 } 163 164 public MagnoliaEditor getEditor() { 165 return editor; 166 } 167 168 public MagnoliaProjectManager getManager() { 169 return manager; 170 } 171 151 172 152 173 } -
trunk/MagnoliaPlugin/src/org/magnolialang/eclipse/editor/StaticCheckModelListener.java
r361 r448 1 1 package org.magnolialang.eclipse.editor; 2 /* 2 3 3 import org.eclipse.core.runtime.IProgressMonitor; 4 4 import org.eclipse.imp.parser.IModelListener; 5 5 import org.eclipse.imp.parser.IParseController; 6 6 import org.eclipse.imp.pdb.facts.IConstructor; 7 import org.eclipse.imp.pdb.facts.IList; 8 import org.rascalmpl.checker.StaticChecker; 9 import org.rascalmpl.eclipse.Activator; 10 import org.rascalmpl.values.uptr.ParsetreeAdapter; 11 import org.rascalmpl.values.uptr.TreeAdapter; 7 import org.magnolialang.env.MagnoliaEnvironment; 8 import org.magnolialang.magnolia.StaticChecker; 9 import org.magnolialang.manager.MagnoliaProjectManager; 12 10 13 11 public class StaticCheckModelListener implements IModelListener { 14 12 private final StaticChecker checker = StaticChecker.getInstance(); 15 private final MarkerModelListener marker = new MarkerModelListener();16 13 17 14 public AnalysisRequired getAnalysisRequired() { … … 21 18 public void update(final IParseController parseController, 22 19 final IProgressMonitor monitor) { 23 Thread x = new Thread(" RascalStatic Checker") {20 Thread x = new Thread("Magnolia Static Checker") { 24 21 @Override 25 22 public void run() { 26 monitor.beginTask("Checking Rascal module " + parseController.getPath().toString(), 1); 27 IConstructor parseTree = (IConstructor) parseController.getCurrentAst(); 28 29 if (parseTree == null) { 30 return; 31 } 32 33 try { 34 IConstructor newTree = checker.checkModule((IConstructor) TreeAdapter.getArgs(ParsetreeAdapter.getTop(parseTree)).get(1)); 35 if (newTree != null) { 36 IConstructor treeTop = ParsetreeAdapter.getTop(parseTree); 37 IList treeArgs = TreeAdapter.getArgs(treeTop).put(1, newTree); 38 IConstructor newTreeTop = treeTop.set("args", treeArgs).setAnnotation("loc", treeTop.getAnnotation("loc")); 39 parseTree = parseTree.set("top", newTreeTop); 40 ((ParseController) parseController).setCurrentAst(parseTree); 41 marker.update(parseTree, parseController, monitor); 42 } 43 else { 44 Activator.getInstance().logException("static checker returned null", new RuntimeException()); 45 } 46 } 47 catch (Throwable e) { 48 Activator.getInstance().logException("static checker failed", e); 49 } 23 monitor.beginTask("Checking Magnolia module " + parseController.getPath().toString(), 3); 24 25 ParseController ctrl = (ParseController)parseController; 26 MagnoliaProjectManager manager = ctrl.getManager(); 27 String moduleName = manager.findEditedModule(ctrl); 28 IConstructor tree = manager.getModuleTree(moduleName, true); 29 monitor.worked(1); 30 MagnoliaEnvironment env = manager.getModuleEnv(moduleName); 31 monitor.worked(1); 32 33 checker.checkModule(tree, env); 50 34 monitor.worked(1); 51 35 } … … 58 42 } 59 43 } 60 */ -
trunk/MagnoliaPlugin/src/org/magnolialang/eclipse/editor/TokenColorer.java
r446 r448 1 1 package org.magnolialang.eclipse.editor; 2 2 3 3 4 import java.util.HashMap; … … 11 12 import org.eclipse.jface.text.TextAttribute; 12 13 import org.eclipse.swt.SWT; 14 import org.eclipse.swt.graphics.Color; 13 15 import org.eclipse.swt.widgets.Display; 14 16 … … 42 44 super(); 43 45 normal = new TextAttribute(Display.getDefault().getSystemColor(SWT.COLOR_BLACK), null, SWT.NONE); 44 46 45 47 Display display = Display.getDefault(); 46 48 map.put(KEYWORD, new TextAttribute(display.getSystemColor(SWT.COLOR_DARK_MAGENTA), null, SWT.BOLD)); … … 55 57 map.put(AMBIGUOUS,new TextAttribute(null, display.getSystemColor(SWT.COLOR_YELLOW), SWT.NONE)); 56 58 map.put(ERROR,new TextAttribute(null, display.getSystemColor(SWT.COLOR_RED), SWT.NONE)); 57 map.put(MXAID,new TextAttribute(display.getSystemColor(SWT.COLOR_BLACK), null, SWT.NONE)); 58 map.put(MXASTRINGLITERAL,new TextAttribute(display.getSystemColor(SWT.COLOR_DARK_RED), null, SWT.NONE)); 59 map.put(MXATRANSITION,new TextAttribute(display.getSystemColor(SWT.COLOR_DARK_BLUE), null, SWT.NONE)); 60 map.put(MXATOKEN,new TextAttribute(display.getSystemColor(SWT.COLOR_BLACK), null, SWT.BOLD)); 61 map.put(MXAMETAVAR,new TextAttribute(display.getSystemColor(SWT.COLOR_DARK_CYAN), null, SWT.BOLD)); 62 map.put(MXAVAR,new TextAttribute(display.getSystemColor(SWT.COLOR_DARK_CYAN), null, SWT.BOLD)); 59 60 Color mxaCol1 = new Color(Display.getDefault(), 95, 35, 20); 61 Color mxaCol2 = new Color(Display.getDefault(), 120, 25, 15); 62 Color mxaCol3 = new Color(Display.getDefault(), 60, 45, 20); 63 map.put(MXAID,new TextAttribute(mxaCol1, null, SWT.NONE)); 64 map.put(MXASTRINGLITERAL,new TextAttribute(mxaCol3, null, SWT.NONE)); 65 map.put(MXATRANSITION,new TextAttribute(mxaCol1, null, SWT.NONE)); 66 map.put(MXATOKEN,new TextAttribute(mxaCol3, null, SWT.BOLD)); 67 map.put(MXAMETAVAR,new TextAttribute(mxaCol2, null, SWT.ITALIC)); 68 map.put(MXAVAR,new TextAttribute(mxaCol1, null, SWT.NONE)); 63 69 } 64 70 -
trunk/MagnoliaPlugin/src/org/magnolialang/eclipse/editor/TokenIterator.java
r446 r448 5 5 import java.util.List; 6 6 7 import org.eclipse.core.resources.IFile; 8 import org.eclipse.core.resources.IMarker; 9 import org.eclipse.core.resources.IResource; 10 import org.eclipse.core.runtime.CoreException; 11 import org.eclipse.core.runtime.IPath; 12 import org.eclipse.imp.model.ISourceProject; 13 import org.eclipse.imp.parser.IMessageHandler; 14 import org.eclipse.imp.parser.IMessageHandlerExtension; 7 15 import org.eclipse.imp.pdb.facts.IConstructor; 16 import org.eclipse.imp.pdb.facts.ISet; 17 import org.eclipse.imp.pdb.facts.ISourceLocation; 8 18 import org.eclipse.imp.pdb.facts.IValue; 9 19 import org.eclipse.imp.pdb.facts.visitors.VisitorException; 20 import org.magnolialang.load.ProjectURIResolver; 10 21 import org.rascalmpl.values.uptr.ProductionAdapter; 11 22 import org.rascalmpl.values.uptr.TreeAdapter; … … 15 26 private final List<Token> tokenList; 16 27 private final Iterator<Token> tokenIterator; 17 28 18 29 public TokenIterator(IConstructor parseTree) { 19 30 this.tokenList = new LinkedList<Token>(); … … 27 38 } 28 39 tokenIterator = tokenList.iterator(); 40 29 41 } 30 42 … … 45 57 public IConstructor visitTreeAmb(IConstructor arg) throws VisitorException { 46 58 // we just go into the first, it's arbitrary but at least we'll get some nice highlighting 59 return (IConstructor) TreeAdapter.getAlternatives(arg).iterator().next().accept(this); 47 60 // TreeAdapter.getAlternatives(arg).iterator().next().accept(this); 48 tokenList.add(new Token(TokenColorer.AMBIGUOUS, TreeAdapter.getLocation((IConstructor)TreeAdapter.getAlternatives(arg).iterator().next()))); 49 return arg; 61 //ISourceLocation loc = TreeAdapter.getLocation((IConstructor)TreeAdapter.getAlternatives(arg).iterator().next()); 62 //tokenList.add(new Token(TokenColorer., loc)); 63 64 /* ISet alts = TreeAdapter.getAlternatives(arg); 65 String message = "Ambiguity:\n"; 66 for(IValue alt : alts) { 67 IConstructor prod = TreeAdapter.getProduction((IConstructor)alt); 68 message += " " + ProductionAdapter.getSortName(prod) + " ::= " + ProductionAdapter.getLhs(prod) + "\n"; 69 } 70 71 if(msgHandler != null) { 72 msgHandler.handleSimpleMessage(message, loc.getOffset(), loc.getOffset()+loc.getLength(), 0, 0, 0, 0); 73 } 74 System.out.println(message); 75 */ 76 // return arg; 50 77 } 51 78 … … 58 85 IConstructor prod = TreeAdapter.getProduction(arg); 59 86 String sort = ProductionAdapter.getSortName(prod); 60 if(TokenColorer.categories.contains(sort)) 87 category = ProductionAdapter.getCategory(prod); 88 //String code = TreeAdapter.yield(arg); 89 90 if(category == null && TokenColorer.categories.contains(sort)) 61 91 category = sort; 62 else 63 category = ProductionAdapter.getCategory(prod); 92 64 93 if(TokenColorer.ERROR.equals(ProductionAdapter.getConstructorName(prod))) 65 94 category = TokenColorer.ERROR; -
trunk/MagnoliaPlugin/src/org/magnolialang/manager/MagnoliaProjectManager.java
r442 r448 200 200 } 201 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 202 216 public boolean dataInvariant() { 203 217 return loader != null && buildPath != null; -
trunk/MagnoliaPlugin/src/org/magnolialang/xatree/TreeImplodeVisitor.java
r442 r448 4 4 import java.util.regex.Pattern; 5 5 6 import org.eclipse.core.resources.IFile; 7 import org.eclipse.core.resources.IMarker; 8 import org.eclipse.core.resources.IResource; 9 import org.eclipse.core.resources.IResourceRuleFactory; 10 import org.eclipse.core.runtime.CoreException; 11 import org.eclipse.imp.parser.IMessageHandler; 6 12 import org.eclipse.imp.pdb.facts.IConstructor; 7 13 import org.eclipse.imp.pdb.facts.IList; 8 14 import org.eclipse.imp.pdb.facts.IListWriter; 9 15 import org.eclipse.imp.pdb.facts.INode; 16 import org.eclipse.imp.pdb.facts.ISet; 17 import org.eclipse.imp.pdb.facts.ISourceLocation; 10 18 import org.eclipse.imp.pdb.facts.IString; 11 19 import org.eclipse.imp.pdb.facts.ITuple; … … 17 25 import org.eclipse.imp.pdb.facts.type.TypeStore; 18 26 import org.eclipse.imp.pdb.facts.visitors.VisitorException; 27 import org.magnolialang.eclipse.editor.Token; 28 import org.magnolialang.eclipse.editor.TokenColorer; 29 import org.magnolialang.load.ProjectURIResolver; 19 30 import org.rascalmpl.values.ValueFactoryFactory; 20 31 import org.rascalmpl.values.uptr.Factory; … … 34 45 public static final Type Attr = tf.abstractDataType(uptr, "Attr"); 35 46 public static final Type Attr_Abstract = tf.constructor(uptr, Attr, "selectable"); 36 47 private static final String AMB_MARKER = "magnolia_eclipse.ambiguityMarker"; 48 private IMessageHandler handler; 49 50 51 /** 52 * Create a new tree imploder, not attached to a message handler. 53 */ 54 public TreeImplodeVisitor() { 55 this.handler = null; 56 } 57 58 /** 59 * Create a new tree imploder, attached to the file. 60 * @param handler Message handler for reporting errors 61 */ 62 public TreeImplodeVisitor(IMessageHandler handler) { 63 this.handler = handler; 64 } 65 66 37 67 @Override 38 68 public IConstructor visitTreeAmb(IConstructor tree) throws VisitorException { 39 // TODO Auto-generated method stub 40 return null; 69 IConstructor result = (IConstructor)TreeAdapter.getAlternatives(tree).iterator().next(); 70 71 return result; 41 72 } 42 73 … … 163 194 assert v instanceof IConstructor; 164 195 IConstructor tree = (IConstructor)v; 165 196 if(TreeAdapter.isAmb(tree)) 197 tree = visitTreeAmb(tree); 166 198 if(TreeAdapter.isCfOptLayout(tree)) { 167 199 String chars = TreeAdapter.yield(tree); -
trunk/MagnoliaPlugin/src/org/magnolialang/xatree/TreeImploder.java
r439 r448 1 1 package org.magnolialang.xatree; 2 2 3 import org.eclipse.core.resources.IFile; 4 import org.eclipse.imp.parser.IMessageHandler; 3 5 import org.eclipse.imp.pdb.facts.IValue; 4 6 import org.eclipse.imp.pdb.facts.visitors.VisitorException; … … 7 9 public class TreeImploder { 8 10 11 /** 12 * Implode an AsFix tree to an XaTree. 13 * @param tree A tree in AsFix format 14 * @return An imploded XaTree 15 */ 9 16 public static IValue implodeTree(IValue tree) { 10 17 try { … … 14 21 } 15 22 } 23 24 /** 25 * Implode an AsFix tree to an XaTree, annotating the given file with any errors encountered. 26 * @param tree A tree in AsFix format 27 * @param file A file, for marker annotations 28 * @return An imploded XaTree 29 */ 30 public static IValue implodeTree(IValue tree, IMessageHandler handler) { 31 try { 32 return tree.accept(new TreeImplodeVisitor(handler)); 33 } catch (VisitorException e) { 34 throw new ImplementationError("Failed to implode parse tree", e); 35 } 36 } 37 16 38 }
Note:
See TracChangeset
for help on using the changeset viewer.