-
Notifications
You must be signed in to change notification settings - Fork 3
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
bd05213
commit 34eba0e
Showing
13 changed files
with
158 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# 1.0.0 (2021-07-15) | ||
|
||
|
||
### Bug Fixes | ||
|
||
* add dependencies - use atom-community packages ([d9d7164](https://github.com/atom-community/atom-ide-code-format/commit/d9d7164db25df401bd76d80dc96f6254d57a54e0)) | ||
* adopt template - add build scripts ([1019c71](https://github.com/atom-community/atom-ide-code-format/commit/1019c71d454ea2a01446869ac4628b15834f33de)) | ||
* do not bundle rxjs-compat/bundles/rxjs-compat.umd.min.js ([933b58f](https://github.com/atom-community/atom-ide-code-format/commit/933b58fb298936eaabe4756612354a1e9d40ce27)) | ||
* eslint fix ([feef034](https://github.com/atom-community/atom-ide-code-format/commit/feef034e679201f68653066c367b04feb16c2d39)) | ||
* export package functions directly ([dd924fb](https://github.com/atom-community/atom-ide-code-format/commit/dd924fb939f8955c1dc3814cedc52d89e06af9a7)) | ||
* free _checkContentsAreSame ([669f20a](https://github.com/atom-community/atom-ide-code-format/commit/669f20a0a24578c50f4cceee0ab29e2412214653)) | ||
* free _getEditorEventStream ([72586af](https://github.com/atom-community/atom-ide-code-format/commit/72586af562a3e01ccc3ffe0c577c96e30ceef24c)) | ||
* more strict tsconfig ([df4ecdd](https://github.com/atom-community/atom-ide-code-format/commit/df4ecdd185976e606a94d2c30e5ceb0168189dd8)) | ||
* move config to config.json ([32260d5](https://github.com/atom-community/atom-ide-code-format/commit/32260d5622dfecc6a76a7a20478c0c4cf75e51cf)) | ||
|
||
|
||
### Features | ||
|
||
* convert to Typescript ([0506e74](https://github.com/atom-community/atom-ide-code-format/commit/0506e743f6482493d87eb40449c24c43c4db155f)) |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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 @@ | ||
export {}; |
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,2 @@ | ||
declare const _default: import("atom").TestRunner; | ||
export default _default; |
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,4 @@ | ||
/** Wait until a function returns true */ | ||
export declare function waitFor(fn: (...args: any[]) => boolean, timeout?: number): any; | ||
/** Sleep for ms */ | ||
export declare function sleep(ms: any): Promise<unknown>; |
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,52 @@ | ||
import type { TextEditor, TextChange, Disposable } from "atom"; | ||
declare type AggregatedTextChange = { | ||
changes: Array<TextChange>; | ||
}; | ||
import type { TextEdit } from "@atom-ide-community/nuclide-commons-atom/text-edit"; | ||
import type { BusySignalService } from "atom-ide-base"; | ||
import type { FileCodeFormatProvider, OnSaveCodeFormatProvider, OnTypeCodeFormatProvider, RangeCodeFormatProvider } from "./types"; | ||
import { Range } from "atom"; | ||
import ProviderRegistry from "@atom-ide-community/nuclide-commons-atom/ProviderRegistry"; | ||
import UniversalDisposable from "@atom-ide-community/nuclide-commons/UniversalDisposable"; | ||
import { Observable } from "rxjs-compat/bundles/rxjs-compat.umd.min.js"; | ||
import type { Subscription } from "rxjs"; | ||
export declare const SAVE_TIMEOUT = 2500; | ||
declare type FormatEvent = { | ||
type: "command" | "save" | "new-save"; | ||
editor: TextEditor; | ||
} | { | ||
type: "type"; | ||
editor: TextEditor; | ||
edit: AggregatedTextChange; | ||
}; | ||
export default class CodeFormatManager { | ||
_subscriptions: UniversalDisposable; | ||
_rangeProviders: ProviderRegistry<RangeCodeFormatProvider>; | ||
_fileProviders: ProviderRegistry<FileCodeFormatProvider>; | ||
_onTypeProviders: ProviderRegistry<OnTypeCodeFormatProvider>; | ||
_onSaveProviders: ProviderRegistry<OnSaveCodeFormatProvider>; | ||
_busySignalService: BusySignalService | undefined | null; | ||
constructor(); | ||
/** | ||
* Subscribe to all formatting events (commands, saves, edits) and dispatch formatters as necessary. By handling all | ||
* events in a central location, we ensure that no buffer runs into race conditions with simultaneous formatters. | ||
*/ | ||
_subscribeToEvents(): Subscription; | ||
_handleEvent(event: FormatEvent): Observable<unknown>; | ||
_formatCodeInTextEditor(editor: TextEditor, range?: Range): Observable<Array<TextEdit>>; | ||
_formatCodeOnTypeInTextEditor(editor: TextEditor, aggregatedEvent: AggregatedTextChange): Observable<Array<TextEdit>>; | ||
_onWillSaveProvider(): { | ||
priority: number; | ||
timeout: number; | ||
callback: (editor: TextEditor) => any; | ||
}; | ||
_formatCodeOnSaveInTextEditor(editor: TextEditor): Observable<TextEdit>; | ||
_reportBusy<T>(editor: TextEditor, promise: Promise<T>, revealTooltip?: boolean): Promise<T>; | ||
addRangeProvider(provider: RangeCodeFormatProvider): Disposable; | ||
addFileProvider(provider: FileCodeFormatProvider): Disposable; | ||
addOnTypeProvider(provider: OnTypeCodeFormatProvider): Disposable; | ||
addOnSaveProvider(provider: OnSaveCodeFormatProvider): Disposable; | ||
consumeBusySignal(busySignalService: BusySignalService): Disposable; | ||
dispose(): void; | ||
} | ||
export {}; |
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,3 @@ | ||
import type { TextEditor } from "atom"; | ||
export declare function getFormatOnSave(editor: TextEditor): boolean; | ||
export declare function getFormatOnType(): boolean; |
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,3 @@ | ||
import type { Disposable } from "atom"; | ||
import type { CodeFormatProvider } from "./types"; | ||
export declare function consumeLegacyProvider(provider: CodeFormatProvider): Disposable; |
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 @@ | ||
import type { Disposable } from "atom"; | ||
import type { BusySignalService } from "atom-ide-base"; | ||
import type { RangeCodeFormatProvider, FileCodeFormatProvider, OnTypeCodeFormatProvider, OnSaveCodeFormatProvider } from "./types"; | ||
export { default as config } from "./config.json"; | ||
export declare function activate(): void; | ||
export declare function consumeRangeProvider(provider: RangeCodeFormatProvider): Disposable; | ||
export declare function consumeFileProvider(provider: FileCodeFormatProvider): Disposable; | ||
export declare function consumeOnTypeProvider(provider: OnTypeCodeFormatProvider): Disposable; | ||
export declare function consumeOnSaveProvider(provider: OnSaveCodeFormatProvider): Disposable; | ||
export declare function consumeBusySignal(busySignalService: BusySignalService): Disposable; | ||
export declare function deactivate(): void; | ||
export { consumeLegacyProvider } from "./legacy-provider"; |
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 type { TextEditor, Range, Point } from "atom"; | ||
import type { TextEdit } from "@atom-ide-community/nuclide-commons-atom/text-edit"; | ||
/** | ||
* A brief overview of the different code formatting providers: | ||
* | ||
* == Range formatters == These accept a range to format and return a list of edits to apply. These will always be | ||
* preferred over file formatters when a range is selected. | ||
* | ||
* == File formatters == These always return the result of formatting the entire file. To compensate, they can return a | ||
* custom cursor position to avoid disruption. These will be preferred over range formatters for whole-file formatting. | ||
* | ||
* == onType formatters == These are run after every typing event in a selected editor. | ||
* | ||
* == onSave formatters == These are run whenever a selected editor is saved. If the global format-on-save option is | ||
* enabled, then file/range formatters will be triggered on save (even if no save formatters are provided). Obviously, | ||
* save formatters are preferred in this case. | ||
*/ | ||
/** | ||
* Formats the range specified, and returns a list of text edits to apply. Text edits must be non-overlapping and | ||
* preferably in reverse-sorted order. | ||
*/ | ||
export declare type RangeCodeFormatProvider = { | ||
formatCode: (editor: TextEditor, range: Range) => Promise<Array<TextEdit>>; | ||
priority: number; | ||
readonly grammarScopes?: Array<string>; | ||
}; | ||
/** | ||
* Formats the range specified, but returns the entire file (along with the new cursor position). Useful for | ||
* less-flexible providers like clang-format. | ||
*/ | ||
export declare type FileCodeFormatProvider = { | ||
formatEntireFile: (editor: TextEditor, range: Range) => Promise<{ | ||
newCursor?: number; | ||
formatted: string; | ||
} | undefined | null>; | ||
priority: number; | ||
readonly grammarScopes?: Array<string>; | ||
}; | ||
/** | ||
* Formats around the given position, and returns a list of text edits to apply, similar to `formatCode`. The provider | ||
* determines the exact range to format based on what's at that position. | ||
* | ||
* This will automatically triggered after every typing event. | ||
*/ | ||
export declare type OnTypeCodeFormatProvider = { | ||
formatAtPosition: (editor: TextEditor, position: Point, triggerCharacter: string) => Promise<Array<TextEdit>>; | ||
priority: number; | ||
readonly grammarScopes?: Array<string>; | ||
keepCursorPosition: boolean; | ||
}; | ||
/** Formats files after save events. */ | ||
export declare type OnSaveCodeFormatProvider = { | ||
formatOnSave: (editor: TextEditor) => Promise<Array<TextEdit>>; | ||
priority: number; | ||
readonly grammarScopes?: Array<string>; | ||
}; | ||
export declare type CodeFormatProvider = RangeCodeFormatProvider | FileCodeFormatProvider | OnTypeCodeFormatProvider | OnSaveCodeFormatProvider; |
Large diffs are not rendered by default.
Oops, something went wrong.
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