Skip to content

Commit

Permalink
Merge master into v1 (#687)
Browse files Browse the repository at this point in the history
* Merge master into v1

* Cleaned up a lot of code, refactored 'getTokenChain' to use AST - just 11 failures

* Fixed some comments

* More test fixes

* Use RangeContainsRange for expressions lookups

* Revert change to using AST for token chains

* Investigating file to deep

* Fixed final tests ... make sur eto link symbol tables on finding completeions

* Lint fixes

* Removed replaceAll(0 in tests

* Removed standardizePath call in test

* Updates from PR comments

Co-authored-by: Mark Pearce <mark.pearce@redspace.com>
  • Loading branch information
TwitchBronBron and markwpearce committed Sep 27, 2022
1 parent 7a0f95b commit 30b3614
Show file tree
Hide file tree
Showing 67 changed files with 6,071 additions and 2,295 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
COVERALLS_REPO_TOKEN: "kVPcGJfehOArEQnHb8BT3KS72xbUQCoxI"
strategy:
matrix:
os: [ubuntu-18.04, macos-10.15, windows-2019]
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@master
- uses: actions/setup-node@master
Expand All @@ -25,7 +25,7 @@ jobs:
#only run this task if a tag starting with 'v' was used to trigger this (i.e. a tagged release)
if: startsWith(github.ref, 'refs/tags/v')
needs: ci
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
steps:
Expand Down
94 changes: 93 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,99 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0



## [0.57.1](https://github.com/rokucommunity/brighterscript/compare/v0.57.0...0.57.1) - 2022-09-07
### Fixed
- fix(parser): consider namespace function transpiled names ([#685](https://github.com/rokucommunity/brighterscript/pull/685))



## [0.57.0](https://github.com/rokucommunity/brighterscript/compare/v0.56.0...0.57.0) - 2022-09-02
### Added
- validation for files that are nested too deep ([#680](https://github.com/rokucommunity/brighterscript/pull/680))
### Changed
- upgrade to [roku-deploy@3.8.1](https://github.com/rokucommunity/roku-deploy/blob/master/CHANGELOG.md#381---2022-09-02). Notable changes since 3.7.1:
### Fixed
- Allow `mod` as an aa prop([#684](https://github.com/rokucommunity/brighterscript/pull/684))
- coerce AA member identifier kinds to `TokenKind.Identifier` ([#684](https://github.com/rokucommunity/brighterscript/pull/684))
- Doc Scraper issues ([#585](https://github.com/rokucommunity/brighterscript/pull/585))
- Fix case sensitivity issue with `bs_const` values ([#677](https://github.com/rokucommunity/brighterscript/pull/677))



## [0.56.0](https://github.com/rokucommunity/brighterscript/compare/v0.55.2...0.56.0) - 2022-08-23
### Added
- validation for dimmed variables ([#672](https://github.com/rokucommunity/brighterscript/pull/672))
- "--lsp" flag to bsc to start an LSP server ([#668](https://github.com/rokucommunity/brighterscript/pull/668))
### Fixed
- compile crash for scope-less files ([#674](https://github.com/rokucommunity/brighterscript/pull/674))
- parse error for malformed dim statement ([#673](https://github.com/rokucommunity/brighterscript/pull/673))
- allow const as variable name ([#670](https://github.com/rokucommunity/brighterscript/pull/670))
- crashes for language clients that don't support "workspace/configuration" requests ([#667](https://github.com/rokucommunity/brighterscript/pull/667))



## [0.55.2](https://github.com/rokucommunity/brighterscript/compare/v0.55.1...0.55.2) - 2022-08-15
### Fixed
- Dedupe code completions in components ([#664](https://github.com/rokucommunity/brighterscript/pull/664))



## [0.55.1](https://github.com/rokucommunity/brighterscript/compare/v0.55.0...0.55.1) - 2022-08-07
### Fixed
- scope-specific diagnostic grouping issue ([#660](https://github.com/rokucommunity/brighterscript/pull/660))
- typescript error for ast parent setting ([#659](https://github.com/rokucommunity/brighterscript/pull/659))



## [0.55.0](https://github.com/rokucommunity/brighterscript/compare/v0.54.1...0.55.0) - 2022-08-03
### Added
- a `toJSON` function to SymbolTable ([#655](https://github.com/rokucommunity/brighterscript/pull/655))
- link all brs AST nodes to parent onFileValidate ([#650](https://github.com/rokucommunity/brighterscript/pull/650))
- semantic token color for consts ([#654](https://github.com/rokucommunity/brighterscript/pull/654))
- go-to-definition support for const statements ([#653](https://github.com/rokucommunity/brighterscript/pull/653))
### Changed
### Fixed
- bug that wasn't transpiling const expressions when used inside assignment expressions ([#658](https://github.com/rokucommunity/brighterscript/pull/658))
- Performance boost: better function sorting during validation ([#651](https://github.com/rokucommunity/brighterscript/pull/651))
- broken plugin imports with custom cwd ([#652](https://github.com/rokucommunity/brighterscript/pull/652))



## [0.54.1](https://github.com/rokucommunity/brighterscript/compare/v0.54.0...0.54.1) - 2022-07-22
### Changed
- Fix bug in languageserver hover provider ([#649](https://github.com/rokucommunity/brighterscript/pull/649))



## [0.54.0](https://github.com/rokucommunity/brighterscript/compare/v0.53.1...0.54.0) - 2022-07-22
### Added
- hover for CONST references. ([#648](https://github.com/rokucommunity/brighterscript/pull/648))
- plugins can contribute completions ([#647](https://github.com/rokucommunity/brighterscript/pull/647))
- plugins can contribute hovers ([#393](https://github.com/rokucommunity/brighterscript/pull/393))
### Changed
- Export some vscode interfaces ([#644](https://github.com/rokucommunity/brighterscript/pull/644))
- Better plugin docs ([#643](https://github.com/rokucommunity/brighterscript/pull/643))



## [0.53.1](https://github.com/rokucommunity/brighterscript/compare/v0.53.0...0.53.1) - 2022-07-15
### Fixed
- bug with codeactions at the edges of tokens. ([#642](https://github.com/rokucommunity/brighterscript/pull/642))
- nested namespace import codeActions bug. ([#641](https://github.com/rokucommunity/brighterscript/pull/641))



## [0.53.0](https://github.com/rokucommunity/brighterscript/compare/v0.52.3...0.53.0) - 2022-07-14
### Added
- New Language Feature: Constants ([#632](https://github.com/rokucommunity/brighterscript/pull/632))
### Changed
- Flag top level statements ([#638](https://github.com/rokucommunity/brighterscript/pull/638))
- Flag usage of undefined variables ([#631](https://github.com/rokucommunity/brighterscript/pull/631))
- Use `util.createLocation`, not `Location.create()` ([#637](https://github.com/rokucommunity/brighterscript/pull/637))
- Better project detection by language server ([#633](https://github.com/rokucommunity/brighterscript/pull/633))



## [1.0.0-alpha.23](https://github.com/rokucommunity/brighterscript/compare/v1.0.0-alpha22...v1.0.0-alpha.23) - 2022-06-14
### Changed
- all changes from [v0.52.3](#0523---2022-06-14)
Expand All @@ -14,7 +107,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0




## [0.52.3](https://github.com/rokucommunity/brighterscript/compare/v0.52.2...v0.52.3) - 2022-06-14
### Fixed
- fix bug with class transpile in watch mode ([#630](https://github.com/rokucommunity/brighterscript/pull/630))
Expand Down
65 changes: 65 additions & 0 deletions docs/classes.md
Original file line number Diff line number Diff line change
Expand Up @@ -543,3 +543,68 @@ function Vertibrates_Birds_Duck()
end function
```
</details>


## Instance binding
As you would expect, methods attached to a class will have their `m` assigned to that class instance whenever they are invoked through the object. (i.e. `someClassInstance.doSomething()`. However, keep in mind that functions themselves retain no direct knowledge of what object they are bound to.

This is no different than the way plain BrightScript functions and objects interact, but it was worth mentioning that classes cannot mitigate this fundamental runtime limitation.

Consider this example:

```brighterscript
class Person
sub new(name as string)
m.name = name
end sub
sub sayHello()
print m.name
end sub
end class
sub main()
m.name = "Main method"
bob = new SomeClass("bob")
'works as expected...the `m` reference is `bob`
bob.sayHello() 'prints "Bob"
'lift the function off of `bob`
sayHello = bob.sayHello
'`m` is actually the global `m` scope
sayHello() ' prints "Main method"
end sub
```
<details>
<summary>View the transpiled BrightScript code</summary>

```BrightScript
function __Person_builder()
instance = {}
instance.new = sub(name as string)
m.name = name
end sub
instance.sayHello = sub()
print m.name
end sub
return instance
end function
function Person(name as string)
instance = __Person_builder()
instance.new(name)
return instance
end function
sub main()
m.name = "Main method"
bob = SomeClass("bob")
'works as expected...the `m` reference is `bob`
bob.sayHello() 'prints "Bob"
'lift the function off of `bob`
sayHello = bob.sayHello
'`m` is actually the global `m` scope
sayHello() ' prints "Main method"
end sub
```
</details>
112 changes: 112 additions & 0 deletions docs/constants.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# Constants
You can use the `const` keyword to declare constant values. These values cannot be changed at runtime. Constant references will be inlined at compile-time, which is very efficient (similar to how [enums](enums.md) work).

**NOTE:** These are not to be confused with the conditional compile `#const` statements, which are a totally different thing.

## Basic usage
Consts can be defined at the root level of files, and are scoped the same way as functions.
```BrighterScript
const GREETING_MESSAGE = "Hello world"
sub main()
print GREETING_MESSAGE
end sub
```
transpiles to
```BrightScript
sub main()
print "Hello world"
end sub
```

## Namespaced Consts
Consts can be defined within namespaces, and accessed like a property.

```BrighterScript
namespace networking
const BASE_URL = "https://your-app.com/api/v1"
sub printBaseUrl()
'namespace-relative access is allowed
print BASE_URL
end sub
end namespace
sub main()
print networking.BASE_URL
end sub
```

transpiles to

```BrightScript
sub networking_printBaseUrl()
'namespace-relative access is allowed
print "https://your-app.com/api/v1"
end sub
sub main()
print "https://your-app.com/api/v1"
end sub
```

## Complex objects
Constants can contain complex objects or arrays as well, but keep in mind that these are inlined at compile-time, so it is not recommended to reach into these objects for specific values all the time.

non-primitive const values will be wrapped with parentheses when transpiled.

```BrighterScript
namespace networking
const HEADERS = {
"Authorization": "Basic",
"Access-Control-Allow-Credentials": "true"
}
const METHODS = [
"GET",
"POST",
"PUT",
"DELETE"
]
end namespace
sub main()
print networking.HEADERS
print networking.METHODS
end sub
```
**Transpiled:**
```brightscript
sub main()
print ({
"Authorization": "Basic"
"Access-Control-Allow-Credentials": "true"
})
print ([
"GET"
"POST"
"PUT"
"DELETE"
])
end sub
```

## Referencing other constants
Constants can reference other constants (as long as there is no circular reference). You can even use template strings!

```brighterscript
const BASE_URL = "https://api.domain.com"
const LOGIN_PATH = "/login"
const LOGIN_URL = BASE_URL + LOGIN_PATH
const ERROR_URL = `${BASE_URL}/some/error`
sub main()
print LOGIN_URL
print ERROR_URL
end sub
```

transpiles to

```brightscript
sub main()
print ("https://api.domain.com" + "/login")
print (bslib_toString("https://api.domain.com") + "/some/error")
end sub
```

0 comments on commit 30b3614

Please sign in to comment.