Skip to content

Commit

Permalink
include namespace for class extends in typedef (#324)
Browse files Browse the repository at this point in the history
  • Loading branch information
TwitchBronBron committed Feb 19, 2021
1 parent d7ab094 commit 19a7dfc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
17 changes: 17 additions & 0 deletions src/files/BrsFile.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2321,6 +2321,23 @@ describe('BrsFile', () => {
expect(file.getTypedef()).to.eql(expected);
}

it('includes namespace on extend class names', () => {
testTypedef(`
namespace AnimalKingdom
class Bird
end class
class Duck extends Bird
end class
end namespace`, trim`
namespace AnimalKingdom
class Bird
end class
class Duck extends AnimalKingdom.Bird
end class
end namespace
`);
});

it('strips function body', () => {
testTypedef(`
sub main(param1 as string)
Expand Down
6 changes: 5 additions & 1 deletion src/parser/Statement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1289,8 +1289,12 @@ export class ClassStatement extends Statement implements TypedefProvider {
this.name.text
);
if (this.extendsKeyword && this.parentClassName) {
const fqName = util.getFullyQualifiedClassName(
this.parentClassName.getName(ParseMode.BrighterScript),
this.namespaceName?.getName(ParseMode.BrighterScript)
);
result.push(
` extends ${this.parentClassName.getName(ParseMode.BrighterScript)}`
` extends ${fqName}`
);
}
result.push(state.newline());
Expand Down

0 comments on commit 19a7dfc

Please sign in to comment.