mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-11 02:15:10 -05:00
Gabritto/semicolons (#46832)
* call formatter in completions * fixes * add test * update api baselines * fix createModifiersFromModifierFlag to not return empty array
This commit is contained in:
committed by
GitHub
parent
f4e1efbc29
commit
404a7d602d
@@ -1052,15 +1052,6 @@ namespace ts.textChanges {
|
||||
? "" : options.suffix);
|
||||
}
|
||||
|
||||
function getFormatCodeSettingsForWriting({ options }: formatting.FormatContext, sourceFile: SourceFile): FormatCodeSettings {
|
||||
const shouldAutoDetectSemicolonPreference = !options.semicolons || options.semicolons === SemicolonPreference.Ignore;
|
||||
const shouldRemoveSemicolons = options.semicolons === SemicolonPreference.Remove || shouldAutoDetectSemicolonPreference && !probablyUsesSemicolons(sourceFile);
|
||||
return {
|
||||
...options,
|
||||
semicolons: shouldRemoveSemicolons ? SemicolonPreference.Remove : SemicolonPreference.Ignore,
|
||||
};
|
||||
}
|
||||
|
||||
/** Note: this may mutate `nodeIn`. */
|
||||
function getFormattedTextOfNode(nodeIn: Node, sourceFile: SourceFile, pos: number, { indentation, prefix, delta }: InsertNodeOptions, newLineCharacter: string, formatContext: formatting.FormatContext, validate: ValidateNonFormattedText | undefined): string {
|
||||
const { node, text } = getNonformattedText(nodeIn, sourceFile, newLineCharacter);
|
||||
@@ -1110,7 +1101,7 @@ namespace ts.textChanges {
|
||||
return skipTrivia(s, 0) === s.length;
|
||||
}
|
||||
|
||||
function assignPositionsToNode(node: Node): Node {
|
||||
export function assignPositionsToNode(node: Node): Node {
|
||||
const visited = visitEachChild(node, assignPositionsToNode, nullTransformationContext, assignPositionsToNodeArray, assignPositionsToNode);
|
||||
// create proxy node for non synthesized nodes
|
||||
const newNode = nodeIsSynthesized(visited) ? visited : Object.create(visited) as Node;
|
||||
@@ -1131,7 +1122,7 @@ namespace ts.textChanges {
|
||||
|
||||
interface TextChangesWriter extends EmitTextWriter, PrintHandlers {}
|
||||
|
||||
function createWriter(newLine: string): TextChangesWriter {
|
||||
export function createWriter(newLine: string): TextChangesWriter {
|
||||
let lastNonTriviaPosition = 0;
|
||||
|
||||
const writer = createTextWriter(newLine);
|
||||
|
||||
Reference in New Issue
Block a user