-
Notifications
You must be signed in to change notification settings - Fork 54
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
Code cleanup #1006
Code cleanup #1006
Conversation
import org.eclipse.lsp4e.LSPEclipseUtils; | ||
import org.eclipse.lsp4j.Location; | ||
import org.eclipse.search.ui.text.Match; | ||
|
||
public class URIMatch extends Match { | ||
|
||
public final @NonNull Location location; | ||
public static URIMatch create(final Location location) throws BadLocationException, URISyntaxException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's wrong with sticking to a constructor here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is that the first invocation in a constructor needs to be a super() call, that's why the current implementation parses the URI three times instead of once and then reusing the uri object to construct arguments for the parent constructor. which is very inefficient.
That is what we have currently:
public URIMatch(@NonNull Location location) throws BadLocationException {
super(
URI.create(location.getUri()),
LSPEclipseUtils.toOffset(location.getRange().getStart(), LSPEclipseUtils.getDocument(URI.create(location.getUri()))),
LSPEclipseUtils.toOffset(location.getRange().getEnd(), LSPEclipseUtils.getDocument(URI.create(location.getUri()))) - LSPEclipseUtils.toOffset(location.getRange().getStart(), LSPEclipseUtils.getDocument(URI.create(location.getUri()))));
this.location = location;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, thanks. Can't wait for https://openjdk.org/jeps/447 ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, thanks. Can't wait for openjdk.org/jeps/447 ;)
Me too!
No description provided.