Skip to content
This repository was archived by the owner on Mar 8, 2020. It is now read-only.

Conversation

@juanjux
Copy link
Contributor

@juanjux juanjux commented Jun 19, 2018

Status:

  • Some identifiers don't have positions, because the don't in the native AST, but that could be fixed later (was that way in the version with the previous DSL too).

@juanjux juanjux self-assigned this Jun 19, 2018
@juanjux juanjux requested a review from dennwc June 19, 2018 16:14
.gitignore Outdated
.cache/*
__pycache__
makebuild.sh
.vscode/launch.json
Copy link
Member

Choose a reason for hiding this comment

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

.vscode/?

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 in the next commit.

},
BenchName: "issue_server101",
// XXX check this
//Semantic: fixtures.SemanticConfig{
Copy link
Member

Choose a reason for hiding this comment

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

Time to uncomment this?

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 in the next push.

var Preprocessors = []Mapping{
ObjectToNode{
InternalTypeKey: "ast_type",
// FIXME: if the node doesn't have positions or is missing end positions
Copy link
Member

Choose a reason for hiding this comment

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

Should be fixed now

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 in the next push.

return n, nil
}

// FIXME: decorators? (annotations/tags)
Copy link
Member

Choose a reason for hiding this comment

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

For now, this can be solved by adding a separate property to the node with async.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mmmm, I don't understand well you here.


// FIXME: decorators? (annotations/tags)
// FIXME: in Python, an argument being variadic or not depends on being on
// args.[kwonlyargs|args] or plain "args" not on any property of the argument
Copy link
Member

Choose a reason for hiding this comment

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

If I understood this correctly, it can be solved by using Cases operator. Please check Java/JS/Go for an example.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was pretty complicated. Forgot to remove that comment; I did the easiest option and changed the native structure to use the standard Arg(with properties)->Default argument instead of the multiple lists to you should have to match aligning to the right...

}
}
}
'PY3AST': {
Copy link
Member

Choose a reason for hiding this comment

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

Please regenerate the fixtures as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Odd. I deleted the fixtures, updated the SDK, did bblfsh-sdk update on the driver dir and regenerated the fixtures with go test and is still using that format.

async: false,
},
{ '@type': "uast:Alias",
Name: "somefunc",
Copy link
Member

Choose a reason for hiding this comment

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

Should be an Identifier node

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.

},
],
Type: { '@type': "uast:FunctionType",
Arguments: { '@type': "arguments",
Copy link
Member

Choose a reason for hiding this comment

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

Arguments should be an array

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!

},
Init: ~,
MapVariadic: false,
Name: "a",
Copy link
Member

Choose a reason for hiding this comment

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

Should be an Identifier node

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.

@juanjux
Copy link
Contributor Author

juanjux commented Jun 27, 2018

Did some fixes, still not finished here but at least now all the semantic objects are being generated 🎉 , which allows me to find some problems (other than the indicated here of Names being strings instead of uast:Identifier nodes).

@juanjux
Copy link
Contributor Author

juanjux commented Jun 28, 2018

Outside of the problem of nodes with missing partial or total positional info not being processed, I think I've fixed all the issues, but that problem doesn't allow me to check if uast:Comment and uast:RuntimeImports are right.

@juanjux
Copy link
Contributor Author

juanjux commented Jul 2, 2018

@dennwc as requested, updated so go test can be run after just a make build-native without installing anything locally.

Unfortunately, this breaks make test and make integration-test; I'll investigate why tomorrow. Ultimately I really thing go test should run the Makefile commands in the configured docker image to avoid these kludges and improve reproducibility.

@dennwc
Copy link
Member

dennwc commented Jul 2, 2018

@juanjux It's expected that user will run make build-native before running tests, so you can still add directives to that makefile (except installing stuff globally). This will ensure that build directory is self-contained and we will be able to package it as-is in Docker, Snap or anything else.

@juanjux
Copy link
Contributor Author

juanjux commented Jul 2, 2018

To make the directory self contained you've to investigate how to do it, how to install modules to a specific path, add the libs in that path to the language path, how to do the same with the binary. This for every language, while installing everything "globally" into a container fixes everything and avoid exotic running environment that could cause side effects (and I've found several of these as you know with this approach).

}

func SetPythonPath() {
os.Setenv("PYTHONPATH", filepath.Join(projectRoot,
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 make ./build/bin/native a bash script, set an env variable there and call python_driver from it.

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, it actually is already a bash script, I'll change it, I was just testing things to make this work, but I fear the environment variable solution won't work for parsing when the Python2 binary must be called, maybe with .pth files...

@juanjux
Copy link
Contributor Author

juanjux commented Jul 3, 2018

@dennwc with the SDK's update and the comments fix all nodes are now processed (searching for "ast_type" in *uast* doesn't give any results, trough I manually checked RuntimeImports which also had skipped subnodes and now doesn't).

I still need to fix make test to make this mergeable, working on it right now.

@juanjux
Copy link
Contributor Author

juanjux commented Jul 4, 2018

make test fixed.

@dennwc I kept the setting of the PYTHONPATH environment variable on the fixtures_test.go file because it's cleaner there, since the native file can be called from different paths depending on if it's a local test, or running inside the docker image, to make it work there I would had needed to add several different paths, which would be ugly.

I've also tested that it doesn't have problems on the tests that force the Python2 interpreter (like print.py).

PS: also rebased.

"LineComment",
"Block",
"ImportDeclaration",
"MethodDeclaration",
Copy link
Member

Choose a reason for hiding this comment

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

I can't find this type in the Python's native AST. Is it a list for Java?

'@pos': { '@type': "uast:Positions",
},
body: [
{ '@type': "FunctionDef",
Copy link
Member

Choose a reason for hiding this comment

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

uast:FunctionGroup

},
body: [
{ '@type': "FunctionDef",
'@token': "testfnc1",
Copy link
Member

Choose a reason for hiding this comment

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

uast:Identifier

},
],
},
body: { '@type': "FunctionDef.body",
Copy link
Member

Choose a reason for hiding this comment

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

uast:Block

Name: "a",
},
],
value: { '@type': "Call",
Copy link
Member

Choose a reason for hiding this comment

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

We could convert an __import__() to RuntimeImport as well. Thoughts?

Copy link
Contributor Author

@juanjux juanjux Jul 5, 2018

Choose a reason for hiding this comment

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

Unsure. There are actually tons of different ways to side-import things in python:

  1. Read and eval and assign to a global name in the module table.
  2. imp module.
  3. importlib
  4. ...many others that I don't remember but I've seen in the past, some of those pretty exotic.

But is true that __import__ is a default function in Python so that case at least could be easy to handle.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After some consideration, I've decided that I'll not convert __import__ in this version:

  • The argument could be a string, but also could be a variable, a function call, etc so we don't have a real way to know the RuntimeImport.path.

  • It will be assigned to a returned value that could be different from the argument.

This would need pretty complex annotations or flow analysis in the native drivers and thus I think is better to leave it to future versions to don't delay this anymore.

},
All: false,
Names: [
{ '@type': "alias",
Copy link
Member

Choose a reason for hiding this comment

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

uast:Identifier or uast:Alias

},
},
],
Path: "c",
Copy link
Member

Choose a reason for hiding this comment

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

uast:String

NewDriver: func() driver.BaseDriver {
return driver.NewExecDriverAt(filepath.Join(projectRoot, "build/bin/native"))
return driver.NewExecDriverAt(filepath.Join(projectRoot,
"build/.local/bin/python_driver"))
Copy link
Member

Choose a reason for hiding this comment

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

Ideally, we shouldn't change the path to native driver (../../build/bin/native). That script should use relative paths so it doesn't matter if it's in /opt/bblfsh/driver or in the project directory.

@juanjux
Copy link
Contributor Author

juanjux commented Jul 5, 2018

All checks from go test passing after the last push. Still need to handle the import levels (the dots) to prepend ../ to the path (or the dots themselves, I'm not sure) and handle __import__(string) as a RuntimeImport object.

@dennwc
Copy link
Member

dennwc commented Jul 6, 2018

@juanjux Please update fixture files

@juanjux
Copy link
Contributor Author

juanjux commented Jul 6, 2018

@dennwc they are updated :-?

@dennwc
Copy link
Member

dennwc commented Jul 6, 2018

Here's the output I'm getting:

Details ``` ~/go/src/github.com/bblfsh/python-driver$ git pull Already up to date. ~/go/src/github.com/bblfsh/python-driver$ go test ./driver/fixtures/ --- FAIL: TestPythonDriver (8.92s) --- FAIL: TestPythonDriver/native (0.85s) --- FAIL: TestPythonDriver/native/funcdef_kwonlyargs (0.00s) fixtures.go:154: Error Trace: fixtures.go:154 Error: Not equal: expected: "{\n 'PY3AST': {\n 'ast_type': \"Module\",\n... Test: TestPythonDriver/native/funcdef_kwonlyargs --- FAIL: TestPythonDriver/native/issue_server101 (0.47s) fixtures.go:154: Error Trace: fixtures.go:154 Error: Not equal: Test: TestPythonDriver/native/issue_server101 --- FAIL: TestPythonDriver/native/u2_func_params_kwonlyargs (0.00s) fixtures.go:154: Error Trace: fixtures.go:154 Error: Not equal: expected: "{\n 'PY3AST': {\n 'ast_type': \"Module\",\n... Test: TestPythonDriver/native/u2_func_params_kwonlyargs --- FAIL: TestPythonDriver/native/u2_func_params_kwonlyargs_default (0.00s) fixtures.go:154: Error Trace: fixtures.go:154 Error: Not equal: expected: "{\n 'PY3AST': {\n 'ast_type': \"Module\",\n body: [\n... Test: TestPythonDriver/native/u2_func_params_kwonlyargs_default --- FAIL: TestPythonDriver/native/u2_func_params_variadic_list (0.00s) fixtures.go:154: Error Trace: fixtures.go:154 Error: Not equal: expected: "{\n 'PY3AST': {\n 'ast_type': \"Module\",\n body: [\n {\n... Test: TestPythonDriver/native/u2_func_params_variadic_list --- FAIL: TestPythonDriver/native/u2_func_params_variadic_map (0.00s) fixtures.go:154: Error Trace: fixtures.go:154 Error: Not equal: expected: "{\n 'PY3AST': {\n 'ast_type': \"Module\",\n body: [\n {\n... Test: TestPythonDriver/native/u2_func_params_variadic_map --- FAIL: TestPythonDriver/uast (3.69s) --- FAIL: TestPythonDriver/uast/funcdef_kwonlyargs (0.01s) fixtures.go:254: Error Trace: fixtures.go:254 Error: Not equal: expected: "{ '@type': \"Module\",\n '@ROLE': [File, Module],\n '@pos': { ... Test: TestPythonDriver/uast/funcdef_kwonlyargs --- FAIL: TestPythonDriver/uast/issue_server101 (2.53s) fixtures.go:254: Error Trace: fixtures.go:254 Error: Not equal: Test: TestPythonDriver/uast/issue_server101 --- FAIL: TestPythonDriver/uast/u2_func_params_kwonlyargs (0.01s) fixtures.go:254: Error Trace: fixtures.go:254 Error: Not equal: expected: "{ '@type': \"Module\",\n '@ROLE': [File, Module],\n '@pos': { ... Test: TestPythonDriver/uast/u2_func_params_kwonlyargs --- FAIL: TestPythonDriver/uast/u2_func_params_kwonlyargs_default (0.01s) fixtures.go:254: Error Trace: fixtures.go:254 Error: Not equal: expected: "{ '@type': \"Module\",\n '@ROLE': [File, Module],\n '@pos': { ... Test: TestPythonDriver/uast/u2_func_params_kwonlyargs_default --- FAIL: TestPythonDriver/uast/u2_func_params_variadic_list (0.00s) fixtures.go:254: Error Trace: fixtures.go:254 Error: Not equal: expected: "{ '@type': \"Module\",\n '@ROLE': [File, Module],\n '@pos': { ... Test: TestPythonDriver/uast/u2_func_params_variadic_list --- FAIL: TestPythonDriver/uast/u2_func_params_variadic_map (0.00s) fixtures.go:254: Error Trace: fixtures.go:254 Error: Not equal: expected: "{ '@type': \"Module\",\n '@ROLE': [File, Module],\n '@pos': { ... Test: TestPythonDriver/uast/u2_func_params_variadic_map --- FAIL: TestPythonDriver/semantic (4.38s) --- FAIL: TestPythonDriver/semantic/issue30 (0.01s) fixtures.go:213: blacklisted nodes of type "Import" (1) found in the tree --- FAIL: TestPythonDriver/semantic/issue62 (0.01s) fixtures.go:213: blacklisted nodes of type "Import" (2) found in the tree --- FAIL: TestPythonDriver/semantic/issue94 (0.07s) fixtures.go:213: blacklisted nodes of type "Import" (3) found in the tree --- FAIL: TestPythonDriver/semantic/issue96 (0.07s) fixtures.go:213: blacklisted nodes of type "Import" (3) found in the tree --- FAIL: TestPythonDriver/semantic/issue_server101 (2.96s) fixtures.go:213: blacklisted nodes of type "Import" (6) found in the tree fixtures.go:230: type check failed for "uast:Function": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:FunctionType": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:Function": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:FunctionType": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:Function": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:FunctionType": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:Function": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:FunctionType": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:Function": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:FunctionType": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:Function": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:FunctionType": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:Function": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:FunctionType": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:Function": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:FunctionType": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:Function": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:FunctionType": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:Function": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:FunctionType": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:Function": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:FunctionType": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:Function": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:FunctionType": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:Function": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:FunctionType": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:Function": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:FunctionType": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:Function": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:FunctionType": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:Function": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:FunctionType": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:Function": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:FunctionType": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:Function": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:FunctionType": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:Function": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:FunctionType": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:Function": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:FunctionType": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:Function": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:FunctionType": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:Function": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:FunctionType": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:Function": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:FunctionType": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:Function": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:FunctionType": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:Function": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:FunctionType": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:Function": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:FunctionType": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:Function": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:FunctionType": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:Function": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:FunctionType": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:Function": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:FunctionType": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:Function": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:FunctionType": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:Function": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:FunctionType": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:Function": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:FunctionType": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:Function": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:FunctionType": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:Function": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:FunctionType": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:Function": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:FunctionType": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:Function": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:FunctionType": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:Function": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:FunctionType": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:Function": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:FunctionType": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:Function": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:FunctionType": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:Function": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:FunctionType": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:Function": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:FunctionType": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:Function": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:230: type check failed for "uast:FunctionType": incorrect object type: "uast:Identifier", expected: "uast:Argument" fixtures.go:254: Error Trace: fixtures.go:254 Error: Not equal: Test: TestPythonDriver/semantic/issue_server101 --- FAIL: TestPythonDriver/semantic/u2_func_params_variadic_list (0.01s) fixtures.go:254: Error Trace: fixtures.go:254 Error: Not equal: expected: "{ '@type': \"Module\",\n '@ROLE': [File, Module],\n '@pos': { ... Test: TestPythonDriver/semantic/u2_func_params_variadic_list --- FAIL: TestPythonDriver/semantic/u2_func_params_variadic_map (0.01s) fixtures.go:254: Error Trace: fixtures.go:254 Error: Not equal: expected: "{ '@type': \"Module\",\n '@ROLE': [File, Module],\n '@pos': { ... Test: TestPythonDriver/semantic/u2_func_params_variadic_map --- FAIL: TestPythonDriver/semantic/u2_import_module_alias (0.00s) fixtures.go:213: blacklisted nodes of type "Import" (1) found in the tree --- FAIL: TestPythonDriver/semantic/u2_import_multiple (0.01s) fixtures.go:213: blacklisted nodes of type "Import" (1) found in the tree --- FAIL: TestPythonDriver/semantic/u2_import_rename (0.01s) fixtures.go:213: blacklisted nodes of type "Import" (1) found in the tree --- FAIL: TestPythonDriver/semantic/u2_import_simple (0.01s) fixtures.go:213: blacklisted nodes of type "Import" (2) found in the tree --- FAIL: TestPythonDriver/semantic/u2_import_subsymbol (0.01s) fixtures.go:213: blacklisted nodes of type "Import" (1) found in the tree --- FAIL: TestPythonDriver/semantic/u2_import_subsymbol_alias (0.01s) fixtures.go:213: blacklisted nodes of type "Import" (1) found in the tree FAIL FAIL github.com/bblfsh/python-driver/driver/fixtures 8.925s ```
Maybe wrong Python version? It's still not running tests in Docker, I guess.

@juanjux
Copy link
Contributor Author

juanjux commented Jul 6, 2018

@dennwc added a missing file, could you try again?

@dennwc
Copy link
Member

dennwc commented Jul 6, 2018

It's better now, but still getting this diff in fixtures:
image

@juanjux
Copy link
Contributor Author

juanjux commented Jul 6, 2018

@dennwc good catch, should be fixed now.

@juanjux
Copy link
Contributor Author

juanjux commented Jul 12, 2018

PR updated with some more positions added to some uast:Identifiers. Some (most notably alias and keywords and function names) won't have positions because they don't have it in the native AST or their position in their native AST is the one of the parent node (e.g. functions).

I was thinking of creating (in Go, I fear) a generic tokenizer pass that could, given a token string and a range of positions, get the token position by the name and the range. For example for a function argument called foo it could be called like: FixPositionOp("foo", argsNodeStartPos, argsNodeEndPos) Then we could use it in the UAST and Semantic UAST to fix most positions of most languages except some cases like several tokens with the same name in the range. But that is a project for another day...

Juanjo Alvarez added 7 commits July 12, 2018 15:34
- Added  mappings for comments, imports and functions

- Change uast.Import for RuntimeImport

- Fix for comments and function arguments

Signed-off-by: Juanjo Alvarez <juanjo@sourced.tech>
…rovements

- Normalized function arguments, updated annotations to the new format

- Removed positions since they don't work when endpos is missing. Added new argument annotations

- Remove two now unneeded workarounds (fix in Python ast module and fix in the SDK)

- Use uast:Identifiers instead of str for Name fields in semantic objects

- FunctionType.Arguments should be an Array

- Un-wtfized python's qualified identifiers. Updated SDK. Regenerated tests

- Update fixtures

- Map normal arg as uast.Argument

- Changes to run go test locally

- Changes some files to "go test" can be run only running
`make native-build`. Unfortunately, this breaks `make test`
and `make integration-test`. WIP.

- Add missing file

- Correct the column of QualifiedIdentifier children

- Fix comments

- Fix make test

Signed-off-by: Juanjo Alvarez <juanjo@sourced.tech>

rebase this

Signed-off-by: Juanjo Alvarez <juanjo@sourced.tech>
Signed-off-by: Juanjo Alvarez <juanjo@sourced.tech>
Signed-off-by: Juanjo Alvarez <juanjo@sourced.tech>
Signed-off-by: Juanjo Alvarez <juanjo@sourced.tech>
Signed-off-by: Juanjo Alvarez <juanjo@sourced.tech>
Signed-off-by: Juanjo Alvarez <juanjo@sourced.tech>
Denys Smirnov and others added 3 commits July 12, 2018 15:34
Signed-off-by: Denys Smirnov <denys@sourced.tech>
Signed-off-by: Juanjo Alvarez <juanjo@sourced.tech>
Signed-off-by: Juanjo Alvarez <juanjo@sourced.tech>
@juanjux
Copy link
Contributor Author

juanjux commented Jul 12, 2018

Checking why CI fails.

Signed-off-by: Denys Smirnov <denys@sourced.tech>
Signed-off-by: Denys Smirnov <denys@sourced.tech>
@juanjux juanjux merged commit 295eb2f into bblfsh:master Jul 20, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants