Skip to content

Commit 088693c

Browse files
authored
Merge pull request #14 from admvx/fixes
Bug fixes
2 parents 82783ed + 1cade0e commit 088693c

File tree

9 files changed

+69
-59
lines changed

9 files changed

+69
-59
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ https://github.com/admvx/as2-language-support
1313

1414
## Release Notes
1515

16+
### 1.2.1
17+
Addresses the following issues:
18+
- Superclass members are not resolved when super declaration uses short type
19+
- Local variables declared after string literals in the same statement are not indexed
20+
- Npm task `parse-intrinsics` no longer runs successfully
21+
1622
### 1.2.0
1723
Add definition support (jump to definition, peek definition)
1824

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"type": "git",
77
"url": "git@github.com:admvx/as2-language-support.git"
88
},
9-
"version": "1.2.0",
9+
"version": "1.2.1",
1010
"author": "Adam Vernon",
1111
"publisher": "admvx",
1212
"icon": "icon.png",

server/src/action-context.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export class ActionContext {
121121

122122
let member: ActionParameter;
123123
if (ambientClass.superClass && chainLength === 1 && symbolChain[0].identifier === 'super') {
124-
let superClass = await this.getClassByFullType(ambientClass.superClass, ambientClass.baseUri);
124+
let superClass = await this.getClassByFullType(ambientClass.importMap[ambientClass.superClass] || ambientClass.superClass, ambientClass.baseUri);
125125
member = superClass && superClass.constructorMethod;
126126
} else {
127127
let memberAndClass = await this.traverseSymbolChainToMember(symbolChain, ambientClass, lineIndex);
@@ -411,7 +411,7 @@ export class ActionContext {
411411
}
412412

413413
if (actionClass.superClass) {
414-
let superActionClass = await this.getClassByFullType(actionClass.superClass, actionClass.baseUri);
414+
let superActionClass = await this.getClassByFullType(actionClass.importMap[actionClass.superClass] || actionClass.superClass, actionClass.baseUri);
415415
if (superActionClass) {
416416
completionItems = completionItems.concat(await this.getInnerSymbols(superActionClass, visibilityFilter, null, false, skipMap, rank));
417417
}

server/src/action-elements.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export class ActionClass {
112112
if (lookup[memberName]) {
113113
return Promise.resolve(lookup[memberName]);
114114
} else if (this.superClass) {
115-
return ActionContext.getClassByFullType(this.superClass, this.baseUri, false)
115+
return ActionContext.getClassByFullType(this.importMap[this.superClass] || this.superClass, this.baseUri, false)
116116
.then(parsedSuperClass => parsedSuperClass && parsedSuperClass.getMemberByName(memberName, filter));
117117
}
118118
return null;
@@ -185,7 +185,7 @@ export class ActionClass {
185185
return description;
186186
}
187187

188-
public toIntrinsicPickle(): string {
188+
public toPickle(): string {
189189
this._members.forEach(member => delete member.description);
190190
return JSON.stringify(<PickledClass>{
191191
shortType: this.shortType,

server/src/action-parser.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,12 @@ const Patterns = {
3232
STATIC: /\bstatic\b/,
3333
METHOD: /(\bfunction\s+)([\w$]+)(\s*\()(.*)\)(?:\s*:\s*([\w$\.]+))?/, //Group 2: method name; group 4 (optional): arg list; group 5 (optional): return type
3434
IDENTIFIER_AND_TYPE: /(\s*)([\w$]+)(\s*)(?:\:\s*([\w$\.]+)\s*)?/, //Group 2: var/argument name; group 4 (optional): type
35-
LOCAL_VARS: /(\bvar\b)([\s\w$:,=.\[\]()-+*/]+)/, //Group 2: content
35+
LOCAL_VARS: /(\bvar\b)([\s\w$:,=.\[\]()-+*/"']+)/, //Group 2: content
3636
BRACES: /[{}]/g,
3737
MATCHED_BRACES: /{(?:(?!{).)*?}/g,
3838
MATCHED_BRACKETS: /\[(?:(?!\[).)*?\]/g,
39-
MATCHED_PARENS: /\((?:(?!\().)*?\)/g
39+
MATCHED_PARENS: /\((?:(?!\().)*?\)/g,
40+
MATCHED_STRINGS: /(?:".*?"|'.*?')/g
4041
};
4142

4243
export class ActionParser {
@@ -48,16 +49,17 @@ export class ActionParser {
4849

4950
public instanceTest(): void { }
5051

51-
public static parseFile(fileUri: string, fileContent: string, deep: boolean = false): ActionClass {
52+
public static parseFile(fileUri: string, fileContent: string, deep: boolean = false, isIntrinsic: boolean = false): ActionClass {
5253
let fullType: string, shortType: string, superClass: string, result: RegExpExecArray, line: string;
5354

5455
fileContent = stripComments(fileContent);
5556

5657
this.wipClass = new ActionClass();
5758
this.wipClass.fileUri = fileUri;
59+
this.wipClass.isIntrinsic = isIntrinsic;
5860
this.wipClass.lines = fileContent.split(/\r?\n/);
5961

60-
let includeLocations: boolean = !! fileUri;
62+
let includeLocations: boolean = !isIntrinsic && !! fileUri;
6163
let imports: string[] = [];
6264

6365
let scopeStack: ActionScope[] = [ActionScope.BASE];
@@ -245,6 +247,7 @@ export class ActionParser {
245247
let localString = recursiveReplaceAndPreserveLength(result[2], Patterns.MATCHED_BRACES);
246248
localString = recursiveReplaceAndPreserveLength(localString, Patterns.MATCHED_BRACKETS);
247249
localString = recursiveReplaceAndPreserveLength(localString, Patterns.MATCHED_PARENS);
250+
localString = recursiveReplaceAndPreserveLength(localString, Patterns.MATCHED_STRINGS);
248251
locals = locals.concat(this.getParameterArrayFromString(localString, false, includeLocations, lineNumber + lineCount, result.index + result[1].length));
249252
}
250253
}

server/src/file-system-utilities.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import { LogLevel, logIt, ActionConfig } from './config';
44

55
export class DirectoryUtility {
66

7-
public static fileNamesInDirectory(directoryPath: string, fileNameFilter?: RegExp, includePathInResults: boolean = true): Promise<string[]> {
8-
return fse.readdir(URI.parse(directoryPath).fsPath)
7+
public static fileNamesInDirectory(directoryPath: string, fileNameFilter?: RegExp, includePathInResults: boolean = true, pathIsUri: boolean = true): Promise<string[]> {
8+
directoryPath = pathIsUri ? URI.parse(directoryPath).fsPath : directoryPath;
9+
return fse.readdir(directoryPath)
910
.then(fileNames => {
1011
if (fileNameFilter) {
1112
fileNames = fileNames.filter(fileName => fileName.match(fileNameFilter));
@@ -52,8 +53,8 @@ export class LoadQueue {
5253
private static _chain: Promise<string> = Promise.resolve('');
5354
private static _naughtyList: { [path: string]: boolean } = { };
5455

55-
public static enqueue(pathUri: string): Promise<string> {
56-
let filePath = URI.parse(pathUri).fsPath;
56+
public static enqueue(filePath: string, pathIsUri: boolean = true): Promise<string> {
57+
filePath = pathIsUri ? URI.parse(filePath).fsPath : filePath;
5758

5859
if (this._naughtyList[filePath]) {
5960
ActionConfig.LOG_LEVEL !== LogLevel.NONE && logIt({ level: LogLevel.WARNING, message: `Already tried to load ${filePath} and failed. Aborting.` });

0 commit comments

Comments
 (0)