Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
e7eea15
solves #7043, formatting error of closing brace in record definition
homberghp Dec 30, 2024
3146e87
Merge branch 'apache:master' into master
homberghp Dec 30, 2024
a5f9865
Merge branch 'apache:master' into master
homberghp Dec 30, 2024
d21c95d
improve debug output
homberghp Jan 2, 2025
52129f6
improved formatting of RefactoringTestBase.
homberghp Jan 2, 2025
0f4607e
add full line compare to make it easier on the eyes for visual inspec…
homberghp Jan 6, 2025
1a41df5
Add tests for record refactoring.
homberghp Jan 6, 2025
727001d
improved output of file comparison, added case labels for RECORD.
homberghp Jan 6, 2025
f7ee501
removed useless version test
homberghp Jan 6, 2025
1f56574
Merge branch 'master' of github.com:homberghp/netbeans
homberghp Jan 6, 2025
8df2817
Merge branch 'apache:master' into master
homberghp Jan 6, 2025
4eb02e1
make test less chatty with debug flag.
homberghp Jan 6, 2025
96ca0cf
check for nullness before dereference.
homberghp Jan 6, 2025
7aa7340
Merge branch 'master' of github.com:homberghp/netbeans
homberghp Jan 6, 2025
88b1059
added tests for simple and case with compact constructors
homberghp Jan 7, 2025
d25d1de
Add RECORD and RECORD_COMPONENT as valid case labels
homberghp Jan 7, 2025
1e3328f
mute debug info in test
homberghp Jan 7, 2025
e8fe391
test code cleanup to easy visual inspaction.
homberghp Jan 7, 2025
cb94b08
Add RECORD and RECORD_COMPONENT as valid case labels
homberghp Jan 7, 2025
1b97602
add test to rename inner record.
homberghp Jan 7, 2025
32588dd
add null check before dereferencing element.
homberghp Jan 8, 2025
374d32e
Merge branch 'master' of github.com:homberghp/netbeans
homberghp Jan 9, 2025
9b38f24
Merge branch 'apache:master' into master
homberghp Jan 9, 2025
fa1be9f
Merge branch 'master' of github.com:homberghp/netbeans
homberghp Jan 9, 2025
4d4daa3
Merge branch 'apache:master' into master
homberghp Jan 15, 2025
e28add2
add source levels up to java 17, make reindex optional
homberghp Jan 9, 2025
364d6bb
solves #7044
homberghp Jan 15, 2025
2288644
adde generic inner record in tests.
homberghp Jan 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public Problem doRefactoring(final boolean saveAfterDone) {
private Problem reallyDoRefactoring(boolean saveAfterDone) {
long time = System.currentTimeMillis();

Iterator it = internalList.iterator();
Iterator<RefactoringElementImplementation> it = internalList.iterator();
ArrayList<Transaction> commits = SPIAccessor.DEFAULT.getCommits(bag);
float progressStep = (float)COMMITSTEPS / internalList.size();
float current = 0F;
Expand All @@ -115,7 +115,7 @@ private Problem reallyDoRefactoring(boolean saveAfterDone) {
try {
try {
while (it.hasNext()) {
RefactoringElementImplementation element = (RefactoringElementImplementation) it.next();
RefactoringElementImplementation element = it.next();
if (element.isEnabled() && !((element.getStatus() == RefactoringElement.GUARDED) || (element.getStatus() == RefactoringElement.READ_ONLY))) {
element.performChange();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ private ElementHandle(final ElementKind kind, String... signatures) {
* Resolves an {@link Element} from the {@link ElementHandle}.
* @param compilationInfo representing the {@link javax.tools.JavaCompiler.CompilationTask}
* in which the {@link Element} should be resolved.
* @return resolved subclass of {@link Element} or null if the elment does not exist on
* @return resolved subclass of {@link Element} or null if the element does not exist on
* the classpath/sourcepath of {@link javax.tools.JavaCompiler.CompilationTask}.
*/
@SuppressWarnings ("unchecked") // NOI18N
Expand Down Expand Up @@ -143,19 +143,20 @@ private T resolveImpl (final ModuleElement module, final JavacTaskImpl jt) {
if (log.isLoggable(Level.FINE))
log.log(Level.FINE, "Resolving element kind: {0}", this.kind); // NOI18N
ElementKind simplifiedKind = this.kind;
if (simplifiedKind.name().equals("RECORD")) {
simplifiedKind = ElementKind.CLASS; //TODO: test
}
if (simplifiedKind.name().equals("RECORD_COMPONENT")) {
simplifiedKind = ElementKind.FIELD; //TODO: test
}
// if (simplifiedKind.name().equals("RECORD")) {
// simplifiedKind = ElementKind.CLASS; //TODO: test
// }
// if (simplifiedKind.name().equals("RECORD_COMPONENT")) {
// simplifiedKind = ElementKind.FIELD; //TODO: test
// }
switch (simplifiedKind) {
case PACKAGE:
assert signatures.length == 1;
return (T) jt.getElements().getPackageElement(signatures[0]);
case CLASS:
case INTERFACE:
case ENUM:
case RECORD:
case ANNOTATION_TYPE: {
assert signatures.length == 1;
final Element type = getTypeElementByBinaryName (module, signatures[0], jt);
Expand Down Expand Up @@ -213,6 +214,8 @@ private T resolveImpl (final ModuleElement module, final JavacTaskImpl jt) {
}
case FIELD:
case ENUM_CONSTANT:
case RECORD_COMPONENT:

{
assert signatures.length == 3;
final Element type = getTypeElementByBinaryName (module, signatures[0], jt);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -644,9 +644,12 @@ else if (rootCase instanceof RuntimeException) {
}


/** Runs a task which permits for modifying the sources.
/**
* Runs a task which permits for modifying the sources.
* Call to this method will cancel processing of all the phase completion tasks until
* this task does not finish.<BR>
*
* ??? what does 'until this task does not finish mean'???
* @see Task for information about implementation requirements
* @param task The task which.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,25 +223,25 @@ static void commit (final FileObject fo, final List<Difference> differences, fin
if (source != null && out == null) {
final Document doc = source.getDocument(false);
if (doc != null) {
final IOException[] exceptions = new IOException [1];
LineDocumentUtils.asRequired(doc, AtomicLockDocument.class).runAtomic(new Runnable () {
public void run () {
final IOException[] exceptions = new IOException[1];
LineDocumentUtils.asRequired(doc, AtomicLockDocument.class).runAtomic(new Runnable() {
public void run() {
try {
commit2 (doc, differences, out);
commit2(doc, differences, out);
} catch (IOException ex) {
exceptions [0] = ex;
exceptions[0] = ex;
}
}
});
if (exceptions [0] != null) {
if (exceptions[0] != null) {
LOG.log(Level.INFO, "Cannot commit changes into " + fo, exceptions[0]);
int s = lastCommitted.size();
for (Throwable t : lastCommitted) {
LOG.log(Level.INFO, "Previous commit number " + s--, t);
}
throw exceptions [0];
throw exceptions[0];
}
return;
return;
}
}
Reader in = null;
Expand Down Expand Up @@ -468,11 +468,11 @@ private static void createUnit(Difference diff, Writer out) {
}

public static class Difference {
Kind kind;
Kind kind;
final Position startPos;
final Position endPos;
String oldText;
String newText;
String oldText;
String newText;
final String description;
private boolean excluded;
private boolean ignoreGuards = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1308,7 +1308,7 @@ public Tree BindingPattern(CharSequence name,

/**
* Creates a new Tree for a given VariableTree
* specication : 15.20.2
* specification : 15.20.2
* @param vt the VariableTree of the pattern
* @see com.sun.source.tree.BindingPatternTree
* @return the newly created BindingPatternTree
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ private static boolean isSupported(Element el) {
case ENUM_CONSTANT:
case RECORD:
//TODO: record component
case RECORD_COMPONENT:
return true;
case PARAMETER:
//only method and constructor parameters supported (not lambda):
Expand Down Expand Up @@ -410,7 +411,7 @@ private TreeDelegate(Position position, KindPath kindPath, FileObject file, Elem
case ENUM: kind = Tree.Kind.ENUM; break;
case INTERFACE: kind = Tree.Kind.INTERFACE; break;
case RECORD: kind = Tree.Kind.RECORD; break;
case ENUM_CONSTANT: case FIELD: kind = Tree.Kind.VARIABLE; break;
case ENUM_CONSTANT: case FIELD: case RECORD_COMPONENT: kind = Tree.Kind.VARIABLE; break;
case METHOD: case CONSTRUCTOR: kind = Tree.Kind.METHOD; break;
default: kind = null; break;
}
Expand Down Expand Up @@ -714,6 +715,7 @@ public Kind getKind() {

case ENUM:
case CLASS:
case RECORD:
case ANNOTATION_TYPE:
case INTERFACE:
return Kind.CLASS;
Expand All @@ -724,6 +726,7 @@ public Kind getKind() {
case LOCAL_VARIABLE:
case RESOURCE_VARIABLE:
case EXCEPTION_PARAMETER:
case RECORD_COMPONENT:
return Kind.VARIABLE;

case METHOD:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1221,6 +1221,7 @@ String template(ElementKind kind) {
case INTERFACE: return "Templates/Classes/Interface.java"; // NOI18N
case ANNOTATION_TYPE: return "Templates/Classes/AnnotationType.java"; // NOI18N
case ENUM: return "Templates/Classes/Enum.java"; // NOI18N
case RECORD: return "Templates/Classes/Record.java"; // NOI18N
case PACKAGE: return "Templates/Classes/package-info.java"; // NOI18N
default:
Logger.getLogger(WorkingCopy.class.getName()).log(Level.SEVERE, "Cannot resolve template for {0}", kind);
Expand Down Expand Up @@ -1248,6 +1249,9 @@ FileObject doCreateFromTemplate(CompilationUnitTree cut) throws IOException {
case ENUM:
kind = ElementKind.ENUM;
break;
case RECORD:
kind = ElementKind.RECORD;
break;
default:
Logger.getLogger(WorkingCopy.class.getName()).log(Level.SEVERE, "Cannot resolve template for {0}", cut.getTypeDecls().get(0).getKind());
kind = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ public class SourceLevelUtils {
public static final Source JDK1_9 = Source.lookup("9");
public static final Source JDK14 = Source.lookup("14");
public static final Source JDK15 = Source.lookup("15");
public static final Source JDK16 = Source.lookup("16");
public static final Source JDK17 = Source.lookup("17");
// for next release:
// public static final Source JDK18 = Source.lookup("18");
// public static final Source JDK19 = Source.lookup("19");
// public static final Source JDK20 = Source.lookup("20");
// public static final Source JDK21 = Source.lookup("21");

public static boolean allowDefaultMethods(Source in) {
return in.compareTo(JDK1_8) >= 0;
Expand Down
Loading