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

Added members to BscType, and adds ReferenceType (future lookups) #794

Merged

Conversation

markwpearce
Copy link
Collaborator

  1. Refactors BscType so each type can have members

Members of a type are possible symbols that can be referenced after the 'dot' ... eg, a class's fields and methods

  1. Adds ReferenceType (and PropertyReferenceType)

ReferenceType is a Proxy for a type that will be established later. eg. a Class that is defined later in the code (or in a different file), or a Namespace that hasn't been walked in the AST yet. PropertyReferenceType is used when we need to access returnType on a BscType, but we're not sure if the type has been defined yet.

  1. Changes the getType() method of many Statements and Expressions so that the result is more accurate.

  2. Eg. On DottedGetExpression.getType(), the expression is "walked back" and the code takes into account the type's getMemberType method to find the correct type of code like (new NameSpaceA.Klass()).method().property

  3. Adds NamespaceType and EnumType so getMemberType can be called on them.

src/FunctionScope.ts Outdated Show resolved Hide resolved
src/Scope.spec.ts Outdated Show resolved Hide resolved
src/types/BscType.ts Outdated Show resolved Hide resolved
@markwpearce markwpearce merged commit a942525 into rokucommunity:typing-phase1 Apr 20, 2023
TwitchBronBron added a commit that referenced this pull request Jun 6, 2023
* Add abstract TypeExpression class

* Convert type tokens to TypeExpressions (#785)

* Convert type tokens to TypeExpressions

* Fixed all tests

* Rebased and fixed any other merge issues

* Further work on SymbolTypeFlags

* Lint fixes

* Fixed issue with using enums as variables

* Uses complete TypeName as Custom type for TypeExpression.getType()

* Removed commented out code, fixed tests

* Fixes from PR review

* Fixed lint issues

---------

Co-authored-by: Mark Pearce <[email protected]>

* Removes Parsetime Static Type Setting (#791)

* Refactors statically set type to use a function

* Lint fixes

* Removed symbolTable getter from function scope - not used

* Adds ReferenceType (#792)

* Added ReferenceType and some tests

* Added scope linking for hovers

* Removed catch in try/finally in hoverprocessor

* Reverted typo

* Removed commented out code

* Changed to using Proxy, fixed circular references

* Fixed lint, added proper isReferencetype reflection

* Added members to `BscType`, and adds ReferenceType (future lookups) (#794)

* Large update to move BscType to a class and add ReferenceTypes

* Fixes validation errors when calling a dynamicType like a function

* Correctly resolves return types after a function call.

* Removed some commented out or dead code

* Fixed build errors

* BscType.symbolTable -> memberTable, PropertyReferenceType->TypePropertyReferenceType

* Fixed test that should fail

* Fix enum transpile crash

* Refactored `getType` to correctly use `SymbolTypeFlags` (#798)

* Fixed issues with namespaces and invalid things being used as types

* Removed unneeded method

* Ran npm install with latest code

* Removed commented and vestigal code, and added TODOs

* Removed additional commented code

* ClassType and InterfaceType refactor and Inheritance (#800)

* Changed CustomType to ClassType

* Adds BscType.equals(), and ClassType tests for inheritance

* Fixes issue when looking for members of classes with supertypes that were originally ReferenceTypes

* Rerfactor of InterfaceStatement and InetrfaceType work more similar to Classes

* Added tests, changed parentClass/Interface to use TypeExpression

* Fixes issue when classes and namespaces extend from a namespaced parent

* Changes from code review

* Type chain refactor (#802)

* Changed getType() methods to use an options parameter

* Refactors getType() to add opttions, and can find all the types in a chain of types

* Fixed lint errors

* Updated Tests

* Update src/interfaces.ts

Co-authored-by: Bronley Plumb <[email protected]>

* name change

---------

Co-authored-by: Bronley Plumb <[email protected]>

* Adds Union types (#803)

* initial commit

* Adds UnionType and associated tests

* Added helper functions to get the most general type from a list of types, including Union types

* Started working on Uniontype.membersTypes

* Started working on Uniontype.membersTypes

* Refactor of types to use  instead of

* Fixed lint errors

* Reverted benchmark package changes

* Removes `NamespacedVariableNamedExpressions` (#801)

* Removes NamespacedVariabledNamedExpressions

* Fixed rest of tests

* Fixes ignored parameter value in Parser.identifyingExpression

* UnionType Improvements (#806)

* Reworked type uniqness checking

* Changed logic of InterfaceType.isEqual

* Able to get member types from a UnionType

* Fixed lint errors

* Starting to add UnionExpression and parsing

* Added pipe token

* Added test for if inner type does not include member in UnionType.getMmeberTypes

* Updated UnionExpression transpile logic

* Re-added whitespace

* removed pipe in favor of 'or' for declaring/displaying union types

* Fix lint/build issues

* TypeExpressions more narrowly look for what they can accept

* Whitespace and typo fixes

* Adds unionType validation tests and allows uniontypes innertypes to be late defined

* fixed lint error

* Fixes issue with ReferenceTypes not displaying a full name

* Fix self references in unions (#808)

* Fixes issue with self-referencing symbols in unions

* Fixed lint error

* Type performance improvements (#811)

* Fixes issue with self-referencing symbols in unions

* Fixed lint error

* Starting performance benchmarking

* Starting performance benchmarking

* getType -> ZgetType()

* Reverse getType removal

* Removes double validation in ScopeValidator

* Trying out type caching

* Some benchmark thing

* Removes TypeCache

* Made the in typeExpression function more robust

* Removed unneeded code

* removed bad imports

* Fixes issue with potential crash when checking types

* Adds `enableTypeValidation` flag and documentation (#812)

* Added bsConfig option for enhancedTypingValidation

* Reverted any benchmark changes

* Added docs for 'enhancedTypingValidation' option

* Adds documentation

* In an effort to increase non-enhancedtypeValidation, old methods were re-added to short circuit getType() calls

* Changed flag to enableTypeValidation

* Fixed docs

* Fixed readme formatting

* Fixes from PR review

* Adds SymbolTable.getSymbolType() to wrap caching and ReferenceType creation (#813)

* Adds SymbolTable.getSymbolType() to wrap caching and ReferenceType creation

* Removed commented out code

* Add SymbolTable exports for plugins, etc

* Added exports from ./types

* Adds Type Casting  (#814)

* Adds TypeCastExpression

* Adds TypeCast expression

* fix lint issue

---------

Co-authored-by: Bronley Plumb <[email protected]>

---------

Co-authored-by: Mark Pearce <[email protected]>
Co-authored-by: Mark Pearce <[email protected]>
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.

2 participants