Lines 22-29
import org.eclipse.core.resources.IFile;
Link Here
|
22 |
import org.eclipse.core.runtime.CoreException; |
22 |
import org.eclipse.core.runtime.CoreException; |
23 |
import org.eclipse.core.runtime.FileLocator; |
23 |
import org.eclipse.core.runtime.FileLocator; |
24 |
import org.eclipse.core.runtime.Platform; |
24 |
import org.eclipse.core.runtime.Platform; |
|
|
25 |
import org.eclipse.jdt.core.ICompilationUnit; |
25 |
import org.eclipse.jdt.core.IJavaProject; |
26 |
import org.eclipse.jdt.core.IJavaProject; |
26 |
import org.eclipse.jdt.core.JavaCore; |
27 |
import org.eclipse.jdt.core.JavaCore; |
|
|
28 |
import org.eclipse.jdt.core.compiler.IProblem; |
29 |
import org.eclipse.jdt.core.dom.AST; |
30 |
import org.eclipse.jdt.core.dom.ASTParser; |
31 |
import org.eclipse.jdt.core.dom.CompilationUnit; |
27 |
|
32 |
|
28 |
public class NullAnnotationModelTests extends ReconcilerTests { |
33 |
public class NullAnnotationModelTests extends ReconcilerTests { |
29 |
|
34 |
|
Lines 222-225
public class NullAnnotationModelTests extends ReconcilerTests {
Link Here
|
222 |
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=302850#c25 |
227 |
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=302850#c25 |
223 |
} |
228 |
} |
224 |
} |
229 |
} |
|
|
230 |
|
231 |
public void testMissingAnnotation3() throws CoreException { |
232 |
try { |
233 |
// Resources creation |
234 |
IJavaProject p = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB", this.ANNOTATION_LIB}, "bin", "1.5"); |
235 |
p.setOption(JavaCore.COMPILER_ANNOTATION_NULL_ANALYSIS, JavaCore.ENABLED); |
236 |
p.setOption(JavaCore.COMPILER_NONNULL_ANNOTATION_NAME, "invalid"); |
237 |
|
238 |
this.createFolder("/P/p1"); |
239 |
String c1SourceString = |
240 |
"package p1;\n" + |
241 |
"@org.eclipse.jdt.annotation.NonNullByDefault\n" + |
242 |
"public class C1 {\n" + |
243 |
" public String foo(Object arg) {\n" + |
244 |
" return arg == null ? \"\" : arg.toString();\n" + |
245 |
" }\n" + |
246 |
"}\n"; |
247 |
this.createFile( |
248 |
"/P/p1/C1.java", |
249 |
c1SourceString); |
250 |
|
251 |
this.problemRequestor.initialize(c1SourceString.toCharArray()); |
252 |
|
253 |
final ICompilationUnit unit = getCompilationUnit("/P/p1/C1.java").getWorkingCopy(this.wcOwner, null); |
254 |
assertProblems("Unexpected problems", |
255 |
"----------\n" + |
256 |
"1. ERROR in /P/p1/C1.java (at line 0)\n" + |
257 |
" package p1;\n" + |
258 |
" ^\n" + |
259 |
"Cannot use the unqualified name \'invalid\' as an annotation name for null specification\n" + |
260 |
"----------\n"); |
261 |
|
262 |
ASTParser parser = ASTParser.newParser(AST.JLS4); |
263 |
parser.setProject(p); |
264 |
parser.setResolveBindings(true); |
265 |
parser.setSource(unit); |
266 |
CompilationUnit ast = (CompilationUnit) parser.createAST(null); |
267 |
assertNotNull("ast should not be null", ast); |
268 |
this.problemRequestor.reset(); |
269 |
this.problemRequestor.beginReporting(); |
270 |
IProblem[] problems = ast.getProblems(); |
271 |
for (int i=0; i<problems.length; i++) |
272 |
this.problemRequestor.acceptProblem(problems[i]); |
273 |
assertProblems("Unexpected problems (2)", |
274 |
"----------\n" + |
275 |
"1. ERROR (at line 0)\n" + |
276 |
" package p1;\n" + |
277 |
" ^\n" + |
278 |
"Cannot use the unqualified name \'invalid\' as an annotation name for null specification\n" + |
279 |
"----------\n"); |
280 |
} finally { |
281 |
deleteProject("P"); |
282 |
} |
283 |
} |
225 |
} |
284 |
} |