KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > retouche > editor > codetemplates > GsfCodeTemplateProcessor


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.retouche.editor.codetemplates;
21
22
23 import java.io.IOException JavaDoc;
24 import java.util.*;
25 import javax.swing.SwingUtilities JavaDoc;
26 import javax.swing.text.JTextComponent JavaDoc;
27 import org.netbeans.api.retouche.source.CompilationInfo;
28
29 import org.netbeans.lib.editor.codetemplates.spi.*;
30 import org.openide.ErrorManager;
31
32 /**
33  * This file is originally from Retouche, the Java Support
34  * infrastructure in NetBeans. I have modified the file as little
35  * as possible to make merging Retouche fixes back as simple as
36  * possible.
37  *
38  *
39  * @author Dusan Balek
40  */

41 public class GsfCodeTemplateProcessor implements CodeTemplateProcessor {
42     
43     public static final String JavaDoc INSTANCE_OF = "instanceof"; //NOI18N
44
public static final String JavaDoc ARRAY = "array"; //NOI18N
45
public static final String JavaDoc ITERABLE = "iterable"; //NOI18N
46
public static final String JavaDoc TYPE = "type"; //NOI18N
47
public static final String JavaDoc ITERABLE_ELEMENT_TYPE = "iterableElementType"; //NOI18N
48
public static final String JavaDoc LEFT_SIDE_TYPE = "leftSideType"; //NOI18N
49
public static final String JavaDoc RIGHT_SIDE_TYPE = "rightSideType"; //NOI18N
50
public static final String JavaDoc CAST = "cast"; //NOI18N
51
public static final String JavaDoc NEW_VAR_NAME = "newVarName"; //NOI18N
52
public static final String JavaDoc NAMED = "named"; //NOI18N
53

54     private static final String JavaDoc FALSE = "false"; //NOI18N
55
private static final String JavaDoc NULL = "null"; //NOI18N
56

57     private CodeTemplateInsertRequest request;
58
59     private CompilationInfo cInfo = null;
60 // private TreePath treePath = null;
61
// private Scope scope = null;
62
// private TypeElement enclClass = null;
63
// private Iterable<? extends Element> locals = null;
64
private Map<CodeTemplateParameter, String JavaDoc> param2hints = new HashMap<CodeTemplateParameter, String JavaDoc>();
65 // private Map<CodeTemplateParameter, TypeMirror> param2types = new HashMap<CodeTemplateParameter, TypeMirror>();
66
// private ErrChecker errChecker = new ErrChecker();
67

68     private GsfCodeTemplateProcessor(CodeTemplateInsertRequest request) {
69         this.request = request;
70     }
71
72     
73     public synchronized void updateDefaultValues() {
74         boolean cont = true;
75         while (cont) {
76             cont = false;
77             for (Object JavaDoc p : request.getMasterParameters()) {
78                 CodeTemplateParameter param = (CodeTemplateParameter)p;
79                 String JavaDoc value = getProposedValue(param);
80                 if (value != null && !value.equals(param.getValue())) {
81                     param.setValue(value);
82                     cont = true;
83                 }
84             }
85         }
86 // for (Map.Entry<CodeTemplateParameter, TypeMirror> entry : param2types.entrySet()) {
87
// CodeTemplateParameter param = entry.getKey();
88
// if (CAST.equals(param2hints.get(param))) {
89
// param.setValue("(" + Utilities.getTypeName(entry.getValue(), false) + ")"); //NOI18N
90
// } else if (INSTANCE_OF.equals(param2hints.get(param))) {
91
// String value = param.getValue().substring(param.getValue().lastIndexOf('.') + 1); //NOI18N
92
// param.setValue(Utilities.getTypeName(entry.getValue(), false) + "." + value); //NOI18N
93
// } else {
94
// param.setValue(Utilities.getTypeName(entry.getValue(), false));
95
// }
96
// }
97
}
98 //
99
public void parameterValueChanged(CodeTemplateParameter masterParameter, boolean typingChange) {
100 // if (typingChange) {
101
// for (Object p : request.getMasterParameters()) {
102
// CodeTemplateParameter param = (CodeTemplateParameter)p;
103
// if (!param.isUserModified()) {
104
// String value = getProposedValue(param);
105
// if (value != null && !value.equals(param.getValue()))
106
// param.setValue(value);
107
// } else {
108
// param2types.remove(param);
109
// }
110
// }
111
// for (Map.Entry<CodeTemplateParameter, TypeMirror> entry : param2types.entrySet()) {
112
// CodeTemplateParameter param = entry.getKey();
113
// if (CAST.equals(param2hints.get(param))) {
114
// param.setValue("(" + Utilities.getTypeName(entry.getValue(), false) + ")"); //NOI18N
115
// } else if (INSTANCE_OF.equals(param2hints.get(param))) {
116
// String value = param.getValue().substring(param.getValue().lastIndexOf('.') + 1); //NOI18N
117
// param.setValue(Utilities.getTypeName(entry.getValue(), false) + "." + value); //NOI18N
118
// } else {
119
// param.setValue(Utilities.getTypeName(entry.getValue(), false));
120
// }
121
// }
122
// }
123
}
124 //
125
public void release() {
126 // if (param2types.size() > 0) {
127
// SwingUtilities.invokeLater(new Runnable() {
128
// public void run() {
129
// try {
130
// cInfo.getJavaSource().runModificationTask(new CancellableTask<WorkingCopy>() {
131
// public void cancel() {
132
// }
133
// public void run(WorkingCopy copy) throws IOException {
134
// copy.toPhase(JavaSource.Phase.PARSED);
135
// AutoImport imp = AutoImport.get(copy);
136
// for (Map.Entry<CodeTemplateParameter, TypeMirror> entry : param2types.entrySet()) {
137
// CodeTemplateParameter param = entry.getKey();
138
// TypeMirror tm = param2types.get(param);
139
// if (tm.getKind() == TypeKind.DECLARED) {
140
// TreePath tp = copy.getTreeUtilities().pathFor(request.getInsertTextOffset() + param.getInsertTextOffset() + (INSTANCE_OF.equals(param2hints.get(param)) ? param.getValue().lastIndexOf('.') - 1 : param.getValue().length()));
141
// imp.resolveImport(tp.getLeaf(), (DeclaredType)tm);
142
// }
143
// }
144
// }
145
// }).commit();
146
// } catch (IOException ex) {
147
// ex.printStackTrace();
148
// }
149
// }
150
// });
151
// }
152
}
153
154 //
155
private String JavaDoc getProposedValue(CodeTemplateParameter param) {
156 // param2hints.remove(param);
157
// param2types.remove(param);
158
String JavaDoc name = null;
159         for (Object JavaDoc e : param.getHints().entrySet()) {
160             Map.Entry entry = (Map.Entry)e;
161             if (INSTANCE_OF.equals(entry.getKey())) {
162 // VariableElement ve = instanceOf((String)entry.getValue(), name);
163
// if (ve != null) {
164
// param2hints.put(param, INSTANCE_OF);
165
// return ve.getSimpleName().toString();
166
// } else {
167
// ve = staticInstanceOf((String)entry.getValue(), name);
168
// if (ve != null) {
169
// param2hints.put(param, INSTANCE_OF);
170
// TypeMirror tm = ve.getEnclosingElement().asType();
171
// param2types.put(param, tm);
172
// return Utilities.getTypeName(tm, true) + "." + ve.getSimpleName();
173
// } else {
174
// return valueOf((String)entry.getValue());
175
// }
176
// }
177
// } else if (ARRAY.equals(entry.getKey())) {
178
// VariableElement ve = array();
179
// if (ve != null) {
180
// param2hints.put(param, ARRAY);
181
// return ve.getSimpleName().toString();
182
// }
183
// } else if (ITERABLE.equals(entry.getKey())) {
184
// VariableElement ve = iterable();
185
// if (ve != null) {
186
// param2hints.put(param, ITERABLE);
187
// return ve.getSimpleName().toString();
188
// }
189
// } else if (TYPE.equals(entry.getKey())) {
190
// TypeMirror tm = type((String)entry.getValue());
191
// if (tm != null && tm.getKind() != TypeKind.ERROR) {
192
// if (tm.getKind() == TypeKind.TYPEVAR)
193
// tm = ((TypeVariable)tm).getUpperBound();
194
// String value = Utilities.getTypeName(tm, true);
195
// if (value != null) {
196
// param2hints.put(param, TYPE);
197
// param2types.put(param, tm);
198
// return value;
199
// }
200
// }
201
// } else if (ITERABLE_ELEMENT_TYPE.equals(entry.getKey())) {
202
// TypeMirror tm = iterableElementType(param.getInsertTextOffset() + 1);
203
// if (tm != null && tm.getKind() != TypeKind.ERROR) {
204
// if (tm.getKind() == TypeKind.TYPEVAR)
205
// tm = ((TypeVariable)tm).getUpperBound();
206
// String value = Utilities.getTypeName(tm, true);
207
// if (value != null) {
208
// param2hints.put(param, ITERABLE_ELEMENT_TYPE);
209
// param2types.put(param, tm);
210
// return value;
211
// }
212
// }
213
// } else if (LEFT_SIDE_TYPE.equals(entry.getKey())) {
214
// TypeMirror tm = assignmentSideType(param.getInsertTextOffset() + 1, true);
215
// if (tm != null && tm.getKind() != TypeKind.ERROR) {
216
// if (tm.getKind() == TypeKind.TYPEVAR)
217
// tm = ((TypeVariable)tm).getUpperBound();
218
// String value = Utilities.getTypeName(tm, true);
219
// if (value != null) {
220
// param2hints.put(param, LEFT_SIDE_TYPE);
221
// param2types.put(param, tm);
222
// return value;
223
// }
224
// }
225
// } else if (RIGHT_SIDE_TYPE.equals(entry.getKey())) {
226
// TypeMirror tm = assignmentSideType(param.getInsertTextOffset() + 1, false);
227
// if (tm != null && tm.getKind() != TypeKind.ERROR) {
228
// if (tm.getKind() == TypeKind.TYPEVAR)
229
// tm = ((TypeVariable)tm).getUpperBound();
230
// String value = Utilities.getTypeName(tm, true);
231
// if (value != null) {
232
// param2hints.put(param, RIGHT_SIDE_TYPE);
233
// param2types.put(param, tm);
234
// return value;
235
// }
236
// }
237
// } else if (CAST.equals(entry.getKey())) {
238
// TypeMirror tm = cast(param.getInsertTextOffset() + 1);
239
// if (tm == null) {
240
// param2hints.put(param, CAST);
241
// param2types.remove(param);
242
// return ""; //NOI18N
243
// } else if (tm.getKind() != TypeKind.ERROR) {
244
// String value = Utilities.getTypeName(tm, true);
245
// if (value != null) {
246
// param2hints.put(param, CAST);
247
// param2types.put(param, tm); //NOI18N
248
// return "(" + value + ")"; //NOI18N
249
// }
250
// }
251
} else if (NEW_VAR_NAME.equals(entry.getKey())) {
252                 param2hints.put(param, NEW_VAR_NAME);
253                 return newVarName(param.getInsertTextOffset() + 1);
254             } else if (NAMED.equals(entry.getKey())) {
255                 name = param.getName();
256             }
257         }
258         return null;
259     }
260 //
261
// private VariableElement instanceOf(String typeName, String name) {
262
// try {
263
// initParsing();
264
// TypeMirror type = cInfo.getTreeUtilities().parseType(typeName, enclClass);
265
// VariableElement closest = null;
266
// int distance = Integer.MAX_VALUE;
267
// if (type != null) {
268
// Types types = cInfo.getTypes();
269
// for (Element e : locals) {
270
// if (e instanceof VariableElement && types.isAssignable(e.asType(), type)) {
271
// if (name == null)
272
// return (VariableElement)e;
273
// int d = UiUtils.getDistance(e.getSimpleName().toString(), name);
274
// if (d < distance) {
275
// distance = d;
276
// closest = (VariableElement)e;
277
// }
278
// }
279
// }
280
// }
281
// return closest;
282
// } catch (Exception e) {
283
// return null;
284
// }
285
// }
286
//
287
// private VariableElement staticInstanceOf(String typeName, String name) {
288
// try {
289
// initParsing();
290
// final TreeUtilities tu = cInfo.getTreeUtilities();
291
// TypeMirror type = tu.parseType(typeName, enclClass);
292
// VariableElement closest = null;
293
// int distance = Integer.MAX_VALUE;
294
// if (type != null) {
295
// final Types types = cInfo.getTypes();
296
// if (type.getKind() == TypeKind.DECLARED) {
297
// final DeclaredType dType = (DeclaredType)type;
298
// final TypeElement element = (TypeElement)dType.asElement();
299
// final boolean isStatic = element.getKind().isClass() || element.getKind().isInterface();
300
// ElementUtilities.ElementAcceptor acceptor = new ElementUtilities.ElementAcceptor() {
301
// public boolean accept(Element e, TypeMirror t) {
302
// return e.getKind().isField() &&
303
// (!isStatic || e.getModifiers().contains(Modifier.STATIC)) &&
304
// tu.isAccessible(scope, e, t) &&
305
// (e.getKind().isField() && types.isAssignable(((VariableElement)e).asType(), dType) || e.getKind() == ElementKind.METHOD && types.isAssignable(((ExecutableElement)e).getReturnType(), dType));
306
// }
307
// };
308
// for (Element ee : cInfo.getElementUtilities().getMembers(dType, acceptor)) {
309
// if (name == null)
310
// return (VariableElement)ee;
311
// int d = UiUtils.getDistance(ee.getSimpleName().toString(), name);
312
// if (d < distance) {
313
// distance = d;
314
// closest = (VariableElement)ee;
315
// }
316
// }
317
// }
318
// }
319
// return closest;
320
// } catch (Exception e) {
321
// return null;
322
// }
323
// }
324
//
325
// private String valueOf(String typeName) {
326
// try {
327
// initParsing();
328
// TypeMirror type = cInfo.getTreeUtilities().parseType(typeName, enclClass);
329
// if (type != null) {
330
// if (type.getKind() == TypeKind.DECLARED)
331
// return NULL;
332
// else if (type.getKind() == TypeKind.BOOLEAN)
333
// return FALSE;
334
// }
335
// } catch (Exception e) {
336
// }
337
// return null;
338
// }
339
//
340
// private VariableElement array() {
341
// initParsing();
342
// for (Element e : locals) {
343
// if (e instanceof VariableElement && e.asType().getKind() == TypeKind.ARRAY)
344
// return (VariableElement)e;
345
// }
346
// return null;
347
// }
348
//
349
// private VariableElement iterable() {
350
// initParsing();
351
// TypeMirror iterableType = cInfo.getTypes().getDeclaredType(cInfo.getElements().getTypeElement("java.lang.Iterable")); //NOI18N
352
// for (Element e : locals) {
353
// if (e instanceof VariableElement && (e.asType().getKind() == TypeKind.ARRAY || cInfo.getTypes().isAssignable(e.asType(), iterableType)))
354
// return (VariableElement)e;
355
// }
356
// return null;
357
// }
358
//
359
// private TypeMirror type(String typeName) {
360
// initParsing();
361
// return cInfo.getTreeUtilities().parseType(typeName, enclClass);
362
// }
363
//
364
// private TypeMirror iterableElementType(int caretOffset) {
365
// try {
366
// initParsing();
367
// SourcePositions[] sourcePositions = new SourcePositions[1];
368
// TreeUtilities tu = cInfo.getTreeUtilities();
369
// StatementTree stmt = tu.parseStatement(request.getInsertText(), sourcePositions);
370
// if (errChecker.containsErrors(stmt))
371
// return null;
372
// tu.attributeTree(stmt, scope);
373
// TreePath path = tu.pathFor(new TreePath(treePath, stmt), caretOffset, sourcePositions[0]);
374
// TreePath loop = Utilities.getPathElementOfKind(Tree.Kind.ENHANCED_FOR_LOOP, path);
375
// if (loop != null) {
376
// TypeMirror type = cInfo.getTrees().getTypeMirror(new TreePath(loop, ((EnhancedForLoopTree)loop.getLeaf()).getExpression()));
377
// switch (type.getKind()) {
378
// case ARRAY:
379
// type = ((ArrayType)type).getComponentType();
380
// return type;
381
// case DECLARED:
382
// Iterator<? extends TypeMirror> types = ((DeclaredType)type).getTypeArguments().iterator();
383
// if (types.hasNext())
384
// return types.next();
385
// return cInfo.getElements().getTypeElement("java.lang.Object").asType(); //NOI18N
386
// }
387
// }
388
// } catch (Exception e) {
389
// }
390
// return null;
391
// }
392
//
393
// private TypeMirror assignmentSideType(int caretOffset, boolean left) {
394
// try {
395
// initParsing();
396
// SourcePositions[] sourcePositions = new SourcePositions[1];
397
// TreeUtilities tu = cInfo.getTreeUtilities();
398
// StatementTree stmt = tu.parseStatement(request.getInsertText(), sourcePositions);
399
// if (errChecker.containsErrors(stmt))
400
// return null;
401
// tu.attributeTree(stmt, scope);
402
// TreePath path = tu.pathFor(new TreePath(treePath, stmt), caretOffset, sourcePositions[0]);
403
// TreePath tree = Utilities.getPathElementOfKind(EnumSet.of(Tree.Kind.ASSIGNMENT, Tree.Kind.VARIABLE), path);
404
// if (tree == null)
405
// return null;
406
// if (tree.getLeaf().getKind() == Tree.Kind.ASSIGNMENT) {
407
// AssignmentTree as = (AssignmentTree)tree.getLeaf();
408
// TreePath type = new TreePath(tree, left ? as.getVariable() : as.getExpression());
409
// return cInfo.getTrees().getTypeMirror(type);
410
// }
411
// VariableTree vd = (VariableTree)tree.getLeaf();
412
// TreePath type = new TreePath(tree, left ? vd.getType() : vd.getInitializer());
413
// return cInfo.getTrees().getTypeMirror(type);
414
// } catch (Exception e) {
415
// }
416
// return null;
417
// }
418
//
419
// private TypeMirror cast(int caretOffset) {
420
// try {
421
// initParsing();
422
// SourcePositions[] sourcePositions = new SourcePositions[1];
423
// TreeUtilities tu = cInfo.getTreeUtilities();
424
// StatementTree stmt = tu.parseStatement(request.getInsertText(), sourcePositions);
425
// if (errChecker.containsErrors(stmt))
426
// return null;
427
// tu.attributeTree(stmt, scope);
428
// TreePath path = tu.pathFor(new TreePath(treePath, stmt), caretOffset, sourcePositions[0]);
429
// TreePath tree = Utilities.getPathElementOfKind(EnumSet.of(Tree.Kind.ASSIGNMENT, Tree.Kind.VARIABLE), path);
430
// if (tree == null)
431
// return null;
432
// if (tree.getLeaf().getKind() == Tree.Kind.ASSIGNMENT) {
433
// AssignmentTree as = (AssignmentTree)tree.getLeaf();
434
// TypeMirror left = cInfo.getTrees().getTypeMirror(new TreePath(tree, as.getVariable()));
435
// TreePath exp = new TreePath(tree, as.getExpression());
436
// if (exp.getLeaf() instanceof TypeCastTree)
437
// exp = new TreePath(exp, ((TypeCastTree)exp.getLeaf()).getExpression());
438
// TypeMirror right = cInfo.getTrees().getTypeMirror(exp);
439
// if (right == null || left == null)
440
// return null;
441
// if (cInfo.getTypes().isAssignable(right, left))
442
// return null;
443
// return left;
444
// }
445
// VariableTree vd = (VariableTree)tree.getLeaf();
446
// TypeMirror left = cInfo.getTrees().getTypeMirror(new TreePath(tree, vd.getType()));
447
// TreePath exp = new TreePath(tree, vd.getInitializer());
448
// if (exp.getLeaf() instanceof TypeCastTree)
449
// exp = new TreePath(exp, ((TypeCastTree)exp.getLeaf()).getExpression());
450
// TypeMirror right = cInfo.getTrees().getTypeMirror(exp);
451
// if (right == null)
452
// return null;
453
// if (left == null)
454
// return null;
455
// if (right.getKind() != TypeKind.ERROR && cInfo.getTypes().isAssignable(right, left))
456
// return null;
457
// return left;
458
// } catch (Exception e) {
459
// }
460
// return null;
461
// }
462
//
463
private String JavaDoc newVarName(int caretOffset) {
464         try {
465 // initParsing();
466
// SourcePositions[] sourcePositions = new SourcePositions[1];
467
// TreeUtilities tu = cInfo.getTreeUtilities();
468
// StatementTree stmt = tu.parseStatement(request.getInsertText(), sourcePositions);
469
// if (errChecker.containsErrors(stmt))
470
// return null;
471
// tu.attributeTree(stmt, scope);
472
// TreePath path = tu.pathFor(new TreePath(treePath, stmt), caretOffset, sourcePositions[0]);
473
// TreePath decl = Utilities.getPathElementOfKind(Tree.Kind.VARIABLE, path);
474
// if (decl != null) {
475
// TypeMirror type = cInfo.getTrees().getTypeMirror(decl);
476
// boolean isConst = ((VariableTree)decl.getLeaf()).getModifiers().getFlags().containsAll(EnumSet.of(Modifier.FINAL, Modifier.STATIC));
477
// Iterator<String> names = Utilities.varNamesSuggestions(type, null, cInfo.getTypes(), cInfo.getElements(), locals, isConst).iterator();
478
// if (names.hasNext())
479
// return names.next();
480
// }
481
} catch (Exception JavaDoc e) {
482         }
483         return null;
484     }
485     
486 // private void initParsing() {
487
// if (cInfo == null) {
488
// JTextComponent c = request.getComponent();
489
// final int caretOffset = c.getCaret().getDot();
490
// JavaSource js = JavaSource.forDocument(c.getDocument());
491
// if (js != null) {
492
// try {
493
// js.runUserActionTask(new CancellableTask<CompilationController>() {
494
// public void cancel() {
495
// }
496
//
497
// public void run(final CompilationController controller) throws IOException {
498
// controller.toPhase(JavaSource.Phase.RESOLVED);
499
// cInfo = controller;
500
// final TreeUtilities tu = cInfo.getTreeUtilities();
501
// treePath = tu.pathFor(caretOffset);
502
// scope = tu.scopeFor(caretOffset);
503
// enclClass = scope.getEnclosingClass();
504
// final boolean isStatic = enclClass != null ? tu.isStaticContext(scope) : false;
505
// final Trees trees = controller.getTrees();
506
// final SourcePositions sp = trees.getSourcePositions();
507
// final Collection<? extends Element> illegalForwardRefs = Utilities.getForwardReferences(treePath, caretOffset, sp, trees);;
508
// final ExecutableElement method = scope.getEnclosingMethod();
509
// ElementUtilities.ElementAcceptor acceptor = new ElementUtilities.ElementAcceptor() {
510
// public boolean accept(Element e, TypeMirror t) {
511
// switch (e.getKind()) {
512
// case LOCAL_VARIABLE:
513
// if (isStatic && e.getSimpleName().contentEquals("this") || e.getSimpleName().contentEquals("super")) //NOI18N
514
// return false;
515
// case EXCEPTION_PARAMETER:
516
// case PARAMETER:
517
// return (method == e.getEnclosingElement() || e.getModifiers().contains(Modifier.FINAL)) &&
518
// !illegalForwardRefs.contains(e);
519
// case FIELD:
520
// if (illegalForwardRefs.contains(e))
521
// return false;
522
// default:
523
// return (!isStatic || e.getModifiers().contains(Modifier.STATIC)) && tu.isAccessible(scope, e, t);
524
// }
525
// }
526
// };
527
// locals = cInfo.getElementUtilities().getLocalMembersAndVars(scope, acceptor);
528
// }
529
// },false);
530
// } catch(IOException ioe) {
531
// ErrorManager.getDefault().notify(ioe);
532
// }
533
// }
534
// }
535
// }
536
//
537
//
538
// private static class ErrChecker extends TreeScanner<Void, Void> {
539
// private boolean containsErrors;
540
//
541
// public boolean containsErrors(Tree tree) {
542
// containsErrors = false;
543
// scan(tree, null);
544
// return containsErrors;
545
// }
546
//
547
// public Void visitErroneous(ErroneousTree node, Void p) {
548
// containsErrors = true;
549
// return null;
550
// }
551
//
552
// public Void scan(Tree node, Void p) {
553
// if (containsErrors)
554
// return null;
555
// return super.scan(node, p);
556
// }
557
// }
558

559     public static final class Factory implements CodeTemplateProcessorFactory {
560         public CodeTemplateProcessor createProcessor(CodeTemplateInsertRequest request) {
561             return new GsfCodeTemplateProcessor(request);
562         }
563     }
564 }
565
Popular Tags