Skip to content

Commit

Permalink
Improve JEP 378 text block support
Browse files Browse the repository at this point in the history
MyBatipse now requires Eclipse 2020-06 or later.
  • Loading branch information
harawata committed Oct 29, 2022
1 parent 5265076 commit fc34ee5
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion mybatipse/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.ui,
org.eclipse.ui.ide,
org.eclipse.core.resources,
org.eclipse.jdt.core;bundle-version="3.10.0",
org.eclipse.jdt.core;bundle-version="3.24.0",
org.eclipse.jdt.ui,
org.eclipse.ui.workbench.texteditor,
org.eclipse.wst.validation,
Expand Down
3 changes: 3 additions & 0 deletions mybatipse/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,9 @@
<partition
type="__java_string">
</partition>
<partition
type="__java_multiline_string">
</partition>
</javaCompletionProposalComputer>
</extension>
<extension
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ protected static void parseSource(IJavaProject project, final IType type,
{
ICompilationUnit compilationUnit = (ICompilationUnit)type
.getAncestor(IJavaElement.COMPILATION_UNIT);
ASTParser parser = ASTParser.newParser(AST.JLS8);
ASTParser parser = ASTParser.newParser(AST.JLS15);
parser.setKind(ASTParser.K_COMPILATION_UNIT);
parser.setSource(compilationUnit);
parser.setResolveBindings(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ private static void parseSourceMapper(final IJavaProject project, final IType ma
{
ICompilationUnit compilationUnit = (ICompilationUnit)mapperType
.getAncestor(IJavaElement.COMPILATION_UNIT);
ASTParser parser = ASTParser.newParser(AST.JLS8);
ASTParser parser = ASTParser.newParser(AST.JLS15);
parser.setKind(ASTParser.K_COMPILATION_UNIT);
parser.setSource(compilationUnit);
parser.setResolveBindings(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region,
else if (srcElements.length == 0)
{
// Annotation value?
final ASTParser parser = ASTParser.newParser(AST.JLS8);
final ASTParser parser = ASTParser.newParser(AST.JLS15);
parser.setKind(ASTParser.K_COMPILATION_UNIT);
parser.setSource(typeRoot);
parser.setResolveBindings(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ private static void findMapperMethodSource(MapperMethodStore methodStore,
{
ICompilationUnit compilationUnit = (ICompilationUnit)mapperType
.getAncestor(IJavaElement.COMPILATION_UNIT);
ASTParser parser = ASTParser.newParser(AST.JLS8);
ASTParser parser = ASTParser.newParser(AST.JLS15);
parser.setKind(ASTParser.K_COMPILATION_UNIT);
parser.setSource(compilationUnit);
parser.setResolveBindings(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ private void scanJavaConfig(IJavaProject project, final TypeAliasMap aliasMap,

for (ITypeRoot typeRoot : typeRoots)
{
ASTParser parser = ASTParser.newParser(AST.JLS8);
ASTParser parser = ASTParser.newParser(AST.JLS15);
parser.setSource(typeRoot);
parser.setResolveBindings(true);
CompilationUnit astUnit = (CompilationUnit)parser.createAST(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import org.eclipse.jdt.core.dom.SimpleName;
import org.eclipse.jdt.core.dom.SingleMemberAnnotation;
import org.eclipse.jdt.core.dom.StringLiteral;
import org.eclipse.jdt.core.dom.TextBlock;
import org.eclipse.jdt.core.dom.Type;
import org.eclipse.jdt.core.dom.TypeDeclaration;
import org.eclipse.jdt.core.dom.TypeLiteral;
Expand Down Expand Up @@ -165,7 +166,7 @@ public void apply(IDocument document)

private CompilationUnit getAstNode(ICompilationUnit compilationUnit)
{
ASTParser parser = ASTParser.newParser(AST.JLS8);
ASTParser parser = ASTParser.newParser(AST.JLS15);
parser.setSource(compilationUnit);
parser.setKind(ASTParser.K_COMPILATION_UNIT);
parser.setResolveBindings(true);
Expand Down Expand Up @@ -383,6 +384,10 @@ private String parseStringValue(Expression value, String separator)
{
return ((StringLiteral)value).getLiteralValue();
}
else if (valueType == ASTNode.TEXT_BLOCK)
{
return ((TextBlock)value).getLiteralValue();
}
else if (valueType == ASTNode.ARRAY_INITIALIZER)
{
StringBuilder buffer = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ private void editJavaSource(RefactoringStatus result) throws JavaModelException
if (compilationUnit == null)
return;

final ASTParser parser = ASTParser.newParser(AST.JLS8);
final ASTParser parser = ASTParser.newParser(AST.JLS15);
parser.setKind(ASTParser.K_COMPILATION_UNIT);
parser.setSource(compilationUnit);
parser.setResolveBindings(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public Object execute(ExecutionEvent event) throws ExecutionException
final ITextEditor textEditor = editor.getAdapter(ITextEditor.class);
final int offset = ((ITextSelection)textEditor.getSelectionProvider().getSelection())
.getOffset();
final ASTParser parser = ASTParser.newParser(AST.JLS8);
final ASTParser parser = ASTParser.newParser(AST.JLS15);
parser.setKind(ASTParser.K_COMPILATION_UNIT);
parser.setSource(compilationUnit);
parser.setResolveBindings(true);
Expand Down

0 comments on commit fc34ee5

Please sign in to comment.