-
Notifications
You must be signed in to change notification settings - Fork 634
add unknown option error for TypeAcquisition #859
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
aeca097
656d81e
1682a4b
4d4a25d
3750c76
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -149,10 +149,18 @@ func parseOwnConfigOfJsonSourceFile( | |
parseDiagnostics = ParseTypeAcquisition(option.Name, value, typeAcquisition) | ||
} | ||
propertySetErrors = append(propertySetErrors, parseDiagnostics...) | ||
iisaduan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} else if keyText != "" { | ||
} else if keyText != "" && extraKeyDiagnostics(parentOption.Name) != nil { | ||
unknownNameDiag := extraKeyDiagnostics(parentOption.Name) | ||
if parentOption.ElementOptions != nil { | ||
// !!! TODO: support suggestion | ||
propertySetErrors = append(propertySetErrors, createDiagnosticForNodeInSourceFileOrCompilerDiagnostic(sourceFile, propertyAssignment.Name(), diagnostics.Unknown_compiler_option_0, keyText)) | ||
propertySetErrors = append(propertySetErrors, createUnknownOptionError( | ||
keyText, | ||
unknownNameDiag, | ||
"", /*unknownOptionErrorText*/ | ||
propertyAssignment.Name(), | ||
sourceFile, | ||
nil, /*alternateMode*/ | ||
)) | ||
} else { | ||
// errors = append(errors, ast.NewCompilerDiagnostic(diagnostics.Unknown_compiler_option_0_Did_you_mean_1, keyText, core.FindKey(parentOption.ElementOptions, keyText))) | ||
} | ||
|
@@ -520,7 +528,7 @@ func convertOptionsFromJson[O optionParser](optionsNameMap map[string]*CommandLi | |
opt, ok := optionsNameMap[key] | ||
if !ok { | ||
// !!! TODO?: support suggestion | ||
errors = append(errors, ast.NewCompilerDiagnostic(diagnostics.Unknown_compiler_option_0, key)) | ||
errors = append(errors, createUnknownOptionError(key, result.UnknownOptionDiagnostic(), "", nil, nil, nil)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. isnt this just There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
continue | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry i meant here shouldnt this be from parser.unknownDiagnostics ? i dont understand why we have two ways of doing same thing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are implemented in two different ways because of how it was implemented in strada, and then the two different code paths that use the messages.
When we are parsing from a
map
to astruct
, we only have anoptionParser
, we don't know what type ofoptionParser
it is, so we can't useextraKeyDiagnostics
directly.When we are parsing the tsconfig, we don't use
optionParser
, so we are not able calloptionsParser.UnknownOptionDiagnostic()
.I could refactor each of the
optionsParser.UnknownOptionDiagnostic()
to be likebut I'm not sure if it's worth the indirection
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about it some more, and ended up doing that refactor