Skip to content

Commit 316f52d

Browse files
committed
fix: remove all unnecessary classes
1 parent 82f8722 commit 316f52d

File tree

14 files changed

+2104
-2599
lines changed

14 files changed

+2104
-2599
lines changed

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

Lines changed: 1609 additions & 1609 deletions
Large diffs are not rendered by default.

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as path from 'path';
44
import mockFs from 'mock-fs';
55
import URI from 'vscode-uri';
66

7-
function normalize(start: string, p: string): string {
7+
const normalize = (start: string, p: string): string => {
88
// Fix relative paths on windows
99
if (start.indexOf('\\') !== -1) {
1010
start = start.replace(/\\/g, '/');
@@ -18,10 +18,11 @@ function normalize(start: string, p: string): string {
1818
return p.slice(start.length + 1);
1919
}
2020
return p;
21-
}
22-
function uriToFile(uri: string): string {
21+
};
22+
23+
const uriToFile = (uri: string): string => {
2324
return URI.parse(uri).fsPath;
24-
}
25+
};
2526

2627
describe('indexer parsing content', () => {
2728
afterEach(() => {

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
import { Indexer, TagInfo, createTagInfo, createAttributeInfo, WorkspaceType, elapsedMillis } from '@salesforce/lightning-lsp-common';
1+
import { Indexer, TagInfo, createTagInfo, createAttributeInfo, WorkspaceType, elapsedMillis, TagType } from '@salesforce/lightning-lsp-common';
22
import { componentFromFile, componentFromDirectory } from '../util/component-util';
33
import { Location } from 'vscode-languageserver';
44
import * as auraUtils from '../aura-utils';
55
import * as fs from 'fs';
66
import LineColumnFinder from 'line-column';
77
import URI from 'vscode-uri';
88
import EventsEmitter from 'events';
9-
import { TagType } from '@salesforce/lightning-lsp-common/lib/indexer/tagInfo';
109
import { parse } from '../aura-utils';
1110
import { Node } from 'vscode-html-languageservice';
1211
import { AuraWorkspaceContext } from '../context/aura-context';

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

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,19 @@ import {
2323
import { getLanguageService, LanguageService, CompletionList } from 'vscode-html-languageservice';
2424

2525
import URI from 'vscode-uri';
26-
import { utils, interceptConsoleLogger, TagInfo } from '@salesforce/lightning-lsp-common';
26+
import {
27+
toResolvedPath,
28+
WorkspaceType,
29+
interceptConsoleLogger,
30+
TagInfo,
31+
elapsedMillis,
32+
isAuraRootDirectoryCreated,
33+
isAuraWatchedDirectory,
34+
} from '@salesforce/lightning-lsp-common';
2735
import { AuraWorkspaceContext } from './context/aura-context';
2836
import { startServer, addFile, delFile, onCompletion, onHover, onDefinition, onTypeDefinition, onReferences, onSignatureHelp } from './tern-server/tern-server';
2937
import AuraIndexer from './aura-indexer/indexer';
30-
import { toResolvedPath } from '@salesforce/lightning-lsp-common/lib/utils';
3138
import { setIndexer, getAuraTagProvider } from './markup/auraTags';
32-
import { WorkspaceType } from '@salesforce/lightning-lsp-common/lib/shared';
3339
import { getAuraBindingTemplateDeclaration, getAuraBindingValue } from './aura-utils';
3440

3541
interface TagParams {
@@ -107,7 +113,7 @@ export default class Server {
107113
this.htmlLS = getLanguageService();
108114
this.htmlLS.setDataProviders(true, [getAuraTagProvider()]);
109115

110-
console.info('... language server started in ' + utils.elapsedMillis(startTime));
116+
console.info('... language server started in ' + elapsedMillis(startTime));
111117

112118
return {
113119
capabilities: {
@@ -266,16 +272,16 @@ export default class Server {
266272
const changes = change.changes;
267273

268274
try {
269-
if (utils.isAuraRootDirectoryCreated(this.context, changes)) {
275+
if (isAuraRootDirectoryCreated(this.context, changes)) {
270276
await this.context.getIndexingProvider('aura').resetIndex();
271277
await this.context.getIndexingProvider('aura').configureAndIndex();
272278
// re-index everything on directory deletions as no events are reported for contents of deleted directories
273279
const startTime = process.hrtime();
274-
console.info('reindexed workspace in ' + utils.elapsedMillis(startTime) + ', directory was deleted:', changes);
280+
console.info('reindexed workspace in ' + elapsedMillis(startTime) + ', directory was deleted:', changes);
275281
return;
276282
} else {
277283
for (const event of changes) {
278-
if (event.type === FileChangeType.Deleted && utils.isAuraWatchedDirectory(this.context, event.uri)) {
284+
if (event.type === FileChangeType.Deleted && isAuraWatchedDirectory(this.context, event.uri)) {
279285
const dir = toResolvedPath(event.uri);
280286
this.auraIndexer.clearTagsforDirectory(dir, this.context.type === WorkspaceType.SFDX);
281287
} else {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import URI from 'vscode-uri';
99
import browser from '../tern/defs/browser.json';
1010
import ecmascript from '../tern/defs/ecmascript.json';
1111

12-
import { memoize } from '@salesforce/lightning-lsp-common/lib/utils';
12+
import { memoize } from '@salesforce/lightning-lsp-common';
1313
import {
1414
TextDocumentPositionParams,
1515
CompletionList,

packages/lightning-lsp-common/package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@
3636
"import": "./lib/namespace-utils.js",
3737
"require": "./lib/namespace-utils.js",
3838
"types": "./lib/namespace-utils.d.ts"
39+
},
40+
"./indexer/attributeInfo": {
41+
"import": "./lib/indexer/attributeInfo.js",
42+
"require": "./lib/indexer/attributeInfo.js",
43+
"types": "./lib/indexer/attributeInfo.d.ts"
44+
},
45+
"./indexer/tagInfo": {
46+
"import": "./lib/indexer/tagInfo.js",
47+
"require": "./lib/indexer/tagInfo.js",
48+
"types": "./lib/indexer/tagInfo.d.ts"
3949
}
4050
},
4151
"license": "BSD-3-Clause",

packages/lightning-lsp-common/src/index.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,23 @@ export {
2323
writeJsonSync,
2424
} from './utils';
2525

26-
// Re-export utils as a namespace
27-
export * as utils from './utils';
28-
2926
// Re-export from base-context
3027
export { BaseWorkspaceContext, Indexer, AURA_EXTENSIONS, processTemplate, getModulesDirs, updateForceIgnoreFile } from './base-context';
3128

3229
// Re-export from shared
33-
export * from './shared';
34-
export * as shared from './shared';
30+
export { WorkspaceType, isLWC, getSfdxProjectFile, detectWorkspaceHelper, detectWorkspaceType } from './shared';
3531

3632
// Re-export from indexer
37-
export { TagInfo, createTagInfo, getAttributeInfo, getHover, getComponentLibraryLink, getAttributeMarkdown, getMethodMarkdown } from './indexer/tagInfo';
33+
export {
34+
TagInfo,
35+
createTagInfo,
36+
getAttributeInfo,
37+
getHover,
38+
getComponentLibraryLink,
39+
getAttributeMarkdown,
40+
getMethodMarkdown,
41+
TagType,
42+
} from './indexer/tagInfo';
3843
export { AttributeInfo, createAttributeInfo, Decorator, MemberType } from './indexer/attributeInfo';
3944

4045
// Re-export from other modules

packages/lightning-lsp-common/src/shared.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,19 @@ export enum WorkspaceType {
2222
UNKNOWN,
2323
}
2424

25-
export function isLWC(type: WorkspaceType): boolean {
25+
export const isLWC = (type: WorkspaceType): boolean => {
2626
return type === WorkspaceType.SFDX || type === WorkspaceType.STANDARD_LWC || type === WorkspaceType.CORE_ALL || type === WorkspaceType.CORE_PARTIAL;
27-
}
27+
};
2828

29-
export function getSfdxProjectFile(root: string): string {
29+
export const getSfdxProjectFile = (root: string): string => {
3030
return path.join(root, SFDX_PROJECT);
31-
}
31+
};
3232

3333
/**
3434
* @param root
3535
* @returns WorkspaceType for singular root
3636
*/
37-
export function detectWorkspaceHelper(root: string): WorkspaceType {
37+
export const detectWorkspaceHelper = (root: string): WorkspaceType => {
3838
if (fs.existsSync(getSfdxProjectFile(root))) {
3939
return WorkspaceType.SFDX;
4040
}
@@ -87,13 +87,13 @@ export function detectWorkspaceHelper(root: string): WorkspaceType {
8787

8888
console.error('unknown workspace type:', root);
8989
return WorkspaceType.UNKNOWN;
90-
}
90+
};
9191

9292
/**
9393
* @param workspaceRoots
9494
* @returns WorkspaceType, actively not supporting workspaces of mixed type
9595
*/
96-
export function detectWorkspaceType(workspaceRoots: string[]): WorkspaceType {
96+
export const detectWorkspaceType = (workspaceRoots: string[]): WorkspaceType => {
9797
if (workspaceRoots.length === 1) {
9898
return detectWorkspaceHelper(workspaceRoots[0]);
9999
}
@@ -105,4 +105,4 @@ export function detectWorkspaceType(workspaceRoots: string[]): WorkspaceType {
105105
}
106106
}
107107
return WorkspaceType.CORE_PARTIAL;
108-
}
108+
};

packages/lwc-language-server/package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,21 @@
4545
"import": "./lib/typing.js",
4646
"require": "./lib/typing.js",
4747
"types": "./lib/typing.d.ts"
48+
},
49+
"./tag": {
50+
"import": "./lib/tag.js",
51+
"require": "./lib/tag.js",
52+
"types": "./lib/tag.d.ts"
53+
},
54+
"./typing-indexer": {
55+
"import": "./lib/typing-indexer.js",
56+
"require": "./lib/typing-indexer.js",
57+
"types": "./lib/typing-indexer.d.ts"
58+
},
59+
"./base-indexer": {
60+
"import": "./lib/base-indexer.js",
61+
"require": "./lib/base-indexer.js",
62+
"types": "./lib/base-indexer.d.ts"
4863
}
4964
},
5065
"license": "BSD-3-Clause",

packages/lwc-language-server/src/__tests__/component-indexer.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@ import { Tag, createTag, getTagName } from '../tag';
33
import { Entry } from 'fast-glob';
44
import * as path from 'path';
55
import { URI } from 'vscode-uri';
6-
import { shared } from '@salesforce/lightning-lsp-common';
6+
import { WorkspaceType } from '@salesforce/lightning-lsp-common';
77
import { Stats, Dirent } from 'fs';
88
import * as fs from 'fs';
99

10-
const { WorkspaceType } = shared;
1110
const workspaceRoot: string = path.resolve('../../test-workspaces/sfdx-workspace');
1211
const componentIndexer: ComponentIndexer = new ComponentIndexer({
1312
workspaceRoot,

0 commit comments

Comments
 (0)