Skip to content

Commit 1b25706

Browse files
committed
some maybe better caching
1 parent 6c3779e commit 1b25706

File tree

5 files changed

+22
-13
lines changed

5 files changed

+22
-13
lines changed

.github/main.workflow

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@ action "Build" {
99
}
1010

1111
action "Lint" {
12-
needs = "Build"
12+
needs = ["Build"]
1313
uses = "actions/npm@master"
1414
args = "run lint"
1515
}
1616

1717
action "Test" {
18-
needs = "Build"
18+
needs = ["Build"]
1919
uses = "actions/npm@master"
20-
args = "run test"
20+
args = "test"
2121
}
2222

2323
action "Package" {
24-
needs = "Test"
24+
needs = ["Test", "Lint"]
2525
uses = "actions/npm@master"
2626
args = "run package"
2727
}

package-lock.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,7 @@
472472
"vscode": "^1.1.26"
473473
},
474474
"dependencies": {
475-
"glob": "^7.1.3"
475+
"glob": "^7.1.3",
476+
"vscode-cache": "^0.3.0"
476477
}
477478
}

providers/ObjectScriptDefinitionProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class ObjectScriptDefinitionProvider implements vscode.DefinitionProvider
1818
return fromClassRef;
1919
}
2020

21-
let selfRef = document.getWordRangeAtPosition(position, /\.\.#?%?[a-zA-Z][a-zA-Z0-9]+(?:\.[a-zA-Z][a-zA-Z0-9]+)*/);
21+
let selfRef = document.getWordRangeAtPosition(position, /\.\.#?%?[a-zA-Z][a-zA-Z0-9]+/);
2222
if (selfRef) {
2323
let selfEntity = document.getText(selfRef).substr(2);
2424
let range = new vscode.Range(position.line, selfRef.start.character + 2, position.line, selfRef.end.character);

utils/classDefinition.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import * as vscode from 'vscode';
2+
const Cache = require('vscode-cache');
23
import { AtelierAPI } from '../api';
34
import { onlyUnique } from '.';
45
import { DocumentContentProvider } from '../providers/DocumentContentProvider';
5-
import { workspaceState } from '../extension';
6+
import { extensionContext } from '../extension';
67

78
export class ClassDefinition {
89
private _className: string;
910
private _classFileName: string;
11+
private _cache;
1012

1113
public static normalizeClassName(className, withExtension = false): string {
1214
return className.replace(/^%(\b\w+\b)$/, '%Library.$1') + (withExtension ? '.cls' : '');
@@ -18,6 +20,7 @@ export class ClassDefinition {
1820
}
1921
this._className = ClassDefinition.normalizeClassName(className, false);
2022
this._classFileName = ClassDefinition.normalizeClassName(className, true);
23+
this._cache = new Cache(extensionContext, this._classFileName);
2124
}
2225

2326
get uri(): vscode.Uri {
@@ -29,12 +32,11 @@ export class ClassDefinition {
2932
}
3033

3134
store(kind: string, data: any): any {
32-
workspaceState.update(`${this._classFileName}|${kind}`, data);
33-
return data;
35+
return this._cache.put(kind, data, 36000).then(() => data);
3436
}
3537

3638
load(kind: string): any {
37-
return workspaceState.get(`${this._classFileName}|${kind}`);
39+
return this._cache.get(kind);
3840
}
3941

4042
async methods(scope: 'any' | 'class' | 'instance' = 'any'): Promise<any[]> {
@@ -110,7 +112,8 @@ export class ClassDefinition {
110112
return Promise.resolve(superList);
111113
}
112114
const api = new AtelierAPI();
113-
let sql = `SELECT PrimarySuper FROM %Dictionary.CompiledClass WHERE Name = ?`;
115+
let sql = `SELECT PrimarySuper FROM %Dictionary.CompiledClass
116+
WHERE Name %inlist (SELECT $LISTFROMSTRING(Super, ',') FROM %Dictionary.CompiledClass WHERE Name = ?)`;
114117
return api
115118
.actionQuery(sql, [this._className])
116119
.then(
@@ -150,9 +153,9 @@ export class ClassDefinition {
150153
async getMemberLocation(name: string): Promise<vscode.Location> {
151154
let pattern;
152155
if (name.startsWith('#')) {
153-
pattern = `(Parameter) ${name.substr(1)}(?!\w)`;
156+
pattern = `(Parameter) ${name.substr(1)}(?=[( ;])`;
154157
} else {
155-
pattern = `((Class)?Method|Property|RelationShip) ${name}(?!\w)`;
158+
pattern = `((Class)?Method|Property|RelationShip) ${name}(?=[( ])`;
156159
}
157160
return this.getDocument().then(document => {
158161
for (let i = 0; i < document.lineCount; i++) {

0 commit comments

Comments
 (0)