Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Add Scope For Alias and Package Name of Import Declarations #97

Merged
merged 3 commits into from
Oct 10, 2016

Conversation

joefitzgerald
Copy link
Contributor

This adds two new scopes:

  • entity.alias.import.go
  • entity.name.import.go

This allows import declarations to be tokenized, and prevents them from being recognized as quoted strings. This paves the way for package autocompletion for single and multi-line import declarations:

Single line import

import "fmt"

Single line import with alias

import aliasedfmt "fmt"

Multi line import

import (
    "fmt"
)

Multi-line import with alias

import (
    aliasedfmt "fmt"
)

Fixes joefitzgerald/go-plus#226
Requires joefitzgerald/autocomplete-go#50 to allow autocompletion in import statements

@winstliu
Copy link
Contributor

winstliu commented Oct 9, 2016

I think the strings should still get the customary string.quoted.double.go/punctuation.definition.string.begin/end.go scopes.

@joefitzgerald
Copy link
Contributor Author

A string is a go type. The text inside the package portion of an import declaration is not a string.

@joefitzgerald
Copy link
Contributor Author

I take that back: https://golang.org/ref/spec#ImportPath. The spec does define an import path as a string literal. Will add that back in.

@joefitzgerald joefitzgerald force-pushed the jf-ensure-imports-have-scope branch from 114e2a7 to fefa6d1 Compare October 9, 2016 22:49
@@ -143,6 +143,48 @@
'name': 'entity.name.package.go'
}
{
'comment': 'Single line import declarations'
'match': '(?<=import)\\s+([^\\s]*)?\\s?((")([^"]*)("))'
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe use \\s* instead of \\s??

@joefitzgerald joefitzgerald merged commit 757e0a1 into master Oct 10, 2016
@winstliu winstliu deleted the jf-ensure-imports-have-scope branch January 15, 2017 01:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants