Making contrib/javahints compilable after recent introduction of Java Hints SPI.
1.1 --- a/javahints/nbproject/project.xml Fri Mar 09 16:37:50 2012 +0100
1.2 +++ b/javahints/nbproject/project.xml Fri Mar 09 21:01:38 2012 +0100
1.3 @@ -172,11 +172,12 @@
1.4 </run-dependency>
1.5 </dependency>
1.6 <dependency>
1.7 - <code-name-base>org.netbeans.modules.java.hints.processor</code-name-base>
1.8 + <code-name-base>org.netbeans.modules.java.hints.legacy.spi</code-name-base>
1.9 <build-prerequisite/>
1.10 <compile-dependency/>
1.11 <run-dependency>
1.12 - <implementation-version/>
1.13 + <release-version>1</release-version>
1.14 + <specification-version>1.0</specification-version>
1.15 </run-dependency>
1.16 </dependency>
1.17 <dependency>
1.18 @@ -277,6 +278,14 @@
1.19 </run-dependency>
1.20 </dependency>
1.21 <dependency>
1.22 + <code-name-base>org.netbeans.spi.java.hints</code-name-base>
1.23 + <build-prerequisite/>
1.24 + <compile-dependency/>
1.25 + <run-dependency>
1.26 + <implementation-version/>
1.27 + </run-dependency>
1.28 + </dependency>
1.29 + <dependency>
1.30 <code-name-base>org.netbeans.spi.tasklist</code-name-base>
1.31 <build-prerequisite/>
1.32 <compile-dependency/>
2.1 --- a/javahints/src/org/netbeans/modules/javahints/RPD.java Fri Mar 09 16:37:50 2012 +0100
2.2 +++ b/javahints/src/org/netbeans/modules/javahints/RPD.java Fri Mar 09 21:01:38 2012 +0100
2.3 @@ -51,24 +51,22 @@
2.4 import org.netbeans.api.java.source.CompilationInfo;
2.5 import org.netbeans.api.java.source.GeneratorUtilities;
2.6 import org.netbeans.api.java.source.WorkingCopy;
2.7 -import org.netbeans.modules.java.hints.jackpot.code.spi.Hint;
2.8 -import org.netbeans.modules.java.hints.jackpot.code.spi.TriggerPattern;
2.9 -import org.netbeans.modules.java.hints.jackpot.impl.Utilities;
2.10 -import org.netbeans.modules.java.hints.jackpot.spi.HintContext;
2.11 -import org.netbeans.modules.java.hints.jackpot.spi.JavaFix;
2.12 -import org.netbeans.modules.java.hints.jackpot.spi.support.ErrorDescriptionFactory;
2.13 +import org.netbeans.modules.java.hints.spiimpl.Utilities;
2.14 import org.netbeans.spi.editor.hints.ErrorDescription;
2.15 +import org.netbeans.spi.java.hints.*;
2.16
2.17 /**
2.18 *
2.19 * @author lahvac
2.20 */
2.21 -@Hint(category="apisupport") // XXX move to apisupport.refactoring once the required packages are at least available to friends
2.22 +@Hint(displayName="#DN_org.netbeans.modules.javahints.RPD",
2.23 + description="#DESC_org.netbeans.modules.javahints.RPD",
2.24 + category="apisupport") // XXX move to apisupport.refactoring once the required packages are at least available to friends
2.25 public class RPD {
2.26
2.27 @TriggerPattern(value="org.openide.util.RequestProcessor.getDefault()")
2.28 public static ErrorDescription hint(HintContext ctx) {
2.29 - return ErrorDescriptionFactory.forTree(ctx, ctx.getPath(), "RequestProcessor.getDefault()", JavaFix.toEditorFix(new FixImpl(ctx.getInfo(), ctx.getPath())));
2.30 + return ErrorDescriptionFactory.forTree(ctx, ctx.getPath(), "RequestProcessor.getDefault()", new FixImpl(ctx.getInfo(), ctx.getPath()).toEditorFix());
2.31 }
2.32
2.33 private static final class FixImpl extends JavaFix {
2.34 @@ -80,12 +78,13 @@
2.35 }
2.36
2.37 @Override
2.38 - protected void performRewrite(WorkingCopy wc, TreePath tp, boolean canShowUI) {
2.39 + protected void performRewrite(TransformationContext ctx) {
2.40 + WorkingCopy wc = ctx.getWorkingCopy();
2.41 String fieldName = fieldCache.get(wc);
2.42 Scope s = Utilities.constructScope(wc, Collections.<String, TypeMirror>emptyMap());
2.43
2.44 if (fieldName == null) {
2.45 - TreePath topLevel = tp;
2.46 + TreePath topLevel = ctx.getPath();
2.47
2.48 while (topLevel.getParentPath().getLeaf().getKind() != Kind.COMPILATION_UNIT) {
2.49 topLevel = topLevel.getParentPath();
2.50 @@ -99,7 +98,7 @@
2.51 fieldCache.put(wc, fieldName);
2.52 }
2.53
2.54 - wc.rewrite(tp.getLeaf(), wc.getTreeMaker().Identifier(fieldName));
2.55 + wc.rewrite(ctx.getPath().getLeaf(), wc.getTreeMaker().Identifier(fieldName));
2.56 }
2.57
2.58 @Override
3.1 --- a/javahints/src/org/netbeans/modules/javahints/tasklist/ComputeTasks.java Fri Mar 09 16:37:50 2012 +0100
3.2 +++ b/javahints/src/org/netbeans/modules/javahints/tasklist/ComputeTasks.java Fri Mar 09 21:01:38 2012 +0100
3.3 @@ -30,16 +30,18 @@
3.4
3.5 import java.io.IOException;
3.6 import java.util.Collection;
3.7 +import java.util.Collections;
3.8 import java.util.LinkedList;
3.9 import java.util.List;
3.10 import java.util.Map.Entry;
3.11 import java.util.concurrent.atomic.AtomicBoolean;
3.12 +import org.netbeans.api.java.classpath.ClassPath;
3.13 import org.netbeans.api.java.source.CompilationInfo;
3.14 -import org.netbeans.modules.java.hints.jackpot.impl.RulesManager;
3.15 -import org.netbeans.modules.java.hints.jackpot.impl.hints.HintsInvoker;
3.16 -import org.netbeans.modules.java.hints.jackpot.spi.HintDescription;
3.17 -import org.netbeans.modules.java.hints.jackpot.spi.HintMetadata;
3.18 -import org.netbeans.modules.java.hints.options.HintsSettings;
3.19 +import org.netbeans.modules.java.hints.providers.spi.HintDescription;
3.20 +import org.netbeans.modules.java.hints.providers.spi.HintMetadata;
3.21 +import org.netbeans.modules.java.hints.spiimpl.RulesManager;
3.22 +import org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker;
3.23 +import org.netbeans.modules.java.hints.spiimpl.options.HintsSettings;
3.24 import org.netbeans.spi.editor.hints.ErrorDescription;
3.25 import org.netbeans.spi.tasklist.Task;
3.26
3.27 @@ -52,7 +54,7 @@
3.28 public static List<? extends Task> computeTasks(CompilationInfo info, AtomicBoolean cancel) throws IOException {
3.29 //TODO: move the hint computation to TaskResolver?
3.30 Collection<HintDescription> hints = new LinkedList<HintDescription>();
3.31 - for (Entry<HintMetadata, Collection<? extends HintDescription>> e : RulesManager.getInstance().allHints.entrySet()) {
3.32 + for ( Entry<HintMetadata, ? extends Collection<? extends HintDescription>> e : RulesManager.getInstance().readHints(info, Collections.<ClassPath>emptyList(), new AtomicBoolean()).entrySet()) {
3.33 if (!HintsSettings.isEnabled(e.getKey()) || !HintsSettings.isShowInTaskList(e.getKey())) continue;
3.34
3.35 hints.addAll(e.getValue());