Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAtaul Ahmad2017-07-17 15:11:47 -0400
committerAlexander Kurtakov2017-07-18 02:50:53 -0400
commit87a89a1a9f0e2a2845c59de13a43807d8c093938 (patch)
tree12a3251edf39d764a5a53a725850a605a07569ca
parent3e47faa229a8e5a2cadb0f5b9c853ed0c6981448 (diff)
downloadeclipse.platform.text-87a89a1a9f0e2a2845c59de13a43807d8c093938.tar.gz
eclipse.platform.text-87a89a1a9f0e2a2845c59de13a43807d8c093938.tar.xz
eclipse.platform.text-87a89a1a9f0e2a2845c59de13a43807d8c093938.zip
Bug 519786 - Remove trailing whitespace from org.,eclipse.search.tests
(edit) Change-Id: I642fe5cc8e95b173658a5b66cd7bf71385c2cee8 Signed-off-by: Ataul Ahmad <ataul@ahmadsoft.de>
-rw-r--r--org.eclipse.search.tests/.settings/org.eclipse.jdt.core.prefs19
-rw-r--r--org.eclipse.search.tests/.settings/org.eclipse.jdt.ui.prefs60
-rw-r--r--org.eclipse.search.tests/src/org/eclipse/search/core/tests/LineConversionTest.java10
-rw-r--r--org.eclipse.search.tests/src/org/eclipse/search/core/tests/LongQuery.java8
-rw-r--r--org.eclipse.search.tests/src/org/eclipse/search/core/tests/NullQuery.java2
-rw-r--r--org.eclipse.search.tests/src/org/eclipse/search/core/tests/QueryManagerTest.java2
-rw-r--r--org.eclipse.search.tests/src/org/eclipse/search/core/tests/TestSearchResult.java76
-rw-r--r--org.eclipse.search.tests/src/org/eclipse/search/tests/FileTool.java32
-rw-r--r--org.eclipse.search.tests/src/org/eclipse/search/tests/ResourceHelper.java40
-rw-r--r--org.eclipse.search.tests/src/org/eclipse/search/tests/SearchTestPlugin.java4
-rw-r--r--org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/AnnotationManagerTest.java16
-rw-r--r--org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/FileCharSequenceTests.java34
-rw-r--r--org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/FileSearchTests.java90
-rw-r--r--org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/JUnitSourceSetup.java12
-rw-r--r--org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/LineAnnotationManagerTest.java12
-rw-r--r--org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/LineBasedFileSearch.java24
-rw-r--r--org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/PositionTrackerTest.java10
-rw-r--r--org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/ResultUpdaterTest.java14
-rw-r--r--org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/SearchResultPageTest.java22
-rw-r--r--org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/SortingTest.java14
20 files changed, 289 insertions, 212 deletions
diff --git a/org.eclipse.search.tests/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.search.tests/.settings/org.eclipse.jdt.core.prefs
index fae2809a8..8a1816977 100644
--- a/org.eclipse.search.tests/.settings/org.eclipse.jdt.core.prefs
+++ b/org.eclipse.search.tests/.settings/org.eclipse.jdt.core.prefs
@@ -133,6 +133,7 @@ org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=warning
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
org.eclipse.jdt.core.compiler.source=1.8
+org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
@@ -146,8 +147,10 @@ org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=48
org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0
org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
+org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0
org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0
org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
+org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80
@@ -157,6 +160,8 @@ org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_type_arguments=0
+org.eclipse.jdt.core.formatter.alignment_for_type_parameters=0
org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16
org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
org.eclipse.jdt.core.formatter.blank_lines_after_package=1
@@ -183,6 +188,7 @@ org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false
+org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position=false
org.eclipse.jdt.core.formatter.comment.format_block_comments=false
org.eclipse.jdt.core.formatter.comment.format_header=false
org.eclipse.jdt.core.formatter.comment.format_html=true
@@ -215,6 +221,7 @@ org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true
org.eclipse.jdt.core.formatter.indentation.size=4
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert
@@ -409,12 +416,24 @@ org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=true
org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=true
org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=3
+org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause=common_lines
org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
org.eclipse.jdt.core.formatter.tabulation.char=tab
org.eclipse.jdt.core.formatter.tabulation.size=4
org.eclipse.jdt.core.formatter.use_on_off_tags=false
org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
+org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false
org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
+org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true
org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true
org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true
org.eclipse.jdt.core.incompatibleJDKLevel=ignore
diff --git a/org.eclipse.search.tests/.settings/org.eclipse.jdt.ui.prefs b/org.eclipse.search.tests/.settings/org.eclipse.jdt.ui.prefs
index b73bfac6f..9a40de191 100644
--- a/org.eclipse.search.tests/.settings/org.eclipse.jdt.ui.prefs
+++ b/org.eclipse.search.tests/.settings/org.eclipse.jdt.ui.prefs
@@ -1,6 +1,7 @@
eclipse.preferences.version=1
+editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
formatter_profile=_JDT UI Code Style Conventions
-formatter_settings_version=12
+formatter_settings_version=13
org.eclipse.jdt.ui.exception.name=e
org.eclipse.jdt.ui.gettersetter.use.is=true
org.eclipse.jdt.ui.ignorelowercasenames=true
@@ -9,3 +10,60 @@ org.eclipse.jdt.ui.keywordthis=false
org.eclipse.jdt.ui.ondemandthreshold=99
org.eclipse.jdt.ui.overrideannotation=true
org.eclipse.jdt.ui.staticondemandthreshold=99
+sp_cleanup.add_default_serial_version_id=true
+sp_cleanup.add_generated_serial_version_id=false
+sp_cleanup.add_missing_annotations=true
+sp_cleanup.add_missing_deprecated_annotations=true
+sp_cleanup.add_missing_methods=false
+sp_cleanup.add_missing_nls_tags=false
+sp_cleanup.add_missing_override_annotations=true
+sp_cleanup.add_missing_override_annotations_interface_methods=true
+sp_cleanup.add_serial_version_id=false
+sp_cleanup.always_use_blocks=true
+sp_cleanup.always_use_parentheses_in_expressions=false
+sp_cleanup.always_use_this_for_non_static_field_access=false
+sp_cleanup.always_use_this_for_non_static_method_access=false
+sp_cleanup.convert_functional_interfaces=false
+sp_cleanup.convert_to_enhanced_for_loop=false
+sp_cleanup.correct_indentation=false
+sp_cleanup.format_source_code=true
+sp_cleanup.format_source_code_changes_only=true
+sp_cleanup.insert_inferred_type_arguments=false
+sp_cleanup.make_local_variable_final=true
+sp_cleanup.make_parameters_final=false
+sp_cleanup.make_private_fields_final=true
+sp_cleanup.make_type_abstract_if_missing_method=false
+sp_cleanup.make_variable_declarations_final=false
+sp_cleanup.never_use_blocks=false
+sp_cleanup.never_use_parentheses_in_expressions=true
+sp_cleanup.on_save_use_additional_actions=true
+sp_cleanup.organize_imports=true
+sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
+sp_cleanup.remove_private_constructors=true
+sp_cleanup.remove_redundant_type_arguments=false
+sp_cleanup.remove_trailing_whitespaces=true
+sp_cleanup.remove_trailing_whitespaces_all=true
+sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
+sp_cleanup.remove_unnecessary_casts=false
+sp_cleanup.remove_unnecessary_nls_tags=false
+sp_cleanup.remove_unused_imports=false
+sp_cleanup.remove_unused_local_variables=false
+sp_cleanup.remove_unused_private_fields=true
+sp_cleanup.remove_unused_private_members=false
+sp_cleanup.remove_unused_private_methods=true
+sp_cleanup.remove_unused_private_types=true
+sp_cleanup.sort_members=false
+sp_cleanup.sort_members_all=false
+sp_cleanup.use_anonymous_class_creation=false
+sp_cleanup.use_blocks=false
+sp_cleanup.use_blocks_only_for_return_and_throw=false
+sp_cleanup.use_lambda=true
+sp_cleanup.use_parentheses_in_expressions=false
+sp_cleanup.use_this_for_non_static_field_access=false
+sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
+sp_cleanup.use_this_for_non_static_method_access=false
+sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/core/tests/LineConversionTest.java b/org.eclipse.search.tests/src/org/eclipse/search/core/tests/LineConversionTest.java
index 21ebb12cf..822149929 100644
--- a/org.eclipse.search.tests/src/org/eclipse/search/core/tests/LineConversionTest.java
+++ b/org.eclipse.search.tests/src/org/eclipse/search/core/tests/LineConversionTest.java
@@ -36,7 +36,7 @@ import junit.framework.TestCase;
*/
public class LineConversionTest extends TestCase {
private IFile fFile;
-
+
private static final String LINE_TWO= "This is the second line\n";
private static final String LINE_ONE= "This is the first line\n";
private static final String LINE_THREE= "This is the third line";
@@ -50,7 +50,7 @@ public class LineConversionTest extends TestCase {
fFile.create(new ByteArrayInputStream(getFileContents().getBytes()), true, null);
super.setUp();
}
-
+
@Override
protected void tearDown() throws Exception {
SearchPlugin.getActivePage().closeAllEditors(false);
@@ -61,12 +61,12 @@ public class LineConversionTest extends TestCase {
private String getFileContents() {
return LINE_ONE+LINE_TWO+LINE_THREE;
}
-
+
public void testConvertToCharacter() throws Exception {
SearchTestPlugin.openTextEditor(SearchPlugin.getActivePage(), fFile);
ITextFileBuffer fb= FileBuffers.getTextFileBufferManager().getTextFileBuffer(fFile.getFullPath(), LocationKind.IFILE);
IDocument doc= fb.getDocument();
-
+
Position p1= new Position(2, 1);
Position p2= PositionTracker.convertToCharacterPosition(p1, doc);
//assertEquals(LINE_THREE, doc.get(p2.getOffset(), p2.getLength()));
@@ -87,7 +87,7 @@ public class LineConversionTest extends TestCase {
assertEquals("", doc.get(p2.getOffset(), p2.getLength()));
assertEquals(p1, PositionTracker.convertToLinePosition(p2, doc));
}
-
+
public void testBogusLines() throws Exception {
SearchTestPlugin.openTextEditor(SearchPlugin.getActivePage(), fFile);
ITextFileBuffer fb= FileBuffers.getTextFileBufferManager().getTextFileBuffer(fFile.getFullPath(), LocationKind.IFILE);
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/core/tests/LongQuery.java b/org.eclipse.search.tests/src/org/eclipse/search/core/tests/LongQuery.java
index c772f96e4..5f3cd8fa9 100644
--- a/org.eclipse.search.tests/src/org/eclipse/search/core/tests/LongQuery.java
+++ b/org.eclipse.search.tests/src/org/eclipse/search/core/tests/LongQuery.java
@@ -17,14 +17,14 @@ import org.eclipse.core.runtime.Status;
/**
*/
public class LongQuery extends NullQuery {
-
+
private boolean fIsRunning= false;
-
+
@Override
public boolean canRunInBackground() {
return true;
}
-
+
@Override
public IStatus run(IProgressMonitor monitor) {
fIsRunning= true;
@@ -38,7 +38,7 @@ public class LongQuery extends NullQuery {
fIsRunning= false;
return Status.OK_STATUS;
}
-
+
public boolean isRunning() {
return fIsRunning;
}
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/core/tests/NullQuery.java b/org.eclipse.search.tests/src/org/eclipse/search/core/tests/NullQuery.java
index d923c9a5d..1b3e6dde6 100644
--- a/org.eclipse.search.tests/src/org/eclipse/search/core/tests/NullQuery.java
+++ b/org.eclipse.search.tests/src/org/eclipse/search/core/tests/NullQuery.java
@@ -17,7 +17,7 @@ import org.eclipse.search.ui.ISearchQuery;
import org.eclipse.search.ui.ISearchResult;
public class NullQuery implements ISearchQuery {
-
+
@Override
public IStatus run(IProgressMonitor monitor) {
return null;
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/core/tests/QueryManagerTest.java b/org.eclipse.search.tests/src/org/eclipse/search/core/tests/QueryManagerTest.java
index 74b84cbdf..a88b74707 100644
--- a/org.eclipse.search.tests/src/org/eclipse/search/core/tests/QueryManagerTest.java
+++ b/org.eclipse.search.tests/src/org/eclipse/search/core/tests/QueryManagerTest.java
@@ -22,7 +22,7 @@ import org.eclipse.search.ui.NewSearchUI;
import org.eclipse.search2.internal.ui.InternalSearchUI;
public class QueryManagerTest {
-
+
@Test
public void testRemoveQuery() {
ISearchQuery query= new NullQuery();
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/core/tests/TestSearchResult.java b/org.eclipse.search.tests/src/org/eclipse/search/core/tests/TestSearchResult.java
index 6bc3e15ea..116af44d0 100644
--- a/org.eclipse.search.tests/src/org/eclipse/search/core/tests/TestSearchResult.java
+++ b/org.eclipse.search.tests/src/org/eclipse/search/core/tests/TestSearchResult.java
@@ -25,14 +25,14 @@ import org.eclipse.search.ui.text.Match;
import org.eclipse.search.ui.text.MatchEvent;
public class TestSearchResult {
-
+
@Test
public void testAddMatch() {
ISearchQuery query= new NullQuery();
AbstractTextSearchResult result= (AbstractTextSearchResult) query.getSearchResult();
-
+
String object= "object"; //$NON-NLS-1$
-
+
Match match1= new Match(object, 0, 0);
result.addMatch(match1);
assertEquals(result.getMatchCount(), 1);
@@ -47,9 +47,9 @@ public class TestSearchResult {
public void testAddMatchDifferentStart() {
ISearchQuery query= new NullQuery();
AbstractTextSearchResult result= (AbstractTextSearchResult) query.getSearchResult();
-
+
String object= "object"; //$NON-NLS-1$
-
+
Match match1= new Match(object, 2, 0);
result.addMatch(match1);
assertEquals(result.getMatchCount(), 1);
@@ -67,9 +67,9 @@ public class TestSearchResult {
public void testAddMatchDifferentStartInOrder() {
ISearchQuery query= new NullQuery();
AbstractTextSearchResult result= (AbstractTextSearchResult) query.getSearchResult();
-
+
String object= "object"; //$NON-NLS-1$
-
+
Match match1= new Match(object, 0, 0);
result.addMatch(match1);
assertEquals(result.getMatchCount(), 1);
@@ -87,9 +87,9 @@ public class TestSearchResult {
public void testAddMatchDifferentLength() {
ISearchQuery query= new NullQuery();
AbstractTextSearchResult result= (AbstractTextSearchResult) query.getSearchResult();
-
+
String object= "object"; //$NON-NLS-1$
-
+
Match match1= new Match(object, 1, 1);
result.addMatch(match1);
assertEquals(result.getMatchCount(), 1);
@@ -99,14 +99,14 @@ public class TestSearchResult {
assertTrue("matches[0]", matches[0] == match2);
assertTrue("matches[1]", matches[1] == match1);
}
-
+
@Test
public void testAddMatchOrderPreserving() {
ISearchQuery query= new NullQuery();
AbstractTextSearchResult result= (AbstractTextSearchResult) query.getSearchResult();
-
+
String object= "object"; //$NON-NLS-1$
-
+
Match match1= new Match(object, 1, 0);
result.addMatch(match1);
assertEquals(result.getMatchCount(), 1);
@@ -121,9 +121,9 @@ public class TestSearchResult {
public void testAddMatches() {
ISearchQuery query= new NullQuery();
AbstractTextSearchResult result= (AbstractTextSearchResult) query.getSearchResult();
-
+
String object= "object"; //$NON-NLS-1$
-
+
Match match1= new Match(object, 0, 0);
Match match2= new Match(object, 0, 0);
result.addMatches(new Match[] { match1, match2 });
@@ -136,47 +136,47 @@ public class TestSearchResult {
public void testRemoveMatch() {
ISearchQuery query= new NullQuery();
AbstractTextSearchResult result= (AbstractTextSearchResult) query.getSearchResult();
-
+
String object= "object"; //$NON-NLS-1$
-
+
Match match1= new Match(object, 0, 0);
result.addMatch(match1);
Match match2= new Match(object, 0, 0);
result.addMatch(match2);
assertEquals(result.getMatchCount(), 2);
-
+
result.removeMatch(match1);
assertEquals(result.getMatchCount(), 1);
result.removeMatch(match1);
assertEquals(result.getMatchCount(), 1);
-
+
}
-
+
@Test
public void testRemoveMatches() {
ISearchQuery query= new NullQuery();
AbstractTextSearchResult result= (AbstractTextSearchResult) query.getSearchResult();
-
+
String object= "object"; //$NON-NLS-1$
-
+
Match match1= new Match(object, 0, 0);
Match match2= new Match(object, 0, 0);
result.addMatches(new Match[] { match1, match2 });
assertEquals(result.getMatchCount(), 2);
-
+
result.removeMatches(new Match[] { match1, match2 });
assertEquals(result.getMatchCount(), 0);
-
+
}
@Test
public void testMatchEvent() {
final boolean [] wasAdded= { false };
final boolean [] wasRemoved= { false };
-
+
ISearchQuery query= new NullQuery();
AbstractTextSearchResult result= (AbstractTextSearchResult) query.getSearchResult();
-
+
result.addListener(new ISearchResultListener() {
@Override
public void searchResultChanged(SearchResultEvent e) {
@@ -190,37 +190,37 @@ public class TestSearchResult {
}
}
});
-
+
String object= "object"; //$NON-NLS-1$
-
+
Match match1= new Match(object, 0, 0);
result.addMatch(match1);
assertTrue(wasAdded[0]);
wasAdded[0]= false;
result.addMatch(match1);
assertFalse(wasAdded[0]);
-
+
Match match2= new Match(object, 0, 0);
result.addMatch(match2);
assertTrue(wasAdded[0]);
wasAdded[0]= false;
-
+
result.removeMatch(match2);
assertTrue(wasRemoved[0]);
wasRemoved[0]= false;
-
+
result.removeMatch(match2);
assertFalse(wasRemoved[0]);
}
-
+
@Test
public void testBatchedMatchEvent() {
final boolean [] wasAdded= { false };
final boolean [] wasRemoved= { false };
-
+
ISearchQuery query= new NullQuery();
AbstractTextSearchResult result= (AbstractTextSearchResult) query.getSearchResult();
-
+
result.addListener(new ISearchResultListener() {
@Override
public void searchResultChanged(SearchResultEvent e) {
@@ -234,25 +234,25 @@ public class TestSearchResult {
}
}
});
-
+
String object= "object"; //$NON-NLS-1$
-
+
Match match1= new Match(object, 0, 0);
result.addMatches(new Match[] { match1 });
assertTrue(wasAdded[0]);
wasAdded[0]= false;
result.addMatches(new Match[] { match1 });
assertFalse(wasAdded[0]);
-
+
Match match2= new Match(object, 0, 0);
result.addMatches(new Match[] { match2 });
assertTrue(wasAdded[0]);
wasAdded[0]= false;
-
+
result.removeMatches(new Match[] { match2 });
assertTrue(wasRemoved[0]);
wasRemoved[0]= false;
-
+
result.removeMatches(new Match[] { match2 });
assertFalse(wasRemoved[0]);
}
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/tests/FileTool.java b/org.eclipse.search.tests/src/org/eclipse/search/tests/FileTool.java
index 20550b158..26568301a 100644
--- a/org.eclipse.search.tests/src/org/eclipse/search/tests/FileTool.java
+++ b/org.eclipse.search.tests/src/org/eclipse/search/tests/FileTool.java
@@ -32,26 +32,26 @@ import org.eclipse.core.runtime.Plugin;
public class FileTool {
-
+
private final static int MAX_RETRY= 5;
-
+
/**
* A buffer.
*/
private static byte[] buffer = new byte[8192];
-
+
/**
* Unzips the given zip file to the given destination directory
* extracting only those entries the pass through the given
* filter.
- *
+ *
* @param zipFile the zip file to unzip
* @param dstDir the destination directory
* @throws IOException in case of problem
*/
public static void unzip(ZipFile zipFile, File dstDir) throws IOException {
Enumeration<? extends ZipEntry> entries = zipFile.entries();
-
+
try {
while(entries.hasMoreElements()){
ZipEntry entry = entries.nextElement();
@@ -76,12 +76,12 @@ public class FileTool {
}
}
}
-
+
/**
* Returns the given file path with its separator
* character changed from the given old separator to the
* given new separator.
- *
+ *
* @param path a file path
* @param oldSeparator a path separator character
* @param newSeparator a path separator character
@@ -92,11 +92,11 @@ public class FileTool {
public static String changeSeparator(String path, char oldSeparator, char newSeparator){
return path.replace(oldSeparator, newSeparator);
}
-
+
/**
* Copies all bytes in the given source file to
* the given destination file.
- *
+ *
* @param source the given source file
* @param destination the given destination file
* @throws IOException in case of error
@@ -107,16 +107,16 @@ public class FileTool {
InputStream is = new FileInputStream(source);
OutputStream os = new FileOutputStream(destination);
) {
-
+
transferData(is, os);
}
}
-
+
/**
* Copies all bytes in the given source stream to
* the given destination stream. Neither streams
* are closed.
- *
+ *
* @param source the given source stream
* @param destination the given destination stream
* @throws IOException in case of error
@@ -133,7 +133,7 @@ public class FileTool {
/**
* Copies the given source file to the given destination file.
- *
+ *
* @param src the given source file
* @param dst the given destination file
* @throws IOException in case of error
@@ -159,13 +159,13 @@ public class FileTool {
return null;
}
}
-
+
public static File createTempFileInPlugin(Plugin plugin, IPath path) {
IPath stateLocation= plugin.getStateLocation();
stateLocation= stateLocation.append(path);
return stateLocation.toFile();
}
-
+
public static StringBuffer read(String fileName) throws IOException {
return read(new FileReader(fileName));
}
@@ -193,7 +193,7 @@ public class FileTool {
writer.write(content.toString());
}
}
-
+
public static void delete(File file) {
if (file.exists()) {
for (int i= 0; i < MAX_RETRY; i++) {
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/tests/ResourceHelper.java b/org.eclipse.search.tests/src/org/eclipse/search/tests/ResourceHelper.java
index b9a030b7f..597d4ee7e 100644
--- a/org.eclipse.search.tests/src/org/eclipse/search/tests/ResourceHelper.java
+++ b/org.eclipse.search.tests/src/org/eclipse/search/tests/ResourceHelper.java
@@ -40,32 +40,32 @@ import org.eclipse.core.resources.ResourcesPlugin;
* @since 3.0
*/
public class ResourceHelper {
-
+
private final static IProgressMonitor NULL_MONITOR= new NullProgressMonitor();
private static final int MAX_RETRY= 10;
-
+
public static IProject createProject(String projectName) throws CoreException {
-
+
IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
IProject project= root.getProject(projectName);
if (!project.exists())
project.create(NULL_MONITOR);
else
project.refreshLocal(IResource.DEPTH_INFINITE, null);
-
+
if (!project.isOpen())
project.open(NULL_MONITOR);
-
+
return project;
}
-
+
public static void deleteProject(String projectName) throws CoreException {
IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
IProject project= root.getProject(projectName);
if (project.exists())
delete(project);
}
-
+
public static void delete(final IResource resource) throws CoreException {
IWorkspaceRunnable runnable= new IWorkspaceRunnable() {
@Override
@@ -89,12 +89,12 @@ public class ResourceHelper {
}
};
ResourcesPlugin.getWorkspace().run(runnable, null);
-
+
}
/**
* Creates a folder and all parent folders if not existing. Project must exist.
- *
+ *
* @param folder The folder to create
* @return Returns the input folder
* @throws CoreException if creation fails
@@ -109,7 +109,7 @@ public class ResourceHelper {
}
return folder;
}
-
+
public static IFile createFile(IFolder folder, String name, String contents, String encoding) throws CoreException, IOException {
IFile file= folder.getFile(name);
if (contents == null)
@@ -121,55 +121,55 @@ public class ResourceHelper {
return file;
}
-
+
public static IFile createFile(IFolder folder, String name, String contents) throws CoreException, IOException {
return createFile(folder, name, contents, "ISO-8859-1");
}
-
+
public static IFile createLinkedFile(IContainer container, IPath linkPath, File linkedFileTarget) throws CoreException {
IFile iFile= container.getFile(linkPath);
iFile.createLink(new Path(linkedFileTarget.getAbsolutePath()), IResource.ALLOW_MISSING_LOCAL, NULL_MONITOR);
return iFile;
}
-
+
public static IFile createLinkedFile(IContainer container, IPath linkPath, Plugin plugin, IPath linkedFileTargetPath) throws CoreException {
File file= FileTool.getFileInPlugin(plugin, linkedFileTargetPath);
IFile iFile= container.getFile(linkPath);
iFile.createLink(new Path(file.getAbsolutePath()), IResource.ALLOW_MISSING_LOCAL, NULL_MONITOR);
return iFile;
}
-
+
public static IFolder createLinkedFolder(IContainer container, IPath linkPath, File linkedFolderTarget) throws CoreException {
IFolder folder= container.getFolder(linkPath);
folder.createLink(new Path(linkedFolderTarget.getAbsolutePath()), IResource.ALLOW_MISSING_LOCAL, NULL_MONITOR);
return folder;
}
-
+
public static IFolder createLinkedFolder(IContainer container, IPath linkPath, Plugin plugin, IPath linkedFolderTargetPath) throws CoreException {
File file= FileTool.getFileInPlugin(plugin, linkedFolderTargetPath);
IFolder iFolder= container.getFolder(linkPath);
iFolder.createLink(new Path(file.getAbsolutePath()), IResource.ALLOW_MISSING_LOCAL, NULL_MONITOR);
return iFolder;
}
-
+
public static IProject createLinkedProject(String projectName, Plugin plugin, IPath linkPath) throws CoreException {
IWorkspace workspace= ResourcesPlugin.getWorkspace();
IProject project= workspace.getRoot().getProject(projectName);
-
+
IProjectDescription desc= workspace.newProjectDescription(projectName);
File file= FileTool.getFileInPlugin(plugin, linkPath);
IPath projectLocation= new Path(file.getAbsolutePath());
if (Platform.getLocation().equals(projectLocation))
projectLocation= null;
desc.setLocation(projectLocation);
-
+
project.create(desc, NULL_MONITOR);
if (!project.isOpen())
project.open(NULL_MONITOR);
-
+
return project;
}
-
+
public static IProject createJUnitSourceProject(String projectName) throws CoreException, ZipException, IOException {
IProject project= ResourceHelper.createProject(projectName);
ZipFile zip= new ZipFile(FileTool.getFileInPlugin(SearchTestPlugin.getDefault(), new Path("testresources/junit37-noUI-src.zip"))); //$NON-NLS-1$
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/tests/SearchTestPlugin.java b/org.eclipse.search.tests/src/org/eclipse/search/tests/SearchTestPlugin.java
index fcdde820e..142af0474 100644
--- a/org.eclipse.search.tests/src/org/eclipse/search/tests/SearchTestPlugin.java
+++ b/org.eclipse.search.tests/src/org/eclipse/search/tests/SearchTestPlugin.java
@@ -35,7 +35,7 @@ import org.eclipse.search2.internal.ui.SearchView;
public class SearchTestPlugin extends AbstractUIPlugin {
//The shared instance.
private static SearchTestPlugin fgPlugin;
-
+
public SearchTestPlugin() {
fgPlugin = this;
}
@@ -43,7 +43,7 @@ public class SearchTestPlugin extends AbstractUIPlugin {
public static SearchTestPlugin getDefault() {
return fgPlugin;
}
-
+
public SearchView getSearchView() {
return (SearchView) NewSearchUI.activateSearchResultView();
}
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/AnnotationManagerTest.java b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/AnnotationManagerTest.java
index 80881a326..c6d922b94 100644
--- a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/AnnotationManagerTest.java
+++ b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/AnnotationManagerTest.java
@@ -65,13 +65,13 @@ public class AnnotationManagerTest {
fQuery1= new FileSearchQuery("Test", false, true, scope); //$NON-NLS-1$//$NON-NLS-2$
fQuery2= new FileSearchQuery("Test", false, true, scope); //$NON-NLS-1$//$NON-NLS-2$
}
-
+
@After
public void tearDown() {
InternalSearchUI.getInstance().removeAllQueries();
fQuery1= null;
fQuery2= null;
-
+
EditorAnnotationManager.debugSetHighlighterType(EditorAnnotationManager.HIGHLLIGHTER_ANY);
}
@@ -94,20 +94,20 @@ public class AnnotationManagerTest {
positions.add(annotationModel.getPosition(annotation));
}
}
-
+
Match[] matches= result.getMatches(file);
for (int j= 0; j < matches.length; j++) {
Position position= new Position(matches[j].getOffset(), matches[j].getLength());
assertTrue("position not found at: "+j, positions.remove(position)); //$NON-NLS-1$
}
assertEquals(0, positions.size());
-
+
}
} finally {
SearchPlugin.getActivePage().closeAllEditors(false);
}
}
-
+
@Test
public void testBogusAnnotation() throws Exception {
NewSearchUI.runQueryInForeground(null, fQuery1);
@@ -116,14 +116,14 @@ public class AnnotationManagerTest {
SearchTestPlugin.openTextEditor(SearchTestPlugin.getDefault().getWorkbench().getWorkbenchWindows()[0].getPages()[0], file);
result.addMatch(new FileMatch(file));
}
-
+
@Test
public void testRemoveQuery() throws Exception {
NewSearchUI.runQueryInForeground(null, fQuery1);
AbstractTextSearchResult result= (AbstractTextSearchResult) fQuery1.getSearchResult();
Object[] files= result.getElements();
InternalSearchUI.getInstance().removeQuery(fQuery1);
-
+
try {
for (int i= 0; i < files.length; i++) {
IFile file= (IFile)files[i];
@@ -170,7 +170,7 @@ public class AnnotationManagerTest {
SearchPlugin.getActivePage().closeAllEditors(false);
}
}
-
+
@Test
public void testSwitchQuery() throws Exception {
NewSearchUI.runQueryInForeground(null, fQuery1);
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/FileCharSequenceTests.java b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/FileCharSequenceTests.java
index f0ac8c9e9..f9df723bf 100644
--- a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/FileCharSequenceTests.java
+++ b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/FileCharSequenceTests.java
@@ -31,19 +31,19 @@ import org.eclipse.search.tests.ResourceHelper;
public class FileCharSequenceTests {
private final String TEST_CONTENT= "ABCDEFGHIJKLMNOPQRSTUVWXYZÜöäüèéùabcdefghijklmnopqrstuvwxyz1234567890@\'\"\n$¢"; //€
-
+
private IProject fProject;
-
+
@Before
public void setUp() throws Exception {
fProject= ResourceHelper.createProject("my-project"); //$NON-NLS-1$
}
-
+
@After
public void tearDown() throws Exception {
ResourceHelper.deleteProject("my-project"); //$NON-NLS-1$
}
-
+
@Test
public void testFileCharSequence() throws Exception {
StringBuilder buf= new StringBuilder();
@@ -77,26 +77,26 @@ public class FileCharSequenceTests {
private void testForEncoding(CharSequence buf, String encoding) throws CoreException, IOException {
IFolder folder= ResourceHelper.createFolder(fProject.getFolder("folder1"));
IFile file1= ResourceHelper.createFile(folder, "file1", buf.toString(), encoding);
-
+
FileCharSequenceProvider provider= new FileCharSequenceProvider();
CharSequence cs= null;
try {
cs= provider.newCharSequence(file1);
-
+
assertEquals(encoding, cs, buf);
-
+
assertSubSequence(encoding, cs, buf, 0, buf.length() / 6);
assertSubSequence(encoding, cs, buf, buf.length() / 6, FileCharSequenceProvider.BUFFER_SIZE);
-
+
int pos= 8 * buf.length() / 9;
assertSubSequence(encoding, cs, buf, pos, buf.length() - pos);
-
+
CharSequence seq1a= cs.subSequence(100, 100 + FileCharSequenceProvider.BUFFER_SIZE);
CharSequence seq1e= buf.subSequence(100, 100 + FileCharSequenceProvider.BUFFER_SIZE);
assertSubSequence(encoding, seq1a, seq1e, 500, 500);
-
+
assertSubSequence(encoding, seq1a, seq1e, FileCharSequenceProvider.BUFFER_SIZE, 0);
-
+
} finally {
if (cs != null) {
provider.releaseCharSequence(cs);
@@ -104,13 +104,13 @@ public class FileCharSequenceTests {
file1.delete(true, null);
}
}
-
+
private void assertSubSequence(String message, CharSequence actual, CharSequence expected, int start, int length) {
CharSequence actualSub= actual.subSequence(start, start + length);
CharSequence expectedSub= expected.subSequence(start, start + length);
assertEquals(message + " - subsequence(" + start + ", " + length + ")", actualSub, expectedSub);
}
-
+
private void assertEquals(String desc, CharSequence actual, CharSequence expected) {
for (int i= 0; i < expected.length(); i++) {
Assert.assertEquals(desc + " - forward " + i, expected.charAt(i), actual.charAt(i));
@@ -125,14 +125,14 @@ public class FileCharSequenceTests {
for (int i= 0; i < expected.length(); i+= FileCharSequenceProvider.BUFFER_SIZE) {
Assert.assertEquals(desc + " - forward - buffersize" + i, expected.charAt(i), actual.charAt(i));
}
-
+
assertOutOfBound(desc + "access at length", actual, expected.length());
assertOutOfBound(desc + "access at -1", actual, -1);
Assert.assertEquals(desc + " - length", actual.toString(), expected.toString());
}
-
-
+
+
private void assertOutOfBound(String message, CharSequence cs, int i) {
try {
cs.charAt(i);
@@ -143,5 +143,5 @@ public class FileCharSequenceTests {
}
-
+
}
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/FileSearchTests.java b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/FileSearchTests.java
index d0ceb1def..4496d61fb 100644
--- a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/FileSearchTests.java
+++ b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/FileSearchTests.java
@@ -43,7 +43,7 @@ import org.eclipse.search.tests.SearchTestPlugin;
import org.eclipse.search.ui.text.FileTextSearchScope;
public class FileSearchTests {
-
+
private static class TestResult {
public IResource resource;
public int offset;
@@ -114,12 +114,12 @@ public class FileSearchTests {
public static JUnitSourceSetup fgJUnitSource= new JUnitSourceSetup();
private IProject fProject;
-
+
@Before
public void setUp() throws Exception{
fProject= ResourceHelper.createProject("my-project"); //$NON-NLS-1$
}
-
+
@After
public void tearDown() throws Exception {
ResourceHelper.deleteProject("my-project"); //$NON-NLS-1$
@@ -129,7 +129,7 @@ public class FileSearchTests {
public void testSimpleFilesSerial() throws Exception {
testSimpleFiles(new SerialTestResultCollector());
}
-
+
@Test
public void testSimpleFilesParallel() throws Exception {
testSimpleFiles(new ParallelTestResultCollector());
@@ -156,12 +156,12 @@ public class FileSearchTests {
assertMatches(results, 2, file1, buf.toString(), "hello");
assertMatches(results, 2, file2, buf.toString(), "hello");
}
-
+
@Test
public void testWildCards1Serial() throws Exception {
testWildCards1(new SerialTestResultCollector());
}
-
+
@Test
public void testWildCards1Parallel() throws Exception {
testWildCards1(new ParallelTestResultCollector());
@@ -179,19 +179,19 @@ public class FileSearchTests {
ResourceHelper.createFile(folder, "file2", buf.toString());
Pattern searchPattern= PatternConstructor.createPattern("mor*", false, false);
-
+
FileTextSearchScope scope= FileTextSearchScope.newSearchScope(new IResource[] {fProject}, (String[]) null, false);
TextSearchEngine.create().search(scope, collector, searchPattern, null);
-
+
TestResult[] results= collector.getResults();
assertEquals("Number of total results", 6, results.length);
}
-
+
@Test
public void testWildCards2Serial() throws Exception {
testWildCards2(new SerialTestResultCollector());
}
-
+
@Test
public void testWildCards2Parallel() throws Exception {
testWildCards2(new ParallelTestResultCollector());
@@ -209,39 +209,39 @@ public class FileSearchTests {
ResourceHelper.createFile(folder, "file2", buf.toString());
Pattern searchPattern= PatternConstructor.createPattern("mo?e", false, false);
-
+
FileTextSearchScope scope= FileTextSearchScope.newSearchScope(new IResource[] {fProject}, (String[]) null, false);
TextSearchEngine.create().search(scope, collector, searchPattern, null);
-
+
TestResult[] results= collector.getResults();
assertEquals("Number of total results", 4, results.length);
}
-
+
@Test
public void testWildCards3Serial() throws Exception {
testWildCards3(new SerialTestResultCollector());
}
-
+
@Test
public void testWildCards3Parallel() throws Exception {
testWildCards3(new ParallelTestResultCollector());
}
private void testWildCards3(TestResultCollector collector) throws Exception {
-
+
IProject project= fgJUnitSource.getStandardProject();
IFile openFile1= (IFile) project.findMember("junit/framework/TestCase.java");
IFile openFile2= (IFile) project.findMember("junit/extensions/ExceptionTestCase.java");
IFile openFile3= (IFile) project.findMember("junit/framework/Assert.java");
IFile openFile4= (IFile) project.findMember("junit/samples/money/MoneyTest.java");
-
+
IWorkbenchPage activePage= SearchPlugin.getActivePage();
try {
SearchTestPlugin.openTextEditor(activePage, openFile1);
SearchTestPlugin.openTextEditor(activePage, openFile2);
SearchTestPlugin.openTextEditor(activePage, openFile3);
SearchTestPlugin.openTextEditor(activePage, openFile4);
-
+
long start= System.currentTimeMillis();
Pattern searchPattern= PatternConstructor.createPattern("\\w*\\(\\)", false, true);
@@ -260,12 +260,12 @@ public class FileSearchTests {
}
}
-
+
@Test
public void testWholeWordSerial() throws Exception {
testWholeWord(new SerialTestResultCollector());
}
-
+
@Test
public void testWholeWordParallel() throws Exception {
testWholeWord(new ParallelTestResultCollector());
@@ -316,12 +316,12 @@ public class FileSearchTests {
assertEquals("Number of partial-word results", 22, collector.getNumberOfResults());
}
}
-
+
@Test
public void testFileOpenInEditorSerial() throws Exception {
testFileOpenInEditor(new SerialTestResultCollector());
}
-
+
@Test
public void testFileOpenInEditorParallel() throws Exception {
testFileOpenInEditor(new ParallelTestResultCollector());
@@ -339,7 +339,7 @@ public class FileSearchTests {
try {
SearchTestPlugin.openTextEditor(SearchPlugin.getActivePage(), file2);
-
+
Pattern searchPattern= PatternConstructor.createPattern("hello", false, true);
FileTextSearchScope scope= FileTextSearchScope.newSearchScope(new IResource[] {fProject}, (String[]) null, false);
@@ -354,12 +354,12 @@ public class FileSearchTests {
SearchPlugin.getActivePage().closeAllEditors(false);
}
}
-
+
@Test
public void testDerivedFilesSerial() throws Exception {
testDerivedFiles(new SerialTestResultCollector());
}
-
+
@Test
public void testDerivedFilesParallel() throws Exception {
testDerivedFiles(new ParallelTestResultCollector());
@@ -372,17 +372,17 @@ public class FileSearchTests {
ResourceHelper.createFile(folder1, "file1", buf.toString());
IFile file2= ResourceHelper.createFile(folder1, "file2", buf.toString());
file2.setDerived(true, null);
-
+
IFolder folder2= ResourceHelper.createFolder(folder1.getFolder("folder2"));
folder2.setDerived(true, null);
ResourceHelper.createFile(folder2, "file3", buf.toString());
IFolder folder3= ResourceHelper.createFolder(folder2.getFolder("folder3"));
ResourceHelper.createFile(folder3, "file4", buf.toString());
-
+
IFolder folder4= ResourceHelper.createFolder(folder1.getFolder("folder4"));
ResourceHelper.createFile(folder4, "file5", buf.toString());
-
+
/**
* folder1
* file1
@@ -394,8 +394,8 @@ public class FileSearchTests {
* folder4
* file5
*/
-
-
+
+
Pattern searchPattern= PatternConstructor.createPattern("hello", false, true);
Pattern fileNamePattern= PatternConstructor.createPattern("*", false, false);
TextSearchEngine engine= TextSearchEngine.create();
@@ -442,12 +442,12 @@ public class FileSearchTests {
assertEquals(0, collector.getNumberOfResults());
}
}
-
+
@Test
public void testFileNamePatternsSerial() throws Exception {
testFileNamePatterns(new SerialTestResultCollector());
}
-
+
@Test
public void testFileNamePatternsParallel() throws Exception {
testFileNamePatterns(new ParallelTestResultCollector());
@@ -463,52 +463,52 @@ public class FileSearchTests {
Pattern searchPattern= PatternConstructor.createPattern("Test", false, false);
String[] fileNamePatterns= { "*" };
-
+
TestResult[] results= performSearch(collector, fileNamePatterns, searchPattern);
assertEquals("Number of total results", 4, results.length);
-
+
fileNamePatterns= new String[] { "*.x" };
results= performSearch(collector, fileNamePatterns, searchPattern);
assertEquals("Number of total results", 2, results.length);
-
+
fileNamePatterns= new String[] { "*.x", "*.y*" };
results= performSearch(collector, fileNamePatterns, searchPattern);
assertEquals("Number of total results", 3, results.length);
-
+
fileNamePatterns= new String[] { "!*.x" };
results= performSearch(collector, fileNamePatterns, searchPattern);
assertEquals("Number of total results", 2, results.length);
-
+
fileNamePatterns= new String[] { "!*.x", "!*.y" };
results= performSearch(collector, fileNamePatterns, searchPattern);
assertEquals("Number of total results", 1, results.length);
-
+
fileNamePatterns= new String[] { "*", "!*.y" };
results= performSearch(collector, fileNamePatterns, searchPattern);
assertEquals("Number of total results", 3, results.length);
-
+
fileNamePatterns= new String[] { "*", "!*.*" };
results= performSearch(collector, fileNamePatterns, searchPattern);
assertEquals("Number of total results", 0, results.length);
-
+
fileNamePatterns= new String[] { "*.x", "*.y*", "!*.y" };
results= performSearch(collector, fileNamePatterns, searchPattern);
assertEquals("Number of total results", 2, results.length);
-
+
fileNamePatterns= new String[] { "file*", "!*.x*", "!*.y" };
results= performSearch(collector, fileNamePatterns, searchPattern);
assertEquals("Number of total results", 1, results.length);
}
-
+
private TestResult[] performSearch(TestResultCollector collector, String[] fileNamePatterns, Pattern searchPattern) {
collector.reset();
FileTextSearchScope scope= FileTextSearchScope.newSearchScope(new IResource[] {fProject}, fileNamePatterns, false);
TextSearchEngine.create().search(scope, collector, searchPattern, null);
-
+
return collector.getResults();
}
-
+
private void assertMatches(TestResult[] results, int expectedCount, IFile file, String fileContent, String string) {
@@ -522,6 +522,6 @@ public class FileSearchTests {
}
assertEquals("Number of results in file", expectedCount, k);
}
-
-
+
+
}
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/JUnitSourceSetup.java b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/JUnitSourceSetup.java
index 50849a889..bd560a54d 100644
--- a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/JUnitSourceSetup.java
+++ b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/JUnitSourceSetup.java
@@ -20,12 +20,12 @@ import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.search.tests.ResourceHelper;
public class JUnitSourceSetup extends ExternalResource {
-
+
public static final String STANDARD_PROJECT_NAME= "JUnitSource";
-
+
private IProject fProject= null;
private final String fProjectName;
-
+
public IProject getStandardProject() {
return ResourcesPlugin.getWorkspace().getRoot().getProject(STANDARD_PROJECT_NAME);
}
@@ -33,11 +33,11 @@ public class JUnitSourceSetup extends ExternalResource {
public JUnitSourceSetup() {
this(STANDARD_PROJECT_NAME);
}
-
+
public JUnitSourceSetup(String projectName) {
fProjectName= projectName;
}
-
+
@Override
public void before() throws Exception {
IProject project= ResourcesPlugin.getWorkspace().getRoot().getProject(fProjectName);
@@ -45,7 +45,7 @@ public class JUnitSourceSetup extends ExternalResource {
fProject= ResourceHelper.createJUnitSourceProject(fProjectName);
}
}
-
+
@Override
public void after() /*throws Exception (but JUnit4 API is stupid...)*/ {
if (fProject != null) { // delete only by the setup who created the project
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/LineAnnotationManagerTest.java b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/LineAnnotationManagerTest.java
index eb18d53f2..5c673e1cd 100644
--- a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/LineAnnotationManagerTest.java
+++ b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/LineAnnotationManagerTest.java
@@ -57,22 +57,22 @@ public class LineAnnotationManagerTest {
@Before
public void setUp() throws Exception {
EditorAnnotationManager.debugSetHighlighterType(EditorAnnotationManager.HIGHLIGHTER_ANNOTATION);
-
+
String[] fileNamePatterns= { "*.java" };
FileTextSearchScope scope= FileTextSearchScope.newWorkspaceScope(fileNamePatterns, false);
-
+
fLineQuery= new LineBasedFileSearch(scope, false, true, "Test");
}
-
+
@After
public void tearDown() throws Exception {
InternalSearchUI.getInstance().removeAllQueries();
fLineQuery= null;
-
+
EditorAnnotationManager.debugSetHighlighterType(EditorAnnotationManager.HIGHLLIGHTER_ANY);
}
-
- @Test
+
+ @Test
public void testLineBasedQuery() throws Exception {
NewSearchUI.runQueryInForeground(null, fLineQuery);
AbstractTextSearchResult result= (AbstractTextSearchResult) fLineQuery.getSearchResult();
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/LineBasedFileSearch.java b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/LineBasedFileSearch.java
index a8d969940..66076c4bd 100644
--- a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/LineBasedFileSearch.java
+++ b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/LineBasedFileSearch.java
@@ -39,13 +39,13 @@ import org.eclipse.search.ui.text.FileTextSearchScope;
/**
*/
public class LineBasedFileSearch extends FileSearchQuery {
-
-
+
+
private static class LineBasedTextSearchResultCollector extends TextSearchRequestor {
-
+
private final AbstractTextSearchResult fResult;
private IFile fLastFile;
- private IDocument fLastDocument;
+ private IDocument fLastDocument;
private Object fLock= new Object();
private LineBasedTextSearchResultCollector(AbstractTextSearchResult result) {
@@ -87,12 +87,12 @@ public class LineBasedFileSearch extends FileSearchQuery {
FileBuffers.getTextFileBufferManager().disconnect(fLastFile.getFullPath(), LocationKind.IFILE, null);
}
fLastFile= file;
-
+
FileBuffers.getTextFileBufferManager().connect(file.getFullPath(), LocationKind.IFILE, null);
fLastDocument= FileBuffers.getTextFileBufferManager().getTextFileBuffer(file.getFullPath(), LocationKind.IFILE).getDocument();
return fLastDocument;
}
-
+
@Override
public void endReporting() {
if (fLastFile != null) {
@@ -103,10 +103,10 @@ public class LineBasedFileSearch extends FileSearchQuery {
}
}
}
-
+
private final FileTextSearchScope fScope;
-
-
+
+
public LineBasedFileSearch(FileTextSearchScope scope, boolean isRegEx, boolean isCaseSensitive, String searchString) {
super(searchString, isRegEx, isCaseSensitive, scope);
fScope= scope;
@@ -117,12 +117,12 @@ public class LineBasedFileSearch extends FileSearchQuery {
public IStatus run(IProgressMonitor monitor) {
AbstractTextSearchResult textResult= (AbstractTextSearchResult) getSearchResult();
textResult.removeAll();
-
+
LineBasedTextSearchResultCollector collector= new LineBasedTextSearchResultCollector(textResult);
-
+
Pattern searchPattern= getSearchPattern();
return TextSearchEngine.create().search(fScope, collector, searchPattern, monitor);
}
-
+
}
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/PositionTrackerTest.java b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/PositionTrackerTest.java
index ec5659a00..504c63aa5 100644
--- a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/PositionTrackerTest.java
+++ b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/PositionTrackerTest.java
@@ -50,11 +50,11 @@ public class PositionTrackerTest {
public void setUp() throws Exception {
String[] fileNamePatterns= { "*.java" };
FileTextSearchScope scope= FileTextSearchScope.newWorkspaceScope(fileNamePatterns, false);
-
+
fQuery1= new FileSearchQuery("Test", false, true, scope);
}
-
-
+
+
@Test
public void testInsertAt0() throws Exception {
NewSearchUI.runQueryInForeground(null, fQuery1);
@@ -68,7 +68,7 @@ public class PositionTrackerTest {
SearchPlugin.getActivePage().closeAllEditors(false);
}
}
-
+
@Test
public void testInsertInsideMatch() throws Exception {
NewSearchUI.runQueryInForeground(null, fQuery1);
@@ -133,5 +133,5 @@ public class PositionTrackerTest {
SearchPlugin.getActivePage().closeAllEditors(false);
}
}
-
+
}
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/ResultUpdaterTest.java b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/ResultUpdaterTest.java
index aba4fcc05..72a224a54 100644
--- a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/ResultUpdaterTest.java
+++ b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/ResultUpdaterTest.java
@@ -30,27 +30,27 @@ import org.eclipse.search.tests.ResourceHelper;
public class ResultUpdaterTest {
private FileSearchQuery fQuery1;
-
+
private IProject fProject;
-
+
private static final String PROJECT_TO_MODIFY= "ModifiableProject";
@Before
public void setUp() throws Exception {
// create a own project to make modifications
fProject= ResourceHelper.createJUnitSourceProject(PROJECT_TO_MODIFY);
-
+
String[] fileNamePatterns= { "*.java" };
FileTextSearchScope scope= FileTextSearchScope.newSearchScope(new IResource[] { fProject }, fileNamePatterns, false);
-
+
fQuery1= new FileSearchQuery("Test", false, true, scope);
}
-
+
@After
public void tearDown() throws Exception {
ResourceHelper.deleteProject(PROJECT_TO_MODIFY);
}
-
+
@Test
public void testRemoveFile() throws Exception {
NewSearchUI.runQueryInForeground(null, fQuery1);
@@ -62,7 +62,7 @@ public class ResultUpdaterTest {
assertEquals(totalCount-fileCount, result.getMatchCount());
assertEquals(0, result.getMatchCount(elements[0]));
}
-
+
@Test
public void testRemoveProject() throws Exception {
NewSearchUI.runQueryInForeground(null, fQuery1);
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/SearchResultPageTest.java b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/SearchResultPageTest.java
index 7d401f10d..1dc55ae50 100644
--- a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/SearchResultPageTest.java
+++ b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/SearchResultPageTest.java
@@ -52,7 +52,7 @@ public class SearchResultPageTest {
SearchTestPlugin.ensureWelcomePageClosed();
String[] fileNamePatterns= { "*.java" };
FileTextSearchScope scope= FileTextSearchScope.newWorkspaceScope(fileNamePatterns, false);
-
+
fQuery1= new FileSearchQuery("Test", false, true, scope);
}
@@ -67,7 +67,7 @@ public class SearchResultPageTest {
page.setLayout(AbstractTextSearchViewPage.FLAG_LAYOUT_FLAT);
checkViewerDisplay(page);
}
-
+
private void checkViewerDisplay(FileSearchPage page) {
StructuredViewer viewer= page.getViewer();
AbstractTextSearchResult result= (AbstractTextSearchResult) fQuery1.getSearchResult();
@@ -81,7 +81,7 @@ public class SearchResultPageTest {
}
}
-
+
@Test
@Ignore // checkElementDisplay(..) misses cases where one line contains multiple matches
public void testRemoveTreeMatches() throws Exception {
@@ -113,7 +113,7 @@ public class SearchResultPageTest {
Display.getDefault().readAndDispatch();
}
}
-
+
private void consumeEvents() {
while (Display.getDefault().readAndDispatch()) {
}
@@ -128,7 +128,7 @@ public class SearchResultPageTest {
if (itemCount > 1)
assertTrue(item.getText().indexOf(String.valueOf(itemCount)) >= 0);
}
-
+
@Test
public void testTableNavigation() {
NewSearchUI.runQueryInForeground(null, fQuery1);
@@ -136,25 +136,25 @@ public class SearchResultPageTest {
FileSearchPage page= (FileSearchPage) view.getActivePage();
page.setLayout(AbstractTextSearchViewPage.FLAG_LAYOUT_FLAT);
Table table= ((TableViewer) page.getViewer()).getTable();
-
+
consumeEvents();
-
+
// select the first element.
table.setSelection(0);
table.showSelection();
-
+
consumeEvents();
// back from first match, goto last
page.gotoPreviousMatch();
-
+
consumeEvents();
-
+
assertEquals(1, table.getSelectionCount());
assertEquals(table.getItemCount()-1, table.getSelectionIndex());
// and forward again, to the first match.
page.gotoNextMatch();
-
+
consumeEvents();
assertEquals(1, table.getSelectionCount());
assertEquals(0, table.getSelectionIndex());
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/SortingTest.java b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/SortingTest.java
index 2571535db..b370c8692 100644
--- a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/SortingTest.java
+++ b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/SortingTest.java
@@ -36,10 +36,10 @@ public class SortingTest {
public void setUp() throws Exception {
String[] fileNamePatterns= { "*.java" };
FileTextSearchScope scope= FileTextSearchScope.newWorkspaceScope(fileNamePatterns, false);
-
+
fQuery1= new FileSearchQuery("Test", false, true, scope);
}
-
+
@Test
public void testSorted() throws Exception {
NewSearchUI.activateSearchResultView();
@@ -47,7 +47,7 @@ public class SortingTest {
AbstractTextSearchResult result= (AbstractTextSearchResult) fQuery1.getSearchResult();
int originalMatchCount= result.getMatchCount();
List<Match> allMatches= new ArrayList<>(originalMatchCount);
-
+
// first, collect all matches
Object[] elements= result.getElements();
for (int i= 0; i < elements.length; i++) {
@@ -59,13 +59,13 @@ public class SortingTest {
// now remove them and readd them in reverse order
result.removeAll();
assertTrue("removed all matches", result.getMatchCount() == 0);
-
+
for (int i= allMatches.size()-1; i >= 0; i--) {
result.addMatch(allMatches.get(i));
}
-
+
assertEquals("Test that all matches have been added again", result.getMatchCount(), originalMatchCount);
-
+
// now check that they're ordered by position.
for (int i= 0; i < elements.length; i++) {
Match[] matches= result.getMatches(elements[i]);
@@ -90,5 +90,5 @@ public class SortingTest {
return false;
}
}
-
+
}

Back to the top