Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into xml-ast-improvements
  • Loading branch information
TwitchBronBron committed May 14, 2021
2 parents e5d2e08 + 8e76fba commit 4717ce8
Show file tree
Hide file tree
Showing 42 changed files with 896 additions and 706 deletions.
22 changes: 21 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0



## [1.0.0-alpha.2]
[1.0.0-alpha.2]: https://github.com/rokucommunity/brighterscript/compare/v1.0.0-alpha.1...v1.0.0-alpha.2
### Add
- all changes from [v0.38.0](#0380---2021-05-04)
### Changed
- Rename pathAbsolute to srcPath ([#399](https://github.com/rokucommunity/brighterscript/pull/399))
- Convert pkgPath to actual pkgPath (i.e. `pkg:/source/main.brs` where previously it would have been `source/main.brs` or `source\main.brs`) ([#399](https://github.com/rokucommunity/brighterscript/pull/399))
- Simplify Program removeFile and addReplaceFile ([#399](https://github.com/rokucommunity/brighterscript/pull/399))
- Add `normalizePath` parameter to file-related functions in `Program` and `Scope` ([#399](https://github.com/rokucommunity/brighterscript/pull/399))



## [0.38.0] - 2021-05-04
### Adds
### Add
- warning for mismatched class method accessibility ([#402](https://github.com/rokucommunity/brighterscript/pull/402))
- allow class field overrides in child classes as long as they are the same type ([#394](https://github.com/rokucommunity/brighterscript/pull/394))

Expand All @@ -22,6 +34,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Remove `FunctionScope` ([#401](https://github.com/rokucommunity/brighterscript/pull/401))
- Add `SymbolTable` and `LazyType` objects to improve type tracking ([#401](https://github.com/rokucommunity/brighterscript/pull/401))



## [0.37.4] - 2021-04-20
### Fixed
- bug validating namespace function calls ([#390](https://github.com/rokucommunity/brighterscript/pull/390))



## [0.37.4] - 2021-04-20
### Fixed
- bug validating namespace function calls ([#390](https://github.com/rokucommunity/brighterscript/pull/390))
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/targets/parse-xml.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = async (suite, name, brighterscript, projectPath, options) => {
suite.add(name, (deferred) => {
const wait = [];
for (const x of xmlFiles) {
const xmlFile = new XmlFile(x.pathAbsolute, x.pkgPath, builder.program);
const xmlFile = new XmlFile(x.srcPath || x.pathAbsolute, x.pkgPath, builder.program);
//handle async and sync parsing
const prom = xmlFile.parse(x.fileContents);
if (prom) {
Expand Down
2 changes: 1 addition & 1 deletion bsconfig.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
"items": {
"anyOf": [
{
"type": "number",
"type": ["number", "string"],
"description": "A code of diagnostics that should be filtered out from the files matched in 'src'"
}
]
Expand Down
2 changes: 1 addition & 1 deletion docs/plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ interface FileObj {
}

interface SourceObj {
pathAbsolute: string;
srcPath: string;
source: string;
}

Expand Down
9 changes: 7 additions & 2 deletions docs/source-literals.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ print SOURCE_FILE_PATH
transpiles to:

```BrightScript
print "file:///c:/projects/roku/brighterscript/scripts/rootDir/source/main.bs"
print "file" + ":///c:/projects/roku/brighterscript/scripts/rootDir/source/main.bs"
```

_note: the literal is concatenated to keep the roku static analysis tool happy_

## SOURCE_LINE_NUM
The 1-based line number of the source file.

Expand Down Expand Up @@ -153,10 +155,13 @@ transpiles to:

```BrightScript
function main()
print "file:///c:/projects/roku/brighterscript/scripts/rootDir/source/main.bs:2"
print "file" + ":///c:/projects/roku/brighterscript/scripts/rootDir/source/main.bs:2"
end function
```

_note: the literal is concatenated to keep the roku static analysis tool happy_


## PKG_PATH
The pkg path of the file.

Expand Down
57 changes: 28 additions & 29 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "brighterscript",
"version": "1.0.0-alpha.1",
"version": "1.0.0-alpha.2",
"description": "A superset of Roku's BrightScript language.",
"scripts": {
"preversion": "npm run build && npm run lint && npm run test",
Expand Down Expand Up @@ -71,7 +71,7 @@
"devDependencies": {
"@types/benchmark": "^1.0.31",
"@types/chai": "^4.1.2",
"@types/chokidar": "^1.7.5",
"@types/chokidar": "^2.1.3",
"@types/command-line-args": "^5.0.0",
"@types/command-line-usage": "^5.0.1",
"@types/debounce-promise": "^3.1.1",
Expand Down Expand Up @@ -113,7 +113,7 @@
"array-flat-polyfill": "^1.0.1",
"chalk": "^2.4.2",
"chevrotain": "^7.0.1",
"chokidar": "^3.0.2",
"chokidar": "^3.5.1",
"clear": "^0.1.0",
"cross-platform-clear-console": "^2.3.0",
"debounce-promise": "^3.1.0",
Expand Down
4 changes: 2 additions & 2 deletions src/DiagnosticCollection.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ describe('DiagnosticCollection', () => {
function removeDiagnostic(filePath: string, message: string) {
for (let i = 0; i < diagnostics.length; i++) {
const diagnostic = diagnostics[i];
if (diagnostic.file.pathAbsolute === filePath && diagnostic.message === message) {
if (diagnostic.file.srcPath === filePath && diagnostic.message === message) {
diagnostics.splice(i, 1);
return;
}
Expand All @@ -99,7 +99,7 @@ describe('DiagnosticCollection', () => {
for (const message of messages) {
diagnostics.push({
file: {
pathAbsolute: filePath
srcPath: filePath
} as BscFile,
range: util.createRange(0, 0, 0, 0),
//the code doesn't matter as long as the messages are different, so just enforce unique messages for this test files
Expand Down
4 changes: 2 additions & 2 deletions src/DiagnosticCollection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ export class DiagnosticCollection {
const keys = {};
//build the full current set of diagnostics by file
for (let diagnostic of diagnostics) {
const filePath = diagnostic.file.pathAbsolute;
const filePath = diagnostic.file.srcPath;
//ensure the file entry exists
if (!result[filePath]) {
result[filePath] = [];
}
const diagnosticMap = result[filePath];

diagnostic.key =
diagnostic.file.pathAbsolute.toLowerCase() + '-' +
diagnostic.file.srcPath.toLowerCase() + '-' +
diagnostic.code + '-' +
diagnostic.range.start.line + '-' +
diagnostic.range.start.character + '-' +
Expand Down
4 changes: 2 additions & 2 deletions src/DiagnosticFilterer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,10 @@ describe('DiagnosticFilterer', () => {

});

function getDiagnostic(code: number | string, pathAbsolute: string) {
function getDiagnostic(code: number | string, srcPath: string) {
return {
file: {
pathAbsolute: s`${pathAbsolute}`
srcPath: s`${srcPath}`
},
code: code
} as BsDiagnostic;
Expand Down
4 changes: 2 additions & 2 deletions src/DiagnosticFilterer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ export class DiagnosticFilterer {

for (let diagnostic of diagnostics) {
//skip diagnostics that have issues
if (!diagnostic?.file?.pathAbsolute) {
if (!diagnostic?.file?.srcPath) {
continue;
}
const lowerSrcPath = diagnostic.file.pathAbsolute.toLowerCase();
const lowerSrcPath = diagnostic.file.srcPath.toLowerCase();
//make a new array for this file if one does not yet exist
if (!this.byFile[lowerSrcPath]) {
this.byFile[lowerSrcPath] = [];
Expand Down

0 comments on commit 4717ce8

Please sign in to comment.