mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-15 10:15:19 +00:00
Support @Delegate in eclipse 2024-03
This commit is contained in:
1 parent
98cdf67ed6
commit
3b20b70363
6 files changed
+112
-6
No files matched your search
@@ -0,0 +1,9 @@
|
||||
package pkg;
|
||||
|
||||
import lombok.experimental.Delegate;
|
||||
|
||||
public class DelegateModel {
|
||||
|
||||
@Delegate
|
||||
private Runnable run;
|
||||
}
|
||||
@@ -28,6 +28,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.misc.DelegateTest;
|
||||
import lombok.eclipse.misc.JavadocTest;
|
||||
import lombok.eclipse.refactoring.ExtractInterfaceTest;
|
||||
import lombok.eclipse.refactoring.InlineTest;
|
||||
@@ -35,7 +36,7 @@ import lombok.eclipse.refactoring.RenameTest;
|
||||
import lombok.eclipse.references.FindReferencesTest;
|
||||
|
||||
@RunWith(Suite.class)
|
||||
@SuiteClasses({ExtractInterfaceTest.class, RenameTest.class, SelectTest.class, CleanupTest.class, FindReferencesTest.class, InlineTest.class, NoErrorsTest.class, JavadocTest.class})
|
||||
@SuiteClasses({ExtractInterfaceTest.class, RenameTest.class, SelectTest.class, CleanupTest.class, FindReferencesTest.class, InlineTest.class, NoErrorsTest.class, JavadocTest.class, DelegateTest.class})
|
||||
public class EclipseTests {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* 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.misc;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.eclipse.jdt.core.ICompilationUnit;
|
||||
import org.eclipse.jdt.core.IMethod;
|
||||
import org.eclipse.jdt.core.ISourceRange;
|
||||
import org.eclipse.jdt.core.WorkingCopyOwner;
|
||||
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 DelegateTest {
|
||||
|
||||
@Rule
|
||||
public SetupSingleFileTest setup = new SetupSingleFileTest();
|
||||
|
||||
@Test
|
||||
public void model() throws Exception {
|
||||
ICompilationUnit cu = setup.getPackageFragment().getCompilationUnit("DelegateModel.java");
|
||||
|
||||
WorkingCopyOwner workingCopyOwner = new WorkingCopyOwner() {};
|
||||
ICompilationUnit workingCopy = cu.getWorkingCopy(workingCopyOwner, null);
|
||||
try {
|
||||
workingCopy.reconcile(ICompilationUnit.NO_AST, true, true, workingCopy.getOwner(), null);
|
||||
|
||||
assertThat(workingCopy.findPrimaryType().getMethods().length, is(not(0)));
|
||||
|
||||
IMethod runMethod = workingCopy.findPrimaryType().getMethods()[0];
|
||||
assertEquals(runMethod.getElementName(), "run");
|
||||
|
||||
ISourceRange sourceRange = runMethod.getSourceRange();
|
||||
assertNotNull(sourceRange);
|
||||
assertEquals(sourceRange.getOffset(), 84);
|
||||
assertEquals(sourceRange.getLength(), 9);
|
||||
} finally {
|
||||
workingCopy.discardWorkingCopy();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user