-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Closes #908 - Added functionality to retrieve the first line of a match. #911
Closes #908 - Added functionality to retrieve the first line of a match. #911
Conversation
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.
Reviewed 4 of 4 files at r1.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @mbrill-nt)
components/inspectit-ocelot-configurationserver/src/main/java/rocks/inspectit/ocelot/rest/file/FileController.java, line 102 at r1 (raw file):
retrieveFirstLine
Imo, includeFirstLine
would be better.
Also ensure that the request accepts it in the following format include-first-line
. In the request we don't want to have parameters in camel case .
components/inspectit-ocelot-configurationserver/src/main/java/rocks/inspectit/ocelot/search/FileContentSearchEngine.java, line 127 at r1 (raw file):
Optional.of(content.substring(startLine.getStartIndex(), startLine.getEndIndex())
Please split this up in multiple statements.
components/inspectit-ocelot-configurationserver/src/main/java/rocks/inspectit/ocelot/search/FileContentSearchEngine.java, line 130 at r1 (raw file):
SearchResult
We have a lot of stuff here, now, so let's add the lombok builder the search result class and use a builder.
Don't forget to add the @NoArgsConstructor
as well, otherwise it cannot be serialized by spring, I think..
Then we don't have to store all these variables.
while (matcher.find() && limitCounter.decrementAndGet() >= 0) {
int start = matcher.start();
SearchResult.SearchResultBuilder resultBuilder = SearchResult.builder();
while (start >= currentLine.getEndIndex()) {
currentLine = listIterator.next();
}
resultBuilder.startLine(currentLine.getLineNumber());
resultBuilder.startColumn(start - currentLine.getStartIndex());
...
SearchResult result = resultBuilder.build();
results.add(result);
}
components/inspectit-ocelot-configurationserver/src/main/java/rocks/inspectit/ocelot/search/SearchResult.java, line 25 at r1 (raw file):
* The first line of the match. */ private Optional<String> firstLine;
Don't use an Optional
here. Makes it more complicated for serialization.
Also add the @JsonInclude(Include.NON_NULL)
annotation to it, then it will be ignored in case it is null.
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.
Reviewable status: 0 of 4 files reviewed, 4 unresolved discussions (waiting on @mariusoe)
components/inspectit-ocelot-configurationserver/src/main/java/rocks/inspectit/ocelot/rest/file/FileController.java, line 102 at r1 (raw file):
Previously, mariusoe (Marius Oehler) wrote…
retrieveFirstLine
Imo,
includeFirstLine
would be better.Also ensure that the request accepts it in the following format
include-first-line
. In the request we don't want to have parameters in camel case .
Done.
components/inspectit-ocelot-configurationserver/src/main/java/rocks/inspectit/ocelot/search/FileContentSearchEngine.java, line 127 at r1 (raw file):
Previously, mariusoe (Marius Oehler) wrote…
Optional.of(content.substring(startLine.getStartIndex(), startLine.getEndIndex())
Please split this up in multiple statements.
Done.
components/inspectit-ocelot-configurationserver/src/main/java/rocks/inspectit/ocelot/search/FileContentSearchEngine.java, line 130 at r1 (raw file):
Previously, mariusoe (Marius Oehler) wrote…
SearchResult
We have a lot of stuff here, now, so let's add the lombok builder the search result class and use a builder.
Don't forget to add the@NoArgsConstructor
as well, otherwise it cannot be serialized by spring, I think..Then we don't have to store all these variables.
while (matcher.find() && limitCounter.decrementAndGet() >= 0) { int start = matcher.start(); SearchResult.SearchResultBuilder resultBuilder = SearchResult.builder(); while (start >= currentLine.getEndIndex()) { currentLine = listIterator.next(); } resultBuilder.startLine(currentLine.getLineNumber()); resultBuilder.startColumn(start - currentLine.getStartIndex()); ... SearchResult result = resultBuilder.build(); results.add(result); }
Done.
components/inspectit-ocelot-configurationserver/src/main/java/rocks/inspectit/ocelot/search/SearchResult.java, line 25 at r1 (raw file):
Previously, mariusoe (Marius Oehler) wrote…
Don't use an
Optional
here. Makes it more complicated for serialization.Also add the
@JsonInclude(Include.NON_NULL)
annotation to it, then it will be ignored in case it is null.
Done.
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.
Reviewed 4 of 4 files at r2, 1 of 1 files at r3.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @mariusoe)
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.
Reviewable status:
complete! all files reviewed, all discussions resolved
This change is