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

CHE-5174 Improving search results #5874

Merged
merged 4 commits into from
Aug 14, 2017
Merged

CHE-5174 Improving search results #5874

merged 4 commits into from
Aug 14, 2017

Conversation

vparfonov
Copy link
Contributor

@vparfonov vparfonov commented Aug 2, 2017

What does this PR do?

Improving search results:

  • line numbers are shown for matches
  • multiple matches in the same file are shown individually
  • when you click on a search result, the editor loads the file AND jumps straight to the matching line with all instances of the search term already highlighted

che-5174

What issues does this PR fix or reference?

#5174

related to eclipse-che/che-dependencies#50

Changelog

ProjectService#search() now return different objects, now it will be List<SearchResultDto> instead of List<ItemReference>

Release Notes

Improving search results:

  • line numbers are shown for matches
  • multiple matches in the same file are shown individually
  • when you click on a search result, the editor loads the file AND jumps straight to the matching line with all instances of the search term already highlighted

NOTE: ProjectService#search() now return different objects, now it will be List<SearchResultDto> instead of List<ItemReference>

@@ -10,13 +10,15 @@
*******************************************************************************/
package org.eclipse.che.ide.api.project;

import org.eclipse.che.api.project.shared.dto.SearchResultDto;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused import

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

for (SearchResultDto dto : arg) {
results.add(new SearchResult(dto));
}
return results;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can do it like return arg.stream().map(SearchResult::new).collect(toList());, but up to you - what is more readable...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with @RomanNikitenko .. @vparfonov can you take a look?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public Promise<List<? extends SearchResult>> search(QueryExpression expression) {

@@ -14,13 +14,16 @@
import com.google.common.base.Optional;

import org.eclipse.che.api.core.model.project.type.ProjectType;
import org.eclipse.che.api.project.shared.dto.SearchResultDto;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused import

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

path = searchResultDto.getItemReference().getPath();
project = searchResultDto.getItemReference().getProject();
final List<Link> links = searchResultDto.getItemReference().getLinks();
if (!links.isEmpty() && links.contains(Constants.LINK_REL_GET_CONTENT)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure the check links.contains(Constants.LINK_REL_GET_CONTENT) is correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@@ -14,6 +14,7 @@
import com.google.common.base.Optional;

import org.eclipse.che.api.core.model.project.ProjectConfig;
import org.eclipse.che.api.project.shared.dto.SearchResultDto;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused import

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@@ -22,6 +22,7 @@
import org.eclipse.che.api.core.model.project.ProjectConfig;
import org.eclipse.che.api.core.model.project.SourceStorage;
import org.eclipse.che.api.core.rest.shared.dto.Link;
import org.eclipse.che.api.project.shared.dto.SearchResultDto;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused import

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@@ -19,6 +19,7 @@
import org.eclipse.che.ide.api.data.tree.settings.NodeSettings;
import org.eclipse.che.ide.api.editor.EditorAgent;
import org.eclipse.che.ide.api.resources.File;
import org.eclipse.che.ide.api.resources.SearchResult;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused import

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

import org.eclipse.che.ide.api.editor.EditorAgent;
import org.eclipse.che.ide.api.resources.SearchResult;
import org.eclipse.che.ide.search.factory.FindResultNodeFactory;
import org.eclipse.che.ide.ui.smartTree.TreeStyles;
import org.eclipse.che.ide.ui.smartTree.compare.NameComparator;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove a few unused imports above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

protected Promise<List<Node>> getChildrenImpl() {
List<Node> fileNodes = new ArrayList<>();
List<SearchOccurrence> occurrences = searchResult.getOccurrences();
occurrences.sort(Comparator.comparingInt((SearchOccurrence searchOccurrence) -> searchOccurrence.getLineNumber()));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be simplified (SearchOccurrence searchOccurrence) -> searchOccurrence.getLineNumber()) -> SearchOccurrence::getLineNumber

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


/** {@inheritDoc} */
@Override
public NodePresentation getPresentation(boolean update) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will do updatePresentation(nodePresentation) twice when nodePresentation == null and update is true. Is it OK?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


final SearchResult result = searcher.search(expr);
final List<SearchResultEntry> searchResultEntries = result.getResults();
final List<ItemReference> items = new ArrayList<>(searchResultEntries.size());
final List<SearchResultDto> s = new ArrayList<>(searchResultEntries.size());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be makes sense something more readable as name of variable instead of s, WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@vparfonov vparfonov changed the title [WIP] CHE-5174 Improving search results CHE-5174 Improving search results Aug 2, 2017
@codenvy-ci
Copy link

Build # 3250 - FAILED

Please check console output at https://ci.codenvycorp.com/job/che-pullrequests-build/3250/ to view the results.

// verify(view).showSelectPathDialog();
// verify(view, never()).getSearchText();
// }
//}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe should to remove this code or rework

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

* @return
*/
String getLineContent();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to fix javadoc

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

*/
SearchOccurrenceDto withLineContent(String lineContent);

}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to fix javadoc

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@@ -80,6 +80,11 @@
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-highlighter</artifactId>
<version>5.2.1</version>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think need to move version to the parent pom

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, will be fixed after eclipse-che/che-dependencies#50

* @param searchResultEntries
* @return
* @throws ServerException
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix java doc

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


if ((endOffset > txt.length()) || (startOffset > txt.length())) {
throw new ServerException(
"Token " + termAtt.toString() + " exceeds length of provided text sized " + txt.length());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo sized -> size

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@codenvy-ci
Copy link

Build # 3256 - FAILED

Please check console output at https://ci.codenvycorp.com/job/che-pullrequests-build/3256/ to view the results.

@codenvy-ci
Copy link

Build # 3266 - FAILED

Please check console output at https://ci.codenvycorp.com/job/che-pullrequests-build/3266/ to view the results.

line numbers are shown for matches
multiple matches in the same file are shown individually
when you click on a search result, the editor loads the file AND jumps straight to the matching line with all instances of the search term already highlighted

Signed-off-by: Vitalii Parfonov <vparfonov@redhat.com>
@vparfonov vparfonov force-pushed the searchwithpossitions branch from 1e04c5e to 90e5866 Compare August 3, 2017 12:08
for (SearchResultDto dto : arg) {
results.add(new SearchResult(dto));
}
return results;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with @RomanNikitenko .. @vparfonov can you take a look?

import java.util.List;

/**
* @author Vitalii Parfonov
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

javadoc

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually class represents a POJO with a readable name.
javadoc is not necessary

ReadFileUtils.getLine(tempFile.toFile(), 10000);

}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

too many new lines.

@codenvy-ci
Copy link

Build # 3268 - FAILED

Please check console output at https://ci.codenvycorp.com/job/che-pullrequests-build/3268/ to view the results.

@tolusha
Copy link
Contributor

tolusha commented Aug 3, 2017

Do we need selenium tests to keep up to date?

@vparfonov
Copy link
Contributor Author

@tolusha yes, @SkorikSergey already start work on it

Signed-off-by: Vitalii Parfonov <vparfonov@redhat.com>
@codenvy-ci
Copy link

Build # 3277 - FAILED

Please check console output at https://ci.codenvycorp.com/job/che-pullrequests-build/3277/ to view the results.

Signed-off-by: Vitalii Parfonov <vparfonov@redhat.com>
@vparfonov vparfonov requested a review from slemeur August 14, 2017 12:12
@vparfonov vparfonov merged commit 83150f4 into master Aug 14, 2017
@vparfonov vparfonov deleted the searchwithpossitions branch August 14, 2017 13:09
vparfonov added a commit that referenced this pull request Aug 14, 2017
vparfonov added a commit that referenced this pull request Aug 14, 2017
@vparfonov vparfonov restored the searchwithpossitions branch August 14, 2017 13:18
@codenvy-ci
Copy link

Build # 3367 - FAILED

Please check console output at https://ci.codenvycorp.com/job/che-pullrequests-build/3367/ to view the results.

dmytro-ndp pushed a commit to dmytro-ndp/che that referenced this pull request Aug 16, 2017
* CHE-5714:Improving search results:

line numbers are shown for matches
multiple matches in the same file are shown individually
when you click on a search result, the editor loads the file AND jumps straight to the matching line with all instances of the search term already highlighted

Signed-off-by: Vitalii Parfonov <vparfonov@redhat.com>

* Code cleanup

Signed-off-by: Vitalii Parfonov <vparfonov@redhat.com>
dmytro-ndp pushed a commit to dmytro-ndp/che that referenced this pull request Aug 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants