1 19 package org.netbeans.api.languages; 20 21 import java.lang.ref.WeakReference ; 22 import java.util.Map ; 23 import java.util.WeakHashMap ; 24 import javax.swing.text.Document ; 25 import org.netbeans.modules.languages.ParserManagerImpl; 26 27 28 33 public abstract class ParserManager { 34 35 38 public static enum State { 39 40 PARSING, 41 42 OK, 43 44 ERROR, 45 46 NOT_PARSED 47 } 48 49 50 private static Map <Document ,WeakReference <ParserManager>> managers = 51 new WeakHashMap <Document ,WeakReference <ParserManager>> (); 52 53 58 public static synchronized ParserManager get (Document doc) { 59 WeakReference <ParserManager> wr = managers.get (doc); 60 ParserManager pm = wr != null ? wr.get () : null; 61 if (pm == null) { 62 pm = new ParserManagerImpl (doc); 63 managers.put (doc, new WeakReference <ParserManager> (pm)); 64 } 66 return pm; 67 } 68 69 74 public abstract State getState (); 75 76 82 public abstract ASTNode getAST () throws ParseException; 83 84 89 public abstract void addListener (ParserManagerListener l); 90 91 96 public abstract void removeListener (ParserManagerListener l); 97 98 103 public abstract void addASTEvaluator (ASTEvaluator e); 104 105 110 public abstract void removeASTEvaluator (ASTEvaluator e); 111 } 112 113 114 115 | Popular Tags |