|
Lines 16-22
Link Here
|
| 16 |
import java.util.ArrayList; |
16 |
import java.util.ArrayList; |
| 17 |
import java.util.List; |
17 |
import java.util.List; |
| 18 |
|
18 |
|
| 19 |
import lpg.lpgjavaruntime.Monitor; |
19 |
import lpg.runtime.Monitor; |
| 20 |
|
20 |
|
| 21 |
import org.eclipse.core.runtime.CoreException; |
21 |
import org.eclipse.core.runtime.CoreException; |
| 22 |
import org.eclipse.core.runtime.IProgressMonitor; |
22 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
Lines 42-48
Link Here
|
| 42 |
{ |
42 |
{ |
| 43 |
protected final EPackage.Registry registryToo; |
43 |
protected final EPackage.Registry registryToo; |
| 44 |
protected final XMIResource ast; |
44 |
protected final XMIResource ast; |
| 45 |
protected final AbstractModelResolver resolver; |
45 |
protected final AbstractModelResolver resolver; |
|
|
46 |
|
| 47 |
private ICSTFileAnalyzer<R> analyzer; |
| 48 |
|
| 46 |
private TypeResolver<EClassifier, EOperation, EStructuralFeature> typeResolver; // FIXME Duplicated to support reset |
49 |
private TypeResolver<EClassifier, EOperation, EStructuralFeature> typeResolver; // FIXME Duplicated to support reset |
| 47 |
// inherited functionality should allow typeResolver to be in CSTRootEnvironment |
50 |
// inherited functionality should allow typeResolver to be in CSTRootEnvironment |
| 48 |
|
51 |
|
|
Lines 63-69
Link Here
|
| 63 |
this(new EPackageRegistryImpl(), file, resourceSet, astResource); |
66 |
this(new EPackageRegistryImpl(), file, resourceSet, astResource); |
| 64 |
} |
67 |
} |
| 65 |
|
68 |
|
| 66 |
public abstract ICSTFileAnalyzer<R> createAnalyzer(Monitor monitor); |
69 |
public ICSTFileAnalyzer<R> getAnalyzer(Monitor monitor, Reader reader, String fileName) throws IOException { |
|
|
70 |
|
| 71 |
if (analyzer == null) { |
| 72 |
analyzer = createAnalyzer(monitor, reader, fileName); |
| 73 |
} else { |
| 74 |
analyzer.reset(reader, null); |
| 75 |
} |
| 76 |
return analyzer; |
| 77 |
} |
| 78 |
|
| 79 |
protected abstract ICSTFileAnalyzer<R> createAnalyzer(Monitor monitor, Reader reader, String fileName) throws IOException; |
| 67 |
|
80 |
|
| 68 |
protected abstract R createRootEnvironment(XMIResource ast, CST cst); |
81 |
protected abstract R createRootEnvironment(XMIResource ast, CST cst); |
| 69 |
|
82 |
|
|
Lines 110-134
Link Here
|
| 110 |
|
123 |
|
| 111 |
public ICSTRootEnvironment parse(Reader reader, AbstractFileHandle file, IProgressMonitor monitor) throws IOException, CoreException { |
124 |
public ICSTRootEnvironment parse(Reader reader, AbstractFileHandle file, IProgressMonitor monitor) throws IOException, CoreException { |
| 112 |
Monitor lpgMonitor = new LPGProgressMonitor(monitor); |
125 |
Monitor lpgMonitor = new LPGProgressMonitor(monitor); |
| 113 |
ICSTFileAnalyzer<R> analyzer = createAnalyzer(lpgMonitor); |
|
|
| 114 |
analyzer.setFileName(file.getName()); |
| 115 |
if (reader == null) |
126 |
if (reader == null) |
| 116 |
reader = new InputStreamReader(file.getContents()); |
127 |
reader = new InputStreamReader(file.getContents()); |
| 117 |
else if (!file.exists()) |
128 |
else if (!file.exists()) |
| 118 |
return null; |
129 |
return null; |
| 119 |
analyzer.initialize(reader); |
130 |
|
|
|
131 |
ICSTFileAnalyzer<R> analyzer = getAnalyzer(lpgMonitor, reader, file.getName()); |
| 132 |
// analyzer.initialize(reader); |
| 120 |
AbstractParser parser = getParser(); |
133 |
AbstractParser parser = getParser(); |
| 121 |
if ((monitor != null) && monitor.isCanceled()) |
134 |
if ((monitor != null) && monitor.isCanceled()) |
| 122 |
return null; |
135 |
return null; |
| 123 |
parser.getLexer().lexToTokens(parser); |
136 |
parser.getLexer().lexer(parser.getIPrsStream()); |
| 124 |
if ((monitor != null) && monitor.isCanceled()) |
137 |
if ((monitor != null) && monitor.isCanceled()) |
| 125 |
return null; |
138 |
return null; |
| 126 |
@SuppressWarnings("unchecked") // Maybe this should be a generic parameter |
139 |
@SuppressWarnings("unchecked") // Maybe this should be a generic parameter |
| 127 |
CST cst = (CST) parser.parseTokensToCST(lpgMonitor, -1); |
140 |
CST cst = (CST) parser.parser(lpgMonitor, -1); |
| 128 |
if (cst == null) |
141 |
if (cst == null) |
| 129 |
return null; |
142 |
return null; |
| 130 |
if ((monitor != null) && monitor.isCanceled()) |
143 |
if ((monitor != null) && monitor.isCanceled()) |
| 131 |
return null; |
144 |
return null; |
|
|
145 |
|
| 132 |
R rootEnvironment; |
146 |
R rootEnvironment; |
| 133 |
try { |
147 |
try { |
| 134 |
reset(); |
148 |
reset(); |