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-15 - Java stacktrace support (From Platform to Che Workspace) #5396

Merged
merged 5 commits into from
Jun 30, 2017

Conversation

vrubezhny
Copy link
Contributor

@vrubezhny vrubezhny commented Jun 16, 2017

Adds the possibility to click on a stacktrace line in order to open
a specified class in editor.

Example 1:
Example 1

Example 2:
Example-2

Also fixes CHE-293 (#5001) - String Written to Dev-Machine stdout not Escaped Properly

Issue: https://issues.jboss.org/browse/CHE-15
Issue: https://issues.jboss.org/browse/CHE-293

see: #5001

Signed-off-by: Victor Rubezhny vrubezhny@redhat.com

What does this PR do?

Adds the possibility to click on a stacktrace line in order to open
a specified class in editor.
Also fixes CHE-293 (#5001) - String Written to Dev-Machine stdout not Escaped Properly

What issues does this PR fix or reference?

Issue: https://issues.jboss.org/browse/CHE-15
Issue: https://issues.jboss.org/browse/CHE-293
(Issue: #5001)

Changelog

The fix adds the possibility to click on a stacktrace line withing a console in order to open an according java class in editor and reveal it to the line according to the info that in provided in stacktrace line.

Release Notes

This version introduces a smart selection for the console outputs. When having exceptions or errors in your stacktrace, you can now directly jump into the file by clicking on it from the outputs. The editor will open with the file and point to the line corresponding to the one provided in the stacktrace. This allows to quickly navigate to the code which is raising an issue.

[Animated Gif]

The smart selection capability is available for Java and NodeJS stacktrace at this moment.

Docs PR

Will need to be cover by: https://github.com/eclipse/che-docs/issues/249

@codenvy-ci
Copy link

Can one of the admins verify this patch?

@sunix sunix self-requested a review June 16, 2017 14:44
@@ -39,23 +41,30 @@
/** Follow output when printing text */
private boolean followOutput = true;

private OutputCustomizer customizer = null;
Copy link
Contributor

Choose a reason for hiding this comment

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

hello, is that the indent is expected ?

view.setDelegate(this);

view.hideCommand();
view.hidePreview();
view.setReRunButtonVisible(false);
view.setStopButtonVisible(false);

Copy link
Contributor

Choose a reason for hiding this comment

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

this line shouldn't be introduced

}

Copy link
Contributor

Choose a reason for hiding this comment

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

this line(spaces) shouldn't be introduced

@@ -89,7 +98,7 @@ public void printText(String text) {
public void printText(String text, String color) {
view.print(text, text.endsWith("\r"), color);

for (ActionDelegate actionDelegate : actionDelegates) {
for (ActionDelegate actionDelegate : actionDelegates) {
Copy link
Contributor

Choose a reason for hiding this comment

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

indent is with spaces, not with tabs

Copy link
Contributor

Choose a reason for hiding this comment

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

you've to check in the whole file as I see mainly only tabs while spaces are expected.

private static RegExp LINE_AT_EXCEPTION = compile("(\\s+at address:.+)");

private AppContext appContext;
private EditorAgent editorAgent;
Copy link
Contributor

Choose a reason for hiding this comment

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

the indent looks odd

import com.google.gwt.user.client.Timer;
import com.google.inject.Inject;

public class DefaultOutputCustomizer implements OutputCustomizer {
Copy link
Contributor

Choose a reason for hiding this comment

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

it is missing javadoc on the class. What it does, etc

public class DefaultOutputCustomizer implements OutputCustomizer {

private static RegExp LINE_AT = compile("(\\s+at .+)");
private static RegExp LINE_AT_EXCEPTION = compile("(\\s+at address:.+)");
Copy link
Contributor

Choose a reason for hiding this comment

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

it is missing the final keyword for the constants.

*/
@Override
public String customize(String text) {
String customText = text;
Copy link
Contributor

Choose a reason for hiding this comment

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

the formatting looks like it is not the expected one

String customText = text;

MatchResult matcher = LINE_AT.exec(text);
if(matcher != null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

spaces around parenthesis

@benoitf
Copy link
Contributor

benoitf commented Jun 16, 2017

ci-build

@benoitf benoitf added the kind/enhancement A feature request - must adhere to the feature request template. label Jun 16, 2017
@benoitf
Copy link
Contributor

benoitf commented Jun 16, 2017

as this issue is not a fix, it should include changelog and the release notes section.
@slemeur maybe documentation as well ?

@benoitf benoitf requested a review from slemeur June 16, 2017 14:47
@benoitf benoitf added status/code-review This issue has a pull request posted for it and is awaiting code review completion by the community. team/ide labels Jun 16, 2017
@vrubezhny
Copy link
Contributor Author

@benoitf I've added a couple of words to Change log. However, I don't know what is to be placed for Release Notes (especially once it not released yet)

@benoitf
Copy link
Contributor

benoitf commented Jun 16, 2017

@vrubezhny Changelog should be a one-line entry, so maybe move your "changelog" text as "Release notes" text and it should be ok

@codenvy-ci
Copy link

Build # 2833 - FAILED

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

@benoitf
Copy link
Contributor

benoitf commented Jun 16, 2017

@vrubezhny also there was a compilation issue https://ci.codenvycorp.com/job/che-pullrequests-build/2833/

@slemeur
Copy link
Contributor

slemeur commented Jun 16, 2017

Hi @vrubezhny !
This seems really cool.

@benoitf is right, this PR introduces a new feature so we need the release note section and the documentation prior to the merge. I can help on that.
We'll also need the QA team to review and validate the changes: @musienko-maxim.

Would you mind recording an animated gif to demo the new capability and attach it to the description of the PR?

@vrubezhny
Copy link
Contributor Author

vrubezhny commented Jun 16, 2017

@benoitf The compilation is known: my two classes (intrf+impl) have "RedHat, Inc." in their headers instead of "Codenvy, S.A.". I don't feel like adding the whole che-core-ide-app as an exclusion to license-maven-plugin is a good approach. Is there a better solution? (Or I just have to use original CodeEnvy's header?)

@vrubezhny
Copy link
Contributor Author

@slemeur I've copied text of ChangeLog to Release Notes. Please let me know if it's not enough.

And I'll try to record an animated gif... (not sure if I can do it on Fedora, though)

@vrubezhny vrubezhny force-pushed the che15 branch 2 times, most recently from 07f4354 to 7741e02 Compare June 16, 2017 17:10
@vrubezhny
Copy link
Contributor Author

vrubezhny commented Jun 16, 2017

@benoitf I believe I've fixed formatting and other issues you pointed to, as well as the 'missing headers' issue with build. Thanks for the review.

@benoitf
Copy link
Contributor

benoitf commented Jun 16, 2017

ci-build

@benoitf
Copy link
Contributor

benoitf commented Jun 16, 2017

@vrubezhny as there is the use of regexp and parsing, IMHO a unit test should be added to cover the analysis of the stack trace.
Else it will be hard to track if it's still working or not upon refactoring.

@codenvy-ci
Copy link

Adds the possibility to click on a stacktrace line in order to open
a specified class in editor.
Also fixes CHE-293 (eclipse-che#5001) - String Written to Dev-Machine stdout not Escaped Properly

Issue: https://issues.jboss.org/browse/CHE-15
Issue: https://issues.jboss.org/browse/CHE-293

see: eclipse-che#5001

Signed-off-by: Victor Rubezhny <vrubezhny@redhat.com>
@vrubezhny
Copy link
Contributor Author

@slemeur I've added the animated gifs to the PR description.

@benoitf The commit is updated due to the issue in my code, so ci-build is required for the PR once again. Sorry about that.

@benoitf
Copy link
Contributor

benoitf commented Jun 17, 2017

@vrubezhny Hello Victor. I'm not seing unit test as said yesterday. Also, could you add changes as adding a new commit (like using --fixup option) because, it's impossible to track what you changed between each review as we see only one commit even if you've done changes. Squashing/Rebasing can be done later when merging it. thanks.

@vrubezhny
Copy link
Contributor Author

@benoitf Yep, I haven't made JUnit test yet - I'll work on it on Monday. Thanks for pointing me to '--fixup' option, I'll follow this policy.

@slemeur
Copy link
Contributor

slemeur commented Jun 19, 2017

Hi @vrubezhny. Thanks for adding the animated gif, they are perfect. Looking at the code, I see that the regexp will properly cover java stacktraces. AFAIK it should also work for NodeJS but I'm bit worry that this might also create wrong interpretation for other type of stacktraces and bother the user.

So to start the discussion, should we:

  • check that the text found by the parser is actually a file before colorizing it and putting a link behind?
  • should we also handle urls?
  • allow the user to disable the smart selection in the console output
  • have the ability for the user to add regular expressions (in preferences for example)?
  • should we have the same behaviour in the terminal?

@vrubezhny
Copy link
Contributor Author

vrubezhny commented Jun 20, 2017

Hi @vrubezhny. Thanks for adding the animated gif, they are perfect. Looking at the code, I see that the regexp will properly cover java stacktraces. AFAIK it should also work for NodeJS but I'm bit worry that this might also create wrong interpretation for other type of stacktraces and bother the user.

Hi @slemeur.
That's it. It's proposed to work with java-stacktraces printed out to a console, it's not intended to work with other kinds of stacktraces. With proposed OutputCustomizer interface we can develop different kinds of customizers. Also, we can add preferences to allow enabling/disabling to the customizers, or configure different kinds of consoles to use different customizers.

So to start the discussion, should we:

  • check that the text found by the parser is actually a file before colorizing it and putting a link behind?

We can't do that, first of all because of the performance reasons: it takes quite a lot of time (and I suppose a several asynchronous IO requests) to perform such a check. If we make it synchronously the console output would tend to freeze. Otherwise the text would not be printed in FIFO manner. As far as I know, desktop eclipse doesn't check for a file existence when a stacktrace is being printed out to a console, it performs searching when a user clicks on a colorized line.
The only thing I probably would verify (beside of matching the stacktrace line RegExp) is that file name really ends with ".java" to make sure that we're in "proper" stacktrace line.

  • should we also handle urls?

Not sure I understand right... Have an example of URLs appearance?

  • allow the user to disable the smart selection in the console output

Do you mean like "to disable" the console text customization (turning it to a link) and as such, not to provide a user with the possibility to search for a class by a stacktrace line? Not sure. I didn't see such a preference before.

  • have the ability for the user to add regular expressions (in preferences for example)?

If you're going to process the other kinds of stacktraces (like the javascript ones) then you should have the other kind of detection and post-processing (like parsing the line for packages/classes/file name/line number and/or adding, probably, javascript-to-java mappings to your search algorithm). This is not something that easy to realize as something that can be configured by preference and, imho, we should rather provide different customizers for users and let them a possibility to enable/disable them. Or hardly set up different customizers depending on the kind of console it should work on.

  • should we have the same behaviour in the terminal?

As far as I understand, my change configures the terminal to use this customizer. So, if a java stacktrace would appear in terminal it will be customized as well. If it's not required I can try to disable/remove this behaviour from terminal.

@vrubezhny
Copy link
Contributor Author

@benoitf I'm going to add a commit with JUnit test to this PR. Should I use that --fixup option, or a separate commit would be OK?

@benoitf
Copy link
Contributor

benoitf commented Jun 23, 2017

@vrubezhny it is up to you, in all cases it will add a new commit (fixup is generating a commit as well)
At the end of the review you can either automatically rebase if you used fixup or manually rebase
Or we squash commits when merging on github

Signed-off-by: Victor Rubezhny <vrubezhny@redhat.com>
customText += text.substring(openBracket + "(".length(), closingBracket);
customText += "</a>";
customText += text.substring(closingBracket);
text = customText;
Copy link
Contributor

Choose a reason for hiding this comment

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

do you think that a String.format would be easier to read than concatenating tons of stuff ?

Copy link
Contributor

@benoitf benoitf Jun 26, 2017

Choose a reason for hiding this comment

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

so bad idea (mine) as GWT is not supporting formatting 👎

Copy link
Contributor Author

Choose a reason for hiding this comment

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

String.format/MessageFormat.format/Formatter.format are not available for GWT application and it doesn't look like a GWT replacement exists.

public List<File> apply(Resource[] children) throws FunctionException {
final List<File> result = newArrayList();

for (Resource child : children) {
Copy link
Contributor

Choose a reason for hiding this comment

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

would it be simpler to read with streams / filter/ Collectors.toList() ?

public void testNonStackTraceLines() throws Exception {
testStackTraceLine(false, "[STDOUT] Listening for transport dt_socket at address: 4403", null);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

an empty blank line is required at the end of the file

Signed-off-by: Victor Rubezhny <vrubezhny@redhat.com>
…Workspace)

Signed-off-by: Victor Rubezhny <vrubezhny@redhat.com>
…Workspace)

Signed-off-by: Victor Rubezhny <vrubezhny@redhat.com>
@vrubezhny
Copy link
Contributor Author

@benoitf I've added fixups for:

  • turning org.eclipse.che.ide.console.DefaultOutputCustomizer.collectChildren(Container, Path) to use streams / filter/ Collectors.toList()
  • added new line to last line of DefaultOutputCustomizerTest
  • added new line before DefaultOutputCustomizer.collectChildren() method's closing bracket (somehow lost on formatting)

@benoitf
Copy link
Contributor

benoitf commented Jun 26, 2017

@vparfonov ?

@benoitf benoitf merged commit 991b895 into eclipse-che:master Jun 30, 2017
@benoitf benoitf added this to the 5.15.0 milestone Jun 30, 2017
JPinkney pushed a commit to JPinkney/che that referenced this pull request Aug 17, 2017
…lipse-che#5396)

* CHE-15 - Java stacktrace support (From Platform to Che Workspace)
Adds the possibility to click on a stacktrace line in order to open
a specified class in editor.
Also fixes CHE-293 (eclipse-che#5001) - String Written to Dev-Machine stdout not Escaped Properly

Issue: https://issues.jboss.org/browse/CHE-15
Issue: https://issues.jboss.org/browse/CHE-293

see: eclipse-che#5001

Signed-off-by: Victor Rubezhny <vrubezhny@redhat.com>
@benoitf benoitf removed the status/code-review This issue has a pull request posted for it and is awaiting code review completion by the community. label Nov 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement A feature request - must adhere to the feature request template.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants