sql-formatter
Advanced tools
Comparing version 9.0.0 to 9.0.1
@@ -182,3 +182,2 @@ "use strict"; | ||
value: function formatSetOperation(node) { | ||
this.layout.indentation.decreaseTopLevel(); | ||
this.layout.add(_Layout.WS.NEWLINE, _Layout.WS.INDENT, this.show(node.nameToken), _Layout.WS.NEWLINE); | ||
@@ -185,0 +184,0 @@ this.layout.add(_Layout.WS.INDENT); |
@@ -173,3 +173,9 @@ "use strict"; | ||
raw: typeDefTokens.map(formatTypeDefToken('raw')).join(''), | ||
text: typeDefTokens.map(formatTypeDefToken('text')).join('') | ||
text: typeDefTokens.map(formatTypeDefToken('text')).join(''), | ||
start: token.start, | ||
end: token.end + typeDefTokens.map(function (t) { | ||
return t.text.length; | ||
}).reduce(function (a, b) { | ||
return a + b; | ||
}) | ||
}); | ||
@@ -176,0 +182,0 @@ i = endIndex; |
@@ -137,7 +137,6 @@ "use strict"; | ||
// this is a word and not COLLECTION ITEMS | ||
return { | ||
return _objectSpread(_objectSpread({}, token), {}, { | ||
type: _token.TokenType.IDENTIFIER, | ||
raw: token.raw, | ||
text: token.raw | ||
}; | ||
}); | ||
} | ||
@@ -144,0 +143,0 @@ } |
@@ -51,3 +51,5 @@ "use strict"; | ||
raw: '«EOF»', | ||
text: '«EOF»' | ||
text: '«EOF»', | ||
start: Infinity, | ||
end: Infinity | ||
}; | ||
@@ -54,0 +56,0 @@ /** Checks if two tokens are equivalent */ |
@@ -150,10 +150,13 @@ "use strict"; | ||
if (matches) { | ||
var matchedToken = matches[0]; // Advance current position by matched token length | ||
var matchedToken = matches[0]; | ||
var outToken = { | ||
type: type, | ||
raw: matchedToken, | ||
text: transform ? transform(matchedToken) : matchedToken, | ||
start: this.index, | ||
end: this.index + matchedToken.length | ||
}; // Advance current position by matched token length | ||
this.index += matchedToken.length; | ||
return { | ||
type: type, | ||
raw: matchedToken, | ||
text: transform ? transform(matchedToken) : matchedToken | ||
}; | ||
return outToken; | ||
} | ||
@@ -160,0 +163,0 @@ |
@@ -1,2 +0,2 @@ | ||
import type { FormatOptions } from "../types"; | ||
import type { FormatOptions } from "../FormatOptions"; | ||
/** | ||
@@ -3,0 +3,0 @@ * Creates a string to use for one step of indentation. |
@@ -1,2 +0,2 @@ | ||
import type { FormatOptions } from "../types"; | ||
import type { FormatOptions } from "../FormatOptions"; | ||
import Params from "./Params"; | ||
@@ -3,0 +3,0 @@ import { AstNode } from "../parser/ast"; |
@@ -1,2 +0,2 @@ | ||
import type { CommaPosition } from "../types"; | ||
import type { CommaPosition } from "../FormatOptions"; | ||
/** | ||
@@ -3,0 +3,0 @@ * Handles comma placement - either before, after or tabulated |
@@ -1,2 +0,2 @@ | ||
import type { FormatOptions } from "../types"; | ||
import type { FormatOptions } from "../FormatOptions"; | ||
import Tokenizer from "../lexer/Tokenizer"; | ||
@@ -3,0 +3,0 @@ /** Main formatter class that produces a final output string from list of tokens */ |
@@ -1,2 +0,2 @@ | ||
import type { IndentStyle } from "../types"; | ||
import type { IndentStyle } from "../FormatOptions"; | ||
import { Token } from "../lexer/token"; | ||
@@ -3,0 +3,0 @@ /** |
export * from './sqlFormatter'; | ||
export type { IndentStyle, KeywordCase, CommaPosition, LogicalOperatorNewline, FormatOptions, } from './types'; | ||
export type { IndentStyle, KeywordCase, CommaPosition, LogicalOperatorNewline, FormatOptions, } from './FormatOptions'; |
@@ -1,2 +0,2 @@ | ||
import type { IdentChars, QuoteType, VariableType } from './regexTypes'; | ||
import type { IdentChars, QuoteType, VariableType } from './TokenizerOptions'; | ||
/** | ||
@@ -3,0 +3,0 @@ * Builds a RegExp for valid line comments in a SQL dialect |
@@ -1,2 +0,2 @@ | ||
import type { PrefixedQuoteType } from './regexTypes'; | ||
import type { PrefixedQuoteType } from './TokenizerOptions'; | ||
export declare const escapeRegExp: (string: string) => string; | ||
@@ -3,0 +3,0 @@ export declare const WHITESPACE_REGEX: RegExp; |
@@ -37,2 +37,4 @@ /** Token type enum for all possible Token categories */ | ||
key?: string; | ||
start: number; | ||
end: number; | ||
} | ||
@@ -43,7 +45,3 @@ /** | ||
*/ | ||
export declare const EOF_TOKEN: { | ||
type: TokenType; | ||
raw: string; | ||
text: string; | ||
}; | ||
export declare const EOF_TOKEN: Token; | ||
/** Checks if two tokens are equivalent */ | ||
@@ -50,0 +48,0 @@ export declare const testToken: (compareToken: { |
import { Token } from "./token"; | ||
import type * as regexTypes from "./regexTypes"; | ||
interface TokenizerOptions { | ||
reservedCommands: string[]; | ||
reservedLogicalOperators?: string[]; | ||
reservedDependentClauses: string[]; | ||
reservedSetOperations: string[]; | ||
reservedJoins: string[]; | ||
reservedPhrases?: string[]; | ||
reservedFunctionNames: string[]; | ||
reservedKeywords: string[]; | ||
stringTypes: regexTypes.QuoteType[]; | ||
identTypes: regexTypes.QuoteType[]; | ||
variableTypes?: regexTypes.VariableType[]; | ||
openParens?: ('(' | '[' | '{' | '{-')[]; | ||
closeParens?: (')' | ']' | '}' | '-}')[]; | ||
positionalParams?: boolean; | ||
numberedParamTypes?: ('?' | ':' | '$')[]; | ||
namedParamTypes?: (':' | '@' | '$')[]; | ||
quotedParamTypes?: (':' | '@' | '$')[]; | ||
lineCommentTypes?: string[]; | ||
identChars?: regexTypes.IdentChars; | ||
paramChars?: regexTypes.IdentChars; | ||
operators?: string[]; | ||
postProcess?: (tokens: Token[]) => Token[]; | ||
} | ||
import { TokenizerOptions } from "./TokenizerOptions"; | ||
export default class Tokenizer { | ||
@@ -34,2 +10,1 @@ private engine; | ||
} | ||
export {}; |
@@ -15,3 +15,3 @@ import BigQueryFormatter from "./languages/bigquery/bigquery.formatter"; | ||
import TSqlFormatter from "./languages/tsql/tsql.formatter"; | ||
import type { FormatOptions } from './types'; | ||
import type { FormatOptions } from './FormatOptions'; | ||
export declare const formatters: { | ||
@@ -18,0 +18,0 @@ bigquery: typeof BigQueryFormatter; |
{ | ||
"name": "sql-formatter", | ||
"version": "9.0.0", | ||
"version": "9.0.1", | ||
"description": "Format whitespace in a SQL query to make it more readable", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
7122
1649935