Skip to content

Commit

Permalink
[NETBEANS-3702] : Fixed hint 'implements all abstract method' for rec…
Browse files Browse the repository at this point in the history
…ord interfaces
  • Loading branch information
singh-akhilesh committed Feb 3, 2020
1 parent dcb9ac3 commit 9eb4cc8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
public final class ImplementAllAbstractMethods implements ErrorRule<Object>, OverrideErrorMessage<Object> {

private static final String PREMATURE_EOF_CODE = "compiler.err.premature.eof"; // NOI18N

private static final String RECORD = "RECORD"; // NOI18N
/** Creates a new instance of ImplementAllAbstractMethodsCreator */
public ImplementAllAbstractMethods() {
}
Expand Down Expand Up @@ -169,11 +169,6 @@ public List<Fix> run(final CompilationInfo info, String diagnosticKey, final int
}
Element e = info.getTrees().getElement(path);
final Tree leaf = path.getLeaf();
//TODO: Fix defect #NETBEANS-3702
//Disabling hints for record
if(leaf.getKind().toString().equals(TreeShims.RECORD)){
return null;
}
boolean isUsableElement = e != null && (e.getKind().isClass() || e.getKind().isInterface());
boolean containsDefaultMethod = saved == Boolean.FALSE;

Expand All @@ -185,7 +180,7 @@ public List<Fix> run(final CompilationInfo info, String diagnosticKey, final int
return null;
}
List<Fix> fixes = new ArrayList<>();
if (TreeUtilities.CLASS_TREE_KINDS.contains(leaf.getKind())) {
if (TreeUtilities.CLASS_TREE_KINDS.contains(leaf.getKind()) || leaf.getKind().toString().equals(RECORD)) {
CompilationUnitTree cut = info.getCompilationUnit();
// do not offer for class declarations without body
long start = info.getTrees().getSourcePositions().getStartPosition(cut, leaf);
Expand Down Expand Up @@ -565,7 +560,7 @@ public String toDebugString() {
// copy from GeneratorUtils, need to change the processing a little.
public static Map<? extends ExecutableElement, ? extends ExecutableElement> generateAllAbstractMethodImplementations(
WorkingCopy wc, TreePath path, List<ElementHandle<? extends Element>> toImplementHandles) {
assert TreeUtilities.CLASS_TREE_KINDS.contains(path.getLeaf().getKind());
assert TreeUtilities.CLASS_TREE_KINDS.contains(path.getLeaf().getKind()) || path.getLeaf().getKind().toString().equals(RECORD);
TypeElement te = (TypeElement)wc.getTrees().getElement(path);
if (te == null) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ public class CasualDiff {
private final Context context;
private final Names names;
private static final Logger LOG = Logger.getLogger(CasualDiff.class.getName());
public static final int GENERATED_MEMBER = 1<<24;

private Map<Integer, String> diffInfo = new HashMap<>();
private final Map<Tree, ?> tree2Tag;
Expand Down Expand Up @@ -3913,7 +3914,11 @@ else if (Kind.VARIABLE == tree.getKind()) {
// collect enum constants, make a field group from them
// and set the flag.
enumConstants.add(var);
} else {
} // filter syntetic member variable, i.e. variable which are in
// the tree, but not available in the source.
else if ((var.mods.flags & GENERATED_MEMBER) != 0)
continue;
else {
if (!fieldGroup.isEmpty()) {
int oldPos = getOldPos(fieldGroup.get(0));

Expand Down

0 comments on commit 9eb4cc8

Please sign in to comment.