Lines 69-75
Link Here
|
69 |
import org.eclipse.jdt.core.search.TypeReferenceMatch; |
69 |
import org.eclipse.jdt.core.search.TypeReferenceMatch; |
70 |
import org.eclipse.jdt.core.tests.util.Util; |
70 |
import org.eclipse.jdt.core.tests.util.Util; |
71 |
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; |
71 |
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; |
72 |
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; |
|
|
73 |
import org.eclipse.jdt.internal.core.ClassFile; |
72 |
import org.eclipse.jdt.internal.core.ClassFile; |
74 |
import org.eclipse.jdt.internal.core.JavaModelManager; |
73 |
import org.eclipse.jdt.internal.core.JavaModelManager; |
75 |
import org.eclipse.jdt.internal.core.SourceMethod; |
74 |
import org.eclipse.jdt.internal.core.SourceMethod; |
Lines 11581-11589
Link Here
|
11581 |
*/ |
11580 |
*/ |
11582 |
public void testBug286379c() throws CoreException { |
11581 |
public void testBug286379c() throws CoreException { |
11583 |
class TestResourceChangeListener implements IResourceChangeListener { |
11582 |
class TestResourceChangeListener implements IResourceChangeListener { |
11584 |
boolean valid = false; |
11583 |
boolean toRemPresent = false; |
11585 |
public void resourceChanged(IResourceChangeEvent event) { |
11584 |
public void resourceChanged(IResourceChangeEvent event) { |
11586 |
this.valid = validate(event.getDelta()); |
11585 |
this.toRemPresent = validate(event.getDelta()); |
11587 |
} |
11586 |
} |
11588 |
/* |
11587 |
/* |
11589 |
* Ensure that the listener receives a delta concerning the resource |
11588 |
* Ensure that the listener receives a delta concerning the resource |
Lines 11606-11622
Link Here
|
11606 |
return false; |
11605 |
return false; |
11607 |
} |
11606 |
} |
11608 |
} |
11607 |
} |
11609 |
// print statement to debug random failures of this test |
|
|
11610 |
JavaModelManager.DEBUG_302850 = true; |
11611 |
System.out.println("================================================================================"); |
11612 |
System.out.println("Starting test JavaSearchBugTests.testBug286379c()..."); |
11613 |
System.out.println(" - Default Options at test start:"); |
11614 |
System.out.println(Util.indentString(new CompilerOptions(JavaCore.getDefaultOptions()).toString(), 1)); |
11615 |
System.out.println(" - Options at test start:"); |
11616 |
System.out.println(" + Task tags: " + JavaCore.getOption(JavaCore.COMPILER_TASK_TAGS)); |
11617 |
System.out.println(" + Task priorities: " + JavaCore.getOption(JavaCore.COMPILER_TASK_PRIORITIES)); |
11618 |
System.out.println(" + Forbidden reference: " + JavaCore.getOption(JavaCore.COMPILER_PB_FORBIDDEN_REFERENCE)); |
11619 |
System.out.println(Util.indentString(new CompilerOptions(JavaCore.getOptions()).toString(), 2)); |
11620 |
|
11608 |
|
11621 |
IContentType javaContentType = Platform.getContentTypeManager().getContentType(JavaCore.JAVA_SOURCE_CONTENT_TYPE); |
11609 |
IContentType javaContentType = Platform.getContentTypeManager().getContentType(JavaCore.JAVA_SOURCE_CONTENT_TYPE); |
11622 |
TestResourceChangeListener changeListener = new TestResourceChangeListener(); |
11610 |
TestResourceChangeListener changeListener = new TestResourceChangeListener(); |
Lines 11646-11652
Link Here
|
11646 |
// fail as we don't get any specific event from the platform to refresh the indexes. |
11634 |
// fail as we don't get any specific event from the platform to refresh the indexes. |
11647 |
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=118619 |
11635 |
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=118619 |
11648 |
int counter = 0; |
11636 |
int counter = 0; |
11649 |
while (!changeListener.valid) { |
11637 |
while (!changeListener.toRemPresent) { |
11650 |
try { |
11638 |
try { |
11651 |
Thread.sleep(100); |
11639 |
Thread.sleep(100); |
11652 |
} |
11640 |
} |
Lines 11659-11679
Link Here
|
11659 |
// Wait to be sure that indexes are ready after the new resource was added |
11647 |
// Wait to be sure that indexes are ready after the new resource was added |
11660 |
waitUntilIndexesReady(); |
11648 |
waitUntilIndexesReady(); |
11661 |
|
11649 |
|
11662 |
// print statement to debug random failures of this test |
|
|
11663 |
System.out.println(" - Options before first exit:"); |
11664 |
System.out.println(" + Task tags: " + JavaCore.getOption(JavaCore.COMPILER_TASK_TAGS)); |
11665 |
System.out.println(" + Task priorities: " + JavaCore.getOption(JavaCore.COMPILER_TASK_PRIORITIES)); |
11666 |
System.out.println(" + Forbidden reference: " + JavaCore.getOption(JavaCore.COMPILER_PB_FORBIDDEN_REFERENCE)); |
11667 |
System.out.println(Util.indentString(new CompilerOptions(JavaCore.getOptions()).toString(), 2)); |
11668 |
// Restart to let the indexes to be refreshed |
11650 |
// Restart to let the indexes to be refreshed |
11669 |
simulateExit(); |
11651 |
simulateExit(); |
11670 |
simulateRestart(); |
11652 |
simulateRestart(); |
11671 |
// print statement to debug random failures of this test |
|
|
11672 |
System.out.println(" - Options after first restart:"); |
11673 |
System.out.println(" + Task tags: " + JavaCore.getOption(JavaCore.COMPILER_TASK_TAGS)); |
11674 |
System.out.println(" + Task priorities: " + JavaCore.getOption(JavaCore.COMPILER_TASK_PRIORITIES)); |
11675 |
System.out.println(" + Forbidden reference: " + JavaCore.getOption(JavaCore.COMPILER_PB_FORBIDDEN_REFERENCE)); |
11676 |
System.out.println(Util.indentString(new CompilerOptions(JavaCore.getOptions()).toString(), 2)); |
11677 |
waitUntilIndexesReady(); |
11653 |
waitUntilIndexesReady(); |
11678 |
|
11654 |
|
11679 |
// Search for the new type with new extension |
11655 |
// Search for the new type with new extension |
Lines 11691-11712
Link Here
|
11691 |
false /*only assume*/); |
11667 |
false /*only assume*/); |
11692 |
|
11668 |
|
11693 |
// Delete the file specification |
11669 |
// Delete the file specification |
|
|
11670 |
changeListener.toRemPresent = true; |
11694 |
javaContentType.removeFileSpec("torem", IContentType.FILE_EXTENSION_SPEC); |
11671 |
javaContentType.removeFileSpec("torem", IContentType.FILE_EXTENSION_SPEC); |
|
|
11672 |
counter = 0; |
11673 |
while (changeListener.toRemPresent) { |
11674 |
try { |
11675 |
Thread.sleep(100); |
11676 |
} |
11677 |
catch (InterruptedException ie) { |
11678 |
// skip |
11679 |
} |
11680 |
assertTrue("We should have got a resource event within a 10s delay!", counter++ < 100); |
11681 |
} |
11682 |
waitUntilIndexesReady(); |
11695 |
|
11683 |
|
11696 |
// print statement to debug random failures of this test |
|
|
11697 |
System.out.println(" - Options before second exit:"); |
11698 |
System.out.println(" + Task tags: " + JavaCore.getOption(JavaCore.COMPILER_TASK_TAGS)); |
11699 |
System.out.println(" + Task priorities: " + JavaCore.getOption(JavaCore.COMPILER_TASK_PRIORITIES)); |
11700 |
System.out.println(" + Forbidden reference: " + JavaCore.getOption(JavaCore.COMPILER_PB_FORBIDDEN_REFERENCE)); |
11701 |
System.out.println(Util.indentString(new CompilerOptions(JavaCore.getOptions()).toString(), 2)); |
11702 |
// Restarting should update the index file to remove the references of any .torem files |
11684 |
// Restarting should update the index file to remove the references of any .torem files |
11703 |
simulateExit(); |
11685 |
simulateExit(); |
11704 |
simulateRestart(); |
11686 |
simulateRestart(); |
11705 |
// print statement to debug random failures of this test |
|
|
11706 |
System.out.println(" - Options after second restart:"); |
11707 |
System.out.println(" + Task tags: " + JavaCore.getOption(JavaCore.COMPILER_TASK_TAGS)); |
11708 |
System.out.println(" + Task priorities: " + JavaCore.getOption(JavaCore.COMPILER_TASK_PRIORITIES)); |
11709 |
System.out.println(" + Forbidden reference: " + JavaCore.getOption(JavaCore.COMPILER_PB_FORBIDDEN_REFERENCE)); |
11710 |
waitUntilIndexesReady(); |
11687 |
waitUntilIndexesReady(); |
11711 |
|
11688 |
|
11712 |
// Search for the new type with new extension |
11689 |
// Search for the new type with new extension |
Lines 11719-11742
Link Here
|
11719 |
IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, |
11696 |
IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, |
11720 |
null); |
11697 |
null); |
11721 |
assertSearchResults("No search results expected", "", collector); |
11698 |
assertSearchResults("No search results expected", "", collector); |
11722 |
System.out.println(" - Options after search:"); |
|
|
11723 |
System.out.println(" + Task tags: " + JavaCore.getOption(JavaCore.COMPILER_TASK_TAGS)); |
11724 |
System.out.println(" + Task priorities: " + JavaCore.getOption(JavaCore.COMPILER_TASK_PRIORITIES)); |
11725 |
System.out.println(" + Forbidden reference: " + JavaCore.getOption(JavaCore.COMPILER_PB_FORBIDDEN_REFERENCE)); |
11726 |
System.out.println(Util.indentString(new CompilerOptions(JavaCore.getOptions()).toString(), 2)); |
11727 |
} finally { |
11699 |
} finally { |
11728 |
getWorkspace().removeResourceChangeListener(changeListener); |
11700 |
getWorkspace().removeResourceChangeListener(changeListener); |
11729 |
if (javaContentType != null) |
11701 |
if (javaContentType != null) |
11730 |
javaContentType.removeFileSpec("torem", IContentType.FILE_EXTENSION_SPEC); |
11702 |
javaContentType.removeFileSpec("torem", IContentType.FILE_EXTENSION_SPEC); |
11731 |
deleteProject("P"); |
11703 |
deleteProject("P"); |
11732 |
System.out.println(" - Options at test end:"); |
|
|
11733 |
System.out.println(" + Task tags: " + JavaCore.getOption(JavaCore.COMPILER_TASK_TAGS)); |
11734 |
System.out.println(" + Task priorities: " + JavaCore.getOption(JavaCore.COMPILER_TASK_PRIORITIES)); |
11735 |
System.out.println(" + Forbidden reference: " + JavaCore.getOption(JavaCore.COMPILER_PB_FORBIDDEN_REFERENCE)); |
11736 |
System.out.println(Util.indentString(new CompilerOptions(JavaCore.getOptions()).toString(), 2)); |
11737 |
System.out.println(" - Default Options at test end:"); |
11738 |
System.out.println(Util.indentString(new CompilerOptions(JavaCore.getDefaultOptions()).toString(), 2)); |
11739 |
JavaModelManager.DEBUG_302850 = false; |
11740 |
} |
11704 |
} |
11741 |
} |
11705 |
} |
11742 |
|
11706 |
|