Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mmews committed Jul 22, 2024
1 parent 60f148c commit 94d82d2
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -866,15 +866,15 @@ private void _validateASTStructure(
String name = model.getIdAsText();
if (name != null) {
if (constraints.isStrict() && (RESERVED_WORDS_IN_STRICT_MODE.contains(name))) {
if (name == IMPORT_KEYWORD
if (IMPORT_KEYWORD.equals(name)
&& model.eContainingFeature() == N4JSPackage.Literals.EXPRESSION_WITH_TARGET__TARGET) {
// allow use of 'import' here
} else {
issueNameDiagnostic(model, producer, name, N4JSPackage.Literals.IDENTIFIER_REF__ID, Severity.ERROR);
}
}
if (model.eContainingFeature() == N4JSPackage.Literals.NAMED_EXPORT_SPECIFIER__EXPORTED_ELEMENT
&& name == N4JSLanguageConstants.EXPORT_DEFAULT_NAME) {
&& N4JSLanguageConstants.EXPORT_DEFAULT_NAME.equals(name)) {
EObject grandParent = model.eContainer().eContainer();
if (grandParent instanceof ExportDeclaration) {
if (((ExportDeclaration) grandParent).getExportedElement() == null
Expand All @@ -901,14 +901,14 @@ private void _validateASTStructure(
Constraints constraints) {
String name = model.getName();
if (name != null) {
if (name == LOCAL_ARGUMENTS_VARIABLE_NAME) {
if (LOCAL_ARGUMENTS_VARIABLE_NAME.equals(name)) {
boolean isFparInN4jsd = constraints.isExternal()// here: isExternal <==> file extension is ".n4jsd"
&& (model instanceof FormalParameter);
if (!isFparInN4jsd) {
issueArgumentsError(model, name, constraints.isStrict(), producer);
}
} else {
if (name != YIELD_KEYWORD && (languageHelper.getECMAKeywords().contains(name)
if (!YIELD_KEYWORD.equals(name) && (languageHelper.getECMAKeywords().contains(name)
|| "enum".equals(name) || "await".equals(name)
|| "true".equals(name) || "false".equals(name) || "null".equals(name))) {

Expand All @@ -918,7 +918,7 @@ private void _validateASTStructure(
issueNameDiagnostic(model, producer, name);
}
} else if (constraints.isStrict()) {
if (RESERVED_WORDS_IN_STRICT_MODE.contains(name) || name == EVAL_NAME) {
if (RESERVED_WORDS_IN_STRICT_MODE.contains(name) || EVAL_NAME.equals(name)) {
issueNameDiagnostic(model, producer, name);
model.setName(name); // do not pollute scope
}
Expand Down Expand Up @@ -1312,10 +1312,10 @@ private void _validateASTStructure(
Constraints constraints) {
String name = model.getName();
if (name != null) {
if (name == LOCAL_ARGUMENTS_VARIABLE_NAME) {
if (LOCAL_ARGUMENTS_VARIABLE_NAME.equals(name)) {
issueArgumentsError(model, name, constraints.isStrict(), producer);
} else if (constraints.isStrict()) {
if (RESERVED_WORDS_IN_STRICT_MODE.contains(name) || name == EVAL_NAME) {
if (RESERVED_WORDS_IN_STRICT_MODE.contains(name) || EVAL_NAME.equals(name)) {
issueNameDiagnostic(model, producer, name);
model.setName(null); // do not pollute scope
}
Expand Down Expand Up @@ -1344,10 +1344,10 @@ private void validateFunctionDefinition(
// TODO improve error message
producer.addDiagnostic(newDiagnosticMessage(IssueCodes.AST_STR_FUN_NOT_NESTED));
} else if (name != null) {
if (name == LOCAL_ARGUMENTS_VARIABLE_NAME) {
if (LOCAL_ARGUMENTS_VARIABLE_NAME.equals(name)) {
issueArgumentsError(model, name, constraints.isStrict(), producer);
} else if (constraints.isStrict()) {
if (RESERVED_WORDS_IN_STRICT_MODE.contains(name) || name == EVAL_NAME) {
if (RESERVED_WORDS_IN_STRICT_MODE.contains(name) || EVAL_NAME.equals(name)) {
issueNameDiagnostic(model, producer, name);
}
}
Expand Down Expand Up @@ -1917,4 +1917,4 @@ private void _validateASTStructure(
private DiagnosticMessage newDiagnosticMessage(IssueCodes issueCode, Object... msgValues) {
return new DiagnosticMessage(issueCode.getMessage(msgValues), issueCode.severity, issueCode.name());
}
}
}

0 comments on commit 94d82d2

Please sign in to comment.