Skip to content

Commit

Permalink
Extension: Importers View and separate LSP protocol package (#8747)
Browse files Browse the repository at this point in the history
  • Loading branch information
mischnic committed Jan 9, 2023
1 parent e2deeec commit 723e844
Show file tree
Hide file tree
Showing 24 changed files with 690 additions and 346 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"outFiles": [
"${workspaceFolder}/packages/utils/parcelforvscode/out/**/*.js"
],
"preLaunchTask": "npm: watch - packages/utils/parcelforvscode",
"preLaunchTask": "Watch VSCode Extension",
"request": "launch",
"type": "extensionHost"
}
Expand Down
38 changes: 38 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,36 @@
{
"version": "2.0.0",
"tasks": [
{
"path": "packages/utils/parcel-lsp/",
"label": "npm: watch - packages/utils/parcel-lsp",
"type": "npm",
"script": "watch",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"presentation": {
"reveal": "never"
},
"group": {
"kind": "build",
"isDefault": true
}
},
{
"path": "packages/utils/parcel-lsp-protocol/",
"label": "npm: watch - packages/utils/parcel-lsp-protocol",
"type": "npm",
"script": "watch",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"presentation": {
"reveal": "never"
},
"group": {
"kind": "build",
"isDefault": true
}
},
{
"path": "packages/utils/parcelforvscode/",
"label": "npm: watch - packages/utils/parcelforvscode",
Expand All @@ -15,6 +45,14 @@
"kind": "build",
"isDefault": true
}
},
{
"label": "Watch VSCode Extension",
"dependsOn": [
"npm: watch - packages/utils/parcel-lsp",
"npm: watch - packages/utils/parcel-lsp-protocol",
"npm: watch - packages/utils/parcelforvscode"
]
}
]
}
188 changes: 188 additions & 0 deletions flow-libs/vscode-languageserver.js.flow
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
// @flow
declare module 'vscode-languageserver' {
declare export opaque type ODiagnosticTag;
declare export opaque type ODiagnosticSeverity;

/**
* The diagnostic tags.
*
* @since 3.15.0
*/
declare export var DiagnosticTag: {|
/**
* Unused or unnecessary code.
*
* Clients are allowed to render diagnostics with this tag faded out instead of having
* an error squiggle.
*/
Unnecessary: ODiagnosticTag,
/**
* Deprecated or obsolete code.
*
* Clients are allowed to rendered diagnostics with this tag strike through.
*/
Deprecated: ODiagnosticTag,
|};

/**
* The diagnostic's severity.
*/
declare export var DiagnosticSeverity: {|
/**
* Reports an error.
*/
Error: ODiagnosticSeverity,
/**
* Reports a warning.
*/
Warning: ODiagnosticSeverity,
/**
* Reports an information.
*/
Information: ODiagnosticSeverity,
/**
* Reports a hint.
*/
Hint: ODiagnosticSeverity,
|};

declare export type DocumentUri = string;

/**
* A literal to identify a text document in the client.
*/
declare export type TextDocumentIdentifier = {|
uri: DocumentUri,
|};

/**
* Position in a text document expressed as zero-based line and character
* offset. Prior to 3.17 the offsets were always based on a UTF-16 string
* representation. So a string of the form `a𐐀b` the character offset of the
* character `a` is 0, the character offset of `𐐀` is 1 and the character
* offset of b is 3 since `𐐀` is represented using two code units in UTF-16.
* Since 3.17 clients and servers can agree on a different string encoding
* representation (e.g. UTF-8). The client announces it's supported encoding
* via the client capability [`general.positionEncodings`](#clientCapabilities).
* The value is an array of position encodings the client supports, with
* decreasing preference (e.g. the encoding at index `0` is the most preferred
* one). To stay backwards compatible the only mandatory encoding is UTF-16
* represented via the string `utf-16`. The server can pick one of the
* encodings offered by the client and signals that encoding back to the
* client via the initialize result's property
* [`capabilities.positionEncoding`](#serverCapabilities). If the string value
* `utf-16` is missing from the client's capability `general.positionEncodings`
* servers can safely assume that the client supports UTF-16. If the server
* omits the position encoding in its initialize result the encoding defaults
* to the string value `utf-16`. Implementation considerations: since the
* conversion from one encoding into another requires the content of the
* file / line the conversion is best done where the file is read which is
* usually on the server side.
*
* Positions are line end character agnostic. So you can not specify a position
* that denotes `\r|\n` or `\n|` where `|` represents the character offset.
*
* @since 3.17.0 - support for negotiated position encoding.
*/
declare export type Position = {|line: number, character: number|};

/**
* A range in a text document expressed as (zero-based) start and end positions.
*
* If you want to specify a range that contains a line including the line ending
* character(s) then use an end position denoting the start of the next line.
* For example:
* ```ts
* {
* start: { line: 5, character: 23 }
* end : { line 6, character : 0 }
* }
* ```
*/
declare export type Range = {|start: Position, end: Position|};

/**
* Structure to capture a description for an error code.
*
* @since 3.16.0
*/
declare export type CodeDescription = {|href: string|};

/**
* Represents a location inside a resource, such as a line
* inside a text file.
*/
declare export type Location = {|uri: string, range: Range|};

/**
* The DiagnosticRelatedInformation namespace provides helper functions to work with
* [DiagnosticRelatedInformation](#DiagnosticRelatedInformation) literals.
*/
declare export type DiagnosticRelatedInformation = {|
location: Location,
message: string,
|};

/**
* Represents a diagnostic, such as a compiler error or warning. Diagnostic objects
* are only valid in the scope of a resource.
*/
declare export type Diagnostic = {|
range: Range,
severity?: ODiagnosticSeverity,
code?: number | string,
codeDescription?: CodeDescription,
source?: string,
message: string,
tags?: ODiagnosticTag[],
relatedInformation?: DiagnosticRelatedInformation[],
data?: mixed,
|};

/**
* A parameter literal used in requests to pass a text document and a position inside that
* document.
*/
declare export type TextDocumentPositionParams = {
textDocument: TextDocumentIdentifier,
position: Position,
...
};

/**
* Represents the connection of two locations. Provides additional metadata over normal [locations](#Location),
* including an origin range.
*/
declare export type LocationLink = {|
/**
* Span of the origin of this link.
*
* Used as the underlined span for mouse interaction. Defaults to the word range at
* the definition position.
*/
originSelectionRange?: Range,
/**
* The target resource identifier of this link.
*/
targetUri: DocumentUri,
/**
* The full target range of this link. If the target for example is a symbol then target range is the
* range enclosing this symbol not including leading/trailing whitespace but everything else
* like comments. This information is typically used to highlight the range in the editor.
*/
targetRange: Range,
/**
* The range that should be selected and revealed when this link is being followed, e.g the name of a function.
* Must be contained by the `targetRange`. See also `DocumentSymbol#range`
*/
targetSelectionRange: Range,
|};

/**
* Information about where a symbol is defined.
*
* Provides additional metadata over normal [location](#Location) definitions, including the range of
* the defining symbol
*/
declare export type DefinitionLink = LocationLink;
}
Loading

0 comments on commit 723e844

Please sign in to comment.