Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

solves #7044, refactor inner to outer for record #8197

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
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 @@ -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,14 @@ 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
}
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 +208,8 @@ private T resolveImpl (final ModuleElement module, final JavacTaskImpl jt) {
}
case FIELD:
case ENUM_CONSTANT:
case RECORD_COMPONENT:

homberghp marked this conversation as resolved.
Show resolved Hide resolved
{
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 @@ -322,6 +322,7 @@ private static boolean isSupported(Element el) {
case ENUM_CONSTANT:
case RECORD:
//TODO: record component
case RECORD_COMPONENT:
homberghp marked this conversation as resolved.
Show resolved Hide resolved
return true;
case PARAMETER:
//only method and constructor parameters supported (not lambda):
Expand Down Expand Up @@ -869,4 +870,4 @@ public Void scan(Tree node, Void p) {
return result;
}

}
}
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");
homberghp marked this conversation as resolved.
Show resolved Hide resolved

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