Skip to content

Commit 0146936

Browse files
committed
Remove unnecessary parameter to function
1 parent 5bff13b commit 0146936

10 files changed

Lines changed: 33 additions & 70 deletions

File tree

server/src/language-service/cnfgComparisonProvider.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,8 @@ export class CnfgComparisionProvider {
3434
if (!settings) {
3535
return "error";
3636
}
37-
prevVersion.updateObjectParents(
38-
SepticMetaInfoProvider.getInstance().getObjectHierarchy()
39-
);
40-
currentVersion.updateObjectParents(
41-
SepticMetaInfoProvider.getInstance().getObjectHierarchy()
42-
);
37+
prevVersion.updateObjectParents();
38+
currentVersion.updateObjectParents();
4339
const rootObjectDiff: ObjectDiff = compareObjects(
4440
prevVersion.objects[0],
4541
currentVersion.objects[0],

server/src/language-service/completionProvider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,8 @@ export function getObjectCompletion(
200200
contextProvider: SepticContext,
201201
settings: CompletionSettings = { onlySuggestValidSnippets: false }
202202
): CompletionItem[] {
203-
cnfg.updateObjectParents(SepticMetaInfoProvider.getInstance().getObjectHierarchy());
204-
contextProvider.updateObjectParents(SepticMetaInfoProvider.getInstance().getObjectHierarchy());
203+
cnfg.updateObjectParents();
204+
contextProvider.updateObjectParents();
205205
const snippets: CompletionItem[] = getRelevantSnippets(position, contextProvider, cnfg.uri, settings.onlySuggestValidSnippets);
206206
const references: CompletionItem[] = [];
207207
const obj = cnfg.findObjectFromLocation(position);

server/src/septic/cnfg.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,8 @@ export class SepticCnfg implements SepticContext, ITextDocument {
221221
}
222222

223223
public updateObjectParents(
224-
hierarchy: SepticObjectHierarchy
225224
): Promise<void> {
226-
updateParentObjects(this.objects, hierarchy);
225+
updateParentObjects(this.objects);
227226
return Promise.resolve();
228227
}
229228

server/src/septic/context.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import { Position } from 'vscode-languageserver';
1010
export interface SepticContext {
1111
load(): Promise<void>;
1212
getReferences(name: string): SepticReference[] | undefined;
13-
getObjectsByType(...types: string[]): SepticObject[];
1413
getAllXvrObjects(): SepticObject[];
1514
getObjectsByIdentifier(identifier: string): SepticObject[];
15+
getObjectsByType(...types: string[]): SepticObject[];
1616
getObjectByIdentifierAndType(
1717
identifier: string,
1818
type: string
@@ -22,6 +22,6 @@ export interface SepticContext {
2222
name: string,
2323
validationFunction: RefValidationFunction
2424
): boolean;
25-
updateObjectParents(hierarchy: SepticObjectHierarchy): Promise<void>;
25+
updateObjectParents(): Promise<void>;
2626
}
2727

server/src/septic/hierarchy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { SepticObject } from "./elements";
2-
import { SepticObjectHierarchy } from "../metaInfoProvider";
2+
import { SepticMetaInfoProvider, SepticObjectHierarchy } from "../metaInfoProvider";
33

44
interface ObjectNode {
55
obj: SepticObject;
@@ -9,8 +9,8 @@ interface ObjectNode {
99

1010
export function updateParentObjects(
1111
objects: SepticObject[],
12-
objectHierarchy: SepticObjectHierarchy
1312
) {
13+
const objectHierarchy = SepticMetaInfoProvider.getInstance().getObjectHierarchy();
1414
objects.forEach((obj) => {
1515
obj.resetChildren();
1616
obj.resetParent();

server/src/septic/scgContext.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { SepticContext } from './context';
1313
import { SepticObject } from "./elements";
1414
import { SepticConfigProvider } from "../configProvider";
1515
import { SepticCnfg } from "./cnfg";
16-
import { SepticObjectHierarchy } from "../metaInfoProvider";
16+
import { SepticMetaInfoProvider } from "../metaInfoProvider";
1717
import { updateParentObjects } from "./hierarchy";
1818

1919
export interface ScgConfig {
@@ -214,7 +214,6 @@ export class ScgContext implements SepticContext {
214214
}
215215

216216
public async updateObjectParents(
217-
hierarchy: SepticObjectHierarchy
218217
): Promise<void> {
219218
await this.load();
220219
const objects: SepticObject[] = [];
@@ -225,6 +224,6 @@ export class ScgContext implements SepticContext {
225224
}
226225
objects.push(...cnfg.objects);
227226
}
228-
updateParentObjects(objects, hierarchy);
227+
updateParentObjects(objects);
229228
}
230229
}

server/src/server.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,7 @@ let hasWorkspaceFolderCapability = false;
7676
async function publishDiagnosticsScgContext(context: ScgContext): Promise<void> {
7777
await context.load();
7878
const ignorePatterns = await getIgnorePatterns(connection, settingsManager);
79-
await context.updateObjectParents(
80-
SepticMetaInfoProvider.getInstance().getObjectHierarchy()
81-
);
79+
await context.updateObjectParents();
8280
const diagnosticsPromises = context.files.map(async (uri) => {
8381
const codes = getIgnoredCodes(uri, ignorePatterns);
8482
if (codes !== undefined && codes.length == 0) {
@@ -102,9 +100,7 @@ async function publishDiagnosticsCnfg(cnfg: SepticCnfg): Promise<void> {
102100
connection.sendDiagnostics({ uri: cnfg.uri, diagnostics: [] });
103101
return;
104102
}
105-
await cnfg.updateObjectParents(
106-
SepticMetaInfoProvider.getInstance().getObjectHierarchy()
107-
);
103+
await cnfg.updateObjectParents();
108104
let diagnostics = await langService.provideDiagnostics(cnfg.uri, cnfg);
109105
if (codes) {
110106
diagnostics = diagnostics.filter((diag) => diag.code && !codes.includes(diag.code as string));
@@ -527,9 +523,7 @@ connection.onCodeAction(async (params) => {
527523
if (!context) {
528524
return undefined;
529525
}
530-
context.updateObjectParents(
531-
SepticMetaInfoProvider.getInstance().getObjectHierarchy()
532-
);
526+
context.updateObjectParents();
533527
const codeActions = await langService.provideCodeAction(params);
534528
return codeActions;
535529
});

server/src/test/codeActions.test.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@ describe("Test codeaction for inserting evr", () => {
3636
};
3737
const content = loadFile("codeAction.cnfg");
3838
const cnfg = parseSepticForTest(content);
39-
await cnfg.updateObjectParents(
40-
SepticMetaInfoProvider.getInstance().getObjectHierarchy()
41-
);
39+
await cnfg.updateObjectParents();
4240
const codeActions = getCodeActionInsertEvr(params, cnfg, "bottom");
4341
expect(codeActions.length).to.equal(1);
4442
const action = codeActions[0];
@@ -66,9 +64,7 @@ describe("Test codeaction for inserting evr", () => {
6664
};
6765
const content = loadFile("codeAction.cnfg");
6866
const cnfg = parseSepticForTest(content);
69-
cnfg.updateObjectParents(
70-
SepticMetaInfoProvider.getInstance().getObjectHierarchy()
71-
);
67+
cnfg.updateObjectParents();
7268
const codeActions = getCodeActionInsertEvr(params, cnfg, "top");
7369
expect(codeActions.length).to.equal(1);
7470
const action = codeActions[0];
@@ -96,9 +92,7 @@ describe("Test codeaction for inserting evr", () => {
9692
};
9793
const content = loadFile("codeAction.cnfg");
9894
const cnfg = parseSepticForTest(content);
99-
cnfg.updateObjectParents(
100-
SepticMetaInfoProvider.getInstance().getObjectHierarchy()
101-
);
95+
cnfg.updateObjectParents();
10296
const codeActions = getCodeActionInsertEvr(params, cnfg, "bottom");
10397
expect(codeActions.length).to.equal(1);
10498
const action = codeActions[0];
@@ -119,9 +113,7 @@ describe("Test codeaction for inserting evr", () => {
119113
};
120114
const content = loadFile("codeAction.cnfg");
121115
const cnfg = parseSepticForTest(content);
122-
cnfg.updateObjectParents(
123-
SepticMetaInfoProvider.getInstance().getObjectHierarchy()
124-
);
116+
cnfg.updateObjectParents();
125117
const doc = TextDocument.create("", "", 0, content);
126118
const codeActions = getCodeActionInsertEvr(params, cnfg, "bottom");
127119
expect(codeActions.length).to.equal(0);

server/src/test/compareCnfg.test.ts

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -200,14 +200,10 @@ ValidationLimit= -1
200200
Color= BLACK
201201
`;
202202
const prevCnfg = parseSepticForTest(prevText);
203-
prevCnfg.updateObjectParents(
204-
SepticMetaInfoProvider.getInstance().getObjectHierarchy()
205-
);
203+
prevCnfg.updateObjectParents();
206204
const prevObject = prevCnfg.objects[0];
207205
const currentCnfg = parseSepticForTest(currentText);
208-
currentCnfg.updateObjectParents(
209-
SepticMetaInfoProvider.getInstance().getObjectHierarchy()
210-
);
206+
currentCnfg.updateObjectParents();
211207
const currentObject = currentCnfg.objects[0];
212208
const diff = compareObjects(prevObject, currentObject, settings);
213209
const noDiff = isNoDiff(diff);
@@ -271,14 +267,10 @@ ValidationLimit= -1
271267
Color= BLACK
272268
`;
273269
const prevCnfg = parseSepticForTest(prevText);
274-
prevCnfg.updateObjectParents(
275-
SepticMetaInfoProvider.getInstance().getObjectHierarchy()
276-
);
270+
prevCnfg.updateObjectParents();
277271
const prevObject = prevCnfg.objects[0];
278272
const currentCnfg = parseSepticForTest(currentText);
279-
currentCnfg.updateObjectParents(
280-
SepticMetaInfoProvider.getInstance().getObjectHierarchy()
281-
);
273+
currentCnfg.updateObjectParents();
282274
const currentObject = currentCnfg.objects[0];
283275
const diff = compareObjects(prevObject, currentObject, settings);
284276
expect(diff.updatedObjects.length).to.equal(1);
@@ -336,14 +328,10 @@ ValidationLimit= -1
336328
Color= BLACK
337329
`;
338330
const prevCnfg = parseSepticForTest(prevText);
339-
prevCnfg.updateObjectParents(
340-
SepticMetaInfoProvider.getInstance().getObjectHierarchy()
341-
);
331+
prevCnfg.updateObjectParents();
342332
const prevObject = prevCnfg.objects[0];
343333
const currentCnfg = parseSepticForTest(currentText);
344-
currentCnfg.updateObjectParents(
345-
SepticMetaInfoProvider.getInstance().getObjectHierarchy()
346-
);
334+
currentCnfg.updateObjectParents();
347335
const currentObject = currentCnfg.objects[0];
348336
const diff = compareObjects(prevObject, currentObject, settings);
349337
expect(diff.addedObjects.length).to.equal(1);
@@ -401,14 +389,10 @@ ValidationLimit= -1
401389
Color= BLACK
402390
`;
403391
const prevCnfg = parseSepticForTest(prevText);
404-
prevCnfg.updateObjectParents(
405-
SepticMetaInfoProvider.getInstance().getObjectHierarchy()
406-
);
392+
prevCnfg.updateObjectParents();
407393
const prevObject = prevCnfg.objects[0];
408394
const currentCnfg = parseSepticForTest(currentText);
409-
currentCnfg.updateObjectParents(
410-
SepticMetaInfoProvider.getInstance().getObjectHierarchy()
411-
);
395+
currentCnfg.updateObjectParents();
412396
const currentObject = currentCnfg.objects[0];
413397
const diff = compareObjects(prevObject, currentObject, settings);
414398
expect(diff.removedObjects.length).to.equal(1);

server/src/test/diagnostics.test.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,7 +1368,6 @@ describe("Test validation of object references", () => {
13681368
});
13691369

13701370
describe("Test validation of object structure", () => {
1371-
const metaInfoProvider = SepticMetaInfoProvider.getInstance();
13721371
it("Expect no diagnostics for correct structure", () => {
13731372
const text = `
13741373
CalcModl: TestModl
@@ -1377,7 +1376,7 @@ describe("Test validation of object structure", () => {
13771376
"
13781377
`;
13791378
const cnfg = parseSepticForTest(text);
1380-
cnfg.updateObjectParents(metaInfoProvider.getObjectHierarchy());
1379+
cnfg.updateObjectParents();
13811380
const diag = validateObjectParent(cnfg.objects[1], cnfg.doc);
13821381
expect(diag.length).to.equal(0);
13831382
});
@@ -1390,7 +1389,7 @@ describe("Test validation of object structure", () => {
13901389
"
13911390
`;
13921391
const cnfg = parseSepticForTest(text);
1393-
cnfg.updateObjectParents(metaInfoProvider.getObjectHierarchy());
1392+
cnfg.updateObjectParents();
13941393
const diag = validateObjectParent(cnfg.objects[0], cnfg.doc);
13951394
expect(diag.length).to.equal(1);
13961395
expect(diag[0].code).to.equal(DiagnosticCode.missingParentObject);
@@ -1404,7 +1403,7 @@ describe("Test validation of object structure", () => {
14041403
"
14051404
`;
14061405
const cnfg = parseSepticForTest(text);
1407-
cnfg.updateObjectParents(metaInfoProvider.getObjectHierarchy());
1406+
cnfg.updateObjectParents();
14081407
const diag = validateObjectParent(cnfg.objects[1], cnfg.doc);
14091408
expect(diag.length).to.equal(1);
14101409
expect(diag[0].code).to.equal(DiagnosticCode.missingParentObject);
@@ -1420,7 +1419,7 @@ describe("Test validation of object structure", () => {
14201419
"
14211420
`;
14221421
const cnfg = parseSepticForTest(text);
1423-
cnfg.updateObjectParents(metaInfoProvider.getObjectHierarchy());
1422+
cnfg.updateObjectParents();
14241423
const diag = validateObjectParent(cnfg.objects[2], cnfg.doc);
14251424
expect(diag.length).to.equal(1);
14261425
expect(diag[0].code).to.equal(DiagnosticCode.invalidParentObject);
@@ -1436,7 +1435,7 @@ describe("Test validation of object structure", () => {
14361435
"
14371436
`;
14381437
const cnfg = parseSepticForTest(text);
1439-
cnfg.updateObjectParents(metaInfoProvider.getObjectHierarchy());
1438+
cnfg.updateObjectParents();
14401439
const diag = validateObjectParent(cnfg.objects[2], cnfg.doc);
14411440
expect(diag.length).to.equal(0);
14421441
});
@@ -1453,7 +1452,7 @@ describe("Test validation of object structure", () => {
14531452
"
14541453
`;
14551454
const cnfg = parseSepticForTest(text);
1456-
cnfg.updateObjectParents(metaInfoProvider.getObjectHierarchy());
1455+
cnfg.updateObjectParents();
14571456
const diag = validateObjectParent(cnfg.objects[3], cnfg.doc);
14581457
expect(diag.length).to.equal(0);
14591458
});
@@ -1464,7 +1463,7 @@ describe("Test validation of object structure", () => {
14641463
"
14651464
`;
14661465
const cnfg = parseSepticForTest(text);
1467-
cnfg.updateObjectParents(metaInfoProvider.getObjectHierarchy());
1466+
cnfg.updateObjectParents();
14681467
const diag = validateObjectParent(cnfg.objects[0], cnfg.doc);
14691468
expect(diag.length).to.equal(0);
14701469
});

0 commit comments

Comments
 (0)