From 58c84f695db2ddbc3e9bc43588ca62eb0d316c2a Mon Sep 17 00:00:00 2001 From: Snjezana Peco Date: Sun, 22 Dec 2024 01:33:26 +0100 Subject: [PATCH] Fix ASTConverter15JLS4Test.test0008 Signed-off-by: Snjezana Peco --- .../eclipse/jdt/core/dom/JavacConverter.java | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/core/dom/JavacConverter.java b/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/core/dom/JavacConverter.java index 9923a0f9fc6..d8f9bd5740a 100644 --- a/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/core/dom/JavacConverter.java +++ b/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/core/dom/JavacConverter.java @@ -386,7 +386,7 @@ private ImportDeclaration convert(JCImport javac) { ImportDeclaration res = this.ast.newImportDeclaration(); commonSettings(res, javac); if (javac.isStatic()) { - if( this.ast.apiLevel != AST.JLS2_INTERNAL) { + if (this.ast.apiLevel != AST.JLS2_INTERNAL) { res.setStatic(true); } } @@ -397,6 +397,30 @@ private ImportDeclaration convert(JCImport javac) { } else { res.setName(toName(select)); } + if (javac.isStatic() || javac.isModule()) { + if (this.ast.apiLevel == AST.JLS2_INTERNAL) { + res.setFlags(res.getFlags() | ASTNode.MALFORMED); + } else if (this.ast.apiLevel < AST.JLS23_INTERNAL) { + if (!javac.isStatic()) { + res.setFlags(res.getFlags() | ASTNode.MALFORMED); + } + } else { + ModifierKeyword keyword = null; + if (javac.isStatic()) { + keyword = ModifierKeyword.STATIC_KEYWORD; + } + if (javac.isModule()) { + keyword = ModifierKeyword.MODULE_KEYWORD; + } + if (keyword != null) { + Modifier newModifier = this.ast.newModifier(keyword); + newModifier.setSourceRange(javac.getStartPosition(), keyword.toString().length()); + res.modifiers().add(newModifier); + } else { + res.setFlags(res.getFlags() | ASTNode.MALFORMED); + } + } + } return res; }