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

Feat/enum completion #485

Merged
merged 25 commits into from
Feb 1, 2022
Merged

Feat/enum completion #485

merged 25 commits into from
Feb 1, 2022

Conversation

georgejecook
Copy link
Contributor

Adds completions for enums and enum statements. Works as follows:

  • if current token is an enum member, then only members for that enum are returned
  • includes global scope enum types in results, without affecting completions
  • includes namespace enum types; non exclusively (i.e. will include the classes and functions as well)

@georgejecook georgejecook marked this pull request as draft January 15, 2022 12:10
@georgejecook georgejecook changed the base branch from master to feat/enum January 15, 2022 12:45
Copy link
Member

@TwitchBronBron TwitchBronBron left a comment

Choose a reason for hiding this comment

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

I pushed some commits to clean up formatting and a few other small issues. I have one question, but other than that, looks great so far!

src/Scope.ts Outdated Show resolved Hide resolved
src/Scope.ts Outdated Show resolved Hide resolved
@georgejecook
Copy link
Contributor Author

somethings gone a bit weird here, @TwitchBronBron - I accidentally did the validation work onthis branch, so I dropped that commit and force pushed.
I then noticed all my works was missing, so I merged it back in.
Now I find that the references for the primary dotted gets is missing.
not sure what's going on..

hayyylp :)

@TwitchBronBron
Copy link
Member

I reverted that code because it wasn't helpful and didn't solve what we needed. Stick with the walker for now...I'll come up with a more efficient approach later.

@georgejecook
Copy link
Contributor Author

@TwitchBronBron updated to use the walker; but it no longer runs. I think it might be a circular reference, issue; but this ts error is beyond me.


> brighterscript@0.42.0 test
> nyc mocha


TypeError: Class extends value undefined is not a constructor or null
    at Object.<anonymous> (/home/george/hope/open-source/vsc/brighterscript/src/XmlScope.ts:2:601)
    at Module._compile (node:internal/modules/cjs/loader:1092:14)
    at Module.replacementCompile (/home/george/hope/open-source/vsc/brighterscript/node_modules/append-transform/index.js:60:13)
    at Module.m._compile (/home/george/hope/open-source/vsc/brighterscript/node_modules/ts-node/src/index.ts:839:23)
    at Module._extensions..js (node:internal/modules/cjs/loader:1121:10)
    at require.extensions.<computed> (/home/george/hope/open-source/vsc/brighterscript/node_modules/ts-node/src/index.ts:842:12)
    at Object.<anonymous> (/home/george/hope/open-source/vsc/brighterscript/node_modules/append-transform/index.js:64:4)
    at Module.load (node:internal/modules/cjs/loader:972:32)
    at Function.Module._load (node:internal/modules/cjs/loader:813:14)

@TwitchBronBron
Copy link
Member

Check all your newly added import statements in .ts files and make sure none of them are coming from ".." or "../../". (Without a file name). Those regularly cause circular ref issues. Always import from an exact files.

@TwitchBronBron TwitchBronBron marked this pull request as ready for review February 1, 2022 15:07
@TwitchBronBron TwitchBronBron merged commit c2b3aa8 into feat/enum Feb 1, 2022
@TwitchBronBron TwitchBronBron deleted the feat/enum-completion branch February 1, 2022 15:07
TwitchBronBron added a commit that referenced this pull request Feb 11, 2022
* Enum support in Lexer

* Basic enum parsing support

* Parser support for enums.

* Baseline enum implementation.

* Enum declaration validations

* Fix lint issues.

* include parent namespace name in enum statements.

* Add EnumStatement to findReferences

* vscode formatting setting.

* Add primaryDottedGetExpressions to _references

* Fix primaryDottedGetExpressions

* Undo `primaryDottedGetExpressions`

* Fix parse errors when enum is at top of file with other content

* Adds plugin hooks for file validation

* Undo space in settings file

* Feat/enum completion (#485)

* adds completions for enum types

* add tests to prove there are no enum member collisions

* Formatting fixes

* small var naming tweaks

* remove unnecessary eslint disable.

* clean up test a little

* adds validation for enums

* adds completions for enum types

* add tests to prove there are no enum member collisions

* Formatting fixes

* small var naming tweaks

* remove unnecessary eslint disable.

* clean up test a little

* changes namespace.enumStatements to map

* changes namespace.enumStatements to map

* fixes broken imports

* uses visitor to ascertain dotted get statements

* fix circular ref issues.

* clean up some tests

Co-authored-by: Bronley Plumb <bronley@gmail.com>

* Feat/enum validation (#486)

* adds completions for enum types

* add tests to prove there are no enum member collisions

* Formatting fixes

* small var naming tweaks

* remove unnecessary eslint disable.

* clean up test a little

* adds validation for enums

* adds completions for enum types

* add tests to prove there are no enum member collisions

* Formatting fixes

* small var naming tweaks

* remove unnecessary eslint disable.

* clean up test a little

* changes namespace.enumStatements to map

* changes namespace.enumStatements to map

* fixes broken imports

* uses visitor to ascertain dotted get statements

* fix circular ref issues.

* Expression tracking during parse.

* Partial support for re-calculating `references.expressions`

* Capture rest of missing expressions.

* Fix lint issues.

* integrate with `parser.references.expressions`

* Remove unnecessary eslint disable comment

* Clean up enum tests

* clean up some tests

Co-authored-by: Bronley Plumb <bronley@gmail.com>

* Fire plugin events for getTranspiledFile.
Add new event properties

* fix lint issues.

* Tests for enum transpile.

* Don't clear parser._references during enum validate

* Fix reflection func for EnumStatement

* Add generics support to Cache class. Use map.

* Implement enum transpile.

* Move file validation into  program.validate()

* fix lint issues

* Fix bug with string enums not transpiling

* make test work on node 10

* better validation for unknown enum values

* make `getFile` more flexible.

* tweaks

* Tweaks.

* Fix completions case sensitivity but

* Fix enum member completions

* Fixed some broken enum completions

* Fix other broken enum completions

* Cache extens map.

* Detect duplicate enum declarations

* fix lint issues

* Remove duplicate tests.
Move enum tests into Enum.spec.ts

* fix lint issue

* Fix unit test indentation bugs

* verify all top-level items show in completion

* use `setFile`

* Fix enum completions

* semantic token support for enums

* Emit better transpiled enums even with errors

* flag non-literal enum values.

* Safer enum member access

* completions test

* Transpile `invalid` for non-literal enums

* Add enum docs

* remove old launch.json

Co-authored-by: George Cook <george@tantawowa.com>
@rokucommunity rokucommunity deleted a comment from nievesmiguel Mar 3, 2022
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.

None yet

2 participants