Skip to content

Commit e7d1bb7

Browse files
authored
fix: delete forked code dependency and cleanup (#611)
* fix: delete forked code dependency and cleanup * fix: address review feedback * fix: try loop to see if windows works * fix: try loop to see if windows works * fix: await * fix: locally working * fix: try windows fix * chore: add logging to debug windows * fix: try full path * fix: remove debug logs * fix: refactor resources files folders * fix: spliting and adding comments * fix: update tests and match functionality * fix: pr feedback and removing unnecessary dependencies.
1 parent 87c893d commit e7d1bb7

File tree

80 files changed

+2188
-14612
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+2188
-14612
lines changed

package.json

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,23 @@
1212
"devDependencies": {
1313
"@commitlint/cli": "^7",
1414
"@commitlint/config-conventional": "^7",
15-
"commitizen": "^3.0.5",
16-
"cz-conventional-changelog": "^2.1.0",
1715
"@types/jest": "^29.5.14",
16+
"@types/minimatch": "^5.1.2",
1817
"@types/node": "^20.0.0",
19-
"@typescript-eslint/eslint-plugin": "^2.22.0",
20-
"@typescript-eslint/parser": "^2.22.0",
21-
"eslint": "^6.8.0",
22-
"eslint-config-prettier": "^6.11.0",
23-
"eslint-plugin-header": "^3.0.0",
24-
"eslint-plugin-jsdoc": "^19.1.0",
25-
"eslint-plugin-prettier": "^3.1.4",
18+
"@typescript-eslint/eslint-plugin": "^5.62.0",
19+
"@typescript-eslint/parser": "^5.62.0",
20+
"commitizen": "^3.0.5",
21+
"cz-conventional-changelog": "^2.1.0",
22+
"eslint": "^8.57.0",
23+
"eslint-config-prettier": "^8.10.0",
24+
"eslint-plugin-header": "^3.1.1",
25+
"eslint-plugin-jsdoc": "^46.9.1",
26+
"eslint-plugin-prettier": "^4.2.1",
2627
"husky": "^4.2.5",
2728
"lerna": "^3.20.2",
2829
"lint-staged": "^10.2.11",
29-
"prettier": "1.19.1",
3030
"patch-package": "^6.0.5",
31+
"prettier": "^2.8.8",
3132
"rimraf": "^3.0.1",
3233
"shelljs": "^0.8.5",
3334
"typescript": "^5.0.4"

packages/aura-language-server/package.json

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,43 +28,27 @@
2828
},
2929
"dependencies": {
3030
"@salesforce/lightning-lsp-common": "4.12.4",
31-
"acorn": "^6.0.0",
3231
"acorn-loose": "^6.0.0",
3332
"acorn-walk": "^6.0.0",
3433
"change-case": "^3.1.0",
35-
"enhanced-resolve": "^2.2.2",
3634
"fs-extra": "^11.3.0",
3735
"line-column": "^1.0.2",
38-
"minimatch": "^3.0.4",
39-
"properties": "^1.2.1",
40-
"resolve-from": "^5.0.0",
4136
"vscode-languageserver": "^5.2.1",
42-
"vscode-languageserver-types": "3.14.0",
43-
"vscode-nls": "^4.1.2",
37+
"vscode-languageserver-types": "3.17.5",
4438
"vscode-uri": "1.0.6"
4539
},
4640
"devDependencies": {
47-
"@jest/reporters": "^29.7.0",
48-
"@types/babel-types": "^7.0.8",
4941
"@types/fs-extra": "^11.0.4",
50-
"@types/glob": "^7.1.3",
5142
"@types/jest": "^29.5.14",
5243
"@types/mock-fs": "^4.13.4",
5344
"@types/node": "^20.0.0",
5445
"@types/shelljs": "^0.8.15",
55-
"babel-types": "^6.26.0",
5646
"eslint": "^7.7.0",
57-
"glob": "^7.1.6",
58-
"husky": "^4.2.5",
5947
"jest": "^29.7.0",
6048
"jest-extended": "^0.11.5",
61-
"lint-staged": "^10.2.11",
6249
"mock-fs": "^5.5.0",
63-
"npm-run": "^5.0.1",
6450
"prettier": "^2.0.5",
65-
"shelljs": "^0.8.5",
6651
"ts-jest": "^29.2.6",
67-
"tsc-transpile-only": "0.0.3",
6852
"typescript": "5.0.4"
6953
}
70-
}
54+
}

