Lines 486-525
Link Here
|
486 |
* Ensure that package level annotation is evaluated during AST creation. |
486 |
* Ensure that package level annotation is evaluated during AST creation. |
487 |
*/ |
487 |
*/ |
488 |
public void testDeprecatedFlag10() throws CoreException { |
488 |
public void testDeprecatedFlag10() throws CoreException { |
489 |
createFolder("/P/src/p2"); |
489 |
try { |
490 |
|
490 |
createFolder("/P/src/p2"); |
491 |
createFile( |
|
|
492 |
"/P/src/p2/package-info.java", |
493 |
"@java.lang.Deprecated package p2;\n" |
494 |
); |
495 |
|
491 |
|
496 |
// workaround for missing type in jclMin: |
492 |
createFile( |
497 |
createFolder("/P/src/java/lang"); |
493 |
"/P/src/p2/package-info.java", |
498 |
createFile( |
494 |
"@java.lang.Deprecated package p2;\n" |
499 |
"/P/src/java/lang/Deprecated.java", |
495 |
); |
500 |
"package java.lang;\n" + |
496 |
|
501 |
"@Retention(RetentionPolicy.RUNTIME)\n" + |
497 |
// workaround for missing type in jclMin: |
502 |
"public @interface Deprecated {\n" + |
498 |
createFolder("/P/src/java/lang"); |
503 |
"}\n" |
499 |
createFile( |
504 |
); |
500 |
"/P/src/java/lang/Deprecated.java", |
|
|
501 |
"package java.lang;\n" + |
502 |
"@Retention(RetentionPolicy.RUNTIME)\n" + |
503 |
"public @interface Deprecated {\n" + |
504 |
"}\n" |
505 |
); |
506 |
|
507 |
createFile("/P/src/p2/C.java", |
508 |
"package p2;\n" + |
509 |
"public class C {}\n"); |
510 |
|
511 |
createFile("/P/src/p/D.java", |
512 |
"package p;\n" + |
513 |
"public class D extends p2.C {}\n"); |
514 |
ICompilationUnit cuD = getCompilationUnit("/P/src/p/D.java"); |
515 |
|
516 |
ASTParser parser = ASTParser.newParser(AST.JLS3); |
517 |
parser.setProject(this.testProject); |
518 |
parser.setSource(cuD); |
519 |
parser.setResolveBindings(true); |
520 |
org.eclipse.jdt.core.dom.CompilationUnit cuAST = (org.eclipse.jdt.core.dom.CompilationUnit) parser.createAST(null); |
521 |
IProblem[] problems = cuAST.getProblems(); |
522 |
assertEquals("Should have 1 problem", 1, problems.length); |
523 |
assertEquals("Should have a deprecation warning", "The type C is deprecated", problems[0].getMessage()); |
524 |
} finally { |
525 |
deleteFile("/P/src/p/D.java"); |
526 |
deleteFolder("/P/src/p2"); |
527 |
deleteFolder("/P/src/java/lang"); |
528 |
} |
529 |
} |
505 |
|
530 |
|
506 |
createFile("/P/src/p2/C.java", |
531 |
/* |
507 |
"package p2;\n" + |
532 |
* Bug 337868 - [compiler][model] incomplete support for package-info.java when using SearchableEnvironment |
508 |
"public class C {}\n"); |
533 |
* Ensure that package level annotation is evaluated during AST creation. |
|
|
534 |
* a working copy for package-info exists and must be used. |
535 |
*/ |
536 |
public void testDeprecatedFlag11() throws CoreException { |
537 |
try { |
538 |
createFolder("/P/src/p2"); |
509 |
|
539 |
|
510 |
createFile("/P/src/p/D.java", |
540 |
createFile( |
511 |
"package p;\n" + |
541 |
"/P/src/p2/package-info.java", |
512 |
"public class D extends p2.C {}\n"); |
542 |
"@java.lang.Deprecated package p2;\n" |
513 |
ICompilationUnit cuD = getCompilationUnit("/P/src/p/D.java"); |
543 |
); |
|
|
544 |
WorkingCopyOwner myWCOwner = newWorkingCopyOwner(null); |
545 |
getCompilationUnit("/P/src/p2/package-info.java").getWorkingCopy(myWCOwner, null); |
546 |
|
547 |
|
548 |
// workaround for missing type in jclMin: |
549 |
createFolder("/P/src/java/lang"); |
550 |
createFile( |
551 |
"/P/src/java/lang/Deprecated.java", |
552 |
"package java.lang;\n" + |
553 |
"@Retention(RetentionPolicy.RUNTIME)\n" + |
554 |
"public @interface Deprecated {\n" + |
555 |
"}\n" |
556 |
); |
557 |
|
558 |
createFile("/P/src/p2/C.java", |
559 |
"package p2;\n" + |
560 |
"public class C {}\n"); |
514 |
|
561 |
|
515 |
ASTParser parser = ASTParser.newParser(AST.JLS3); |
562 |
createFile("/P/src/p/D.java", |
516 |
parser.setProject(this.testProject); |
563 |
"package p;\n" + |
517 |
parser.setSource(cuD); |
564 |
"public class D extends p2.C {}\n"); |
518 |
parser.setResolveBindings(true); |
565 |
ICompilationUnit cuD = getCompilationUnit("/P/src/p/D.java"); |
519 |
org.eclipse.jdt.core.dom.CompilationUnit cuAST = (org.eclipse.jdt.core.dom.CompilationUnit) parser.createAST(null); |
566 |
|
520 |
IProblem[] problems = cuAST.getProblems(); |
567 |
ASTParser parser = ASTParser.newParser(AST.JLS3); |
521 |
assertEquals("Should have 1 problem", 1, problems.length); |
568 |
parser.setWorkingCopyOwner(myWCOwner); |
522 |
assertEquals("Should have a deprecation warning", "The type C is deprecated", problems[0].getMessage()); |
569 |
parser.setProject(this.testProject); |
|
|
570 |
parser.setSource(cuD); |
571 |
parser.setResolveBindings(true); |
572 |
org.eclipse.jdt.core.dom.CompilationUnit cuAST = (org.eclipse.jdt.core.dom.CompilationUnit) parser.createAST(null); |
573 |
IProblem[] problems = cuAST.getProblems(); |
574 |
assertEquals("Should have 1 problem", 1, problems.length); |
575 |
assertEquals("Should have a deprecation warning", "The type C is deprecated", problems[0].getMessage()); |
576 |
} finally { |
577 |
deleteFile("/P/src/p/D.java"); |
578 |
deleteFolder("/P/src/p2"); |
579 |
deleteFolder("/P/src/java/lang"); |
580 |
} |
523 |
} |
581 |
} |
524 |
/* |
582 |
/* |
525 |
* Ensures that the primary type of a cu can be found. |
583 |
* Ensures that the primary type of a cu can be found. |