KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > retouche > hints > infrastructure > HintsTask


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-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.retouche.hints.infrastructure;
20
21 import java.util.ArrayList JavaDoc;
22 import java.util.List JavaDoc;
23 import java.util.Map JavaDoc;
24 import org.netbeans.api.retouche.source.CompilationInfo;
25 import org.netbeans.modules.retouche.editor.semantic.ScanningCancellableTask;
26 import org.netbeans.modules.retouche.hints.spi.TreeRule;
27 import org.netbeans.spi.editor.hints.ErrorDescription;
28 import org.netbeans.spi.editor.hints.HintsController;
29
30 /**
31  *
32  * @author Jan Lahoda
33  */

34 public class HintsTask extends ScanningCancellableTask<CompilationInfo> {
35     
36     public HintsTask() {
37     }
38     
39     public void run(CompilationInfo info) throws Exception JavaDoc {
40 // Map<Kind, List<TreeRule>> hints = RulesManager.getInstance().getHints();
41
//
42
// if (hints.isEmpty()) {
43
// return;
44
// }
45

46         List JavaDoc<ErrorDescription> result = new ArrayList JavaDoc<ErrorDescription>();
47         
48         // TODO - delegate to the language plugins
49
//scan(new ScannerImpl(info, hints), info.getCompilationUnit(), result);
50

51         if (isCancelled())
52             return ;
53         
54         HintsController.setErrors(info.getFileObject(), HintsTask.class.getName(), result);
55     }
56     
57 // private static final class ScannerImpl extends CancellableTreePathScanner<Void, List<ErrorDescription>> {
58
//
59
// private CompilationInfo info;
60
// private Map<Kind, List<TreeRule>> hints;
61
//
62
// public ScannerImpl(CompilationInfo info, Map<Kind, List<TreeRule>> hints) {
63
// this.info = info;
64
// this.hints = hints;
65
// }
66
//
67
// private void runAndAdd(TreePath path, List<TreeRule> rules, List<ErrorDescription> d) {
68
// if (rules != null) {
69
// for (TreeRule tr : rules) {
70
// if (isCanceled()) {
71
// return ;
72
// }
73
// List<ErrorDescription> errors = tr.run(info, path);
74
//
75
// if (errors != null) {
76
// d.addAll(errors);
77
// }
78
// }
79
// }
80
// }
81
//
82
// @Override
83
// public Void scan(Tree tree, List<ErrorDescription> p) {
84
// if (tree == null)
85
// return null;
86
//
87
// TreePath tp = new TreePath(getCurrentPath(), tree);
88
// Kind k = tree.getKind();
89
//
90
// runAndAdd(tp, hints.get(k), p);
91
//
92
// if (isCanceled()) {
93
// return null;
94
// }
95
//
96
// return super.scan(tree, p);
97
// }
98
//
99
// @Override
100
// public Void scan(TreePath path, List<ErrorDescription> p) {
101
// Kind k = path.getLeaf().getKind();
102
// runAndAdd(path, hints.get(k), p);
103
//
104
// if (isCanceled()) {
105
// return null;
106
// }
107
//
108
// return super.scan(path, p);
109
// }
110
//
111
// }
112

113 }
114
Popular Tags