generated from atom-community/atom-ide-template
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e94505a
commit 5a8ac27
Showing
13 changed files
with
422 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// declare module "atom-ide-base" { | ||
export interface BusySignalOptions { | ||
// Can say that a busy signal will only appear when a given file is open. | ||
// Default = `null`, meaning the busy signal applies to all files. | ||
onlyForFile?: string; | ||
// Is user waiting for computer to finish a task? (traditional busy spinner) | ||
// or is the computer waiting for user to finish a task? (action required) | ||
// Default = spinner. | ||
waitingFor?: "computer" | "user"; | ||
// Debounce it? default = `true` for busy-signal, and false for action-required. | ||
debounce?: boolean; | ||
// If `onClick` is set, then the tooltip will be clickable. Default = `null`. | ||
onDidClick?: () => void; | ||
// If set to `true`, the busy signal tooltip will be immediately revealed | ||
// when it first becomes visible (without explicit mouse interaction). | ||
revealTooltip?: boolean; | ||
} | ||
|
||
export interface BusySignalService { | ||
// Activates the busy signal with the given title and returns the promise | ||
// from the provided callback. | ||
// The busy signal automatically deactivates when the returned promise | ||
// either resolves or rejects. | ||
reportBusyWhile<T>( | ||
title: string, | ||
f: () => Promise<T>, | ||
options?: BusySignalOptions | ||
): Promise<T>; | ||
|
||
// Activates the busy signal. Set the title in the returned BusySignal | ||
// object (you can update the title multiple times) and dispose it when done. | ||
reportBusy(title: string, options?: BusySignalOptions): BusyMessage; | ||
|
||
// This is a no-op. When someone consumes the busy service, they get back a | ||
// reference to the single shared instance, so disposing of it would be wrong. | ||
dispose(): void; | ||
} | ||
|
||
export interface BusyMessage { | ||
// You can set/update the title. | ||
setTitle(title: string): void; | ||
// Dispose of the signal when done to make it go away. | ||
dispose(): void; | ||
} | ||
// } |
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,31 @@ | ||
import * as Atom from "atom"; | ||
import { Message } from "atom/linter"; | ||
|
||
export interface CodeAction { | ||
apply(): Promise<void>; | ||
getTitle(): Promise<string>; | ||
dispose(): void; | ||
} | ||
|
||
export interface CodeActionProvider { | ||
grammarScopes?: ReadonlyArray<string>; | ||
priority: number; | ||
getCodeActions( | ||
editor: Atom.TextEditor, | ||
range: Atom.Range, | ||
diagnostics: Message[] | ||
): Promise<CodeAction[] | null | undefined>; | ||
} | ||
|
||
/** | ||
* atom-ide-base-code-actions provides a CodeActionFetcher which offers an API to | ||
* request CodeActions from all CodeAction providers. For now, CodeActionFetcher | ||
* can only fetch CodeActions for a Diagnostic. In the future, this API can be | ||
* extended to provide a stream of CodeActions based on the cursor position. | ||
*/ | ||
export interface CodeActionFetcher { | ||
getCodeActionForDiagnostic: ( | ||
diagnostic: Message, | ||
editor: Atom.TextEditor | ||
) => Promise<CodeAction[]>; | ||
} |
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,10 @@ | ||
import * as Atom from "atom"; | ||
|
||
export interface CodeHighlightProvider { | ||
priority: number; | ||
grammarScopes: ReadonlyArray<string>; | ||
highlight( | ||
editor: Atom.TextEditor, | ||
bufferPosition: Atom.Point | ||
): Promise<Atom.Range[] | undefined | null>; | ||
} |
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,71 @@ | ||
import * as Atom from "atom"; | ||
|
||
export interface DatatipService { | ||
addProvider(provider: DatatipProvider): Atom.DisposableLike; | ||
addModifierProvider(provider: ModifierDatatipProvider): Atom.DisposableLike; | ||
createPinnedDataTip( | ||
datatip: Datatip, | ||
editor: Atom.TextEditor, | ||
options?: PinnedDatatipOptions | ||
): Atom.DisposableLike; | ||
} | ||
|
||
export interface PinnedDatatipOptions { | ||
// Defaults to 'end-of-line'. | ||
position?: PinnedDatatipPosition; | ||
// Defaults to true. | ||
showRangeHighlight?: boolean; | ||
} | ||
|
||
export type PinnedDatatipPosition = "end-of-line" | "above-range"; | ||
|
||
export interface DatatipProvider { | ||
priority: number; | ||
grammarScopes?: ReadonlyArray<string>; | ||
// A unique name for the provider to be used for analytics. | ||
// It is recommended that it be the name of the provider's package. | ||
providerName: string; | ||
datatip( | ||
editor: Atom.TextEditor, | ||
bufferPosition: Atom.Point | ||
): Promise<Datatip | undefined | null>; | ||
} | ||
|
||
export interface ModifierDatatipProvider { | ||
priority: number; | ||
grammarScopes?: string[]; | ||
providerName: string; | ||
modifierDatatip( | ||
editor: Atom.TextEditor, | ||
bufferPosition: Atom.Point, | ||
heldKeys: Set<ModifierKey> | ||
): Promise<Datatip | undefined | null>; | ||
} | ||
|
||
export type AnyDatatipProvider = DatatipProvider | ModifierDatatipProvider; | ||
|
||
export type Datatip = | ||
| { | ||
markedStrings: MarkedString[]; | ||
range: Atom.Range; | ||
pinnable?: boolean; | ||
} | ||
| { | ||
component: () => JSX.Element; // React component | ||
range: Atom.Range; | ||
pinnable?: boolean; | ||
}; | ||
|
||
// Borrowed from the LSP API. | ||
export type MarkedString = | ||
| { | ||
type: "markdown"; | ||
value: string; | ||
} | ||
| { | ||
type: "snippet"; | ||
grammar: Atom.Grammar; | ||
value: string; | ||
}; | ||
|
||
export type ModifierKey = "metaKey" | "shiftKey" | "altKey" | "ctrlKey"; |
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,57 @@ | ||
import * as Atom from "atom"; | ||
|
||
export interface Definition { | ||
// Path of the file in which the definition is located. | ||
path: string; | ||
// First character of the definition's identifier. | ||
// e.g. "F" in `class Foo {}` | ||
position: Atom.Point; | ||
// Optional: the range of the entire definition. | ||
// e.g. "c" to "}" in `class Foo {}` | ||
range?: Atom.Range; | ||
// Optional: `name` and `projectRoot` can be provided to display a more human-readable title | ||
// inside of Hyperclick when there are multiple definitions. | ||
name?: string; | ||
// If provided, `projectRoot` will be used to display a relativized version of `path`. | ||
projectRoot?: string; | ||
// `language` may be used by consumers to identify the source of definitions. | ||
language: string; | ||
} | ||
|
||
// Definition queries supply a point. | ||
// The returned queryRange is the range within which the returned definition is valid. | ||
// Typically queryRange spans the containing identifier around the query point. | ||
// (If a null queryRange is returned, the range of the word containing the point is used.) | ||
export interface DefinitionQueryResult { | ||
queryRange: ReadonlyArray<Atom.Range> | null | undefined; | ||
definitions: ReadonlyArray<Definition>; // Must be non-empty. | ||
} | ||
|
||
// Provides definitions for a set of language grammars. | ||
export interface DefinitionProvider { | ||
// If there are multiple providers for a given grammar, | ||
// the one with the highest priority will be used. | ||
priority: number; | ||
grammarScopes: ReadonlyArray<string>; | ||
wordRegExp: RegExp | null | undefined; | ||
// Obtains the definition in an editor at the given point. | ||
// This should return null if no definition is available. | ||
getDefinition: ( | ||
editor: Atom.TextEditor, | ||
position: Atom.Point | ||
) => Promise<DefinitionQueryResult | null | undefined>; | ||
} | ||
|
||
export interface DefinitionPreviewProvider { | ||
getDefinitionPreview( | ||
definition: Definition | ||
): Promise< | ||
| { | ||
mime: string; | ||
contents: string; | ||
encoding: string; | ||
} | ||
| null | ||
| 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,34 @@ | ||
import * as Atom from "atom"; | ||
|
||
export interface FindReferencesProvider { | ||
// Return true if your provider supports finding references for the provided Atom.TextEditor. | ||
isEditorSupported(editor: Atom.TextEditor): Promise<boolean>; | ||
|
||
// `findReferences` will only be called if `isEditorSupported` previously returned true | ||
// for the given Atom.TextEditor. | ||
findReferences( | ||
editor: Atom.TextEditor, | ||
position: Atom.Point | ||
): Promise<FindReferencesReturn | undefined | null>; | ||
} | ||
|
||
export interface Reference { | ||
uri: string; // Nuclide URI of the file path | ||
name: string | undefined | null; // name of calling method/function/symbol | ||
range: Atom.Range; | ||
} | ||
|
||
export interface FindReferencesData { | ||
type: "data"; | ||
baseUri: string; | ||
referencedSymbolName: string; | ||
references: Reference[]; | ||
title?: string; // defaults to 'Symbol References' | ||
} | ||
|
||
export interface FindReferencesError { | ||
type: "error"; | ||
message: string; | ||
} | ||
|
||
export type FindReferencesReturn = FindReferencesData | FindReferencesError; |
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,39 @@ | ||
import * as Atom from "atom"; | ||
|
||
export interface HyperclickProvider { | ||
// Use this to provide a suggestion for single-word matches. | ||
// Optionally set `wordRegExp` to adjust word-matching. | ||
getSuggestionForWord?: ( | ||
textEditor: Atom.TextEditor, | ||
text: string, | ||
range: Atom.Range | ||
) => Promise<HyperclickSuggestion | null | undefined>; | ||
|
||
wordRegExp?: RegExp; | ||
|
||
// Use this to provide a suggestion if it can have non-contiguous ranges. | ||
// A primary use-case for this is Objective-C methods. | ||
getSuggestion?: ( | ||
textEditor: Atom.TextEditor, | ||
position: Atom.Point | ||
) => Promise<HyperclickSuggestion | null | undefined>; | ||
|
||
// Must be unique. Used for analytics. | ||
providerName?: string; | ||
|
||
// The higher this is, the more precedence the provider gets. | ||
priority: number; | ||
|
||
// Optionally, limit the set of grammar scopes the provider should apply to. | ||
grammarScopes?: string[]; | ||
} | ||
|
||
export interface HyperclickSuggestion { | ||
// The range(s) to underline to provide as a visual cue for clicking. | ||
range: Atom.Range | Atom.Range[]; | ||
|
||
// The function to call when the underlined text is clicked. | ||
callback: | ||
| (() => void) | ||
| Array<{ rightLabel?: string; title: string; callback: () => void }>; | ||
} |
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,12 @@ | ||
// atom-ide | ||
// https://github.com/atom-ide-community/atom-ide-base | ||
|
||
export * from "./busy-signal" | ||
export * from "./code-actions" | ||
export * from "./code-highlight" | ||
export * from "./datatip" | ||
export * from "./definitions" | ||
export * from "./find-references" | ||
export * from "./hyperclick" | ||
export * from "./outline" | ||
export * from "./sig-help" |
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,71 @@ | ||
import * as Atom from "atom"; | ||
|
||
export interface OutlineProvider { | ||
name: string; | ||
// If there are multiple providers for a given grammar, the one with the highest priority will be | ||
// used. | ||
priority: number; | ||
grammarScopes: ReadonlyArray<string>; | ||
updateOnEdit?: boolean; | ||
getOutline(editor: Atom.TextEditor): Promise<Outline | null | undefined>; | ||
} | ||
|
||
export interface OutlineTree { | ||
icon?: string; // from Atom.Octicon (that type's not allowed over rpc so we use string) | ||
kind?: OutlineTreeKind; // kind you can pass to the UI for theming | ||
|
||
// Must be one or the other. If both are present, tokenizedText is preferred. | ||
plainText?: string; | ||
tokenizedText?: TokenizedText; | ||
|
||
// If user has atom-ide-base-outline-view.nameOnly then representativeName is used instead. | ||
representativeName?: string; | ||
|
||
startPosition: Atom.Point; | ||
endPosition?: Atom.Point; | ||
landingPosition?: Atom.Point; | ||
children: OutlineTree[]; | ||
} | ||
|
||
export interface Outline { | ||
outlineTrees: OutlineTree[]; | ||
} | ||
|
||
// Kind of outline tree - matches the names from the Language Server Protocol v2. | ||
export type OutlineTreeKind = | ||
| "file" | ||
| "module" | ||
| "namespace" | ||
| "package" | ||
| "class" | ||
| "method" | ||
| "property" | ||
| "field" | ||
| "constructor" | ||
| "enum" | ||
| "interface" | ||
| "function" | ||
| "variable" | ||
| "constant" | ||
| "string" | ||
| "number" | ||
| "boolean" | ||
| "array"; | ||
|
||
export type TokenKind = | ||
| "keyword" | ||
| "class-name" | ||
| "constructor" | ||
| "method" | ||
| "param" | ||
| "string" | ||
| "whitespace" | ||
| "plain" | ||
| "type"; | ||
|
||
export interface TextToken { | ||
kind: TokenKind; | ||
value: string; | ||
} | ||
|
||
export type TokenizedText = TextToken[]; |
Oops, something went wrong.