Skip to content

Commit

Permalink
perf(ls): apply perfomanze optimization for reference validation (#3966)
Browse files Browse the repository at this point in the history
Refs #3965
  • Loading branch information
char0n authored Mar 25, 2024
1 parent 0196a31 commit ef9f2ba
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions packages/apidom-ls/src/services/validation/validation-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
findAtOffset,
traverse,
toValue,
cloneDeep,
} from '@swagger-api/apidom-core';
import { CodeActionKind, CodeActionParams } from 'vscode-languageserver-protocol';
import { evaluate, evaluateMulti } from '@swagger-api/apidom-json-path';
Expand Down Expand Up @@ -233,7 +234,7 @@ export class DefaultValidationService implements ValidationService {
const baseURI = validationContext?.baseURI
? validationContext?.baseURI
: 'https://smartbear.com/';
const apiReference = Reference({ uri: baseURI, value: result });
const apiReference = Reference({ uri: baseURI, value: cloneDeep(result) });
const cachedParsers = options.parse.parsers.map(DefaultValidationService.createCachedParser);

for (const [fragmentId, refEl] of refElements.entries()) {
Expand All @@ -253,7 +254,10 @@ export class DefaultValidationService implements ValidationService {
parsers: cachedParsers,
mediaType: nameSpace.mediaType,
},
dereference: { refSet },
dereference: {
refSet,
immutable: false,
},
}).catch((e: Error) => {
return { error: e, refEl };
});
Expand Down Expand Up @@ -332,7 +336,7 @@ export class DefaultValidationService implements ValidationService {
const baseURI = validationContext?.baseURI
? validationContext?.baseURI
: 'https://smartbear.com/';
const apiReference = Reference({ uri: baseURI, value: result });
const apiReference = Reference({ uri: baseURI, value: cloneDeep(result) });
const cachedParsers = options.parse.parsers.map(DefaultValidationService.createCachedParser);

for (const [fragmentId, refEl] of refElements.entries()) {
Expand All @@ -353,7 +357,10 @@ export class DefaultValidationService implements ValidationService {
mediaType: nameSpace.mediaType,
parsers: cachedParsers,
},
dereference: { refSet },
dereference: {
refSet,
immutable: false,
},
});
} catch (ex) {
const message = DefaultValidationService.buildReferenceErrorMessageFromError(ex);
Expand Down

0 comments on commit ef9f2ba

Please sign in to comment.