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

Uast filtering #135

Merged
merged 11 commits into from
Jun 29, 2018
Merged

Uast filtering #135

merged 11 commits into from
Jun 29, 2018

Conversation

smacker
Copy link
Contributor

@smacker smacker commented Jun 22, 2018

Based on: #128

Fix: #49

No protobuf decoding on FE. If we decided to go that way: we can implement it later.
Though I would experiment on dashboard first, not here.

screen shot 2018-06-22 at 15 56 24

@smacker smacker requested review from carlosms and bzz June 22, 2018 14:00
@bzz
Copy link
Contributor

bzz commented Jun 26, 2018

Woks like a charm! 👏

@smacker shall we add simple progress indicator in here? Nothing fancy, a simple clue to the user that it's in progress.

On my local machine under heavy CPU load it took a while to UAST to get back and having no visual feedback in situation like this can be confusing

@bzz
Copy link
Contributor

bzz commented Jun 26, 2018

Few other things that seems not to be related to the UAST filtering itself were moved to #137

@smacker
Copy link
Contributor Author

smacker commented Jun 26, 2018

Yes. You are right. I missed a loader somehow, my bad. Most probably it worked too fast on my laptop :) Thanks!

Copy link
Contributor

@carlosms carlosms left a comment

Choose a reason for hiding this comment

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

Besides the inline comments, I have two more:

  • Missing documentation in res-api.md
  • Bad layout, the main panel overflows in the bottom:

a

.then(uast => {
this.setState({ uast: transformer(uast) });
})
.catch(err => this.state({ uast: null, error: err }));
Copy link
Contributor

Choose a reason for hiding this comment

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

should be setState

@@ -116,6 +116,7 @@ func Query(db service.SQLDB) RequestProcessFunc {
nodes, err := service.UnmarshallUAST(val)
if err == nil {
colData[columnNames[i]] = nodes
colData["__uast-protobufs"] = val
Copy link
Contributor

Choose a reason for hiding this comment

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

Using the same name does not work when you can have multiple uast columns.

For example:

select file_path, language(file_path, blob_content) as lang,
uast(blob_content, lang, '//*[@roleNumber and @roleLiteral]') as numbers,
uast(blob_content, lang, '//*[@roleString and @roleLiteral]') as strings
from files where lang = 'Go' limit 1

If you open the numbers column and search, you get results for the strings uast nodes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great catch! thank you!


let content = null;
if (searchResults && !searchResults.length) {
content = <NotFound>Nothing found</NotFound>;
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be content = <NotFound />;?


resp := &uast.Node{InternalType: "Search results"}

if req.Filter != "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe an empty filter could be a bad request error, to simplify this part of the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm open to this change. The only problem is then we will move complexity to frontend. Please let me know it's better to have it in JS than in Go.

Copy link
Contributor

Choose a reason for hiding this comment

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

If you are talking about disabling the search button when the input is empty, I think it adds a nice feel to the interface and it's not that much complexity. I would make this change, but I'm also OK merging as it is. Up to you 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm talking about how to return to full UAST.
Right now you can filter than just remove the filter query and get origin UAST back.
If we disable search button we would need one more button for it :) I personally use this feature.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think for now I would keep current behavior to be consistent with dashboard. But feel free to create an issue if you see how to improve it! Thank you.

@smacker
Copy link
Contributor Author

smacker commented Jun 26, 2018

rebased 😢 😢 😢

@smacker
Copy link
Contributor Author

smacker commented Jun 27, 2018

@bzz @carlosms please another pass

@carlosms
Copy link
Contributor

A few comments:

  • UAST viewer has a loading indicator, but the CODE right panel does not. I would be good if this was consistent.
  • If /filter fails the whole modal content gets replaced. this means that you cannot fix an xpath query with invalid syntax, for example. I think the UAST modal should use the same error overlay as the CODE modal.
    a
  • It would be better if an invalid xpath query returned an error different to 'internal server error'.

Signed-off-by: Maxim Sukharev <maxim@sourced.tech>
Signed-off-by: Maxim Sukharev <maxim@sourced.tech>
Signed-off-by: Maxim Sukharev <maxim@sourced.tech>
Signed-off-by: Maxim Sukharev <maxim@sourced.tech>
Signed-off-by: Maxim Sukharev <maxim@sourced.tech>
Signed-off-by: Maxim Sukharev <maxim@sourced.tech>
Signed-off-by: Maxim Sukharev <maxim@sourced.tech>
Signed-off-by: Maxim Sukharev <maxim@sourced.tech>
Signed-off-by: Maxim Sukharev <maxim@sourced.tech>
Signed-off-by: Maxim Sukharev <maxim@sourced.tech>
Signed-off-by: Maxim Sukharev <maxim@sourced.tech>
@smacker
Copy link
Contributor Author

smacker commented Jun 28, 2018

rebase.

  1. not sure why I should fix code viewer in PR about uast viewer, but I did.
  2. changed to display error similar to the one in code viewer
  3. there is no "special" error for it. I changed 500 to bad request and return string of error. In this case: UastFilter() failed: Invalid expression. But it isn't really correct. Real internal error will be also returned as bad request. Though hopefully it's unlikely.

@carlosms
Copy link
Contributor

there is no "special" error for it. I changed 500 to bad request and return string of error. In this case: UastFilter() failed: Invalid expression. But it isn't really correct. Real internal error will be also returned as bad request. Though hopefully it's unlikely.

Maybe we could open a request to report different this error types?

Copy link
Contributor

@carlosms carlosms left a comment

Choose a reason for hiding this comment

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

👍 looks good to me

Copy link
Contributor

@bzz bzz left a comment

Choose a reason for hiding this comment

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

👏

@smacker smacker mentioned this pull request Jun 29, 2018
@smacker
Copy link
Contributor Author

smacker commented Jun 29, 2018

issue to client-go: https://github.com/bblfsh/client-go/issues/65

@smacker smacker merged commit 4a32d62 into src-d:master Jun 29, 2018
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.

3 participants