Lines 190-201
Link Here
|
190 |
if (cancel.get() || found) { |
190 |
if (cancel.get() || found) { |
191 |
return null; |
191 |
return null; |
192 |
} |
192 |
} |
193 |
|
193 |
|
194 |
List<Fix> fix = Collections.<Fix>singletonList(new FixImpl(info.getJavaSource(), TreePathHandle.create(treePath, info), isFinalFields(getPreferences(null)), existing)); |
194 |
if (treePath.getLeaf().getKind() == Kind.VARIABLE) { |
195 |
String displayName = NbBundle.getMessage(FieldForUnusedParam.class, "ERR_UnusedParameter"); |
195 |
final VariableTree vt = (VariableTree) treePath.getLeaf(); |
196 |
ErrorDescription err = ErrorDescriptionFactory.createErrorDescription(Severity.HINT, displayName,fix, info.getFileObject(), offset, offset); |
196 |
final String name = vt.getName().toString(); |
197 |
|
197 |
|
198 |
return Collections.singletonList(err); |
198 |
List<Fix> fix = Collections.<Fix>singletonList(new FixImpl(info.getJavaSource(), TreePathHandle.create(treePath, info), isFinalFields(getPreferences(null)), existing, name)); |
|
|
199 |
String displayName = NbBundle.getMessage(FieldForUnusedParam.class, "ERR_UnusedParameter", name); |
200 |
ErrorDescription err = ErrorDescriptionFactory.createErrorDescription(Severity.HINT, displayName, fix, info.getFileObject(), offset, offset); |
201 |
|
202 |
return Collections.singletonList(err); |
203 |
} |
204 |
else{ |
205 |
return null; |
206 |
} |
199 |
} |
207 |
} |
200 |
|
208 |
|
201 |
public String getId() { |
209 |
public String getId() { |
Lines 225-241
Link Here
|
225 |
private final JavaSource js; |
233 |
private final JavaSource js; |
226 |
private final TreePathHandle tph; |
234 |
private final TreePathHandle tph; |
227 |
private final boolean finalFields; |
235 |
private final boolean finalFields; |
|
|
236 |
private final String fieldName; |
228 |
final boolean existing; |
237 |
final boolean existing; |
229 |
|
238 |
|
230 |
public FixImpl(JavaSource js, TreePathHandle tph, boolean finalFields, boolean existing) { |
239 |
public FixImpl(JavaSource js, TreePathHandle tph, boolean finalFields, boolean existing, String fieldName) { |
231 |
this.js = js; |
240 |
this.js = js; |
232 |
this.tph = tph; |
241 |
this.tph = tph; |
233 |
this.finalFields = finalFields; |
242 |
this.finalFields = finalFields; |
234 |
this.existing = existing; |
243 |
this.existing = existing; |
|
|
244 |
this.fieldName = fieldName; |
235 |
} |
245 |
} |
236 |
|
246 |
|
237 |
public String getText() { |
247 |
public String getText() { |
238 |
return existing ? NbBundle.getMessage(FieldForUnusedParam.class, "FIX_AssignToExisting") : NbBundle.getMessage(FieldForUnusedParam.class, "FIX_CreateField"); |
248 |
return existing ? NbBundle.getMessage(FieldForUnusedParam.class, "FIX_AssignToExisting", fieldName) : NbBundle.getMessage(FieldForUnusedParam.class, "FIX_CreateField", fieldName); |
239 |
} |
249 |
} |
240 |
|
250 |
|
241 |
public ChangeInfo implement() throws Exception { |
251 |
public ChangeInfo implement() throws Exception { |