Lines 60-73
Link Here
|
60 |
import javax.swing.text.BadLocationException; |
60 |
import javax.swing.text.BadLocationException; |
61 |
import javax.swing.text.Document; |
61 |
import javax.swing.text.Document; |
62 |
import org.netbeans.api.annotations.common.NonNull; |
62 |
import org.netbeans.api.annotations.common.NonNull; |
|
|
63 |
import org.netbeans.api.annotations.common.NullAllowed; |
63 |
import org.netbeans.api.java.source.CompilationInfo; |
64 |
import org.netbeans.api.java.source.CompilationInfo; |
64 |
import org.netbeans.api.java.source.TreePathHandle; |
65 |
import org.netbeans.api.java.source.TreePathHandle; |
65 |
import org.netbeans.api.java.source.WorkingCopy; |
66 |
import org.netbeans.api.java.source.WorkingCopy; |
66 |
import org.netbeans.api.queries.FileEncodingQuery; |
67 |
import org.netbeans.api.queries.FileEncodingQuery; |
67 |
import org.netbeans.modules.java.hints.spiimpl.JavaFixImpl; |
68 |
import org.netbeans.modules.java.hints.spiimpl.JavaFixImpl; |
|
|
69 |
import org.netbeans.modules.java.hints.spiimpl.JavaFixImpl.EnhancedJavaFixImpl; |
68 |
import org.netbeans.modules.java.hints.spiimpl.batch.BatchUtilities; |
70 |
import org.netbeans.modules.java.hints.spiimpl.batch.BatchUtilities; |
69 |
import org.netbeans.modules.refactoring.spi.RefactoringElementImplementation; |
71 |
import org.netbeans.modules.refactoring.spi.RefactoringElementImplementation; |
70 |
import org.netbeans.spi.editor.hints.ChangeInfo; |
72 |
import org.netbeans.spi.editor.hints.ChangeInfo; |
|
|
73 |
import org.netbeans.spi.editor.hints.EnhancedFix; |
71 |
import org.netbeans.spi.editor.hints.Fix; |
74 |
import org.netbeans.spi.editor.hints.Fix; |
72 |
import org.openide.filesystems.FileObject; |
75 |
import org.openide.filesystems.FileObject; |
73 |
import org.openide.util.Exceptions; |
76 |
import org.openide.util.Exceptions; |
Lines 85-90
Link Here
|
85 |
|
88 |
|
86 |
private final TreePathHandle handle; |
89 |
private final TreePathHandle handle; |
87 |
private final Map<String, String> options; |
90 |
private final Map<String, String> options; |
|
|
91 |
private final String sortText; |
88 |
|
92 |
|
89 |
/**Create JavaFix with the given base {@link TreePath}. The base {@link TreePath} |
93 |
/**Create JavaFix with the given base {@link TreePath}. The base {@link TreePath} |
90 |
* will be passed back to the real implementation of the fix. |
94 |
* will be passed back to the real implementation of the fix. |
Lines 96-107
Link Here
|
96 |
protected JavaFix(@NonNull CompilationInfo info, @NonNull TreePath tp) { |
100 |
protected JavaFix(@NonNull CompilationInfo info, @NonNull TreePath tp) { |
97 |
this(info, tp, Collections.<String, String>emptyMap()); |
101 |
this(info, tp, Collections.<String, String>emptyMap()); |
98 |
} |
102 |
} |
|
|
103 |
|
104 |
/**Create JavaFix with the given base {@link TreePath}. The base {@link TreePath} |
105 |
* will be passed back to the real implementation of the fix. |
106 |
* |
107 |
* @param info a {@link CompilationInfo} from which the given {@link TreePath} originates |
108 |
* @param tp a {@link TreePath} that will be passed back to the |
109 |
* {@link #performRewrite(org.netbeans.spi.java.hints.JavaFix.TransformationContext) } method |
110 |
* @param sortText if non-null, fix returned from {@link #toEditorFix() } will be an {@link EnhancedFix}, |
111 |
* and the given {@code sortText} will be returned from its {@link EnhancedFix#getSortText() }. |
112 |
* @since 1.18 |
113 |
*/ |
114 |
protected JavaFix(@NonNull CompilationInfo info, @NonNull TreePath tp, @NullAllowed String sortText) { |
115 |
this(TreePathHandle.create(tp, info), Collections.<String, String>emptyMap(), sortText); |
116 |
} |
99 |
|
117 |
|
100 |
JavaFix(CompilationInfo info, TreePath tp, Map<String, String> options) { |
118 |
JavaFix(CompilationInfo info, TreePath tp, Map<String, String> options) { |
101 |
this.handle = TreePathHandle.create(tp, info); |
119 |
this(TreePathHandle.create(tp, info), options, null); |
102 |
this.options = Collections.unmodifiableMap(new HashMap<String, String>(options)); |
|
|
103 |
} |
120 |
} |
104 |
|
121 |
|
105 |
/**Create JavaFix with the given base {@link TreePathHandle}. The base {@link TreePathHandle} |
122 |
/**Create JavaFix with the given base {@link TreePathHandle}. The base {@link TreePathHandle} |
106 |
* will be resolved and passed back to the real implementation of the fix. |
123 |
* will be resolved and passed back to the real implementation of the fix. |
107 |
* |
124 |
* |
Lines 112-120
Link Here
|
112 |
this(handle, Collections.<String, String>emptyMap()); |
129 |
this(handle, Collections.<String, String>emptyMap()); |
113 |
} |
130 |
} |
114 |
|
131 |
|
|
|
132 |
/**Create JavaFix with the given base {@link TreePathHandle}. The base {@link TreePathHandle} |
133 |
* will be resolved and passed back to the real implementation of the fix. |
134 |
* |
135 |
* @param handle a {@link TreePathHandle} that will be resolved and passed back to the |
136 |
* {@link #performRewrite(org.netbeans.spi.java.hints.JavaFix.TransformationContext) } method |
137 |
* @param sortText if non-null, fix returned from {@link #toEditorFix() } will be an {@link EnhancedFix}, |
138 |
* and the given {@code sortText} will be returned from its {@link EnhancedFix#getSortText() }. |
139 |
* @since 1.18 |
140 |
*/ |
141 |
protected JavaFix(@NonNull TreePathHandle handle, @NullAllowed String sortText) { |
142 |
this(handle, Collections.<String, String>emptyMap()); |
143 |
} |
144 |
|
115 |
JavaFix(TreePathHandle handle, Map<String, String> options) { |
145 |
JavaFix(TreePathHandle handle, Map<String, String> options) { |
|
|
146 |
this(handle, options, null); |
147 |
} |
148 |
|
149 |
JavaFix(TreePathHandle handle, Map<String, String> options, String sortText) { |
116 |
this.handle = handle; |
150 |
this.handle = handle; |
117 |
this.options = Collections.unmodifiableMap(new HashMap<String, String>(options)); |
151 |
this.options = Collections.unmodifiableMap(new HashMap<String, String>(options)); |
|
|
152 |
this.sortText = sortText; |
118 |
} |
153 |
} |
119 |
|
154 |
|
120 |
/**The display text of the fix. |
155 |
/**The display text of the fix. |
Lines 137-143
Link Here
|
137 |
* method on this {@link JavaFix}. |
172 |
* method on this {@link JavaFix}. |
138 |
*/ |
173 |
*/ |
139 |
public final Fix toEditorFix() { |
174 |
public final Fix toEditorFix() { |
140 |
return new JavaFixImpl(this); |
175 |
return sortText != null ? new EnhancedJavaFixImpl(this) : new JavaFixImpl(this); |
141 |
} |
176 |
} |
142 |
|
177 |
|
143 |
static { |
178 |
static { |
Lines 187-192
Link Here
|
187 |
public List<Fix> resolveDefaultFixes(HintContext ctx, Fix... provided) { |
222 |
public List<Fix> resolveDefaultFixes(HintContext ctx, Fix... provided) { |
188 |
return ErrorDescriptionFactory.resolveDefaultFixes(ctx, provided); |
223 |
return ErrorDescriptionFactory.resolveDefaultFixes(ctx, provided); |
189 |
} |
224 |
} |
|
|
225 |
|
226 |
@Override |
227 |
public String getSortText(JavaFix jf) { |
228 |
return jf.sortText; |
229 |
} |
190 |
}; |
230 |
}; |
191 |
} |
231 |
} |
192 |
|
232 |
|