aboutsummaryrefslogtreecommitdiff
path: root/src/utils/lombok/javac/CommentCatcher.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/lombok/javac/CommentCatcher.java')
-rw-r--r--src/utils/lombok/javac/CommentCatcher.java15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/utils/lombok/javac/CommentCatcher.java b/src/utils/lombok/javac/CommentCatcher.java
index f8b73b0a..90266c26 100644
--- a/src/utils/lombok/javac/CommentCatcher.java
+++ b/src/utils/lombok/javac/CommentCatcher.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011-2014 The Project Lombok Authors.
+ * Copyright (C) 2011-2019 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -35,9 +35,10 @@ import com.sun.tools.javac.util.Context;
public class CommentCatcher {
private final JavaCompiler compiler;
public static final FieldAugment<JCCompilationUnit, List<CommentInfo>> JCCompilationUnit_comments = FieldAugment.augment(JCCompilationUnit.class, List.class, "lombok$comments");
+ public static final FieldAugment<JCCompilationUnit, List<Integer>> JCCompilationUnit_textBlockStarts = FieldAugment.augment(JCCompilationUnit.class, List.class, "lombok$textBlockStarts");
- public static CommentCatcher create(Context context) {
- registerCommentsCollectingScannerFactory(context);
+ public static CommentCatcher create(Context context, boolean findTextBlocks) {
+ registerCommentsCollectingScannerFactory(context, findTextBlocks);
JavaCompiler compiler = new JavaCompiler(context);
setInCompiler(compiler, context);
@@ -69,7 +70,12 @@ public class CommentCatcher {
return list == null ? Collections.<CommentInfo>emptyList() : list;
}
- private static void registerCommentsCollectingScannerFactory(Context context) {
+ public List<Integer> getTextBlockStarts(JCCompilationUnit ast) {
+ List<Integer> list = JCCompilationUnit_textBlockStarts.get(ast);
+ return list == null ? Collections.<Integer>emptyList() : list;
+ }
+
+ private static void registerCommentsCollectingScannerFactory(Context context, boolean findTextBlocks) {
try {
Class<?> scannerFactory;
int javaCompilerVersion = Javac.getJavaCompilerVersion();
@@ -79,6 +85,7 @@ public class CommentCatcher {
scannerFactory = Class.forName("lombok.javac.java7.CommentCollectingScannerFactory");
} else {
scannerFactory = Class.forName("lombok.javac.java8.CommentCollectingScannerFactory");
+ if (findTextBlocks) Permit.getField(scannerFactory, "findTextBlocks").set(null, true);
}
Permit.getMethod(scannerFactory, "preRegister", Context.class).invoke(null, context);
} catch (InvocationTargetException e) {