Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add null check for compilation unit #3726

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -2838,6 +2838,7 @@ public static void setDocComment(CompilationUnitDeclaration cud, TypeDeclaration
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);
Expand Down
14 changes: 14 additions & 0 deletions test/eclipse/resource/noerrors/builderJavadoc/BuilderJavadoc.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package pkg;

import lombok.Builder;

@Builder
public class BuilderJavadoc {
/**
* Javadoc
*
* @param test ABC
* @return test
*/
private String test;
}
7 changes: 7 additions & 0 deletions test/eclipse/resource/noerrors/builderJavadoc/Usage.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package pkg;

public class Usage {
public void test() {
BuilderJavadoc.builder().test("test").build();
}
}
17 changes: 15 additions & 2 deletions test/eclipse/src/lombok/eclipse/compile/NoErrorsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

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;
Expand All @@ -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
Expand Down Expand Up @@ -83,7 +97,6 @@ public IProblemRequestor getProblemRequestor(ICompilationUnit workingCopy) {
workingCopy.discardWorkingCopy();
}

System.out.println(problems);
assertTrue(problems.isEmpty());
return problems;
}
}
Loading