-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: inter-file code flow in diagnostics [ROAD-864] (#214)
- Loading branch information
1 parent
55e1dfb
commit 2449c68
Showing
12 changed files
with
260 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import sinon from 'sinon'; | ||
import { IVSCodeLanguages } from '../../../snyk/common/vscode/languages'; | ||
import { DiagnosticRelatedInformation, Position, Range as vsRange, Uri } from '../../../snyk/common/vscode/types'; | ||
|
||
export const languagesMock = { | ||
createDiagnostic: sinon.fake(), | ||
createDiagnosticCollection: sinon.fake(), | ||
registerCodeActionsProvider: sinon.fake(), | ||
registerHoverProvider: sinon.fake(), | ||
|
||
createDiagnosticRelatedInformation( | ||
uri: Uri, | ||
rangeOrPosition: vsRange | Position, | ||
message: string, | ||
): DiagnosticRelatedInformation { | ||
const range = isRange(rangeOrPosition) | ||
? rangeOrPosition | ||
: ({ | ||
start: { | ||
line: rangeOrPosition.line, | ||
character: rangeOrPosition.character, | ||
}, | ||
end: { | ||
line: rangeOrPosition.line, | ||
character: rangeOrPosition.character, | ||
}, | ||
} as unknown as vsRange); | ||
|
||
return { | ||
message, | ||
location: { | ||
uri, | ||
range, | ||
}, | ||
}; | ||
}, | ||
|
||
createRange(startLine: number, startCharacter: number, endLine: number, endCharacter: number): vsRange { | ||
return { | ||
start: { | ||
line: startLine, | ||
character: startCharacter, | ||
} as unknown as Position, | ||
end: { | ||
line: endLine, | ||
character: endCharacter, | ||
} as unknown as Position, | ||
} as unknown as vsRange; | ||
}, | ||
} as IVSCodeLanguages; | ||
|
||
function isRange(pet: vsRange | Position): pet is vsRange { | ||
return (pet as vsRange).start !== undefined; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Uri } from '../../../snyk/common/vscode/types'; | ||
import { IUriAdapter } from '../../../snyk/common/vscode/uri'; | ||
|
||
export class UriAdapterMock implements IUriAdapter { | ||
file(path: string): Uri { | ||
return { | ||
path: path, | ||
} as Uri; | ||
} | ||
|
||
parse(path: string): Uri { | ||
return { | ||
path: path, | ||
} as Uri; | ||
} | ||
} | ||
|
||
export const uriAdapterMock = new UriAdapterMock(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.