diff --git a/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java b/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java index c5b0ea079f..c176f51591 100644 --- a/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java +++ b/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2023 The Project Lombok Authors. + * Copyright (C) 2009-2024 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 @@ -100,6 +100,7 @@ public String mapResourceName(int classFileFormatVersion, String resourceName) { patchJavadoc(sm); patchASTConverterLiterals(sm); patchASTNodeSearchUtil(sm); + patchFieldInitializer(sm); patchPostCompileHookEcj(sm); @@ -1029,6 +1030,42 @@ private static void patchASTNodeSearchUtil(ScriptManager sm) { .build()); } + private static void patchFieldInitializer(ScriptManager sm) { + sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.addField() + .targetClass("org.eclipse.jdt.internal.core.CompilationUnitStructureRequestor") + .fieldName("$fieldInfo") + .fieldType("Ljava/lang/Object;") + .build()); + + sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.addField() + .targetClass("org.eclipse.jdt.internal.core.CompilationUnitStructureRequestor") + .fieldName("$sourceFieldElementInfo") + .fieldType("Lorg/eclipse/jdt/internal/core/SourceFieldElementInfo;") + .build()); + + sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.exitEarly() + .target(new MethodTarget("org.eclipse.jdt.internal.core.CompilationUnitStructureRequestor", "exitField", "void", "int", "int", "int")) + .decisionMethod(new Hook("lombok.launch.PatchFixesHider$FieldInitializer", "storeFieldInfo", "boolean", "org.eclipse.jdt.internal.core.CompilationUnitStructureRequestor")) + .request(StackRequest.THIS) + .transplant() + .build()); + + sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.wrapMethodCall() + .target(new MethodTarget("org.eclipse.jdt.internal.core.CompilationUnitStructureRequestor", "exitField", "void", "int", "int", "int")) + .methodToWrap(new Hook("org.eclipse.jdt.internal.core.SourceFieldElementInfo", "", "void")) + .wrapMethod(new Hook("lombok.launch.PatchFixesHider$FieldInitializer", "storeSourceFieldElementInfo", "void", "org.eclipse.jdt.internal.core.SourceFieldElementInfo", "org.eclipse.jdt.internal.core.CompilationUnitStructureRequestor")) + .requestExtra(StackRequest.THIS) + .transplant() + .build()); + + sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.wrapReturnValue() + .target(new MethodTarget("org.eclipse.jdt.internal.core.CompilationUnitStructureRequestor", "exitField", "void", "int", "int", "int")) + .wrapMethod(new Hook("lombok.launch.PatchFixesHider$FieldInitializer", "overwriteInitializer", "void", "org.eclipse.jdt.internal.core.CompilationUnitStructureRequestor")) + .request(StackRequest.THIS) + .transplant() + .build()); + } + private static void patchCrossModuleClassLoading(ScriptManager sm) { sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.wrapReturnValue() .target(new MethodTarget("org.eclipse.jdt.internal.compiler.parser.Parser", "")) diff --git a/src/eclipseAgent/lombok/launch/PatchFixesHider.java b/src/eclipseAgent/lombok/launch/PatchFixesHider.java index c88f317158..3bdf7974f1 100755 --- a/src/eclipseAgent/lombok/launch/PatchFixesHider.java +++ b/src/eclipseAgent/lombok/launch/PatchFixesHider.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2023 The Project Lombok Authors. + * Copyright (C) 2010-2024 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 @@ -52,7 +52,9 @@ import org.eclipse.jdt.core.dom.SingleVariableDeclaration; import org.eclipse.jdt.core.dom.Type; import org.eclipse.jdt.core.search.SearchMatch; +import org.eclipse.jdt.internal.compiler.ISourceElementRequestor.FieldInfo; import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration; +import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration; import org.eclipse.jdt.internal.compiler.ast.Annotation; import org.eclipse.jdt.internal.compiler.ast.Expression; import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration; @@ -61,7 +63,9 @@ import org.eclipse.jdt.internal.compiler.lookup.BlockScope; import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; import org.eclipse.jdt.internal.compiler.parser.Parser; +import org.eclipse.jdt.internal.core.CompilationUnitStructureRequestor; import org.eclipse.jdt.internal.core.SourceField; +import org.eclipse.jdt.internal.core.SourceFieldElementInfo; import org.eclipse.jdt.internal.core.dom.rewrite.NodeRewriteEvent; import org.eclipse.jdt.internal.core.dom.rewrite.RewriteEvent; import org.eclipse.jdt.internal.core.dom.rewrite.TokenScanner; @@ -935,6 +939,68 @@ public static String[] getRealCodeBlocks(String[] blocks, SourceProvider sourceP } } + public static class FieldInitializer { + public static final Field INFO_STACK; + public static final Field FIELD_INFO; + public static final Field SOURCE_FIELD_ELEMENT_INFO; + public static final Field INITIALIZATION_SOURCE; + public static final Field NODE; + public static final boolean INITIALIZED; + + static { + INFO_STACK = Permit.permissiveGetField(CompilationUnitStructureRequestor.class, "infoStack"); + FIELD_INFO = Permit.permissiveGetField(CompilationUnitStructureRequestor.class, "$fieldInfo"); + SOURCE_FIELD_ELEMENT_INFO = Permit.permissiveGetField(CompilationUnitStructureRequestor.class, "$sourceFieldElementInfo"); + INITIALIZATION_SOURCE = Permit.permissiveGetField(SourceFieldElementInfo.class, "initializationSource"); + NODE = Permit.permissiveGetField(FieldInfo.class, "node"); + INITIALIZED = INFO_STACK != null && FIELD_INFO != null && SOURCE_FIELD_ELEMENT_INFO != null && INITIALIZATION_SOURCE != null && NODE != null; + } + + public static boolean storeFieldInfo(CompilationUnitStructureRequestor compilationUnitStructureRequestor) { + try { + if (INITIALIZED) { + Stack infoStack = Permit.get(INFO_STACK, compilationUnitStructureRequestor); + Object fieldInfo = infoStack.peek(); + Permit.set(FIELD_INFO, compilationUnitStructureRequestor, fieldInfo); + } + } catch (Exception e) { + // do not break eclipse + } + return false; + } + public static void storeSourceFieldElementInfo(SourceFieldElementInfo fieldInfo, CompilationUnitStructureRequestor compilationUnitStructureRequestor) { + try { + if (INITIALIZED) { + Permit.set(SOURCE_FIELD_ELEMENT_INFO, compilationUnitStructureRequestor, fieldInfo); + } + } catch (Exception e) { + // do not break eclipse + } + } + + public static void overwriteInitializer(CompilationUnitStructureRequestor compilationUnitStructureRequestor) { + try { + if (INITIALIZED) { + FieldInfo fieldInfo = Permit.get(FIELD_INFO, compilationUnitStructureRequestor); + Permit.set(FIELD_INFO, compilationUnitStructureRequestor, null); + + SourceFieldElementInfo sourceFieldElementInfo = Permit.get(SOURCE_FIELD_ELEMENT_INFO,compilationUnitStructureRequestor); + Permit.set(SOURCE_FIELD_ELEMENT_INFO, compilationUnitStructureRequestor, null); + + if (sourceFieldElementInfo.getInitializationSource() != null) { + AbstractVariableDeclaration node = Permit.get(NODE, fieldInfo); + + if (PatchFixes.isGenerated(node)) { + Permit.set(INITIALIZATION_SOURCE, sourceFieldElementInfo, node.initialization.toString().toCharArray()); + } + } + } + } catch (Exception e) { + // do not break eclipse + } + } + } + public static class Tests { public static StringBuffer printMethod(AbstractMethodDeclaration methodDeclaration, int tab, StringBuffer output, TypeDeclaration type) { return (StringBuffer) printMethod(methodDeclaration, tab, (Object) output, type); diff --git a/test/eclipse/resource/noerrors/fieldNameConstantsInAnnotation/Annotation.java b/test/eclipse/resource/noerrors/fieldNameConstantsInAnnotation/Annotation.java new file mode 100644 index 0000000000..e3ecb40f2c --- /dev/null +++ b/test/eclipse/resource/noerrors/fieldNameConstantsInAnnotation/Annotation.java @@ -0,0 +1,5 @@ +package pkg; + +public @interface Annotation { + String value(); +} \ No newline at end of file diff --git a/test/eclipse/resource/noerrors/fieldNameConstantsInAnnotation/Constants.java b/test/eclipse/resource/noerrors/fieldNameConstantsInAnnotation/Constants.java new file mode 100644 index 0000000000..fad3811f70 --- /dev/null +++ b/test/eclipse/resource/noerrors/fieldNameConstantsInAnnotation/Constants.java @@ -0,0 +1,8 @@ +package pkg; + +import lombok.experimental.FieldNameConstants; + +@FieldNameConstants +public class Constants { + String test; +} \ No newline at end of file diff --git a/test/eclipse/resource/noerrors/fieldNameConstantsInAnnotation/Usage.java b/test/eclipse/resource/noerrors/fieldNameConstantsInAnnotation/Usage.java new file mode 100644 index 0000000000..5f8880efe2 --- /dev/null +++ b/test/eclipse/resource/noerrors/fieldNameConstantsInAnnotation/Usage.java @@ -0,0 +1,5 @@ +package pkg; + +@Annotation(Constants.Fields.test) +public class Usage { +} \ No newline at end of file diff --git a/test/eclipse/src/lombok/eclipse/EclipseRunner.java b/test/eclipse/src/lombok/eclipse/EclipseRunner.java index 1e1c17fe88..36e98d9e38 100644 --- a/test/eclipse/src/lombok/eclipse/EclipseRunner.java +++ b/test/eclipse/src/lombok/eclipse/EclipseRunner.java @@ -1,3 +1,24 @@ +/* + * Copyright (C) 2022 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.eclipse; import java.io.File; diff --git a/test/eclipse/src/lombok/eclipse/EclipseTests.java b/test/eclipse/src/lombok/eclipse/EclipseTests.java index 5fba99039f..04f78f0f71 100644 --- a/test/eclipse/src/lombok/eclipse/EclipseTests.java +++ b/test/eclipse/src/lombok/eclipse/EclipseTests.java @@ -1,3 +1,24 @@ +/* + * Copyright (C) 2022-2024 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.eclipse; import org.junit.runner.RunWith; @@ -5,6 +26,7 @@ import org.junit.runners.Suite.SuiteClasses; import lombok.eclipse.cleanup.CleanupTest; +import lombok.eclipse.compile.NoErrorsTest; import lombok.eclipse.edit.SelectTest; import lombok.eclipse.refactoring.ExtractInterfaceTest; import lombok.eclipse.refactoring.InlineTest; @@ -12,7 +34,7 @@ import lombok.eclipse.references.FindReferencesTest; @RunWith(Suite.class) -@SuiteClasses({ExtractInterfaceTest.class, RenameTest.class, SelectTest.class, CleanupTest.class, FindReferencesTest.class, InlineTest.class}) +@SuiteClasses({ExtractInterfaceTest.class, RenameTest.class, SelectTest.class, CleanupTest.class, FindReferencesTest.class, InlineTest.class, NoErrorsTest.class}) public class EclipseTests { } diff --git a/test/eclipse/src/lombok/eclipse/RefactoringUtils.java b/test/eclipse/src/lombok/eclipse/RefactoringUtils.java index 38349d2de8..2362ff11e2 100644 --- a/test/eclipse/src/lombok/eclipse/RefactoringUtils.java +++ b/test/eclipse/src/lombok/eclipse/RefactoringUtils.java @@ -1,3 +1,24 @@ +/* + * Copyright (C) 2022 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.eclipse; import static org.junit.Assert.assertTrue; diff --git a/test/eclipse/src/lombok/eclipse/SetupBeforeAfterTest.java b/test/eclipse/src/lombok/eclipse/SetupBeforeAfterTest.java index 05deabde6a..ff51ef138e 100644 --- a/test/eclipse/src/lombok/eclipse/SetupBeforeAfterTest.java +++ b/test/eclipse/src/lombok/eclipse/SetupBeforeAfterTest.java @@ -1,3 +1,24 @@ +/* + * Copyright (C) 2022-2023 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.eclipse; import static org.junit.Assert.assertEquals; diff --git a/test/eclipse/src/lombok/eclipse/SetupSingleFileTest.java b/test/eclipse/src/lombok/eclipse/SetupSingleFileTest.java index 47010f0cf8..d4b934ce8c 100644 --- a/test/eclipse/src/lombok/eclipse/SetupSingleFileTest.java +++ b/test/eclipse/src/lombok/eclipse/SetupSingleFileTest.java @@ -1,3 +1,24 @@ +/* + * Copyright (C) 2022 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.eclipse; import java.io.File; diff --git a/test/eclipse/src/lombok/eclipse/SetupTest.java b/test/eclipse/src/lombok/eclipse/SetupTest.java index fe8d469c6c..d3a2f1b062 100644 --- a/test/eclipse/src/lombok/eclipse/SetupTest.java +++ b/test/eclipse/src/lombok/eclipse/SetupTest.java @@ -1,3 +1,24 @@ +/* + * Copyright (C) 2022 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.eclipse; import java.io.File; diff --git a/test/eclipse/src/lombok/eclipse/cleanup/CleanupTest.java b/test/eclipse/src/lombok/eclipse/cleanup/CleanupTest.java index 2d01822855..76956aff5f 100644 --- a/test/eclipse/src/lombok/eclipse/cleanup/CleanupTest.java +++ b/test/eclipse/src/lombok/eclipse/cleanup/CleanupTest.java @@ -1,3 +1,24 @@ +/* + * Copyright (C) 2022 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.eclipse.cleanup; import static lombok.eclipse.RefactoringUtils.performRefactoring; diff --git a/test/eclipse/src/lombok/eclipse/compile/NoErrorsTest.java b/test/eclipse/src/lombok/eclipse/compile/NoErrorsTest.java new file mode 100644 index 0000000000..6d81d3812d --- /dev/null +++ b/test/eclipse/src/lombok/eclipse/compile/NoErrorsTest.java @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2024 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.eclipse.compile; + +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.jdt.core.ICompilationUnit; +import org.eclipse.jdt.core.IProblemRequestor; +import org.eclipse.jdt.core.WorkingCopyOwner; +import org.eclipse.jdt.core.compiler.IProblem; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; + +import lombok.eclipse.EclipseRunner; +import lombok.eclipse.SetupSingleFileTest; + +@RunWith(EclipseRunner.class) +public class NoErrorsTest { + + @Rule + public SetupSingleFileTest setup = new SetupSingleFileTest(); + + @Test + public void fieldNameConstantsInAnnotation() throws Exception { + ICompilationUnit cu = setup.getPackageFragment().getCompilationUnit("Usage.java"); + + final List problems = new ArrayList(); + final IProblemRequestor requestor = new IProblemRequestor() { + @Override + public void acceptProblem(IProblem problem) { + problems.add(problem); + } + + @Override + public void beginReporting() { + problems.clear(); + } + + @Override + public void endReporting() { + } + + @Override + public boolean isActive() { + return true; + } + }; + + WorkingCopyOwner workingCopyOwner = new WorkingCopyOwner() { + @Override + public IProblemRequestor getProblemRequestor(ICompilationUnit workingCopy) { + return requestor; + } + }; + + ICompilationUnit workingCopy = cu.getWorkingCopy(workingCopyOwner, null); + try { + workingCopy.reconcile(ICompilationUnit.NO_AST, true, true, workingCopy.getOwner(), null); + } finally { + workingCopy.discardWorkingCopy(); + } + + System.out.println(problems); + assertTrue(problems.isEmpty()); + } +} diff --git a/test/eclipse/src/lombok/eclipse/edit/SelectTest.java b/test/eclipse/src/lombok/eclipse/edit/SelectTest.java index 9f348a0c12..a972361893 100644 --- a/test/eclipse/src/lombok/eclipse/edit/SelectTest.java +++ b/test/eclipse/src/lombok/eclipse/edit/SelectTest.java @@ -1,3 +1,24 @@ +/* + * Copyright (C) 2022 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.eclipse.edit; import static org.junit.Assert.assertEquals; diff --git a/test/eclipse/src/lombok/eclipse/refactoring/ExtractInterfaceTest.java b/test/eclipse/src/lombok/eclipse/refactoring/ExtractInterfaceTest.java index d4c892f3d4..1ad64398b5 100644 --- a/test/eclipse/src/lombok/eclipse/refactoring/ExtractInterfaceTest.java +++ b/test/eclipse/src/lombok/eclipse/refactoring/ExtractInterfaceTest.java @@ -1,3 +1,24 @@ +/* + * Copyright (C) 2022 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.eclipse.refactoring; import static lombok.eclipse.RefactoringUtils.performRefactoring; diff --git a/test/eclipse/src/lombok/eclipse/refactoring/InlineTest.java b/test/eclipse/src/lombok/eclipse/refactoring/InlineTest.java index 1a3315b76d..25a21d6226 100644 --- a/test/eclipse/src/lombok/eclipse/refactoring/InlineTest.java +++ b/test/eclipse/src/lombok/eclipse/refactoring/InlineTest.java @@ -1,3 +1,24 @@ +/* + * Copyright (C) 2023 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.eclipse.refactoring; import static lombok.eclipse.RefactoringUtils.performRefactoring; diff --git a/test/eclipse/src/lombok/eclipse/refactoring/RenameTest.java b/test/eclipse/src/lombok/eclipse/refactoring/RenameTest.java index 8ce4874c71..7f085f08b3 100644 --- a/test/eclipse/src/lombok/eclipse/refactoring/RenameTest.java +++ b/test/eclipse/src/lombok/eclipse/refactoring/RenameTest.java @@ -1,3 +1,24 @@ +/* + * Copyright (C) 2022-2023 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.eclipse.refactoring; import static lombok.eclipse.RefactoringUtils.performRefactoring; diff --git a/test/eclipse/src/lombok/eclipse/references/FindReferencesTest.java b/test/eclipse/src/lombok/eclipse/references/FindReferencesTest.java index a4668088bc..e2806ea357 100644 --- a/test/eclipse/src/lombok/eclipse/references/FindReferencesTest.java +++ b/test/eclipse/src/lombok/eclipse/references/FindReferencesTest.java @@ -1,3 +1,24 @@ +/* + * Copyright (C) 2023 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.eclipse.references; import static org.junit.Assert.*;