From 132d603dd4e43f50555ef33bac290b1080dfc5fa Mon Sep 17 00:00:00 2001 From: Roel Spilker Date: Tue, 13 Aug 2013 00:24:51 +0200 Subject: Getting the java8 compiler remember the comments --- .../javac/java8/CommentCollectingParser.java | 32 ++++++ .../java8/CommentCollectingParserFactory.java | 52 ++++++++++ .../javac/java8/CommentCollectingScanner.java | 21 ++++ .../java8/CommentCollectingScannerFactory.java | 89 +++++++++++++++++ .../javac/java8/CommentCollectingTokenizer.java | 108 +++++++++++++++++++++ 5 files changed, 302 insertions(+) create mode 100644 src/utils/lombok/javac/java8/CommentCollectingParser.java create mode 100644 src/utils/lombok/javac/java8/CommentCollectingParserFactory.java create mode 100644 src/utils/lombok/javac/java8/CommentCollectingScanner.java create mode 100644 src/utils/lombok/javac/java8/CommentCollectingScannerFactory.java create mode 100644 src/utils/lombok/javac/java8/CommentCollectingTokenizer.java (limited to 'src/utils/lombok/javac/java8') diff --git a/src/utils/lombok/javac/java8/CommentCollectingParser.java b/src/utils/lombok/javac/java8/CommentCollectingParser.java new file mode 100644 index 00000000..6cf65dca --- /dev/null +++ b/src/utils/lombok/javac/java8/CommentCollectingParser.java @@ -0,0 +1,32 @@ +package lombok.javac.java8; + +import java.util.List; +import java.util.Map; + +import lombok.javac.CommentInfo; + +import com.sun.tools.javac.parser.JavacParser; +import com.sun.tools.javac.parser.Lexer; +import com.sun.tools.javac.parser.ParserFactory; +import com.sun.tools.javac.tree.JCTree.JCCompilationUnit; + +class CommentCollectingParser extends JavacParser { + private final Map> commentsMap; + private final Lexer lexer; + + protected CommentCollectingParser(ParserFactory fac, Lexer S, + boolean keepDocComments, boolean keepLineMap, boolean keepEndPositions, Map> commentsMap) { + super(fac, S, keepDocComments, keepLineMap, keepEndPositions); + lexer = S; + this.commentsMap = commentsMap; + } + + public JCCompilationUnit parseCompilationUnit() { + JCCompilationUnit result = super.parseCompilationUnit(); + if (lexer instanceof CommentCollectingScanner) { + List comments = ((CommentCollectingScanner)lexer).getComments(); + commentsMap.put(result, comments); + } + return result; + } +} \ No newline at end of file diff --git a/src/utils/lombok/javac/java8/CommentCollectingParserFactory.java b/src/utils/lombok/javac/java8/CommentCollectingParserFactory.java new file mode 100644 index 00000000..594ff8ba --- /dev/null +++ b/src/utils/lombok/javac/java8/CommentCollectingParserFactory.java @@ -0,0 +1,52 @@ +package lombok.javac.java8; + +import java.lang.reflect.Field; +import java.util.List; +import java.util.Map; + +import lombok.javac.CommentInfo; + +import com.sun.tools.javac.main.JavaCompiler; +import com.sun.tools.javac.parser.JavacParser; +import com.sun.tools.javac.parser.Lexer; +import com.sun.tools.javac.parser.ParserFactory; +import com.sun.tools.javac.parser.ScannerFactory; +import com.sun.tools.javac.tree.JCTree.JCCompilationUnit; +import com.sun.tools.javac.util.Context; + +public class CommentCollectingParserFactory extends ParserFactory { + private final Map> commentsMap; + private final Context context; + + static Context.Key key() { + return parserFactoryKey; + } + + protected CommentCollectingParserFactory(Context context, Map> commentsMap) { + super(context); + this.context = context; + this.commentsMap = commentsMap; + } + + public JavacParser newParser(CharSequence input, boolean keepDocComments, boolean keepEndPos, boolean keepLineMap) { + ScannerFactory scannerFactory = ScannerFactory.instance(context); + Lexer lexer = scannerFactory.newScanner(input, true); + Object x = new CommentCollectingParser(this, lexer, true, keepLineMap, keepEndPos, commentsMap); + return (JavacParser) x; + // CCP is based on a stub which extends nothing, but at runtime the stub is replaced with either + //javac6's EndPosParser which extends Parser, or javac8's JavacParser which implements Parser. + //Either way this will work out. + } + + public static void setInCompiler(JavaCompiler compiler, Context context, Map> commentsMap) { + context.put(CommentCollectingParserFactory.key(), (ParserFactory)null); + Field field; + try { + field = JavaCompiler.class.getDeclaredField("parserFactory"); + field.setAccessible(true); + field.set(compiler, new CommentCollectingParserFactory(context, commentsMap)); + } catch (Exception e) { + throw new IllegalStateException("Could not set comment sensitive parser in the compiler", e); + } + } +} \ No newline at end of file diff --git a/src/utils/lombok/javac/java8/CommentCollectingScanner.java b/src/utils/lombok/javac/java8/CommentCollectingScanner.java new file mode 100644 index 00000000..1b8474ac --- /dev/null +++ b/src/utils/lombok/javac/java8/CommentCollectingScanner.java @@ -0,0 +1,21 @@ +package lombok.javac.java8; + +import lombok.javac.CommentInfo; + +import com.sun.tools.javac.parser.Scanner; +import com.sun.tools.javac.parser.ScannerFactory; +import com.sun.tools.javac.util.List; + +public class CommentCollectingScanner extends Scanner { + + private CommentCollectingTokenizer tokenizer; + + public CommentCollectingScanner(ScannerFactory fac, CommentCollectingTokenizer tokenizer) { + super(fac, tokenizer); + this.tokenizer = tokenizer; + } + + public List getComments() { + return tokenizer.getComments(); + } +} \ No newline at end of file diff --git a/src/utils/lombok/javac/java8/CommentCollectingScannerFactory.java b/src/utils/lombok/javac/java8/CommentCollectingScannerFactory.java new file mode 100644 index 00000000..fa79ff67 --- /dev/null +++ b/src/utils/lombok/javac/java8/CommentCollectingScannerFactory.java @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2011-2013 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 + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package lombok.javac.java8; + +import java.nio.CharBuffer; + +import com.sun.tools.javac.parser.Scanner; +import com.sun.tools.javac.parser.ScannerFactory; +import com.sun.tools.javac.util.Context; + +public class CommentCollectingScannerFactory extends ScannerFactory { + + @SuppressWarnings("all") + public static void preRegister(final Context context) { + if (context.get(scannerFactoryKey) == null) { + // Careful! There is voodoo magic here! + // + // Context.Factory is parameterized. make() is for javac6 and below; make(Context) is for javac7 and up. + // this anonymous inner class definition is intentionally 'raw' - the return type of both 'make' methods is 'T', + // which means the compiler will only generate the correct "real" override method (with returntype Object, which is + // the lower bound for T, as a synthetic accessor for the make with returntype ScannerFactory) for that make method which + // is actually on the classpath (either make() for javac6-, or make(Context) for javac7+). + // + // We normally solve this issue via src/stubs, with BOTH make methods listed, but for some reason the presence of a stubbed out + // Context (or even a complete copy, it doesn't matter) results in a really strange eclipse bug, where any mention of any kind + // of com.sun.tools.javac.tree.TreeMaker in a source file disables ALL usage of 'go to declaration' and auto-complete in the entire + // source file. + // + // Thus, in short: + // * Do NOT parameterize the anonymous inner class literal. + // * Leave the return types as 'j.l.Object'. + // * Leave both make methods intact; deleting one has no effect on javac6- / javac7+, but breaks the other. Hard to test for. + // * Do not stub com.sun.tools.javac.util.Context or any of its inner types, like Factory. + @SuppressWarnings("all") + class MyFactory implements Context.Factory { + // This overrides the javac6- version of make. + public Object make() { + return new CommentCollectingScannerFactory(context); + } + + // This overrides the javac7+ version. + public Object make(Context c) { + return new CommentCollectingScannerFactory(c); + } + } + @SuppressWarnings("unchecked") Context.Factory factory = new MyFactory(); + context.put(scannerFactoryKey, factory); + } + } + + /** Create a new scanner factory. */ + protected CommentCollectingScannerFactory(Context context) { + super(context); + } + + @Override + public Scanner newScanner(CharSequence input, boolean keepDocComments) { + if (input instanceof CharBuffer) { + CharBuffer buf = (CharBuffer) input; + return new CommentCollectingScanner(this, new CommentCollectingTokenizer(this, buf)); + } + char[] array = input.toString().toCharArray(); + return newScanner(array, array.length, keepDocComments); + } + + @Override + public Scanner newScanner(char[] input, int inputLength, boolean keepDocComments) { + return new CommentCollectingScanner(this, new CommentCollectingTokenizer(this, input, inputLength)); + } +} diff --git a/src/utils/lombok/javac/java8/CommentCollectingTokenizer.java b/src/utils/lombok/javac/java8/CommentCollectingTokenizer.java new file mode 100644 index 00000000..95945f8f --- /dev/null +++ b/src/utils/lombok/javac/java8/CommentCollectingTokenizer.java @@ -0,0 +1,108 @@ +package lombok.javac.java8; + +import java.nio.CharBuffer; + +import lombok.javac.CommentInfo; +import lombok.javac.CommentInfo.EndConnection; +import lombok.javac.CommentInfo.StartConnection; + +import com.sun.tools.javac.parser.JavaTokenizer; +import com.sun.tools.javac.parser.ScannerFactory; +import com.sun.tools.javac.parser.Tokens.Comment; +import com.sun.tools.javac.parser.Tokens.Token; +import com.sun.tools.javac.parser.Tokens.Comment.CommentStyle; +import com.sun.tools.javac.parser.UnicodeReader; +import com.sun.tools.javac.util.List; +import com.sun.tools.javac.util.ListBuffer; + +class CommentCollectingTokenizer extends JavaTokenizer { + private int prevEndPosition = 0; + private final ListBuffer comments = ListBuffer.lb(); + private int endComment = 0; + + CommentCollectingTokenizer(ScannerFactory fac, char[] buf, int inputLength) { + super(fac, new PositionUnicodeReader(fac, buf, inputLength)); + } + + CommentCollectingTokenizer(ScannerFactory fac, CharBuffer buf) { + super(fac, new PositionUnicodeReader(fac, buf)); + } + + @Override public Token readToken() { + Token token = super.readToken(); + prevEndPosition = ((PositionUnicodeReader)reader).pos(); + return token; + } + + @Override + protected Comment processComment(int pos, int endPos, CommentStyle style) { + int prevEndPos = Math.max(prevEndPosition, endComment); + endComment = endPos; + String content = new String(reader.getRawCharacters(pos, endPos)); + StartConnection start = determineStartConnection(prevEndPos, pos); + EndConnection end = determineEndConnection(endPos); + + CommentInfo comment = new CommentInfo(prevEndPos, pos, endPos, content, start, end); + comments.append(comment); + + return super.processComment(pos, endPos, style); + } + + private EndConnection determineEndConnection(int pos) { + boolean first = true; + for (int i = pos;; i++) { + char c; + try { + c = reader.getRawCharacters(i, i + 1)[0]; + } catch (IndexOutOfBoundsException e) { + c = '\n'; + } + if (isNewLine(c)) { + return EndConnection.ON_NEXT_LINE; + } + if (Character.isWhitespace(c)) { + first = false; + continue; + } + return first ? EndConnection.DIRECT_AFTER_COMMENT : EndConnection.AFTER_COMMENT; + } + } + + private StartConnection determineStartConnection(int from, int to) { + if (from == to) { + return StartConnection.DIRECT_AFTER_PREVIOUS; + } + char[] between = reader.getRawCharacters(from, to); + if (isNewLine(between[between.length - 1])) { + return StartConnection.START_OF_LINE; + } + for (char c : between) { + if (isNewLine(c)) { + return StartConnection.ON_NEXT_LINE; + } + } + return StartConnection.AFTER_PREVIOUS; + } + + private boolean isNewLine(char c) { + return c == '\n' || c == '\r'; + } + + public List getComments() { + return comments.toList(); + } + + static class PositionUnicodeReader extends UnicodeReader { + protected PositionUnicodeReader(ScannerFactory sf, char[] input, int inputLength) { + super(sf, input, inputLength); + } + + public PositionUnicodeReader(ScannerFactory sf, CharBuffer buffer) { + super(sf, buffer); + } + + int pos() { + return bp; + } + } +} \ No newline at end of file -- cgit From 7fc6e70b36c978ef230e3df41db151f3c0da3da1 Mon Sep 17 00:00:00 2001 From: Roel Spilker Date: Wed, 25 Sep 2013 21:38:37 +0200 Subject: Pre-emptive fix for the anticipated removal of ListBuffer.lb() in javac8 --- src/core/lombok/javac/JavacAST.java | 2 +- src/core/lombok/javac/JavacResolution.java | 2 +- src/core/lombok/javac/handlers/HandleBuilder.java | 8 ++++---- src/core/lombok/javac/handlers/HandleCleanup.java | 4 ++-- .../lombok/javac/handlers/HandleConstructor.java | 22 ++++++++++---------- .../javac/handlers/HandleEqualsAndHashCode.java | 10 ++++----- src/core/lombok/javac/handlers/HandleGetter.java | 8 ++++---- src/core/lombok/javac/handlers/HandleSetter.java | 2 +- src/core/lombok/javac/handlers/HandleToString.java | 2 +- src/core/lombok/javac/handlers/HandleWither.java | 4 ++-- .../lombok/javac/handlers/JavacHandlerUtil.java | 24 +++++++++++----------- .../javac/java6/CommentCollectingScanner.java | 3 ++- .../javac/java7/CommentCollectingScanner.java | 3 ++- .../javac/java8/CommentCollectingTokenizer.java | 3 ++- 14 files changed, 50 insertions(+), 47 deletions(-) (limited to 'src/utils/lombok/javac/java8') diff --git a/src/core/lombok/javac/JavacAST.java b/src/core/lombok/javac/JavacAST.java index d565b0ef..2422b553 100644 --- a/src/core/lombok/javac/JavacAST.java +++ b/src/core/lombok/javac/JavacAST.java @@ -409,7 +409,7 @@ public class JavacAST extends AST { // Possibly integrate these 2 code paths. if (JAVAC7_DEFERRED_DIAGNOSTICS != null) { ListBuffer deferredDiagnostics = (ListBuffer) JAVAC7_DEFERRED_DIAGNOSTICS.get(log); - ListBuffer newDeferredDiagnostics = ListBuffer.lb(); + ListBuffer newDeferredDiagnostics = new ListBuffer(); for (Object diag : deferredDiagnostics) { if (!(diag instanceof JCDiagnostic)) { newDeferredDiagnostics.add(diag); diff --git a/src/core/lombok/javac/JavacResolution.java b/src/core/lombok/javac/JavacResolution.java index acd4b3bd..acfca6a6 100644 --- a/src/core/lombok/javac/JavacResolution.java +++ b/src/core/lombok/javac/JavacResolution.java @@ -534,7 +534,7 @@ public class JavacResolution { private static JCExpression genericsToJCTreeNodes(List generics, JavacAST ast, JCExpression rawTypeNode) throws TypeNotConvertibleException { if (generics != null && !generics.isEmpty()) { - ListBuffer args = ListBuffer.lb(); + ListBuffer args = new ListBuffer(); for (Type t : generics) args.append(typeToJCTree(t, ast, true, false)); return ast.getTreeMaker().TypeApply(rawTypeNode, args.toList()); } diff --git a/src/core/lombok/javac/handlers/HandleBuilder.java b/src/core/lombok/javac/handlers/HandleBuilder.java index d7ea2806..8a826087 100644 --- a/src/core/lombok/javac/handlers/HandleBuilder.java +++ b/src/core/lombok/javac/handlers/HandleBuilder.java @@ -98,7 +98,7 @@ public class HandleBuilder extends JavacAnnotationHandler { if (parent.get() instanceof JCClassDecl) { tdParent = parent; JCClassDecl td = (JCClassDecl) tdParent.get(); - ListBuffer allFields = ListBuffer.lb(); + ListBuffer allFields = new ListBuffer(); @SuppressWarnings("deprecation") boolean valuePresent = (hasAnnotation(lombok.Value.class, parent) || hasAnnotation(lombok.experimental.Value.class, parent)); for (JavacNode fieldNode : HandleConstructor.findAllFields(tdParent)) { @@ -224,7 +224,7 @@ public class HandleBuilder extends JavacAnnotationHandler { JCExpression call; JCStatement statement; - ListBuffer args = ListBuffer.lb(); + ListBuffer args = new ListBuffer(); for (Name n : fieldNames) { args.append(maker.Ident(n)); } @@ -233,7 +233,7 @@ public class HandleBuilder extends JavacAnnotationHandler { call = maker.NewClass(null, List.nil(), returnType, args.toList(), null); statement = maker.Return(call); } else { - ListBuffer typeParams = ListBuffer.lb(); + ListBuffer typeParams = new ListBuffer(); for (JCTypeParameter tp : ((JCClassDecl) type.get()).typarams) { typeParams.append(maker.Ident(tp.name)); } @@ -255,7 +255,7 @@ public class HandleBuilder extends JavacAnnotationHandler { private JCMethodDecl generateBuilderMethod(String builderMethodName, String builderClassName, JavacNode type, List typeParams) { JavacTreeMaker maker = type.getTreeMaker(); - ListBuffer typeArgs = ListBuffer.lb(); + ListBuffer typeArgs = new ListBuffer(); for (JCTypeParameter typeParam : typeParams) { typeArgs.append(maker.Ident(typeParam.name)); } diff --git a/src/core/lombok/javac/handlers/HandleCleanup.java b/src/core/lombok/javac/handlers/HandleCleanup.java index 417d2815..e7786ffe 100644 --- a/src/core/lombok/javac/handlers/HandleCleanup.java +++ b/src/core/lombok/javac/handlers/HandleCleanup.java @@ -96,8 +96,8 @@ public class HandleCleanup extends JavacAnnotationHandler { } boolean seenDeclaration = false; - ListBuffer newStatements = ListBuffer.lb(); - ListBuffer tryBlock = ListBuffer.lb(); + ListBuffer newStatements = new ListBuffer(); + ListBuffer tryBlock = new ListBuffer(); for (JCStatement statement : statements) { if (!seenDeclaration) { if (statement == decl) seenDeclaration = true; diff --git a/src/core/lombok/javac/handlers/HandleConstructor.java b/src/core/lombok/javac/handlers/HandleConstructor.java index 5156d709..b77a5367 100644 --- a/src/core/lombok/javac/handlers/HandleConstructor.java +++ b/src/core/lombok/javac/handlers/HandleConstructor.java @@ -91,7 +91,7 @@ public class HandleConstructor { } private static List findRequiredFields(JavacNode typeNode) { - ListBuffer fields = ListBuffer.lb(); + ListBuffer fields = new ListBuffer(); for (JavacNode child : typeNode.down()) { if (child.getKind() != Kind.FIELD) continue; JCVariableDecl fieldDecl = (JCVariableDecl) child.get(); @@ -126,7 +126,7 @@ public class HandleConstructor { } static List findAllFields(JavacNode typeNode) { - ListBuffer fields = ListBuffer.lb(); + ListBuffer fields = new ListBuffer(); for (JavacNode child : typeNode.down()) { if (child.getKind() != Kind.FIELD) continue; JCVariableDecl fieldDecl = (JCVariableDecl) child.get(); @@ -209,7 +209,7 @@ public class HandleConstructor { if (fields.isEmpty()) return; JavacTreeMaker maker = node.getTreeMaker(); JCExpression constructorPropertiesType = chainDots(node, "java", "beans", "ConstructorProperties"); - ListBuffer fieldNames = ListBuffer.lb(); + ListBuffer fieldNames = new ListBuffer(); for (JavacNode field : fields) { Name fieldName = removePrefixFromField(field); fieldNames.append(maker.Literal(fieldName.toString())); @@ -225,9 +225,9 @@ public class HandleConstructor { boolean isEnum = (((JCClassDecl) typeNode.get()).mods.flags & Flags.ENUM) != 0; if (isEnum) level = AccessLevel.PRIVATE; - ListBuffer nullChecks = ListBuffer.lb(); - ListBuffer assigns = ListBuffer.lb(); - ListBuffer params = ListBuffer.lb(); + ListBuffer nullChecks = new ListBuffer(); + ListBuffer assigns = new ListBuffer(); + ListBuffer params = new ListBuffer(); for (JavacNode fieldNode : fields) { JCVariableDecl field = (JCVariableDecl) fieldNode.get(); @@ -272,11 +272,11 @@ public class HandleConstructor { JCExpression returnType, constructorType; - ListBuffer typeParams = ListBuffer.lb(); - ListBuffer params = ListBuffer.lb(); - ListBuffer typeArgs1 = ListBuffer.lb(); - ListBuffer typeArgs2 = ListBuffer.lb(); - ListBuffer args = ListBuffer.lb(); + ListBuffer typeParams = new ListBuffer(); + ListBuffer params = new ListBuffer(); + ListBuffer typeArgs1 = new ListBuffer(); + ListBuffer typeArgs2 = new ListBuffer(); + ListBuffer args = new ListBuffer(); if (!type.typarams.isEmpty()) { for (JCTypeParameter param : type.typarams) { diff --git a/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java b/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java index ad3b571a..0f8161e1 100644 --- a/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java +++ b/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java @@ -154,7 +154,7 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandler nodesForEquality = ListBuffer.lb(); + ListBuffer nodesForEquality = new ListBuffer(); if (includes != null) { for (JavacNode child : typeNode.down()) { if (child.getKind() != Kind.FIELD) continue; @@ -224,7 +224,7 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandlernil()); JCModifiers mods = maker.Modifiers(Flags.PUBLIC, List.of(overrideAnnotation)); JCExpression returnType = maker.TypeIdent(CTC_INT); - ListBuffer statements = ListBuffer.lb(); + ListBuffer statements = new ListBuffer(); Name primeName = typeNode.toName(PRIME_NAME); Name resultName = typeNode.toName(RESULT_NAME); @@ -370,7 +370,7 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandler statements = ListBuffer.lb(); + ListBuffer statements = new ListBuffer(); final List params = List.of(maker.VarDef(maker.Modifiers(Flags.FINAL | Flags.PARAMETER), oName, objectType, null)); /* if (o == this) return true; */ { @@ -387,8 +387,8 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandler other = (MyType) o; */ { if (!fields.isEmpty() || needsCanEqual) { final JCExpression selfType1, selfType2; - ListBuffer wildcards1 = ListBuffer.lb(); - ListBuffer wildcards2 = ListBuffer.lb(); + ListBuffer wildcards1 = new ListBuffer(); + ListBuffer wildcards2 = new ListBuffer(); for (int i = 0 ; i < type.typarams.length() ; i++) { wildcards1.append(maker.Wildcard(maker.TypeBoundKind(BoundKind.UNBOUND), null)); wildcards2.append(maker.Wildcard(maker.TypeBoundKind(BoundKind.UNBOUND), null)); diff --git a/src/core/lombok/javac/handlers/HandleGetter.java b/src/core/lombok/javac/handlers/HandleGetter.java index f6c14add..4ef23170 100644 --- a/src/core/lombok/javac/handlers/HandleGetter.java +++ b/src/core/lombok/javac/handlers/HandleGetter.java @@ -270,7 +270,7 @@ public class HandleGetter extends JavacAnnotationHandler { } if (!delegates.isEmpty()) { - ListBuffer withoutDelegates = ListBuffer.lb(); + ListBuffer withoutDelegates = new ListBuffer(); for (JCAnnotation annotation : fieldNode.mods.annotations) { if (!delegates.contains(annotation)) { withoutDelegates.append(annotation); @@ -328,7 +328,7 @@ public class HandleGetter extends JavacAnnotationHandler { [END IF] */ - ListBuffer statements = ListBuffer.lb(); + ListBuffer statements = new ListBuffer(); JCVariableDecl field = (JCVariableDecl) fieldNode.get(); JCExpression copyOfRawFieldType = copyType(maker, field); @@ -356,14 +356,14 @@ public class HandleGetter extends JavacAnnotationHandler { /* if (value == null) { */ { JCSynchronized synchronizedStatement; /* synchronized (this.fieldName) { */ { - ListBuffer synchronizedStatements = ListBuffer.lb(); + ListBuffer synchronizedStatements = new ListBuffer(); /* value = this.fieldName.get(); */ { JCExpressionStatement newAssign = maker.Exec(maker.Assign(maker.Ident(valueName), callGet(fieldNode, createFieldAccessor(maker, fieldNode, FieldAccess.ALWAYS_FIELD)))); synchronizedStatements.append(newAssign); } /* if (value == null) { */ { - ListBuffer innerIfStatements = ListBuffer.lb(); + ListBuffer innerIfStatements = new ListBuffer(); /* final RawValueType actualValue = INITIALIZER_EXPRESSION; */ { innerIfStatements.append(maker.VarDef(maker.Modifiers(Flags.FINAL), actualValueName, copyOfRawFieldType, field.init)); } diff --git a/src/core/lombok/javac/handlers/HandleSetter.java b/src/core/lombok/javac/handlers/HandleSetter.java index 6f345418..c4977b2b 100644 --- a/src/core/lombok/javac/handlers/HandleSetter.java +++ b/src/core/lombok/javac/handlers/HandleSetter.java @@ -204,7 +204,7 @@ public class HandleSetter extends JavacAnnotationHandler { JCExpression fieldRef = createFieldAccessor(treeMaker, field, FieldAccess.ALWAYS_FIELD); JCAssign assign = treeMaker.Assign(fieldRef, treeMaker.Ident(fieldDecl.name)); - ListBuffer statements = ListBuffer.lb(); + ListBuffer statements = new ListBuffer(); List nonNulls = findAnnotations(field, TransformationsUtil.NON_NULL_PATTERN); List nullables = findAnnotations(field, TransformationsUtil.NULLABLE_PATTERN); diff --git a/src/core/lombok/javac/handlers/HandleToString.java b/src/core/lombok/javac/handlers/HandleToString.java index ea526009..9bd5b920 100644 --- a/src/core/lombok/javac/handlers/HandleToString.java +++ b/src/core/lombok/javac/handlers/HandleToString.java @@ -129,7 +129,7 @@ public class HandleToString extends JavacAnnotationHandler { return; } - ListBuffer nodesForToString = ListBuffer.lb(); + ListBuffer nodesForToString = new ListBuffer(); if (includes != null) { for (JavacNode child : typeNode.down()) { if (child.getKind() != Kind.FIELD) continue; diff --git a/src/core/lombok/javac/handlers/HandleWither.java b/src/core/lombok/javac/handlers/HandleWither.java index 4bda5464..9cfa4531 100644 --- a/src/core/lombok/javac/handlers/HandleWither.java +++ b/src/core/lombok/javac/handlers/HandleWither.java @@ -207,7 +207,7 @@ public class HandleWither extends JavacAnnotationHandler { JCVariableDecl fieldDecl = (JCVariableDecl) field.get(); - ListBuffer statements = ListBuffer.lb(); + ListBuffer statements = new ListBuffer(); List nonNulls = findAnnotations(field, TransformationsUtil.NON_NULL_PATTERN); List nullables = findAnnotations(field, TransformationsUtil.NULLABLE_PATTERN); @@ -219,7 +219,7 @@ public class HandleWither extends JavacAnnotationHandler { JCExpression selfType = cloneSelfType(field); if (selfType == null) return null; - ListBuffer args = ListBuffer.lb(); + ListBuffer args = new ListBuffer(); for (JavacNode child : field.up().down()) { if (child.getKind() != Kind.FIELD) continue; JCVariableDecl childDecl = (JCVariableDecl) child.get(); diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java index f25a11c1..f90bb60d 100644 --- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java +++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java @@ -338,7 +338,7 @@ public class JavacHandlerUtil { public static void deleteImportFromCompilationUnit(JavacNode node, String name) { if (inNetbeansEditor(node)) return; if (!node.shouldDeleteLombokAnnotations()) return; - ListBuffer newDefs = ListBuffer.lb(); + ListBuffer newDefs = new ListBuffer(); JCCompilationUnit unit = (JCCompilationUnit) node.top().get(); @@ -354,7 +354,7 @@ public class JavacHandlerUtil { } private static List filterList(List annotations, JCTree jcTree) { - ListBuffer newAnnotations = ListBuffer.lb(); + ListBuffer newAnnotations = new ListBuffer(); for (JCAnnotation ann : annotations) { if (jcTree != ann) newAnnotations.append(ann); } @@ -437,7 +437,7 @@ public class JavacHandlerUtil { while (typeNode != null && typeNode.getKind() != Kind.TYPE) typeNode = typeNode.up(); if (typeNode != null && typeNode.get() instanceof JCClassDecl) { JCClassDecl type = (JCClassDecl) typeNode.get(); - ListBuffer typeArgs = ListBuffer.lb(); + ListBuffer typeArgs = new ListBuffer(); if (!type.typarams.isEmpty()) { for (JCTypeParameter tp : type.typarams) { typeArgs.append(maker.Ident(tp.name)); @@ -885,7 +885,7 @@ public class JavacHandlerUtil { } private static List addAllButOne(List defs, int idx) { - ListBuffer out = ListBuffer.lb(); + ListBuffer out = new ListBuffer(); int i = 0; for (JCTree def : defs) { if (i++ != idx) out.append(def); @@ -956,7 +956,7 @@ public class JavacHandlerUtil { * Only the simple name is checked - the package and any containing class are ignored. */ public static List findAnnotations(JavacNode fieldNode, Pattern namePattern) { - ListBuffer result = ListBuffer.lb(); + ListBuffer result = new ListBuffer(); for (JavacNode child : fieldNode.down()) { if (child.getKind() == Kind.ANNOTATION) { JCAnnotation annotation = (JCAnnotation) child.get(); @@ -1006,7 +1006,7 @@ public class JavacHandlerUtil { if (idx > -1) matched[idx] = true; } - ListBuffer problematic = ListBuffer.lb(); + ListBuffer problematic = new ListBuffer(); for (int i = 0 ; i < list.size() ; i++) { if (!matched[i]) problematic.append(i); } @@ -1015,8 +1015,8 @@ public class JavacHandlerUtil { } static List unboxAndRemoveAnnotationParameter(JCAnnotation ast, String parameterName, String errorName, JavacNode errorNode) { - ListBuffer params = ListBuffer.lb(); - ListBuffer result = ListBuffer.lb(); + ListBuffer params = new ListBuffer(); + ListBuffer result = new ListBuffer(); errorNode.removeDeferredErrors(); @@ -1086,13 +1086,13 @@ public class JavacHandlerUtil { public static List copyTypeParams(JavacTreeMaker maker, List params) { if (params == null || params.isEmpty()) return params; - ListBuffer out = ListBuffer.lb(); + ListBuffer out = new ListBuffer(); for (JCTypeParameter tp : params) out.append(maker.TypeParameter(tp.name, tp.bounds)); return out.toList(); } public static JCExpression namePlusTypeParamsToTypeReference(JavacTreeMaker maker, Name typeName, List params) { - ListBuffer typeArgs = ListBuffer.lb(); + ListBuffer typeArgs = new ListBuffer(); if (!params.isEmpty()) { for (JCTypeParameter param : params) { @@ -1128,7 +1128,7 @@ public class JavacHandlerUtil { } static List copyAnnotations(List in) { - ListBuffer out = ListBuffer.lb(); + ListBuffer out = new ListBuffer(); for (JCExpression expr : in) { if (!(expr instanceof JCAnnotation)) continue; out.append((JCAnnotation) expr.clone()); @@ -1197,7 +1197,7 @@ public class JavacHandlerUtil { if (in instanceof JCTypeApply) { JCTypeApply ta = (JCTypeApply) in; - ListBuffer lb = ListBuffer.lb(); + ListBuffer lb = new ListBuffer(); for (JCExpression typeArg : ta.arguments) { lb.append(cloneType0(maker, typeArg)); } diff --git a/src/utils/lombok/javac/java6/CommentCollectingScanner.java b/src/utils/lombok/javac/java6/CommentCollectingScanner.java index 5d820ba0..a0e78380 100644 --- a/src/utils/lombok/javac/java6/CommentCollectingScanner.java +++ b/src/utils/lombok/javac/java6/CommentCollectingScanner.java @@ -28,11 +28,12 @@ import lombok.javac.CommentInfo.EndConnection; import lombok.javac.CommentInfo.StartConnection; import com.sun.tools.javac.parser.Scanner; +import com.sun.tools.javac.tree.JCTree.JCExpression; import com.sun.tools.javac.util.List; import com.sun.tools.javac.util.ListBuffer; public class CommentCollectingScanner extends Scanner { - private final ListBuffer comments = ListBuffer.lb(); + private final ListBuffer comments = new ListBuffer(); private int endComment = 0; public CommentCollectingScanner(CommentCollectingScannerFactory factory, CharBuffer charBuffer) { diff --git a/src/utils/lombok/javac/java7/CommentCollectingScanner.java b/src/utils/lombok/javac/java7/CommentCollectingScanner.java index 86c474ea..f97c20a7 100644 --- a/src/utils/lombok/javac/java7/CommentCollectingScanner.java +++ b/src/utils/lombok/javac/java7/CommentCollectingScanner.java @@ -28,11 +28,12 @@ import lombok.javac.CommentInfo.EndConnection; import lombok.javac.CommentInfo.StartConnection; import com.sun.tools.javac.parser.Scanner; +import com.sun.tools.javac.tree.JCTree.JCExpression; import com.sun.tools.javac.util.List; import com.sun.tools.javac.util.ListBuffer; public class CommentCollectingScanner extends Scanner { - private final ListBuffer comments = ListBuffer.lb(); + private final ListBuffer comments = new ListBuffer(); private int endComment = 0; public CommentCollectingScanner(CommentCollectingScannerFactory factory, CharBuffer charBuffer) { diff --git a/src/utils/lombok/javac/java8/CommentCollectingTokenizer.java b/src/utils/lombok/javac/java8/CommentCollectingTokenizer.java index 95945f8f..a81ebab1 100644 --- a/src/utils/lombok/javac/java8/CommentCollectingTokenizer.java +++ b/src/utils/lombok/javac/java8/CommentCollectingTokenizer.java @@ -12,12 +12,13 @@ import com.sun.tools.javac.parser.Tokens.Comment; import com.sun.tools.javac.parser.Tokens.Token; import com.sun.tools.javac.parser.Tokens.Comment.CommentStyle; import com.sun.tools.javac.parser.UnicodeReader; +import com.sun.tools.javac.tree.JCTree.JCExpression; import com.sun.tools.javac.util.List; import com.sun.tools.javac.util.ListBuffer; class CommentCollectingTokenizer extends JavaTokenizer { private int prevEndPosition = 0; - private final ListBuffer comments = ListBuffer.lb(); + private final ListBuffer comments = new ListBuffer(); private int endComment = 0; CommentCollectingTokenizer(ScannerFactory fac, char[] buf, int inputLength) { -- cgit From 728dddbc81d9f9bfbbd3f8217b8c94f3f201c83d Mon Sep 17 00:00:00 2001 From: Roel Spilker Date: Wed, 25 Sep 2013 23:04:04 +0200 Subject: [jdk8support] ... and javadoc copying support is back for javac8. Also fixed some copyright headers. --- .../lombok/javac/handlers/JavacHandlerUtil.java | 42 +++++++++++++++++ .../lombok/delombok/DocCommentIntegrator.java | 25 +++++++++- .../lombok/delombok/PrettyCommentsPrinter.java | 54 ++++++++++++---------- src/stubs/com/sun/tools/javac/parser/Tokens.java | 12 ++++- .../com/sun/tools/javac/tree/DocCommentTable.java | 10 ++++ .../javac/java6/CommentCollectingParser.java | 21 +++++++++ .../java6/CommentCollectingParserFactory.java | 21 +++++++++ .../javac/java6/CommentCollectingScanner.java | 3 +- .../javac/java7/CommentCollectingParser.java | 21 +++++++++ .../java7/CommentCollectingParserFactory.java | 21 +++++++++ .../javac/java7/CommentCollectingScanner.java | 3 +- .../javac/java8/CommentCollectingParser.java | 21 +++++++++ .../java8/CommentCollectingParserFactory.java | 21 +++++++++ .../javac/java8/CommentCollectingScanner.java | 21 +++++++++ .../javac/java8/CommentCollectingTokenizer.java | 22 ++++++++- 15 files changed, 287 insertions(+), 31 deletions(-) create mode 100644 src/stubs/com/sun/tools/javac/tree/DocCommentTable.java (limited to 'src/utils/lombok/javac/java8') diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java index f90bb60d..6d6426aa 100644 --- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java +++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java @@ -50,6 +50,8 @@ import lombok.javac.JavacTreeMaker; import com.sun.tools.javac.code.BoundKind; import com.sun.tools.javac.code.Flags; +import com.sun.tools.javac.parser.Tokens.Comment; +import com.sun.tools.javac.tree.DocCommentTable; import com.sun.tools.javac.tree.JCTree; import com.sun.tools.javac.tree.JCTree.JCAnnotation; import com.sun.tools.javac.tree.JCTree.JCArrayTypeTree; @@ -216,6 +218,17 @@ public class JavacHandlerUtil { return false; } + /** + * Returns if a node is marked deprecated (as picked up on by the parser). + * @param node the node to check (type, method, or field decl). + */ + public static boolean nodeHasDeprecatedFlag(JCTree node) { + if (node instanceof JCVariableDecl) return (((JCVariableDecl) node).mods.flags & Flags.DEPRECATED) != 0; + if (node instanceof JCMethodDecl) return (((JCMethodDecl) node).mods.flags & Flags.DEPRECATED) != 0; + if (node instanceof JCClassDecl) return (((JCClassDecl) node).mods.flags & Flags.DEPRECATED) != 0; + return false; + } + /** * Creates an instance of {@code AnnotationValues} for the provided AST Node. * @@ -1325,7 +1338,36 @@ public class JavacHandlerUtil { docComments.put(to, filtered[0]); docComments.put(from.get(), filtered[1]); } + } else if (dc instanceof DocCommentTable) { + DocCommentTable dct = (DocCommentTable) dc; + Comment javadoc = dct.getComment(from.get()); + + if (javadoc != null) { + String[] filtered = copyMode.split(javadoc.getText()); + dct.putComment(to, createJavadocComment(filtered[0], from)); + dct.putComment(from.get(), createJavadocComment(filtered[1], from)); + } } } catch (Exception ignore) {} } + + private static Comment createJavadocComment(final String text, final JavacNode field) { + return new Comment() { + @Override public String getText() { + return text; + } + + @Override public int getSourcePos(int index) { + return -1; + } + + @Override public CommentStyle getStyle() { + return CommentStyle.JAVADOC; + } + + @Override public boolean isDeprecated() { + return text.contains("@deprecated") && field.getKind() == Kind.FIELD && isFieldDeprecated(field); + } + }; + } } diff --git a/src/delombok/lombok/delombok/DocCommentIntegrator.java b/src/delombok/lombok/delombok/DocCommentIntegrator.java index 80aec16a..c1eb02b6 100644 --- a/src/delombok/lombok/delombok/DocCommentIntegrator.java +++ b/src/delombok/lombok/delombok/DocCommentIntegrator.java @@ -8,7 +8,10 @@ import java.util.regex.Pattern; import lombok.javac.CommentInfo; import lombok.javac.Javac; +import lombok.javac.handlers.JavacHandlerUtil; +import com.sun.tools.javac.parser.Tokens.Comment; +import com.sun.tools.javac.tree.DocCommentTable; import com.sun.tools.javac.tree.JCTree; import com.sun.tools.javac.tree.JCTree.JCClassDecl; import com.sun.tools.javac.tree.JCTree.JCCompilationUnit; @@ -50,7 +53,7 @@ public class DocCommentIntegrator { } private static final Pattern CONTENT_STRIPPER = Pattern.compile("^(?:\\s*\\*)?[ \\t]*(.*?)$", Pattern.MULTILINE); - @SuppressWarnings("unchecked") private boolean attach(JCCompilationUnit top, JCTree node, CommentInfo cmt) { + @SuppressWarnings("unchecked") private boolean attach(JCCompilationUnit top, final JCTree node, CommentInfo cmt) { String docCommentContent = cmt.content; if (docCommentContent.startsWith("/**")) docCommentContent = docCommentContent.substring(3); if (docCommentContent.endsWith("*/")) docCommentContent = docCommentContent.substring(0, docCommentContent.length() -2); @@ -63,6 +66,26 @@ public class DocCommentIntegrator { if (map_ instanceof Map) { ((Map) map_).put(node, docCommentContent); return true; + } else if (map_ instanceof DocCommentTable) { + final String docCommentContent_ = docCommentContent; + ((DocCommentTable) map_).putComment(node, new Comment() { + @Override public String getText() { + return docCommentContent_; + } + + @Override public int getSourcePos(int index) { + return -1; + } + + @Override public CommentStyle getStyle() { + return CommentStyle.JAVADOC; + } + + @Override public boolean isDeprecated() { + return JavacHandlerUtil.nodeHasDeprecatedFlag(node); + } + }); + return true; } return false; diff --git a/src/delombok/lombok/delombok/PrettyCommentsPrinter.java b/src/delombok/lombok/delombok/PrettyCommentsPrinter.java index 525773f4..67c313ab 100644 --- a/src/delombok/lombok/delombok/PrettyCommentsPrinter.java +++ b/src/delombok/lombok/delombok/PrettyCommentsPrinter.java @@ -101,6 +101,7 @@ import com.sun.tools.javac.tree.JCTree.JCWhileLoop; import com.sun.tools.javac.tree.JCTree.JCWildcard; import com.sun.tools.javac.tree.JCTree.LetExpr; import com.sun.tools.javac.tree.JCTree.TypeBoundKind; +import com.sun.tools.javac.tree.DocCommentTable; import com.sun.tools.javac.tree.TreeInfo; import com.sun.tools.javac.tree.TreeScanner; import com.sun.tools.javac.util.Convert; @@ -270,6 +271,13 @@ public class PrettyCommentsPrinter extends JCTree.Visitor { * (can be null) */ Map docComments = null; + DocCommentTable docTable = null; + + String getJavadocFor(JCTree node) { + if (docComments != null) return docComments.get(node); + if (docTable != null) return docTable.getCommentText(node); + return null; + } /** Align code to be indented to left margin. */ @@ -464,31 +472,28 @@ public class PrettyCommentsPrinter extends JCTree.Visitor { * @param tree The tree for which a documentation comment should be printed. */ public void printDocComment(JCTree tree) throws IOException { - if (docComments != null) { - String dc = docComments.get(tree); - if (dc != null) { - print("/**"); println(); - int pos = 0; - int endpos = lineEndPos(dc, pos); - boolean atStart = true; - while (pos < dc.length()) { - String line = dc.substring(pos, endpos); - if (line.trim().isEmpty() && atStart) { - atStart = false; - continue; - } - atStart = false; - align(); - print(" *"); - if (pos < dc.length() && dc.charAt(pos) > ' ') print(" "); - print(dc.substring(pos, endpos)); println(); - pos = endpos + 1; - endpos = lineEndPos(dc, pos); - } - align(); print(" */"); println(); - align(); + String dc = getJavadocFor(tree); + if (dc == null) return; + print("/**"); println(); + int pos = 0; + int endpos = lineEndPos(dc, pos); + boolean atStart = true; + while (pos < dc.length()) { + String line = dc.substring(pos, endpos); + if (line.trim().isEmpty() && atStart) { + atStart = false; + continue; } + atStart = false; + align(); + print(" *"); + if (pos < dc.length() && dc.charAt(pos) > ' ') print(" "); + print(dc.substring(pos, endpos)); println(); + pos = endpos + 1; + endpos = lineEndPos(dc, pos); } + align(); print(" */"); println(); + align(); } //where static int lineEndPos(String s, int start) { @@ -586,6 +591,7 @@ public class PrettyCommentsPrinter extends JCTree.Visitor { public void printUnit(JCCompilationUnit tree, JCClassDecl cdef) throws IOException { Object dc = getDocComments(tree); if (dc instanceof Map) this.docComments = (Map) dc; + else if (dc instanceof DocCommentTable) this.docTable = (DocCommentTable) dc; printDocComment(tree); if (tree.pid != null) { consumeComments(tree.pos, tree); @@ -767,7 +773,7 @@ public class PrettyCommentsPrinter extends JCTree.Visitor { public void visitVarDef(JCVariableDecl tree) { try { - if (docComments != null && docComments.get(tree) != null) { + if (getJavadocFor(tree) != null) { println(); align(); } printDocComment(tree); diff --git a/src/stubs/com/sun/tools/javac/parser/Tokens.java b/src/stubs/com/sun/tools/javac/parser/Tokens.java index 3d14d27c..6e0aa479 100644 --- a/src/stubs/com/sun/tools/javac/parser/Tokens.java +++ b/src/stubs/com/sun/tools/javac/parser/Tokens.java @@ -6,6 +6,16 @@ public class Tokens { } public interface Comment { - enum CommentStyle {} + enum CommentStyle { + LINE, BLOCK, JAVADOC, + } + + String getText(); + + int getSourcePos(int index); + + CommentStyle getStyle(); + + boolean isDeprecated(); } } diff --git a/src/stubs/com/sun/tools/javac/tree/DocCommentTable.java b/src/stubs/com/sun/tools/javac/tree/DocCommentTable.java new file mode 100644 index 00000000..75b2526a --- /dev/null +++ b/src/stubs/com/sun/tools/javac/tree/DocCommentTable.java @@ -0,0 +1,10 @@ +package com.sun.tools.javac.tree; + +import com.sun.tools.javac.parser.Tokens.Comment; + +public interface DocCommentTable { + boolean hasComment(JCTree tree); + Comment getComment(JCTree tree); + String getCommentText(JCTree tree); + void putComment(JCTree tree, Comment c); +} diff --git a/src/utils/lombok/javac/java6/CommentCollectingParser.java b/src/utils/lombok/javac/java6/CommentCollectingParser.java index 94a85e55..30192b06 100644 --- a/src/utils/lombok/javac/java6/CommentCollectingParser.java +++ b/src/utils/lombok/javac/java6/CommentCollectingParser.java @@ -1,3 +1,24 @@ +/* + * Copyright (C) 2013 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 + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package lombok.javac.java6; import java.util.Map; diff --git a/src/utils/lombok/javac/java6/CommentCollectingParserFactory.java b/src/utils/lombok/javac/java6/CommentCollectingParserFactory.java index 7e34b723..b250b898 100644 --- a/src/utils/lombok/javac/java6/CommentCollectingParserFactory.java +++ b/src/utils/lombok/javac/java6/CommentCollectingParserFactory.java @@ -1,3 +1,24 @@ +/* + * Copyright (C) 2013 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 + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package lombok.javac.java6; import java.lang.reflect.Field; diff --git a/src/utils/lombok/javac/java6/CommentCollectingScanner.java b/src/utils/lombok/javac/java6/CommentCollectingScanner.java index a0e78380..df383b93 100644 --- a/src/utils/lombok/javac/java6/CommentCollectingScanner.java +++ b/src/utils/lombok/javac/java6/CommentCollectingScanner.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 The Project Lombok Authors. + * Copyright (C) 2011-2013 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 @@ -28,7 +28,6 @@ import lombok.javac.CommentInfo.EndConnection; import lombok.javac.CommentInfo.StartConnection; import com.sun.tools.javac.parser.Scanner; -import com.sun.tools.javac.tree.JCTree.JCExpression; import com.sun.tools.javac.util.List; import com.sun.tools.javac.util.ListBuffer; diff --git a/src/utils/lombok/javac/java7/CommentCollectingParser.java b/src/utils/lombok/javac/java7/CommentCollectingParser.java index 82f19c42..0e8a4ef6 100644 --- a/src/utils/lombok/javac/java7/CommentCollectingParser.java +++ b/src/utils/lombok/javac/java7/CommentCollectingParser.java @@ -1,3 +1,24 @@ +/* + * Copyright (C) 2013 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 + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package lombok.javac.java7; import java.util.List; diff --git a/src/utils/lombok/javac/java7/CommentCollectingParserFactory.java b/src/utils/lombok/javac/java7/CommentCollectingParserFactory.java index e9575c14..ed8279df 100644 --- a/src/utils/lombok/javac/java7/CommentCollectingParserFactory.java +++ b/src/utils/lombok/javac/java7/CommentCollectingParserFactory.java @@ -1,3 +1,24 @@ +/* + * Copyright (C) 2013 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 + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package lombok.javac.java7; import java.lang.reflect.Field; diff --git a/src/utils/lombok/javac/java7/CommentCollectingScanner.java b/src/utils/lombok/javac/java7/CommentCollectingScanner.java index f97c20a7..3f76f910 100644 --- a/src/utils/lombok/javac/java7/CommentCollectingScanner.java +++ b/src/utils/lombok/javac/java7/CommentCollectingScanner.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 The Project Lombok Authors. + * Copyright (C) 2011-2013 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 @@ -28,7 +28,6 @@ import lombok.javac.CommentInfo.EndConnection; import lombok.javac.CommentInfo.StartConnection; import com.sun.tools.javac.parser.Scanner; -import com.sun.tools.javac.tree.JCTree.JCExpression; import com.sun.tools.javac.util.List; import com.sun.tools.javac.util.ListBuffer; diff --git a/src/utils/lombok/javac/java8/CommentCollectingParser.java b/src/utils/lombok/javac/java8/CommentCollectingParser.java index 6cf65dca..e305e44f 100644 --- a/src/utils/lombok/javac/java8/CommentCollectingParser.java +++ b/src/utils/lombok/javac/java8/CommentCollectingParser.java @@ -1,3 +1,24 @@ +/* + * Copyright (C) 2013 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 + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package lombok.javac.java8; import java.util.List; diff --git a/src/utils/lombok/javac/java8/CommentCollectingParserFactory.java b/src/utils/lombok/javac/java8/CommentCollectingParserFactory.java index 594ff8ba..6b5f9198 100644 --- a/src/utils/lombok/javac/java8/CommentCollectingParserFactory.java +++ b/src/utils/lombok/javac/java8/CommentCollectingParserFactory.java @@ -1,3 +1,24 @@ +/* + * Copyright (C) 2013 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 + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package lombok.javac.java8; import java.lang.reflect.Field; diff --git a/src/utils/lombok/javac/java8/CommentCollectingScanner.java b/src/utils/lombok/javac/java8/CommentCollectingScanner.java index 1b8474ac..b59a9390 100644 --- a/src/utils/lombok/javac/java8/CommentCollectingScanner.java +++ b/src/utils/lombok/javac/java8/CommentCollectingScanner.java @@ -1,3 +1,24 @@ +/* + * Copyright (C) 2013 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 + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package lombok.javac.java8; import lombok.javac.CommentInfo; diff --git a/src/utils/lombok/javac/java8/CommentCollectingTokenizer.java b/src/utils/lombok/javac/java8/CommentCollectingTokenizer.java index a81ebab1..1834fb00 100644 --- a/src/utils/lombok/javac/java8/CommentCollectingTokenizer.java +++ b/src/utils/lombok/javac/java8/CommentCollectingTokenizer.java @@ -1,3 +1,24 @@ +/* + * Copyright (C) 2013 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 + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package lombok.javac.java8; import java.nio.CharBuffer; @@ -12,7 +33,6 @@ import com.sun.tools.javac.parser.Tokens.Comment; import com.sun.tools.javac.parser.Tokens.Token; import com.sun.tools.javac.parser.Tokens.Comment.CommentStyle; import com.sun.tools.javac.parser.UnicodeReader; -import com.sun.tools.javac.tree.JCTree.JCExpression; import com.sun.tools.javac.util.List; import com.sun.tools.javac.util.ListBuffer; -- cgit