mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-11-16 05:39:28 +00:00
Link compiler errors to editor.
Closes #118 Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
import { ApplicationError } from '@theia/core/lib/common/application-error';
|
||||
import type { Location } from '@theia/core/shared/vscode-languageserver-protocol';
|
||||
import type {
|
||||
Location,
|
||||
Range,
|
||||
Position,
|
||||
} from '@theia/core/shared/vscode-languageserver-protocol';
|
||||
import type {
|
||||
BoardUserField,
|
||||
Port,
|
||||
@@ -15,11 +19,41 @@ export const CompilerWarningLiterals = [
|
||||
] as const;
|
||||
export type CompilerWarnings = typeof CompilerWarningLiterals[number];
|
||||
export namespace CoreError {
|
||||
export interface ErrorLocation {
|
||||
export interface ErrorLocationRef {
|
||||
readonly message: string;
|
||||
readonly location: Location;
|
||||
readonly details?: string;
|
||||
}
|
||||
export namespace ErrorLocationRef {
|
||||
export function equals(
|
||||
left: ErrorLocationRef,
|
||||
right: ErrorLocationRef
|
||||
): boolean {
|
||||
return (
|
||||
left.message === right.message &&
|
||||
left.details === right.details &&
|
||||
equalsLocation(left.location, right.location)
|
||||
);
|
||||
}
|
||||
function equalsLocation(left: Location, right: Location): boolean {
|
||||
return left.uri === right.uri && equalsRange(left.range, right.range);
|
||||
}
|
||||
function equalsRange(left: Range, right: Range): boolean {
|
||||
return (
|
||||
equalsPosition(left.start, right.start) &&
|
||||
equalsPosition(left.end, right.end)
|
||||
);
|
||||
}
|
||||
function equalsPosition(left: Position, right: Position): boolean {
|
||||
return left.character === right.character && left.line === right.line;
|
||||
}
|
||||
}
|
||||
export interface ErrorLocation extends ErrorLocationRef {
|
||||
/**
|
||||
* The range of the error location source from the CLI output.
|
||||
*/
|
||||
readonly rangesInOutput: Range[]; // The same error might show up multiple times in the CLI output: https://github.com/arduino/arduino-cli/issues/1761
|
||||
}
|
||||
export const Codes = {
|
||||
Verify: 4001,
|
||||
Upload: 4002,
|
||||
|
||||
Reference in New Issue
Block a user