Skip to content

Commit

Permalink
[NETBEANS-4400] Added support for renaming RECORD name using refactor…
Browse files Browse the repository at this point in the history
…ing (apache#2164)

* [NETBEANS-4400] Added support for renaming RECORD name using refactoring

* [NETBEANS-4400] Addressed code review comments
  • Loading branch information
singh-akhilesh authored Jun 28, 2020
1 parent 709978e commit 8469268
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
import org.netbeans.api.lexer.TokenSequence;

import org.netbeans.api.java.lexer.JavaTokenId;
import org.netbeans.modules.java.source.TreeShims;

import org.netbeans.modules.java.source.builder.ASTService;
import org.netbeans.modules.java.source.query.CommentSet;
Expand Down Expand Up @@ -2869,8 +2870,8 @@ private <N extends Tree> N setLabelImpl(final N node, final CharSequence aLabel)
// todo (#pf): Shouldn't here be check that names are not the same?
// i.e. node label == aLabel? -- every case branch has to check itself
// This will improve performance, no change was done by API user.
Tree.Kind kind = node.getKind();

Tree.Kind kind = TreeShims.isRecord(node) ? Kind.CLASS : node.getKind();
switch (kind) {
case BREAK: {
BreakTree t = (BreakTree) node;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ private static <T extends Throwable> RuntimeException throwAny(Throwable t) thro
public static boolean isRecord(Element el) {
return el != null && "RECORD".equals(el.getKind().name());
}

public static<N extends Tree> boolean isRecord(final N node) {
return node != null && TreeShims.RECORD.equals(node.getKind().name());
}

public static boolean isRecordComponent(Element el) {
return el != null && "RECORD_COMPONENT".equals(el.getKind().name());
Expand Down

0 comments on commit 8469268

Please sign in to comment.