This is an automated email from the ASF dual-hosted git repository.
skygo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git
The following commit(s) were added to refs/heads/master by this push:
new 9eb4cc8 [NETBEANS-3702] : Fixed hint 'implements all abstract method'
for record interfaces
new daea256 Merge pull request #1907 from
singh-akhilesh/fixed-hint-for-record
9eb4cc8 is described below
commit 9eb4cc8799abc8fca5d52f47159e812695367e40
Author: Akhilesh Singh <[email protected]>
AuthorDate: Fri Jan 31 17:45:25 2020 +0530
[NETBEANS-3702] : Fixed hint 'implements all abstract method' for record
interfaces
---
.../java/hints/errors/ImplementAllAbstractMethods.java | 11 +++--------
.../src/org/netbeans/modules/java/source/save/CasualDiff.java | 7 ++++++-
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git
a/java/java.hints/src/org/netbeans/modules/java/hints/errors/ImplementAllAbstractMethods.java
b/java/java.hints/src/org/netbeans/modules/java/hints/errors/ImplementAllAbstractMethods.java
index 1b5404e..7699146 100644
---
a/java/java.hints/src/org/netbeans/modules/java/hints/errors/ImplementAllAbstractMethods.java
+++
b/java/java.hints/src/org/netbeans/modules/java/hints/errors/ImplementAllAbstractMethods.java
@@ -81,7 +81,7 @@ import org.openide.util.NbBundle;
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() {
}
@@ -169,11 +169,6 @@ public final class ImplementAllAbstractMethods implements
ErrorRule<Object>, Ove
}
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;
@@ -185,7 +180,7 @@ public final class ImplementAllAbstractMethods implements
ErrorRule<Object>, Ove
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);
@@ -565,7 +560,7 @@ public final class ImplementAllAbstractMethods implements
ErrorRule<Object>, Ove
// 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;
diff --git
a/java/java.source.base/src/org/netbeans/modules/java/source/save/CasualDiff.java
b/java/java.source.base/src/org/netbeans/modules/java/source/save/CasualDiff.java
index b55ceb6..90b8f0a 100644
---
a/java/java.source.base/src/org/netbeans/modules/java/source/save/CasualDiff.java
+++
b/java/java.source.base/src/org/netbeans/modules/java/source/save/CasualDiff.java
@@ -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;
@@ -3913,7 +3914,11 @@ public class CasualDiff {
// 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));
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists