Skip to content

Commit 49bf749

Browse files
authored
Merge pull request #57 from atom-community/types
2 parents b49f7ab + fbc4b82 commit 49bf749

File tree

14 files changed

+165
-21
lines changed

14 files changed

+165
-21
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
- Fix atom-package-deps issues (#60)
44
-
5+
56
### 2.3.4
67

78
- Fix copying from overlays on MacOS (#58)

types-packages/busy-signal.d.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
1+
import type { IdeUri } from "./uri"
2+
13
export interface BusySignalOptions {
24
/**
35
* Can say that a busy signal will only appear when a given file is open.
46
* Default = `null`, meaning the busy signal applies to all files.
57
*/
6-
onlyForFile?: string
8+
onlyForFile?: IdeUri
79

810
/**
911
* Is user waiting for computer to finish a task? (traditional busy spinner)
1012
* or is the computer waiting for user to finish a task? (action required)
11-
* Default = `"computer"`.
13+
* @defaultValue `'computer'`
1214
*/
1315
waitingFor?: "computer" | "user"
1416

1517
/**
16-
* Debounce it? default = `true` for busy-signal, and false for action-required.
18+
* Debounce it? default = `true` for busy-signal, and `false` for action-required.
1719
*/
1820
debounce?: boolean
1921

2022
/**
21-
* If `onClick` is set, then the tooltip will be clickable. Default = `null`.
23+
* If `onClick` is set, then the tooltip will be clickable.
24+
* @defaultValue `null`
2225
*/
2326
onDidClick?: () => void
2427

types-packages/code-actions.d.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
import * as Atom from "atom"
22
import { Message } from "atom/linter"
3+
// TODO add code action support to Atom linter?
4+
5+
export type DiagnosticType = "Error" | "Warning" | "Info"
6+
7+
export interface Diagnostic {
8+
providerName: string
9+
type: DiagnosticType
10+
filePath: string
11+
text?: string
12+
range: Atom.Range
13+
}
314

415
export interface CodeAction {
516
apply(): Promise<void>
@@ -13,7 +24,7 @@ export interface CodeActionProvider {
1324
getCodeActions(
1425
editor: Atom.TextEditor,
1526
range: Atom.Range,
16-
diagnostics: Message[]
27+
diagnostics: Diagnostic[] // | Message[]
1728
): Promise<CodeAction[] | null | undefined>
1829
}
1930

@@ -24,5 +35,5 @@ export interface CodeActionProvider {
2435
* extended to provide a stream of CodeActions based on the cursor position.
2536
*/
2637
export interface CodeActionFetcher {
27-
getCodeActionForDiagnostic: (diagnostic: Message, editor: Atom.TextEditor) => Promise<CodeAction[]>
38+
getCodeActionForDiagnostic: (diagnostic: Diagnostic /* | Message */, editor: Atom.TextEditor) => Promise<CodeAction[]>
2839
}

types-packages/code-format.d.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import type { TextEditor, Point, Range } from "atom"
2+
import type { TextEdit } from "./text-edit"
3+
4+
export interface FileCodeFormatProvider {
5+
formatEntireFile: (editor: TextEditor, range: Range) => Promise<TextEdit[]>
6+
priority: number
7+
grammarScopes: string[]
8+
}
9+
10+
export interface RangeCodeFormatProvider {
11+
formatCode: (editor: TextEditor, range: Range) => Promise<TextEdit[]>
12+
priority: number
13+
grammarScopes: string[]
14+
}
15+
16+
export interface OnSaveCodeFormatProvider {
17+
formatOnSave: (editor: TextEditor) => Promise<TextEdit[]>
18+
priority: number
19+
grammarScopes: string[]
20+
}
21+
22+
export interface OnTypeCodeFormatProvider {
23+
formatAtPosition: (editor: TextEditor, position: Point, character: string) => Promise<TextEdit[]>
24+
priority: number
25+
grammarScopes: string[]
26+
}

types-packages/console.d.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
export interface SourceInfo {
2+
id: string
3+
name: string
4+
start?: () => void
5+
stop?: () => void
6+
}
7+
8+
export type ConsoleService = (options: SourceInfo) => ConsoleApi
9+
10+
export interface ConsoleApi {
11+
setStatus(status: OutputProviderStatus): void
12+
append(message: Message): void
13+
dispose(): void
14+
log(object: string): void
15+
error(object: string): void
16+
warn(object: string): void
17+
info(object: string): void
18+
}
19+
20+
export type OutputProviderStatus = "starting" | "running" | "stopped"
21+
22+
export interface Message {
23+
text: string
24+
level: Level
25+
tags?: string[] | null
26+
kind?: MessageKind | null
27+
scopeName?: string | null
28+
}
29+
30+
export type TaskLevelType = "info" | "log" | "warning" | "error" | "debug" | "success"
31+
export type Level = TaskLevelType | Color
32+
type Color = "red" | "orange" | "yellow" | "green" | "blue" | "purple" | "violet" | "rainbow"
33+
34+
export type MessageKind = "message" | "request" | "response"

types-packages/datatip.d.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,27 @@ export type PinnedDatatipPosition = "end-of-line" | "above-range"
2121

2222
export interface DatatipProvider {
2323
priority: number
24-
grammarScopes?: ReadonlyArray<string>
24+
2525
/**
2626
* A unique name for the provider to be used for analytics.
2727
* It is recommended that it be the name of the provider's package.
2828
*/
2929
providerName: string
30-
datatip(editor: Atom.TextEditor, bufferPosition: Atom.Point): Promise<Datatip | undefined | null>
30+
datatip(
31+
editor: Atom.TextEditor,
32+
bufferPosition: Atom.Point,
33+
/**
34+
* The mouse event that triggered the datatip.
35+
* This is null for manually toggled datatips.
36+
*/
37+
mouseEvent?: MouseEvent | null
38+
): Promise<Datatip | undefined | null>
39+
40+
/** Either pass this or `validForScope` */
41+
grammarScopes?: ReadonlyArray<string>
42+
43+
/** Either pass `grammarScopes` or this function. */
44+
validForScope?(scopeName: string): boolean
3145
}
3246

3347
export interface ModifierDatatipProvider {

types-packages/definitions.d.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import * as Atom from "atom"
2+
import { IdeUri } from "./uri"
23

34
export interface Definition {
45
/**
56
* Path of the file in which the definition is located.
67
*/
7-
path: string
8+
path: IdeUri
89
/**
910
* First character of the definition's identifier.
1011
* e.g. "F" in `class Foo {}`
@@ -23,7 +24,7 @@ export interface Definition {
2324
/**
2425
* If provided, `projectRoot` will be used to display a relativized version of `path`.
2526
*/
26-
projectRoot?: string
27+
projectRoot?: IdeUri
2728
/**
2829
* `language` may be used by consumers to identify the source of definitions.
2930
*/
@@ -48,6 +49,7 @@ export interface DefinitionQueryResult {
4849
* Provides definitions for a set of language grammars.
4950
*/
5051
export interface DefinitionProvider {
52+
name: string
5153
/**
5254
* If there are multiple providers for a given grammar,
5355
* the one with the highest priority will be used.

types-packages/find-references.d.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import * as Atom from "atom"
2+
import { IdeUri } from "./uri"
23

34
export interface FindReferencesProvider {
45
/**
56
* Return true if your provider supports finding references for the provided Atom.TextEditor.
67
*/
7-
isEditorSupported(editor: Atom.TextEditor): Promise<boolean>
8+
isEditorSupported(editor: Atom.TextEditor): boolean | Promise<boolean>
89

910
/**
1011
* `findReferences` will only be called if `isEditorSupported` previously returned true
@@ -15,9 +16,9 @@ export interface FindReferencesProvider {
1516

1617
export interface Reference {
1718
/**
18-
* Nuclide URI of the file path
19+
* URI of the file path
1920
*/
20-
uri: string
21+
uri: IdeUri
2122
/**
2223
* name of calling method/function/symbol
2324
*/
@@ -27,7 +28,7 @@ export interface Reference {
2728

2829
export interface FindReferencesData {
2930
type: "data"
30-
baseUri: string
31+
baseUri: IdeUri
3132
referencedSymbolName: string
3233
references: Reference[]
3334
/**

types-packages/main.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* @see https://github.com/atom-ide-community/atom-ide-base
44
*/
55

6+
export * from "./uri"
67
export * from "./busy-signal"
78
export * from "./code-actions"
89
export * from "./code-highlight"
@@ -13,6 +14,10 @@ export * from "./hyperclick"
1314
export * from "./outline"
1415
export * from "./sig-help"
1516
export * from "./markdown-service"
17+
export * from "./code-format"
18+
export * from "./text-edit"
19+
export * from "./refactor"
20+
export * from "./console"
1621

1722
import { BusySignalProvider } from "./busy-signal.d"
1823
import { CodeActionProvider } from "./code-actions"

types-packages/outline.d.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export interface OutlineProvider {
1414

1515
export interface OutlineTree {
1616
/**
17-
* from Atom.Octicon (that type's not allowed over rpc so we use string)
17+
* from Atom.Octicon or Atom.OcticonsPrivate (types not allowed over rpc so we use string)
1818
*/
1919
icon?: string
2020
/**
@@ -23,9 +23,12 @@ export interface OutlineTree {
2323
kind?: OutlineTreeKind
2424

2525
/**
26-
* Must be one or the other. If both are present, tokenizedText is preferred.
26+
* Must have `plainText` or the `tokenizedText` property. If both are present, `tokenizedText` is preferred.
2727
*/
2828
plainText?: string
29+
/**
30+
* Must have `plainText` or the `tokenizedText` property. If both are present, `tokenizedText` is preferred.
31+
*/
2932
tokenizedText?: TokenizedText
3033

3134
/**

0 commit comments

Comments
 (0)