GithubHelp home page GithubHelp logo

go-driver's Introduction

Go driver for Babelfish Driver Status Build Status Native Version Go Version

Development Environment

Requirements:

  • docker
  • Go 1.13+

To initialize the build system execute: go test ./driver, at the root of the project. This will generate the Dockerfile for this driver.

To run the tests just execute go run test.go, this will start the test over the native and the Go components of the driver using Docker.

The build is done executing go run build.go. To evaluate the result using a docker container, execute: go run build.go test-driver && docker run -it test-driver.

If the project is located under $GOPATH, run all the above with GO111MODULE=on environment variable, or move the project to any other directory outside of $GOPATH.

License

GPLv3, see LICENSE

go-driver's People

Contributors

bzz avatar creachadair avatar dennwc avatar juanjux avatar lwsanty avatar mcarmonaa avatar mcuadros avatar ncordon avatar smola avatar tsolakoua avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

go-driver's Issues

Complete annotations

This issue will track missing annotations before promoting Go driver to beta.

TODO:

  • check driver with xpath and other bblfsh apps

semantic: Discrepancy in parsing of header comments

Basically, if we have:

// comment 1
// comment 2
package foo
// comment 3
// comment 4
import "bar"

Then:

  • comment 1, comment 2, comment 3 and comment 4 go in the Comments attribute of the root node
  • comment 1 and comment 2 go in the Doc attribute of the root node
  • comment 3 and comment 4 go in the Doc attribute of the GenDecl node in the root node's Decl attribute

However, if we have:

// comment 1

// comment 2
package foo
// comment 3

// comment 4
import "bar"

Then:

  • comment 1, comment 2, comment 3 and comment 4 still go in the Comments attribute of the root node
  • only comment 2 goes in the Doc attribute of the root node
  • only comment 4 goes in the Doc attribute of the GenDecl node in the root node's Decl attribute

Basically, any comments placed before a newline before the package/import keywords get removed from the Doc attributes of the respective nodes.

Driver image is too large

After an update, the driver image size increased by 100 MB.

It's probably due to the fact that we now use official Go image, while a bare Alpine image was used previously. Should be easy to fix.

Update native driver to Go 1.12

We should update the native Go driver to Go 1.12+.

Currently, the bug in go test breaks the build on Alpine, so we should have to either work around it by setting CGO_ENABLE=0 in SDK, or wait for the fix.

error during importing go driver as a dependency

during including go-driver to go.mod as a dependency

...
require (
	github.com/bblfsh/go-driver/v2 v2.7.3
...

error: go: github.com/bblfsh/go-driver/[email protected]: go.mod has non-.../v2 module path "github.com/bblfsh/go-driver" (and .../v2/go.mod does not exist) at revision v2.7.3

Comments include "//"

I extracted nodes from a Go file by XPath //*[@roleComment]. .Token values include // prepended, so it is hard to actually get the text. Not tested on /* */ comments.

Driver returns more than one the same comment

If it's parsed the following example:

package main

// inline comment.
const a=3

It is returned 4 nodes having Comment role instead of only one

  • internal_type: CommentGroup
    internalRole: Comments
    roles: Comment, List
  • internal_type: CommentGroup
    internalRole: Doc
    roles: Comment, List
  • internal_type: Comment
    internalRole: List
    roles: Comment

image

addendum:
This issue might be related to these similar ones in other languages drivers:
bblfsh/javascript-driver#36 bblfsh/python-driver#167 bblfsh/java-driver#86

Missing positions in external import parts

Consider this code:

import "gopkg.in/src-d/go-git.v4"

Each leaf in the tree of type uast:Identifier has a Position, but it is not filled. The parent uast:QualifiedIdentifier has it filled, however.

"#" is included into comments

This is related to #13

My Go driver version is 2.5.0. The //*[role='Comment'] nodes have @token-s with "#" prepended. I expect them to be erased.

semantic: Discrepancy in handling of imports

Basically, if I have this:

package main

import (
    "foo"
    _ "bar"
    . "baz"
    bak_alias "bak"
)

Then in order to get all imports, the xpath query: //uast:Import/Path works, yielding 8 nodes, twice the same ones, and all is good. However, in the case where I have:

package main

import (
    "foo" // foo
    _ "bar" 
    . "baz" 
    bak_alias "bak"
)

Then the same query does not return the foo nodes, as they now have the go:ImportSpec type. You can check that is the case for each import syntax.

Furthermore, if I have a comment directly above an import like here:

package main

import (
     // foo
    "foo" 
    _ "bar" 
    . "baz" 
    bak_alias "bak" 
)

Then the foo nodes also disappear, for the same reasons. This is not the case if I insert a new line between my comment and the import, as in here:

package main

import (
     // foo

    "foo" 
    _ "bar" 
    . "baz" 
    bak_alias "bak" 
)

Furthermore, when querying //uast:Comment in the snippets with the bug, we now get 3 nodes, one in the flat list, and two nested in the go:ImportSpec nodes - not in the Comment attribute btw, in the Doc attribute. I'm guessing this is maybe related to #56

So yeah, this is quite annoying as we are not able to retrieve imports properly. I think the solution is to change the type of the import node to the normalized uast:Import, but I'd like to point out that this again exemplifies issues with comments that we discussed in #56. I don't know if this a proper bug, or a design choice (I'm guessing the former), but I can't help thinking this is because we are intent on providing structure to comments, and, again, I think a simpler and unified approach should be taken, such as a single flat list with positional information.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.