mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-14 10:18:46 +00:00
Merge pull request #3726 from Rawi01/npe-builder-javadoc
Add null check for compilation unit
This commit is contained in:
4 files changed
+37
-2
No files matched your search
@@ -2843,6 +2843,7 @@ public class EclipseHandlerUtil {
|
||||
if (doc == null) return;
|
||||
|
||||
ICompilationUnit compilationUnit = cud.compilationResult.compilationUnit;
|
||||
if (compilationUnit == null) return;
|
||||
if (compilationUnit.getClass().equals(COMPILATION_UNIT)) {
|
||||
try {
|
||||
compilationUnit = (ICompilationUnit) Permit.invoke(COMPILATION_UNIT_ORIGINAL_FROM_CLONE, compilationUnit);
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package pkg;
|
||||
|
||||
import lombok.Builder;
|
||||
|
||||
@Builder
|
||||
public class BuilderJavadoc {
|
||||
/**
|
||||
* Javadoc
|
||||
*
|
||||
* @param test ABC
|
||||
* @return test
|
||||
*/
|
||||
private String test;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package pkg;
|
||||
|
||||
public class Usage {
|
||||
public void test() {
|
||||
BuilderJavadoc.builder().test("test").build();
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,7 @@ import java.util.List;
|
||||
|
||||
import org.eclipse.jdt.core.ICompilationUnit;
|
||||
import org.eclipse.jdt.core.IProblemRequestor;
|
||||
import org.eclipse.jdt.core.JavaModelException;
|
||||
import org.eclipse.jdt.core.WorkingCopyOwner;
|
||||
import org.eclipse.jdt.core.compiler.IProblem;
|
||||
import org.junit.Rule;
|
||||
@@ -47,6 +48,19 @@ public class NoErrorsTest {
|
||||
public void fieldNameConstantsInAnnotation() throws Exception {
|
||||
ICompilationUnit cu = setup.getPackageFragment().getCompilationUnit("Usage.java");
|
||||
|
||||
List<IProblem> problems = collectProblems(cu);
|
||||
assertTrue(problems.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void builderJavadoc() throws Exception {
|
||||
ICompilationUnit cu = setup.getPackageFragment().getCompilationUnit("Usage.java");
|
||||
|
||||
List<IProblem> problems = collectProblems(cu);
|
||||
assertTrue(problems.isEmpty());
|
||||
}
|
||||
|
||||
private List<IProblem> collectProblems(ICompilationUnit cu) throws JavaModelException {
|
||||
final List<IProblem> problems = new ArrayList<IProblem>();
|
||||
final IProblemRequestor requestor = new IProblemRequestor() {
|
||||
@Override
|
||||
@@ -83,7 +97,6 @@ public class NoErrorsTest {
|
||||
workingCopy.discardWorkingCopy();
|
||||
}
|
||||
|
||||
System.out.println(problems);
|
||||
assertTrue(problems.isEmpty());
|
||||
return problems;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user