packages/aura-language-server/scripts/build.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,4 @@ shell.mkdir('-p', 'lib/tern/');
1212
shell.cp('-R', 'src/tern/lib', 'lib/tern/lib/');
1313
shell.cp('-R', 'src/tern/defs', 'lib/tern/defs/');
1414
shell.cp('-R', 'src/tern/plugin', 'lib/tern/plugin/');
15-
// Copy Html Language Service files
16-
// shell.cp('-R', 'src/html-language-service/beautify/*.js', 'lib/html-language-service/beautify/');
17-
// shell.mkdir('-p', 'lib/html-language-service/beautify/esm/');
18-
// shell.cp('-R', 'src/html-language-service/beautify/esm/*.js', 'lib/html-language-service/beautify/esm/');
15+

packages/aura-language-server/src/resources/fix-system.js renamed to packages/aura-language-server/scripts/transform-aura-system.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1+
// NOTE: This script is not used in the build.js, but needs to be run manually to update the aura-system.json file
12
const fs = require('fs');
2-
const tags = JSON.parse(fs.readFileSync('aura-system.json.bak','utf-8'));
3+
const path = require('path');
4+
5+
const inputPath = path.join(__dirname, '..', 'src', 'build-time-resources', 'aura-system.json');
6+
const outputPath = path.join(__dirname, '..', 'src', 'resources', 'transformed-aura-system.json');
7+
8+
const tags = JSON.parse(fs.readFileSync(inputPath, 'utf-8'));
39

