Skip to content

Commit

Permalink
fix imports
Browse files Browse the repository at this point in the history
  • Loading branch information
a-tarasyuk committed Jan 5, 2023
1 parent eb6aaf3 commit 1136d5a
Show file tree
Hide file tree
Showing 5 changed files with 163 additions and 167 deletions.
2 changes: 1 addition & 1 deletion src/compiler/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ import {
tokenIsIdentifierOrKeywordOrGreaterThan,
tokenToString,
} from "./scanner";
import { textToKeywordObj } from "./scannerUtilities";
import { textToKeywordObj } from "./scannerKeywords";
import { tracing } from "./tracing";
import {
AccessorDeclaration,
Expand Down
3 changes: 1 addition & 2 deletions src/compiler/scanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ import {
} from "./core";
import { Debug } from "./debug";
import { Diagnostics } from "./diagnosticInformationMap.generated";
import { textToKeyword, textToToken } from "./scannerKeywords";
import {
parsePseudoBigInt,
positionIsSynthesized,
textToKeyword,
textToToken,
} from "./scannerUtilities";
import {
CharacterCodes,
Expand Down
158 changes: 158 additions & 0 deletions src/compiler/scannerKeywords.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
import { getEntries } from "./core";
import { MapLike } from "./corePublic";
import {
KeywordSyntaxKind,
SyntaxKind,
} from "./types";

export const textToKeywordObj: MapLike<KeywordSyntaxKind> = {
abstract: SyntaxKind.AbstractKeyword,
accessor: SyntaxKind.AccessorKeyword,
any: SyntaxKind.AnyKeyword,
as: SyntaxKind.AsKeyword,
asserts: SyntaxKind.AssertsKeyword,
assert: SyntaxKind.AssertKeyword,
bigint: SyntaxKind.BigIntKeyword,
boolean: SyntaxKind.BooleanKeyword,
break: SyntaxKind.BreakKeyword,
case: SyntaxKind.CaseKeyword,
catch: SyntaxKind.CatchKeyword,
class: SyntaxKind.ClassKeyword,
continue: SyntaxKind.ContinueKeyword,
const: SyntaxKind.ConstKeyword,
["" + "constructor"]: SyntaxKind.ConstructorKeyword,
debugger: SyntaxKind.DebuggerKeyword,
declare: SyntaxKind.DeclareKeyword,
default: SyntaxKind.DefaultKeyword,
delete: SyntaxKind.DeleteKeyword,
do: SyntaxKind.DoKeyword,
else: SyntaxKind.ElseKeyword,
enum: SyntaxKind.EnumKeyword,
export: SyntaxKind.ExportKeyword,
extends: SyntaxKind.ExtendsKeyword,
false: SyntaxKind.FalseKeyword,
finally: SyntaxKind.FinallyKeyword,
for: SyntaxKind.ForKeyword,
from: SyntaxKind.FromKeyword,
function: SyntaxKind.FunctionKeyword,
get: SyntaxKind.GetKeyword,
if: SyntaxKind.IfKeyword,
implements: SyntaxKind.ImplementsKeyword,
import: SyntaxKind.ImportKeyword,
in: SyntaxKind.InKeyword,
infer: SyntaxKind.InferKeyword,
instanceof: SyntaxKind.InstanceOfKeyword,
interface: SyntaxKind.InterfaceKeyword,
intrinsic: SyntaxKind.IntrinsicKeyword,
is: SyntaxKind.IsKeyword,
keyof: SyntaxKind.KeyOfKeyword,
let: SyntaxKind.LetKeyword,
module: SyntaxKind.ModuleKeyword,
namespace: SyntaxKind.NamespaceKeyword,
never: SyntaxKind.NeverKeyword,
new: SyntaxKind.NewKeyword,
null: SyntaxKind.NullKeyword,
number: SyntaxKind.NumberKeyword,
object: SyntaxKind.ObjectKeyword,
package: SyntaxKind.PackageKeyword,
private: SyntaxKind.PrivateKeyword,
protected: SyntaxKind.ProtectedKeyword,
public: SyntaxKind.PublicKeyword,
override: SyntaxKind.OverrideKeyword,
out: SyntaxKind.OutKeyword,
readonly: SyntaxKind.ReadonlyKeyword,
require: SyntaxKind.RequireKeyword,
global: SyntaxKind.GlobalKeyword,
return: SyntaxKind.ReturnKeyword,
satisfies: SyntaxKind.SatisfiesKeyword,
set: SyntaxKind.SetKeyword,
static: SyntaxKind.StaticKeyword,
string: SyntaxKind.StringKeyword,
super: SyntaxKind.SuperKeyword,
switch: SyntaxKind.SwitchKeyword,
symbol: SyntaxKind.SymbolKeyword,
this: SyntaxKind.ThisKeyword,
throw: SyntaxKind.ThrowKeyword,
true: SyntaxKind.TrueKeyword,
try: SyntaxKind.TryKeyword,
type: SyntaxKind.TypeKeyword,
typeof: SyntaxKind.TypeOfKeyword,
undefined: SyntaxKind.UndefinedKeyword,
unique: SyntaxKind.UniqueKeyword,
unknown: SyntaxKind.UnknownKeyword,
var: SyntaxKind.VarKeyword,
void: SyntaxKind.VoidKeyword,
while: SyntaxKind.WhileKeyword,
with: SyntaxKind.WithKeyword,
yield: SyntaxKind.YieldKeyword,
async: SyntaxKind.AsyncKeyword,
await: SyntaxKind.AwaitKeyword,
of: SyntaxKind.OfKeyword,
};

export const textToKeyword = new Map(getEntries(textToKeywordObj));

export const textToToken = new Map(getEntries({
...textToKeywordObj,
"{": SyntaxKind.OpenBraceToken,
"}": SyntaxKind.CloseBraceToken,
"(": SyntaxKind.OpenParenToken,
")": SyntaxKind.CloseParenToken,
"[": SyntaxKind.OpenBracketToken,
"]": SyntaxKind.CloseBracketToken,
".": SyntaxKind.DotToken,
"...": SyntaxKind.DotDotDotToken,
";": SyntaxKind.SemicolonToken,
",": SyntaxKind.CommaToken,
"<": SyntaxKind.LessThanToken,
">": SyntaxKind.GreaterThanToken,
"<=": SyntaxKind.LessThanEqualsToken,
">=": SyntaxKind.GreaterThanEqualsToken,
"==": SyntaxKind.EqualsEqualsToken,
"!=": SyntaxKind.ExclamationEqualsToken,
"===": SyntaxKind.EqualsEqualsEqualsToken,
"!==": SyntaxKind.ExclamationEqualsEqualsToken,
"=>": SyntaxKind.EqualsGreaterThanToken,
"+": SyntaxKind.PlusToken,
"-": SyntaxKind.MinusToken,
"**": SyntaxKind.AsteriskAsteriskToken,
"*": SyntaxKind.AsteriskToken,
"/": SyntaxKind.SlashToken,
"%": SyntaxKind.PercentToken,
"++": SyntaxKind.PlusPlusToken,
"--": SyntaxKind.MinusMinusToken,
"<<": SyntaxKind.LessThanLessThanToken,
"</": SyntaxKind.LessThanSlashToken,
">>": SyntaxKind.GreaterThanGreaterThanToken,
">>>": SyntaxKind.GreaterThanGreaterThanGreaterThanToken,
"&": SyntaxKind.AmpersandToken,
"|": SyntaxKind.BarToken,
"^": SyntaxKind.CaretToken,
"!": SyntaxKind.ExclamationToken,
"~": SyntaxKind.TildeToken,
"&&": SyntaxKind.AmpersandAmpersandToken,
"||": SyntaxKind.BarBarToken,
"?": SyntaxKind.QuestionToken,
"??": SyntaxKind.QuestionQuestionToken,
"?.": SyntaxKind.QuestionDotToken,
":": SyntaxKind.ColonToken,
"=": SyntaxKind.EqualsToken,
"+=": SyntaxKind.PlusEqualsToken,
"-=": SyntaxKind.MinusEqualsToken,
"*=": SyntaxKind.AsteriskEqualsToken,
"**=": SyntaxKind.AsteriskAsteriskEqualsToken,
"/=": SyntaxKind.SlashEqualsToken,
"%=": SyntaxKind.PercentEqualsToken,
"<<=": SyntaxKind.LessThanLessThanEqualsToken,
">>=": SyntaxKind.GreaterThanGreaterThanEqualsToken,
">>>=": SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken,
"&=": SyntaxKind.AmpersandEqualsToken,
"|=": SyntaxKind.BarEqualsToken,
"^=": SyntaxKind.CaretEqualsToken,
"||=": SyntaxKind.BarBarEqualsToken,
"&&=": SyntaxKind.AmpersandAmpersandEqualsToken,
"??=": SyntaxKind.QuestionQuestionEqualsToken,
"@": SyntaxKind.AtToken,
"#": SyntaxKind.HashToken,
"`": SyntaxKind.BacktickToken,
}));
163 changes: 1 addition & 162 deletions src/compiler/scannerUtilities.ts
Original file line number Diff line number Diff line change
@@ -1,165 +1,4 @@
import { getEntries } from "./core";
import { MapLike } from "./corePublic";
import {
CharacterCodes,
KeywordSyntaxKind,
SyntaxKind,
} from "./types";

/** @internal */
export const textToKeywordObj: MapLike<KeywordSyntaxKind> = {
abstract: SyntaxKind.AbstractKeyword,
accessor: SyntaxKind.AccessorKeyword,
any: SyntaxKind.AnyKeyword,
as: SyntaxKind.AsKeyword,
asserts: SyntaxKind.AssertsKeyword,
assert: SyntaxKind.AssertKeyword,
bigint: SyntaxKind.BigIntKeyword,
boolean: SyntaxKind.BooleanKeyword,
break: SyntaxKind.BreakKeyword,
case: SyntaxKind.CaseKeyword,
catch: SyntaxKind.CatchKeyword,
class: SyntaxKind.ClassKeyword,
continue: SyntaxKind.ContinueKeyword,
const: SyntaxKind.ConstKeyword,
["" + "constructor"]: SyntaxKind.ConstructorKeyword,
debugger: SyntaxKind.DebuggerKeyword,
declare: SyntaxKind.DeclareKeyword,
default: SyntaxKind.DefaultKeyword,
delete: SyntaxKind.DeleteKeyword,
do: SyntaxKind.DoKeyword,
else: SyntaxKind.ElseKeyword,
enum: SyntaxKind.EnumKeyword,
export: SyntaxKind.ExportKeyword,
extends: SyntaxKind.ExtendsKeyword,
false: SyntaxKind.FalseKeyword,
finally: SyntaxKind.FinallyKeyword,
for: SyntaxKind.ForKeyword,
from: SyntaxKind.FromKeyword,
function: SyntaxKind.FunctionKeyword,
get: SyntaxKind.GetKeyword,
if: SyntaxKind.IfKeyword,
implements: SyntaxKind.ImplementsKeyword,
import: SyntaxKind.ImportKeyword,
in: SyntaxKind.InKeyword,
infer: SyntaxKind.InferKeyword,
instanceof: SyntaxKind.InstanceOfKeyword,
interface: SyntaxKind.InterfaceKeyword,
intrinsic: SyntaxKind.IntrinsicKeyword,
is: SyntaxKind.IsKeyword,
keyof: SyntaxKind.KeyOfKeyword,
let: SyntaxKind.LetKeyword,
module: SyntaxKind.ModuleKeyword,
namespace: SyntaxKind.NamespaceKeyword,
never: SyntaxKind.NeverKeyword,
new: SyntaxKind.NewKeyword,
null: SyntaxKind.NullKeyword,
number: SyntaxKind.NumberKeyword,
object: SyntaxKind.ObjectKeyword,
package: SyntaxKind.PackageKeyword,
private: SyntaxKind.PrivateKeyword,
protected: SyntaxKind.ProtectedKeyword,
public: SyntaxKind.PublicKeyword,
override: SyntaxKind.OverrideKeyword,
out: SyntaxKind.OutKeyword,
readonly: SyntaxKind.ReadonlyKeyword,
require: SyntaxKind.RequireKeyword,
global: SyntaxKind.GlobalKeyword,
return: SyntaxKind.ReturnKeyword,
satisfies: SyntaxKind.SatisfiesKeyword,
set: SyntaxKind.SetKeyword,
static: SyntaxKind.StaticKeyword,
string: SyntaxKind.StringKeyword,
super: SyntaxKind.SuperKeyword,
switch: SyntaxKind.SwitchKeyword,
symbol: SyntaxKind.SymbolKeyword,
this: SyntaxKind.ThisKeyword,
throw: SyntaxKind.ThrowKeyword,
true: SyntaxKind.TrueKeyword,
try: SyntaxKind.TryKeyword,
type: SyntaxKind.TypeKeyword,
typeof: SyntaxKind.TypeOfKeyword,
undefined: SyntaxKind.UndefinedKeyword,
unique: SyntaxKind.UniqueKeyword,
unknown: SyntaxKind.UnknownKeyword,
var: SyntaxKind.VarKeyword,
void: SyntaxKind.VoidKeyword,
while: SyntaxKind.WhileKeyword,
with: SyntaxKind.WithKeyword,
yield: SyntaxKind.YieldKeyword,
async: SyntaxKind.AsyncKeyword,
await: SyntaxKind.AwaitKeyword,
of: SyntaxKind.OfKeyword,
};

/** @internal */
export const textToKeyword = new Map(getEntries(textToKeywordObj));

/** @internal */
export const textToToken = new Map(getEntries({
...textToKeywordObj,
"{": SyntaxKind.OpenBraceToken,
"}": SyntaxKind.CloseBraceToken,
"(": SyntaxKind.OpenParenToken,
")": SyntaxKind.CloseParenToken,
"[": SyntaxKind.OpenBracketToken,
"]": SyntaxKind.CloseBracketToken,
".": SyntaxKind.DotToken,
"...": SyntaxKind.DotDotDotToken,
";": SyntaxKind.SemicolonToken,
",": SyntaxKind.CommaToken,
"<": SyntaxKind.LessThanToken,
">": SyntaxKind.GreaterThanToken,
"<=": SyntaxKind.LessThanEqualsToken,
">=": SyntaxKind.GreaterThanEqualsToken,
"==": SyntaxKind.EqualsEqualsToken,
"!=": SyntaxKind.ExclamationEqualsToken,
"===": SyntaxKind.EqualsEqualsEqualsToken,
"!==": SyntaxKind.ExclamationEqualsEqualsToken,
"=>": SyntaxKind.EqualsGreaterThanToken,
"+": SyntaxKind.PlusToken,
"-": SyntaxKind.MinusToken,
"**": SyntaxKind.AsteriskAsteriskToken,
"*": SyntaxKind.AsteriskToken,
"/": SyntaxKind.SlashToken,
"%": SyntaxKind.PercentToken,
"++": SyntaxKind.PlusPlusToken,
"--": SyntaxKind.MinusMinusToken,
"<<": SyntaxKind.LessThanLessThanToken,
"</": SyntaxKind.LessThanSlashToken,
">>": SyntaxKind.GreaterThanGreaterThanToken,
">>>": SyntaxKind.GreaterThanGreaterThanGreaterThanToken,
"&": SyntaxKind.AmpersandToken,
"|": SyntaxKind.BarToken,
"^": SyntaxKind.CaretToken,
"!": SyntaxKind.ExclamationToken,
"~": SyntaxKind.TildeToken,
"&&": SyntaxKind.AmpersandAmpersandToken,
"||": SyntaxKind.BarBarToken,
"?": SyntaxKind.QuestionToken,
"??": SyntaxKind.QuestionQuestionToken,
"?.": SyntaxKind.QuestionDotToken,
":": SyntaxKind.ColonToken,
"=": SyntaxKind.EqualsToken,
"+=": SyntaxKind.PlusEqualsToken,
"-=": SyntaxKind.MinusEqualsToken,
"*=": SyntaxKind.AsteriskEqualsToken,
"**=": SyntaxKind.AsteriskAsteriskEqualsToken,
"/=": SyntaxKind.SlashEqualsToken,
"%=": SyntaxKind.PercentEqualsToken,
"<<=": SyntaxKind.LessThanLessThanEqualsToken,
">>=": SyntaxKind.GreaterThanGreaterThanEqualsToken,
">>>=": SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken,
"&=": SyntaxKind.AmpersandEqualsToken,
"|=": SyntaxKind.BarEqualsToken,
"^=": SyntaxKind.CaretEqualsToken,
"||=": SyntaxKind.BarBarEqualsToken,
"&&=": SyntaxKind.AmpersandAmpersandEqualsToken,
"??=": SyntaxKind.QuestionQuestionEqualsToken,
"@": SyntaxKind.AtToken,
"#": SyntaxKind.HashToken,
"`": SyntaxKind.BacktickToken,
}));
import { CharacterCodes } from "./types";

/** @internal */
export function positionIsSynthesized(pos: number): boolean {
Expand Down
4 changes: 2 additions & 2 deletions src/services/codefixes/fixJSDocTypes.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { Diagnostics } from "../../compiler/diagnosticInformationMap.generated";
import { append } from "../../compiler/core";
import {
append,
AsExpression,
CallSignatureDeclaration,
ConstructSignatureDeclaration,
DiagnosticMessage,
FunctionDeclaration,
GetAccessorDeclaration,
IndexSignatureDeclaration,
isJSDocNullableType,
MappedTypeNode,
MethodDeclaration,
MethodSignature,
Expand Down Expand Up @@ -36,6 +35,7 @@ import {
import { ChangeTracker } from "../textChanges";
import { CodeFixAction } from "../types";
import { getTokenAtPosition } from "../utilities";
import { isJSDocNullableType } from "../../compiler/factory/nodeTests";

const fixIdPlain = "fixJSDocTypes_plain";
const fixIdNullable = "fixJSDocTypes_nullable";
Expand Down

0 comments on commit 1136d5a

Please sign in to comment.