410
const tagkeys = Object.keys(tags);
511
for (const key of tagkeys) {
@@ -22,4 +28,4 @@ for (const key of tagkeys) {
2228
tag.attributes = a;
2329
}
2430
const out = JSON.stringify(tags, null, 3);
25-
fs.writeFileSync('aura-system.json',out, 'utf-8');
31+
fs.writeFileSync(outputPath, out, 'utf-8');
Lines changed: 252 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,252 @@
1+
import { TextDocument, Position } from 'vscode-languageserver';
2+
import { getAuraBindingValue, parse } from '../aura-utils';
3+
4+
describe('getAuraBindingValue', () => {
5+
function createDocument(content: string): TextDocument {
6+
return TextDocument.create('file:///test.cmp', 'html', 0, content);
7+
}
8+
9+
function createPosition(line: number, character: number): Position {
10+
return Position.create(line, character);
11+
}
12+
13+
function getBindingValue(content: string, line: number, character: number): string | null {
14+
const document = createDocument(content);
15+
const htmlDocument = parse(content);
16+
const position = createPosition(line, character);
17+
console.log('position', position);
18+
return getAuraBindingValue(document, position, htmlDocument);
19+
}
20+
21+
// simple function to find the cursor position in a string, helpful for readability
22+
function findCursorPosition(content: string): number {
23+
const cursorPosition = content.indexOf('|');
24+
return cursorPosition;
25+
}
26+
27+
describe('basic functionality', () => {
28+
it('should extract property from v binding in attribute', () => {
29+
const content = '<div value="{!v.property}"></div>';
30+
const stringWithCursor = '<div value="{!v.property|}"></div>';
31+
const cursorPosition = findCursorPosition(stringWithCursor);
32+
const result = getBindingValue(content, 0, cursorPosition); // Position: <div value="{!v.property|}"></div>
33+
expect(result).toBe('property');
34+
});
35+
36+
it('should extract property from c binding in attribute', () => {
37+
const content = '<div onclick="{!c.handleClick}"></div>';
38+
const stringWithCursor = '<div onclick="{!c.handleClick|}"></div>';
39+
const cursorPosition = findCursorPosition(stringWithCursor);
40+
const result = getBindingValue(content, 0, cursorPosition); // Position: <div onclick="{!c.handleClick|}"></div>
41+
expect(result).toBe('handleClick');
42+
});
43+
44+
it('should extract property from m binding in attribute', () => {
45+
const content = '<div data="{!m.dataValue}"></div>';
46+
const stringWithCursor = '<div data="{!m.dataValue|}"></div>';
47+
const cursorPosition = findCursorPosition(stringWithCursor);
48+
const result = getBindingValue(content, 0, cursorPosition); // Position: <div data="{!m.dataValue|}"></div>
49+
expect(result).toBe('dataValue');
50+
});
51+
52+
it('should return null when cursor is before dot', () => {
53+
const content = '<div value="{!v.property}"></div>';
54+
const stringWithCursor = '<div value="{!v|.property}"></div>';
55+
const cursorPosition = findCursorPosition(stringWithCursor);
56+
const result = getBindingValue(content, 0, cursorPosition); // Position: <div value="{!v|.property}"></div>
57+
expect(result).toBe('property');
58+
});
59+
60+
it('should handle quoted attribute values', () => {
61+
const content = '<div value="\'{!v.property}\'"></div>';
62+
const stringWithCursor = '<div value="\'{!v.property|}\'"></div>';
63+
const cursorPosition = findCursorPosition(stringWithCursor);
64+
const result = getBindingValue(content, 0, cursorPosition); // Position: <div value='{!v.property|}'></div>
65+
expect(result).toBe('property');
66+
});
67+
68+
it('should handle double quoted attribute values', () => {
69+
const content = '<div value=\'"{!v.property}"\'></div>';
70+
const stringWithCursor = '<div value=\'"{!v.property|}"\'></div>';
71+
const cursorPosition = findCursorPosition(stringWithCursor);
72+
const result = getBindingValue(content, 0, cursorPosition); // Position: <div value='"{!v.property|}"'></div>
73+
expect(result).toBe('property');
74+
});
75+
76+
it('should return null for non-binding attributes', () => {
77+
const content = '<div class="some-class"></div>';
78+
const stringWithCursor = '<div class="some-|class"></div>';
79+
const cursorPosition = findCursorPosition(stringWithCursor);
80+
const result = getBindingValue(content, 0, cursorPosition); // Position: <div class="some-|class"></div>
81+
expect(result).toBeNull();
82+
});
83+
});
84+
85+
describe('body text bindings', () => {
86+
it('should extract property from v binding in body text', () => {
87+
const content = '<div>{!v.property}</div>';
88+
const stringWithCursor = '<div>{!v.property|}</div>';
89+
const cursorPosition = findCursorPosition(stringWithCursor);
90+
const result = getBindingValue(content, 0, cursorPosition); // Position: <div>{!v.property|}</div>
91+
expect(result).toBe('property');
92+
});
93+
94+
it('should extract property from c binding in body text', () => {
95+
const content = '<div>{!c.method}</div>';
96+
const stringWithCursor = '<div>{!c.method|}</div>';
97+
const cursorPosition = findCursorPosition(stringWithCursor);
98+
const result = getBindingValue(content, 0, cursorPosition); // Position: <div>{!c.method|}</div>
99+
expect(result).toBe('method');
100+
});
101+
102+
it('should extract property from m binding in body text', () => {
103+
const content = '<div>{!m.data}</div>';
104+
const stringWithCursor = '<div>{!m.data|}</div>';
105+
const cursorPosition = findCursorPosition(stringWithCursor);
106+
const result = getBindingValue(content, 0, cursorPosition); // Position: <div>{!m.data|}</div>
107+
expect(result).toBe('data');
108+
});
109+
110+
it('should return null when cursor is before dot in body text', () => {
111+
const content = '<div>{!v.property}</div>';
112+
const stringWithCursor = '<div>{!v|.property|}</div>';
113+
const cursorPosition = findCursorPosition(stringWithCursor);
114+
const result = getBindingValue(content, 0, cursorPosition); // Position: <div>{!v|.property|}</div>
115+
expect(result).toBeNull();
116+
});
117+
118+
it('should handle multiple bindings in body text', () => {
119+
const content = '<div>{!v.first} and {!v.second}</div>';
120+
const stringWithCursor = '<div>{!v.first| and {!v.second}</div>';
121+
const cursorPosition = findCursorPosition(stringWithCursor);
122+
const result = getBindingValue(content, 0, cursorPosition); // Position: <div>{!v.first| and {!v.second}</div>
123+
expect(result).toBe('first');
124+
});
125+
});
126+
127+
describe('edge cases', () => {
128+
it('should return null for empty document', () => {
129+
const result = getBindingValue('', 0, 0);
130+
expect(result).toBeNull();
131+
});
132+
133+
it('should return null for invalid HTML', () => {
134+
const result = getBindingValue('<div>', 0, 0);
135+
expect(result).toBeNull();
136+
});
137+
138+
it('should return null when cursor is outside any node', () => {
139+
const content = '<div>{!v.property}</div>';
140+
const result = getBindingValue(content, 1, 0); // Position on new line
141+
expect(result).toBeNull();
142+
});
143+
144+
it('should handle expressions with special characters in property names', () => {
145+
const content = '<div value="{!v.property_name}"></div>';
146+
const stringWithCursor = '<div value="{!v.property_name|}"></div>';
147+
const cursorPosition = findCursorPosition(stringWithCursor);
148+
const result = getBindingValue(content, 0, cursorPosition); // Position: <div value="{!v.property_name|}"></div>
149+
expect(result).toBe('property_name');
150+
});
151+
152+
it('should handle expressions with numbers in property names', () => {
153+
const content = '<div value="{!v.property123}"></div>';
154+
const stringWithCursor = '<div value="{!v.property123|}"></div>';
155+
const cursorPosition = findCursorPosition(stringWithCursor);
156+
const result = getBindingValue(content, 0, cursorPosition); // Position: <div value="{!v.property123|}"></div>
157+
expect(result).toBe('property123');
158+
});
159+
160+
it('should return "" for incomplete expressions', () => {
161+
const content = '<div value="{!v.}"></div>';
162+
const stringWithCursor = '<div value="{!v.|}"></div>';
163+
const cursorPosition = findCursorPosition(stringWithCursor);
164+
const result = getBindingValue(content, 0, cursorPosition); // Position: <div value="{!v.|}"></div>
165+
expect(result).toBe("");
166+
});
167+
168+
it('should extract property when cursor is within property name in attribute', () => {
169+
const content = '<div value="{!v.property}"></div>';
170+
const stringWithCursor = '<div value="{!v.prop|erty|}"></div>';
171+
const cursorPosition = findCursorPosition(stringWithCursor);
172+
const result = getBindingValue(content, 0, cursorPosition); // Position: <div value="{!v.prop|erty|}"></div>
173+
expect(result).toBe('property');
174+
});
175+
176+
it('should extract property when cursor is within property name in body text', () => {
177+
const content = '<div>{!v.property}</div>';
178+
const stringWithCursor = '<div>{!v.prop|erty}</div>';
179+
const cursorPosition = findCursorPosition(stringWithCursor);
180+
const result = getBindingValue(content, 0, cursorPosition); // Position: <div>{!v.prop|erty}</div>
181+
expect(result).toBe('property');
182+
});
183+
184+
it('should extract property when cursor is at start of property name', () => {
185+
const content = '<div value="{!v.property}"></div>';
186+
const stringWithCursor = '<div value="{!v.|property}"></div>';
187+
const cursorPosition = findCursorPosition(stringWithCursor);
188+
const result = getBindingValue(content, 0, cursorPosition); // Position: <div value="{!v.|property}"></div>
189+
expect(result).toBe('property');
190+
});
191+
192+
it('should extract property when cursor is at end of property name', () => {
193+
const content = '<div value="{!v.property}"></div>';
194+
const stringWithCursor = '<div value="{!v.propert|y}"></div>';
195+
const cursorPosition = findCursorPosition(stringWithCursor);
196+
const result = getBindingValue(content, 0, cursorPosition); // Position: <div value="{!v.propert|y}"></div>
197+
expect(result).toBe('property');
198+
});
199+
});
200+
201+
describe('complex scenarios', () => {
202+
it('should handle multiple attributes with bindings', () => {
203+
const content = '<div value="{!v.property}" onclick="{!c.method}"></div>';
204+
const stringWithCursor = '<div value="{!v.property|}" onclick="{!c.method}"></div>';
205+
const cursorPosition = findCursorPosition(stringWithCursor);
206+
const result = getBindingValue(content, 0, cursorPosition); // Position: <div value="{!v.property|}" onclick="{!c.method}"></div>
207+
expect(result).toBe('property');
208+
});
209+
210+
it('should handle self-closing tags with bindings', () => {
211+
const content = '<input value="{!v.property}" />';
212+
const stringWithCursor = '<input value="{!v.property|}" />';
213+
const cursorPosition = findCursorPosition(stringWithCursor);
214+
const result = getBindingValue(content, 0, cursorPosition); // Position: <input value="{!v.property|}"></input>
215+
expect(result).toBe('property');
216+
});
217+
218+
it('should handle expressions with comments', () => {
219+
const content = '<div value="{!v.property}<!-- comment -->"></div>';
220+
const stringWithCursor = '<div value="{!v.property|}"><!-- comment --></div>';
221+
const cursorPosition = findCursorPosition(stringWithCursor);
222+
const result = getBindingValue(content, 0, cursorPosition); // Position: <div value="{!v.property|}"><!-- comment --></div>
223+
expect(result).toBe('property');
224+
});
225+
});
226+
227+
describe('advanced scenarios', () => {
228+
it('should handle nested properties', () => {
229+
const content = '<div value="{!v.object.property}"></div>';
230+
const stringWithCursor = '<div value="{!v.object.property|}"></div>';
231+
const cursorPosition = findCursorPosition(stringWithCursor);
232+
const result = getBindingValue(content, 0, cursorPosition); // Position: <div value="{!v.object.property|}"></div>
233+
expect(result).toBe('object'); // Function returns first property in regex group
234+
});
235+
236+
it('should handle expressions with multiple dots', () => {
237+
const content = '<div value="{!v.object.subObject.property}"></div>';
238+
const stringWithCursor = '<div value="{!v.object.subObject.property|}"></div>';
239+
const cursorPosition = findCursorPosition(stringWithCursor);
240+
const result = getBindingValue(content, 0, cursorPosition); // Position: <div value="{!v.object.subObject.property|}"></div>
241+
expect(result).toBe('object'); // Function returns first property in regex group
242+
});
243+
244+
it('should handle negated expressions', () => {
245+
const content = '<div hidden="{!!v.isHidden}"></div>';
246+
const stringWithCursor = '<div hidden="{!!v.isHidden|}"></div>';
247+
const cursorPosition = findCursorPosition(stringWithCursor);
248+
const result = getBindingValue(content, 0, cursorPosition); // Position: <div hidden="{!!v.isHidden|}"></div>
249+
expect(result).toBe('isHidden');
250+
});
251+
});
252+
});

packages/aura-language-server/src/aura-indexer/__tests__/indexer.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ describe('indexer parsing content', () => {
3939
context.addIndexingProvider({ name: 'aura', indexer: auraIndexer });
4040

4141
let markup = await context.findAllAuraMarkup();
42-
markup = markup.map(p => normalize(full, p));
43-
markup = markup.sort();
42+
markup = markup.map(p => normalize(full, p)).sort();
4443
expect(markup).toMatchSnapshot();
4544
const tags = auraIndexer.getAuraTags();
4645
tags.forEach(taginfo => {

packages/aura-language-server/src/aura-indexer/indexer.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
import { WorkspaceContext, shared, Indexer, TagInfo, utils, AttributeInfo, componentUtil, parse, Node } from '@salesforce/lightning-lsp-common';
1+
import { WorkspaceContext, shared, Indexer, TagInfo, utils, AttributeInfo, componentUtil } from '@salesforce/lightning-lsp-common';
22
import { Location } from 'vscode-languageserver';
33
import * as auraUtils from '../aura-utils';
44
import * as fs from 'fs-extra';
55
import LineColumnFinder from 'line-column';
66
import URI from 'vscode-uri';
77
import EventsEmitter from 'events';
88
import { TagType } from '@salesforce/lightning-lsp-common/lib/indexer/tagInfo';
9+
import { parse } from '../aura-utils';
10+
import { Node } from 'vscode-html-languageservice';
911

1012
const { WorkspaceType } = shared;
1113

0 commit comments

Comments
 (0)