entry, MutableClassDeclaration annotatedClass,
- AnnotationReference nlsAnnotation, extension TransformationContext context) {
- val value = entry.value as String
- val parts = value.split(";;;")
- if (parts.length != 2) {
- nlsAnnotation.addError(
- "Value for " + entry.key + " in properties file doesn't follow pattern 'defaultSeverity;;;message'")
- return
- }
- val defaultSeverity = parts.get(0)
- if (!SEVERITIES.contains(defaultSeverity)) {
- nlsAnnotation.addError(
- defaultSeverity + " is not a valid severity (which would be " + SEVERITIES.join(", ") + ").")
- return
- }
- val message = parts.get(1)
- val wildcardCount = message.getWildcardCount
- val params = if (wildcardCount > 0) (0 .. wildcardCount - 1).map["param" + it] else newArrayList
- val getMessageForMethodName = "getMessageFor" + entry.key
- checkForExistentMethod(annotatedClass, getMessageForMethodName, context, nlsAnnotation, params.size)
- annotatedClass.addMethod(getMessageForMethodName) [
- visibility = Visibility.PUBLIC
- static = true
- returnType = context.string
- params.forEach(param|addParameter(param, object))
- docComment = message
- body = '''return «nlsClass».bind(getString(«entry.key»), new Object [] { «params.join(", ")» });'''
- ]
- }
-
-
-
-}
diff --git a/plugins/org.eclipse.n4js.utils/src/org/eclipse/n4js/utils/Strings.java b/plugins/org.eclipse.n4js.utils/src/org/eclipse/n4js/utils/Strings.java
index 582d3b658b..8a7dc0aeee 100644
--- a/plugins/org.eclipse.n4js.utils/src/org/eclipse/n4js/utils/Strings.java
+++ b/plugins/org.eclipse.n4js.utils/src/org/eclipse/n4js/utils/Strings.java
@@ -288,4 +288,21 @@ public static String stripAllTrailing(String str) {
}
return Strings.join("\n", (Object[]) lines);
}
+
+ public static int count(String str, String pattern) {
+ if (str == null || str.isEmpty()) {
+ return 0;
+ }
+
+ int count = 0;
+ int idx = 0;
+ idx = str.indexOf(pattern, idx);
+ while (idx > 0) {
+ idx++;
+ count++;
+ idx = str.indexOf(pattern, idx);
+ }
+
+ return count;
+ }
}
diff --git a/plugins/org.eclipse.n4js.utils/src/org/eclipse/n4js/utils/XtextUtilN4.xtend b/plugins/org.eclipse.n4js.utils/src/org/eclipse/n4js/utils/XtextUtilN4.xtend
deleted file mode 100644
index c005138279..0000000000
--- a/plugins/org.eclipse.n4js.utils/src/org/eclipse/n4js/utils/XtextUtilN4.xtend
+++ /dev/null
@@ -1,73 +0,0 @@
-/**
- * Copyright (c) 2017 NumberFour AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * NumberFour AG - Initial API and implementation
- */
-package org.eclipse.n4js.utils
-
-import com.google.inject.Inject
-import com.google.inject.Singleton
-import java.util.List
-import org.eclipse.emf.ecore.EClass
-import org.eclipse.emf.ecore.EObject
-import org.eclipse.emf.ecore.resource.Resource
-import org.eclipse.xtext.resource.IContainer
-import org.eclipse.xtext.resource.IEObjectDescription
-import org.eclipse.xtext.resource.IResourceDescription
-import org.eclipse.xtext.resource.impl.ResourceDescriptionsProvider
-
-/**
- * This class contains helper methods for working with Xtext.
- */
- @Singleton
-class XtextUtilN4 {
- @Inject IContainer.Manager containerManager;
- @Inject ResourceDescriptionsProvider resourceDescriptionsProvider;
- @Inject IResourceDescription.Manager descriptionManager;
-
- /**
- * Return all EObjectDescriptions in the index that are visible from an EObject.
- * @param o
- * the EObject
- *
- * See Lorenzo's book page 260.
- */
- def Iterable getVisibleEObjectDescriptions(EObject o) {
- o.visibleContainers.map [ container | container.exportedObjects ].flatten;
- }
-
- /**
- * Return all EObjectDescriptions of a certain type in the index that are visible from an EObject.
- * @param o
- * the EObject.
- * @param type
- * the type of EObjectDescriptions to filter.
- *
- * See Lorenzo's book page 260.
- */
- def Iterable getVisibleEObjectDescriptions(EObject o, EClass type) {
- o.visibleContainers.map [ container | container.getExportedObjectsByType(type) ].flatten;
- }
-
- /**
- * Return all visible containers from within a given resource.
- * @param resource
- * the resource
- */
- def List getVisibleContainers(Resource resource) {
- val index = resourceDescriptionsProvider.getResourceDescriptions(resource.getResourceSet());
- val resourceDescription = descriptionManager.getResourceDescription(resource);
- return containerManager.getVisibleContainers(resourceDescription, index);
- }
-
- def private List getVisibleContainers(EObject o) {
- val index = resourceDescriptionsProvider.getResourceDescriptions((o.eResource));
- val resourceDescription = index.getResourceDescription(o.eResource.URI)
- containerManager.getVisibleContainers(resourceDescription, index);
- }
-}
diff --git a/plugins/org.eclipse.n4js.utils/xtend-gen/.gitignore b/plugins/org.eclipse.n4js.utils/xtend-gen/.gitignore
deleted file mode 100644
index c96a04f008..0000000000
--- a/plugins/org.eclipse.n4js.utils/xtend-gen/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-*
-!.gitignore
\ No newline at end of file
diff --git a/plugins/org.eclipse.n4js/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.n4js/.settings/org.eclipse.jdt.core.prefs
index f22022d1bb..f8f455c60f 100644
--- a/plugins/org.eclipse.n4js/.settings/org.eclipse.jdt.core.prefs
+++ b/plugins/org.eclipse.n4js/.settings/org.eclipse.jdt.core.prefs
@@ -1,4 +1,5 @@
eclipse.preferences.version=1
+org.eclipse.jdt.core.builder.annotationPath.allLocations=disabled
org.eclipse.jdt.core.builder.cleanOutputFolder=clean
org.eclipse.jdt.core.builder.duplicateResourceTask=warning
org.eclipse.jdt.core.builder.invalidClasspath=abort
@@ -21,8 +22,11 @@ org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes=
org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=enabled
org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
org.eclipse.jdt.core.compiler.annotation.nonnull=javax.annotation.Nonnull
+org.eclipse.jdt.core.compiler.annotation.nonnull.secondary=
org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=javax.annotation.ParametersAreNonnullByDefault
+org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary=
org.eclipse.jdt.core.compiler.annotation.nullable=javax.annotation.Nullable
+org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
@@ -34,6 +38,8 @@ org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.doc.comment.support=enabled
org.eclipse.jdt.core.compiler.maxProblemPerUnit=100
+org.eclipse.jdt.core.compiler.problem.APILeak=warning
+org.eclipse.jdt.core.compiler.problem.annotatedTypeArgumentToUnannotated=info
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
@@ -84,12 +90,14 @@ org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning
+org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning
org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=warning
org.eclipse.jdt.core.compiler.problem.nullReference=error
org.eclipse.jdt.core.compiler.problem.nullSpecViolation=warning
org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning
org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.pessimisticNullAnalysisForFreeTypeVariables=warning
org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=warning
@@ -104,21 +112,28 @@ org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=enabled
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.suppressWarningsNotFullyAnalysed=info
org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=enabled
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
+org.eclipse.jdt.core.compiler.problem.terminalDeprecation=warning
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentType=warning
+org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentTypeStrict=disabled
+org.eclipse.jdt.core.compiler.problem.unlikelyEqualsArgumentType=warning
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unstableAutoModuleName=warning
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedImport=warning
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/N4JSLanguageConstants.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/N4JSLanguageConstants.java
index 69f0140585..7551825239 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/N4JSLanguageConstants.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/N4JSLanguageConstants.java
@@ -61,9 +61,9 @@ public abstract class N4JSLanguageConstants {
* or {@code SuppressIssuesSetup} to configure Xpect tests for issue suppression.
*/
public static final Set DEFAULT_SUPPRESSED_ISSUE_CODES_FOR_TESTS = unmodifiableSet(newHashSet(
- IssueCodes.CFG_LOCAL_VAR_UNUSED,
- IssueCodes.DFG_NULL_DEREFERENCE,
- JSONIssueCodes.JSON_COMMENT_UNSUPPORTED
+ IssueCodes.CFG_LOCAL_VAR_UNUSED.name(),
+ IssueCodes.DFG_NULL_DEREFERENCE.name(),
+ JSONIssueCodes.JSON_COMMENT_UNSUPPORTED.name()
));
//@formatter:on
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/PropertyNameAwareElementFactory.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/PropertyNameAwareElementFactory.java
index c63f86fa34..2d79d4b3ed 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/PropertyNameAwareElementFactory.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/PropertyNameAwareElementFactory.java
@@ -89,7 +89,7 @@ public void set(EObject object, String feature, Object value, String ruleName, I
} catch (ValueConverterException e) {
throw e;
} catch (NullPointerException e) {
- throw new N4JSValueConverterException(IssueCodes.getMessageForVCO_NPE(), IssueCodes.VCO_NPE, node, e);
+ throw new N4JSValueConverterException(IssueCodes.VCO_NPE.getMessage(), IssueCodes.VCO_NPE.name(), node, e);
} catch (Exception e) {
throw new ValueConverterException(null, node, e);
}
@@ -142,7 +142,8 @@ private Object getTokenValue(Object tokenOrValue, String ruleName, INode node) t
private void checkNullForPrimitiveFeatures(EStructuralFeature structuralFeature, Object tokenValue, INode node) {
if (tokenValue == null && structuralFeature.getEType().getInstanceClass().isPrimitive()) {
throw new N4JSValueConverterException(
- IssueCodes.getMessageForVCO_NULL_FEATURE(structuralFeature.getName()), IssueCodes.VCO_NULL_FEATURE,
+ IssueCodes.VCO_NULL_FEATURE.getMessage(structuralFeature.getName()),
+ IssueCodes.VCO_NULL_FEATURE.name(),
node, null);
}
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/AbstractN4JSStringValueConverter.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/AbstractN4JSStringValueConverter.java
index 2d76c2beab..4bc8ad5f84 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/AbstractN4JSStringValueConverter.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/AbstractN4JSStringValueConverter.java
@@ -79,11 +79,11 @@ public static String convertFromN4JSString(String n4jsString, INode node, boolea
null);
if (validate) {
if (result.hasError()) {
- throw new BadEscapementException(IssueCodes.getMessageForVCO_STRING_BAD_ESCAPE_ERROR(),
- IssueCodes.VCO_STRING_BAD_ESCAPE_ERROR, node, result.getValue(), true);
+ throw new BadEscapementException(IssueCodes.VCO_STRING_BAD_ESCAPE_ERROR.getMessage(),
+ IssueCodes.VCO_STRING_BAD_ESCAPE_ERROR.name(), node, result.getValue(), true);
} else if (result.hasWarning()) {
- throw new BadEscapementException(IssueCodes.getMessageForVCO_STRING_BAD_ESCAPE_WARN(),
- IssueCodes.VCO_STRING_BAD_ESCAPE_WARN, node, result.getValue(), false);
+ throw new BadEscapementException(IssueCodes.VCO_STRING_BAD_ESCAPE_WARN.getMessage(),
+ IssueCodes.VCO_STRING_BAD_ESCAPE_WARN.name(), node, result.getValue(), false);
}
}
return result.getValue();
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/BinaryIntValueConverter.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/BinaryIntValueConverter.java
index 41e2bc6455..dc7f57a6f1 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/BinaryIntValueConverter.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/BinaryIntValueConverter.java
@@ -13,12 +13,11 @@
import java.math.BigDecimal;
import java.math.BigInteger;
+import org.eclipse.n4js.validation.IssueCodes;
import org.eclipse.xtext.conversion.impl.AbstractLexerBasedConverter;
import org.eclipse.xtext.nodemodel.INode;
import org.eclipse.xtext.util.Strings;
-import org.eclipse.n4js.validation.IssueCodes;
-
/**
* A value converter that properly converts hexadecimal JS numbers to {@link BigDecimal}.
*/
@@ -33,26 +32,26 @@ protected String toEscapedString(BigDecimal value) {
protected void assertValidValue(BigDecimal value) {
super.assertValidValue(value);
if (value.signum() == -1)
- throw new N4JSValueConverterException(IssueCodes.getMessageForVCO_BINARYINT_NEGATIVE(getRuleName(), value),
- IssueCodes.VCO_BINARYINT_NEGATIVE, null, null);
+ throw new N4JSValueConverterException(IssueCodes.VCO_BINARYINT_NEGATIVE.getMessage(getRuleName(), value),
+ IssueCodes.VCO_BINARYINT_NEGATIVE.name(), null, null);
}
@Override
public BigDecimal toValue(String string, INode node) {
if (Strings.isEmpty(string))
- throw new N4JSValueConverterException(IssueCodes.getMessageForVCO_BINARYINT_CONVERT_EMPTY_STR(),
- IssueCodes.VCO_BINARYINT_CONVERT_EMPTY_STR, node, null);
+ throw new N4JSValueConverterException(IssueCodes.VCO_BINARYINT_CONVERT_EMPTY_STR.getMessage(),
+ IssueCodes.VCO_BINARYINT_CONVERT_EMPTY_STR.name(), node, null);
if (string.length() <= 2) {
throw new N4JSValueConverterWithValueException(
- IssueCodes.getMessageForVCO_BINARYINT_CONVERT_TOO_SHORT(string),
- IssueCodes.VCO_BINARYINT_CONVERT_TOO_SHORT, node,
+ IssueCodes.VCO_BINARYINT_CONVERT_TOO_SHORT.getMessage(string),
+ IssueCodes.VCO_BINARYINT_CONVERT_TOO_SHORT.name(), node,
BigDecimal.ZERO, null);
}
try {
return new BigDecimal(new BigInteger(string.substring(2), 2));
} catch (NumberFormatException e) {
- throw new N4JSValueConverterException(IssueCodes.getMessageForVCO_HEXINT_CONVERT_STR(string),
- IssueCodes.VCO_HEXINT_CONVERT_STR, node, null);
+ throw new N4JSValueConverterException(IssueCodes.VCO_HEXINT_CONVERT_STR.getMessage(string),
+ IssueCodes.VCO_HEXINT_CONVERT_STR.name(), node, null);
}
}
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/DoubleValueConverter.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/DoubleValueConverter.java
index ac3c38b82a..c528b5b581 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/DoubleValueConverter.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/DoubleValueConverter.java
@@ -12,12 +12,11 @@
import java.math.BigDecimal;
+import org.eclipse.n4js.validation.IssueCodes;
import org.eclipse.xtext.conversion.impl.AbstractLexerBasedConverter;
import org.eclipse.xtext.nodemodel.INode;
import org.eclipse.xtext.util.Strings;
-import org.eclipse.n4js.validation.IssueCodes;
-
/**
* A value converter that properly converts floating point JS numbers to {@link BigDecimal}.
*/
@@ -32,20 +31,20 @@ protected String toEscapedString(BigDecimal value) {
protected void assertValidValue(BigDecimal value) {
super.assertValidValue(value);
if (value.signum() == -1)
- throw new N4JSValueConverterException(IssueCodes.getMessageForVCO_DOUBLE_NEGATIVE(getRuleName(), value),
- IssueCodes.VCO_DOUBLE_NEGATIVE, null, null);
+ throw new N4JSValueConverterException(IssueCodes.VCO_DOUBLE_NEGATIVE.getMessage(getRuleName(), value),
+ IssueCodes.VCO_DOUBLE_NEGATIVE.name(), null, null);
}
@Override
public BigDecimal toValue(String string, INode node) {
if (Strings.isEmpty(string))
- throw new N4JSValueConverterException(IssueCodes.getMessageForVCO_DOUBLE_CONVERT_EMPTY_STR(),
- IssueCodes.VCO_DOUBLE_CONVERT_EMPTY_STR, node, null);
+ throw new N4JSValueConverterException(IssueCodes.VCO_DOUBLE_CONVERT_EMPTY_STR.getMessage(),
+ IssueCodes.VCO_DOUBLE_CONVERT_EMPTY_STR.name(), node, null);
try {
return new BigDecimal(string);
} catch (NumberFormatException e) {
- throw new N4JSValueConverterException(IssueCodes.getMessageForVCO_DOUBLE_CONVERT_STR(string),
- IssueCodes.VCO_DOUBLE_CONVERT_STR, node, null);
+ throw new N4JSValueConverterException(IssueCodes.VCO_DOUBLE_CONVERT_STR.getMessage(string),
+ IssueCodes.VCO_DOUBLE_CONVERT_STR.name(), node, null);
}
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/HexIntValueConverter.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/HexIntValueConverter.java
index 1da5ec4a5d..ff77c492cf 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/HexIntValueConverter.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/HexIntValueConverter.java
@@ -13,12 +13,11 @@
import java.math.BigDecimal;
import java.math.BigInteger;
+import org.eclipse.n4js.validation.IssueCodes;
import org.eclipse.xtext.conversion.impl.AbstractLexerBasedConverter;
import org.eclipse.xtext.nodemodel.INode;
import org.eclipse.xtext.util.Strings;
-import org.eclipse.n4js.validation.IssueCodes;
-
/**
* A value converter that properly converts hexadecimal JS numbers to {@link BigDecimal}.
*/
@@ -33,26 +32,26 @@ protected String toEscapedString(BigDecimal value) {
protected void assertValidValue(BigDecimal value) {
super.assertValidValue(value);
if (value.signum() == -1)
- throw new N4JSValueConverterException(IssueCodes.getMessageForVCO_HEXINT_NEGATIVE(getRuleName(), value),
- IssueCodes.VCO_HEXINT_NEGATIVE, null, null);
+ throw new N4JSValueConverterException(IssueCodes.VCO_HEXINT_NEGATIVE.getMessage(getRuleName(), value),
+ IssueCodes.VCO_HEXINT_NEGATIVE.name(), null, null);
}
@Override
public BigDecimal toValue(String string, INode node) {
if (Strings.isEmpty(string))
- throw new N4JSValueConverterException(IssueCodes.getMessageForVCO_HEXINT_CONVERT_EMPTY_STR(),
- IssueCodes.VCO_HEXINT_CONVERT_EMPTY_STR, node, null);
+ throw new N4JSValueConverterException(IssueCodes.VCO_HEXINT_CONVERT_EMPTY_STR.getMessage(),
+ IssueCodes.VCO_HEXINT_CONVERT_EMPTY_STR.name(), node, null);
if (string.length() <= 2) {
throw new N4JSValueConverterWithValueException(
- IssueCodes.getMessageForVCO_HEXINT_CONVERT_TOO_SHORT(string),
- IssueCodes.VCO_HEXINT_CONVERT_TOO_SHORT, node,
+ IssueCodes.VCO_HEXINT_CONVERT_TOO_SHORT.getMessage(string),
+ IssueCodes.VCO_HEXINT_CONVERT_TOO_SHORT.name(), node,
BigDecimal.ZERO, null);
}
try {
return new BigDecimal(new BigInteger(string.substring(2), 16));
} catch (NumberFormatException e) {
- throw new N4JSValueConverterException(IssueCodes.getMessageForVCO_HEXINT_CONVERT_STR(string),
- IssueCodes.VCO_HEXINT_CONVERT_STR, node, null);
+ throw new N4JSValueConverterException(IssueCodes.VCO_HEXINT_CONVERT_STR.getMessage(string),
+ IssueCodes.VCO_HEXINT_CONVERT_STR.name(), node, null);
}
}
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/IdentifierValueConverter.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/IdentifierValueConverter.java
index 38460212f6..9727971157 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/IdentifierValueConverter.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/IdentifierValueConverter.java
@@ -63,21 +63,21 @@ public static String convertFromN4JSIdentifier(String jsString, INode node) {
validityChecker);
if (result.hasError()) {
throw new N4JSValueConverterWithValueException(
- IssueCodes.getMessageForVCO_IDENT_ESCAPE_SEQ(jsString, result.getErrorOffset()),
- IssueCodes.VCO_IDENT_ESCAPE_SEQ,
+ IssueCodes.VCO_IDENT_ESCAPE_SEQ.getMessage(jsString, result.getErrorOffset()),
+ IssueCodes.VCO_IDENT_ESCAPE_SEQ.name(),
node, result.getValue(), null);
}
if (result.hasInvalidChar()) {
if (result.getValue().length() != 0)
throw new N4JSValueConverterWithValueException(
- IssueCodes.getMessageForVCO_IDENT_ILLEGAL_CHAR_WITH_RESULT(result.getValue(), jsString,
+ IssueCodes.VCO_IDENT_ILLEGAL_CHAR_WITH_RESULT.getMessage(result.getValue(), jsString,
result.getInvalidCharOffset()),
- IssueCodes.VCO_IDENT_ILLEGAL_CHAR_WITH_RESULT,
+ IssueCodes.VCO_IDENT_ILLEGAL_CHAR_WITH_RESULT.name(),
node, result.getValue(), null);
else
- throw new N4JSValueConverterException(IssueCodes.getMessageForVCO_IDENT_ILLEGAL_CHAR(
+ throw new N4JSValueConverterException(IssueCodes.VCO_IDENT_ILLEGAL_CHAR.getMessage(
jsString, result.getInvalidCharOffset()),
- IssueCodes.VCO_IDENT_ILLEGAL_CHAR,
+ IssueCodes.VCO_IDENT_ILLEGAL_CHAR.name(),
node, null);
}
return result.getValue();
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/JSXIdentifierValueConverter.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/JSXIdentifierValueConverter.java
index 8f09fddd0a..527bf9aa16 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/JSXIdentifierValueConverter.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/JSXIdentifierValueConverter.java
@@ -48,8 +48,8 @@ public String toValue(String string, INode node) throws ValueConverterException
int idx = disallowedChar.indexIn(string);
if (idx != -1) {
throw new N4JSValueConverterWithValueException(
- IssueCodes.getMessageForVCO_IDENT_ILLEGAL_CHAR_WITH_RESULT(string, string.charAt(idx), idx),
- IssueCodes.VCO_IDENT_ILLEGAL_CHAR_WITH_RESULT, node, string.substring(0, idx), null);
+ IssueCodes.VCO_IDENT_ILLEGAL_CHAR_WITH_RESULT.getMessage(string, string.charAt(idx), idx),
+ IssueCodes.VCO_IDENT_ILLEGAL_CHAR_WITH_RESULT.name(), node, string.substring(0, idx), null);
}
}
return string;
@@ -63,16 +63,16 @@ private void validate(String value, int firstOffset, ILeafNode leaf) {
if (leaf.isHidden()) {
int idx = leaf.getTotalOffset() - firstOffset;
throw new N4JSValueConverterWithValueException(
- IssueCodes.getMessageForVCO_JSXIDENT_WHITESPACE_COMMENT(),
- IssueCodes.VCO_JSXIDENT_WHITESPACE_COMMENT, leaf, value.substring(0, idx), null);
+ IssueCodes.VCO_JSXIDENT_WHITESPACE_COMMENT.getMessage(),
+ IssueCodes.VCO_JSXIDENT_WHITESPACE_COMMENT.name(), leaf, value.substring(0, idx), null);
} else {
int escapeSequence = leaf.getText().indexOf("\\");
if (escapeSequence >= 0) {
int idx = leaf.getTotalOffset() - firstOffset + escapeSequence;
throw new N4JSValueConverterWithValueException(
- IssueCodes.getMessageForVCO_IDENT_ILLEGAL_CHAR_WITH_RESULT(value,
+ IssueCodes.VCO_IDENT_ILLEGAL_CHAR_WITH_RESULT.getMessage(value,
leaf.getText().charAt(escapeSequence), idx),
- IssueCodes.VCO_IDENT_ILLEGAL_CHAR_WITH_RESULT, leaf, value.substring(0, idx), null);
+ IssueCodes.VCO_IDENT_ILLEGAL_CHAR_WITH_RESULT.name(), leaf, value.substring(0, idx), null);
}
}
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/LegacyOctalIntValueConverter.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/LegacyOctalIntValueConverter.java
index 32dbb7ad60..19d894b05d 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/LegacyOctalIntValueConverter.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/LegacyOctalIntValueConverter.java
@@ -13,12 +13,11 @@
import java.math.BigDecimal;
import java.math.BigInteger;
+import org.eclipse.n4js.validation.IssueCodes;
import org.eclipse.xtext.conversion.impl.AbstractLexerBasedConverter;
import org.eclipse.xtext.nodemodel.INode;
import org.eclipse.xtext.util.Strings;
-import org.eclipse.n4js.validation.IssueCodes;
-
/**
* A value converter that properly converts octal JS numbers to {@link BigDecimal}.
*/
@@ -54,19 +53,19 @@ protected String toEscapedString(BigDecimal value) {
protected void assertValidValue(BigDecimal value) {
super.assertValidValue(value);
if (value.signum() == -1)
- throw new N4JSValueConverterException(IssueCodes.getMessageForVCO_OCTALINT_NEGATIVE(getRuleName(), value),
- IssueCodes.VCO_OCTALINT_NEGATIVE, null, null);
+ throw new N4JSValueConverterException(IssueCodes.VCO_OCTALINT_NEGATIVE.getMessage(getRuleName(), value),
+ IssueCodes.VCO_OCTALINT_NEGATIVE.name(), null, null);
}
@Override
public BigDecimal toValue(String string, INode node) {
if (Strings.isEmpty(string))
- throw new N4JSValueConverterException(IssueCodes.getMessageForVCO_OCTALINT_CONVERT_EMPTY_STR(),
- IssueCodes.VCO_OCTALINT_CONVERT_EMPTY_STR, node, null);
+ throw new N4JSValueConverterException(IssueCodes.VCO_OCTALINT_CONVERT_EMPTY_STR.getMessage(),
+ IssueCodes.VCO_OCTALINT_CONVERT_EMPTY_STR.name(), node, null);
if (string.length() <= 1) {
throw new N4JSValueConverterWithValueException(
- IssueCodes.getMessageForVCO_OCTALINT_CONVERT_TOO_SHORT(string),
- IssueCodes.VCO_OCTALINT_CONVERT_TOO_SHORT, node,
+ IssueCodes.VCO_OCTALINT_CONVERT_TOO_SHORT.getMessage(string),
+ IssueCodes.VCO_OCTALINT_CONVERT_TOO_SHORT.name(), node,
BigDecimal.ZERO, null);
}
try {
@@ -74,11 +73,11 @@ public BigDecimal toValue(String string, INode node) {
} catch (NumberFormatException e) {
try {
BigDecimal result = new BigDecimal(new BigInteger(string, 10));
- throw new LeadingZerosException(IssueCodes.getMessageForVCO_OCTALINT_LEADING_ZEROS(string),
- IssueCodes.VCO_OCTALINT_LEADING_ZEROS, node, result);
+ throw new LeadingZerosException(IssueCodes.VCO_OCTALINT_LEADING_ZEROS.getMessage(string),
+ IssueCodes.VCO_OCTALINT_LEADING_ZEROS.name(), node, result);
} catch (NumberFormatException again) {
- throw new N4JSValueConverterException(IssueCodes.getMessageForVCO_OCTALINT_CONVERT_STR(string),
- IssueCodes.VCO_OCTALINT_CONVERT_STR, node, null);
+ throw new N4JSValueConverterException(IssueCodes.VCO_OCTALINT_CONVERT_STR.getMessage(string),
+ IssueCodes.VCO_OCTALINT_CONVERT_STR.name(), node, null);
}
}
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/N4JSStringValueConverter.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/N4JSStringValueConverter.java
index 3771a790bf..b721443ae4 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/N4JSStringValueConverter.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/N4JSStringValueConverter.java
@@ -63,10 +63,10 @@ public String toValue(String string, INode node) {
*/
protected N4JSValueConverterWithValueException newN4JSValueConverterException(char c, INode node, String value) {
if (c == '"')
- return new N4JSValueConverterWithValueException(IssueCodes.getMessageForVCO_STRING_DOUBLE_QUOTE(),
- IssueCodes.VCO_STRING_DOUBLE_QUOTE, node, value, null);
+ return new N4JSValueConverterWithValueException(IssueCodes.VCO_STRING_DOUBLE_QUOTE.getMessage(),
+ IssueCodes.VCO_STRING_DOUBLE_QUOTE.name(), node, value, null);
else
- return new N4JSValueConverterWithValueException(IssueCodes.getMessageForVCO_STRING_QUOTE(),
- IssueCodes.VCO_STRING_QUOTE, node, value, null);
+ return new N4JSValueConverterWithValueException(IssueCodes.VCO_STRING_QUOTE.getMessage(),
+ IssueCodes.VCO_STRING_QUOTE.name(), node, value, null);
}
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/N4JSValueConverterException.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/N4JSValueConverterException.java
index b32930c2f8..8ed69bc91a 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/N4JSValueConverterException.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/N4JSValueConverterException.java
@@ -10,14 +10,13 @@
*/
package org.eclipse.n4js.parser.conversion;
+import org.eclipse.n4js.validation.IssueCodes;
import org.eclipse.xtext.conversion.ValueConverterException;
import org.eclipse.xtext.diagnostics.Severity;
import org.eclipse.xtext.nodemodel.INode;
-import org.eclipse.n4js.validation.IssueCodes;
-
/**
- * Extende value converter exception to hold issue code and message later to use by Xtext diagnostic producer.
+ * Extends value converter exception to hold issue code and message later to use by Xtext diagnostic producer.
*/
public class N4JSValueConverterException extends ValueConverterException {
private final String issueCode;
@@ -37,7 +36,7 @@ public N4JSValueConverterException(final String message, final String issueCode,
final Exception cause) {
super(message, node, cause);
this.issueCode = issueCode;
- this.severity = IssueCodes.getDefaultSeverity(issueCode);
+ this.severity = IssueCodes.getSeverityForName(issueCode);
}
/**
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/N4JSValueConverterWithValueException.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/N4JSValueConverterWithValueException.java
index 11593a9201..d1221ff79a 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/N4JSValueConverterWithValueException.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/N4JSValueConverterWithValueException.java
@@ -10,14 +10,13 @@
*/
package org.eclipse.n4js.parser.conversion;
+import org.eclipse.n4js.validation.IssueCodes;
import org.eclipse.xtext.conversion.ValueConverterWithValueException;
import org.eclipse.xtext.diagnostics.Severity;
import org.eclipse.xtext.nodemodel.INode;
-import org.eclipse.n4js.validation.IssueCodes;
-
/**
- * Extende value converter with value exception to hold issue code and message later to use by Xtext diagnostic
+ * Extends value converter with value exception to hold issue code and message later to use by Xtext diagnostic
* producer.
*/
public class N4JSValueConverterWithValueException extends ValueConverterWithValueException {
@@ -43,7 +42,7 @@ public N4JSValueConverterWithValueException(final String message, final String i
super(message, node, value, cause);
this.hasRange = false;
this.issueCode = issueCode;
- this.severity = IssueCodes.getDefaultSeverity(issueCode);
+ this.severity = IssueCodes.getSeverityForName(issueCode);
}
/**
@@ -69,7 +68,7 @@ public N4JSValueConverterWithValueException(final String message, final String i
super(message, node, value, offset, length, cause);
this.hasRange = true;
this.issueCode = issueCode;
- this.severity = IssueCodes.getDefaultSeverity(issueCode);
+ this.severity = IssueCodes.getSeverityForName(issueCode);
}
@Override
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/NoSubstitutionTemplateSegmentValueConverter.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/NoSubstitutionTemplateSegmentValueConverter.java
index 751b315139..7b20ca8537 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/NoSubstitutionTemplateSegmentValueConverter.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/NoSubstitutionTemplateSegmentValueConverter.java
@@ -10,9 +10,8 @@
*/
package org.eclipse.n4js.parser.conversion;
-import org.eclipse.xtext.nodemodel.INode;
-
import org.eclipse.n4js.validation.IssueCodes;
+import org.eclipse.xtext.nodemodel.INode;
/**
*/
@@ -33,8 +32,8 @@ protected String getLeftDelimiter() {
*/
@Override
protected N4JSValueConverterWithValueException newN4JSValueConverterException(INode node, String value) {
- return new N4JSValueConverterWithValueException(IssueCodes.getMessageForVCO_TEMPLATE_QUOTE(),
- IssueCodes.VCO_TEMPLATE_QUOTE, node, value, null);
+ return new N4JSValueConverterWithValueException(IssueCodes.VCO_TEMPLATE_QUOTE.getMessage(),
+ IssueCodes.VCO_TEMPLATE_QUOTE.name(), node, value, null);
}
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/OctalIntValueConverter.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/OctalIntValueConverter.java
index 55582a179e..9b835daede 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/OctalIntValueConverter.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/OctalIntValueConverter.java
@@ -13,12 +13,11 @@
import java.math.BigDecimal;
import java.math.BigInteger;
+import org.eclipse.n4js.validation.IssueCodes;
import org.eclipse.xtext.conversion.impl.AbstractLexerBasedConverter;
import org.eclipse.xtext.nodemodel.INode;
import org.eclipse.xtext.util.Strings;
-import org.eclipse.n4js.validation.IssueCodes;
-
/**
* A value converter that properly converts hexadecimal JS numbers to {@link BigDecimal}.
*/
@@ -33,26 +32,26 @@ protected String toEscapedString(BigDecimal value) {
protected void assertValidValue(BigDecimal value) {
super.assertValidValue(value);
if (value.signum() == -1)
- throw new N4JSValueConverterException(IssueCodes.getMessageForVCO_HEXINT_NEGATIVE(getRuleName(), value),
- IssueCodes.VCO_OCTALINT_NEGATIVE, null, null);
+ throw new N4JSValueConverterException(IssueCodes.VCO_HEXINT_NEGATIVE.getMessage(getRuleName(), value),
+ IssueCodes.VCO_OCTALINT_NEGATIVE.name(), null, null);
}
@Override
public BigDecimal toValue(String string, INode node) {
if (Strings.isEmpty(string))
- throw new N4JSValueConverterException(IssueCodes.getMessageForVCO_OCTALINT_CONVERT_EMPTY_STR(),
- IssueCodes.VCO_OCTALINT_CONVERT_EMPTY_STR, node, null);
+ throw new N4JSValueConverterException(IssueCodes.VCO_OCTALINT_CONVERT_EMPTY_STR.getMessage(),
+ IssueCodes.VCO_OCTALINT_CONVERT_EMPTY_STR.name(), node, null);
if (string.length() <= 2) {
throw new N4JSValueConverterWithValueException(
- IssueCodes.getMessageForVCO_OCTALINT_CONVERT_TOO_SHORT(string),
- IssueCodes.VCO_OCTALINT_CONVERT_TOO_SHORT, node,
+ IssueCodes.VCO_OCTALINT_CONVERT_TOO_SHORT.getMessage(string),
+ IssueCodes.VCO_OCTALINT_CONVERT_TOO_SHORT.name(), node,
BigDecimal.ZERO, null);
}
try {
return new BigDecimal(new BigInteger(string.substring(2), 8));
} catch (NumberFormatException e) {
- throw new N4JSValueConverterException(IssueCodes.getMessageForVCO_OCTALINT_CONVERT_STR(string),
- IssueCodes.VCO_OCTALINT_CONVERT_STR, node, null);
+ throw new N4JSValueConverterException(IssueCodes.VCO_OCTALINT_CONVERT_STR.getMessage(string),
+ IssueCodes.VCO_OCTALINT_CONVERT_STR.name(), node, null);
}
}
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/RegExLiteralConverter.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/RegExLiteralConverter.java
index 9ee809ea7d..9581b8bc4c 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/RegExLiteralConverter.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/RegExLiteralConverter.java
@@ -112,8 +112,8 @@ public String toValue(String string, INode node) {
offsetFixup = node.getOffset() - node.getTotalOffset();
}
N4JSValueConverterWithValueException mainError = new N4JSValueConverterWithValueException(
- IssueCodes.getMessageForVCO_REGEX_INVALID(),
- IssueCodes.VCO_REGEX_INVALID, node,
+ IssueCodes.VCO_REGEX_INVALID.getMessage(),
+ IssueCodes.VCO_REGEX_INVALID.name(), node,
stringConverterResult.getSourceOffset(localOffset) + offsetFixup,
syntaxError.getLength(), string,
null);
@@ -139,8 +139,8 @@ public String toValue(String string, INode node) {
if (offsetFixup == -1) {
offsetFixup = node.getOffset() - node.getTotalOffset();
}
- errors.add(new N4JSValueConverterWithValueException(IssueCodes.getMessageForVCO_REGEX_INVALID(),
- IssueCodes.VCO_REGEX_INVALID, node,
+ errors.add(new N4JSValueConverterWithValueException(IssueCodes.VCO_REGEX_INVALID.getMessage(),
+ IssueCodes.VCO_REGEX_INVALID.name(), node,
stringConverterResult.getSourceOffset(nodeForElement.getOffset()) + offsetFixup,
nodeForElement.getLength(),
string, null));
@@ -152,8 +152,8 @@ public String toValue(String string, INode node) {
if (offsetFixup == -1) {
offsetFixup = node.getOffset() - node.getTotalOffset();
}
- errors.add(new N4JSValueConverterWithValueException(IssueCodes.getMessageForVCO_REGEX_INVALID(),
- IssueCodes.VCO_REGEX_INVALID, node,
+ errors.add(new N4JSValueConverterWithValueException(IssueCodes.VCO_REGEX_INVALID.getMessage(),
+ IssueCodes.VCO_REGEX_INVALID.name(), node,
stringConverterResult.getSourceOffset(featureNode.getOffset()) + offsetFixup,
featureNode.getLength(),
string, null));
@@ -165,8 +165,8 @@ public String toValue(String string, INode node) {
if (offsetFixup == -1) {
offsetFixup = node.getOffset() - node.getTotalOffset();
}
- errors.add(new N4JSValueConverterWithValueException(IssueCodes.getMessageForVCO_REGEX_INVALID(),
- IssueCodes.VCO_REGEX_INVALID, node,
+ errors.add(new N4JSValueConverterWithValueException(IssueCodes.VCO_REGEX_INVALID.getMessage(),
+ IssueCodes.VCO_REGEX_INVALID.name(), node,
stringConverterResult.getSourceOffset(nodeForElement.getOffset()) + offsetFixup,
nodeForElement.getLength(), string, null));
}
@@ -175,8 +175,8 @@ public String toValue(String string, INode node) {
if (offsetFixup == -1) {
offsetFixup = node.getOffset() - node.getTotalOffset();
}
- errors.add(new N4JSValueConverterWithValueException(IssueCodes.getMessageForVCO_REGEX_INVALID(),
- IssueCodes.VCO_REGEX_INVALID, node,
+ errors.add(new N4JSValueConverterWithValueException(IssueCodes.VCO_REGEX_INVALID.getMessage(),
+ IssueCodes.VCO_REGEX_INVALID.name(), node,
stringConverterResult.getSourceOffset(nodeForElement.getOffset()) + offsetFixup,
nodeForElement.getLength(), string, null));
}
@@ -191,8 +191,8 @@ public String toValue(String string, INode node) {
if (offsetFixup == -1) {
offsetFixup = node.getOffset() - node.getTotalOffset();
}
- errors.add(new N4JSValueConverterWithValueException(IssueCodes.getMessageForVCO_REGEX_NAMED_GROUP(),
- IssueCodes.VCO_REGEX_NAMED_GROUP, node,
+ errors.add(new N4JSValueConverterWithValueException(IssueCodes.VCO_REGEX_NAMED_GROUP.getMessage(),
+ IssueCodes.VCO_REGEX_NAMED_GROUP.name(), node,
stringConverterResult.getSourceOffset(nameNode.getOffset()) + offsetFixup,
nameNode.getLength(),
string, null));
@@ -214,8 +214,8 @@ private static StringConverterResult convertFromJS(String jsString, INode node)
if (result.hasError()) {
int offsetFixup = node.getOffset() - node.getTotalOffset();
throw new N4JSValueConverterWithValueException(
- IssueCodes.getMessageForVCO_REGEX_ILLEGAL_ESCAPE(jsString),
- IssueCodes.VCO_REGEX_ILLEGAL_ESCAPE, node, result.getErrorOffset() + offsetFixup, 1,
+ IssueCodes.VCO_REGEX_ILLEGAL_ESCAPE.getMessage(jsString),
+ IssueCodes.VCO_REGEX_ILLEGAL_ESCAPE.name(), node, result.getErrorOffset() + offsetFixup, 1,
result.getValue(), null);
}
return result;
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/ScientificIntValueConverter.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/ScientificIntValueConverter.java
index f3a14d3654..a99c959bcd 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/ScientificIntValueConverter.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/ScientificIntValueConverter.java
@@ -12,12 +12,11 @@
import java.math.BigDecimal;
+import org.eclipse.n4js.validation.IssueCodes;
import org.eclipse.xtext.conversion.impl.AbstractLexerBasedConverter;
import org.eclipse.xtext.nodemodel.INode;
import org.eclipse.xtext.util.Strings;
-import org.eclipse.n4js.validation.IssueCodes;
-
/**
* A value converter that properly converts JS numbers in scientific notation to {@link BigDecimal}.
*/
@@ -32,20 +31,20 @@ protected String toEscapedString(BigDecimal value) {
protected void assertValidValue(BigDecimal value) {
super.assertValidValue(value);
if (value.signum() == -1)
- throw new N4JSValueConverterException(IssueCodes.getMessageForVCO_SCIINT_NEGATIVE(getRuleName(), value),
- IssueCodes.VCO_SCIINT_NEGATIVE, null, null);
+ throw new N4JSValueConverterException(IssueCodes.VCO_SCIINT_NEGATIVE.getMessage(getRuleName(), value),
+ IssueCodes.VCO_SCIINT_NEGATIVE.name(), null, null);
}
@Override
public BigDecimal toValue(String string, INode node) {
if (Strings.isEmpty(string))
- throw new N4JSValueConverterException(IssueCodes.getMessageForVCO_SCIINT_CONVERT_EMPTY_STR(),
- IssueCodes.VCO_SCIINT_CONVERT_EMPTY_STR, node, null);
+ throw new N4JSValueConverterException(IssueCodes.VCO_SCIINT_CONVERT_EMPTY_STR.getMessage(),
+ IssueCodes.VCO_SCIINT_CONVERT_EMPTY_STR.name(), node, null);
try {
return new BigDecimal(string);
} catch (NumberFormatException e) {
- throw new N4JSValueConverterException(IssueCodes.getMessageForVCO_SCIINT_CONVERT_STR(string),
- IssueCodes.VCO_SCIINT_CONVERT_STR, node, null);
+ throw new N4JSValueConverterException(IssueCodes.VCO_SCIINT_CONVERT_STR.getMessage(string),
+ IssueCodes.VCO_SCIINT_CONVERT_STR.name(), node, null);
}
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/TemplateEndValueConverter.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/TemplateEndValueConverter.java
index 1a5098adfc..7a8aafeba8 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/TemplateEndValueConverter.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/TemplateEndValueConverter.java
@@ -10,12 +10,11 @@
*/
package org.eclipse.n4js.parser.conversion;
+import org.eclipse.n4js.validation.IssueCodes;
import org.eclipse.xtext.AbstractRule;
import org.eclipse.xtext.RuleCall;
import org.eclipse.xtext.nodemodel.INode;
-import org.eclipse.n4js.validation.IssueCodes;
-
/**
*/
public class TemplateEndValueConverter extends AbstractTemplateSegmentValueConverter {
@@ -40,8 +39,9 @@ public String toValue(String string, INode node) {
@Override
protected N4JSValueConverterWithValueException newN4JSValueConverterException(INode node, String value) {
- return new N4JSValueConverterWithValueException(IssueCodes.getMessageForVCO_TEMPLATE_QUOTE(),
- IssueCodes.VCO_TEMPLATE_QUOTE, node, -1 /* offset relative to node */, value.length() + 1, value, null);
+ return new N4JSValueConverterWithValueException(IssueCodes.VCO_TEMPLATE_QUOTE.getMessage(),
+ IssueCodes.VCO_TEMPLATE_QUOTE.name(), node, -1 /* offset relative to node */, value.length() + 1, value,
+ null);
}
@Override
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/TemplateHeadValueConverter.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/TemplateHeadValueConverter.java
index 679514f6de..182c0b0209 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/TemplateHeadValueConverter.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/TemplateHeadValueConverter.java
@@ -10,9 +10,8 @@
*/
package org.eclipse.n4js.parser.conversion;
-import org.eclipse.xtext.nodemodel.INode;
-
import org.eclipse.n4js.validation.IssueCodes;
+import org.eclipse.xtext.nodemodel.INode;
/**
*/
@@ -30,8 +29,8 @@ protected String getLeftDelimiter() {
@Override
protected N4JSValueConverterWithValueException newN4JSValueConverterException(INode node, String value) {
- return new N4JSValueConverterWithValueException(IssueCodes.getMessageForVCO_TEMPLATE_QUOTE(),
- IssueCodes.VCO_TEMPLATE_MIDDLE, node, value, null);
+ return new N4JSValueConverterWithValueException(IssueCodes.VCO_TEMPLATE_QUOTE.getMessage(),
+ IssueCodes.VCO_TEMPLATE_MIDDLE.name(), node, value, null);
}
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/TemplateMiddleValueConverter.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/TemplateMiddleValueConverter.java
index 8a067a633c..380cb4b824 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/TemplateMiddleValueConverter.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/parser/conversion/TemplateMiddleValueConverter.java
@@ -10,12 +10,11 @@
*/
package org.eclipse.n4js.parser.conversion;
+import org.eclipse.n4js.validation.IssueCodes;
import org.eclipse.xtext.AbstractRule;
import org.eclipse.xtext.RuleCall;
import org.eclipse.xtext.nodemodel.INode;
-import org.eclipse.n4js.validation.IssueCodes;
-
/**
*/
public class TemplateMiddleValueConverter extends AbstractTemplateSegmentValueConverter {
@@ -32,8 +31,8 @@ protected String getLeftDelimiter() {
@Override
protected N4JSValueConverterWithValueException newN4JSValueConverterException(INode node, String value) {
- return new N4JSValueConverterWithValueException(IssueCodes.getMessageForVCO_TEMPLATE_QUOTE(),
- IssueCodes.VCO_TEMPLATE_MIDDLE, node, value, null);
+ return new N4JSValueConverterWithValueException(IssueCodes.VCO_TEMPLATE_QUOTE.getMessage(),
+ IssueCodes.VCO_TEMPLATE_MIDDLE.name(), node, value, null);
}
@Override
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/resource/N4JSResource.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/resource/N4JSResource.java
index eae9d11a3b..33cca2ff63 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/resource/N4JSResource.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/resource/N4JSResource.java
@@ -1548,7 +1548,7 @@ protected void addSyntaxErrors() {
for (INode error : getParseResult().getSyntaxErrors()) {
processSyntaxDiagnostic(error, diagnostic -> {
String code = diagnostic.getCode();
- Severity severity = IssueCodes.getDefaultSeverity(code);
+ Severity severity = IssueCodes.getSeverityForName(code);
if (AbstractN4JSStringValueConverter.WARN_ISSUE_CODE.equals(code)
|| RegExLiteralConverter.ISSUE_CODE.equals(code)
|| LegacyOctalIntValueConverter.ISSUE_CODE.equals(code)
@@ -1630,9 +1630,10 @@ private boolean isRangeBased(SyntaxErrorMessage syntaxErrorMessage) {
String issueCode = syntaxErrorMessage.getIssueCode();
return SYNTAX_DIAGNOSTIC_WITH_RANGE.equals(issueCode)
|| RegExLiteralConverter.ISSUE_CODE.equals(issueCode)
- || IssueCodes.VCO_REGEX_NAMED_GROUP.equals(issueCode)
- || IssueCodes.VCO_REGEX_ILLEGAL_ESCAPE.equals(issueCode)
- || (IssueCodes.VCO_TEMPLATE_QUOTE.equals(issueCode) && syntaxErrorMessage.getIssueData() != null);
+ || IssueCodes.VCO_REGEX_NAMED_GROUP.name().equals(issueCode)
+ || IssueCodes.VCO_REGEX_ILLEGAL_ESCAPE.name().equals(issueCode)
+ || (IssueCodes.VCO_TEMPLATE_QUOTE.name().equals(issueCode)
+ && syntaxErrorMessage.getIssueData() != null);
}
// FIXME the following method should no longer be required once TypingASTWalker is fully functional
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/accessModifiers/ContextAwareTypeScope.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/accessModifiers/ContextAwareTypeScope.java
index 38023f72f5..7ae956be3b 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/accessModifiers/ContextAwareTypeScope.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/accessModifiers/ContextAwareTypeScope.java
@@ -86,13 +86,13 @@ protected IEObjectDescriptionWithError wrapFilteredDescription(IEObjectDescripti
}
if (!isValidLocationForVoid && eClass == TypesPackage.Literals.VOID_TYPE) {
return new DisallowedTypeDescription(originalDescr,
- IssueCodes.getMessageForTYS_VOID_AT_WRONG_LOCATION(),
- IssueCodes.TYS_VOID_AT_WRONG_LOCATION);
+ IssueCodes.TYS_VOID_AT_WRONG_LOCATION.getMessage(),
+ IssueCodes.TYS_VOID_AT_WRONG_LOCATION.name());
}
if (!isValidLocationForFunctionType && TypesPackage.Literals.TFUNCTION.isSuperTypeOf(eClass)) {
return new DisallowedTypeDescription(originalDescr,
- IssueCodes.getMessageForTYS_FUNCTION_DISALLOWED_AS_TYPE(),
- IssueCodes.TYS_FUNCTION_DISALLOWED_AS_TYPE);
+ IssueCodes.TYS_FUNCTION_DISALLOWED_AS_TYPE.getMessage(),
+ IssueCodes.TYS_FUNCTION_DISALLOWED_AS_TYPE.name());
}
return null; // should never happen, because #isAccepted() has returned true
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/accessModifiers/HollowTypeOrValueDescription.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/accessModifiers/HollowTypeOrValueDescription.java
index e83624b583..7126e79c16 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/accessModifiers/HollowTypeOrValueDescription.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/accessModifiers/HollowTypeOrValueDescription.java
@@ -34,12 +34,12 @@ public HollowTypeOrValueDescription(IEObjectDescription delegate, String expecta
@Override
public String getMessage() {
String name = getName().getLastSegment();
- return IssueCodes.getMessageForAST_ELEMENT_MISUSED_AS_VALUE_OR_TYPE(name, expectation);
+ return IssueCodes.AST_ELEMENT_MISUSED_AS_VALUE_OR_TYPE.getMessage(name, expectation);
}
@Override
public String getIssueCode() {
- return IssueCodes.AST_ELEMENT_MISUSED_AS_VALUE_OR_TYPE;
+ return IssueCodes.AST_ELEMENT_MISUSED_AS_VALUE_OR_TYPE.name();
}
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/accessModifiers/InvalidStaticWriteAccessDescription.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/accessModifiers/InvalidStaticWriteAccessDescription.java
index 4b0bae15a2..9cd8da605a 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/accessModifiers/InvalidStaticWriteAccessDescription.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/accessModifiers/InvalidStaticWriteAccessDescription.java
@@ -10,11 +10,10 @@
*/
package org.eclipse.n4js.scoping.accessModifiers;
-import org.eclipse.xtext.naming.QualifiedName;
-import org.eclipse.xtext.resource.IEObjectDescription;
-
import org.eclipse.n4js.scoping.utils.AbstractDescriptionWithError;
import org.eclipse.n4js.validation.IssueCodes;
+import org.eclipse.xtext.naming.QualifiedName;
+import org.eclipse.xtext.resource.IEObjectDescription;
/**
* Description marking invalid write access to static member via subtype or other expression.
@@ -46,16 +45,15 @@ public String getMessage() {
QualifiedName qualifiedName = getName();
String memberName = qualifiedName.getLastSegment();
return aliasOfMemberDefiningType == null
- ? IssueCodes.getMessageForVIS_ILLEGAL_STATIC_MEMBER_WRITE_ACCESS(memberDefTypeName, memberName)
- : IssueCodes.getMessageForVIS_ILLEGAL_STATIC_MEMBER_WRITE_ACCESS_WITH_ALIAS(memberDefTypeName,
- memberName,
- aliasOfMemberDefiningType);
+ ? IssueCodes.VIS_ILLEGAL_STATIC_MEMBER_WRITE_ACCESS.getMessage(memberDefTypeName, memberName)
+ : IssueCodes.VIS_ILLEGAL_STATIC_MEMBER_WRITE_ACCESS_WITH_ALIAS.getMessage(memberDefTypeName,
+ memberName, aliasOfMemberDefiningType);
}
@Override
public String getIssueCode() {
- return aliasOfMemberDefiningType == null ? IssueCodes.VIS_ILLEGAL_STATIC_MEMBER_WRITE_ACCESS
- : IssueCodes.VIS_ILLEGAL_STATIC_MEMBER_WRITE_ACCESS_WITH_ALIAS;
+ return aliasOfMemberDefiningType == null ? IssueCodes.VIS_ILLEGAL_STATIC_MEMBER_WRITE_ACCESS.name()
+ : IssueCodes.VIS_ILLEGAL_STATIC_MEMBER_WRITE_ACCESS_WITH_ALIAS.name();
}
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/accessModifiers/InvisibleMemberDescription.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/accessModifiers/InvisibleMemberDescription.java
index 0b0860fe88..2d2d655ba9 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/accessModifiers/InvisibleMemberDescription.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/accessModifiers/InvisibleMemberDescription.java
@@ -51,12 +51,12 @@ public String getMessage() {
// here, because error message refers not to the member available in the type but to the missing member accessed
// by the source code.
String memberName = getName().getLastSegment();
- return IssueCodes.getMessageForVIS_ILLEGAL_MEMBER_ACCESS(memberTypeName, memberName);
+ return IssueCodes.VIS_ILLEGAL_MEMBER_ACCESS.getMessage(memberTypeName, memberName);
}
@Override
public String getIssueCode() {
- return IssueCodes.VIS_ILLEGAL_MEMBER_ACCESS;
+ return IssueCodes.VIS_ILLEGAL_MEMBER_ACCESS.name();
}
@Override
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/accessModifiers/InvisibleTypeOrVariableDescription.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/accessModifiers/InvisibleTypeOrVariableDescription.java
index d972196266..055aab1561 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/accessModifiers/InvisibleTypeOrVariableDescription.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/accessModifiers/InvisibleTypeOrVariableDescription.java
@@ -11,14 +11,13 @@
package org.eclipse.n4js.scoping.accessModifiers;
import org.eclipse.emf.ecore.EObject;
-import org.eclipse.xtext.resource.IEObjectDescription;
-
import org.eclipse.n4js.scoping.utils.AbstractDescriptionWithError;
import org.eclipse.n4js.ts.types.TFunction;
import org.eclipse.n4js.ts.types.Type;
import org.eclipse.n4js.validation.IssueCodes;
import org.eclipse.n4js.validation.IssueUserDataKeys.VIS_ILLEGAL_TYPE_ACCESS;
import org.eclipse.n4js.validation.IssueUserDataKeys.VIS_ILLEGAL_VARIABLE_ACCESS;
+import org.eclipse.xtext.resource.IEObjectDescription;
/**
* This description wraps an invisible type or variable.
@@ -63,22 +62,22 @@ public String getMessage() {
EObject objectOrProxy = getEObjectOrProxy();
String name = getName().getLastSegment();
if (objectOrProxy instanceof TFunction) {
- return IssueCodes.getMessageForVIS_ILLEGAL_FUN_ACCESS(name);
+ return IssueCodes.VIS_ILLEGAL_FUN_ACCESS.getMessage(name);
} else if (objectOrProxy instanceof Type) {
- return IssueCodes.getMessageForVIS_ILLEGAL_TYPE_ACCESS(name);
+ return IssueCodes.VIS_ILLEGAL_TYPE_ACCESS.getMessage(name);
}
- return IssueCodes.getMessageForVIS_ILLEGAL_VARIABLE_ACCESS(name);
+ return IssueCodes.VIS_ILLEGAL_VARIABLE_ACCESS.getMessage(name);
}
@Override
public String getIssueCode() {
EObject objectOrProxy = getEObjectOrProxy();
if (objectOrProxy instanceof TFunction) {
- return IssueCodes.VIS_ILLEGAL_FUN_ACCESS;
+ return IssueCodes.VIS_ILLEGAL_FUN_ACCESS.name();
} else if (objectOrProxy instanceof Type) {
- return IssueCodes.VIS_ILLEGAL_TYPE_ACCESS;
+ return IssueCodes.VIS_ILLEGAL_TYPE_ACCESS.name();
}
- return IssueCodes.VIS_ILLEGAL_VARIABLE_ACCESS;
+ return IssueCodes.VIS_ILLEGAL_VARIABLE_ACCESS.name();
}
/*
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/accessModifiers/NonExportedElementDescription.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/accessModifiers/NonExportedElementDescription.java
index f7e0d468da..a5ea132301 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/accessModifiers/NonExportedElementDescription.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/accessModifiers/NonExportedElementDescription.java
@@ -32,12 +32,12 @@ public NonExportedElementDescription(IEObjectDescription delegate) {
@Override
public String getMessage() {
String name = getName().getLastSegment();
- return IssueCodes.getMessageForIMP_NOT_EXPORTED(name);
+ return IssueCodes.IMP_NOT_EXPORTED.getMessage(name);
}
@Override
public String getIssueCode() {
- return IssueCodes.IMP_NOT_EXPORTED;
+ return IssueCodes.IMP_NOT_EXPORTED.name();
}
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/diagnosing/N4JSScopingConsumableMethodsDiagnosis.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/diagnosing/N4JSScopingConsumableMethodsDiagnosis.java
index 200f19015b..d85f38ca0a 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/diagnosing/N4JSScopingConsumableMethodsDiagnosis.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/diagnosing/N4JSScopingConsumableMethodsDiagnosis.java
@@ -57,8 +57,8 @@ DiagnosticMessage diagnose(QualifiedName name, ParameterizedPropertyAccessExpres
.anyMatch(m -> m.getName().equals(name.toString()));
if (hasMethod) {
- return createMessage(IssueCodes.CLF_CANNOT_REFER_TO_DEFAULT_METHOD_WITH_SUPER,
- IssueCodes.getMessageForCLF_CANNOT_REFER_TO_DEFAULT_METHOD_WITH_SUPER());
+ return createMessage(IssueCodes.CLF_CANNOT_REFER_TO_DEFAULT_METHOD_WITH_SUPER.name(),
+ IssueCodes.CLF_CANNOT_REFER_TO_DEFAULT_METHOD_WITH_SUPER.getMessage());
}
}
return null;
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/diagnosing/N4JSScopingInstanceOfPrimitivTypeDiagnosis.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/diagnosing/N4JSScopingInstanceOfPrimitivTypeDiagnosis.java
index 05d0865af5..9a68581a64 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/diagnosing/N4JSScopingInstanceOfPrimitivTypeDiagnosis.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/diagnosing/N4JSScopingInstanceOfPrimitivTypeDiagnosis.java
@@ -59,8 +59,8 @@ DiagnosticMessage diagnose(QualifiedName name, RelationalExpression expression)
// if we can find a primitive type for the qualified name
if (singleElement.getEClass().getClassifierID() == TypesPackage.Literals.PRIMITIVE_TYPE.getClassifierID()) {
// create special error message
- return createMessage(IssueCodes.TYS_INSTANCEOF_NOT_SUPPORTED_FOR_PRIMITIVE_TYPES,
- IssueCodes.getMessageForTYS_INSTANCEOF_NOT_SUPPORTED_FOR_PRIMITIVE_TYPES());
+ return createMessage(IssueCodes.TYS_INSTANCEOF_NOT_SUPPORTED_FOR_PRIMITIVE_TYPES.name(),
+ IssueCodes.TYS_INSTANCEOF_NOT_SUPPORTED_FOR_PRIMITIVE_TYPES.getMessage());
} else {
// the found element is not a primitive type, diagnosis not applicable
return null;
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/diagnosing/ScopingDiagnosis.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/diagnosing/ScopingDiagnosis.java
index 8d65fe116c..7a0e7fb731 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/diagnosing/ScopingDiagnosis.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/diagnosing/ScopingDiagnosis.java
@@ -36,7 +36,7 @@ public abstract class ScopingDiagnosis {
* See {@link IssueCodes} for valid issue codes.
*/
protected DiagnosticMessage createMessage(String issueCode, String message) {
- return new DiagnosticMessage(message, IssueCodes.getDefaultSeverity(issueCode), issueCode);
+ return new DiagnosticMessage(message, IssueCodes.getSeverityForName(issueCode), issueCode);
}
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/imports/AmbiguousImportDescription.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/imports/AmbiguousImportDescription.java
index dcc2e5ee69..bfa9301648 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/imports/AmbiguousImportDescription.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/imports/AmbiguousImportDescription.java
@@ -84,12 +84,12 @@ public String getMessage() {
typeListStr.append(((TNamespace) container).getName());
}
}
- if (this.issueCode == IssueCodes.IMP_AMBIGUOUS_WILDCARD) {
- return IssueCodes.getMessageForIMP_AMBIGUOUS_WILDCARD(typeIdent, getName(), typeListStr.toString());
- } else if (this.issueCode == IssueCodes.IMP_AMBIGUOUS) {
- return IssueCodes.getMessageForIMP_AMBIGUOUS(typeIdent, getName(), typeListStr.toString());
- } else if (this.issueCode == IssueCodes.IMP_DUPLICATE_NAMESPACE) {
- return IssueCodes.getMessageForIMP_DUPLICATE_NAMESPACE("stub", getName(), "stub");
+ if (this.issueCode == IssueCodes.IMP_AMBIGUOUS_WILDCARD.name()) {
+ return IssueCodes.IMP_AMBIGUOUS_WILDCARD.getMessage(typeIdent, getName(), typeListStr.toString());
+ } else if (this.issueCode == IssueCodes.IMP_AMBIGUOUS.name()) {
+ return IssueCodes.IMP_AMBIGUOUS.getMessage(typeIdent, getName(), typeListStr.toString());
+ } else if (this.issueCode == IssueCodes.IMP_DUPLICATE_NAMESPACE.name()) {
+ return IssueCodes.IMP_DUPLICATE_NAMESPACE.getMessage("stub", getName(), "stub");
}
return "Unknown ambiguous import issue: " + this.issueCode + " for " + context + ".";
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/imports/ImportedElementsScopingHelper.xtend b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/imports/ImportedElementsScopingHelper.xtend
index 1dcad98348..9f40a9b446 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/imports/ImportedElementsScopingHelper.xtend
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/imports/ImportedElementsScopingHelper.xtend
@@ -235,7 +235,7 @@ class ImportedElementsScopingHelper {
private def void addNamedImports(NamedImportSpecifier specifier, TExportableElement element, QualifiedName importedName,
IEODesc2ISpec originatorMap, ImportedElementsMap validImports) {
- val ieod = validImports.putOrError(element, importedName, IssueCodes.IMP_AMBIGUOUS);
+ val ieod = validImports.putOrError(element, importedName, IssueCodes.IMP_AMBIGUOUS.name);
originatorMap.putWithOrigin(ieod, specifier)
}
@@ -284,7 +284,7 @@ class ImportedElementsScopingHelper {
LOGGER.error("namespaceType not found\n" + sb.toString);
return;
}
- val ieodx = validImports.putOrError(namespaceType, namespaceQName, IssueCodes.IMP_AMBIGUOUS)
+ val ieodx = validImports.putOrError(namespaceType, namespaceQName, IssueCodes.IMP_AMBIGUOUS.name)
originatorMap.putWithOrigin(ieodx, specifier)
if (includeValueOnlyElements) {
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/imports/PlainAccessOfAliasedImportDescription.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/imports/PlainAccessOfAliasedImportDescription.java
index 4ccf6c1978..d3b58dfb8c 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/imports/PlainAccessOfAliasedImportDescription.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/imports/PlainAccessOfAliasedImportDescription.java
@@ -39,12 +39,12 @@ public String getAlias() {
@Override
public String getMessage() {
- return IssueCodes.getMessageForIMP_PLAIN_ACCESS_OF_ALIASED_TYPE(getName(), alias);
+ return IssueCodes.IMP_PLAIN_ACCESS_OF_ALIASED_TYPE.getMessage(getName(), alias);
}
@Override
public String getIssueCode() {
- return IssueCodes.IMP_PLAIN_ACCESS_OF_ALIASED_TYPE;
+ return IssueCodes.IMP_PLAIN_ACCESS_OF_ALIASED_TYPE.name();
}
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/imports/PlainAccessOfNamespacedImportDescription.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/imports/PlainAccessOfNamespacedImportDescription.java
index fd6685c959..593ba633b8 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/imports/PlainAccessOfNamespacedImportDescription.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/imports/PlainAccessOfNamespacedImportDescription.java
@@ -33,12 +33,12 @@ public PlainAccessOfNamespacedImportDescription(IEObjectDescription delegate, Qu
@Override
public String getMessage() {
- return IssueCodes.getMessageForIMP_PLAIN_ACCESS_OF_NAMESPACED_TYPE(getName(), namespacedName);
+ return IssueCodes.IMP_PLAIN_ACCESS_OF_NAMESPACED_TYPE.getMessage(getName(), namespacedName);
}
@Override
public String getIssueCode() {
- return IssueCodes.IMP_PLAIN_ACCESS_OF_NAMESPACED_TYPE;
+ return IssueCodes.IMP_PLAIN_ACCESS_OF_NAMESPACED_TYPE.name();
}
/**
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/members/ComposedMemberDescriptionWithError.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/members/ComposedMemberDescriptionWithError.java
index 7ae62e6a41..a8f4253812 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/members/ComposedMemberDescriptionWithError.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/members/ComposedMemberDescriptionWithError.java
@@ -197,7 +197,7 @@ protected boolean initSubMessages(IEObjectDescription[] descriptions, MapOfIndex
if (submessage.endsWith(".")) {
submessage = submessage.substring(0, submessage.length() - 1);
}
- completeSubMessage = IssueCodes.getMessageForCOMP_SUBMESSAGES(allScopeNames, submessage);
+ completeSubMessage = IssueCodes.COMP_SUBMESSAGES.getMessage(allScopeNames, submessage);
}
if (strb.length() > 0) {
strb.append(" ");
@@ -205,7 +205,7 @@ protected boolean initSubMessages(IEObjectDescription[] descriptions, MapOfIndex
strb.append(completeSubMessage);
}
message = strb.toString();
- code = IssueCodes.COMP_SUBMESSAGES;
+ code = IssueCodes.COMP_SUBMESSAGES.name();
return true;
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/members/IntersectionMemberDescriptionWithError.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/members/IntersectionMemberDescriptionWithError.java
index cfeacfd91a..65075917b1 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/members/IntersectionMemberDescriptionWithError.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/members/IntersectionMemberDescriptionWithError.java
@@ -12,13 +12,12 @@
import java.util.List;
+import org.eclipse.n4js.ts.typeRefs.ComposedTypeRef;
+import org.eclipse.n4js.validation.IssueCodes;
import org.eclipse.xtext.naming.QualifiedName;
import org.eclipse.xtext.resource.IEObjectDescription;
import org.eclipse.xtext.scoping.IScope;
-import org.eclipse.n4js.ts.typeRefs.ComposedTypeRef;
-import org.eclipse.n4js.validation.IssueCodes;
-
/**
* This description wraps a member of a union type that is not present in all contained types or is somehow incompatible
* so that it cannot be composed into a single valid composed member.
@@ -58,8 +57,8 @@ private boolean initMemberTypeConflict(MapOfIndexes indexesPerMemberType
strb.append(memberTypeName + " in " + foundScopes);
}
final String memberName = getName().getLastSegment();
- message = IssueCodes.getMessageForINTER_MEMBER_TYPE_CONFLICT(memberName, strb);
- code = IssueCodes.INTER_MEMBER_TYPE_CONFLICT;
+ message = IssueCodes.INTER_MEMBER_TYPE_CONFLICT.getMessage(memberName, strb);
+ code = IssueCodes.INTER_MEMBER_TYPE_CONFLICT.name();
return true;
}
return false;
@@ -67,8 +66,8 @@ private boolean initMemberTypeConflict(MapOfIndexes indexesPerMemberType
private boolean initDefault() {
final String memberName = getName().getLastSegment();
- message = IssueCodes.getMessageForINTER_UNCOMMON(memberName);
- code = IssueCodes.INTER_UNCOMMON;
+ message = IssueCodes.INTER_UNCOMMON.getMessage(memberName);
+ code = IssueCodes.INTER_UNCOMMON.name();
return true;
}
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/members/PolyfillMemberConflictDescription.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/members/PolyfillMemberConflictDescription.java
index 1c48bd9bc2..4561852d2b 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/members/PolyfillMemberConflictDescription.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/members/PolyfillMemberConflictDescription.java
@@ -12,13 +12,12 @@
import java.util.Collection;
+import org.eclipse.n4js.scoping.utils.AbstractDescriptionWithError;
+import org.eclipse.n4js.validation.IssueCodes;
import org.eclipse.xtext.resource.IEObjectDescription;
import com.google.common.base.Joiner;
-import org.eclipse.n4js.scoping.utils.AbstractDescriptionWithError;
-import org.eclipse.n4js.validation.IssueCodes;
-
/**
* Creates a description for error code {@link IssueCodes#CLF_POLYFILL_MULTIPOLYFILLS_MEMBER_CONFLICT}.
*/
@@ -45,13 +44,13 @@ public PolyfillMemberConflictDescription(IEObjectDescription delegate, String me
@Override
public String getMessage() {
- return IssueCodes.getMessageForCLF_POLYFILL_MULTIPOLYFILLS_MEMBER_CONFLICT(
+ return IssueCodes.CLF_POLYFILL_MULTIPOLYFILLS_MEMBER_CONFLICT.getMessage(
Joiner.on(", ").join(conflictingModuleNames), memberName);
}
@Override
public String getIssueCode() {
- return IssueCodes.CLF_POLYFILL_MULTIPOLYFILLS_MEMBER_CONFLICT;
+ return IssueCodes.CLF_POLYFILL_MULTIPOLYFILLS_MEMBER_CONFLICT.name();
}
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/members/UnionMemberDescriptionWithError.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/members/UnionMemberDescriptionWithError.java
index e86265ac8b..e7ddfd09f1 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/members/UnionMemberDescriptionWithError.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/members/UnionMemberDescriptionWithError.java
@@ -55,8 +55,8 @@ private boolean initInvalidCombination(MapOfIndexes indexesPerMemberType
// check for three special cases of error 'multipleKinds' that require a more informative message
if (numberOfFields + indexesPerMemberType.numberOf("getter") == max) {
if (writeAccess) {
- message = IssueCodes.getMessageForUNI_INVALID_COMBINATION("getters", name, "read-only");
- code = IssueCodes.UNI_INVALID_COMBINATION;
+ message = IssueCodes.UNI_INVALID_COMBINATION.getMessage("getters", name, "read-only");
+ code = IssueCodes.UNI_INVALID_COMBINATION.name();
return true;
} else {
return false; // access would be ok, there must be another reason
@@ -65,11 +65,11 @@ private boolean initInvalidCombination(MapOfIndexes indexesPerMemberType
if (numberOfFields + indexesPerMemberType.numberOf("setter") == max) {
if (writeAccess) {
if (readOnlyField) {
- message = IssueCodes.getMessageForUNI_INVALID_COMBINATION_SETTER_VS_READ_ONLY_FIELD(name);
- code = IssueCodes.UNI_INVALID_COMBINATION_SETTER_VS_READ_ONLY_FIELD;
+ message = IssueCodes.UNI_INVALID_COMBINATION_SETTER_VS_READ_ONLY_FIELD.getMessage(name);
+ code = IssueCodes.UNI_INVALID_COMBINATION_SETTER_VS_READ_ONLY_FIELD.name();
} else {
- message = IssueCodes.getMessageForUNI_INVALID_COMBINATION("setters", name, "write-only");
- code = IssueCodes.UNI_INVALID_COMBINATION;
+ message = IssueCodes.UNI_INVALID_COMBINATION.getMessage("setters", name, "write-only");
+ code = IssueCodes.UNI_INVALID_COMBINATION.name();
}
return true;
}
@@ -79,9 +79,9 @@ private boolean initInvalidCombination(MapOfIndexes indexesPerMemberType
}
// invalid special case
- if (indexesPerCode.containsKey(IssueCodes.VIS_WRONG_STATIC_ACCESSOR)) {
- message = IssueCodes.getMessageForVIS_WRONG_STATIC_ACCESSOR("static", name, "non-static");
- code = IssueCodes.VIS_WRONG_STATIC_ACCESSOR;
+ if (indexesPerCode.containsKey(IssueCodes.VIS_WRONG_STATIC_ACCESSOR.name())) {
+ message = IssueCodes.VIS_WRONG_STATIC_ACCESSOR.getMessage("static", name, "non-static");
+ code = IssueCodes.VIS_WRONG_STATIC_ACCESSOR.name();
return true;
}
@@ -94,8 +94,8 @@ private boolean initInvalidCombination(MapOfIndexes indexesPerMemberType
}
strb.append(memberTypeName + " in " + foundScopes);
}
- message = IssueCodes.getMessageForUNI_MULTIPLE_KINDS(name, strb.toString());
- code = IssueCodes.UNI_MULTIPLE_KINDS;
+ message = IssueCodes.UNI_MULTIPLE_KINDS.getMessage(name, strb.toString());
+ code = IssueCodes.UNI_MULTIPLE_KINDS.name();
return true;
}
return false;
@@ -103,9 +103,9 @@ private boolean initInvalidCombination(MapOfIndexes indexesPerMemberType
private boolean initMissingFrom(List missingFrom) {
if (!missingFrom.isEmpty()) {
- message = IssueCodes.getMessageForUNI_MISSING(getName().getLastSegment(),
+ message = IssueCodes.UNI_MISSING.getMessage(getName().getLastSegment(),
Joiner.on(", ").join(missingFrom));
- code = IssueCodes.UNI_MISSING;
+ code = IssueCodes.UNI_MISSING.name();
return true;
} else {
return false;
@@ -114,8 +114,8 @@ private boolean initMissingFrom(List missingFrom) {
private boolean initDefault() {
final String memberName = getName().getLastSegment();
- message = IssueCodes.getMessageForUNI_UNCOMMON(memberName);
- code = IssueCodes.UNI_UNCOMMON;
+ message = IssueCodes.UNI_UNCOMMON.getMessage(memberName);
+ code = IssueCodes.UNI_UNCOMMON.name();
return true;
}
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/members/WrongTypingStrategyDescription.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/members/WrongTypingStrategyDescription.java
index 7c8e4acd71..5743a01973 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/members/WrongTypingStrategyDescription.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/members/WrongTypingStrategyDescription.java
@@ -38,14 +38,14 @@ public String getMessage() {
// by the source code.
String typeName = receiverTypeName;
if (fields) {
- return IssueCodes.getMessageForTYS_MEMBER_NOT_IN_STRUCTURAL_FIELDS_TYPE_USE_SITE(memberTypeName,
+ return IssueCodes.TYS_MEMBER_NOT_IN_STRUCTURAL_FIELDS_TYPE_USE_SITE.getMessage(memberTypeName,
memberName, typeName);
}
if (useSite) {
- return IssueCodes.getMessageForTYS_MEMBER_NOT_IN_STRUCTURAL_TYPE_USE_SITE(memberTypeName, memberName,
+ return IssueCodes.TYS_MEMBER_NOT_IN_STRUCTURAL_TYPE_USE_SITE.getMessage(memberTypeName, memberName,
typeName);
} else {
- return IssueCodes.getMessageForTYS_MEMBER_NOT_IN_STRUCTURAL_TYPE_DEF_SITE(memberTypeName, memberName,
+ return IssueCodes.TYS_MEMBER_NOT_IN_STRUCTURAL_TYPE_DEF_SITE.getMessage(memberTypeName, memberName,
typeName);
}
}
@@ -53,12 +53,12 @@ public String getMessage() {
@Override
public String getIssueCode() {
if (fields) {
- return IssueCodes.TYS_MEMBER_NOT_IN_STRUCTURAL_FIELDS_TYPE_USE_SITE;
+ return IssueCodes.TYS_MEMBER_NOT_IN_STRUCTURAL_FIELDS_TYPE_USE_SITE.name();
}
if (useSite) {
- return IssueCodes.TYS_MEMBER_NOT_IN_STRUCTURAL_TYPE_USE_SITE;
+ return IssueCodes.TYS_MEMBER_NOT_IN_STRUCTURAL_TYPE_USE_SITE.name();
}
- return IssueCodes.TYS_MEMBER_NOT_IN_STRUCTURAL_TYPE_DEF_SITE;
+ return IssueCodes.TYS_MEMBER_NOT_IN_STRUCTURAL_TYPE_DEF_SITE.name();
}
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/utils/ProjectImportEnablingScope.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/utils/ProjectImportEnablingScope.java
index 36fc859ec1..f28a78dfa1 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/utils/ProjectImportEnablingScope.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/utils/ProjectImportEnablingScope.java
@@ -275,7 +275,7 @@ public IEObjectDescription getSingleElement(QualifiedName name) {
final EObject originalProxy = (EObject) this.importOrExportDecl.get()
.eGet(N4JSPackage.eINSTANCE.getModuleRef_Module(), false);
return new IssueCodeBasedEObjectDescription(EObjectDescription.create("impDecl", originalProxy),
- sbErrrorMessage.toString(), IssueCodes.IMP_UNRESOLVED);
+ sbErrrorMessage.toString(), IssueCodes.IMP_UNRESOLVED.name());
}
/**
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/utils/RestrictedUsageDescription.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/utils/RestrictedUsageDescription.java
index 36130bd96d..d330e1fed4 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/utils/RestrictedUsageDescription.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/utils/RestrictedUsageDescription.java
@@ -10,9 +10,8 @@
*/
package org.eclipse.n4js.scoping.utils;
-import org.eclipse.xtext.resource.IEObjectDescription;
-
import org.eclipse.n4js.validation.IssueCodes;
+import org.eclipse.xtext.resource.IEObjectDescription;
/**
* This description wraps an invisible member.
@@ -38,11 +37,11 @@ public RestrictedUsageDescription(IEObjectDescription delegate, String jsVariant
@Override
public String getMessage() {
String memberName = getName().getLastSegment();
- return IssueCodes.getMessageForVIS_RESTRITCTED_USAGE(memberName, jsVariant);
+ return IssueCodes.VIS_RESTRITCTED_USAGE.getMessage(memberName, jsVariant);
}
@Override
public String getIssueCode() {
- return IssueCodes.VIS_RESTRITCTED_USAGE;
+ return IssueCodes.VIS_RESTRITCTED_USAGE.name();
}
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/utils/UnsatisfiedRWAccessDescription.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/utils/UnsatisfiedRWAccessDescription.java
index e6aeca2ea9..5c7e14d6be 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/utils/UnsatisfiedRWAccessDescription.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/utils/UnsatisfiedRWAccessDescription.java
@@ -34,13 +34,13 @@ public UnsatisfiedRWAccessDescription(IEObjectDescription delegate, boolean isRe
@Override
public String getMessage() {
String available = (isReadMissing ? "write-access" : "read-access");
- return IssueCodes.getMessageForVIS_WRONG_READ_WRITE_ACCESS(
+ return IssueCodes.VIS_WRONG_READ_WRITE_ACCESS.getMessage(
"operation", "requires both read and write access, but only " + available, "available");
}
@Override
public String getIssueCode() {
- return IssueCodes.VIS_WRONG_READ_WRITE_ACCESS;
+ return IssueCodes.VIS_WRONG_READ_WRITE_ACCESS.name();
}
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/utils/WrongStaticAccessDescription.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/utils/WrongStaticAccessDescription.java
index 53d8c76b89..576df9ed74 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/utils/WrongStaticAccessDescription.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/utils/WrongStaticAccessDescription.java
@@ -10,11 +10,10 @@
*/
package org.eclipse.n4js.scoping.utils;
-import org.eclipse.xtext.resource.IEObjectDescription;
-
import org.eclipse.n4js.scoping.members.MemberScope;
import org.eclipse.n4js.ts.types.TypesPackage;
import org.eclipse.n4js.validation.IssueCodes;
+import org.eclipse.xtext.resource.IEObjectDescription;
/**
* If the {@link MemberScope} finds a static accessor in a wrong context, this descriptor is used to bound the reference
@@ -52,22 +51,22 @@ public WrongStaticAccessDescription(IEObjectDescription delegate, boolean static
public String getMessage() {
if (getEClass() == TypesPackage.eINSTANCE.getTypeVariable()) {
// special case for TypeVariables (because the generic error message does not fit here):
- return IssueCodes.getMessageForVIS_WRONG_TYPE_VARIABLE_ACCESSOR(getName());
+ return IssueCodes.VIS_WRONG_TYPE_VARIABLE_ACCESSOR.getMessage(getName());
}
// standard case:
String[] staticNonStatic = { "static", "non-static" };
String staticMemberStr = staticNonStatic[staticAccess ? 1 : 0];
String staticContextStr = staticNonStatic[staticAccess ? 0 : 1];
- return IssueCodes.getMessageForVIS_WRONG_STATIC_ACCESSOR(staticMemberStr, getName(), staticContextStr);
+ return IssueCodes.VIS_WRONG_STATIC_ACCESSOR.getMessage(staticMemberStr, getName(), staticContextStr);
}
@Override
public String getIssueCode() {
if (getEClass() == TypesPackage.eINSTANCE.getTypeVariable()) {
// special case:
- return IssueCodes.VIS_WRONG_TYPE_VARIABLE_ACCESSOR;
+ return IssueCodes.VIS_WRONG_TYPE_VARIABLE_ACCESSOR.name();
}
// standard case:
- return IssueCodes.VIS_WRONG_STATIC_ACCESSOR;
+ return IssueCodes.VIS_WRONG_STATIC_ACCESSOR.name();
}
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/utils/WrongWriteAccessDescription.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/utils/WrongWriteAccessDescription.java
index 7192b8b03c..2b9978fd18 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/utils/WrongWriteAccessDescription.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/utils/WrongWriteAccessDescription.java
@@ -46,19 +46,18 @@ public WrongWriteAccessDescription(IEObjectDescription delegate, boolean accessF
@Override
public String getMessage() {
if (isAssignmentToFinalFieldInCtor) {
- return IssueCodes.getMessageForCLF_FIELD_FINAL_REINIT_IN_CTOR(
- getName());
+ return IssueCodes.CLF_FIELD_FINAL_REINIT_IN_CTOR.getMessage(getName());
}
- return IssueCodes.getMessageForVIS_WRONG_READ_WRITE_ACCESS(
+ return IssueCodes.VIS_WRONG_READ_WRITE_ACCESS.getMessage(
getKeyword(), getName(), accessForWriteOperation ? "read-only" : "write-only");
}
@Override
public String getIssueCode() {
if (isAssignmentToFinalFieldInCtor) {
- return IssueCodes.CLF_FIELD_FINAL_REINIT_IN_CTOR;
+ return IssueCodes.CLF_FIELD_FINAL_REINIT_IN_CTOR.name();
}
- return IssueCodes.VIS_WRONG_READ_WRITE_ACCESS;
+ return IssueCodes.VIS_WRONG_READ_WRITE_ACCESS.name();
}
private String getKeyword() {
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/validation/ContextAwareTypeScopeValidator.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/validation/ContextAwareTypeScopeValidator.java
index 62d35e178f..6911817a67 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/validation/ContextAwareTypeScopeValidator.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/validation/ContextAwareTypeScopeValidator.java
@@ -85,13 +85,13 @@ public ScopeElementIssue getIssue(IEObjectDescription originalDescr) {
}
if (!isValidLocationForVoid && eClass == TypesPackage.Literals.VOID_TYPE) {
return new ScopeElementIssue(originalDescr,
- IssueCodes.TYS_VOID_AT_WRONG_LOCATION,
- IssueCodes.getMessageForTYS_VOID_AT_WRONG_LOCATION());
+ IssueCodes.TYS_VOID_AT_WRONG_LOCATION.name(),
+ IssueCodes.TYS_VOID_AT_WRONG_LOCATION.getMessage());
}
if (!isValidLocationForFunctionType && TypesPackage.Literals.TFUNCTION.isSuperTypeOf(eClass)) {
return new ScopeElementIssue(originalDescr,
- IssueCodes.TYS_FUNCTION_DISALLOWED_AS_TYPE,
- IssueCodes.getMessageForTYS_FUNCTION_DISALLOWED_AS_TYPE());
+ IssueCodes.TYS_FUNCTION_DISALLOWED_AS_TYPE.name(),
+ IssueCodes.TYS_FUNCTION_DISALLOWED_AS_TYPE.getMessage());
}
return null; // should never happen, because #isAccepted() has returned true
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/validation/VeeScopeValidator.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/validation/VeeScopeValidator.java
index 4a017418ae..fb7c83410b 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/validation/VeeScopeValidator.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/validation/VeeScopeValidator.java
@@ -74,8 +74,8 @@ public ScopeElementIssue getIssue(IEObjectDescription originalDescr) {
}
QualifiedName name = originalDescr.getName();
return new ScopeElementIssue(originalDescr,
- IssueCodes.AST_ELEMENT_MISUSED_AS_VALUE_OR_TYPE,
- IssueCodes.getMessageForAST_ELEMENT_MISUSED_AS_VALUE_OR_TYPE(name.toString(), "value"));
+ IssueCodes.AST_ELEMENT_MISUSED_AS_VALUE_OR_TYPE.name(),
+ IssueCodes.AST_ELEMENT_MISUSED_AS_VALUE_OR_TYPE.getMessage(name.toString(), "value"));
}
@Override
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/validation/VisibilityAwareCtorScopeValidator.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/validation/VisibilityAwareCtorScopeValidator.java
index 6099e3ead0..ad993f214c 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/validation/VisibilityAwareCtorScopeValidator.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/scoping/validation/VisibilityAwareCtorScopeValidator.java
@@ -72,10 +72,11 @@ public ScopeElementIssue getIssue(IEObjectDescription objDescr) {
TClassifier ctorClassifier = (TClassifier) proxyOrInstance;
String containerName = ctorClassifier.getTypeAsString();
- String message = IssueCodes.getMessageForVIS_NEW_CANNOT_INSTANTIATE_INVISIBLE_CONSTRUCTOR("constructor",
+ String message = IssueCodes.VIS_NEW_CANNOT_INSTANTIATE_INVISIBLE_CONSTRUCTOR.getMessage("constructor",
containerName);
- return new ScopeElementIssue(objDescr, IssueCodes.VIS_NEW_CANNOT_INSTANTIATE_INVISIBLE_CONSTRUCTOR, message);
+ return new ScopeElementIssue(objDescr, IssueCodes.VIS_NEW_CANNOT_INSTANTIATE_INVISIBLE_CONSTRUCTOR.name(),
+ message);
}
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/tooling/organizeImports/ImportStateCalculator.xtend b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/tooling/organizeImports/ImportStateCalculator.xtend
index 39c4c345b7..85aa1e7a16 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/tooling/organizeImports/ImportStateCalculator.xtend
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/tooling/organizeImports/ImportStateCalculator.xtend
@@ -238,6 +238,6 @@ class ImportStateCalculator {
private static def boolean isNamedImportOfNonExportedElement(ImportSpecifier importSpec, ASTMetaInfoCache astMetaInfoCache) {
return astMetaInfoCache.getLinkingIssueCodes(importSpec, N4JSPackage.Literals.NAMED_IMPORT_SPECIFIER__IMPORTED_ELEMENT)
- .contains(IssueCodes.IMP_NOT_EXPORTED);
+ .contains(IssueCodes.IMP_NOT_EXPORTED.name());
}
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/typesystem/SubtypeJudgment.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/typesystem/SubtypeJudgment.java
index 05dd7aa70e..70e17eab95 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/typesystem/SubtypeJudgment.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/typesystem/SubtypeJudgment.java
@@ -37,6 +37,7 @@
import static org.eclipse.n4js.typesystem.utils.RuleEnvironmentExtensions.stringType;
import static org.eclipse.n4js.typesystem.utils.RuleEnvironmentExtensions.undefinedType;
import static org.eclipse.n4js.typesystem.utils.RuleEnvironmentExtensions.wrap;
+import static org.eclipse.n4js.validation.IssueCodes.TYS_NO_SUBTYPE;
import java.math.BigDecimal;
import java.util.Iterator;
@@ -107,7 +108,7 @@ public Result apply(RuleEnvironment G, TypeArgument leftArg, TypeArgument rightA
// set default failure message
final String leftMsg = leftArg != null ? leftArg.getTypeRefAsString() : "";
final String rightMsg = rightArg != null ? rightArg.getTypeRefAsString() : "";
- return result.setDefaultFailureMessage(leftMsg + " is not a subtype of " + rightMsg);
+ return result.setDefaultFailureMessage(TYS_NO_SUBTYPE.getMessage(leftMsg, rightMsg));
}
return result;
}
@@ -504,8 +505,11 @@ private Result applyParameterizedTypeRef(RuleEnvironment G, ParameterizedTypeRef
if ((left.isUseSiteStructuralTyping() || left.isDefSiteStructuralTyping())
&& !(rightDeclType == objectType(G) && leftDeclType instanceof TClassifier)
&& !(leftDeclType instanceof PrimitiveType)) {
- return failure("Structural type " + left.getTypeRefAsString()
- + " is not a subtype of non-structural type " + right.getTypeRefAsString());
+
+ String msg = TYS_NO_SUBTYPE.getMessage(
+ "Structural type " + left.getTypeRefAsString(),
+ "non-structural type " + right.getTypeRefAsString());
+ return failure(msg);
}
// nominal typing (the default behavior)
if (leftDeclType instanceof TypeVariable || rightDeclType instanceof TypeVariable) {
@@ -856,10 +860,12 @@ private Result checkTypeArgumentCompatibility(RuleEnvironment G,
if (tempResult.isFailure()) {
if (tempResult.isOrIsCausedByPriority()) {
// fail with a custom message including the nested custom failure message:
- return failure(leftContainingTypeRef.getTypeRefAsString()
- + " is not a subtype of " + rightContainingTypeRef.getTypeRefAsString()
- + " due to incompatible type arguments: "
- + tempResult.getPriorityFailureMessage());
+ String msg = TYS_NO_SUBTYPE.getMessage(
+ leftContainingTypeRef.getTypeRefAsString(),
+ rightContainingTypeRef.getTypeRefAsString()
+ + " due to incompatible type arguments: "
+ + tempResult.getPriorityFailureMessage());
+ return failure(msg);
} else {
// fail with our default message:
return failure();
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/typesystem/utils/StructuralTypingComputer.xtend b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/typesystem/utils/StructuralTypingComputer.xtend
index beabfefdb3..b45f7802c7 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/typesystem/utils/StructuralTypingComputer.xtend
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/typesystem/utils/StructuralTypingComputer.xtend
@@ -51,6 +51,7 @@ import static org.eclipse.n4js.utils.StructuralMembersPredicates.*
import static extension org.eclipse.n4js.typesystem.utils.RuleEnvironmentExtensions.*
import static extension org.eclipse.n4js.utils.N4JSLanguageUtils.*
+import static org.eclipse.n4js.validation.IssueCodes.TYS_NO_SUBTYPE
/**
*/
@@ -147,12 +148,12 @@ class StructuralTypingComputer extends TypeSystemHelperStrategy {
val leftIsPrimitive = left.declaredType instanceof PrimitiveType
// primitive type on the right and non-primitive on the left
- if (rightIsPrimitive && !leftIsPrimitive) {
- return failure(leftRaw.typeRefAsString + " is not a subtype of " + right.typeRefAsString);
+ if (rightIsPrimitive && !leftIsPrimitive) {
+ return failure(TYS_NO_SUBTYPE.getMessage(leftRaw.typeRefAsString, right.typeRefAsString));
}
// primitive type on the left and non-primitive on the right
else if (leftIsPrimitive && !rightIsPrimitive) {
- return failure(leftRaw.typeRefAsString + " is not a subtype of " + right.typeRefAsString);
+ return failure(TYS_NO_SUBTYPE.getMessage(leftRaw.typeRefAsString, right.typeRefAsString));
}
// primitive types on both sides
else if (leftIsPrimitive && rightIsPrimitive) {
@@ -160,7 +161,7 @@ class StructuralTypingComputer extends TypeSystemHelperStrategy {
return if (left.declaredType === right.declaredType) {
success();
} else {
- failure(leftRaw.typeRefAsString + " is not a subtype of " + right.typeRefAsString);
+ failure(TYS_NO_SUBTYPE.getMessage(leftRaw.typeRefAsString, right.typeRefAsString));
}
}
// neither left nor right is primitive
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/ASTStructureValidator.xtend b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/ASTStructureValidator.xtend
index d9308d9262..b62de0146e 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/ASTStructureValidator.xtend
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/ASTStructureValidator.xtend
@@ -121,1754 +121,1652 @@ import static extension org.eclipse.n4js.parser.conversion.AbstractN4JSStringVal
*/
class ASTStructureValidator {
- @Inject
- private WorkspaceAccess workspaceAccess;
-
- @Inject
- private N4JSGrammarAccess grammarAccess;
-
- @Inject
- private N4JSLanguageHelper languageHelper;
-
- @Inject
- private JavaScriptVariantHelper jsVariantHelper;
-
- @ToString
- protected static class Constraints {
- static val BUILT_IN_TYPE_DEFINITION = 1
- static val STRICT = BUILT_IN_TYPE_DEFINITION << 1
- static val N4JS = STRICT << 1
- static val EXTERNAL = N4JS << 1
- static val ALLOW_NESTED_FUNCTION_DECLARATION = EXTERNAL << 1
- static val ALLOW_RETURN = ALLOW_NESTED_FUNCTION_DECLARATION << 1
- static val ALLOW_CONTINUE = ALLOW_RETURN << 1
- static val ALLOW_BREAK = ALLOW_CONTINUE << 1 // whether we are in "break-allowed-with/without-label" (for||while||switch-case||labelled-block) area
- static val ALLOW_BREAK_WITHOUT_LABEL = ALLOW_BREAK << 1 // whether we are in (for||while||switch-case) area
- static val ALLOW_VAR_WITHOUT_INITIALIZER = ALLOW_BREAK_WITHOUT_LABEL << 1
- static val ALLOW_YIELD_EXPRESSION = ALLOW_VAR_WITHOUT_INITIALIZER << 1
- static val ALLOW_SUPER = ALLOW_YIELD_EXPRESSION << 1
- static val ALLOW_SUPER_CALL = ALLOW_SUPER << 1
- static val IN_FUNCTION_DECLARATION = ALLOW_SUPER_CALL << 1
-
- val int bits
-
- def private static getIf(int value, boolean b) {
- if (b) value else 0
- }
-
- new(boolean builtInTypeDefinition, boolean n4js, boolean external) {
- this(
- BUILT_IN_TYPE_DEFINITION.getIf(builtInTypeDefinition).bitwiseOr(
- N4JS.getIf(n4js).bitwiseOr(
- EXTERNAL.getIf(external).bitwiseOr(
- ALLOW_VAR_WITHOUT_INITIALIZER.bitwiseOr(
- ALLOW_YIELD_EXPRESSION
- )
- )
- )
- )
- )
- }
-
- new(int bits) {
- this.bits = bits
- }
-
- def private is(int bit) {
- return this.bits.bitwiseAnd(bit) !== 0
- }
-
- def boolean isBuiltInTypeDefinition() {
- return is(BUILT_IN_TYPE_DEFINITION)
- }
-
- def boolean isN4JS() {
- return is(N4JS)
- }
-
- def boolean isStrict() {
- return is(N4JS) || is(STRICT)
- }
-
- def boolean isExternal() {
- return is(EXTERNAL)
- }
-
- def boolean isNestedFunctionAllowed() {
- return is(ALLOW_NESTED_FUNCTION_DECLARATION)
- }
-
- def boolean isInFunctionDeclaration() {
- return is(IN_FUNCTION_DECLARATION)
- }
-
- def boolean isReturnAllowed() {
- return is(ALLOW_RETURN)
- }
-
- def boolean isBreakAllowed() {
- return is(ALLOW_BREAK)
- }
-
- def boolean isBreakAllowedWithoutLabel() {
- return is(ALLOW_BREAK_WITHOUT_LABEL)
- }
-
- def boolean isContinueAllowed() {
- return is(ALLOW_CONTINUE)
- }
-
- def boolean isVarInitializerRequired() {
- return !is(ALLOW_VAR_WITHOUT_INITIALIZER)
- }
-
- def boolean isYieldExpressionAllowed() {
- return is(ALLOW_YIELD_EXPRESSION)
- }
-
- def boolean isSuperLiteralAllowed() {
- return is(ALLOW_SUPER)
- }
-
- def boolean isSuperCallAllowed() {
- return is(ALLOW_SUPER_CALL)
- }
-
- def Constraints with(int bit, boolean set) {
- val newBits = if (set) {
- this.bits.bitwiseOr(bit)
- } else {
- this.bits.bitwiseAnd(bit.bitwiseNot)
- }
- if (newBits === this.bits) {
- return this
- }
- return new Constraints(newBits)
- }
-
- def Constraints strict(boolean strict) {
- with(STRICT, strict)
- }
-
- def Constraints allowNestedFunctions(boolean allow) {
- with(ALLOW_NESTED_FUNCTION_DECLARATION, allow)
- }
-
- def Constraints allowBreak(boolean allow) {
- with(ALLOW_BREAK, allow)
- }
-
- def Constraints allowBreakWithoutLabel(boolean allow) {
- with(ALLOW_BREAK_WITHOUT_LABEL, allow)
- }
-
- def Constraints allowContinue(boolean allow) {
- with(ALLOW_CONTINUE, allow)
- }
-
- def Constraints allowReturn(boolean allow) {
- with(ALLOW_RETURN, allow)
- }
-
- def Constraints allowVarWithoutInitializer(boolean allow) {
- with(ALLOW_VAR_WITHOUT_INITIALIZER, allow)
- }
-
- def Constraints allowYieldExpression(boolean allow) {
- with(ALLOW_YIELD_EXPRESSION, allow)
- }
-
- def Constraints allowSuperLiteral(boolean allow) {
- if (!allow) {
- allowSuperCall(false).with(ALLOW_SUPER, allow)
- } else {
- with(ALLOW_SUPER, allow)
- }
- }
-
- def Constraints allowSuperCall(boolean allow) {
- with(ALLOW_SUPER_CALL, allow)
- }
-
- def Constraints enterFunctionDeclaration() {
- with(IN_FUNCTION_DECLARATION, true)
- }
-
- }
-
- def void validate(EObject model, IDiagnosticConsumer consumer) {
- val resource = model?.eResource;
- if(resource !== null && !workspaceAccess.isNoValidate(resource, resource.getURI())) {
- val producer = new ASTStructureDiagnosticProducer(consumer);
- validateASTStructure(model, producer, Sets.newHashSetWithExpectedSize(2),
- new Constraints(
- N4Scheme.isResourceWithN4Scheme(resource),
- jsVariantHelper.isN4JSMode(model),
- jsVariantHelper.isExternalMode(model))
- );
- }
- }
-
- def private void recursiveValidateASTStructure(
- EObject model,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- val content = model.eContents.iterator
- var newStrict = constraints.isStrict
- var first = true
- while (content.hasNext()) {
- val next = content.next();
-
- // TODO this looks wrong: "strict mode" must be defined as first statement only!
- // see IDE-163, also see JavaScriptVariant
- // SZ: "use strict" must not be the first entry in the prolog, see test/language/directive-prologue/14.1-5gs.js
- newStrict = newStrict || (first && isUseStrictProlog(model, next))
- first = first && isProlog(next)
- if (next instanceof StrictModeRelevant) {
- next.setStrictMode(newStrict)
- }
- validateASTStructure(
- next,
- producer,
- validLabels,
- constraints.strict(newStrict)
- )
- }
- }
-
- def private isProlog(EObject object) {
- if (object instanceof ExpressionStatement) {
- return object.expression instanceof StringLiteral
- }
- return false
- }
-
- def private isUseStrictProlog(EObject model, EObject next) {
- if (model instanceof Script || model instanceof Block && model.eContainer instanceof FunctionDefinition) {
- switch (next) {
- ExpressionStatement: {
- switch it: next.expression {
- StringLiteral: {
- return BaseJavaScriptVariantHelper.STRICT_MODE_LITERAL_VALUE == value
- }
- }
- }
- }
- }
- return false
- }
-
- def private dispatch void validateASTStructure(
- EObject model,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- recursiveValidateASTStructure(
- model,
- producer,
- validLabels,
- constraints
- )
- }
-
- def private dispatch void validateASTStructure(
- Script model,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- recursiveValidateASTStructure(
- model,
- producer,
- validLabels,
- constraints.strict(false).allowNestedFunctions(true).allowReturn(false).allowContinue(false).allowBreak(false).allowBreakWithoutLabel(false)
- );
- }
-
- def private dispatch void validateASTStructure(
- CoalesceExpression model,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- val container = model.eContainer
- if (container instanceof BinaryLogicalExpression) {
- val target = NodeModelUtils.findActualNodeFor(model)
- producer.node = target
- producer.addDiagnostic(
- new DiagnosticMessage(IssueCodes.getMessageForAST_INVALID_COALESCE_PARENT(container.op.literal),
- IssueCodes.getDefaultSeverity(IssueCodes.AST_INVALID_COALESCE_PARENT), IssueCodes.AST_INVALID_COALESCE_PARENT))
- } else if (model.expression instanceof BinaryLogicalExpression) {
- val target = NodeModelUtils.findActualNodeFor(model.expression)
- producer.node = target
- producer.addDiagnostic(
- new DiagnosticMessage(IssueCodes.getMessageForAST_INVALID_COALESCE_CHILD((model.expression as BinaryLogicalExpression).op.literal),
- IssueCodes.getDefaultSeverity(IssueCodes.AST_INVALID_COALESCE_CHILD), IssueCodes.AST_INVALID_COALESCE_CHILD))
- } else if (model.defaultExpression instanceof BinaryLogicalExpression) {
- val target = NodeModelUtils.findActualNodeFor(model.defaultExpression)
- producer.node = target
- producer.addDiagnostic(
- new DiagnosticMessage(IssueCodes.getMessageForAST_INVALID_COALESCE_CHILD((model.defaultExpression as BinaryLogicalExpression).op.literal),
- IssueCodes.getDefaultSeverity(IssueCodes.AST_INVALID_COALESCE_CHILD), IssueCodes.AST_INVALID_COALESCE_CHILD))
- }
- recursiveValidateASTStructure(
- model,
- producer,
- validLabels,
- constraints
- )
- }
-
- def private dispatch void validateASTStructure(
- N4ClassifierDefinition model,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- if (model instanceof N4ClassifierDeclaration) {
- if(model.name===null && !model.isExportedAsDefault) {
- val target = NodeModelUtils.findActualNodeFor(model)
- producer.node = target
- producer.addDiagnostic(
- new DiagnosticMessage(IssueCodes.messageForAST_TYPE_DECL_MISSING_NAME,
- IssueCodes.getDefaultSeverity(IssueCodes.AST_TYPE_DECL_MISSING_NAME), IssueCodes.AST_TYPE_DECL_MISSING_NAME))
- }
- }
-
- recursiveValidateASTStructure(
- model,
- producer,
- validLabels,
- // according to ecma6 spec, class bodies are always strict
- constraints.strict(true).allowNestedFunctions(true).allowReturn(false).allowContinue(false).allowBreak(false).allowBreakWithoutLabel(false)
- )
- }
-
- def private dispatch void validateASTStructure(
- N4EnumDeclaration model,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- if(model.name===null && !model.isExportedAsDefault) {
- val target = NodeModelUtils.findActualNodeFor(model)
- producer.node = target
- producer.addDiagnostic(
- new DiagnosticMessage(IssueCodes.messageForAST_TYPE_DECL_MISSING_NAME,
- IssueCodes.getDefaultSeverity(IssueCodes.AST_TYPE_DECL_MISSING_NAME), IssueCodes.AST_TYPE_DECL_MISSING_NAME))
- }
-
- if (model.literals.isEmpty) {
- val target = NodeModelUtils.findActualNodeFor(model)
- producer.node = target
- producer.addDiagnostic(
- new DiagnosticMessage(IssueCodes.messageForENM_WITHOUT_LITERALS,
- IssueCodes.getDefaultSeverity(IssueCodes.ENM_WITHOUT_LITERALS), IssueCodes.ENM_WITHOUT_LITERALS))
- }
-
- recursiveValidateASTStructure(
- model,
- producer,
- validLabels,
- // according to ecma6 spec, class bodies are always strict
- constraints.strict(true).allowNestedFunctions(true).allowReturn(false).allowContinue(false).allowBreak(false).allowBreakWithoutLabel(false)
- )
- }
-
- def private dispatch void validateASTStructure(
- N4EnumLiteral model,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- if (!N4JSLanguageUtils.isEnumLiteralValueExpressionValid(model)) {
- val nodes = NodeModelUtils.findNodesForFeature(model, N4JSPackage.eINSTANCE.n4EnumLiteral_ValueExpression);
- producer.node = nodes.head;
- producer.addDiagnostic(
- new DiagnosticMessage(IssueCodes.messageForENM_INVALID_VALUE_EXPRESSION,
- IssueCodes.getDefaultSeverity(IssueCodes.ENM_INVALID_VALUE_EXPRESSION), IssueCodes.ENM_INVALID_VALUE_EXPRESSION))
- }
-
- recursiveValidateASTStructure(
- model,
- producer,
- validLabels,
- constraints
- )
- }
-
- def private dispatch void validateASTStructure(
- LegacyOctalIntLiteral model,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- if (constraints.isStrict) {
- val target = NodeModelUtils.findActualNodeFor(model)
- producer.node = target
- producer.addDiagnostic(
- new DiagnosticMessage(IssueCodes.messageForAST_STR_NO_OCTALS,
- IssueCodes.getDefaultSeverity(IssueCodes.AST_STR_NO_OCTALS), IssueCodes.AST_STR_NO_OCTALS))
- }
- recursiveValidateASTStructure(
- model,
- producer,
- validLabels,
- constraints
- )
- }
-
- def private dispatch void validateASTStructure(
- NumericLiteralTypeRef model,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- if (constraints.isStrict) {
- val node = NodeModelUtils.findNodesForFeature(model, TypeRefsPackage.Literals.LITERAL_TYPE_REF__AST_VALUE).head;
- if (node !== null) {
- val text = NodeModelUtils.getTokenText(node);
- if (text.length() >= 2 && text.startsWith("0") && Character.isDigit(text.charAt(1))) {
- producer.node = node;
- producer.addDiagnostic(
- new DiagnosticMessage(IssueCodes.messageForAST_STR_NO_OCTALS,
- IssueCodes.getDefaultSeverity(IssueCodes.AST_STR_NO_OCTALS), IssueCodes.AST_STR_NO_OCTALS));
- }
- }
- }
-
- recursiveValidateASTStructure(
- model,
- producer,
- validLabels,
- constraints
- )
- }
-
- def private dispatch void validateASTStructure(
- StringLiteral model,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- if (constraints.isStrict) {
- addErrorForOctalEscapeSequence(model.rawValue, model, N4JSPackage.Literals.STRING_LITERAL__VALUE, producer);
- }
- recursiveValidateASTStructure(
- model,
- producer,
- validLabels,
- constraints
- )
- }
-
- def private dispatch void validateASTStructure(
- TemplateSegment model,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- addErrorForOctalEscapeSequence(model.rawValue, model, N4JSPackage.Literals.TEMPLATE_SEGMENT__VALUE, producer);
-
- recursiveValidateASTStructure(
- model,
- producer,
- validLabels,
- constraints
- )
- }
-
- def private dispatch void validateASTStructure(
- StringLiteralTypeRef model,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- val node = NodeModelUtils.findNodesForFeature(model, TypeRefsPackage.Literals.LITERAL_TYPE_REF__AST_VALUE).head;
- if (node !== null) {
- val text = NodeModelUtils.getTokenText(node);
- addErrorForOctalEscapeSequence(text, model, TypeRefsPackage.Literals.LITERAL_TYPE_REF__AST_VALUE, producer);
- }
-
- recursiveValidateASTStructure(
- model,
- producer,
- validLabels,
- constraints
- )
- }
-
- def private addErrorForOctalEscapeSequence(String rawValue, EObject model, EAttribute valueEAttribute, ASTStructureDiagnosticProducer producer) {
- val nodes = NodeModelUtils.findNodesForFeature(model, valueEAttribute);
- val target = nodes.head;
- val syntaxError = target.syntaxErrorMessage;
- if ((syntaxError === null || syntaxError.issueCode == WARN_ISSUE_CODE || syntaxError.issueCode == InternalSemicolonInjectingParser.SEMICOLON_INSERTED) && rawValue.hasOctalEscapeSequence) {
- producer.node = target;
- producer.addDiagnostic(
- new DiagnosticMessage(IssueCodes.messageForAST_STR_NO_OCTALS,
- IssueCodes.getDefaultSeverity(IssueCodes.AST_STR_NO_OCTALS), IssueCodes.AST_STR_NO_OCTALS));
- }
- }
-
- def private dispatch void validateASTStructure(
- PostfixExpression model,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- recursiveValidateASTStructure(
- model,
- producer,
- validLabels,
- constraints
- )
- val child = model.expression
- if (!child.isValidSimpleAssignmentTarget) {
- val nodes = NodeModelUtils.findNodesForFeature(model, N4JSPackage.Literals.POSTFIX_EXPRESSION__EXPRESSION)
- val target = nodes.head
- producer.node = target
- val operand = if (model.op == PostfixOperator.DEC) 'decrement' else 'increment'
- producer.addDiagnostic(
- new DiagnosticMessage(IssueCodes.getMessageForAST_INVALID_OPERAND(operand),
- IssueCodes.getDefaultSeverity(IssueCodes.AST_INVALID_OPERAND), IssueCodes.AST_INVALID_OPERAND))
- }
- }
-
- def private dispatch void validateASTStructure(
- UnaryExpression model,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- recursiveValidateASTStructure(
- model,
- producer,
- validLabels,
- constraints
- )
- if (model.op == UnaryOperator.DEC || model.op == UnaryOperator.INC) {
- val child = model.expression
- if (child!==null && !child.isValidSimpleAssignmentTarget) {
- val nodes = NodeModelUtils.findNodesForFeature(model,
- N4JSPackage.Literals.POSTFIX_EXPRESSION__EXPRESSION)
- val target = nodes.head
- producer.node = target
- val operand = if (model.op == UnaryOperator.DEC) 'decrement' else 'increment'
- producer.addDiagnostic(
- new DiagnosticMessage(IssueCodes.getMessageForAST_INVALID_OPERAND(operand),
- IssueCodes.getDefaultSeverity(IssueCodes.AST_INVALID_OPERAND), IssueCodes.AST_INVALID_OPERAND))
- }
- }
- }
-
- def private dispatch void validateASTStructure(
- YieldExpression model,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- if (!constraints.isYieldExpressionAllowed) {
- val target = NodeModelUtils.findActualNodeFor(model)
- producer.node = target
- producer.addDiagnostic(
- new DiagnosticMessage(IssueCodes.messageForAST_INVALID_YIELD_EXPRESSION,
- IssueCodes.getDefaultSeverity(IssueCodes.AST_INVALID_YIELD_EXPRESSION), IssueCodes.AST_INVALID_YIELD_EXPRESSION))
- }
- recursiveValidateASTStructure(
- model,
- producer,
- validLabels,
- constraints
- )
- }
-
- def private dispatch void validateASTStructure(
- AssignmentExpression model,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- // first validate the children to make sure strictMode flag was set
- recursiveValidateASTStructure(
- model,
- producer,
- validLabels,
- constraints
- )
- if (model.lhs !== null && !N4JSLanguageUtils.hasValidLHS(model)) {
- val nodes = NodeModelUtils.findNodesForFeature(model, N4JSPackage.Literals.ASSIGNMENT_EXPRESSION__LHS)
- val target = nodes.head
- producer.node = target
- producer.addDiagnostic(
- new DiagnosticMessage(IssueCodes.getMessageForAST_EXP_INVALID_LHS_ASS,
- IssueCodes.getDefaultSeverity(IssueCodes.AST_EXP_INVALID_LHS_ASS),
- IssueCodes.AST_EXP_INVALID_LHS_ASS))
- }
- }
-
- def private dispatch void validateASTStructure(
- ParameterizedCallExpression model,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- if (N4JSLanguageUtils.isDynamicImportCall(model)) {
- if (!model.arguments.empty && model.arguments.get(0).isSpread) {
- val target = NodeModelUtils.findActualNodeFor(model.arguments.get(0));
- producer.node = target;
- producer.addDiagnostic(
- new DiagnosticMessage(IssueCodes.messageForAST_IMPORT_CALL_SPREAD,
- IssueCodes.getDefaultSeverity(IssueCodes.AST_IMPORT_CALL_SPREAD), IssueCodes.AST_IMPORT_CALL_SPREAD));
- }
- }
- recursiveValidateASTStructure(
- model,
- producer,
- validLabels,
- constraints
- )
- }
-
- def private dispatch void validateASTStructure(
- IdentifierRef model,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- val name = model.idAsText
- if (name !== null) {
- if (constraints.isStrict && (RESERVED_WORDS_IN_STRICT_MODE.contains(name))) {
- if (name == IMPORT_KEYWORD && 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) {
- val grandParent = model.eContainer?.eContainer;
- if (grandParent instanceof ExportDeclaration) {
- if (grandParent.exportedElement === null && !grandParent.isReexport) {
- val target = NodeModelUtils.findActualNodeFor(model);
- producer.node = target;
- producer.addDiagnostic(
- new DiagnosticMessage(IssueCodes.messageForAST_SEPARATE_DEFAULT_EXPORT_WITHOUT_FROM,
- IssueCodes.getDefaultSeverity(IssueCodes.AST_SEPARATE_DEFAULT_EXPORT_WITHOUT_FROM), IssueCodes.AST_SEPARATE_DEFAULT_EXPORT_WITHOUT_FROM));
- }
- }
- }
- }
- recursiveValidateASTStructure(
- model,
- producer,
- validLabels,
- constraints
- )
- }
-
- def private dispatch void validateASTStructure(
- AbstractVariable> model,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- val name = model.name
- if (name !== null) {
- if (name == LOCAL_ARGUMENTS_VARIABLE_NAME) {
- val 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)
- || 'enum'.equals(name) || 'await'.equals(name)
- || 'true'.equals(name) || 'false'.equals(name) || 'null'.equals(name))) {
-
- if (constraints.isBuiltInTypeDefinition() && 'import'.equals(name)) {
- // ignore
- } else {
- issueNameDiagnostic(model, producer, name)
- }
- } else if (constraints.isStrict) {
- if (RESERVED_WORDS_IN_STRICT_MODE.contains(name) || name == EVAL_NAME) {
- issueNameDiagnostic(model, producer, name)
- model.name = null; // do not pollute scope
- }
- }
- }
- }
- recursiveValidateASTStructure(
- model,
- producer,
- validLabels,
- constraints
- )
- }
-
- def private dispatch void validateASTStructure(
- WithStatement model,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- if (constraints.isStrict) {
- val node = NodeModelUtils.findActualNodeFor(model).leafNodes.findFirst[ grammarElement == grammarAccess.withStatementAccess.withKeyword_0 ]
- producer.node = node
- if(node !== null) {
- producer.addDiagnostic(
- new DiagnosticMessage(IssueCodes.messageForAST_STR_NO_WITH_STMT,
- IssueCodes.getDefaultSeverity(IssueCodes.AST_STR_NO_WITH_STMT),
- IssueCodes.AST_STR_NO_WITH_STMT))
- }
- }
- recursiveValidateASTStructure(
- model,
- producer,
- validLabels,
- constraints
- )
- }
-
- def private dispatch void validateASTStructure(
- LabelledStatement model,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- val name = model.name
- if (name !== null) {
- if (constraints.isStrict && (RESERVED_WORDS_IN_STRICT_MODE.contains(name))) {
- issueNameDiagnostic(model, producer, name)
- model.name = null; // do not pollute scope
- }
- }
- try {
- validLabels.add(model)
- recursiveValidateASTStructure(
- model,
- producer,
- validLabels,
- constraints.allowNestedFunctions(!constraints.isStrict).allowBreak(true)
- )
- } finally {
- validLabels.remove(model)
- }
- }
-
- def private dispatch void validateASTStructure(
- Block model,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- validateBlockStructure(
- model.eContainer,
- model,
- producer,
- validLabels,
- constraints
- )
- }
-
- def private dispatch void validateBlockStructure(
- IfStatement container,
- Block model,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- recursiveValidateASTStructure(
- model,
- producer,
- validLabels,
- constraints
- )
- }
-
- def private dispatch void validateBlockStructure(
- IterationStatement container,
- Block model,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- recursiveValidateASTStructure(
- model,
- producer,
- validLabels,
- constraints.allowNestedFunctions(!constraints.isStrict && !constraints.isInFunctionDeclaration)
- )
- }
-
- def private dispatch void validateBlockStructure(
- FunctionDefinition container,
- Block model,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- recursiveValidateASTStructure(
- model,
- producer,
- validLabels,
- constraints.allowNestedFunctions(true)
- )
- }
-
- def private dispatch void validateBlockStructure(
- CatchBlock container,
- Block model,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- recursiveValidateASTStructure(
- model,
- producer,
- validLabels,
- constraints.allowNestedFunctions(true)
- )
- }
-
- def private dispatch void validateBlockStructure(
- EObject container,
- Block model,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- recursiveValidateASTStructure(
- model,
- producer,
- validLabels,
- constraints.allowNestedFunctions(!constraints.isStrict)
- )
- }
-
- def private dispatch void validateASTStructure(
- IfStatement model,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- recursiveValidateASTStructure(
- model,
- producer,
- validLabels,
- constraints.allowNestedFunctions(!constraints.isStrict && !constraints.isInFunctionDeclaration)
- )
- }
-
- def private dispatch void validateASTStructure(
- AbstractCaseClause model,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- recursiveValidateASTStructure(
- model,
- producer,
- validLabels,
- constraints.allowBreak(true).allowBreakWithoutLabel(true)
- )
- }
-
- def private dispatch void validateASTStructure(
- ForStatement model,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- if (model.isAwait && !model.isForOf) {
- val nodes = NodeModelUtils.findNodesForFeature(model, N4JSPackage.Literals.FOR_STATEMENT__AWAIT);
- val target = nodes.head ?: NodeModelUtils.findActualNodeFor(model);
- if (target !== null) {
- producer.node = target;
- producer.addDiagnostic(new DiagnosticMessage(IssueCodes.messageForAST_INVALID_FOR_AWAIT,
- IssueCodes.getDefaultSeverity(IssueCodes.AST_INVALID_FOR_AWAIT), IssueCodes.AST_INVALID_FOR_AWAIT));
- }
- }
- if (!model.isForPlain) {
- if (! model.varDeclsOrBindings.empty) {
- model.varDecl.forEach[ varDecl |
- if (varDecl.expression !== null && !(varDecl.eContainer instanceof BindingElement) && (constraints.isStrict || model.varStmtKeyword === VariableStatementKeyword.LET)) {
- val nodes = NodeModelUtils.findNodesForFeature(varDecl, N4JSPackage.Literals.VARIABLE_DECLARATION__EXPRESSION)
- val target = nodes.head ?: NodeModelUtils.findActualNodeFor(varDecl)
- producer.node = target
- if(target !== null) {
- producer.addDiagnostic(
- new DiagnosticMessage(IssueCodes.messageForAST_VAR_DECL_IN_FOR_INVALID_INIT,
- if (constraints.isStrict || model.isForIn) IssueCodes.getDefaultSeverity(IssueCodes.AST_VAR_DECL_IN_FOR_INVALID_INIT) else Severity.WARNING,
- IssueCodes.AST_VAR_DECL_IN_FOR_INVALID_INIT))
- }
- } else if (model.varStmtKeyword === VariableStatementKeyword.LET && varDecl.name == 'let') {
- val nodes = NodeModelUtils.findNodesForFeature(varDecl, N4JSPackage.Literals.ABSTRACT_VARIABLE__NAME)
- val target = nodes.head ?: NodeModelUtils.findActualNodeFor(varDecl)
- producer.node = target
- if(target !== null) {
- producer.addDiagnostic(
- new DiagnosticMessage(IssueCodes.getMessageForAST_RESERVED_IDENTIFIER(varDecl.name),
- IssueCodes.getDefaultSeverity(IssueCodes.AST_RESERVED_IDENTIFIER),
- IssueCodes.AST_RESERVED_IDENTIFIER))
- }
- }
- ]
- } else if (model.initExpr!==null) {
- val initExpr = model.initExpr;
- if (initExpr instanceof AssignmentExpression) {
- val nodes = NodeModelUtils.findNodesForFeature(initExpr,
- TypesPackage.Literals.IDENTIFIABLE_ELEMENT__NAME)
- val target = nodes.head ?: NodeModelUtils.findActualNodeFor(initExpr)
- producer.node = target
- if (target !== null) {
- producer.addDiagnostic(
- new DiagnosticMessage(
- IssueCodes.getMessageForAST_VAR_DECL_IN_FOR_INVALID_INIT(),
- IssueCodes.getDefaultSeverity(IssueCodes.AST_VAR_DECL_IN_FOR_INVALID_INIT),
- IssueCodes.AST_VAR_DECL_IN_FOR_INVALID_INIT))
- }
- } else if(!initExpr.isValidSimpleAssignmentTarget && !model.isTopOfDestructuringForStatement) {
- val nodes = NodeModelUtils.findNodesForFeature(model,
- N4JSPackage.Literals.FOR_STATEMENT__INIT_EXPR)
- val target = nodes.head ?: NodeModelUtils.findActualNodeFor(initExpr)
- producer.node = target
- if (target !== null) {
- producer.addDiagnostic(
- new DiagnosticMessage(
- IssueCodes.getMessageForAST_EXP_INVALID_LHS_ASS,
- IssueCodes.getDefaultSeverity(IssueCodes.AST_EXP_INVALID_LHS_ASS),
- IssueCodes.AST_EXP_INVALID_LHS_ASS))
- }
- }
- }
- }
- recursiveValidateASTStructure(
- model,
- producer,
- validLabels,
- constraints.allowNestedFunctions(!constraints.isStrict && !constraints.isInFunctionDeclaration).allowBreak(true).allowContinue(true).allowBreakWithoutLabel(true)
- )
- }
-
- def private dispatch void validateASTStructure(
- IterationStatement model,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- recursiveValidateASTStructure(
- model,
- producer,
- validLabels,
- constraints.allowNestedFunctions(!constraints.isStrict && !constraints.isInFunctionDeclaration).allowBreak(true).allowContinue(true).allowBreakWithoutLabel(true)
- )
- }
-
- def private dispatch void validateASTStructure(
- FormalParameter model,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- val container = model.eContainer
- var allowYieldInInit = false
- if (container instanceof FunctionDefinition) {
- allowYieldInInit = !container.isGenerator
-
- val issueConsumer = [String msg, String id, EObject eObj |
- producer.node = NodeModelUtils.findActualNodeFor(eObj);
- producer.addDiagnostic(new DiagnosticMessage(msg, IssueCodes.getDefaultSeverity(id), id));
- ];
- internalCheckFormalParameter(
- container.fpars,
- model,
- [variadic],
- [hasInitializerAssignment],
- issueConsumer
- );
- }
-
- _validateASTStructure(
- model as AbstractVariable>,
- producer,
- validLabels,
- constraints.allowYieldExpression(allowYieldInInit)
- )
- }
-
- def private dispatch void validateASTStructure(
- NewTarget model,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- if (EcoreUtil2.getContainerOfType(model, FunctionDefinition) === null) {
- val target = NodeModelUtils.findActualNodeFor(model)
- if(target !== null) {
- producer.node = target
- producer.addDiagnostic(
- new DiagnosticMessage(IssueCodes.messageForAST_INVALID_NEW_TARGET,
- IssueCodes.getDefaultSeverity(IssueCodes.AST_INVALID_NEW_TARGET),
- IssueCodes.AST_INVALID_NEW_TARGET))
- }
- }
- recursiveValidateASTStructure(
- model,
- producer,
- validLabels,
- constraints
- )
- }
-
- def private dispatch void validateASTStructure(
- SuperLiteral model,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- if (model.isInvalidSuperLiteral(constraints)) {
-
- val target = NodeModelUtils.findActualNodeFor(model)
- if(target !== null) {
- producer.node = target
- if (model.eContainingFeature === N4JSPackage.Literals.EXPRESSION_WITH_TARGET__TARGET && model.eContainer instanceof ParameterizedCallExpression) {
- producer.addDiagnostic(
- new DiagnosticMessage(IssueCodes.messageForKEY_SUP_CTOR_INVALID_LOC,
- IssueCodes.getDefaultSeverity(IssueCodes.KEY_SUP_CTOR_INVALID_LOC),
- IssueCodes.KEY_SUP_CTOR_INVALID_LOC))
- } else if (EcoreUtil2.getContainerOfType(model, N4MethodDeclaration) === null) {
- producer.addDiagnostic(
- new DiagnosticMessage(IssueCodes.messageForKEY_SUP_ACCESS_INVALID_LOC,
- IssueCodes.getDefaultSeverity(IssueCodes.KEY_SUP_ACCESS_INVALID_LOC),
- IssueCodes.KEY_SUP_ACCESS_INVALID_LOC))
- } else {
- val containingClass = EcoreUtil2.getContainerOfType(model, N4ClassifierDeclaration)
- if (containingClass instanceof N4InterfaceDeclaration) {
- producer.addDiagnostic(
- new DiagnosticMessage(IssueCodes.messageForKEY_SUP_ACCESS_INVALID_LOC_INTERFACE,
- IssueCodes.getDefaultSeverity(IssueCodes.KEY_SUP_ACCESS_INVALID_LOC_INTERFACE),
- IssueCodes.KEY_SUP_ACCESS_INVALID_LOC_INTERFACE))
- } else if (containingClass !== null) {
- if (!constraints.isN4JS) { // implicit super type only available in n4js
- producer.addDiagnostic(
- new DiagnosticMessage(IssueCodes.messageForKEY_SUP_ACCESS_NO_EXTENDS,
- IssueCodes.getDefaultSeverity(IssueCodes.KEY_SUP_ACCESS_NO_EXTENDS),
- IssueCodes.KEY_SUP_ACCESS_NO_EXTENDS))
- }
- } else {
- throw new IllegalStateException('a')
- }
- }
- }
-
- }
- recursiveValidateASTStructure(
- model,
- producer,
- validLabels,
- constraints
- )
- }
-
- def private boolean isInvalidSuperLiteral(SuperLiteral model, Constraints constraints) {
- if (!model.isValidContainment) {
- return true
- }
- if (!constraints.isSuperLiteralAllowed) {
- return true
- }
- if (!constraints.isSuperCallAllowed) {
- return model.eContainer instanceof ParameterizedCallExpression
- }
- return false
- }
-
- def private boolean isValidContainment(SuperLiteral literal) {
- val container = literal.eContainer
- return container instanceof IndexedAccessExpression || container instanceof ParameterizedCallExpression || container instanceof ParameterizedPropertyAccessExpression
- }
-
- def private dispatch void validateASTStructure(
- FunctionDeclaration model,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- validateFunctionDefinition(
- model,
- N4JSPackage.Literals.FUNCTION_DECLARATION__NAME,
- constraints.enterFunctionDeclaration,
- model.name,
- producer,
- validLabels
- )
- }
-
- def private dispatch void validateASTStructure(
- FunctionExpression model,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- val name = model.name
- if (name !== null) {
- if (name == LOCAL_ARGUMENTS_VARIABLE_NAME) {
- issueArgumentsError(model, name, constraints.isStrict, producer)
- } else if (constraints.isStrict()) {
- if (RESERVED_WORDS_IN_STRICT_MODE.contains(name) || name == EVAL_NAME) {
- issueNameDiagnostic(model, producer, name)
- model.name = null; // do not pollute scope
- }
- }
- }
- recursiveValidateASTStructure(
- model,
- producer,
- Sets.newHashSetWithExpectedSize(2),
- constraints.allowNestedFunctions(true).allowReturn(true).allowBreak(false).allowContinue(false).allowBreakWithoutLabel(false)
- )
- }
-
- def private void validateFunctionDefinition(
- FunctionDefinition model,
- EAttribute attribute,
- Constraints constraints,
- String name,
- ASTStructureDiagnosticProducer producer,
- Set validLabels
- ) {
- if (!constraints.isNestedFunctionAllowed) {
- val nodes = NodeModelUtils.findNodesForFeature(model, attribute)
- val target = nodes.head ?: NodeModelUtils.findActualNodeFor(model)
- producer.node = target
-
- // TODO improve error message
- producer.addDiagnostic(
- new DiagnosticMessage(IssueCodes.getMessageForAST_STR_FUN_NOT_NESTED(),
- IssueCodes.getDefaultSeverity(IssueCodes.AST_STR_FUN_NOT_NESTED), IssueCodes.AST_STR_FUN_NOT_NESTED))
- } else if (name !== null) {
- if (name == LOCAL_ARGUMENTS_VARIABLE_NAME) {
- issueArgumentsError(model, name, constraints.isStrict, producer)
- } else if (constraints.isStrict()) {
- if (RESERVED_WORDS_IN_STRICT_MODE.contains(name) || name == EVAL_NAME) {
- issueNameDiagnostic(model, producer, name)
- }
- }
- }
- recursiveValidateASTStructure(
- model,
- producer,
- Sets.newHashSetWithExpectedSize(2),
- constraints.allowNestedFunctions(true).allowReturn(true).allowContinue(false).allowBreak(false).allowYieldExpression(true).allowBreakWithoutLabel(false)
- )
- }
-
- def private void validateName(PropertyNameOwner model, Constraints constraints, ASTStructureDiagnosticProducer producer) {
- val name = model.name
- if (name !== null) {
- if (!model.isValidName
- && !constraints.isBuiltInTypeDefinition) {
- issueNameDiagnostic(model, producer, name)
- } else {
- if (constraints.isN4JS) {
- if (RESERVED_WORDS_IN_STRICT_MODE.contains(name)) {
- issueNameDiagnostic(model, producer, name)
- }
- } else if (constraints.isStrict) {
- if (RESERVED_WORDS_IN_STRICT_MODE.contains(name)) {
- issueNameDiagnostic(model, producer, name, getNameFeature(model), Severity.WARNING)
- }
- }
- }
- }
- }
-
- def private void issueArgumentsError(EObject model, String name, boolean strict, ASTStructureDiagnosticProducer producer) {
- issueNameDiagnostic(model, producer, name, getNameFeature(model), if (strict) Severity.ERROR else Severity.WARNING);
- }
-
- def private void issueNameDiagnostic(EObject model, ASTStructureDiagnosticProducer producer, String name) {
- issueNameDiagnostic(model, producer, name, getNameFeature(model), IssueCodes.getDefaultSeverity(IssueCodes.AST_RESERVED_IDENTIFIER))
- }
-
- def private void issueNameDiagnostic(EObject model, ASTStructureDiagnosticProducer producer, String name, EStructuralFeature feature, Severity severity) {
- val nodes = NodeModelUtils.findNodesForFeature(model, feature)
- val target = nodes.head ?: NodeModelUtils.findActualNodeFor(model)
- producer.node = target
- if(target !== null) {
- producer.addDiagnostic(
- new DiagnosticMessage(IssueCodes.getMessageForAST_RESERVED_IDENTIFIER(name),
- severity,
- IssueCodes.AST_RESERVED_IDENTIFIER))
- }
- }
-
- def private EStructuralFeature getNameFeature(EObject model) {
- return model.eClass.getEStructuralFeature('name') ?: model.eClass.getEStructuralFeature('declaredName');
- }
-
- def private dispatch void validateASTStructure(
- N4FieldAccessor model,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- model.validateName(constraints, producer)
- recursiveValidateASTStructure(
- model,
- producer,
- Sets.newHashSetWithExpectedSize(2),
- constraints.allowReturn(true).allowSuperLiteral(true).allowSuperCall(false)
- )
- }
-
- def private dispatch void validateASTStructure(
- MethodDeclaration model,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- model.validateName(constraints, producer)
- recursiveValidateASTStructure(
- model,
- producer,
- Sets.newHashSetWithExpectedSize(2),
- constraints.allowReturn(true).allowSuperLiteral(true).allowSuperCall(model.name == 'constructor' && !model.isStatic && model.canCallSuperConstructor(constraints))
- )
- }
-
- def private boolean canCallSuperConstructor(MethodDeclaration declaration, Constraints constraints) {
- val container = declaration.eContainer
- if (container instanceof N4ClassDefinition) {
- if (constraints.isN4JS) {
- return true
- }
- return container.superClassRef !== null || container.superClassExpression !== null
- }
- return false
- }
-
- def private dispatch void validateASTStructure(
- FieldAccessor model,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- model.validateName(constraints, producer)
- recursiveValidateASTStructure(
- model,
- producer,
- Sets.newHashSetWithExpectedSize(2),
- constraints.allowReturn(true).allowSuperLiteral(true).allowSuperCall(false)
- )
- }
-
- def private dispatch void validateASTStructure(
- PropertyAssignment model,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- recursiveValidateASTStructure(
- model,
- producer,
- Sets.newHashSetWithExpectedSize(2),
- constraints.allowNestedFunctions(false).allowReturn(true).allowContinue(false).allowBreak(false).allowYieldExpression(true).allowBreakWithoutLabel(false)
- )
- }
-
- def private dispatch void validateASTStructure(
- ReturnStatement model,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- if (!constraints.isReturnAllowed) {
- val target = NodeModelUtils.findActualNodeFor(model)
- producer.node = target
- producer.addDiagnostic(
- new DiagnosticMessage(IssueCodes.getMessageForAST_INVALID_RETURN,
- IssueCodes.getDefaultSeverity(IssueCodes.AST_INVALID_RETURN), IssueCodes.AST_INVALID_RETURN))
- }
- recursiveValidateASTStructure(
- model,
- producer,
- validLabels,
- constraints
- )
- }
-
- def private dispatch void validateASTStructure(
- ContinueStatement model,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- if (!constraints.isContinueAllowed) {
- val target = NodeModelUtils.findActualNodeFor(model)
- producer.node = target
- producer.addDiagnostic(
- new DiagnosticMessage(IssueCodes.getMessageForAST_INVALID_CONTINUE,
- IssueCodes.getDefaultSeverity(IssueCodes.AST_INVALID_CONTINUE), IssueCodes.AST_INVALID_CONTINUE))
- } else {
- validateLabelRef(model, producer, validLabels)
- }
- recursiveValidateASTStructure(
- model,
- producer,
- validLabels,
- constraints
- )
- }
-
- def private dispatch void validateASTStructure(
- BreakStatement model,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- if (!constraints.isBreakAllowed
- || (!validateLabelRef(model, producer, validLabels) && !constraints.isBreakAllowedWithoutLabel)
- ) {
- val target = NodeModelUtils.findActualNodeFor(model)
- producer.node = target
- producer.addDiagnostic(
- new DiagnosticMessage(IssueCodes.getMessageForAST_INVALID_BREAK,
- IssueCodes.getDefaultSeverity(IssueCodes.AST_INVALID_BREAK), IssueCodes.AST_INVALID_BREAK))
- }
- recursiveValidateASTStructure(
- model,
- producer,
- validLabels,
- constraints
- )
- }
+ @Inject
+ private WorkspaceAccess workspaceAccess;
+
+ @Inject
+ private N4JSGrammarAccess grammarAccess;
+
+ @Inject
+ private N4JSLanguageHelper languageHelper;
+
+ @Inject
+ private JavaScriptVariantHelper jsVariantHelper;
+
+ @ToString
+ protected static class Constraints {
+ static val BUILT_IN_TYPE_DEFINITION = 1
+ static val STRICT = BUILT_IN_TYPE_DEFINITION << 1
+ static val N4JS = STRICT << 1
+ static val EXTERNAL = N4JS << 1
+ static val ALLOW_NESTED_FUNCTION_DECLARATION = EXTERNAL << 1
+ static val ALLOW_RETURN = ALLOW_NESTED_FUNCTION_DECLARATION << 1
+ static val ALLOW_CONTINUE = ALLOW_RETURN << 1
+ static val ALLOW_BREAK = ALLOW_CONTINUE << 1 // whether we are in "break-allowed-with/without-label" (for||while||switch-case||labelled-block) area
+ static val ALLOW_BREAK_WITHOUT_LABEL = ALLOW_BREAK << 1 // whether we are in (for||while||switch-case) area
+ static val ALLOW_VAR_WITHOUT_INITIALIZER = ALLOW_BREAK_WITHOUT_LABEL << 1
+ static val ALLOW_YIELD_EXPRESSION = ALLOW_VAR_WITHOUT_INITIALIZER << 1
+ static val ALLOW_SUPER = ALLOW_YIELD_EXPRESSION << 1
+ static val ALLOW_SUPER_CALL = ALLOW_SUPER << 1
+ static val IN_FUNCTION_DECLARATION = ALLOW_SUPER_CALL << 1
+
+ val int bits
+
+ def private static getIf(int value, boolean b) {
+ if (b) value else 0
+ }
+
+ new(boolean builtInTypeDefinition, boolean n4js, boolean external) {
+ this(
+ BUILT_IN_TYPE_DEFINITION.getIf(builtInTypeDefinition).bitwiseOr(
+ N4JS.getIf(n4js).bitwiseOr(
+ EXTERNAL.getIf(external).bitwiseOr(
+ ALLOW_VAR_WITHOUT_INITIALIZER.bitwiseOr(
+ ALLOW_YIELD_EXPRESSION
+ )
+ )
+ )
+ )
+ )
+ }
+
+ new(int bits) {
+ this.bits = bits
+ }
+
+ def private is(int bit) {
+ return this.bits.bitwiseAnd(bit) !== 0
+ }
+
+ def boolean isBuiltInTypeDefinition() {
+ return is(BUILT_IN_TYPE_DEFINITION)
+ }
+
+ def boolean isN4JS() {
+ return is(N4JS)
+ }
+
+ def boolean isStrict() {
+ return is(N4JS) || is(STRICT)
+ }
+
+ def boolean isExternal() {
+ return is(EXTERNAL)
+ }
+
+ def boolean isNestedFunctionAllowed() {
+ return is(ALLOW_NESTED_FUNCTION_DECLARATION)
+ }
+
+ def boolean isInFunctionDeclaration() {
+ return is(IN_FUNCTION_DECLARATION)
+ }
+
+ def boolean isReturnAllowed() {
+ return is(ALLOW_RETURN)
+ }
+
+ def boolean isBreakAllowed() {
+ return is(ALLOW_BREAK)
+ }
+
+ def boolean isBreakAllowedWithoutLabel() {
+ return is(ALLOW_BREAK_WITHOUT_LABEL)
+ }
+
+ def boolean isContinueAllowed() {
+ return is(ALLOW_CONTINUE)
+ }
+
+ def boolean isVarInitializerRequired() {
+ return !is(ALLOW_VAR_WITHOUT_INITIALIZER)
+ }
+
+ def boolean isYieldExpressionAllowed() {
+ return is(ALLOW_YIELD_EXPRESSION)
+ }
+
+ def boolean isSuperLiteralAllowed() {
+ return is(ALLOW_SUPER)
+ }
+
+ def boolean isSuperCallAllowed() {
+ return is(ALLOW_SUPER_CALL)
+ }
+
+ def Constraints with(int bit, boolean set) {
+ val newBits = if (set) {
+ this.bits.bitwiseOr(bit)
+ } else {
+ this.bits.bitwiseAnd(bit.bitwiseNot)
+ }
+ if (newBits === this.bits) {
+ return this
+ }
+ return new Constraints(newBits)
+ }
+
+ def Constraints strict(boolean strict) {
+ with(STRICT, strict)
+ }
+
+ def Constraints allowNestedFunctions(boolean allow) {
+ with(ALLOW_NESTED_FUNCTION_DECLARATION, allow)
+ }
+
+ def Constraints allowBreak(boolean allow) {
+ with(ALLOW_BREAK, allow)
+ }
+
+ def Constraints allowBreakWithoutLabel(boolean allow) {
+ with(ALLOW_BREAK_WITHOUT_LABEL, allow)
+ }
+
+ def Constraints allowContinue(boolean allow) {
+ with(ALLOW_CONTINUE, allow)
+ }
+
+ def Constraints allowReturn(boolean allow) {
+ with(ALLOW_RETURN, allow)
+ }
+
+ def Constraints allowVarWithoutInitializer(boolean allow) {
+ with(ALLOW_VAR_WITHOUT_INITIALIZER, allow)
+ }
+
+ def Constraints allowYieldExpression(boolean allow) {
+ with(ALLOW_YIELD_EXPRESSION, allow)
+ }
+
+ def Constraints allowSuperLiteral(boolean allow) {
+ if (!allow) {
+ allowSuperCall(false).with(ALLOW_SUPER, allow)
+ } else {
+ with(ALLOW_SUPER, allow)
+ }
+ }
+
+ def Constraints allowSuperCall(boolean allow) {
+ with(ALLOW_SUPER_CALL, allow)
+ }
+
+ def Constraints enterFunctionDeclaration() {
+ with(IN_FUNCTION_DECLARATION, true)
+ }
+
+ }
+
+ def void validate(EObject model, IDiagnosticConsumer consumer) {
+ val resource = model?.eResource;
+ if(resource !== null && !workspaceAccess.isNoValidate(resource, resource.getURI())) {
+ val producer = new ASTStructureDiagnosticProducer(consumer);
+ validateASTStructure(model, producer, Sets.newHashSetWithExpectedSize(2),
+ new Constraints(
+ N4Scheme.isResourceWithN4Scheme(resource),
+ jsVariantHelper.isN4JSMode(model),
+ jsVariantHelper.isExternalMode(model))
+ );
+ }
+ }
+
+ def private void recursiveValidateASTStructure(
+ EObject model,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ val content = model.eContents.iterator
+ var newStrict = constraints.isStrict
+ var first = true
+ while (content.hasNext()) {
+ val next = content.next();
+
+ // TODO this looks wrong: "strict mode" must be defined as first statement only!
+ // see IDE-163, also see JavaScriptVariant
+ // SZ: "use strict" must not be the first entry in the prolog, see test/language/directive-prologue/14.1-5gs.js
+ newStrict = newStrict || (first && isUseStrictProlog(model, next))
+ first = first && isProlog(next)
+ if (next instanceof StrictModeRelevant) {
+ next.setStrictMode(newStrict)
+ }
+ validateASTStructure(
+ next,
+ producer,
+ validLabels,
+ constraints.strict(newStrict)
+ )
+ }
+ }
+
+ def private isProlog(EObject object) {
+ if (object instanceof ExpressionStatement) {
+ return object.expression instanceof StringLiteral
+ }
+ return false
+ }
+
+ def private isUseStrictProlog(EObject model, EObject next) {
+ if (model instanceof Script || model instanceof Block && model.eContainer instanceof FunctionDefinition) {
+ switch (next) {
+ ExpressionStatement: {
+ switch it: next.expression {
+ StringLiteral: {
+ return BaseJavaScriptVariantHelper.STRICT_MODE_LITERAL_VALUE == value
+ }
+ }
+ }
+ }
+ }
+ return false
+ }
+
+ def private dispatch void validateASTStructure(
+ EObject model,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ recursiveValidateASTStructure(
+ model,
+ producer,
+ validLabels,
+ constraints
+ )
+ }
+
+ def private dispatch void validateASTStructure(
+ Script model,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ recursiveValidateASTStructure(
+ model,
+ producer,
+ validLabels,
+ constraints.strict(false).allowNestedFunctions(true).allowReturn(false).allowContinue(false).allowBreak(false).allowBreakWithoutLabel(false)
+ );
+ }
+
+ def private dispatch void validateASTStructure(
+ CoalesceExpression model,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ val container = model.eContainer
+ if (container instanceof BinaryLogicalExpression) {
+ val target = NodeModelUtils.findActualNodeFor(model)
+ producer.node = target
+ producer.addDiagnostic(
+ newDiagnosticMessage(IssueCodes.AST_INVALID_COALESCE_PARENT, container.op.literal)
+ );
+ } else if (model.expression instanceof BinaryLogicalExpression) {
+ val target = NodeModelUtils.findActualNodeFor(model.expression)
+ producer.node = target
+ producer.addDiagnostic(
+ newDiagnosticMessage(IssueCodes.AST_INVALID_COALESCE_CHILD, (model.expression as BinaryLogicalExpression).op.literal)
+ );
+ } else if (model.defaultExpression instanceof BinaryLogicalExpression) {
+ val target = NodeModelUtils.findActualNodeFor(model.defaultExpression)
+ producer.node = target
+ producer.addDiagnostic(
+ newDiagnosticMessage(IssueCodes.AST_INVALID_COALESCE_CHILD, (model.defaultExpression as BinaryLogicalExpression).op.literal)
+ );
+ }
+ recursiveValidateASTStructure(
+ model,
+ producer,
+ validLabels,
+ constraints
+ )
+ }
+
+ def private dispatch void validateASTStructure(
+ N4ClassifierDefinition model,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ if (model instanceof N4ClassifierDeclaration) {
+ if(model.name===null && !model.isExportedAsDefault) {
+ val target = NodeModelUtils.findActualNodeFor(model)
+ producer.node = target
+ producer.addDiagnostic(newDiagnosticMessage(IssueCodes.AST_TYPE_DECL_MISSING_NAME));
+ }
+ }
+
+ recursiveValidateASTStructure(
+ model,
+ producer,
+ validLabels,
+ // according to ecma6 spec, class bodies are always strict
+ constraints.strict(true).allowNestedFunctions(true).allowReturn(false).allowContinue(false).allowBreak(false).allowBreakWithoutLabel(false)
+ )
+ }
+
+ def private dispatch void validateASTStructure(
+ N4EnumDeclaration model,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ if(model.name===null && !model.isExportedAsDefault) {
+ val target = NodeModelUtils.findActualNodeFor(model)
+ producer.node = target
+ producer.addDiagnostic(newDiagnosticMessage(IssueCodes.AST_TYPE_DECL_MISSING_NAME));
+ }
+
+ if (model.literals.isEmpty) {
+ val target = NodeModelUtils.findActualNodeFor(model)
+ producer.node = target
+ producer.addDiagnostic(newDiagnosticMessage(IssueCodes.ENM_WITHOUT_LITERALS));
+ }
+
+ recursiveValidateASTStructure(
+ model,
+ producer,
+ validLabels,
+ // according to ecma6 spec, class bodies are always strict
+ constraints.strict(true).allowNestedFunctions(true).allowReturn(false).allowContinue(false).allowBreak(false).allowBreakWithoutLabel(false)
+ )
+ }
+
+ def private dispatch void validateASTStructure(
+ N4EnumLiteral model,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ if (!N4JSLanguageUtils.isEnumLiteralValueExpressionValid(model)) {
+ val nodes = NodeModelUtils.findNodesForFeature(model, N4JSPackage.eINSTANCE.n4EnumLiteral_ValueExpression);
+ producer.node = nodes.head;
+ producer.addDiagnostic(newDiagnosticMessage(IssueCodes.ENM_INVALID_VALUE_EXPRESSION));
+ }
+
+ recursiveValidateASTStructure(
+ model,
+ producer,
+ validLabels,
+ constraints
+ )
+ }
+
+ def private dispatch void validateASTStructure(
+ LegacyOctalIntLiteral model,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ if (constraints.isStrict) {
+ val target = NodeModelUtils.findActualNodeFor(model)
+ producer.node = target
+ producer.addDiagnostic(newDiagnosticMessage(IssueCodes.AST_STR_NO_OCTALS));
+ }
+ recursiveValidateASTStructure(
+ model,
+ producer,
+ validLabels,
+ constraints
+ )
+ }
+
+ def private dispatch void validateASTStructure(
+ NumericLiteralTypeRef model,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ if (constraints.isStrict) {
+ val node = NodeModelUtils.findNodesForFeature(model, TypeRefsPackage.Literals.LITERAL_TYPE_REF__AST_VALUE).head;
+ if (node !== null) {
+ val text = NodeModelUtils.getTokenText(node);
+ if (text.length() >= 2 && text.startsWith("0") && Character.isDigit(text.charAt(1))) {
+ producer.node = node;
+ producer.addDiagnostic(newDiagnosticMessage(IssueCodes.AST_STR_NO_OCTALS));
+ }
+ }
+ }
+
+ recursiveValidateASTStructure(
+ model,
+ producer,
+ validLabels,
+ constraints
+ )
+ }
+
+ def private dispatch void validateASTStructure(
+ StringLiteral model,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ if (constraints.isStrict) {
+ addErrorForOctalEscapeSequence(model.rawValue, model, N4JSPackage.Literals.STRING_LITERAL__VALUE, producer);
+ }
+ recursiveValidateASTStructure(
+ model,
+ producer,
+ validLabels,
+ constraints
+ )
+ }
+
+ def private dispatch void validateASTStructure(
+ TemplateSegment model,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ addErrorForOctalEscapeSequence(model.rawValue, model, N4JSPackage.Literals.TEMPLATE_SEGMENT__VALUE, producer);
+
+ recursiveValidateASTStructure(
+ model,
+ producer,
+ validLabels,
+ constraints
+ )
+ }
+
+ def private dispatch void validateASTStructure(
+ StringLiteralTypeRef model,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ val node = NodeModelUtils.findNodesForFeature(model, TypeRefsPackage.Literals.LITERAL_TYPE_REF__AST_VALUE).head;
+ if (node !== null) {
+ val text = NodeModelUtils.getTokenText(node);
+ addErrorForOctalEscapeSequence(text, model, TypeRefsPackage.Literals.LITERAL_TYPE_REF__AST_VALUE, producer);
+ }
+
+ recursiveValidateASTStructure(
+ model,
+ producer,
+ validLabels,
+ constraints
+ )
+ }
+
+ def private addErrorForOctalEscapeSequence(String rawValue, EObject model, EAttribute valueEAttribute, ASTStructureDiagnosticProducer producer) {
+ val nodes = NodeModelUtils.findNodesForFeature(model, valueEAttribute);
+ val target = nodes.head;
+ val syntaxError = target.syntaxErrorMessage;
+ if ((syntaxError === null || syntaxError.issueCode == WARN_ISSUE_CODE || syntaxError.issueCode == InternalSemicolonInjectingParser.SEMICOLON_INSERTED) && rawValue.hasOctalEscapeSequence) {
+ producer.node = target;
+ producer.addDiagnostic(newDiagnosticMessage(IssueCodes.AST_STR_NO_OCTALS));
+ }
+ }
+
+ def private dispatch void validateASTStructure(
+ PostfixExpression model,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ recursiveValidateASTStructure(
+ model,
+ producer,
+ validLabels,
+ constraints
+ )
+ val child = model.expression
+ if (!child.isValidSimpleAssignmentTarget) {
+ val nodes = NodeModelUtils.findNodesForFeature(model, N4JSPackage.Literals.POSTFIX_EXPRESSION__EXPRESSION)
+ val target = nodes.head
+ producer.node = target
+ val operand = if (model.op == PostfixOperator.DEC) 'decrement' else 'increment'
+ producer.addDiagnostic(newDiagnosticMessage(IssueCodes.AST_INVALID_OPERAND, operand));
+ }
+ }
+
+ def private dispatch void validateASTStructure(
+ UnaryExpression model,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ recursiveValidateASTStructure(
+ model,
+ producer,
+ validLabels,
+ constraints
+ )
+ if (model.op == UnaryOperator.DEC || model.op == UnaryOperator.INC) {
+ val child = model.expression
+ if (child!==null && !child.isValidSimpleAssignmentTarget) {
+ val nodes = NodeModelUtils.findNodesForFeature(model,
+ N4JSPackage.Literals.POSTFIX_EXPRESSION__EXPRESSION)
+ val target = nodes.head
+ producer.node = target
+ val operand = if (model.op == UnaryOperator.DEC) 'decrement' else 'increment'
+ producer.addDiagnostic(newDiagnosticMessage(IssueCodes.AST_INVALID_OPERAND, operand));
+ }
+ }
+ }
+
+ def private dispatch void validateASTStructure(
+ YieldExpression model,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ if (!constraints.isYieldExpressionAllowed) {
+ val target = NodeModelUtils.findActualNodeFor(model)
+ producer.node = target
+ producer.addDiagnostic(newDiagnosticMessage(IssueCodes.AST_INVALID_YIELD_EXPRESSION));
+ }
+ recursiveValidateASTStructure(
+ model,
+ producer,
+ validLabels,
+ constraints
+ )
+ }
+
+ def private dispatch void validateASTStructure(
+ AssignmentExpression model,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ // first validate the children to make sure strictMode flag was set
+ recursiveValidateASTStructure(
+ model,
+ producer,
+ validLabels,
+ constraints
+ )
+ if (model.lhs !== null && !N4JSLanguageUtils.hasValidLHS(model)) {
+ val nodes = NodeModelUtils.findNodesForFeature(model, N4JSPackage.Literals.ASSIGNMENT_EXPRESSION__LHS)
+ val target = nodes.head
+ producer.node = target
+ producer.addDiagnostic(newDiagnosticMessage(IssueCodes.AST_EXP_INVALID_LHS_ASS));
+ }
+ }
+
+ def private dispatch void validateASTStructure(
+ ParameterizedCallExpression model,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ if (N4JSLanguageUtils.isDynamicImportCall(model)) {
+ if (!model.arguments.empty && model.arguments.get(0).isSpread) {
+ val target = NodeModelUtils.findActualNodeFor(model.arguments.get(0));
+ producer.node = target;
+ producer.addDiagnostic(newDiagnosticMessage(IssueCodes.AST_IMPORT_CALL_SPREAD));
+ }
+ }
+ recursiveValidateASTStructure(
+ model,
+ producer,
+ validLabels,
+ constraints
+ )
+ }
+
+ def private dispatch void validateASTStructure(
+ IdentifierRef model,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ val name = model.idAsText
+ if (name !== null) {
+ if (constraints.isStrict && (RESERVED_WORDS_IN_STRICT_MODE.contains(name))) {
+ if (name == IMPORT_KEYWORD && 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) {
+ val grandParent = model.eContainer?.eContainer;
+ if (grandParent instanceof ExportDeclaration) {
+ if (grandParent.exportedElement === null && !grandParent.isReexport) {
+ val target = NodeModelUtils.findActualNodeFor(model);
+ producer.node = target;
+ producer.addDiagnostic(
+ newDiagnosticMessage(IssueCodes.AST_SEPARATE_DEFAULT_EXPORT_WITHOUT_FROM));
+ }
+ }
+ }
+ }
+ recursiveValidateASTStructure(
+ model,
+ producer,
+ validLabels,
+ constraints
+ )
+ }
+
+ def private dispatch void validateASTStructure(
+ AbstractVariable> model,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ val name = model.name
+ if (name !== null) {
+ if (name == LOCAL_ARGUMENTS_VARIABLE_NAME) {
+ val 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)
+ || 'enum'.equals(name) || 'await'.equals(name)
+ || 'true'.equals(name) || 'false'.equals(name) || 'null'.equals(name))) {
+
+ if (constraints.isBuiltInTypeDefinition() && 'import'.equals(name)) {
+ // ignore
+ } else {
+ issueNameDiagnostic(model, producer, name)
+ }
+ } else if (constraints.isStrict) {
+ if (RESERVED_WORDS_IN_STRICT_MODE.contains(name) || name == EVAL_NAME) {
+ issueNameDiagnostic(model, producer, name)
+ model.name = null; // do not pollute scope
+ }
+ }
+ }
+ }
+ recursiveValidateASTStructure(
+ model,
+ producer,
+ validLabels,
+ constraints
+ )
+ }
+
+ def private dispatch void validateASTStructure(
+ WithStatement model,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ if (constraints.isStrict) {
+ val node = NodeModelUtils.findActualNodeFor(model).leafNodes.findFirst[ grammarElement == grammarAccess.withStatementAccess.withKeyword_0 ]
+ producer.node = node
+ if(node !== null) {
+ producer.addDiagnostic(newDiagnosticMessage(IssueCodes.AST_STR_NO_WITH_STMT));
+ }
+ }
+ recursiveValidateASTStructure(
+ model,
+ producer,
+ validLabels,
+ constraints
+ )
+ }
+
+ def private dispatch void validateASTStructure(
+ LabelledStatement model,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ val name = model.name
+ if (name !== null) {
+ if (constraints.isStrict && (RESERVED_WORDS_IN_STRICT_MODE.contains(name))) {
+ issueNameDiagnostic(model, producer, name)
+ model.name = null; // do not pollute scope
+ }
+ }
+ try {
+ validLabels.add(model)
+ recursiveValidateASTStructure(
+ model,
+ producer,
+ validLabels,
+ constraints.allowNestedFunctions(!constraints.isStrict).allowBreak(true)
+ )
+ } finally {
+ validLabels.remove(model)
+ }
+ }
+
+ def private dispatch void validateASTStructure(
+ Block model,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ validateBlockStructure(
+ model.eContainer,
+ model,
+ producer,
+ validLabels,
+ constraints
+ )
+ }
+
+ def private dispatch void validateBlockStructure(
+ IfStatement container,
+ Block model,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ recursiveValidateASTStructure(
+ model,
+ producer,
+ validLabels,
+ constraints
+ )
+ }
+
+ def private dispatch void validateBlockStructure(
+ IterationStatement container,
+ Block model,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ recursiveValidateASTStructure(
+ model,
+ producer,
+ validLabels,
+ constraints.allowNestedFunctions(!constraints.isStrict && !constraints.isInFunctionDeclaration)
+ )
+ }
+
+ def private dispatch void validateBlockStructure(
+ FunctionDefinition container,
+ Block model,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ recursiveValidateASTStructure(
+ model,
+ producer,
+ validLabels,
+ constraints.allowNestedFunctions(true)
+ )
+ }
+
+ def private dispatch void validateBlockStructure(
+ CatchBlock container,
+ Block model,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ recursiveValidateASTStructure(
+ model,
+ producer,
+ validLabels,
+ constraints.allowNestedFunctions(true)
+ )
+ }
+
+ def private dispatch void validateBlockStructure(
+ EObject container,
+ Block model,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ recursiveValidateASTStructure(
+ model,
+ producer,
+ validLabels,
+ constraints.allowNestedFunctions(!constraints.isStrict)
+ )
+ }
+
+ def private dispatch void validateASTStructure(
+ IfStatement model,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ recursiveValidateASTStructure(
+ model,
+ producer,
+ validLabels,
+ constraints.allowNestedFunctions(!constraints.isStrict && !constraints.isInFunctionDeclaration)
+ )
+ }
+
+ def private dispatch void validateASTStructure(
+ AbstractCaseClause model,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ recursiveValidateASTStructure(
+ model,
+ producer,
+ validLabels,
+ constraints.allowBreak(true).allowBreakWithoutLabel(true)
+ )
+ }
+
+ def private dispatch void validateASTStructure(
+ ForStatement model,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ if (model.isAwait && !model.isForOf) {
+ val nodes = NodeModelUtils.findNodesForFeature(model, N4JSPackage.Literals.FOR_STATEMENT__AWAIT);
+ val target = nodes.head ?: NodeModelUtils.findActualNodeFor(model);
+ if (target !== null) {
+ producer.node = target;
+ producer.addDiagnostic(newDiagnosticMessage(IssueCodes.AST_INVALID_FOR_AWAIT));
+ }
+ }
+ if (!model.isForPlain) {
+ if (! model.varDeclsOrBindings.empty) {
+ model.varDecl.forEach[ varDecl |
+ if (varDecl.expression !== null && !(varDecl.eContainer instanceof BindingElement) && (constraints.isStrict || model.varStmtKeyword === VariableStatementKeyword.LET)) {
+ val nodes = NodeModelUtils.findNodesForFeature(varDecl, N4JSPackage.Literals.VARIABLE_DECLARATION__EXPRESSION)
+ val target = nodes.head ?: NodeModelUtils.findActualNodeFor(varDecl)
+ producer.node = target
+ if(target !== null) {
+ producer.addDiagnostic(
+ new DiagnosticMessage(IssueCodes.AST_VAR_DECL_IN_FOR_INVALID_INIT.getMessage(),
+ if (constraints.isStrict || model.isForIn) IssueCodes.AST_VAR_DECL_IN_FOR_INVALID_INIT.severity else Severity.WARNING,
+ IssueCodes.AST_VAR_DECL_IN_FOR_INVALID_INIT.name()))
+ }
+ } else if (model.varStmtKeyword === VariableStatementKeyword.LET && varDecl.name == 'let') {
+ val nodes = NodeModelUtils.findNodesForFeature(varDecl, N4JSPackage.Literals.ABSTRACT_VARIABLE__NAME)
+ val target = nodes.head ?: NodeModelUtils.findActualNodeFor(varDecl)
+ producer.node = target
+ if(target !== null) {
+ producer.addDiagnostic(newDiagnosticMessage(IssueCodes.AST_RESERVED_IDENTIFIER, varDecl.name));
+ }
+ }
+ ]
+ } else if (model.initExpr!==null) {
+ val initExpr = model.initExpr;
+ if (initExpr instanceof AssignmentExpression) {
+ val nodes = NodeModelUtils.findNodesForFeature(initExpr,
+ TypesPackage.Literals.IDENTIFIABLE_ELEMENT__NAME)
+ val target = nodes.head ?: NodeModelUtils.findActualNodeFor(initExpr)
+ producer.node = target
+ if (target !== null) {
+ producer.addDiagnostic(newDiagnosticMessage(IssueCodes.AST_VAR_DECL_IN_FOR_INVALID_INIT));
+ }
+ } else if(!initExpr.isValidSimpleAssignmentTarget && !model.isTopOfDestructuringForStatement) {
+ val nodes = NodeModelUtils.findNodesForFeature(model,
+ N4JSPackage.Literals.FOR_STATEMENT__INIT_EXPR)
+ val target = nodes.head ?: NodeModelUtils.findActualNodeFor(initExpr)
+ producer.node = target
+ if (target !== null) {
+ producer.addDiagnostic(newDiagnosticMessage(IssueCodes.AST_EXP_INVALID_LHS_ASS));
+ }
+ }
+ }
+ }
+ recursiveValidateASTStructure(
+ model,
+ producer,
+ validLabels,
+ constraints.allowNestedFunctions(!constraints.isStrict && !constraints.isInFunctionDeclaration).allowBreak(true).allowContinue(true).allowBreakWithoutLabel(true)
+ )
+ }
+
+ def private dispatch void validateASTStructure(
+ IterationStatement model,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ recursiveValidateASTStructure(
+ model,
+ producer,
+ validLabels,
+ constraints.allowNestedFunctions(!constraints.isStrict && !constraints.isInFunctionDeclaration).allowBreak(true).allowContinue(true).allowBreakWithoutLabel(true)
+ )
+ }
+
+ def private dispatch void validateASTStructure(
+ FormalParameter model,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ val container = model.eContainer
+ var allowYieldInInit = false
+ if (container instanceof FunctionDefinition) {
+ allowYieldInInit = !container.isGenerator
+
+ val issueConsumer = [String msg, String id, EObject eObj |
+ producer.node = NodeModelUtils.findActualNodeFor(eObj);
+ producer.addDiagnostic(new DiagnosticMessage(msg, IssueCodes.getSeverityForName(id), id));
+ ];
+ internalCheckFormalParameter(
+ container.fpars,
+ model,
+ [variadic],
+ [hasInitializerAssignment],
+ issueConsumer
+ );
+ }
+
+ _validateASTStructure(
+ model as AbstractVariable>,
+ producer,
+ validLabels,
+ constraints.allowYieldExpression(allowYieldInInit)
+ )
+ }
+
+ def private dispatch void validateASTStructure(
+ NewTarget model,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ if (EcoreUtil2.getContainerOfType(model, FunctionDefinition) === null) {
+ val target = NodeModelUtils.findActualNodeFor(model)
+ if(target !== null) {
+ producer.node = target
+ producer.addDiagnostic(newDiagnosticMessage(IssueCodes.AST_INVALID_NEW_TARGET));
+ }
+ }
+ recursiveValidateASTStructure(
+ model,
+ producer,
+ validLabels,
+ constraints
+ )
+ }
+
+ def private dispatch void validateASTStructure(
+ SuperLiteral model,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ if (model.isInvalidSuperLiteral(constraints)) {
+
+ val target = NodeModelUtils.findActualNodeFor(model)
+ if(target !== null) {
+ producer.node = target
+ if (model.eContainingFeature === N4JSPackage.Literals.EXPRESSION_WITH_TARGET__TARGET && model.eContainer instanceof ParameterizedCallExpression) {
+ producer.addDiagnostic(newDiagnosticMessage(IssueCodes.KEY_SUP_CTOR_INVALID_LOC));
+ } else if (EcoreUtil2.getContainerOfType(model, N4MethodDeclaration) === null) {
+ producer.addDiagnostic(newDiagnosticMessage(IssueCodes.KEY_SUP_ACCESS_INVALID_LOC));
+ } else {
+ val containingClass = EcoreUtil2.getContainerOfType(model, N4ClassifierDeclaration)
+ if (containingClass instanceof N4InterfaceDeclaration) {
+ producer.addDiagnostic(newDiagnosticMessage(IssueCodes.KEY_SUP_ACCESS_INVALID_LOC_INTERFACE));
+ } else if (containingClass !== null) {
+ if (!constraints.isN4JS) { // implicit super type only available in n4js
+ producer.addDiagnostic(newDiagnosticMessage(IssueCodes.KEY_SUP_ACCESS_NO_EXTENDS));
+ }
+ } else {
+ throw new IllegalStateException('a')
+ }
+ }
+ }
+
+ }
+ recursiveValidateASTStructure(
+ model,
+ producer,
+ validLabels,
+ constraints
+ )
+ }
+
+ def private boolean isInvalidSuperLiteral(SuperLiteral model, Constraints constraints) {
+ if (!model.isValidContainment) {
+ return true
+ }
+ if (!constraints.isSuperLiteralAllowed) {
+ return true
+ }
+ if (!constraints.isSuperCallAllowed) {
+ return model.eContainer instanceof ParameterizedCallExpression
+ }
+ return false
+ }
+
+ def private boolean isValidContainment(SuperLiteral literal) {
+ val container = literal.eContainer
+ return container instanceof IndexedAccessExpression || container instanceof ParameterizedCallExpression || container instanceof ParameterizedPropertyAccessExpression
+ }
+
+ def private dispatch void validateASTStructure(
+ FunctionDeclaration model,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ validateFunctionDefinition(
+ model,
+ N4JSPackage.Literals.FUNCTION_DECLARATION__NAME,
+ constraints.enterFunctionDeclaration,
+ model.name,
+ producer,
+ validLabels
+ )
+ }
+
+ def private dispatch void validateASTStructure(
+ FunctionExpression model,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ val name = model.name
+ if (name !== null) {
+ if (name == LOCAL_ARGUMENTS_VARIABLE_NAME) {
+ issueArgumentsError(model, name, constraints.isStrict, producer)
+ } else if (constraints.isStrict()) {
+ if (RESERVED_WORDS_IN_STRICT_MODE.contains(name) || name == EVAL_NAME) {
+ issueNameDiagnostic(model, producer, name)
+ model.name = null; // do not pollute scope
+ }
+ }
+ }
+ recursiveValidateASTStructure(
+ model,
+ producer,
+ Sets.newHashSetWithExpectedSize(2),
+ constraints.allowNestedFunctions(true).allowReturn(true).allowBreak(false).allowContinue(false).allowBreakWithoutLabel(false)
+ )
+ }
+
+ def private void validateFunctionDefinition(
+ FunctionDefinition model,
+ EAttribute attribute,
+ Constraints constraints,
+ String name,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels
+ ) {
+ if (!constraints.isNestedFunctionAllowed) {
+ val nodes = NodeModelUtils.findNodesForFeature(model, attribute)
+ val target = nodes.head ?: NodeModelUtils.findActualNodeFor(model)
+ producer.node = target
+
+ // TODO improve error message
+ producer.addDiagnostic(newDiagnosticMessage(IssueCodes.AST_STR_FUN_NOT_NESTED));
+ } else if (name !== null) {
+ if (name == LOCAL_ARGUMENTS_VARIABLE_NAME) {
+ issueArgumentsError(model, name, constraints.isStrict, producer)
+ } else if (constraints.isStrict()) {
+ if (RESERVED_WORDS_IN_STRICT_MODE.contains(name) || name == EVAL_NAME) {
+ issueNameDiagnostic(model, producer, name)
+ }
+ }
+ }
+ recursiveValidateASTStructure(
+ model,
+ producer,
+ Sets.newHashSetWithExpectedSize(2),
+ constraints.allowNestedFunctions(true).allowReturn(true).allowContinue(false).allowBreak(false).allowYieldExpression(true).allowBreakWithoutLabel(false)
+ )
+ }
+
+ def private void validateName(PropertyNameOwner model, Constraints constraints, ASTStructureDiagnosticProducer producer) {
+ val name = model.name
+ if (name !== null) {
+ if (!model.isValidName
+ && !constraints.isBuiltInTypeDefinition) {
+ issueNameDiagnostic(model, producer, name)
+ } else {
+ if (constraints.isN4JS) {
+ if (RESERVED_WORDS_IN_STRICT_MODE.contains(name)) {
+ issueNameDiagnostic(model, producer, name)
+ }
+ } else if (constraints.isStrict) {
+ if (RESERVED_WORDS_IN_STRICT_MODE.contains(name)) {
+ issueNameDiagnostic(model, producer, name, getNameFeature(model), Severity.WARNING)
+ }
+ }
+ }
+ }
+ }
+
+ def private void issueArgumentsError(EObject model, String name, boolean strict, ASTStructureDiagnosticProducer producer) {
+ issueNameDiagnostic(model, producer, name, getNameFeature(model), if (strict) Severity.ERROR else Severity.WARNING);
+ }
+
+ def private void issueNameDiagnostic(EObject model, ASTStructureDiagnosticProducer producer, String name) {
+ issueNameDiagnostic(model, producer, name, getNameFeature(model), IssueCodes.AST_RESERVED_IDENTIFIER.severity)
+ }
+
+ def private void issueNameDiagnostic(EObject model, ASTStructureDiagnosticProducer producer, String name, EStructuralFeature feature, Severity severity) {
+ val nodes = NodeModelUtils.findNodesForFeature(model, feature)
+ val target = nodes.head ?: NodeModelUtils.findActualNodeFor(model)
+ producer.node = target
+ if(target !== null) {
+ producer.addDiagnostic(
+ new DiagnosticMessage(IssueCodes.AST_RESERVED_IDENTIFIER.getMessage(name),
+ severity,
+ IssueCodes.AST_RESERVED_IDENTIFIER.name()))
+ }
+ }
+
+ def private EStructuralFeature getNameFeature(EObject model) {
+ return model.eClass.getEStructuralFeature('name') ?: model.eClass.getEStructuralFeature('declaredName');
+ }
+
+ def private dispatch void validateASTStructure(
+ N4FieldAccessor model,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ model.validateName(constraints, producer)
+ recursiveValidateASTStructure(
+ model,
+ producer,
+ Sets.newHashSetWithExpectedSize(2),
+ constraints.allowReturn(true).allowSuperLiteral(true).allowSuperCall(false)
+ )
+ }
+
+ def private dispatch void validateASTStructure(
+ MethodDeclaration model,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ model.validateName(constraints, producer)
+ recursiveValidateASTStructure(
+ model,
+ producer,
+ Sets.newHashSetWithExpectedSize(2),
+ constraints.allowReturn(true).allowSuperLiteral(true).allowSuperCall(model.name == 'constructor' && !model.isStatic && model.canCallSuperConstructor(constraints))
+ )
+ }
+
+ def private boolean canCallSuperConstructor(MethodDeclaration declaration, Constraints constraints) {
+ val container = declaration.eContainer
+ if (container instanceof N4ClassDefinition) {
+ if (constraints.isN4JS) {
+ return true
+ }
+ return container.superClassRef !== null || container.superClassExpression !== null
+ }
+ return false
+ }
+
+ def private dispatch void validateASTStructure(
+ FieldAccessor model,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ model.validateName(constraints, producer)
+ recursiveValidateASTStructure(
+ model,
+ producer,
+ Sets.newHashSetWithExpectedSize(2),
+ constraints.allowReturn(true).allowSuperLiteral(true).allowSuperCall(false)
+ )
+ }
+
+ def private dispatch void validateASTStructure(
+ PropertyAssignment model,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ recursiveValidateASTStructure(
+ model,
+ producer,
+ Sets.newHashSetWithExpectedSize(2),
+ constraints.allowNestedFunctions(false).allowReturn(true).allowContinue(false).allowBreak(false).allowYieldExpression(true).allowBreakWithoutLabel(false)
+ )
+ }
+
+ def private dispatch void validateASTStructure(
+ ReturnStatement model,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ if (!constraints.isReturnAllowed) {
+ val target = NodeModelUtils.findActualNodeFor(model)
+ producer.node = target
+ producer.addDiagnostic(newDiagnosticMessage(IssueCodes.AST_INVALID_RETURN));
+ }
+ recursiveValidateASTStructure(
+ model,
+ producer,
+ validLabels,
+ constraints
+ )
+ }
+
+ def private dispatch void validateASTStructure(
+ ContinueStatement model,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ if (!constraints.isContinueAllowed) {
+ val target = NodeModelUtils.findActualNodeFor(model)
+ producer.node = target
+ producer.addDiagnostic(newDiagnosticMessage(IssueCodes.AST_INVALID_CONTINUE));
+ } else {
+ validateLabelRef(model, producer, validLabels)
+ }
+ recursiveValidateASTStructure(
+ model,
+ producer,
+ validLabels,
+ constraints
+ )
+ }
+
+ def private dispatch void validateASTStructure(
+ BreakStatement model,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ if (!constraints.isBreakAllowed
+ || (!validateLabelRef(model, producer, validLabels) && !constraints.isBreakAllowedWithoutLabel)
+ ) {
+ val target = NodeModelUtils.findActualNodeFor(model)
+ producer.node = target
+ producer.addDiagnostic(newDiagnosticMessage(IssueCodes.AST_INVALID_BREAK));
+ }
+ recursiveValidateASTStructure(
+ model,
+ producer,
+ validLabels,
+ constraints
+ )
+ }
/*
* @returns whether there is a label
*/
- def private boolean validateLabelRef(LabelRef model, ASTStructureDiagnosticProducer producer,
- Set validLabels
- ) {
- val labelAsText = model.labelAsText; // cannot use model.label, because we aren't allowed to resolve proxies in this phase!
- if (labelAsText !== null && !validLabels.exists[it.name==labelAsText]) {
- val target = NodeModelUtils.findActualNodeFor(model)
- producer.node = target
- producer.addDiagnostic(
- new DiagnosticMessage(IssueCodes.getMessageForAST_INVALID_LABEL,
- IssueCodes.getDefaultSeverity(IssueCodes.AST_INVALID_LABEL), IssueCodes.AST_INVALID_LABEL))
- }
- return labelAsText !== null
- }
-
- def private dispatch void validateASTStructure(
- Expression model,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- recursiveValidateASTStructure(
- model,
- producer,
- validLabels,
- constraints
- )
- }
-
- def private dispatch void validateASTStructure(
- ArrayElement model,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- recursiveValidateASTStructure(
- model,
- producer,
- validLabels,
- constraints
- )
-
- validateExpressionInArrayOrObjectLiteral(model, constraints, producer);
- validateSpreadInArrayLiteral(model, producer);
- }
-
- /** @param elem must be an ArrayElement or PropertyNameValuePair. */
- def private void validateExpressionInArrayOrObjectLiteral(EObject elem, Constraints constraints, ASTStructureDiagnosticProducer producer) {
- if(!(elem instanceof ArrayElement || elem instanceof PropertyNameValuePair || elem instanceof PropertyMethodDeclaration)) {
- throw new IllegalArgumentException();
- }
- if(elem instanceof PropertyNameValuePairSingleName) {
- val identifier = elem.identifierRef
- if (identifier !== null && !identifier.isValidSimpleAssignmentTarget) {
- producer.node = NodeModelUtils.findActualNodeFor(identifier)
- producer.addDiagnostic(
- new DiagnosticMessage(IssueCodes.getMessageForAST_INVALID_EXPR_IN_LHS_DESTRUCTURING_PATTERN,
- IssueCodes.getDefaultSeverity(IssueCodes.AST_INVALID_EXPR_IN_LHS_DESTRUCTURING_PATTERN), IssueCodes.AST_INVALID_EXPR_IN_LHS_DESTRUCTURING_PATTERN))
- }
- // more validation not required in this case, because expression has a different meaning and problem cannot occur
- return;
- }
- if(elem!==null && DestructureUtils.isArrayOrObjectLiteralUsedAsDestructuringPattern(elem.eContainer)) {
- if(elem instanceof PropertyMethodDeclaration) {
- // methods are not allowed at all in a destructuring pattern
- producer.node = NodeModelUtils.findActualNodeFor(elem)
- producer.addDiagnostic(
- new DiagnosticMessage(IssueCodes.getMessageForAST_INVALID_PROPERTY_METHOD_IN_LHS_DESTRUCTURING_PATTERN,
- IssueCodes.getDefaultSeverity(IssueCodes.AST_INVALID_PROPERTY_METHOD_IN_LHS_DESTRUCTURING_PATTERN), IssueCodes.AST_INVALID_PROPERTY_METHOD_IN_LHS_DESTRUCTURING_PATTERN))
- } else {
- val expr = switch(elem) {
- ArrayElement: elem.expression
- PropertyNameValuePair: elem.expression
- };
- if(expr!==null && !expr.isValidBindingElement(constraints)) {
- producer.node = NodeModelUtils.findActualNodeFor(expr)
- producer.addDiagnostic(
- new DiagnosticMessage(IssueCodes.getMessageForAST_INVALID_EXPR_IN_LHS_DESTRUCTURING_PATTERN,
- IssueCodes.getDefaultSeverity(IssueCodes.AST_INVALID_EXPR_IN_LHS_DESTRUCTURING_PATTERN), IssueCodes.AST_INVALID_EXPR_IN_LHS_DESTRUCTURING_PATTERN))
- }
- }
- }
- }
-
- def private isValidBindingElement(Expression expr, Constraints constraints) {
- if (constraints.isN4JS) {
- return (expr.isValidSimpleAssignmentTarget && expr instanceof IdentifierRef)
- || expr instanceof AssignmentExpression
- || expr instanceof ArrayLiteral
- || expr instanceof ObjectLiteral
- } else {
- return expr.isValidSimpleAssignmentTarget
- || expr instanceof AssignmentExpression
- || expr instanceof ArrayLiteral
- || expr instanceof ObjectLiteral
- }
- }
-
- def private void validateSpreadInArrayLiteral(ArrayElement elem, ASTStructureDiagnosticProducer producer) {
- if(elem!==null && elem.spread) {
- if(!DestructureUtils.isArrayOrObjectLiteralUsedAsDestructuringPattern(elem.eContainer)) {
- // use of spread in an array literal that is *not* used as a destructuring pattern
- // --> valid at any position
- }
- else {
- // use of spread in an array literal that *is* used as a destructuring pattern
- // --> error if not at end of array literal
- val lit = elem.eContainer;
- if(lit instanceof ArrayLiteral) {
- if(lit.elements.last!==elem || lit.trailingComma) {
- val nodes = NodeModelUtils.findNodesForFeature(elem, N4JSPackage.eINSTANCE.arrayElement_Spread);
- producer.node = nodes.head ?: NodeModelUtils.findActualNodeFor(elem)
- producer.addDiagnostic(
- new DiagnosticMessage(IssueCodes.getMessageForAST_REST_MUST_APPEAR_AT_END,
- IssueCodes.getDefaultSeverity(IssueCodes.AST_REST_MUST_APPEAR_AT_END), IssueCodes.AST_REST_MUST_APPEAR_AT_END))
- }
-
- if (elem.expression instanceof AssignmentExpression) {
- val nodes = NodeModelUtils.findNodesForFeature(elem.expression, N4JSPackage.eINSTANCE.assignmentExpression_Rhs);
- producer.node = nodes.head ?: NodeModelUtils.findActualNodeFor(elem.expression)
- producer.addDiagnostic(
- new DiagnosticMessage(IssueCodes.getMessageForAST_REST_WITH_INITIALIZER,
- IssueCodes.getDefaultSeverity(IssueCodes.AST_REST_WITH_INITIALIZER), IssueCodes.AST_REST_WITH_INITIALIZER))
- }
- }
- }
- }
- }
-
- def private dispatch void validateASTStructure(
- PropertyNameValuePair model,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- recursiveValidateASTStructure(
- model,
- producer,
- validLabels,
- constraints.allowYieldExpression(true)
- )
-
- validateExpressionInArrayOrObjectLiteral(model, constraints, producer);
- validateSingleNameInObjectLiteral(model, producer);
- }
-
- def private dispatch void validateASTStructure(
- PropertyMethodDeclaration model,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- recursiveValidateASTStructure(
- model,
- producer,
- validLabels,
- constraints.allowReturn(true).allowSuperLiteral(true).allowSuperCall(false).allowYieldExpression(true)
- )
-
- validateExpressionInArrayOrObjectLiteral(model, constraints, producer);
- }
-
- def private void validateSingleNameInObjectLiteral(PropertyNameValuePair elem, ASTStructureDiagnosticProducer producer) {
- if(elem instanceof PropertyNameValuePairSingleName
- && !DestructureUtils.isArrayOrObjectLiteralUsedAsDestructuringPattern(elem.eContainer)
- && elem.expression instanceof AssignmentExpression) {
-
- val nodes = NodeModelUtils.findNodesForFeature(elem.expression, N4JSPackage.Literals.ASSIGNMENT_EXPRESSION__RHS)
- producer.node = nodes.head ?: NodeModelUtils.findActualNodeFor(elem.expression)
- producer.addDiagnostic(
- new DiagnosticMessage(IssueCodes.getMessageForAST_INVALID_DEFAULT_EXPR_SINGLE_NAME_PROPERTY,
- IssueCodes.getDefaultSeverity(IssueCodes.AST_INVALID_DEFAULT_EXPR_SINGLE_NAME_PROPERTY), IssueCodes.AST_INVALID_DEFAULT_EXPR_SINGLE_NAME_PROPERTY))
- }
- }
-
- def private dispatch void validateASTStructure(
- VariableStatement model,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- if (model.varStmtKeyword === VariableStatementKeyword.CONST) {
- if (!model.isValidConstOrLetPosition) {
- val nodes = NodeModelUtils.findNodesForFeature(model, N4JSPackage.Literals.VARIABLE_DECLARATION_CONTAINER__VAR_STMT_KEYWORD)
- producer.node = nodes.head ?: NodeModelUtils.findActualNodeFor(model)
- producer.addDiagnostic(
- new DiagnosticMessage(IssueCodes.messageForAST_CONST_IN_STATEMENT_POSITION,
- IssueCodes.getDefaultSeverity(IssueCodes.AST_CONST_IN_STATEMENT_POSITION),
- IssueCodes.AST_CONST_IN_STATEMENT_POSITION))
- }
- } else if (model.varStmtKeyword === VariableStatementKeyword.LET) {
- if (!model.isValidConstOrLetPosition) {
- val nodes = NodeModelUtils.findNodesForFeature(model, N4JSPackage.Literals.VARIABLE_DECLARATION_CONTAINER__VAR_STMT_KEYWORD)
- producer.node = nodes.head ?: NodeModelUtils.findActualNodeFor(model)
- producer.addDiagnostic(
- new DiagnosticMessage(IssueCodes.messageForAST_LET_IN_STATEMENT_POSITION,
- IssueCodes.getDefaultSeverity(IssueCodes.AST_LET_IN_STATEMENT_POSITION),
- IssueCodes.AST_LET_IN_STATEMENT_POSITION))
- }
- }
- if (model.varDeclsOrBindings.empty) {
- val nodes = NodeModelUtils.findNodesForFeature(model, N4JSPackage.Literals.VARIABLE_DECLARATION_CONTAINER__VAR_STMT_KEYWORD)
- producer.node = nodes.head ?: NodeModelUtils.findActualNodeFor(model)
- producer.addDiagnostic(
- new DiagnosticMessage(IssueCodes.messageForAST_VAR_STMT_NO_DECL,
- IssueCodes.getDefaultSeverity(IssueCodes.AST_VAR_STMT_NO_DECL),
- IssueCodes.AST_VAR_STMT_NO_DECL))
- }
- val directParent = model.eContainer;
- val parent = if(directParent instanceof ExportDeclaration) directParent.eContainer else directParent;
- recursiveValidateASTStructure(
- model,
- producer,
- validLabels,
- constraints.allowVarWithoutInitializer(model.varStmtKeyword === VariableStatementKeyword.VAR || model.varStmtKeyword === VariableStatementKeyword.LET &&
- (parent instanceof Block || parent instanceof Script || parent instanceof AbstractCaseClause)
- )
- )
- }
-
- def private boolean isValidConstOrLetPosition(EObject model) {
- if (model.eContainer instanceof Block
- || model.eContainer instanceof Script
- || model.eContainer instanceof AbstractCaseClause
- || model.eContainer instanceof N4NamespaceDeclaration
- ) {
- return true
- }
- if (model.eContainer instanceof ExportDeclaration) {
- return model.eContainer.isValidConstOrLetPosition
- }
- return false
- }
-
- def private dispatch void validateASTStructure(
- VariableDeclaration model,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- if (model.expression === null && constraints.isVarInitializerRequired && !constraints.external) {
- val nodes = NodeModelUtils.findNodesForFeature(model, N4JSPackage.Literals.ABSTRACT_VARIABLE__NAME);
- producer.node = nodes.head ?: NodeModelUtils.findActualNodeFor(model)
- producer.addDiagnostic(
- new DiagnosticMessage(IssueCodes.getMessageForAST_CONST_HAS_NO_INITIALIZER(model.getName()),
- IssueCodes.getDefaultSeverity(IssueCodes.AST_CONST_HAS_NO_INITIALIZER), IssueCodes.AST_CONST_HAS_NO_INITIALIZER))
- }
- _validateASTStructure(model as AbstractVariable>, producer, validLabels, constraints.allowVarWithoutInitializer(true))
- }
-
- def private dispatch void validateASTStructure(
- ThisTypeRef thisTypeRef,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- // note: validity of location of ThisTypeRef was checked here; now moved to N4JSTypeValidator#checkThisTypeRef()
-
- recursiveValidateASTStructure(
- thisTypeRef,
- producer,
- validLabels,
- constraints
- )
- }
-
- def private dispatch void validateASTStructure(
- VariableBinding model,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- // no need to assert model.expression!==null (it is enforced by the grammar)
-
- recursiveValidateASTStructure(
- model,
- producer,
- validLabels,
- // initializers of variable declarations below a VariableBinding are always optional, even if we are in the
- // context of a const declaration, e.g. the following should not show an error about missing initializer:
- // const [c1, c2] = [10, 20];
- // Requiring an initializer of variable declarations below VariableBindings would render the above code
- // invalid and require something like:
- // const [c1=1, c2=2] = [10, 20];
- constraints.allowVarWithoutInitializer(true)
- )
- }
-
- def private dispatch void validateASTStructure(
- BindingElement model,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- validateRestInBindingPattern(model, producer);
-
- recursiveValidateASTStructure(
- model,
- producer,
- validLabels,
- constraints
- )
- }
-
- def private dispatch void validateASTStructure(
- Annotation model,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- // Add an issue for all script annotation (indicated by '@@') that do
- // not appear at the very top of the module.
- if (model.eContainer instanceof Script) {
- val script = model.eContainer as Script;
- if (script.scriptElements.size > 0) {
- val annotationNode = NodeModelUtils.findActualNodeFor(model);
- val annotationOffset = annotationNode.offset
- val firstScriptElement = script.scriptElements.get(0);
- val scriptElementOffset = NodeModelUtils.findActualNodeFor(firstScriptElement).offset;
-
- if (annotationOffset > scriptElementOffset) {
- producer.node = annotationNode;
- producer.addDiagnostic(
- new DiagnosticMessage(IssueCodes.getMessageForAST_SCRIPT_ANNO_INVALID_PLACEMENT(model.name),
- IssueCodes.getDefaultSeverity(IssueCodes.AST_SCRIPT_ANNO_INVALID_PLACEMENT), IssueCodes.AST_SCRIPT_ANNO_INVALID_PLACEMENT))
- }
- }
- }
- }
-
- def private void validateRestInBindingPattern(BindingElement elem, ASTStructureDiagnosticProducer producer) {
- if(elem!==null && elem.rest) {
- val pattern = elem.eContainer;
- if(pattern instanceof ArrayBindingPattern) {
- // note: the grammar ensures that BindingElement with rest===true will only appear
- // within an array binding pattern; we only have to assert that it appears at the end
- if(pattern.elements.last!==elem) {
- val nodes = NodeModelUtils.findNodesForFeature(elem, N4JSPackage.eINSTANCE.bindingElement_Rest);
- producer.node = nodes.head ?: NodeModelUtils.findActualNodeFor(elem)
- producer.addDiagnostic(
- new DiagnosticMessage(IssueCodes.getMessageForAST_REST_MUST_APPEAR_AT_END,
- IssueCodes.getDefaultSeverity(IssueCodes.AST_REST_MUST_APPEAR_AT_END), IssueCodes.AST_REST_MUST_APPEAR_AT_END))
- }
- }
- if (elem.expression !== null) {
- val nodes = NodeModelUtils.findNodesForFeature(elem, N4JSPackage.eINSTANCE.bindingElement_Expression);
- producer.node = nodes.head ?: NodeModelUtils.findActualNodeFor(elem)
- producer.addDiagnostic(
- new DiagnosticMessage(IssueCodes.getMessageForAST_REST_WITH_INITIALIZER,
- IssueCodes.getDefaultSeverity(IssueCodes.AST_REST_WITH_INITIALIZER), IssueCodes.AST_REST_WITH_INITIALIZER))
- }
- }
- }
-
- def private dispatch void validateASTStructure(
- BinaryLogicalExpression model,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- if (model.getLhs() === null) {
- producer.node = NodeModelUtils.findActualNodeFor(model);
- producer.addDiagnostic(
- new DiagnosticMessage(
- IssueCodes.getMessageForAST_BINARY_LOGICAL_EXPRESSION_MISSING_PART("left operand"),
- IssueCodes.getDefaultSeverity(IssueCodes.AST_BINARY_LOGICAL_EXPRESSION_MISSING_PART),
- IssueCodes.AST_BINARY_LOGICAL_EXPRESSION_MISSING_PART))
-
- }
- if (model.getRhs() === null) {
- producer.node = NodeModelUtils.findActualNodeFor(model);
- producer.addDiagnostic(
- new DiagnosticMessage(
- IssueCodes.getMessageForAST_BINARY_LOGICAL_EXPRESSION_MISSING_PART("right operand"),
- IssueCodes.getDefaultSeverity(IssueCodes.AST_BINARY_LOGICAL_EXPRESSION_MISSING_PART),
- IssueCodes.AST_BINARY_LOGICAL_EXPRESSION_MISSING_PART))
-
- }
- if (model.getOp() === null) {
- producer.node = NodeModelUtils.findActualNodeFor(model);
- producer.addDiagnostic(
- new DiagnosticMessage(IssueCodes.getMessageForAST_BINARY_LOGICAL_EXPRESSION_MISSING_PART("operator"),
- IssueCodes.getDefaultSeverity(IssueCodes.AST_BINARY_LOGICAL_EXPRESSION_MISSING_PART),
- IssueCodes.AST_BINARY_LOGICAL_EXPRESSION_MISSING_PART))
-
- }
- recursiveValidateASTStructure(
- model,
- producer,
- validLabels,
- constraints
- );
- }
-
- def private dispatch void validateASTStructure(
- N4TypeVariable model,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- recursiveValidateASTStructure(
- model,
- producer,
- validLabels,
- constraints
- )
- }
-
- def private dispatch void validateASTStructure(
- TypeVariable model,
- ASTStructureDiagnosticProducer producer,
- Set validLabels,
- Constraints constraints
- ) {
- recursiveValidateASTStructure(
- model,
- producer,
- validLabels,
- constraints
- )
- }
+ def private boolean validateLabelRef(LabelRef model, ASTStructureDiagnosticProducer producer,
+ Set validLabels
+ ) {
+ val labelAsText = model.labelAsText; // cannot use model.label, because we aren't allowed to resolve proxies in this phase!
+ if (labelAsText !== null && !validLabels.exists[it.name==labelAsText]) {
+ val target = NodeModelUtils.findActualNodeFor(model)
+ producer.node = target
+ producer.addDiagnostic(newDiagnosticMessage(IssueCodes.AST_INVALID_LABEL));
+ }
+ return labelAsText !== null
+ }
+
+ def private dispatch void validateASTStructure(
+ Expression model,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ recursiveValidateASTStructure(
+ model,
+ producer,
+ validLabels,
+ constraints
+ )
+ }
+
+ def private dispatch void validateASTStructure(
+ ArrayElement model,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ recursiveValidateASTStructure(
+ model,
+ producer,
+ validLabels,
+ constraints
+ )
+
+ validateExpressionInArrayOrObjectLiteral(model, constraints, producer);
+ validateSpreadInArrayLiteral(model, producer);
+ }
+
+ /** @param elem must be an ArrayElement or PropertyNameValuePair. */
+ def private void validateExpressionInArrayOrObjectLiteral(EObject elem, Constraints constraints, ASTStructureDiagnosticProducer producer) {
+ if(!(elem instanceof ArrayElement || elem instanceof PropertyNameValuePair || elem instanceof PropertyMethodDeclaration)) {
+ throw new IllegalArgumentException();
+ }
+ if(elem instanceof PropertyNameValuePairSingleName) {
+ val identifier = elem.identifierRef
+ if (identifier !== null && !identifier.isValidSimpleAssignmentTarget) {
+ producer.node = NodeModelUtils.findActualNodeFor(identifier)
+ producer.addDiagnostic(newDiagnosticMessage(IssueCodes.AST_INVALID_EXPR_IN_LHS_DESTRUCTURING_PATTERN));
+ }
+ // more validation not required in this case, because expression has a different meaning and problem cannot occur
+ return;
+ }
+ if(elem!==null && DestructureUtils.isArrayOrObjectLiteralUsedAsDestructuringPattern(elem.eContainer)) {
+ if(elem instanceof PropertyMethodDeclaration) {
+ // methods are not allowed at all in a destructuring pattern
+ producer.node = NodeModelUtils.findActualNodeFor(elem)
+ producer.addDiagnostic(newDiagnosticMessage(IssueCodes.AST_INVALID_PROPERTY_METHOD_IN_LHS_DESTRUCTURING_PATTERN));
+ } else {
+ val expr = switch(elem) {
+ ArrayElement: elem.expression
+ PropertyNameValuePair: elem.expression
+ };
+ if(expr!==null && !expr.isValidBindingElement(constraints)) {
+ producer.node = NodeModelUtils.findActualNodeFor(expr)
+ producer.addDiagnostic(newDiagnosticMessage(IssueCodes.AST_INVALID_EXPR_IN_LHS_DESTRUCTURING_PATTERN));
+ }
+ }
+ }
+ }
+
+ def private isValidBindingElement(Expression expr, Constraints constraints) {
+ if (constraints.isN4JS) {
+ return (expr.isValidSimpleAssignmentTarget && expr instanceof IdentifierRef)
+ || expr instanceof AssignmentExpression
+ || expr instanceof ArrayLiteral
+ || expr instanceof ObjectLiteral
+ } else {
+ return expr.isValidSimpleAssignmentTarget
+ || expr instanceof AssignmentExpression
+ || expr instanceof ArrayLiteral
+ || expr instanceof ObjectLiteral
+ }
+ }
+
+ def private void validateSpreadInArrayLiteral(ArrayElement elem, ASTStructureDiagnosticProducer producer) {
+ if(elem!==null && elem.spread) {
+ if(!DestructureUtils.isArrayOrObjectLiteralUsedAsDestructuringPattern(elem.eContainer)) {
+ // use of spread in an array literal that is *not* used as a destructuring pattern
+ // --> valid at any position
+ }
+ else {
+ // use of spread in an array literal that *is* used as a destructuring pattern
+ // --> error if not at end of array literal
+ val lit = elem.eContainer;
+ if(lit instanceof ArrayLiteral) {
+ if(lit.elements.last!==elem || lit.trailingComma) {
+ val nodes = NodeModelUtils.findNodesForFeature(elem, N4JSPackage.eINSTANCE.arrayElement_Spread);
+ producer.node = nodes.head ?: NodeModelUtils.findActualNodeFor(elem)
+ producer.addDiagnostic(newDiagnosticMessage(IssueCodes.AST_REST_MUST_APPEAR_AT_END));
+ }
+
+ if (elem.expression instanceof AssignmentExpression) {
+ val nodes = NodeModelUtils.findNodesForFeature(elem.expression, N4JSPackage.eINSTANCE.assignmentExpression_Rhs);
+ producer.node = nodes.head ?: NodeModelUtils.findActualNodeFor(elem.expression)
+ producer.addDiagnostic(newDiagnosticMessage(IssueCodes.AST_REST_WITH_INITIALIZER));
+ }
+ }
+ }
+ }
+ }
+
+ def private dispatch void validateASTStructure(
+ PropertyNameValuePair model,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ recursiveValidateASTStructure(
+ model,
+ producer,
+ validLabels,
+ constraints.allowYieldExpression(true)
+ )
+
+ validateExpressionInArrayOrObjectLiteral(model, constraints, producer);
+ validateSingleNameInObjectLiteral(model, producer);
+ }
+
+ def private dispatch void validateASTStructure(
+ PropertyMethodDeclaration model,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ recursiveValidateASTStructure(
+ model,
+ producer,
+ validLabels,
+ constraints.allowReturn(true).allowSuperLiteral(true).allowSuperCall(false).allowYieldExpression(true)
+ )
+
+ validateExpressionInArrayOrObjectLiteral(model, constraints, producer);
+ }
+
+ def private void validateSingleNameInObjectLiteral(PropertyNameValuePair elem, ASTStructureDiagnosticProducer producer) {
+ if(elem instanceof PropertyNameValuePairSingleName
+ && !DestructureUtils.isArrayOrObjectLiteralUsedAsDestructuringPattern(elem.eContainer)
+ && elem.expression instanceof AssignmentExpression) {
+
+ val nodes = NodeModelUtils.findNodesForFeature(elem.expression, N4JSPackage.Literals.ASSIGNMENT_EXPRESSION__RHS)
+ producer.node = nodes.head ?: NodeModelUtils.findActualNodeFor(elem.expression)
+ producer.addDiagnostic(newDiagnosticMessage(IssueCodes.AST_INVALID_DEFAULT_EXPR_SINGLE_NAME_PROPERTY));
+ }
+ }
+
+ def private dispatch void validateASTStructure(
+ VariableStatement model,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ if (model.varStmtKeyword === VariableStatementKeyword.CONST) {
+ if (!model.isValidConstOrLetPosition) {
+ val nodes = NodeModelUtils.findNodesForFeature(model, N4JSPackage.Literals.VARIABLE_DECLARATION_CONTAINER__VAR_STMT_KEYWORD)
+ producer.node = nodes.head ?: NodeModelUtils.findActualNodeFor(model)
+ producer.addDiagnostic(newDiagnosticMessage(IssueCodes.AST_CONST_IN_STATEMENT_POSITION));
+ }
+ } else if (model.varStmtKeyword === VariableStatementKeyword.LET) {
+ if (!model.isValidConstOrLetPosition) {
+ val nodes = NodeModelUtils.findNodesForFeature(model, N4JSPackage.Literals.VARIABLE_DECLARATION_CONTAINER__VAR_STMT_KEYWORD)
+ producer.node = nodes.head ?: NodeModelUtils.findActualNodeFor(model)
+ producer.addDiagnostic(newDiagnosticMessage(IssueCodes.AST_LET_IN_STATEMENT_POSITION));
+ }
+ }
+ if (model.varDeclsOrBindings.empty) {
+ val nodes = NodeModelUtils.findNodesForFeature(model, N4JSPackage.Literals.VARIABLE_DECLARATION_CONTAINER__VAR_STMT_KEYWORD)
+ producer.node = nodes.head ?: NodeModelUtils.findActualNodeFor(model)
+ producer.addDiagnostic(newDiagnosticMessage(IssueCodes.AST_VAR_STMT_NO_DECL));
+ }
+ val directParent = model.eContainer;
+ val parent = if(directParent instanceof ExportDeclaration) directParent.eContainer else directParent;
+ recursiveValidateASTStructure(
+ model,
+ producer,
+ validLabels,
+ constraints.allowVarWithoutInitializer(model.varStmtKeyword === VariableStatementKeyword.VAR || model.varStmtKeyword === VariableStatementKeyword.LET &&
+ (parent instanceof Block || parent instanceof Script || parent instanceof AbstractCaseClause)
+ )
+ )
+ }
+
+ def private boolean isValidConstOrLetPosition(EObject model) {
+ if (model.eContainer instanceof Block
+ || model.eContainer instanceof Script
+ || model.eContainer instanceof AbstractCaseClause
+ || model.eContainer instanceof N4NamespaceDeclaration
+ ) {
+ return true
+ }
+ if (model.eContainer instanceof ExportDeclaration) {
+ return model.eContainer.isValidConstOrLetPosition
+ }
+ return false
+ }
+
+ def private dispatch void validateASTStructure(
+ VariableDeclaration model,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ if (model.expression === null && constraints.isVarInitializerRequired && !constraints.external) {
+ val nodes = NodeModelUtils.findNodesForFeature(model, N4JSPackage.Literals.ABSTRACT_VARIABLE__NAME);
+ producer.node = nodes.head ?: NodeModelUtils.findActualNodeFor(model)
+ producer.addDiagnostic(newDiagnosticMessage(IssueCodes.AST_CONST_HAS_NO_INITIALIZER, model.getName()));
+ }
+ _validateASTStructure(model as AbstractVariable>, producer, validLabels, constraints.allowVarWithoutInitializer(true))
+ }
+
+ def private dispatch void validateASTStructure(
+ ThisTypeRef thisTypeRef,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ // note: validity of location of ThisTypeRef was checked here; now moved to N4JSTypeValidator#checkThisTypeRef()
+
+ recursiveValidateASTStructure(
+ thisTypeRef,
+ producer,
+ validLabels,
+ constraints
+ )
+ }
+
+ def private dispatch void validateASTStructure(
+ VariableBinding model,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ // no need to assert model.expression!==null (it is enforced by the grammar)
+
+ recursiveValidateASTStructure(
+ model,
+ producer,
+ validLabels,
+ // initializers of variable declarations below a VariableBinding are always optional, even if we are in the
+ // context of a const declaration, e.g. the following should not show an error about missing initializer:
+ // const [c1, c2] = [10, 20];
+ // Requiring an initializer of variable declarations below VariableBindings would render the above code
+ // invalid and require something like:
+ // const [c1=1, c2=2] = [10, 20];
+ constraints.allowVarWithoutInitializer(true)
+ )
+ }
+
+ def private dispatch void validateASTStructure(
+ BindingElement model,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ validateRestInBindingPattern(model, producer);
+
+ recursiveValidateASTStructure(
+ model,
+ producer,
+ validLabels,
+ constraints
+ )
+ }
+
+ def private dispatch void validateASTStructure(
+ Annotation model,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ // Add an issue for all script annotation (indicated by '@@') that do
+ // not appear at the very top of the module.
+ if (model.eContainer instanceof Script) {
+ val script = model.eContainer as Script;
+ if (script.scriptElements.size > 0) {
+ val annotationNode = NodeModelUtils.findActualNodeFor(model);
+ val annotationOffset = annotationNode.offset
+ val firstScriptElement = script.scriptElements.get(0);
+ val scriptElementOffset = NodeModelUtils.findActualNodeFor(firstScriptElement).offset;
+
+ if (annotationOffset > scriptElementOffset) {
+ producer.node = annotationNode;
+ producer.addDiagnostic(newDiagnosticMessage(IssueCodes.AST_SCRIPT_ANNO_INVALID_PLACEMENT, model.name));
+ }
+ }
+ }
+ }
+
+ def private void validateRestInBindingPattern(BindingElement elem, ASTStructureDiagnosticProducer producer) {
+ if(elem!==null && elem.rest) {
+ val pattern = elem.eContainer;
+ if(pattern instanceof ArrayBindingPattern) {
+ // note: the grammar ensures that BindingElement with rest===true will only appear
+ // within an array binding pattern; we only have to assert that it appears at the end
+ if(pattern.elements.last!==elem) {
+ val nodes = NodeModelUtils.findNodesForFeature(elem, N4JSPackage.eINSTANCE.bindingElement_Rest);
+ producer.node = nodes.head ?: NodeModelUtils.findActualNodeFor(elem)
+ producer.addDiagnostic(newDiagnosticMessage(IssueCodes.AST_REST_MUST_APPEAR_AT_END));
+ }
+ }
+ if (elem.expression !== null) {
+ val nodes = NodeModelUtils.findNodesForFeature(elem, N4JSPackage.eINSTANCE.bindingElement_Expression);
+ producer.node = nodes.head ?: NodeModelUtils.findActualNodeFor(elem)
+ producer.addDiagnostic(newDiagnosticMessage(IssueCodes.AST_REST_WITH_INITIALIZER));
+ }
+ }
+ }
+
+ def private dispatch void validateASTStructure(
+ BinaryLogicalExpression model,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ if (model.getLhs() === null) {
+ producer.node = NodeModelUtils.findActualNodeFor(model);
+ producer.addDiagnostic(newDiagnosticMessage(IssueCodes.AST_BINARY_LOGICAL_EXPRESSION_MISSING_PART, "left operand"));
+
+ }
+ if (model.getRhs() === null) {
+ producer.node = NodeModelUtils.findActualNodeFor(model);
+ producer.addDiagnostic(newDiagnosticMessage(IssueCodes.AST_BINARY_LOGICAL_EXPRESSION_MISSING_PART, "right operand"));
+
+ }
+ if (model.getOp() === null) {
+ producer.node = NodeModelUtils.findActualNodeFor(model);
+ producer.addDiagnostic(newDiagnosticMessage(IssueCodes.AST_BINARY_LOGICAL_EXPRESSION_MISSING_PART, "operator"));
+
+ }
+ recursiveValidateASTStructure(
+ model,
+ producer,
+ validLabels,
+ constraints
+ );
+ }
+
+ def private dispatch void validateASTStructure(
+ N4TypeVariable model,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ recursiveValidateASTStructure(
+ model,
+ producer,
+ validLabels,
+ constraints
+ )
+ }
+
+ def private dispatch void validateASTStructure(
+ TypeVariable model,
+ ASTStructureDiagnosticProducer producer,
+ Set validLabels,
+ Constraints constraints
+ ) {
+ recursiveValidateASTStructure(
+ model,
+ producer,
+ validLabels,
+ constraints
+ )
+ }
+
+ def private DiagnosticMessage newDiagnosticMessage(IssueCodes issueCode, Object... msgValues) {
+ return new DiagnosticMessage(issueCode.getMessage(msgValues), issueCode.severity, issueCode.name());
+ }
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/AbstractN4JSDeclarativeValidator.xtend b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/AbstractN4JSDeclarativeValidator.xtend
index 4068c07c1b..24b76093ac 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/AbstractN4JSDeclarativeValidator.xtend
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/AbstractN4JSDeclarativeValidator.xtend
@@ -219,18 +219,18 @@ public abstract class AbstractN4JSDeclarativeValidator extends AbstractMessageAd
"not more than " + typeParameterCount
};
if (source instanceof ParameterizedTypeRef && (source as ParameterizedTypeRef).isArrayNTypeExpression) {
- val message = IssueCodes.
- getMessageForEXP_WRONG_NUMBER_OF_TYPEARGS_FOR_ITERABLE_N_SYNTAX(BuiltInTypeScope.ITERABLE_N__MAX_LEN);
- addIssue(message, source, feature, IssueCodes.EXP_WRONG_NUMBER_OF_TYPEARGS_FOR_ITERABLE_N_SYNTAX);
+ val message = IssueCodes.EXP_WRONG_NUMBER_OF_TYPEARGS_FOR_ITERABLE_N_SYNTAX.
+ getMessage(BuiltInTypeScope.ITERABLE_N__MAX_LEN);
+ addIssue(message, source, feature, IssueCodes.EXP_WRONG_NUMBER_OF_TYPEARGS_FOR_ITERABLE_N_SYNTAX.name());
} else if (parameterizedElement !== null && parameterizedElement.name !== null) {
- val message = IssueCodes.
- getMessageForEXP_WRONG_NUMBER_OF_TYPEARGS_FOR_ELEMENT(parameterizedElement.keyword,
+ val message = IssueCodes.EXP_WRONG_NUMBER_OF_TYPEARGS_FOR_ELEMENT.
+ getMessage(parameterizedElement.keyword,
parameterizedElement.name, expectationStr, typeArgumentCount);
- addIssue(message, source, feature, IssueCodes.EXP_WRONG_NUMBER_OF_TYPEARGS_FOR_ELEMENT);
+ addIssue(message, source, feature, IssueCodes.EXP_WRONG_NUMBER_OF_TYPEARGS_FOR_ELEMENT.name());
} else {
- val message = IssueCodes.
- getMessageForEXP_WRONG_NUMBER_OF_TYPEARGS(expectationStr, typeArgumentCount);
- addIssue(message, source, feature, IssueCodes.EXP_WRONG_NUMBER_OF_TYPEARGS);
+ val message = IssueCodes.EXP_WRONG_NUMBER_OF_TYPEARGS.
+ getMessage(expectationStr, typeArgumentCount);
+ addIssue(message, source, feature, IssueCodes.EXP_WRONG_NUMBER_OF_TYPEARGS.name());
}
return;
}
@@ -298,15 +298,15 @@ public abstract class AbstractN4JSDeclarativeValidator extends AbstractMessageAd
&& useSiteVariance !== defSiteVariance) {
// we've got an inconsistency!
if (typeArgumentInAST.usingInOutNotation) {
- val message = IssueCodes.getMessageForEXP_INCONSISTENT_VARIANCE_OF_TYPE_ARG_IN_OUT(
+ val message = IssueCodes.EXP_INCONSISTENT_VARIANCE_OF_TYPE_ARG_IN_OUT.getMessage(
useSiteVariance.getDescriptiveStringNoun(true),
defSiteVariance.getDescriptiveStringNoun(true));
- addIssue(message, typeArgumentInAST, IssueCodes.EXP_INCONSISTENT_VARIANCE_OF_TYPE_ARG_IN_OUT);
+ addIssue(message, typeArgumentInAST, IssueCodes.EXP_INCONSISTENT_VARIANCE_OF_TYPE_ARG_IN_OUT.name());
} else {
- val message = IssueCodes.getMessageForEXP_INCONSISTENT_VARIANCE_OF_TYPE_ARG(
+ val message = IssueCodes.EXP_INCONSISTENT_VARIANCE_OF_TYPE_ARG.getMessage(
if (useSiteVariance === Variance.CO) "upper" else "lower",
defSiteVariance.getDescriptiveString(true));
- addIssue(message, typeArgumentInAST, IssueCodes.EXP_INCONSISTENT_VARIANCE_OF_TYPE_ARG);
+ addIssue(message, typeArgumentInAST, IssueCodes.EXP_INCONSISTENT_VARIANCE_OF_TYPE_ARG.name());
}
}
}
@@ -399,8 +399,8 @@ public abstract class AbstractN4JSDeclarativeValidator extends AbstractMessageAd
}
private def void createUnusedTypeParameterIssue(EObject typeVarInAST) {
- val msg = IssueCodes.getMessageForFUN_UNUSED_GENERIC_TYPE_PARAM(N4JSASTUtils.getNameOfTypeVarInAST(typeVarInAST));
- addIssue(msg, typeVarInAST, N4JSASTUtils.getNameFeatureOfTypeVarInAST(typeVarInAST), IssueCodes.FUN_UNUSED_GENERIC_TYPE_PARAM);
+ val msg = IssueCodes.FUN_UNUSED_GENERIC_TYPE_PARAM.getMessage(N4JSASTUtils.getNameOfTypeVarInAST(typeVarInAST));
+ addIssue(msg, typeVarInAST, N4JSASTUtils.getNameFeatureOfTypeVarInAST(typeVarInAST), IssueCodes.FUN_UNUSED_GENERIC_TYPE_PARAM.name());
}
/**
@@ -637,4 +637,27 @@ public abstract class AbstractN4JSDeclarativeValidator extends AbstractMessageAd
return isFieldAccessorPair(m1, m2)
}
+ def public void addIssue(EObject source, IssueCodes issueCode, String... msgValues) {
+ super.addIssue(issueCode.getMessage(msgValues), source, issueCode.name());
+ }
+
+ def public void addIssue(EObject source, EStructuralFeature feature, IssueCodes issueCode, String... msgValues) {
+ super.addIssue(issueCode.getMessage(msgValues), source, feature, issueCode.name());
+ }
+
+ def public void addIssue(EObject source, int offset, int length, IssueItem issueItem) {
+ super.addIssue(issueItem.message, source, offset, length, issueItem.ID, issueItem.data);
+ }
+
+ def public void addIssue(EObject source, EStructuralFeature feature, int index, IssueItem issueItem) {
+ super.addIssue(issueItem.message, source, feature, index, issueItem.ID, issueItem.data);
+ }
+
+ def public void addIssue(EObject source, EStructuralFeature feature, IssueItem issueItem) {
+ super.addIssue(issueItem.message, source, feature, issueItem.ID, issueItem.data);
+ }
+
+ def public void addIssue(EObject source, IssueItem issueItem) {
+ super.addIssue(issueItem.message, source, null, issueItem.ID, issueItem.data);
+ }
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/IssueCodes.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/IssueCodes.java
new file mode 100644
index 0000000000..ea670ca3f8
--- /dev/null
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/IssueCodes.java
@@ -0,0 +1,2137 @@
+/**
+ * Copyright (c) 2023 NumberFour AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * NumberFour AG - Initial API and implementation
+ */
+package org.eclipse.n4js.validation;
+
+import static org.eclipse.xtext.diagnostics.Severity.ERROR;
+import static org.eclipse.xtext.diagnostics.Severity.WARNING;
+
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.eclipse.xtext.diagnostics.Severity;
+
+import com.google.common.base.Preconditions;
+
+/**
+ * Enum contains all issues
+ */
+@SuppressWarnings("javadoc")
+public enum IssueCodes {
+
+ /** Only for internal use. */
+ INVALID_ISSUE_CODE(WARNING, null),
+
+ /**
+ * The following message is intended for ES6 features that are implemented in N4JS but are not yet supported in
+ * current version of V8 or some other relevant runtime environment. 0: description of the feature that is not
+ * supported
+ */
+ UNSUPPORTED(ERROR, "Unsupported feature: {0}."),
+
+ /** Not necessary. */
+ SCR_HASHBANG_WRONG_LOCATION(ERROR, "Hashbang must start at the absolute start of a script or module"),
+
+ /** 0: file names of files that contain errors */
+ EXTERNAL_LIBRARY_ERRORS(ERROR, "External library error: {0}"),
+
+ /** 0: file names of files that contain warnings */
+ EXTERNAL_LIBRARY_WARNINGS(ERROR, "External library warning: {0}"),
+
+ /**
+ * 0: kind of throwable ('error', 'exception', or 'throwable'), 1: simple name of throwable, 2: message of throwable
+ */
+ POST_PROCESSING_FAILED(ERROR, "{0} {1} thrown during post-processing (please report this!): {2}"),
+
+ /** Unknown type ref in resource */
+ TYS_UNKNOWN_TYPE_REF(ERROR, "Resource contains unknown type ref (please report this!)"),
+
+ /** 0: namespace name, 1: import module name, that both occur multiple times in this combination */
+ IMP_STMT_DUPLICATE_NAMESPACE(ERROR, "Duplicate namespace import statement with name {0} and imported module {1}."),
+
+ /** 0: imported element local name, 1: import module name, that both occur multiple times in this combination */
+ IMP_STMT_DUPLICATE_NAMED(ERROR, "Duplicate named import statement with local name {0} and imported module {1}."),
+
+ /** 0: type1 imported name1, 1: import module name, 2: name under which type is already imported */
+ IMP_DUPLICATE(ERROR, "{0} from {1} is already imported as {2}."),
+
+ /** 0: import module name, 1: namespace name already importing those elements */
+ IMP_DUPLICATE_NAMESPACE(ERROR, "Element {0} of {1} is already imported in namespace {2}."),
+
+ /**
+ * 0: local name (import name, alias name or namespace name), 1: import module name, 2: name under which type is
+ * already imported
+ */
+ IMP_LOCAL_NAME_CONFLICT(ERROR, "Name {0} is already used as {1}."),
+
+ /** 0: type name, 1: alias name */
+ IMP_PLAIN_ACCESS_OF_ALIASED_TYPE(ERROR, "{0} has been imported as {1}."),
+
+ /** 0: type name, 1: full name (namespace + '.' + type name) */
+ IMP_PLAIN_ACCESS_OF_NAMESPACED_TYPE(ERROR, "{0} has been imported as {1}."),
+
+ /** 0: imported name */
+ IMP_UNUSED_IMPORT(WARNING, "The import of {0} is unused."),
+
+ /** 0: imported name */
+ IMP_NOT_EXPORTED(ERROR, "Element {0} is not exported."),
+
+ /** 0: type import name */
+ IMP_UNRESOLVED(ERROR, "Import of {0} cannot be resolved."),
+
+ /** Not necessary. */
+ IMP_DISCOURAGED_PLACEMENT(WARNING, "The import statement should be placed on top of other statements."),
+
+ /** 0: type or variable, 1: type name, 2: comma separated list of types - the sources of the imports */
+ IMP_AMBIGUOUS(ERROR, "The {0} {1} is ambiguously imported from {2}."),
+
+ /** 0: type or variable, 1: type name, 2: comma separated list of types - the sources of the imports */
+ IMP_AMBIGUOUS_WILDCARD(ERROR, "The {0} {1} is ambiguously imported from {2}."),
+
+ /** 0: imported type name, 1: qualified name of the module */
+ IMP_CONFLICT(ERROR, "Conflicting import of {0} with import from {1}."),
+
+ /** 0: imported type1 name, 1: type1 alias, 2: type2 imported name, 3: type2 import module name */
+ IMP_CONFLICT_ALIAS_TYPE(ERROR,
+ "Conflicting import of {0} as {1}. Cannot import same type with different name ({2}) from {3}."),
+
+ /** 0: type1 imported name, 1: type2 alias, 2: type2 import module name */
+ IMP_CONFLICT_ALIASES(ERROR,
+ "Conflicting import of {0}. Cannot import same type with different name ({1}) from {2}."),
+
+ /** 0: type1 imported name1, that occur multiple times, 1: import module name */
+ IMP_DUPLICATEX(ERROR, "Duplicate import of {0} in import from {1}."),
+
+ /** 0: type1 imported name1, 1: type1 imported name2, 2: import module name */
+ IMP_DUPLICATE_ALIAS(ERROR, "Duplicate import of {0}, already defined as {1} in import from {2}."),
+
+ /** 0: module in wildcard specifier */
+ IMP_EMPTY_WILDCARD_IMPORT(WARNING,
+ "The wild-card import from {0} doesn't import anything because nothing is exported there."),
+
+ /** 0: alias in namespace import */
+ IMP_STATIC_IMPORT_PLAIN_JS(ERROR, "Use dynamic import in order to access elements of {0}."),
+
+ /** 0: alias in namespace import */
+ IMP_DYNAMIC_IMPORT_N4JS(ERROR, "N4JS module {0} must not be imported dynamically."),
+
+ /** 0: variant type, 1: alias in namespace import */
+ IMP_DYNAMIC_IMPORT_N4JSD(WARNING, "The {0} module {1} should not be imported dynamically."),
+
+ /** no parameters required */
+ IMP_DEFAULT_EXPORT_DUPLICATE(ERROR, "Duplicate default export."),
+
+ /** 0: local name of the imported element */
+ IMP_IMPORTED_ELEMENT_READ_ONLY(ERROR, "Imported element {0} is read-only."),
+
+ /** 0: local name of the imported element, 1: re-exporting project name to use, 2: imported project name */
+ IMP_IMPORTED_ELEMENT_FROM_REEXPORTING_PROJECT(ERROR,
+ "The imported element {0} is defined in the re-exporting project {1} but project {2} was imported. Import from {1} instead."),
+
+ /** 0: method, field, getter, setter, member, 1: member name */
+ VIS_ILLEGAL_MEMBER_ACCESS(ERROR, "The {0} {1} is not visible."),
+
+ /** 0: function name */
+ VIS_ILLEGAL_FUN_ACCESS(ERROR, "The function {0} is not visible."),
+
+ /** 0: type name */
+ VIS_ILLEGAL_TYPE_ACCESS(ERROR, "The type {0} is not visible."),
+
+ /** 0: variable name */
+ VIS_ILLEGAL_VARIABLE_ACCESS(ERROR, "The variable {0} is not visible."),
+
+ /** 0: member name, 1: type defining member */
+ VIS_ILLEGAL_STATIC_MEMBER_WRITE_ACCESS(ERROR,
+ "Write access to the static member {1} defined in {0} must use {0} directly."),
+
+ /** 0: member name, 1: type defining member, 2: member alias */
+ VIS_ILLEGAL_STATIC_MEMBER_WRITE_ACCESS_WITH_ALIAS(ERROR,
+ "Write access to the static member {1} defined in {0} must use the alias {2} directly."),
+
+ /**
+ * 0: member kind, 1: member name, 2: 'read-only', when a read-only member was used with write access or
+ * 'write-only' when a write-only member was used with read access.
+ */
+ VIS_WRONG_READ_WRITE_ACCESS(ERROR, "The {0} {1} is {2}."),
+
+ /** 0: static or non-static, 1: member name, 2: static or non-static */
+ VIS_WRONG_STATIC_ACCESSOR(ERROR, "The {0} member {1} cannot be accessed from a {2} context."),
+
+ /** 0: type variable name */
+ VIS_WRONG_TYPE_VARIABLE_ACCESSOR(ERROR, "The type variable {0} cannot be accessed from a static context."),
+
+ /** 0: type parameter name, 1: kind of type hidden (e.g. class, type variable, etc.) */
+ VIS_TYPE_PARAMETER_HIDES_TYPE(WARNING, "The type parameter {0} hides {1} {0}."),
+
+ /** 0: concept which is not allowed, 1: Mode (n4js,strict,...) in which it is not allowed. */
+ VIS_RESTRITCTED_USAGE(ERROR, "The usage of {0} is not allowed in {1} mode."),
+
+ /**
+ * 0: 'constructor' or 'construct signature', 1: classifier name whose constructor / construct signature is not
+ * visible.
+ */
+ VIS_NEW_CANNOT_INSTANTIATE_INVISIBLE_CONSTRUCTOR(ERROR, "The {0} of {1} is not visible."),
+
+ /** no parameters required */
+ TYP_TYPE_PARAM_MANDATORY_AFTER_OPTIONAL(ERROR,
+ "Mandatory type parameters may not follow optional type parameters."),
+
+ /** no parameters required */
+ TYP_TYPE_PARAM_DEFAULT_REFERENCES_LATER_TYPE_PARAM(ERROR,
+ "Default type arguments may only reference type parameters that are declared before the current type parameter."),
+
+ /** 0: name of type parameter, 1: error message of subtype check */
+ TYP_TYPE_PARAM_DEFAULT_NOT_SUBTYPE_OF_BOUND(ERROR,
+ "Default argument of optional type parameter {0} must comply to its upper bound, but: {1}"),
+
+ /** no parameters required */
+ CLF_MUST_BE_NOMINAL(ERROR, "Classes cannot be structural."),
+
+ /** no parameters required */
+ CLF_CTOR_RETURN_TYPE(ERROR, "A constructor must not have a return type declaration."),
+
+ /** no parameters required */
+ CLF_CTOR_ILLEGAL_MODIFIER(ERROR,
+ "A constructor must not be declared abstract, static or final and may not be annotated with @Override."),
+
+ /** no parameters required */
+ CLF_CALL_CONSTRUCT_SIG_ONLY_IN_N4JSD(ERROR, "Call and construct signatures may only be used in .n4jsd files."),
+
+ /** no parameters required */
+ CLF_CALL_CONSTRUCT_SIG_NOT_IN_N4JS(ERROR,
+ "Call and construct signatures are not allowed in n4js classifiers. Use shapes or @EcmaScript."),
+
+ /** no parameters required */
+ CLF_CALL_CONSTRUCT_SIG_BODY(ERROR, "Call and construct signatures must not have a body."),
+
+ /** 0: kind of signature ('call' or 'construct') */
+ CLF_CALL_CONSTRUCT_SIG_DUPLICATE(ERROR, "Duplicate {0} signature."),
+
+ /** no parameters required */
+ CLF_CALL_CONSTRUCT_SIG_CANNOT_IMPLEMENT(ERROR,
+ "An interface with a call or construct signature cannot be implemented by a class."),
+
+ /** no parameters required */
+ CLF_CONSTRUCT_SIG_ONLY_IN_INTERFACE(ERROR, "Construct signatures may only be used in interfaces."),
+
+ /** no parameters required */
+ CLF_CONSTRUCT_SIG_VOID_RETURN_TYPE(ERROR, "Construct signatures must have a non-void return type."),
+
+ /** no parameters required */
+ CLF_CTOR_NO_TYPE_PARAMETERS(ERROR, "Constructors must not have any type parameters."),
+
+ /** no parameters required */
+ CLF_NAME_DOLLAR(ERROR, "Member names must not start with a dollar character."),
+
+ /** 0: the human readable name of the violating discouraged character */
+ CLF_NAME_CONTAINS_DISCOURAGED_CHARACTER(WARNING, "Name should not contain {0} character."),
+
+ /** 0: static or const keywords */
+ CLF_NAME_DOES_NOT_MATCH_WITH_PATTERN_FOR_STATIC_OR_CONST(WARNING,
+ "Name should be all upper case with words separated by underscores for variables with {0} modifier."),
+
+ /** 0: element meta type */
+ CLF_NAME_DOES_NOT_START_UPPERCASE(WARNING, "{0} names should start with upper case letter."),
+
+ /** 0: element meta type */
+ CLF_NAME_DOES_NOT_START_LOWERCASE(WARNING, "{0} names should start with lower case letter."),
+
+ /** 0: element description, 1: conflicting category */
+ CLF_NAME_INDISTINGUISHABLE(ERROR, "{0} may be indistinguishable with {1}."),
+
+ /** 0: element description, 1: conflicting category */
+ CLF_NAME_RESERVED(WARNING, "{0} may be confused with {1}."),
+
+ /** no parameters required */
+ CLF_NAME_CONFLICTS_WITH_CONSTRUCTOR(WARNING, "Name may be confused with constructor."),
+
+ /** 0: element description, 1: conflicting type name 2: actual type */
+ CLF_NAME_DIFFERS_TYPE(WARNING, "{0} is not of type {1} but of type {2}."),
+
+ /** 0: name of final type, 1: name of type parameter */
+ CLF_UPPER_BOUND_FINAL(WARNING,
+ "Final type {0} should not be used as upper bound of type parameter {1}. Final types cannot be extended."),
+
+ /** no parameters required */
+ CLF_DEF_SITE_VARIANCE_ONLY_IN_CLASSIFIER(ERROR,
+ "Declaration of definition-site variance only allowed in generic classes and interfaces, not in generic functions or methods."),
+
+ /** 0: 'covariant' or 'contravariant', 1: 'covariant', 'contravariant', or 'invariant' */
+ CLF_TYPE_VARIABLE_AT_INVALID_POSITION(ERROR, "Cannot use {0} type variable at {1} position."),
+
+ /** 0: the actual primitive type */
+ CLF_EXTENDS_PRIMITIVE_GENERIC_TYPE(ERROR, "Cannot subclass primitive type {0}."),
+
+ /** 0: class name */
+ CLF_EXTEND_FINAL(ERROR, "Cannot extend final class {0}."),
+
+ /** 0: keyword, 1: name of class */
+ CLF_EXTEND_NON_ACCESSIBLE_CTOR(ERROR, "Cannot extend {0} {1} because its constructor is not accessible."),
+
+ /** 0: name of class, 1: name of super class */
+ CLF_OBSERVABLE_MISSING(ERROR,
+ "Class {0} extends observable class {1} and must therefore be annotated with @Observable."),
+
+ /** no parameters required */
+ CLF_TEST_CLASS_NOT_EXPORTED(WARNING,
+ "Classes containing test methods must be abstract or marked with modifier export."),
+
+ /** /** 0: module name, 1: path to other module */
+ CLF_DUP_MODULE(ERROR, "A duplicate module {0} is also defined in {1}."),
+
+ /** /** 0: module name, 1: js module, 2: path to other module */
+ CLF_DUP_DEF_MODULE(ERROR, "A duplicate definition module {0} for {1} is also defined in {2}."),
+
+ /**
+ * /** 0: first name with line ({@link ValidatorMessageHelper/**nameWithLine(TMember,TMember)}, 1: other name with
+ * line ({@link ValidatorMessageHelper/**nameWithLine(TMember,TMember)}
+ */
+ CLF_DUP_CTOR(ERROR, "Constructor line {0} duplicates constructor in line {1}."),
+
+ /**
+ * /** 0: first short description ({@link ValidatorMessageHelper/**descriptionWithLine(TMember,TMember)}, 1: other
+ * short description ({@link ValidatorMessageHelper/**descriptionWithLine(TMember,TMember)}
+ */
+ CLF_DUP_MEMBER(ERROR, "The {0} duplicates {1}."),
+
+ /** /** 0: first short description ({@link ValidatorMessageHelper/**descriptionWithLine(TMember,TMember)} */
+ CLF_DUP_WITH_MEMBER(ERROR,
+ "The {0} conflicts with the structural this type in the inherit constructor definition."),
+
+ /**
+ * 0: overriding description ({@link ValidatorMessageHelper/**descriptionDifferentFrom(TMember,TMember)}, 1:
+ * overridden description ({@link ValidatorMessageHelper/**descriptionDifferentFrom(TMember,TMember)}, 2: setter or
+ * getter
+ */
+ CLF_OVERRIDE_FIELD_REQUIRES_ACCESSOR_PAIR(ERROR, "The {0} cannot override {1}, matching {2} missing."),
+
+ /**
+ * 0: overriding description ({@link ValidatorMessageHelper/**descriptionDifferentFrom(TMember,TMember)}, 1:
+ * overridden description ({@link ValidatorMessageHelper/**descriptionDifferentFrom(TMember,TMember)}
+ */
+ CLF_CONSUMED_OVERRIDE_FIELD(ERROR, "The consumed {0} cannot override {1}."),
+
+ /**
+ * 0: overriding description ({@link ValidatorMessageHelper/**descriptionDifferentFrom(TMember,TMember)}, 1:
+ * 'overriding' or 'implementing' 2: overridden description
+ * ({@link ValidatorMessageHelper/**descriptionDifferentFrom(TMember,TMember)}
+ */
+ CLF_OVERRIDE_ANNOTATION(ERROR, "The {0} {1} {2} must be annotated with @Override."),
+
+ /**
+ * 0: overriding description ({@link ValidatorMessageHelper/**descriptionDifferentFrom(TMember,TMember)}, 1:
+ * overridden description ({@link ValidatorMessageHelper/**descriptionDifferentFrom(TMember,TMember)}
+ */
+ CLF_REDEFINED_NON_ACCESSIBLE(ERROR, "The {0} cannot override or implement non-accessible {1}."),
+
+ /**
+ * 0: overriding description ({@link ValidatorMessageHelper/**descriptionDifferentFrom(TMember,TMember)}, 1:
+ * overridden description ({@link ValidatorMessageHelper/**descriptionDifferentFrom(TMember,TMember)}
+ */
+ CLF_OVERRIDE_FINAL(ERROR, "The {0} cannot override final {1}."),
+
+ /**
+ * 0: overridden description ({@link ValidatorMessageHelper/**descriptionDifferentFrom(TMember,TMember)}, 1: 'final'
+ * or 'const'
+ */
+ CLF_OVERRIDE_WITH_FINAL_OR_CONST_FIELD(ERROR, "Cannot override {0} with a {1} field."),
+
+ /**
+ * 0: overriding description ({@link ValidatorMessageHelper/**descriptionDifferentFrom(TMember,TMember)}, 1:
+ * overridden description ({@link ValidatorMessageHelper/**descriptionDifferentFrom(TMember,TMember)}
+ */
+ CLF_OVERRIDE_CONST(ERROR, "The {0} cannot override {1}."),
+
+ /**
+ * 0: overriding description ({@link ValidatorMessageHelper/**descriptionDifferentFrom(TMember,TMember)}, 1:
+ * overridden description ({@link ValidatorMessageHelper/**descriptionDifferentFrom(TMember,TMember)}
+ */
+ CLF_OVERRIDEN_CONCRETE_WITH_ABSTRACT(ERROR, "The abstract {0} cannot override concrete {1}."),
+
+ /**
+ * 0: overriding description ({@link ValidatorMessageHelper/**descriptionDifferentFrom(TMember,TMember)}, 1:
+ * overridden description ({@link ValidatorMessageHelper/**descriptionDifferentFrom(TMember,TMember)}
+ */
+ CLF_OVERRIDE_VISIBILITY(ERROR, "The {0} cannot reduce the visibility of {1}."),
+
+ /** 0: method, getter or setter, 1: member name */
+ CLF_OVERRIDE_NON_EXISTENT(ERROR, "The {0} {1} must override or implement a {0} from a super class or interface."),
+
+ /** 0: member description, 1: member description */
+ CLF_OVERRIDE_NON_EXISTENT_INTERFACE(WARNING,
+ "The {0} does not override {1} (no inheritance of static members in interfaces); remove annotation @Override."),
+
+ /**
+ * 0: description of constructor, 1: description of classifier inheriting the constructor, 2: description of
+ * classifier owning the constructor
+ */
+ CLF_PSEUDO_REDEFINED_SPEC_CTOR_INCOMPATIBLE(ERROR,
+ "Inherited {0} in context of {1} not compatible to itself in context of {2}."),
+
+ /**
+ * 0: overriding description ({@link ValidatorMessageHelper/**descriptionDifferentFrom(TMember,TMember)}, 1:
+ * overridden/implemented/consumed, 2: overridden description
+ * ({@link ValidatorMessageHelper/**descriptionDifferentFrom(TMember,TMember)} 3: additional members or error
+ * information (may be empty)
+ */
+ CLF_REDEFINED_TYPE_NOT_SAME_TYPE(ERROR, "Type of {0} must equal type of {1} {2}.{3}"),
+
+ /**
+ * 0: overriding description ({@link ValidatorMessageHelper/**descriptionDifferentFrom(TMember,TMember)}, 1:
+ * overridden/implemented/consumed, 2: overridden description
+ * ({@link ValidatorMessageHelper/**descriptionDifferentFrom(TMember,TMember)}
+ */
+ CLF_REDEFINED_BY_CONSUMED_TYPE_NOT_SAME_TYPE(ERROR, "Type of inherited {0} must equal type of {1} {2}."),
+
+ /**
+ * 0: overriding description ({@link ValidatorMessageHelper/**descriptionDifferentFrom(TMember,TMember)}, 1:
+ * overridden description ({@link ValidatorMessageHelper/**descriptionDifferentFrom(TMember,TMember)}, 1:
+ * overridden/implemented/consumed, 3: signature type error message, 4: additional members or error information (may
+ * be empty)
+ */
+ CLF_REDEFINED_MEMBER_TYPE_INVALID(ERROR, "Type of {0} does not conform to {2} {1}: {3}.{4}"),
+
+ /**
+ * 0: consumed/inherited, 1: overriding description
+ * ({@link ValidatorMessageHelper/**descriptionDifferentFrom(TMember,TMember)}, 2: overridden/implemented/consumed,
+ * 3: overridden description ({@link ValidatorMessageHelper/**descriptionDifferentFrom(TMember,TMember)}, 4:
+ * signature type error message
+ */
+ CLF_REDEFINED_BY_CONSUMED_MEMBER_TYPE_INVALID(ERROR, "Type of {0} {1} does not conform to {2} {3}: {4}."),
+
+ /** 0: comma separated description of conflicting members */
+ CLF_CONSUMED_MEMBER_SOLVABLE_CONFLICT(ERROR, "Redefine ambiguously consumed members: {0}."),
+
+ /** 0: comma separated description of conflicting members */
+ CLF_CONSUMED_MEMBER_UNSOLVABLE_CONFLICT(ERROR, "Incompatible consumed members: {0}."),
+
+ /** 0: inherited member leading to conflict, 1: comma separated description of conflicting members */
+ CLF_CONSUMED_INHERITED_MEMBER_UNSOLVABLE_CONFLICT(ERROR, "Inherited {0} cannot implement {1}."),
+
+ /**
+ * 0: overriding description, should usually start with 'Signature of '
+ * ({@link ValidatorMessageHelper/**descriptionDifferentFrom(TMember,TMember)}, 1: overridden/implemented/consumed,
+ * 2: overridden description ({@link ValidatorMessageHelper/**descriptionDifferentFrom(TMember,TMember)}, 3:
+ * signature type error message, 4: additional members or error information (may be empty)
+ */
+ CLF_REDEFINED_METHOD_TYPE_CONFLICT(ERROR, "{0} does not conform to {1} {2}: {3}.{4}"),
+
+ /**
+ * 0: overriding description ({@link ValidatorMessageHelper/**descriptionDifferentFrom(TMember,TMember)}, 1:
+ * overridden description ({@link ValidatorMessageHelper/**descriptionDifferentFrom(TMember,TMember)}
+ */
+ CLF_OVERRIDE_MEMBERTYPE_INCOMPATIBLE(ERROR, "Cannot override {1} with {0}."),
+
+ /**
+ * TODO remove?! 0: overriding description
+ * ({@link ValidatorMessageHelper/**descriptionDifferentFrom(TMember,TMember)}, 1: overridden description
+ * ({@link ValidatorMessageHelper/**descriptionDifferentFrom(TMember,TMember)}
+ */
+ CLF_CONSUMED_OVERRIDE_MEMBERTYPE_INCOMPATIBLE(ERROR, "Cannot override {1} with consumed {0}."),
+
+ /**
+ * 0: getter/setter, 0: overridden descriptions (CSV)
+ * ({@link ValidatorMessageHelper/**descriptionDifferentFrom(TMember,TMember)}
+ */
+ CLF_CONSUMED_FIELD_ACCESSOR_PAIR_INCOMPLETE(ERROR, "Missing {0} to completely override consumed {1}."),
+
+ /** no parameters required */
+ CLF_FIELD_CONST_FINAL(ERROR, "A field may not be declared both final and const."),
+
+ /** no parameters required */
+ CLF_FIELD_CONST_STATIC(ERROR, "All const fields are static. Remove unnecessary modifier 'static'."),
+
+ /** 0: name of const field */
+ CLF_FIELD_CONST_MISSING_INIT(ERROR, "Const field {0} must be provided with an initializer."),
+
+ /** no parameters required */
+ CLF_FIELD_FINAL_STATIC(ERROR, "A field may not be declared both final and static. Use a const field instead."),
+
+ /** 0: name of final field */
+ CLF_FIELD_FINAL_MISSING_INIT(ERROR,
+ "Final field {0} must be provided with an initializer or must be initialized in the constructor."),
+
+ /** 0: name of final field */
+ CLF_FIELD_FINAL_MISSING_INIT_IN_STATIC_POLYFILL(ERROR,
+ "Final field {0} must be provided with an initializer or must be initialized in the constructor. HINT: You might want to check the polyfilled constructor."),
+
+ /** 0: name of final field (that has an initializer expression) */
+ CLF_FIELD_FINAL_REINIT_IN_CTOR(ERROR,
+ "Final field {0} has an initializer and may therefore not be initialized in the constructor."),
+
+ /** no parameters required */
+ CLF_FIELD_OPTIONAL_OLD_SYNTAX(ERROR,
+ "This syntax for optional fields is no longer allowed. Place the ? right after the field's name."),
+
+ /** no parameters required */
+ CLF_IMPLEMENT_EXTEND_WITH_WILDCARD(ERROR,
+ "Wildcards may not be used as type argument when declaring an extended or implemented type."),
+
+ /**
+ * 0: 'implement' or 'extend', 0: name of interface, 1: name of type variable, 2: comma-separated list of type
+ * arguments
+ */
+ CLF_IMPLEMENT_EXTEND_SAME_INTERFACE_INCONSISTENTLY(ERROR,
+ "Cannot {0} interface {1} multiple times with different type arguments for {2}: {3}."),
+
+ /**
+ * 0: overridden description ({@link ValidatorMessageHelper/**descriptionDifferentFrom(TMember,TMember)}, 1:
+ * overriding description ({@link ValidatorMessageHelper/**descriptionDifferentFrom(TMember,TMember)}, 2: additional
+ * error information
+ */
+ CLF_IMPLEMENT_MEMBERTYPE_INCOMPATIBLE(ERROR, "Cannot implement {0} with {1}.{2}"),
+
+ /** 0: descriptions of missing members, 1: the consumer */
+ CLF_IMPLEMENT_MIXIN_CONFLICTS(ERROR, "The {0} cannot be mixed in {1} due to conflicts."),
+
+ /** 0: name of the current classifier, 1: abstract non overridden descriptions */
+ CLF_MISSING_IMPLEMENTATION(ERROR, "Class {0} must either be declared abstract or implement {1}."),
+
+ /** 0: name of the current classifier, 1: abstract non overridden descriptions */
+ CLF_MISSING_IMPLEMENTATION_EXT(WARNING,
+ "External class {0} must either be declared abstract or explicit declare {1}."),
+
+ /** 0: class, method, getter or setter */
+ CLF_ABSTRACT_FINAL(ERROR, "An abstract {0} cannot be declared final."),
+
+ /** no parameters required, will be changed to error (IDE-1236) */
+ CLF_NO_FINAL_INTERFACE_MEMBER(WARNING, "In interfaces, only methods may be declared final."),
+
+ /** no parameters required */
+ CLF_NO_THIS_IN_STATIC_FIELD(ERROR, "The 'this' literal may not be used in initializers of static data fields."),
+
+ /** no parameters required */
+ CLF_NO_THIS_IN_FIELD_OF_INTERFACE(ERROR,
+ "In interfaces, the 'this' literal may not be used in initializers of data fields."),
+
+ /** no parameters required */
+ CLF_NO_THIS_IN_STATIC_MEMBER_OF_INTERFACE(ERROR,
+ "In interfaces, the 'this' literal may not be used in static methods or field accessors and in initializers of static data fields."),
+
+ /** no parameters required */
+ CLF_INVALID_ACCESS_OF_STATIC_MEMBER_OF_INTERFACE(ERROR,
+ "Static members of interfaces may only be accessed directly via the type name of their containing interface."),
+
+ /** 0: method, getter or setter, 1: name of method/getter/setter */
+ CLF_STATIC_ABSTRACT(ERROR, "The {0} {1} may not be both static and abstract."),
+
+ /** no parameters required */
+ CLF_ABSTRACT_BODY(ERROR, "Abstract methods do not specify a body."),
+
+ /** 0: method, getter or setter, 1: member name, 2: class name */
+ CLF_ABSTRACT_MISSING(ERROR, "The abstract {0} {1} in class {2} can only be defined in an abstract class."),
+
+ /** 0: method, getter or setter, 1: member name */
+ CLF_MISSING_BODY(ERROR, "The {0} {1} has to have either a body or must be defined abstract."),
+
+ /** no parameters required */
+ CLF_MISSING_CTOR_BODY(ERROR, "Constructors must have a body."),
+
+ /** no parameters required */
+ CLF_VOID_ACCESSOR(ERROR, "Void is not a valid type for getters and setters."),
+
+ /** 0: accessor description, 1: verb, 2: missing accessor type */
+ CLF_UNMATCHED_ACCESSOR_OVERRIDE(ERROR, "{0} cannot be {1} without overriding the corresponding {2}."),
+
+ /** 0: accessor description, 1: verb, 2: missing accessor type */
+ CLF_UNMATCHED_ACCESSOR_OVERRIDE_JS(WARNING, "{0} should not be {1} without overriding the corresponding {2}."),
+
+ /** 0: interface name */
+ CLF_MULTIPLE_ROLE_CONSUME(ERROR, "Cannot consume {0} multiple times."),
+
+ /** 0: 'Classes' or 'Roles' */
+ CLF_EXT_EXTERNAL_N4JSD(ERROR, "{0} declared as external have to be placed in a file with file extension 'n4jsd'."),
+
+ /** none */
+ CLF_EXT_PROVIDED_BY_RUNTIME_IN_RUNTIME_TYPE(ERROR,
+ "Only runtime environments/libraries may specify elements provided by runtime."),
+
+ /** no parameters required */
+ CLF_EXT_UNALLOWED_N4JSD(ERROR,
+ "Only namespaces, classes, interfaces, enums, type aliases and functions declared as external as well as structurally typed interfaces are allowed in n4jsd files."),
+
+ /** no parameters required */
+ CLF_EXT_EXPORTED(ERROR, "External elements have to be marked with modifier export."),
+
+ /** no parameters required */
+ CLF_EXT_NOT_ANNOTATED_EXTEND_N4OBJECT(ERROR,
+ "External classes annotated with @EcmaScript are not allowed to inherit from n4js classes."),
+
+ /** 0: classes or interfaces */
+ CLF_EXT_CONSUME_NON_EXT(ERROR, "External {0} are not allowed to consume a non external interface."),
+
+ /** 0: classes or interfaces */
+ CLF_EXT_IMPLEMENTS_NON_EXT(ERROR, "External {0} are not allowed to implement an interface from a non n4jsd file."),
+
+ /** 0: classes or interfaces */
+ CLF_EXT_PUBLIC(ERROR, "External {0} have to be marked as public (and without @Internal)."),
+
+ /** no parameters required */
+ CLF_EXT_INTF_PUBLIC(ERROR,
+ "Structural typed interfaces in n4jsd files have to be marked as public (and without @Internal)."),
+
+ /** 0: classes or interfaces */
+ CLF_EXT_EXTERNAL(ERROR, "External {0} have to be marked as external in n4jsd files."),
+
+ /** 0: methods, getters or setters, 1: classes or interfaces */
+ CLF_EXT_NO_METHOD_BODY(ERROR, "{0} in external {1} have to have no body."),
+
+ /** 0: classes or interfaces */
+ CLF_EXT_NO_FIELD_EXPR(ERROR, "Fields in external {0} have to have no right side."),
+
+ /** no parameters required */
+ CLF_EXT_PUBLIC_CONSTRUCTOR(ERROR, "External classes annotated with @EcmaScript have to have a public constructor."),
+
+ /** 0: classes or interfaces */
+ CLF_EXT_NO_OBSERV_ANNO(ERROR, "External {0} must not have the Observable annotation."),
+
+ /** 0: methods, getters or setters, 1: classes or interfaces, 2: Observable or Nfon */
+ CLF_EXT_METHOD_NO_ANNO(ERROR, "{0} in external {1} must not have the {2} annotation."),
+
+ /** no parameters required */
+ CLF_EXT_LITERAL_NO_VALUE(ERROR, "An enumeration literal in a n4jsd file isn't allowed to define a value."),
+
+ /** no parameters required */
+ CLF_EXT_FUN_NO_BODY(ERROR, "External function declarations have to have no body."),
+
+ /** 0 var or constant */
+ CLF_EXT_VAR_NO_VAL(ERROR, "External {0} declaration cannot be initialized."),
+
+ /** spec: Component/Manifest/General-Constraint, no parameters required */
+ CLF_EXT_NO_MATCH(WARNING,
+ "For the given n4jsd file no corresponding external file resp. no matching implemented by expression can be found."),
+
+ /**
+ * doc: validate duplicates between src/src-test and external (so there is e.g. file A.n4js that compiles to A.js
+ * that would be name conflict with A.js in external), spec: Component/Manifest/General-Contraint, 0: file, 1: path
+ */
+ CLF_EXT_DUPLICATE_PATH_SRC_EXTERNAL(ERROR, "Duplicate external file {0}, has been already defined in {1}."),
+
+ /** no parameters required */
+ CLF_IN_DEFINITION_PRJ_NON_N4JS(WARNING,
+ "Class declarations in definition projects should be annotated with @EcmaScript."),
+
+ /** 0: annotation name, 1: type (interface or classifier) */
+ CLF_EXT_PROVIDES_IMPL_ONLY_IN_DEFFILES(ERROR, "@{0} must only be used in external {1} in n4jsd files."),
+
+ /** 0: annotation name, 1: type (interface or classifier) */
+ CLF_EXT_PROVIDES_IMPL_ONLY_IN_INTERFACE_MEMBERS(ERROR, "@{0} must only be used in {1}."),
+
+ /** 0: annotation name, 1: type (interface or classifier) */
+ CLF_EXT_PROVIDES_IMPL_ONLY_IN_N4JS_INTERFACES(ERROR, "@{0} must only be used in n4js interfaces or classes."),
+
+ /** 0: type name, 1: access modifier name */
+ CLF_LOW_ACCESSOR_WITH_INTERNAL(ERROR, "A {0} with visibility {1} shouldn't be annotated with @Internal."),
+
+ /** 0: 'extend' or 'implement', 1: type name, 2: description of members causing problems */
+ CLF_NON_ACCESSIBLE_ABSTRACT_MEMBERS(ERROR,
+ "Cannot {0} {1}: cannot implement one or more non-accessible abstract members: {2}."),
+
+ /** no parameters required */
+ CLF_MINIMAL_ACCESSIBILITY_IN_INTERFACES(ERROR, "Members of interfaces must not be declared private."),
+
+ /** no parameters required */
+ CLF_SPEC_WRONG_TYPE(ERROR, "Annotation @Spec may only be used with formal parameters of type ~i~this."),
+
+ /** 0: name of field, 1: type of member, 2: type system error message */
+ CLF_SPEC_WRONG_ADD_MEMBERTYPE(ERROR,
+ "Type of structural member {0} of spec parameter must be a subtype of {1}: {2}."),
+
+ /** no parameters required */
+ CLF_SPEC_MULTIPLE(ERROR, "Only a single formal parameter in each constructor may be annotated with @Spec."),
+
+ /** 0: name of the superfluous property, 1: the type not defining the property */
+ CLF_SPEC_SUPERFLUOUS_PROPERTIES(WARNING,
+ "{0} is not defined in {1}; it will not have any effect in the spec constructor."),
+
+ /**
+ * 0: name of the superfluous property, 1: the type not defining the property, 2: name of variable the object
+ * literal is assigned to
+ */
+ CLF_SUPERFLUOUS_PROPERTIES(WARNING, "{0} is not defined in {1}; it will not be accessible from {2}."),
+
+ /** 0: name of the property, {1} built-in/provided by runtime interface */
+ CLF_SPEC_BUILT_IN_OR_PROVIDED_BY_RUNTIME_OR_EXTENAL_WITHOUT_N4JS_ANNOTATION(WARNING,
+ "{0} is a property of a built-in, provided by runtime, or external module with @EcmaScript annotation. Hence the interface {1} can not be initialized in a spec constructor."),
+
+ /** 0:the cycle */
+ CLF_INHERITANCE_CYCLE(ERROR, "Inheritance cycle detected: {0}."),
+
+ /** no param */
+ CLF_INTERNAL_BAD_WITH_PRIVATE_OR_PROJECT(ERROR, "@Internal is only allowed for public and protected."),
+
+ /** no param */
+ CLF_CANNOT_CALL_ABSTRACT_SUPER_METHOD(ERROR, "Cannot call super method since it is abstract."),
+
+ /** no param */
+ CLF_CANNOT_REFER_TO_DEFAULT_METHOD_WITH_SUPER(ERROR,
+ "Cannot refer to default method of an implemented interface with super."),
+
+ /** 0: name of polyfill, 1: 'class' or 'interface' including indefinite article */
+ CLF_POLYFILL_EXTEND_MISSING(ERROR, "Polyfill {0} must explicitly extend {1}."),
+
+ /** 0: name of polyfill */
+ CLF_POLYFILL_NO_TOPLEVEL(ERROR, "Polyfill {0} can only extend top level class declaration."),
+
+ /**
+ * 0: 'class' or 'interface', 1: name of correct classifier kind (without article), 2: name of correct classifier
+ * kind including indefinite article, 3: name of *incorrect* classifier kind including indefinite article
+ */
+ CLF_POLYFILL_DIFFERENT_CLASSIFIER_KIND(ERROR, "Polyfill for {0} {1} must be {2}, not {3}."),
+
+ /** 0: name of polyfill, 1: 'class' or 'interface', 2: name of extended class */
+ CLF_POLYFILL_DIFFERENT_NAME(ERROR, "Name of polyfill {0} must equal name of filled {1} {2}."),
+
+ /** 0: name of polyfill, 1: name polyfill's module, 2: name of filled class' module */
+ CLF_POLYFILL_DIFFERENT_MODULE_SPECIFIER(ERROR,
+ "Specifier {1} of module containing polyfill {0} must equal name of filled classes module specifier {2}."),
+
+ /** 0: name of polyfill, 1: global/not global polyfill module, 2: not/empty global polyfill */
+ CLF_POLYFILL_DIFFERENT_GLOBALS(ERROR, "Module containing polyfill {0} is {1}, but filled classes module is {2}."),
+
+ /** 0: name of polyfill */
+ CLF_POLYFILL_FILLED_NOT_PROVIDEDBYRUNTIME(ERROR, "Polyfill {0} cannot fill class not provided by runtime."),
+
+ /** 0: name of polyfill */
+ CLF_POLYFILL_NOT_PROVIDEDBYRUNTIME(ERROR, "Polyfill {0} must be provided by runtime."),
+
+ /** 0: name of polyfill */
+ CLF_POLYFILL_NO_IMPLEMENTS(ERROR, "Polyfill {0} must not implement any interfaces."),
+
+ /** 0: name of polyfill */
+ CLF_POLYFILL_NO_EXTENDS_ADDITIONAL(ERROR, "Polyfill {0} must not extend any additional interfaces."),
+
+ /** 0: name of polyfill */
+ CLF_POLYFILL_NOT_DIRECTLY_EXPORTED(ERROR, "Polyfill {0} must be exported."),
+
+ /** 0: name of polyfill, 1: name of polyfill modifier, 2: name of filled modifier, 3: 'class' or 'interface' */
+ CLF_POLYFILL_DIFFERENT_MODIFIER(ERROR,
+ "Polyfill {0} cannot be declared {1}, must be defined {2} just as the filled {3}."),
+
+ /** 0: name of polyfill, 1: type system error message */
+ CLF_POLYFILL_CTOR_NOT_OVERRIDE_COMPATIBLE(ERROR,
+ "Constructor of polyfill {0} must be override compatible with inherited constructor: {1}"),
+
+ /** 0: name of polyfill, 1: 'class' or 'interface' */
+ CLF_POLYFILL_DIFFERENT_TYPEPARS(ERROR, "Polyfill {0} must declare same type parameters as the filled {1}."),
+
+ /** 0: name of polyfill */
+ CLF_POLYFILL_INCOMPLETE_TYPEARGS(ERROR,
+ "Polyfill {0} must pass all type parameters to type arguments (even optional ones)."),
+
+ /** 0: name of polyfill, 1: type par, 2: type arg */
+ CLF_POLYFILL_TYPEPARS_DIFFER_TYPEARGS(ERROR,
+ "Polyfill {0} must pass type parameters to type arguments in same order and without modifications, but {1} differs from {2}."),
+
+ /** 0: list of modules name with polyfills, 0: member name */
+ CLF_POLYFILL_MULTIPOLYFILLS_MEMBER_CONFLICT(ERROR,
+ "Polyfills in {0} provide member {1} - only one provider per member is allowed."),
+
+ /** 0: name of polyfill */
+ CLF_POLYFILL_STATIC_FILLED_TYPE_NOT_AWARE(ERROR,
+ "For static polyfills, the module of the filled type {0} must be annotated with @StaticPolyfillAware."),
+
+ /** 0: name of polyfill, 1: file extension (.n4js or .n4jsd) */
+ CLF_POLYFILL_STATIC_DIFFERENT_VARIANT(ERROR,
+ "Since static polyfill {0} is declared in an {1} file, the filled type must also be declared in an {1} file."),
+
+ /** 0: string that is used as name for more than one literal */
+ ENM_DUPLICTAE_LITERALS(ERROR, "Multiple literals with name {0}."),
+
+ /** no parameters required */
+ ENM_INVALID_VALUE_EXPRESSION(ERROR,
+ "Only string literals and number literals are allowed as value of an enum literal."),
+
+ /** 0: string with the name of the meta property */
+ ENM_LITERALS_HIDE_META(ERROR, "EnumLiteral cannot have the same name as Enum meta property <{0}>."),
+
+ /** no parameters required */
+ ENM_WITHOUT_LITERALS(ERROR, "An enum type must declare at least one literal."),
+
+ /** no parameters required */
+ ENM_BOTH_NUMBER_AND_STRING_BASED(ERROR, "An enum may not be annotated with both @NumberBased and @StringBased."),
+
+ /** no parameters required */
+ ENM_ILLEGAL_NUMERIC_VALUE(ERROR, "Values of type number may only be used for literals of @NumberBased enums."),
+
+ /** no parameters required */
+ ENM_ILLEGAL_STRING_VALUE(ERROR, "Values of literals in @NumberBased enums must be of type number."),
+
+ /** no parameters required */
+ ENM_INVALID_USE_OF_NUM_OR_STR_BASED_ENUM(ERROR,
+ "A @NumberBased or @StringBased enum may only be used in type annotations and in property access expressions to access either one of its literals or the static getter called 'literals'."),
+
+ /** no parameters required */
+ /**
+ * ITF_MEMBER_ACCESSIBILITY(ERROR, "Member of an interface must not have lower accessibility than the containing
+ * interface."),
+ */
+ /** no parameters required */
+ ITF_NO_FINAL(ERROR, "Interfaces must not be declared final."),
+
+ /** 0: name of field, 1: name of interface */
+ ITF_NO_FIELD_INITIALIZER(ERROR,
+ "Cannot initialize field in interface. Only classes or interfaces implementing {1} can initialize {0}."),
+
+ /** 0: property kind name, 1: structural /nominal / */
+ ITF_NO_PROPERTY_BODY(ERROR, "{0} in {1}interfaces must not have a body."),
+
+ /** no parameters required */
+ ITF_CONSTRUCTOR_COVARIANCE(ERROR, "Constructors in interfaces must be annotated with @CovariantConstructor."),
+
+ /** no parameters required */
+ ITF_IN_DEFINITION_PRJ_NON_N4JS(WARNING,
+ "Nominal interface declarations in definition projects should instead be structural (use '~')."),
+
+ /** no parameters required */
+ STRCT_ITF_CANNOT_EXTEND_INTERFACE(ERROR, "Structural interfaces cannot extend nominal interfaces."),
+
+ /** no parameters required */
+ STRCT_ITF_CANNOT_CONTAIN_STATIC_MEMBERS(ERROR, "Structural interfaces cannot contain static members."),
+
+ /** no parameters required */
+ STRCT_ITF_MEMBER_MUST_BE_PUBLIC(WARNING, "Non-public members of structural interfaces are effectless."),
+
+ /** 0: name of cyclic type aliases */
+ ALI_CYCLIC_TYPE_ALIAS(ERROR, "Cyclic type alias declaration: {0}."),
+
+ /** no parameters required */
+ ALI_INVALID_MODIFIER(ERROR, "A type alias may be referenced {0} only if its aliased type may be referenced {0}."),
+
+ /** 0: the string '{}' */
+ ALI_INVALID_TYPE_ALIAS_IN_TYPE_TYPE_REF(ERROR,
+ "A type alias may be used inside type{0} or constructor{0} only if its aliased type may be used at this location."),
+
+ /** 0: passed parameter count, 1: expected parameter count */
+ FUN_PARAM_COUNT(ERROR, "Passed parameter count {0} doesn't match with expected parameter count {1}."),
+
+ /** no parameters required */
+ FUN_BLOCK(WARNING,
+ "Functions declarations should not be placed in blocks. Use a function expression or move the statement to the top of the outer function."),
+
+ /** no parameters required */
+ FUN_BODY(ERROR, "Functions have to have a body."),
+
+ /** 0: element description, 1: conflicting category */
+ FUN_NAME_RESERVED(ERROR, "{0} may be confused with {1}."),
+
+ /** no parameters */
+ FUN_NAME_MISSING(ERROR, "Function declarations must have a name."),
+
+ /** 0: formal parameter */
+ FUN_PARAM_OPTIONAL_WRONG_SYNTAX(ERROR, "Wrong syntax: Use {0}=undefined instead of ?."),
+
+ /** no parameters */
+ FUN_PARAM_INITIALIZER_ILLEGAL_FORWARD_REFERENCE(ERROR,
+ "Illegal forward reference to formal parameter of same function."),
+
+ /** no parameters */
+ FUN_PARAM_INITIALIZER_ONLY_UNDEFINED_ALLOWED(ERROR,
+ "Only 'undefined' allowed for initializers of default parameters in function types."),
+
+ /** 0: formal parameter */
+ /** 1: identifier */
+ FUN_PARAM_INITIALIZER_ILLEGAL_REFERENCE_TO_BODY_VARIABLE(ERROR,
+ "Initializer of parameter '{0}' cannot reference the identifier '{1}' declared in the body."),
+
+ /** 0: formal parameter */
+ FUN_PARAM_INITIALIZER_ILLEGAL_AWAIT_CALL(ERROR,
+ "Illegal await-expression in initializer of formal parameter '{0}'."),
+
+ /**
+ * 0: name of actually used generator type, 1: expected generator kind (synchronous or asynchronous), 2: name of
+ * expected generator type
+ */
+ FUN_GENERATOR_RETURN_TYPE_MISMATCH(WARNING,
+ "Type {0} is intended for {1} generator functions; consider using type {2} instead."),
+
+ /** no parameters required */
+ AST_SEPARATE_DEFAULT_EXPORT_WITHOUT_FROM(ERROR, "Missing from-clause in default re-export."),
+
+ /** 0: element, 1: kind of value */
+ AST_ELEMENT_MISUSED_AS_VALUE_OR_TYPE(ERROR, "{0} cannot be used as a {1}."),
+
+ /** no parameters required */
+ AST_INVALID_NEW_TARGET(ERROR, "Invalid new.target."),
+
+ /** no parameters required */
+ AST_INVALID_YIELD_EXPRESSION(ERROR,
+ "The parameter initializer of a generator may not contain a `yield` expression."),
+
+ /** no parameters required */
+ AST_CONST_IN_STATEMENT_POSITION(ERROR, "Const variable statements must be on the top level or nested in a block."),
+
+ /** no parameters required */
+ AST_LET_IN_STATEMENT_POSITION(ERROR, "Let declarations may not appear in statement position."),
+
+ /** 0: name of blank const variable */
+ AST_CONST_HAS_NO_INITIALIZER(ERROR, "Const variable {0} must be provided with an initializer."),
+
+ /** no parameters required */
+ AST_STR_NO_OCTALS(ERROR, "octal literals and octal escape sequences are not allowed in strict mode."),
+
+ /** 0: operand (decrement or increment) */
+ AST_INVALID_OPERAND(ERROR, "Invalid {0} operand."),
+
+ /** no parameters required */
+ AST_EXP_INVALID_LHS_ASS(ERROR, "Invalid assignment left-hand side."),
+
+ /** 0: identifier */
+ AST_RESERVED_IDENTIFIER(ERROR, "{0} is a reserved identifier."),
+
+ /** no parameters required */
+ AST_STR_NO_WITH_STMT(ERROR, "With statement not allowed."),
+
+ /** no parameters required, not used yet in AST, was before in N4JSStrictValidator */
+ AST_STR_FUN_NOT_NESTED(ERROR, "Functions must only be declared on script level or as part of other expressions"),
+
+ /** no parameters required */
+ AST_INVALID_RETURN(ERROR, "return statement without enclosing function"),
+
+ /** no parameters required */
+ AST_INVALID_CONTINUE(ERROR, "continue statement without enclosing iteration"),
+
+ /** no parameters required */
+ AST_INVALID_BREAK(ERROR, "break statement without enclosing iteration or case block"),
+
+ /** no parameters required */
+ AST_INVALID_LABEL(ERROR, "Label must be of an enclosing iteration statement but may not cross function boundaries"),
+
+ /** no parameters required */
+ AST_THIS_WRONG_PLACE(ERROR,
+ "The 'this' type isn't allowed on this place. (Please refer to Spec for valid use cases.)"),
+
+ /** 0: variable name */
+ AST_VAR_DECL_RECURSIVE(WARNING,
+ "Reference to variable {0} within the initializer expression of the declaration of {0}."),
+
+ /** no parameters required */
+ AST_VAR_DECL_IN_FOR_INVALID_INIT(ERROR,
+ "The iteration variable of a for..in or for..of loop must not be provided with an initializer."),
+
+ /** no parameters required */
+ AST_INVALID_FOR_AWAIT(ERROR, "Only for..of loops may be used for asynchronous iteration with 'for await'."),
+
+ /** no parameters required */
+ AST_INVALID_OPTIONAL_TYPE_PARAMS(ERROR,
+ "Only type parameters of classes, interfaces, and type aliases may be declared optional."),
+
+ /** no parameters required */
+ AST_NO_TYPE_ARGS_IN_CLASSIFIERTYPEREF(ERROR, "Only raw types can be used in classifier type references."),
+
+ /** no parameters required */
+ AST_NO_FUNCTIONTYPEREFS_IN_CLASSIFIERTYPEREF(ERROR,
+ "Function types are not allowed in classifier type references."),
+
+ /** no parameters required */
+ AST_INVALID_EXPR_IN_LHS_DESTRUCTURING_PATTERN(ERROR,
+ "Only a variable or nested destructuring pattern is allowed at this location within a destructuring pattern."),
+
+ /** no parameters required */
+ AST_INVALID_PROPERTY_METHOD_IN_LHS_DESTRUCTURING_PATTERN(ERROR,
+ "Property methods are not allowed within an object destructuring pattern."),
+
+ /** no parameters required */
+ AST_INVALID_DEFAULT_EXPR_SINGLE_NAME_PROPERTY(ERROR,
+ "A default value is only allowed within a destructuring pattern."),
+
+ /** no parameters required */
+ AST_REST_MUST_APPEAR_AT_END(ERROR, "Rest operator only allowed on last element in an array destructuring pattern."),
+
+ /** no parameters required */
+ AST_REST_WITH_INITIALIZER(ERROR, "Rest operator does not support an initializer."),
+
+ /** no parameters required */
+ AST_TYPE_DECL_MISSING_NAME(ERROR, "Name missing in type declaration."),
+
+ /** no type annotation for catch variable */
+ AST_CATCH_VAR_TYPED(ERROR, "Catch variable must not be typed."),
+
+ /** 0: name of the JavaScript variant of the context */
+ AST_TOP_LEVEL_STATEMENTS(ERROR, "Top-level statements are not supported in {0} files."),
+
+ /** No parameters */
+ AST_VAR_STMT_NO_DECL(ERROR, "A variable statement must at least contain one variable declaration."),
+
+ /** 0: script annotation name */
+ AST_SCRIPT_ANNO_INVALID_PLACEMENT(ERROR, "The script annotation @@{0} must be placed at the top of the module."),
+
+ /** 0: Forbidden Type e.g. null / undefined */
+ AST_BINARY_LOGICAL_EXPRESSION_MISSING_PART(ERROR, "The logical expression is missing the {0}."),
+
+ /** no parameters required */
+ AST_IMPORT_CALL_SPREAD(ERROR, "The spread operator is not allowed in import calls."),
+
+ /** 0: Invalid parent e.g. && / || */
+ AST_INVALID_COALESCE_PARENT(ERROR, "Nullish coalescing expressions cannot be contained within an {0} operation. "),
+
+ /** 0: Invalid child e.g. && / || */
+ AST_INVALID_COALESCE_CHILD(ERROR, "Nullish coalescing expressions cannot immediately contain an {0} operation."),
+
+ /** 0: local variable name */
+ CFG_LOCAL_VAR_UNUSED(WARNING, "The local variable {0} is never used"),
+
+ /** 0: local variable name */
+ CFG_USED_BEFORE_DECLARED(WARNING, "Variable {0} is used before it is declared"),
+
+ /** 0: local variable name */
+ /** 1: 'is' or 'may be' */
+ /** 2: 'null' or 'undefined' */
+ /** 3: reason (optional) */
+ DFG_NULL_DEREFERENCE(WARNING, "Variable {0} {1} {2}{3}"),
+
+ /** 0: shadowing object, 1: shadowed object */
+ AST_NAME_SHADOW_WARN(WARNING, "{0} shadows {1}."),
+
+ /** 0: shadowing object, 1: shadowed object */
+ AST_NAME_SHADOW_ERR(ERROR, "{0} shadows {1}."),
+
+ /** 0: hiding parameter 1: hidden parameter */
+ AST_GLOBAL_NAME_SHADOW_ERR(ERROR, "{0} shadows {1} from global scope."),
+
+ /** 0: name */
+ AST_GLOBAL_JS_NAME_CONFLICT(ERROR, "Globally defined element named {0} must be defined in runtime environment."),
+
+ /** 0: name */
+ AST_GLOBAL_NAME_CONFLICT(ERROR, "Globally defined element must not be named {0}."),
+
+ /** 0: duplicating object, 1: duplicated object */
+ AST_NAME_DUPLICATE_ERR(ERROR, "{0} duplicates {1}."),
+
+ /** 0: duplicating object, 1: duplicated object */
+ AST_NAME_DUPLICATE_WARN(WARNING, "{0} duplicates {1}."),
+
+ /** 0: grammar rule, 1: value */
+ VCO_DOUBLE_NEGATIVE(ERROR, "{0}-value may not be negative (value: {1})."),
+
+ /** no parameters required */
+ VCO_DOUBLE_CONVERT_EMPTY_STR(ERROR, "Couldn't convert empty string to a double value."),
+
+ /** 0: the string value */
+ VCO_DOUBLE_CONVERT_STR(ERROR, "Couldn't convert {0} to a double value."),
+
+ /** 0: grammar rule, 1: value */
+ VCO_HEXINT_NEGATIVE(ERROR, "{0}-value may not be negative (value: {1})."),
+
+ /** no parameters required */
+ VCO_HEXINT_CONVERT_EMPTY_STR(ERROR, "Couldn't convert empty string to an hex int value."),
+
+ /** 0: the string value */
+ VCO_HEXINT_CONVERT_TOO_SHORT(ERROR, "Couldn't convert {0} to an int value."),
+
+ /** 0: the string value */
+ VCO_HEXINT_CONVERT_STR(ERROR, "Couldn't convert {0} to an hex int value."),
+
+ /** 0: grammar rule, 1: value */
+ VCO_BINARYINT_NEGATIVE(ERROR, "{0}-value may not be negative (value: {1})."),
+
+ /** no parameters required */
+ VCO_BINARYINT_CONVERT_EMPTY_STR(ERROR, "Couldn't convert empty string to a binary int value."),
+
+ /** 0: the string value */
+ VCO_BINARYINT_CONVERT_TOO_SHORT(ERROR, "Couldn't convert {0} to an int value."),
+
+ /** 0: the string value */
+ VCO_BINARYINT_CONVERT_STR(ERROR, "Couldn't convert {0} to a binary int value."),
+
+ /** 0: grammar rule, 1: value */
+ VCO_OCTALINT_NEGATIVE(ERROR, "{0}-value may not be negative (value: {1})."),
+
+ /** no parameters required */
+ VCO_OCTALINT_CONVERT_EMPTY_STR(ERROR, "Couldn't convert empty string to an octal int value."),
+
+ /** 0: the string value */
+ VCO_OCTALINT_CONVERT_TOO_SHORT(ERROR, "Couldn't convert {0} to an int value."),
+
+ /** 0: the string value */
+ VCO_OCTALINT_LEADING_ZEROS(ERROR, "Don't use extra leading zeros {0}."),
+
+ /** 0: the string value */
+ VCO_OCTALINT_CONVERT_STR(ERROR, "Couldn't convert {0} to an octal int value."),
+
+ /** 0: grammar rule, 1: value */
+ VCO_SCIINT_NEGATIVE(ERROR, "{0}-value may not be negative (value: {1})."),
+
+ /** no parameters required */
+ VCO_SCIINT_CONVERT_EMPTY_STR(ERROR, "Couldn't convert empty string to an scientific int value."),
+
+ /** 0: the string value */
+ VCO_SCIINT_CONVERT_STR(ERROR, "Couldn't convert {0} to an scientific int value."),
+
+ /** 0: identifier, 1: position */
+ VCO_IDENT_ESCAPE_SEQ(ERROR, "Illegal escape sequence in identifier {0} at position {1}."),
+
+ /** 0: result, 1: identifier, 2: position */
+ VCO_IDENT_ILLEGAL_CHAR_WITH_RESULT(ERROR, "Illegal character in identifier '{0}' ({1}) at position {2}."),
+
+ /** 0: identifier, 1: position */
+ VCO_IDENT_ILLEGAL_CHAR(ERROR, "Illegal character in identifier '{0}' at position {1}."),
+
+ /** no parameters required */
+ VCO_JSXIDENT_WHITESPACE_COMMENT(ERROR,
+ "JSX attribute names may not contain whitespace or comments. Attribute names ending with a '-' and directly followed by another attribute name are merged and must not contain whitespace or comments."),
+
+ /** no parameters required */
+ VCO_STRING_DOUBLE_QUOTE(ERROR, "String literal is not properly closed by a double-quote."),
+
+ /** no parameters required */
+ VCO_STRING_QUOTE(ERROR, "String literal is not properly closed by a quote."),
+
+ /** no parameters required */
+ VCO_TEMPLATE_QUOTE(ERROR, "Template literal is not properly closed by a backtick."),
+
+ /** no parameters required */
+ VCO_TEMPLATE_MIDDLE(ERROR, "Template literal is not properly closed by ${."),
+
+ /** no parameters required */
+ VCO_TEMPLATE_IN_OPT_CHAIN(ERROR, "Tagged template expressions are not permitted in an optional chain."),
+
+ /** no parameters required */
+ VCO_STRING_BAD_ESCAPE_WARN(WARNING, "Bad escapement"),
+
+ /** no parameters required */
+ VCO_STRING_BAD_ESCAPE_ERROR(ERROR, "Bad escapement"),
+
+ /** no parameters required */
+ VCO_REGEX_INVALID(ERROR, "Invalid regular expression literal"),
+
+ /** 0: literal */
+ VCO_REGEX_ILLEGAL_ESCAPE(ERROR, "Illegal escape sequence in regular expression {0}"),
+
+ /** no parameters required */
+ VCO_REGEX_NAMED_GROUP(WARNING, "Named capture groups are not supported on all platforms."),
+
+ /** no parameters required */
+ VCO_NPE(ERROR,
+ "A NullPointerException occurred. This indicates a missing value converter or a bug in its implementation."),
+
+ /** 0: feature name */
+ VCO_NULL_FEATURE(ERROR, "ValueConverter returned null for primitive feature {0}"),
+
+ /** no parameters required */
+ BIT_SYMBOL_INVALID_USE(ERROR,
+ "Invalid use of 'Symbol': may only be used to create symbols (i.e. Symbol()) or to access built-in symbols (e.g. Symbol.iterator)."),
+
+ /** no parameters required */
+ BIT_SYMBOL_NOT_A_CTOR(ERROR, "Symbol is not a constructor, use Symbol() without new."),
+
+ /** no parameters required */
+ TYS_MISSING(ERROR, "Types model hasn't been built for this file. Please report this bug to a N4JS developer."),
+
+ /** 0: expression */
+ TYS_CANNOT_TYPE(ERROR, "cannot type {0}."),
+
+ /** 0: left expression, 1: right expression */
+ TYS_NO_SUBTYPE(ERROR, "{0} is not a subtype of {1}"),
+
+ /** 0: expected type, 1: actual type */
+ TYS_NO_SUPERTYPE_WRITE_ACCESS(ERROR, "expecting write-access for type {0} but {1} is not a super type of {0}."),
+
+ /** no parameters required */
+ TYS_NULL_OBJECT(ERROR, "passed null object to system at {0}."),
+
+ /** no parameters required */
+ TYS_VOID_AT_WRONG_LOCATION(ERROR,
+ "Type 'void' may only be used to declare the return type of functions and methods."),
+
+ /** 0: member type, 1: member name, 2: type name */
+ TYS_MEMBER_NOT_IN_STRUCTURAL_TYPE_DEF_SITE(ERROR, "{0} {1} is not available for structurally defined type {2}."),
+
+ /** 0: member type, 1: member name, 2: type name */
+ TYS_MEMBER_NOT_IN_STRUCTURAL_TYPE_USE_SITE(ERROR, "{0} {1} is not available for structurally referenced type {2}."),
+
+ /** 0: member type, 1: member name, 2: type name */
+ TYS_MEMBER_NOT_IN_STRUCTURAL_FIELDS_TYPE_USE_SITE(ERROR,
+ "{0} {1} is not available for fields-only-referenced type {2}."),
+
+ /** no parameters required */
+ TYS_INSTANCEOF_NOT_SUPPORTED_FOR_USE_SITE_STRUCTURAL(ERROR,
+ "'instanceof' cannot be used with use site structural typing."),
+
+ /** 0: type name */
+ TYS_INSTANCEOF_NOT_SUPPORTED_FOR_BUILT_IN_INTERFACES(ERROR,
+ "'instanceof' cannot be used with built-in interface {0}."),
+
+ /** no parameters required */
+ TYS_INSTANCEOF_NOT_SUPPORTED_FOR_PRIMITIVE_TYPES(ERROR, "'instanceof' cannot be used with primitive types."),
+
+ /** 0: property name */
+ TYS_PROPERTY_HAS_NO_SETTER(ERROR, "Property {0} has no setter."),
+
+ /** 0: type name */
+ TYS_PRIMITIVE_TYPE_DYNAMIC(ERROR, "Primitive type {0} must not be referenced dynamically."),
+
+ /** no parameters required */
+ TYS_COMPOUND_MISSING_GETTER(ERROR, "Missing getter on left-hand side of compound assignment."),
+
+ /** no parameters required */
+ TYS_NON_VOID_ASYNC(ERROR,
+ "Internal error: Only Promise allowed as inferred return type of an async FunctionDefinition"),
+
+ /** no parameters required */
+ TYS_NON_THIS_ASYNC(ERROR, "The return type of an async function is not allowed to refer to the this-type."),
+
+ /** 0: type name */
+ TYS_FOR_IN_VAR_STRING(ERROR, "Type of for-in-loop variable must be a super type of string but {0} is not."),
+
+ /** no parameters required */
+ TYS_ADDITIONAL_STRUCTURAL_MEMBERS_ON_TYPE_VARS(ERROR,
+ "No additional structural members allowed on type variables, since they can cause collisions."),
+
+ /** no parameters required */
+ TYS_FUNCTION_DISALLOWED_AS_TYPE(ERROR, "The name of a declared function may not be used as a type name."),
+
+ /** no parameters required */
+ TYS_STRUCTURAL_PRIMITIVE(WARNING, "Structural type operator ~ does not have any effect on primitive types."),
+
+ /** no parameters required */
+ EXP_USE_OF_UNDEF_EXPR(WARNING,
+ "The type of this expression is 'undefined', so it will never evaluate to a value other than 'undefined'."),
+
+ /** 0: actual type */
+ EXP_CALL_NOT_A_FUNCTION(ERROR, "Not a function or method: {0}."),
+
+ /** 0: comma-separated list of conflicting callable type references */
+ EXP_CALL_CONFLICT_IN_INTERSECTION(ERROR, "More than one callable type in intersection: {0}."),
+
+ /** no parameters required */
+ EXP_CALL_CLASS_CTOR(ERROR, "Cannot directly invoke class constructor functions; use 'new' instead."),
+
+ /** 0: actual type */
+ EXP_NEW_NOT_A_CTOR(ERROR, "Not a reference to a constructor: {0}."),
+
+ /** 0: intersection type with conflicting ctors or construct signatures */
+ EXP_NEW_CONFLICT_IN_INTERSECTION(ERROR, "More than one constructor or construct signature in intersection: {0}."),
+
+ /** 0: type arg name of constructor, 1: static type */
+ EXP_NEW_WILDCARD_NO_COVARIANT_CTOR(ERROR,
+ "Cannot instantiate {0}, because {1} does not have a @CovariantConstructor."),
+
+ /** 0: type arg name of constructor */
+ EXP_NEW_WILDCARD_OR_TYPEVAR(ERROR, "Cannot instantiate {0}."),
+
+ /** 0: abstract class, interface, 1: classifier name */
+ EXP_NEW_CANNOT_INSTANTIATE(ERROR, "Cannot instantiate {0} {1}."),
+
+ /** 0: number of expected type args, 1: number of actual type args */
+ EXP_WRONG_NUMBER_OF_TYPEARGS(ERROR, "Incorrect number of type arguments: expected {0}, got {1}."),
+
+ /**
+ * 0: class, interface, method, function 1: name of classifier/method/function, 2: number of expected type args, 3:
+ * number of actual type args
+ */
+ EXP_WRONG_NUMBER_OF_TYPEARGS_FOR_ELEMENT(ERROR,
+ "Incorrect number of type arguments for {0} {1}: expected {2}, got {3}."),
+
+ /** 0: maximum number of element types in an ArrayN */
+ EXP_WRONG_NUMBER_OF_TYPEARGS_FOR_ITERABLE_N_SYNTAX(ERROR,
+ "The ArrayN types are available for a maximum of {0} element types only (i.e. type Array{0})."),
+
+ /** 0: upper or lower, 1: covariant or contravariant */
+ EXP_INCONSISTENT_VARIANCE_OF_TYPE_ARG(ERROR,
+ "Cannot use wildcard with {0} bound as argument to a {1} type parameter."),
+
+ /** 0: covariant or contravariant, 1: covariant or contravariant */
+ EXP_INCONSISTENT_VARIANCE_OF_TYPE_ARG_IN_OUT(ERROR, "Cannot combine {0} on use site with {1} on definition site."),
+
+ /** 0: expected num of params, 1: actual num of params */
+ EXP_NUM_OF_ARGS_TOO_FEW(ERROR, "Incorrect number of arguments: expected {0}, got {1}."),
+
+ /** 0: expected num of params, 1: actual num of params */
+ EXP_NUM_OF_ARGS_TOO_MANY(ERROR, "Incorrect number of arguments: expected {0}, got {1}."),
+
+ /** 0: from type ref, 1: target type ref */
+ EXP_CAST_FAILED(ERROR, "Cannot cast from {0} to {1}"),
+
+ /** 0: from type ref, 1: target type ref */
+ EXP_CAST_UNNECESSARY(WARNING, "Unnecessary cast from {0} to {1}"),
+
+ /** no parameter required */
+ EXP_CAST_INVALID_TARGET(ERROR,
+ "Can only cast to class, interface, enum, function, primitive, union or intersection types"),
+
+ /** 0: recognized type, 2: result, e.g. NaN */
+ EXP_MATH_OPERATION_RESULT_IS_CONSTANT(WARNING, "Operand {0} will always result in {1}."),
+
+ /** 0: recognized type, 1: constant value */
+ EXP_MATH_OPERAND_IS_CONSTANT(WARNING, "Operand of type {0} will be interpreted as {1}."),
+
+ /** 0: recognized type, 2: result, e.g. NaN */
+ EXP_MATH_TYPE_NOT_PERMITTED(ERROR, "Operand of type {0} cannot be converted to number."),
+
+ /** 0: left type 1: rght type 2: result */
+ EXP_WARN_CONSTANT_EQUALITY_TEST(WARNING,
+ "Neither {0} is a subtype of {1} nor {1} is a subtype of {0}. The expression will always evaluate to {2}."),
+
+ /** 0: Forbidden Type e.g. null / undefined */
+ EXP_FORBIDDEN_TYPE_IN_BINARY_LOGICAL_EXPRESSION(ERROR,
+ "{0} is not allowed on the left hand side of a logical expression."),
+
+ /** 0: member description, 1: type of target, 2: declared this type (from @This annotation) */
+ EXP_ACCESS_INVALID_TYPE_OF_TARGET(ERROR,
+ "Target of property access not a subtype of the declared @This type of {0}: {1} is not a subtype of {2}."),
+
+ /** 0: method name */
+ EXP_METHOD_REF_UNATTACHED_FROM_RECEIVER(ERROR,
+ "A reference to method {0} is created detached from a (correct) this-instance."),
+
+ /** 0: await expression, 1 async annotation */
+ EXP_MISPLACED_AWAIT(ERROR, "{0} is allowed only inside functions annotated with {1}."),
+
+ /** no parameter required */
+ EXP_MISSNG_AWAIT_FOR_ASYNC_TARGET(WARNING,
+ "Calling async function without await, Promise should be made explicit."),
+
+ /** 0: Suspicious expression, 1: boolean value, 2:left-hand/right-hand */
+ EXP_WARN_DISPENSABLE_CONDITIONAL_EXPRESSION(WARNING,
+ "Dispensable use of conditional expression. The expression '{0}' always evaluates to {1}, so only the {2} side will ever be evaluated."),
+
+ /** no parameter required */
+ EXP_AWAIT_NON_ASYNC(WARNING,
+ "await should only be used on expressions of type Promise,?> since otherwise it has no effect."),
+
+ /** 0: recognized expression */
+ EXP_AWAIT_NON_ASYNC_SPECIAL(WARNING, "await should not be used on '{0}' since it has no effect here."),
+
+ /** no parameter required */
+ FUN_RETURNTYPE_VOID_FOR_SETTER_VIOLATED(ERROR, "Set accessors must not return anything."),
+
+ /** 0: name of return type */
+ FUN_MISSING_RETURN_EXPRESSION(ERROR, "Return statement must have an expression of type {0}"),
+
+ /** no parameter required */
+ FUN_MISSING_RETURN_OR_THROW_STATEMENT(ERROR, "Missing return or throw statement."),
+
+ /** no parameter required */
+ FUN_MISSING_ELSE_BRANCH_FOR_CONDITIONAL_LAST_CONTROL_FLOW(ERROR,
+ "Last if statement on control flow path is missing required else branch."),
+
+ /** no parameter required */
+ FUN_MISSING_RETURN_OR_THROW_STATEMENT_WHILE_CANNOT_BE_CHECKED(ERROR,
+ "Missing return or throw statement after while-expression. Correct termination of while-loops cannot be verified. Please append return/throw."),
+
+ /** no parameter required */
+ FUN_MISSING_RETURN_OR_THROW_STATEMENT_FOR_CANNOT_BE_CHECKED(ERROR,
+ "Missing return or throw statement after for-expression. Correct termination of for-loops cannot be verified. Please append return/throw."),
+
+ /** no parameter required */
+ FUN_DEAD_CODE(WARNING, "Dead code."),
+
+ /** 0: last executed statement name */
+ FUN_DEAD_CODE_WITH_PREDECESSOR(WARNING, "Dead code. No execution possible after {0}."),
+
+ /** no parameters required */
+ FUN_SETTER_CANT_BE_VARIADIC(ERROR, "Variadic parameter is not allowed in setter declarations."),
+
+ /** no parameters required */
+ FUN_SETTER_CANT_BE_DEFAULT(ERROR, "Default parameter is not allowed in setter declarations."),
+
+ /** no parameters required */
+ FUN_PARAM_VARIADIC_ONLY_LAST(ERROR, "Only the last formal parameter can be variadic."),
+
+ /** 0: name of parameter */
+ FUN_PARAM_IMPLICIT_DEFAULT_PARAM(WARNING,
+ "This parameter is changed to the default parameter '{0}=undefined' since it follows a default parameter."),
+
+ /** no parameter required */
+ FUN_PARAM_VARIADIC_WITH_INITIALIZER(ERROR, "Variadic parameters must not have a default initializer."),
+
+ /** no parameter required */
+ FUN_SINGLE_EXP_LAMBDA_IMPLICIT_RETURN_ALLOWED_UNLESS_VOID(ERROR,
+ "An arrow-function is used in a context where its body is expected to have some value as opposed to being void."),
+
+ /** 0: type parameter name */
+ FUN_UNUSED_GENERIC_TYPE_PARAM(WARNING, "Type variable {0} not used in parameters or return type."),
+
+ /** no parameters required */
+ KEY_SUP_INVALID_USAGE(ERROR,
+ "Keyword super may only be used in member access expressions, call expressions or new expressions."),
+
+ /** no parameters required */
+ KEY_SUP_ACCESS_INVALID_LOC(ERROR,
+ "Super member access may only be used in constructors, methods, getters, or setters."),
+
+ /** no parameters required */
+ KEY_SUP_ACCESS_NO_EXTENDS(ERROR, "Super member access requires a declared super type."),
+
+ /** no parameters required */
+ KEY_SUP_ACCESS_INVALID_LOC_INTERFACE(ERROR, "Super member access may not be used in interfaces."),
+
+ /** no parameters required */
+ KEY_SUP_ACCESS_FIELD(ERROR, "Super member access may not be used to access a field."),
+
+ /** no parameters required */
+ KEY_SUP_CTOR_INVALID_LOC(ERROR, "Super calls may only be used in constructors."),
+
+ /** no parameters required */
+ KEY_SUP_NEW_NOT_SUPPORTED(ERROR, "Keyword super with in expressions is not supported yet."),
+
+ /** no parameters required */
+ KEY_SUP_NESTED(ERROR, "Super call must not be nested in function expressions."),
+
+ /** no parameters required */
+ KEY_SUP_CTOR_EXPRSTMT(ERROR, "Super constructor call must no be used in a composed expression."),
+
+ /** 0: container in which super is nested (with line number). */
+ KEY_SUP_CTOR_NESTED(ERROR,
+ "Super constructor call must only be directly contained in constructor body, i.e. not nested in {0}."),
+
+ /** 0: container in which super is nested (with line number). */
+ KEY_SUP_CTOR_INVALID_EXPR_BEFORE(ERROR, "Super constructor call must not be preceded by {0}."),
+
+ /** 0: super class name */
+ KEY_SUP_REQUIRE_EXPLICIT_SUPERCTOR_CALL(ERROR, "Must explicitly invoke constructor of super class {0}."),
+
+ /** no parameters required */
+ KEY_SUP_CALL_NO_INDEXACCESS(ERROR, "Super member access may not be used with index access."),
+
+ /** no parameters required */
+ KEY_THIS_REJECTED_IN_TOP_LEVEL_LAMBDA(ERROR,
+ "In a top-level arrow function, the 'this' keyword refers to nothing."),
+
+ /** no parameters required */
+ EXP_OPTIONAL_INVALID_PLACE(ERROR, "The optional modifier isn't allowed here."),
+
+ /** 0: name of const variable */
+ EXP_ASSIGN_CONST_VARIABLE(ERROR, "Const variable {0} is read-only."),
+
+ /** 0: names of legal built-in symbol */
+ EXP_INDEXED_ACCESS_SYMBOL_INVALID(ERROR, "Indexed access with built-in symbols is only allowed for {0}."),
+
+ /** 0: name of built-in symbol, 1: name of expected receiver type */
+ EXP_INDEXED_ACCESS_SYMBOL_WRONG_TYPE(ERROR,
+ "Access of property Symbol.{0} only allowed for instances of {1}, immediate instances of Object, and dynamic types."),
+
+ /** 0: name of built-in symbol, 1: name of receiver type */
+ EXP_INDEXED_ACCESS_SYMBOL_READONLY(ERROR, "Access to property Symbol.{0} of an {1} is read-only."),
+
+ /** no parameters required */
+ EXP_INDEXED_ACCESS_ENUM(ERROR, "Indexed access is not allowed for enumerations."),
+
+ /** no parameters required */
+ EXP_INDEXED_ACCESS_FORBIDDEN(ERROR,
+ "Indexed access is only allowed for strings, arrays and iterables and for immediate(!) instances of Object."),
+
+ /** 0: index-key in indexed-access */
+ EXP_INDEXED_ACCESS_COMPUTED_NOTFOUND(ERROR, "Member {0} not found."),
+
+ /** no parameters required */
+ EXP_INDEXED_ACCESS_IMPL_RESTRICTION(ERROR,
+ "Implementation restriction: member name clashes with compiler-internal, synthetic, mangled name."),
+
+ /** no parameters required */
+ EXP_PROMISIFY_INVALID_USE(ERROR,
+ "@Promisify may only be applied to a call expression with a @Promisifiable function or method as target."),
+
+ /** no parameters required */
+ EXP_COMPUTED_PROP_NAME_DISCOURAGED(WARNING,
+ "Computed property name using an expression other than a compile-time expression; this property won't be type-checked at compile time."),
+
+ /** 0: detailed message */
+ EXP_COMPILE_TIME_MANDATORY(ERROR, "Not a compile-time expression: {0}."),
+
+ /**
+ * 0: usage type ('invoke' or 'instantiate'), 1: name of interface with call/construct signature, 2: signature kind
+ * ('call' or 'construct')
+ */
+ EXP_CALL_CONSTRUCT_SIG_OF_INTERFACE_DIRECTLY_USED(ERROR,
+ "Cannot directly {0} interface {1}; its {2} signature applies to values of type {1}, not to {1} itself."),
+
+ /** 0: type names, submessage -- full message is a concatenation of these messages */
+ COMP_SUBMESSAGES(ERROR, "{1} in {0}."),
+
+ /** 0: member name */
+ UNI_UNCOMMON(ERROR, "Member {0} not present in all types of union or incompatible."),
+
+ /** 0: member name, 1: list of types in union that do not contain a member of that name */
+ UNI_MISSING(ERROR, "Member {0} not present in all types of union; missing from: {1}."),
+
+ /** 0: either 'getters' or 'setters', 1: member name, 2: either 'read-only' or 'write-only' */
+ UNI_INVALID_COMBINATION(ERROR, "Union combines fields and {0} with name {1} and therefore property {1} is {2}."),
+
+ /** 0: member name */
+ UNI_INVALID_COMBINATION_SETTER_VS_READ_ONLY_FIELD(ERROR,
+ "Union combines fields and setters with name {0} but still write-access is not allowed because one or more fields are read-only (const or @Final)."),
+
+ /** 0: member name, 1: list of kinds */
+ UNI_MULTIPLE_KINDS(ERROR, "Member {0} not of same kind in all types of union: {1}."),
+
+ /** 0: member name, 1: list of types */
+ UNI_DIFFERENT_TYPES(ERROR, "Member {0} not of same type in all types of union: {1}."),
+
+ /** no parameters required */
+ UNI_ANY_USED(WARNING, "The use of the any type in a union type is discouraged."),
+
+ /** no parameters required */
+ UNI_REDUNDANT_SUBTYPE(WARNING, "The use of redundant subtypes is discouraged."),
+
+ /** no parameters required */
+ INTER_ANY_USED(WARNING, "The use of the any type in an intersection type is discouraged."),
+
+ /** no parameters required */
+ INTER_ONLY_ONE_CLASS_ALLOWED(WARNING,
+ "An intersection type should not contain more than one class. Otherwise there cannot exist a value of such a type."),
+
+ /** no parameters required */
+ INTER_TYEPARGS_ONLY_ONE_CLASS_ALLOWED(WARNING,
+ "Type arguments for the same covariant type parameter in an intersection type should not contain more than one class. Otherwise there cannot exist a value of such a type."),
+
+ /** no parameters required */
+ INTER_WITH_ONE_GENERIC(WARNING,
+ "An intersection type should not contain different type arguments for the same invariant type parameter. Otherwise is can be instantiated only with undefined."),
+
+ /** no parameters required */
+ INTER_REDUNDANT_SUPERTYPE(WARNING, "The use of redundant supertypes is discouraged."),
+
+ /** 0: method member name, 1: list of kinds */
+ INTER_MEMBER_TYPE_CONFLICT(ERROR,
+ "Member method {0} is in conflict with non-method members in types of intersection: {1}."),
+
+ /** 0: member name */
+ INTER_UNCOMMON(ERROR, "Member {0} is incompatible in types of intersection."),
+
+ /** no parameters required */
+ ANN__N4JS_NO_EFFECT(WARNING, "This annotation is deprecated and has no effect."),
+
+ /** no parameters required */
+ ANN__ONLY_IN_N4JS(ERROR, "Annotations are a N4JS feature and cannot be used in JS mode."),
+
+ /** 0: annotation name */
+ ANN_NOT_DEFINED(ERROR, "The annotation @{0} is not defined."),
+
+ /** 0: annotation name, 1: expected number of arguments, 2: actual number of arguments */
+ ANN_WRONG_NUMBER_OF_ARGUMENTS(ERROR, "Wrong number of annotation arguments: @{0} expects {1} but got {2}."),
+
+ /** 0: annotation name, 1: expected type */
+ ANN_WRONG_ARGUMENT_TYPE(ERROR, "The annotation @{0} expects a {1} here."),
+
+ /** 0: annotation name */
+ ANN_DISALLOWED_AT_LOCATION(ERROR, "The annotation @{0} is disallowed for this location."),
+
+ /** 0: annotation name, 1: list of language variants */
+ ANN_ONLY_ALLOWED_LOCATION_CONSTRUCTORS(ERROR,
+ "The annotation @{0} may only be applied at a parameter of a constructor."),
+
+ /** 0: name of annotation (without @) */
+ ANN_NON_REPEATABLE(ERROR, "Duplicate annotation of non-repeatable type @{0}."),
+
+ /** 0: name of annotation */
+ ANN_UNNECESSARY(WARNING, "Unnecessary @{0}."),
+
+ /** no parameters required */
+ ANN_THIS_DISALLOWED_ON_STATIC_MEMBER_OF_INTERFACE(ERROR,
+ "@This annotation not allowed on static members of interfaces."),
+
+ /** 0: member description, 1: description of containing type, 2: required type */
+ ANN_THIS_NOT_SUBTYPE_OF_CONTAINING_TYPE(ERROR, "Declared @This type of {0} in {1} must be a subtype of {2}."),
+
+ /** no parameters required */
+ ANN_POLY_STATIC_POLY_ONLY_IN_POLYFILL_MODULE(ERROR,
+ "The annotation StaticPolyfill is only allowed in modules annotated as StaticPolyfillModule."),
+
+ /** no parameters required */
+ ANN_POLY_AWARE_AND_MODULE_MUTUAL_EXCLUSIVE(ERROR,
+ "A module cannot be annotated as filler and filling at the same time."),
+
+ /** no parameters required */
+ ANN_PROMISIFIABLE_MISSING_CALLBACK(ERROR,
+ "The annotation @Promisifiable is only allowed on functions/methods that take a function as a last argument (i.e. the callback)."),
+
+ /** no parameters required */
+ ANN_PROMISIFIABLE_BAD_CALLBACK_MORE_THAN_ONE_ERROR(ERROR,
+ "The callback of a @Promisifiable function/method must not have more than one parameter of type Error."),
+
+ /** no parameters required */
+ ANN_PROMISIFIABLE_BAD_CALLBACK_ERROR_NOT_FIRST_ARG(ERROR,
+ "If the callback of a @Promisifiable function/method has a parameter of type Error, this parameter must be the first parameter."),
+
+ /** 0: annotation name */
+ ANN_DISALLOWED_IN_NONDEFINTION_FILE(ERROR, "The annotation @{0} can only be applied in definition files."),
+
+ /** 0: annotation name */
+ ANN_DISALLOWED_IN_NON_RUNTIME_COMPONENT(ERROR, "The annotation @{0} can only be applied in a runtime component."),
+
+ /** 0: bug id */
+ ANN_UNUSED_IDEBUG(ERROR,
+ "No matching error found, apparently bug IDEBUG-{0} has been fixed or does not occur here."),
+
+ /** 0: name of the violating annotation. */
+ ANN_REQUIRES_TEST(ERROR, "Only methods annotated with @Test could be annotated with {0}."),
+
+ /** 0: annotation name, 1: list of language variants */
+ ANN_ONL_ALLOWED_IN_VARIANTS(ERROR, "The annotation @{0} may only be applied in {1} files."),
+
+ /** 0: annotation name, 1: list of language variants */
+ ANN_ONL_ALLOWED_AT_CLASSES_IN_N4JSD(ERROR, "The annotation @{0} may only be applied at classes in n4jsd files."),
+
+ /** 0: annotation name, 1: list of language variants */
+ ANN_DISALLOWED_ON_SHAPES(ERROR, "Only nominal interfaces can be annotated with @{0}."),
+
+ /** 0: annotation name */
+ ANN__TEST_ONLY_IN_TEST_SOURCES(WARNING,
+ "Test annotation @{0} may only be used in test source folders (defined in package.json)."),
+
+ /** 0: library name, 1: String of concatenated polyfilled things. */
+ POLY_ERROR_IN_RUNTIMEDEPENDENCY(ERROR, "Erroneous library {0} provides contradicting polyfills for {1}."),
+
+ /** 0: String of concatenated library names, 1: String of concatenated polyfilled things. */
+ POLY_CLASH_IN_RUNTIMEDEPENDENCY(ERROR,
+ "The libraries {0} provide polyfills for the same element {1} and cannot be used together."),
+
+ /** 0: String of concatenated library names, 1: String of concatenated polyfilled things. */
+ POLY_CLASH_IN_RUNTIMEDEPENDENCY_MULTI(ERROR,
+ "The libraries {0} provide polyfills for the same elements {1} and cannot be used together."),
+
+ /** 0: String of conflicting static-polyfilling modules. */
+ POLY_CLASH_IN_STATIC_POLYFILL_MODULE(ERROR,
+ "Only one module annotated with @@StaticPolyfillModule is allowed per project. Conflicting with {0}."),
+
+ /** no param */
+ POLY_STATIC_POLYFILL_MODULE_ONLY_FILLING_CLASSES(ERROR,
+ "Only top-level classes annotated as StaticPolyfill are allowed in a module annotated with StaticPolyfillModule."),
+
+ /** no param */
+ POLY_IMPLEMENTING_INTERFACE_NOT_ALLOWED(ERROR,
+ "The filling class cannot introduce additional interfaces; all interfaces must be declared on the filled class."),
+
+ /** doc: detected dependency cycle 0:String describing the cycle. */
+ PROJECT_DEPENDENCY_CYCLE(ERROR, "Dependency cycle of the projects: {0}."),
+
+ /** 0: ID of the non-existing project. */
+ NON_EXISTING_PROJECT(ERROR, "Project does not exist with project ID: {0}."),
+
+ /** 0: ID of the non-existing project. */
+ MISSING_YARN_WORKSPACE(ERROR,
+ "Project depends on workspace project {0} which is missing in the node_modules folder. Either install project {0} or introduce a yarn workspace of both of the projects."),
+
+ /** 0: human readable name of the obsolete feature block. */
+ OBSOLETE_BLOCK(WARNING, "Obsolete {0} block."),
+
+ /** 0: project project ID, 1: human readable name of the project type, 2: human readable name of the feature. */
+ INVALID_PROJECT_TYPE_REF(WARNING, "Project {0} of type {1} cannot be declared among the {2}."),
+
+ /** 0: library project ID */
+ INVALID_API_PROJECT_DEPENDENCY(WARNING,
+ "Library project {0} with an implementation ID cannot be declared among the dependencies of an API project."),
+
+ /** 0: violating feature/block name, 1: actual project type name */
+ INVALID_FEATURE_FOR_PROJECT_TYPE(WARNING, "{0} cannot be specified for {1} projects."),
+
+ /** 0: name used in duplicate */
+ DUPLICATE_PROJECT_REF(ERROR, "Duplicate project reference {0}."),
+
+ /** 0: name of the containing folder, 1: name of the nested folder */
+ OUTPUT_AND_SOURCES_FOLDER_NESTING(ERROR, "{0} must not be located inside {1}."),
+
+ /** no parameters required */
+ PROJECT_REFERENCES_ITSELF(ERROR, "Project cannot reference itself."),
+
+ /** 0: the type of the deprecated project 1: alternatives */
+ DEPRECATED_PROJECT_TYPE(WARNING, "Project type '{0}' is deprecated and will be removed soon. {1}"),
+
+ /** no parameters are required. */
+ MISMATCHING_TESTED_PROJECT_TYPES(WARNING, "Tested projects should have the same project type."),
+
+ /**
+ * 0: current project implementation ID, 1: the violating project's ID, 2: the implementation ID of the violating
+ * project
+ */
+ MISMATCHING_IMPLEMENTATION_ID(WARNING,
+ "Implementation ID mismatch. Current project belongs to '{0}' implementation while {1} project belongs to '{2}' implementation."),
+
+ /** 0: test library name */
+ SRCTEST_NO_TESTLIB_DEP(ERROR, "Project with source folder of type test should depend on {0}."),
+
+ /**
+ * 0: ID of the violating transitive external project dependency, 1: ID of the workspace project that is required by
+ * an external one.
+ */
+ EXTERNAL_PROJECT_REFERENCES_WORKSPACE_PROJECT(WARNING,
+ "Transitive external project dependency of project '{0}' requires a workspace project '{1}'. Current project setup could result in runtime oddities. It is highly recommended to import project '{0}' into workspace as well."),
+
+ /** 0: project type of containing project */
+ INVALID_FILE_TYPE_FOR_PROJECT_TYPE(ERROR, "An n4js file may not be contained in a project of type '{0}'."),
+
+ /** 0: resource name */
+ NO_PROJECT_FOUND(WARNING, "No project found for resource {0}."),
+
+ /** 0: part of the specifier that contains a dot, 1: the module specifier */
+ MOD_NAME_MUST_NOT_CONTAIN_DOTS(ERROR, "{0} of this module contain(s) the disallowed character '.' : '{1}'."),
+
+ /** 0: dependency name, 1: required version, 2: present version */
+ NO_MATCHING_VERSION(WARNING, "Project {0} is required in version {1}, but only version {2} is present."),
+
+ /**
+ * doc: checks if the module specifier wildcard can be resolved to an existing resource (not applied for
+ * implementation provided by runtime), spec: Component/Manifest/ModuleSpecifier-Constraint, 0: the module specifier
+ */
+ NON_EXISTING_MODULE_SPECIFIER(WARNING, "Module specifier {0} doesn't exist."),
+
+ /**
+ * doc: checks for invalid wildcards, spec: Component/Manifest/ModuleSpecifierWildcardConstraints, 0: the invalid
+ * part of the wild card
+ */
+ INVALID_WILDCARD(ERROR, "'{0}' isn't a valid character sequence in a wild card."),
+
+ /**
+ * doc: disallow relative navigation, spec: Component/Manifest/ModuleSpecifierWildcardConstraints, no parameters
+ * required
+ */
+ NO_RELATIVE_NAVIGATION(ERROR, "Relative navigation isn't allowed in a module specifier."),
+
+ /**
+ * doc: disallow switching off semantic validation for n4js files, spec:
+ * Component/Manifest/ModuleSpecifier-Constraint, 0: module filter type (e.g. noValidate)
+ */
+ DISALLOWED_NO_VALIDATE_FOR_N4JS(ERROR, "{0} paths shouldn't match n4js files."),
+
+ /** 0: sub description, 1: extend/implement, 2: super description, 3: implements/extends */
+ SYN_KW_EXTENDS_IMPLEMENTS_MIXED_UP(ERROR, "The {0} cannot {1} {2}, use '{3}'."),
+
+ /** no parameters required */
+ SYN_KW_EXTENDS_IMPLEMENTS_WRONG_ORDER(ERROR, "Extended class must be declared before implemented interfaces."),
+
+ /** 0: class description, 1: keyword, 2: super description */
+ CLF_WRONG_META_TYPE(ERROR, "The {0} cannot {1} {2}."),
+
+ /** 0: modifier name, 1: type of element that may not have this modifier (e.g. 'class', 'interface', etc.) */
+ SYN_MODIFIER_INVALID(ERROR, "Modifier {0} is not allowed on a {1}."),
+
+ /** 0: modifier name */
+ SYN_MODIFIER_DUPLICATE(ERROR, "Duplicate modifier {0}."),
+
+ /** no parameters required */
+ SYN_MODIFIER_ACCESS_SEVERAL(ERROR, "Only a single access modifier may be provided."),
+
+ /** 0: modifiers in correct order */
+ SYN_MODIFIER_BAD_ORDER(ERROR, "Modifiers should appear in this order: {0}."),
+
+ /** 0: element {modifier|keyword}, 1: name of modifier or keyword element (e.g. public) */
+ SYN_UNNECESSARY_ELEMENT(WARNING, "Unnecessary {0} {1}."),
+
+ /** no parameters required */
+ EXP_ONLY_TOP_LEVEL_ELEMENTS(ERROR, "Only top level elements can be exported."),
+
+ /** 0: element kind, 1: element name */
+ EXP_PRIVATE_ELEMENT(ERROR, "Private {0} {1} cannot be exported."),
+
+ /** no parameters required */
+ DESTRUCT_EMPTY_PATTERN(ERROR,
+ "Empty destructuring pattern (disallowed for time being, since ES6 implementations have different semantics)."),
+
+ /** 0: name of missing property, 1: type of value to be destructured */
+ DESTRUCT_PROP_MISSING(ERROR,
+ "Value to be destructured does not contain a property, field or getter named '{0}': {1}."),
+
+ /** 0: name of property that returned AbstractDescriptionWithError, 1: error message */
+ DESTRUCT_PROP_WITH_ERROR(ERROR, "Property named '{0}' is not readable: {1}."),
+
+ /**
+ * 0: name of variable, 1: 'at index N' or 'of property NAME', 2: error message from type system (must not end in a
+ * dot!)
+ */
+ DESTRUCT_TYPE_ERROR_VAR(ERROR, "Variable {0} cannot hold destructured value {1}: {2}."),
+
+ /**
+ * 0: kind of destructuring pattern ('Array' or 'Object' or 'Nested array' or 'Nested object'), 1: 'destructured
+ * value at index N' or 'destructured value of property NAME', 2: error message from type system (must not end in a
+ * dot!)
+ */
+ DESTRUCT_TYPE_ERROR_PATTERN(ERROR, "{0} destructuring pattern cannot be applied to {1}: {2}."),
+
+ ////// Dependency Injection
+ /**
+ * 0: type name, 1: additional description identifying the place of the violating context (name of the
+ * member/parameter)
+ */
+ DI_NOT_INJECTABLE(ERROR,
+ "Type {0} is not injectable{1}: only user-defined, non-generic, nominally typed interfaces and classes are allowed."),
+
+ /** no parameters are required */
+ DI_VARARGS_NOT_INJECTABLE(ERROR, "Injection of parameters that are variadic or optional is not supported."),
+
+ /** 0: type name */
+ DI_MUST_BE_INJECTED(WARNING,
+ "Type {0} must be injected, because it contains or inherits one or more members annotated with @Inject."),
+
+ /** 0: annotation name, 1: name of required annotation on containing class */
+ DI_ANN_ONLY_ON_CLASS_ANNOTATED_WITH(ERROR, "The annotation @{0} is only allowed on classes annotated with @{1}."),
+
+ /** 0: annotation name, 1: name of required annotation on containing class */
+ DI_ANN_ONLY_ON_METHOD_IN_CLASS_ANNOTATED_WITH(ERROR,
+ "The annotation @{0} is only allowed on methods contained in a class annotated with @{1}."),
+
+ /** 0: annotation name, 1: name of required annotation on argument class */
+ DI_ANN_ARG_MUST_BE_ANNOTATED_WITH(ERROR, "Argument to annotation @{0} must be a class annotated with @{1}."),
+
+ /** 0: the name of the violating annotation. */
+ DI_ANN_BIND_SECOND_MUST_BE_SUBTYPE_FIRST(ERROR, "Second argument to @{0} must be a subtype of the first."),
+
+ /** no parameters required */
+ DI_ANN_PROVIDES_METHOD_MUST_RETURN_VALUE(ERROR, "A provider method must return a value."),
+
+ /** no parameters required */
+ DI_ANN_INTERFACE_INJECTION_NOT_SUPPORTED(ERROR, "Injection inside interfaces is not supported."),
+
+ /** no parameters required */
+ DI_ANN_INJECTOR_EXTENDS(ERROR, "Classes annotated with @GenerateInjector cannot extend other class."),
+
+ /** 0: the binded type name */
+ DI_ANN_BIND_SINGLETON_TARGET_SHOULD_BE_DEFINED_AS_SINGLETON(ERROR,
+ "{0} can be defined as a singleton if it is annotated with @Singleton on the definition site."),
+
+ /** no parameters required */
+ DI_ANN_INJECTOR_CANNOT_BE_INJECTED_INTO_INJECTOR(ERROR,
+ "Types annotated with @GenerateInjector cannot be injected. Use @WithParentInjector instead for creating nested injectors."),
+
+ /** 0: the cyclic graph as a string */
+ DI_ANN_USE_INJECTOR_CYCLE(ERROR, "A cycle was detected among the parent injectors: {0}."),
+
+ /** 0: the name of the unavailable field */
+ DI_FIELD_IS_NOT_INJECTED_YET(ERROR, "{0} is not yet injected at this point."),
+
+ /** 0: super class type name, 1: violating type name */
+ DI_CTOR_BREAKS_INJECTION_CHAIN(WARNING,
+ "Constructor at super class {0} is annotated with @Inject. Omitting the @Inject annotation from constructor at class {1} could break injection chain."),
+
+ /** no parameters required */
+ DI_ANN_BINDER_NOT_APPLICABLE(ERROR,
+ "Annotation @Binder is applicable only for (exported) non-abstract class definitions."),
+
+ /** no parameters required */
+ DI_ANN_BINDER_AND_INJECTOR_DONT_GO_TOGETHER(ERROR,
+ "Annotations @Binder and @GenerateInjector may not be applied both on the same class definition."),
+
+ /** no parameters required */
+ DI_ANN_DUPLICATE_BINDING(ERROR,
+ "Duplicate @Binding-s (two different bindings share the same key, for the same @Binder)."),
+
+ /** no parameters required */
+ DI_ANN_BIND_ABSTRACT_TARGET(ERROR, "The target of a @Binding must be a non-abstract class."),
+
+ /** no parameters required */
+ DI_ANN_INJECT_METHOD_NOT_SUPPORTED_YET(ERROR, "Method injection not supported yet."),
+
+ /** no parameters required */
+ DI_ANN_BINDER_EXTENDS(ERROR, "Classes annotated with @Binder may not extend another class."),
+
+ /** no parameters required */
+ DI_ANN_INJECTOR_CTOR_MUST_BE_INJECT(ERROR,
+ "The constructor of an injector must itself be injected unless it declares no parameters."),
+
+ /** no parameters required */
+ DI_ANN_INJECTOR_REQUIRED(ERROR, "Only types annotated with @GenerateInjector can be used here."),
+
+ /** 0: list of missing binders (as a list of type names) */
+ DI_ANN_MISSING_PROVIDED_BINDERS(ERROR,
+ "No binders are provided (third param for this callsite). The following binders are used by the injector and themselves require injection: {0}."),
+
+ /** no parameters required */
+ DI_ANN_INJECTOR_MISSING(ERROR, "An instance of N4Injector is required here."),
+
+ /** 0: list of missing binders (as a list of type names) */
+ DI_ANN_MISSING_NEEDED_BINDERS(ERROR,
+ "Instances are missing for the following binders (they are used by the injector and themselves require injection): {0}."),
+
+ /** no parameters required */
+ DI_API_INJECTED(ERROR,
+ "The class being instantiated (or one of its super-types) has been marked @Injected in an API project."),
+
+ /** no parameters required */
+ DI_ANN_INJECTED_NOT_APPLICABLE(ERROR, "@Injected annotates a class (abstract or not) defined in an API project."),
+
+ ////// JSX
+ /** 0: name of opening JSX element, 1: name of closing JSX element */
+ JSX_JSXELEMENT_OPENING_CLOSING_ELEMENT_NOT_MATCH(ERROR,
+ "Opening element {0} does not match with closing element {1}."),
+
+ /** 0: name of the type JSX element is binding to */
+ JSX_REACT_ELEMENT_NOT_FUNCTION_OR_CLASS_ERROR(ERROR,
+ "JSX element is expected to bind to either a function or class, but bind to type {0} instead."),
+
+ /** No parameter */
+ JSX_REACT_ELEMENT_CLASS_MUST_NOT_BE_ABSTRACT(ERROR, "JSX element class must not be abstract."),
+
+ /** 0: name of the return type of the function that JSX element is binding to */
+ JSX_REACT_ELEMENT_FUNCTION_NOT_REACT_ELEMENT_ERROR(ERROR,
+ "Expecting a function returning a value of type {0} but the return type is {1}."),
+
+ /** no argument */
+ JSX_REACT_ELEMENT_CLASS_NOT_REACT_ELEMENT_ERROR(ERROR, "The referred class is not a subtype of React.Component"),
+
+ /** 0: name of the function that JSX element is binding to */
+ JSX_REACT_FUNCTIONAL_COMPONENT_CANNOT_START_WITH_LOWER_CASE(ERROR,
+ "React functional component {0} cannot start with lower case."),
+
+ /** 0: name of the class that JSX element is binding to */
+ JSX_REACT_CLASS_COMPONENT_CANNOT_START_WITH_LOWER_CASE(ERROR,
+ "React class component {0} cannot start with lower case."),
+
+ /** 0: name of JSX element is binding to */
+ JSX_JSXELEMENT_NOT_BIND_TO_REACT_COMPONENT(ERROR, "JSX element {0} does not bind to any valid React component."),
+
+ /** 0: name of JSX element is binding to */
+ JSX_TAG_UNKNOWN(WARNING, "Tag {0} is neither a known HTML tag nor an SVG tag."),
+
+ /** 0: name of JSX property */
+ JSX_JSXPROPERTY_ATTRIBUTE_NON_OPTIONAL_PROPERTY_NOT_SPECIFIED(ERROR,
+ "Non-optional property {0} should be specified."),
+
+ /**
+ * 0: The name of attribute in spread operator, 1: type of the attribute, 2: the declared type of the corresponding
+ * property in 'props'
+ */
+ JSX_JSXSPREADATTRIBUTE_WRONG_SUBTYPE(ERROR, "Attribute {0} has wrong type because {1} not subtype of {2}."),
+
+ /** 0: The name of attribute in spread operator, 1: name of JSX element */
+ JSX_JSXSPREADATTRIBUTE_NOT_DECLARED_IN_PROPS(WARNING,
+ "Attribute {0} is not a declared property in the props of {1}."),
+
+ /** 0: The name of attribute in JSX property, 1: name of JSX element */
+ JSX_JSXSPROPERTYATTRIBUTE_NOT_DECLARED_IN_PROPS(WARNING,
+ "Attribute {0} is not a declared property in the props of {1}."),
+
+ /** 0: JSX element in non-JSX file */
+ JSX_JSXELEMENT_IN_NON_JSX_RESOURCE(ERROR, "JSX element is expected to be placed in JSX like resource, was {0}."),
+
+ /** No parameter */
+ JSX_REACT_NAMESPACE_NOT_ALLOWED(ERROR, "Namespace to react must be React."),
+
+ /** No parameter */
+ JSX_REACT_NOT_RESOLVED(ERROR, "Cannot resolve JSX implementation."),
+
+ /** No parameter */
+ JSX_NAME_CANNOT_BE_REACT(ERROR, "Element cannot be named React in N4JSX file."),
+
+ ////// THIRD PARTY
+ /** no parameters required */
+ THIRD_PARTY_BABEL_LET_CONST_IN_FUN_EXPR(WARNING,
+ "This code is prone to Babel bug #6302. If you use Babel in your build pipeline, you should rename this let/const or the containing function expression."),
+
+ ////// N4JS package.json
+ /** no parameters */
+ PKGJ_MISSING_DEPENDENCY_N4JS_RUNTIME(ERROR,
+ "Missing dependency to 'n4js-runtime' (mandatory for all N4JS projects of type library, application, test)."),
+
+ /** no parameters */
+ PKGJ_WRONG_DEPENDENCY_N4JS_RUNTIME(ERROR,
+ "Dependency to 'n4js-runtime' should be defined below key 'dependencies', not 'devDependencies'."),
+
+ /** 0: The package name without scope, as declared in the package.json, 1: project folder name */
+ PKGJ_PACKAGE_NAME_MISMATCH(WARNING,
+ "As a convention the package name '{0}' should match the name of the project folder '{1}' on the file system."),
+
+ /** 0: The scope name, as declared in the package.json, 1: parent folder name */
+ PKGJ_SCOPE_NAME_MISMATCH(WARNING,
+ "As a convention the scope name '{0}' should match the name of the project folder's parent folder '{1}' on the file system."),
+
+ /** 0: The project name without scope */
+ PKGJ_INVALID_PROJECT_NAME(ERROR, "The name '{0}' is not a valid package name."),
+
+ /** 0: The scope name */
+ PKGJ_INVALID_SCOPE_NAME(ERROR, "The name '{0}' is not a valid scope name."),
+
+ /** 0: Invalid source container type name */
+ PKGJ_INVALID_SOURCE_CONTAINER_TYPE(ERROR, "Invalid source container type '{0}'."),
+
+ /** 0: the non-existing path */
+ PKGJ_NON_EXISTING_PATH(ERROR, "Path {0} does not exist."),
+
+ /** no parameters */
+ PKGJ_EMPTY_SOURCE_PATH(ERROR, "Source container paths must not be empty."),
+
+ /** 0: the non-existing source container path */
+ PKGJ_NON_EXISTING_SOURCE_PATH(WARNING, "Source container path {0} does not exist."),
+
+ /** 0: the path 1: 'in'-clause with leading space (e.g. ' in external, test') */
+ PKGJ_DUPLICATE_SOURCE_CONTAINER(WARNING, "Duplicate path '{0}' has already been declared as source container{1}."),
+
+ /** 0: the container source path */
+ PKGJ_NESTED_SOURCE_CONTAINER(ERROR,
+ "A source container must not be nested within other source containers (nested in {0})"),
+
+ /** no parameters */
+ PKGJ_NO_OUTPUT_FOLDER(ERROR, "There is no output folder defined, so compilation isn't possible."),
+
+ /** 0: the invalid path */
+ PKGJ_INVALID_PATH(ERROR, "'{0}' is not a valid path."),
+
+ /** 0: the absolute path */
+ PKGJ_INVALID_ABSOLUTE_PATH(ERROR, "Path '{0}' must not be absolute."),
+
+ /** 0: the non-directory path */
+ PKGJ_EXPECTED_DIRECTORY_PATH(ERROR, "Path '{0}' does not point to a directory."),
+
+ /** 0: the non-existing main module specifier */
+ PKGJ_NON_EXISTING_MAIN_MODULE(ERROR, "Main module specifier {0} does not exist."),
+
+ /** 0: invalid module filter type, 1: all valid module filter types */
+ PKGJ_INVALID_MODULE_FILTER_TYPE(ERROR, "Invalid module filter type '{0}'. Valid filter types are {1}."),
+
+ /** 0: invalid module specifier */
+ PKGJ_INVALID_MODULE_FILTER_SPECIFIER(ERROR,
+ "Invalid module specifier. Use simple strings or object syntax instead."),
+
+ /** no parameters */
+ PKGJ_INVALID_MODULE_FILTER_SPECIFIER_EMPTY(ERROR,
+ "The filter specifier and declared source container must not be empty."),
+
+ /** no parameters */
+ PKGJ_DUPLICATE_MODULE_FILTER_SPECIFIER(ERROR, "Duplicate module filter specifier."),
+
+ /** no parameters */
+ PKGJ_SRC_IN_FILTER_IS_NO_DECLARED_SOURCE(ERROR,
+ "The given source container '{0}' has not been declared as source container."),
+
+ /** 0: the invalid part of a wildcard */
+ PKGJ_INVALID_WILDCARD(ERROR, "'{0}' is not a valid character sequence in a wildcard."),
+
+ /** no parameters */
+ PKGJ_NO_RELATIVE_NAVIGATION(ERROR, "Relative navigation is not allowed in a module filter specifier."),
+
+ /** 0: the module filter specifier */
+ PKGJ_MODULE_FILTER_DOES_NOT_MATCH(WARNING, "Module filter '{0}' does not match any modules."),
+
+ /** 0: module filter type (e.g. noValidate) */
+ PKGJ_FILTER_NO_N4JS_MATCH(ERROR, "Module filters of type {0} must not match N4JS modules/files."),
+
+ /** no parameters */
+ PKGJ_APIIMPL_MISSING_IMPL_PROJECTS(ERROR,
+ "When defining an implementation ID, you also have to define one or more API projects that are implemented by this project using property 'n4js.implementedProjects'."),
+
+ /** no parameters */
+ PKGJ_APIIMPL_REFLEXIVE(ERROR, "An implementation project may not implement itself."),
+
+ /** no parameters required */
+ PKGJ_APIIMPL_MISSING_IMPL_ID(ERROR,
+ "When defining one or more implemented projects, you also have to define an implementation ID, using property 'implementationId'."),
+
+ /** 0: invalid project type */
+ PKGJ_INVALID_PROJECT_TYPE(ERROR, "Invalid project type '{0}'."),
+
+ /** 0: project id 1: section label (e.g. required runtime libraries) */
+ PKGJ_PROJECT_REFERENCE_MUST_BE_DEPENDENCY(ERROR,
+ "The project reference {0} in {1} must also be declared as explicit project dependency in 'dependencies' or 'devDependencies'."),
+
+ /** 0: message */
+ PKGJ_SEMVER_ERROR(ERROR, "{0}"),
+
+ /** 0: message */
+ PKGJ_SEMVER_WARNING(WARNING, "{0}"),
+
+ /** 0: version number string representation, 1: reason */
+ PKGJ_INVALID_VERSION_NUMBER(ERROR, "Invalid version number '{0}': {1}."),
+
+ /** 0: version constraint string representation, 1: reason */
+ PKGJ_INVALID_VERSION_REQUIREMENT(WARNING, "Invalid version requirement '{0}': {1}. Will assume empty string."),
+
+ /** 0: project type */
+ PKGJ_PROJECT_TYPE_MANDATORY_OUTPUT_AND_SOURCES(ERROR,
+ "Projects of type {0} must always declare an output folder and at least one source container."),
+
+ /** no parameters */
+ PKGJ_EMPTY_PROJECT_REFERENCE(ERROR, "A project reference must not be empty."),
+
+ /** no parameters */
+ PKGJ_EMPTY_INIT_MODULE(ERROR, "An init module specifier must not be empty."),
+
+ /** 0: project type, 1: empty or 'not ', 2: property name */
+ PKGJ_DEFINES_PROPERTY(ERROR, "A project of type '{0}' must {1}define the property '{2}'."),
+
+ /** 0: property name */
+ PKGJ_PROPERTY_UNKNOWN(WARNING, "Property '{0}' is unknown."),
+
+ /** 0: implementation project name, 1: type definition project name */
+ PKGJ_IMPL_PROJECT_IS_MISSING_FOR_TYPE_DEF(WARNING,
+ "The implementation project {0} of type definition project {1} is missing from the dependencies section."),
+
+ /** 0: 'Source' or 'Output code' */
+ PKGJ_REWRITE_MODULE_SPECIFIERS__EMPTY_SPECIFIER(ERROR, "{0} module specifier must not be empty."),
+
+ /** no parameters */
+ PKGJ_REWRITE_MODULE_SPECIFIERS__INVALID_VALUE(ERROR,
+ "String expected (i.e. the module specifier to use in the output code)."),
+
+ /** 0: dependency cycle */
+ LTD_ILLEGAL_LOADTIME_REFERENCE(ERROR,
+ "Load-time references to the same or other modules are not allowed within a runtime dependency cycle (except in extends/implements clauses).{0}"),
+
+ /**
+ * 0: name of load-time dependency target module, 1: comma-separated list of other load-time dependency source
+ * modules (including the prefix 'modules ' or 'module '), 2: dependency cycle
+ */
+ LTD_LOADTIME_DEPENDENCY_CONFLICT(ERROR,
+ "A load-time dependency target module {0} must only be imported once within the same runtime dependency cycle, but {0} is also imported by {1}.{2}"),
+
+ /** 0: dependency cycle */
+ LTD_LOADTIME_DEPENDENCY_CYCLE(ERROR,
+ "Load-time dependency cycles are disallowed, because successful resolution by Javascript engine cannot be guaranteed.{0}"),
+
+ /**
+ * 0: name of load-time dependency target module, 1: modules that could heal this reference (including the prefix
+ * 'one of the modules ' or 'module '), 2: dependency cycle
+ */
+ LTD_REFERENCE_TO_LOADTIME_DEPENDENCY_TARGET(ERROR,
+ "When importing modules from a runtime cycle, those that are the target of a load-time dependency (marked with * below) may only be imported after first importing one of the others. Thus, import of module {0} must be preceded by an import of {1}.{2}")
+
+ ;
+
+ public final Severity severity;
+ private final String msgTemplate;
+ private final int argCount;
+
+ private final Pattern ARG = Pattern.compile("\\{\\d\\}");
+
+ IssueCodes(Severity severity, String msgTemplate) {
+ this.severity = severity;
+ this.msgTemplate = msgTemplate;
+ if (msgTemplate == null) {
+ this.argCount = 0;
+ } else {
+ Matcher matcher = ARG.matcher(msgTemplate);
+ int maxArgCount = 0;
+ while (matcher.find()) {
+ String digitStr = matcher.group().substring(1, 2);
+ int argPlace = Integer.parseInt(digitStr);
+ maxArgCount = Math.max(maxArgCount, argPlace + 1);
+ }
+ this.argCount = maxArgCount;
+ }
+ }
+
+ public String getMessage(Object... values) {
+ Preconditions.checkArgument(argCount == 0 || (values != null && values.length == argCount), "Check arguments");
+ if (values == null) {
+ return msgTemplate;
+ }
+ String message = msgTemplate;
+ for (int i = 0; i < values.length; i++) {
+ message = message.replace("{" + i + "}", values[i].toString());
+ }
+ return message;
+ }
+
+ public IssueItem toIssueItem(Object... values) {
+ return new IssueItem(this, severity, getMessage(values));
+ }
+
+ public IssueItem toIssueItemWithData(List data, Object... values) {
+ return new IssueItem(this, severity, getMessage(values), data.toArray(new String[0]));
+ }
+
+ static public Severity getSeverityForName(String issueName) {
+ try {
+ return valueOf(issueName).severity;
+ } catch (Exception e) {
+ return null;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/IssueCodes.xtend b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/IssueCodes.xtend
deleted file mode 100644
index e34f50e771..0000000000
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/IssueCodes.xtend
+++ /dev/null
@@ -1,21 +0,0 @@
-/**
- * Copyright (c) 2016 NumberFour AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * NumberFour AG - Initial API and implementation
- */
-package org.eclipse.n4js.validation
-
-import org.eclipse.n4js.utils.NLS
-
-/**
- * Provides messages and helper methods for creating NLS messages.
- * This class uses an active annotation {@code @NLS} to derive constants and methods out of the entries of the
- * {@code messages.properties}. See {@link org.eclipse.n4js.utils.NLSProcessor} for details about the message format.
- */
-@NLS(propertyFileName="messages")
-class IssueCodes {}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/IssueItem.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/IssueItem.java
new file mode 100644
index 0000000000..5d715c5565
--- /dev/null
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/IssueItem.java
@@ -0,0 +1,45 @@
+/**
+ * Copyright (c) 2023 NumberFour AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * NumberFour AG - Initial API and implementation
+ */
+package org.eclipse.n4js.validation;
+
+import org.eclipse.xtext.diagnostics.Severity;
+
+/**
+ * Data container for concrete issues.
+ */
+public class IssueItem {
+ /** Reference to the general {@link IssueCodes} */
+ public final IssueCodes code;
+ /** Severity */
+ public final Severity severity;
+ /** Complete message */
+ public final String message;
+ /** Auxiliary data */
+ public final String[] data;
+
+ /** Constructor */
+ public IssueItem(IssueCodes code, Severity severity, String message) {
+ this(code, severity, message, new String[0]);
+ }
+
+ /** Constructor */
+ public IssueItem(IssueCodes code, Severity severity, String message, String[] data) {
+ this.code = code;
+ this.severity = severity;
+ this.message = message;
+ this.data = data;
+ }
+
+ /** Returns the issue code name */
+ public String getID() {
+ return code.name();
+ }
+}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/N4JSIssueSeverities.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/N4JSIssueSeverities.java
index 27ded0668b..7f0bc495a2 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/N4JSIssueSeverities.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/N4JSIssueSeverities.java
@@ -39,7 +39,7 @@ public N4JSIssueSeverities(IPreferenceValues preferenceValues, Map issues) {
if (cache != null && cache.hasUnknownTypeRef()) {
boolean hasErrors = issues.stream().anyMatch(issue -> issue.getSeverity() == Severity.ERROR);
if (!hasErrors) {
- final String msg = IssueCodes.getMessageForTYS_UNKNOWN_TYPE_REF();
+ final String msg = IssueCodes.TYS_UNKNOWN_TYPE_REF.getMessage();
for (TypableElement elem : cache.getAstNodesOfUnknownTypes()) {
- Issue issue = createFileIssue(resource, elem, msg, IssueCodes.TYS_UNKNOWN_TYPE_REF);
+ Issue issue = createFileIssue(resource, elem, msg, IssueCodes.TYS_UNKNOWN_TYPE_REF.name());
issues.add(issue);
}
@@ -223,8 +223,8 @@ private boolean isValidFileTypeForProjectType(Resource resource, N4JSProjectConf
private static Issue createInvalidFileTypeError(Resource res, N4JSProjectConfigSnapshot project) {
final String projectTypeStr = PackageJsonUtils.getProjectTypeStringRepresentation(project.getType());
- final String msg = IssueCodes.getMessageForINVALID_FILE_TYPE_FOR_PROJECT_TYPE(projectTypeStr);
- return createFileIssue(res, msg, IssueCodes.INVALID_FILE_TYPE_FOR_PROJECT_TYPE);
+ final String msg = IssueCodes.INVALID_FILE_TYPE_FOR_PROJECT_TYPE.getMessage(projectTypeStr);
+ return createFileIssue(res, msg, IssueCodes.INVALID_FILE_TYPE_FOR_PROJECT_TYPE.name());
}
private static Issue createPostProcessingFailedError(Resource res, Throwable th) {
@@ -233,8 +233,8 @@ private static Issue createPostProcessingFailedError(Resource res, Throwable th)
final String trace = "\n" + Stream.of(th.getStackTrace())
.map(ste -> ste.toString())
.collect(Collectors.joining("\n")); // cannot add indentation, because Xtext would reformat the message
- final String msg = IssueCodes.getMessageForPOST_PROCESSING_FAILED(thKind, thName, th.getMessage() + trace);
- return createFileIssue(res, msg, IssueCodes.POST_PROCESSING_FAILED);
+ final String msg = IssueCodes.POST_PROCESSING_FAILED.getMessage(thKind, thName, th.getMessage() + trace);
+ return createFileIssue(res, msg, IssueCodes.POST_PROCESSING_FAILED.name());
}
private static Issue createFileIssue(Resource res, String message, String issueCode) {
@@ -245,7 +245,7 @@ private static Issue createFileIssue(Resource res, TypableElement elem, String m
URI uri = res.getURI();
final IssueImpl issue = new IssueImpl();
issue.setCode(issueCode);
- issue.setSeverity(IssueCodes.getDefaultSeverity(issueCode));
+ issue.setSeverity(IssueCodes.getSeverityForName(issueCode));
issue.setMessage(message);
issue.setUriToProblem(URIUtils.getBaseOfVirtualResourceURI(uri));
issue.setType(CheckType.FAST); // using CheckType.FAST is important to get proper marker update behavior in ...
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/helper/FunctionValidationHelper.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/helper/FunctionValidationHelper.java
index f6dea87eed..bd15408eb2 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/helper/FunctionValidationHelper.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/helper/FunctionValidationHelper.java
@@ -15,11 +15,6 @@
import static org.eclipse.n4js.validation.IssueCodes.FUN_PARAM_INITIALIZER_ILLEGAL_FORWARD_REFERENCE;
import static org.eclipse.n4js.validation.IssueCodes.FUN_PARAM_VARIADIC_ONLY_LAST;
import static org.eclipse.n4js.validation.IssueCodes.FUN_PARAM_VARIADIC_WITH_INITIALIZER;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForFUN_PARAM_IMPLICIT_DEFAULT_PARAM;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForFUN_PARAM_INITIALIZER_ILLEGAL_AWAIT_CALL;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForFUN_PARAM_INITIALIZER_ILLEGAL_FORWARD_REFERENCE;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForFUN_PARAM_VARIADIC_ONLY_LAST;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForFUN_PARAM_VARIADIC_WITH_INITIALIZER;
import java.util.Arrays;
import java.util.Iterator;
@@ -95,8 +90,8 @@ static public void internalCheckFormalParameters(
TypesPackage.Literals.SYNTAX_RELATED_TELEMENT__AST_ELEMENT, false);
}
if (fparsL.indexOf(id) >= fpPos) {
- String msg = getMessageForFUN_PARAM_INITIALIZER_ILLEGAL_FORWARD_REFERENCE();
- issueConsumer.accept(msg, FUN_PARAM_INITIALIZER_ILLEGAL_FORWARD_REFERENCE, ir);
+ String msg = FUN_PARAM_INITIALIZER_ILLEGAL_FORWARD_REFERENCE.getMessage();
+ issueConsumer.accept(msg, FUN_PARAM_INITIALIZER_ILLEGAL_FORWARD_REFERENCE.name(), ir);
}
}
@@ -110,8 +105,8 @@ static public void internalCheckFormalParameters(
paramName = ((FormalParameter) fPar).getName();
}
for (AwaitExpression await : awaits) {
- String msg = getMessageForFUN_PARAM_INITIALIZER_ILLEGAL_AWAIT_CALL(paramName);
- issueConsumer.accept(msg, FUN_PARAM_INITIALIZER_ILLEGAL_AWAIT_CALL, await);
+ String msg = FUN_PARAM_INITIALIZER_ILLEGAL_AWAIT_CALL.getMessage(paramName);
+ issueConsumer.accept(msg, FUN_PARAM_INITIALIZER_ILLEGAL_AWAIT_CALL.name(), await);
}
}
}
@@ -126,8 +121,8 @@ static public void internalCheckFormalParameters(
while (initAssgnVisited && iter.hasNext()) {
T fpar = iter.next();
if (!hasInitAssgn.test(fpar) && !variadic.test(fpar)) {
- String msg = getMessageForFUN_PARAM_IMPLICIT_DEFAULT_PARAM(name.apply(fpar));
- issueConsumer.accept(msg, FUN_PARAM_IMPLICIT_DEFAULT_PARAM, fpar);
+ String msg = FUN_PARAM_IMPLICIT_DEFAULT_PARAM.getMessage(name.apply(fpar));
+ issueConsumer.accept(msg, FUN_PARAM_IMPLICIT_DEFAULT_PARAM.name(), fpar);
}
}
}
@@ -149,14 +144,14 @@ static public void internalCheckFormalParameter(
// 1. Variadic is last
if (fpPos != fPars.size() - 1) { // is not last?
- String msg = getMessageForFUN_PARAM_VARIADIC_ONLY_LAST();
- issueConsumer.accept(msg, FUN_PARAM_VARIADIC_ONLY_LAST, fPar);
+ String msg = FUN_PARAM_VARIADIC_ONLY_LAST.getMessage();
+ issueConsumer.accept(msg, FUN_PARAM_VARIADIC_ONLY_LAST.name(), fPar);
}
// 2. Both variadic and initializerAssignment
if (hasInitAssgn.test(fPar)) {
- String msg = getMessageForFUN_PARAM_VARIADIC_WITH_INITIALIZER();
- issueConsumer.accept(msg, FUN_PARAM_VARIADIC_WITH_INITIALIZER, fPar);
+ String msg = FUN_PARAM_VARIADIC_WITH_INITIALIZER.getMessage();
+ issueConsumer.accept(msg, FUN_PARAM_VARIADIC_WITH_INITIALIZER.name(), fPar);
}
}
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/messages.properties b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/messages.properties
deleted file mode 100644
index 3fa0603598..0000000000
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/messages.properties
+++ /dev/null
@@ -1,1221 +0,0 @@
-# see NLSProcessor for description of value format
-# If you change anything here, manually trigger re-compilation of IssueCodes
-
-
-# The following message is intended for ES6 features that are implemented in N4JS but
-# are not yet supported in current version of V8 or some other relevant runtime environment.
-# 0: description of the feature that is not supported
-UNSUPPORTED=error;;;Unsupported feature: {0}.
-
-# Not necessary.
-SCR_HASHBANG_WRONG_LOCATION=error;;;Hashbang must start at the absolute start of a script or module
-
-# 0: file names of files that contain errors
-EXTERNAL_LIBRARY_ERRORS=error;;;External library error: {0}
-# 0: file names of files that contain warnings
-EXTERNAL_LIBRARY_WARNINGS=error;;;External library warning: {0}
-
-# 0: kind of throwable ("error", "exception", or "throwable"), 1: simple name of throwable, 2: message of throwable
-POST_PROCESSING_FAILED=error;;;{0} {1} thrown during post-processing (please report this!): {2}
-# Unknown type ref in resource
-TYS_UNKNOWN_TYPE_REF=error;;;Resource contains unknown type ref (please report this!)
-
-# 0: namespace name, 1: import module name, that both occur multiple times in this combination
-IMP_STMT_DUPLICATE_NAMESPACE=error;;;Duplicate namespace import statement with name {0} and imported module {1}.
-# 0: imported element local name, 1: import module name, that both occur multiple times in this combination
-IMP_STMT_DUPLICATE_NAMED=error;;;Duplicate named import statement with local name {0} and imported module {1}.
-# 0: type1 imported name1, 1: import module name, 2: name under which type is already imported
-IMP_DUPLICATE=error;;;{0} from {1} is already imported as {2}.
-# 0: import module name, 1: namespace name already importing those elements
-IMP_DUPLICATE_NAMESPACE=error;;;Element {0} of {1} is already imported in namespace {2}.
-# 0: local name (import name, alias name or namespace name), 1: import module name, 2: name under which type is already imported
-IMP_LOCAL_NAME_CONFLICT=error;;;Name {0} is already used as {1}.
-# 0: type name, 1: alias name
-IMP_PLAIN_ACCESS_OF_ALIASED_TYPE=error;;;{0} has been imported as {1}.
-# 0: type name, 1: full name (namespace + '.' + type name)
-IMP_PLAIN_ACCESS_OF_NAMESPACED_TYPE=error;;;{0} has been imported as {1}.
-# 0: imported name
-IMP_UNUSED_IMPORT=warning;;;The import of {0} is unused.
-# 0: imported name
-IMP_NOT_EXPORTED=error;;;Element {0} is not exported.
-# 0: type import name
-IMP_UNRESOLVED=error;;;Import of {0} cannot be resolved.
-# Not necessary.
-IMP_DISCOURAGED_PLACEMENT=warning;;;The import statement should be placed on top of other statements.
-
-
-# 0: type or variable, 1: type name, 2: comma separated list of types - the sources of the imports
-IMP_AMBIGUOUS=error;;;The {0} {1} is ambiguously imported from {2}.
-# 0: type or variable, 1: type name, 2: comma separated list of types - the sources of the imports
-IMP_AMBIGUOUS_WILDCARD=error;;;The {0} {1} is ambiguously imported from {2}.
-# 0: imported type name, 1: qualified name of the module
-IMP_CONFLICT=error;;;Conflicting import of {0} with import from {1}.
-# 0: imported type1 name, 1: type1 alias, 2: type2 imported name, 3: type2 import module name
-IMP_CONFLICT_ALIAS_TYPE=error;;;Conflicting import of {0} as {1}. Cannot import same type with different name ({2}) from {3}.
-# 0: type1 imported name, 1: type2 alias, 2: type2 import module name
-IMP_CONFLICT_ALIASES=error;;;Conflicting import of {0}. Cannot import same type with different name ({1}) from {2}.
-# 0: type1 imported name1, that occur multiple times, 1: import module name
-IMP_DUPLICATEX=error;;;Duplicate import of {0} in import from {1}.
-# 0: type1 imported name1, 1: type1 imported name2, 2: import module name
-IMP_DUPLICATE_ALIAS=error;;;Duplicate import of {0}, already defined as {1} in import from {2}.
-# 0: module in wildcard specifier
-IMP_EMPTY_WILDCARD_IMPORT=warning;;;The wild-card import from {0} doesn't import anything because nothing is exported there.
-# 0: alias in namespace import
-IMP_STATIC_IMPORT_PLAIN_JS=error;;;Use dynamic import in order to access elements of {0}.
-# 0: alias in namespace import
-IMP_DYNAMIC_IMPORT_N4JS=error;;;N4JS module {0} must not be imported dynamically.
-# 0: variant type, 1: alias in namespace import
-IMP_DYNAMIC_IMPORT_N4JSD=warning;;;The {0} module {1} should not be imported dynamically.
-# no parameters required
-IMP_DEFAULT_EXPORT_DUPLICATE=error;;;Duplicate default export.
-# 0: local name of the imported element
-IMP_IMPORTED_ELEMENT_READ_ONLY=error;;;Imported element {0} is read-only.
-# 0: local name of the imported element, 1: re-exporting project name to use, 2: imported project name
-IMP_IMPORTED_ELEMENT_FROM_REEXPORTING_PROJECT=error;;;The imported element {0} is defined in the re-exporting project {1} but project {2} was imported. Import from {1} instead.
-
-# 0: method, field, getter, setter, member, 1: member name
-VIS_ILLEGAL_MEMBER_ACCESS=error;;;The {0} {1} is not visible.
-# 0: function name
-VIS_ILLEGAL_FUN_ACCESS=error;;;The function {0} is not visible.
-# 0: type name
-VIS_ILLEGAL_TYPE_ACCESS=error;;;The type {0} is not visible.
-# 0: variable name
-VIS_ILLEGAL_VARIABLE_ACCESS=error;;;The variable {0} is not visible.
-# 0: member name, 1: type defining member
-VIS_ILLEGAL_STATIC_MEMBER_WRITE_ACCESS=error;;;Write access to the static member {1} defined in {0} must use {0} directly.
-# 0: member name, 1: type defining member, 2: member alias
-VIS_ILLEGAL_STATIC_MEMBER_WRITE_ACCESS_WITH_ALIAS=error;;;Write access to the static member {1} defined in {0} must use the alias {2} directly.
-# 0: member kind, 1: member name, 2: 'read-only', when a read-only member was used with write access or 'write-only' when a write-only member was used with read access.
-VIS_WRONG_READ_WRITE_ACCESS=error;;;The {0} {1} is {2}.
-# 0: static or non-static, 1: member name, 2: static or non-static
-VIS_WRONG_STATIC_ACCESSOR=error;;;The {0} member {1} cannot be accessed from a {2} context.
-# 0: type variable name
-VIS_WRONG_TYPE_VARIABLE_ACCESSOR=error;;;The type variable {0} cannot be accessed from a static context.
-# 0: type parameter name, 1: kind of type hidden (e.g. class, type variable, etc.)
-VIS_TYPE_PARAMETER_HIDES_TYPE=warning;;;The type parameter {0} hides {1} {0}.
-# 0: concept which is not allowed, 1: Mode (n4js,strict,...) in which it is not allowed.
-VIS_RESTRITCTED_USAGE=error;;;The usage of {0} is not allowed in {1} mode.
-# 0: 'constructor' or 'construct signature', 1: classifier name whose constructor / construct signature is not visible.
-VIS_NEW_CANNOT_INSTANTIATE_INVISIBLE_CONSTRUCTOR=error;;;The {0} of {1} is not visible.
-
-# no parameters required
-TYP_TYPE_PARAM_MANDATORY_AFTER_OPTIONAL=error;;;Mandatory type parameters may not follow optional type parameters.
-# no parameters required
-TYP_TYPE_PARAM_DEFAULT_REFERENCES_LATER_TYPE_PARAM=error;;;Default type arguments may only reference type parameters that are declared before the current type parameter.
-# 0: name of type parameter, 1: error message of subtype check
-TYP_TYPE_PARAM_DEFAULT_NOT_SUBTYPE_OF_BOUND=error;;;Default argument of optional type parameter {0} must comply to its upper bound, but: {1}
-
-# no parameters required
-CLF_MUST_BE_NOMINAL=error;;;Classes cannot be structural.
-# no parameters required
-CLF_CTOR_RETURN_TYPE=error;;;A constructor must not have a return type declaration.
-# no parameters required
-CLF_CTOR_ILLEGAL_MODIFIER=error;;;A constructor must not be declared abstract, static or final and may not be annotated with @Override.
-# no parameters required
-CLF_CALL_CONSTRUCT_SIG_ONLY_IN_N4JSD=error;;;Call and construct signatures may only be used in .n4jsd files.
-# no parameters required
-CLF_CALL_CONSTRUCT_SIG_NOT_IN_N4JS=error;;;Call and construct signatures are not allowed in n4js classifiers. Use shapes or @EcmaScript.
-# no parameters required
-CLF_CALL_CONSTRUCT_SIG_BODY=error;;;Call and construct signatures must not have a body.
-# 0: kind of signature ('call' or 'construct')
-CLF_CALL_CONSTRUCT_SIG_DUPLICATE=error;;;Duplicate {0} signature.
-# no parameters required
-CLF_CALL_CONSTRUCT_SIG_CANNOT_IMPLEMENT=error;;;An interface with a call or construct signature cannot be implemented by a class.
-# no parameters required
-CLF_CONSTRUCT_SIG_ONLY_IN_INTERFACE=error;;;Construct signatures may only be used in interfaces.
-# no parameters required
-CLF_CONSTRUCT_SIG_VOID_RETURN_TYPE=error;;;Construct signatures must have a non-void return type.
-# no parameters required
-CLF_CTOR_NO_TYPE_PARAMETERS=error;;;Constructors must not have any type parameters.
-# no parameters required
-CLF_NAME_DOLLAR=error;;;Member names must not start with a dollar character.
-# 0: the human readable name of the violating discouraged character
-CLF_NAME_CONTAINS_DISCOURAGED_CHARACTER=warning;;;Name should not contain {0} character.
-# 0: static or const keywords
-CLF_NAME_DOES_NOT_MATCH_WITH_PATTERN_FOR_STATIC_OR_CONST=warning;;;Name should be all upper case with words separated by underscores for variables with {0} modifier.
-# 0: element meta type
-CLF_NAME_DOES_NOT_START_UPPERCASE=warning;;;{0} names should start with upper case letter.
-# 0: element meta type
-CLF_NAME_DOES_NOT_START_LOWERCASE=warning;;;{0} names should start with lower case letter.
-# 0: element description, 1: conflicting category
-CLF_NAME_INDISTINGUISHABLE=error;;;{0} may be indistinguishable with {1}.
-# 0: element description, 1: conflicting category
-CLF_NAME_RESERVED=warning;;;{0} may be confused with {1}.
-# no parameters required
-CLF_NAME_CONFLICTS_WITH_CONSTRUCTOR=warning;;;Name may be confused with constructor.
-# 0: element description, 1: conflicting type name 2: actual type
-CLF_NAME_DIFFERS_TYPE=warning;;;{0} is not of type {1} but of type {2}.
-# 0: name of final type, 1: name of type parameter
-CLF_UPPER_BOUND_FINAL=warning;;;Final type {0} should not be used as upper bound of type parameter {1}. Final types cannot be extended.
-# no parameters required
-CLF_DEF_SITE_VARIANCE_ONLY_IN_CLASSIFIER=error;;;Declaration of definition-site variance only allowed in generic classes and interfaces, not in generic functions or methods.
-# 0: "covariant" or "contravariant", 1: "covariant", "contravariant", or "invariant"
-CLF_TYPE_VARIABLE_AT_INVALID_POSITION=error;;;Cannot use {0} type variable at {1} position.
-# 0: the actual primitive type
-CLF_EXTENDS_PRIMITIVE_GENERIC_TYPE=error;;;Cannot subclass primitive type {0}.
-# 0: keyword (extends, implements, with), 1: expected meta type in plural form (classes, interfaces, roles), 2: type name, 3: actual meta type (class, interface)
-CLF_WRONG_META_TYPE=error;;;Keyword {0} must be used with {1} but {2} is a {3}.
-# 0: class name
-CLF_EXTEND_FINAL=error;;;Cannot extend final class {0}.
-# 0: keyword, 1: name of class
-CLF_EXTEND_NON_ACCESSIBLE_CTOR=error;;;Cannot extend {0} {1} because its constructor is not accessible.
-# 0: name of class, 1: name of super class
-CLF_OBSERVABLE_MISSING=error;;;Class {0} extends observable class {1} and must therefore be annotated with @Observable.
-# no parameters required
-CLF_TEST_CLASS_NOT_EXPORTED=warning;;;Classes containing test methods must be abstract or marked with modifier export.
-
-# # 0: module name, 1: path to other module
-CLF_DUP_MODULE=error;;;A duplicate module {0} is also defined in {1}.
-# # 0: module name, 1: js module, 2: path to other module
-CLF_DUP_DEF_MODULE=error;;;A duplicate definition module {0} for {1} is also defined in {2}.
-# # 0: first name with line ({@link ValidatorMessageHelper#nameWithLine(TMember,TMember)}, 1: other name with line ({@link ValidatorMessageHelper#nameWithLine(TMember,TMember)}
-CLF_DUP_CTOR=error;;;Constructor line {0} duplicates constructor in line {1}.
-# # 0: first short description ({@link ValidatorMessageHelper#descriptionWithLine(TMember,TMember)}, 1: other short description ({@link ValidatorMessageHelper#descriptionWithLine(TMember,TMember)}
-CLF_DUP_MEMBER=error;;;The {0} duplicates {1}.
-# # 0: first short description ({@link ValidatorMessageHelper#descriptionWithLine(TMember,TMember)}
-CLF_DUP_WITH_MEMBER=error;;;The {0} conflicts with the structural this type in the inherit constructor definition.
-# 0: overriding description ({@link ValidatorMessageHelper#descriptionDifferentFrom(TMember,TMember)}, 1: overridden description ({@link ValidatorMessageHelper#descriptionDifferentFrom(TMember,TMember)}, 2: setter or getter
-CLF_OVERRIDE_FIELD_REQUIRES_ACCESSOR_PAIR=error;;;The {0} cannot override {1}, matching {2} missing.
-# 0: overriding description ({@link ValidatorMessageHelper#descriptionDifferentFrom(TMember,TMember)}, 1: overridden description ({@link ValidatorMessageHelper#descriptionDifferentFrom(TMember,TMember)}
-CLF_CONSUMED_OVERRIDE_FIELD=error;;;The consumed {0} cannot override {1}.
-# 0: overriding description ({@link ValidatorMessageHelper#descriptionDifferentFrom(TMember,TMember)}, 1: "overriding" or "implementing" 2: overridden description ({@link ValidatorMessageHelper#descriptionDifferentFrom(TMember,TMember)}
-CLF_OVERRIDE_ANNOTATION=error;;;The {0} {1} {2} must be annotated with @Override.
-# 0: overriding description ({@link ValidatorMessageHelper#descriptionDifferentFrom(TMember,TMember)}, 1: overridden description ({@link ValidatorMessageHelper#descriptionDifferentFrom(TMember,TMember)}
-CLF_REDEFINED_NON_ACCESSIBLE=error;;;The {0} cannot override or implement non-accessible {1}.
-# 0: overriding description ({@link ValidatorMessageHelper#descriptionDifferentFrom(TMember,TMember)}, 1: overridden description ({@link ValidatorMessageHelper#descriptionDifferentFrom(TMember,TMember)}
-CLF_OVERRIDE_FINAL=error;;;The {0} cannot override final {1}.
-# 0: overridden description ({@link ValidatorMessageHelper#descriptionDifferentFrom(TMember,TMember)}, 1: "final" or "const"
-CLF_OVERRIDE_WITH_FINAL_OR_CONST_FIELD=error;;;Cannot override {0} with a {1} field.
-# 0: overriding description ({@link ValidatorMessageHelper#descriptionDifferentFrom(TMember,TMember)}, 1: overridden description ({@link ValidatorMessageHelper#descriptionDifferentFrom(TMember,TMember)}
-CLF_OVERRIDE_CONST=error;;;The {0} cannot override {1}.
-# 0: overriding description ({@link ValidatorMessageHelper#descriptionDifferentFrom(TMember,TMember)}, 1: overridden description ({@link ValidatorMessageHelper#descriptionDifferentFrom(TMember,TMember)}
-CLF_OVERRIDEN_CONCRETE_WITH_ABSTRACT=error;;;The abstract {0} cannot override concrete {1}.
-# 0: overriding description ({@link ValidatorMessageHelper#descriptionDifferentFrom(TMember,TMember)}, 1: overridden description ({@link ValidatorMessageHelper#descriptionDifferentFrom(TMember,TMember)}
-CLF_OVERRIDE_VISIBILITY=error;;;The {0} cannot reduce the visibility of {1}.
-# 0: method, getter or setter, 1: member name
-CLF_OVERRIDE_NON_EXISTENT=error;;;The {0} {1} must override or implement a {0} from a super class or interface.
-# 0: member description, 1: member description
-CLF_OVERRIDE_NON_EXISTENT_INTERFACE=warning;;;The {0} does not override {1} (no inheritance of static members in interfaces); remove annotation @Override.
-# 0: description of constructor, 1: description of classifier inheriting the constructor, 2: description of classifier owning the constructor
-CLF_PSEUDO_REDEFINED_SPEC_CTOR_INCOMPATIBLE=error;;;Inherited {0} in context of {1} not compatible to itself in context of {2}.
-# 0: overriding description ({@link ValidatorMessageHelper#descriptionDifferentFrom(TMember,TMember)}, 1: overridden/implemented/consumed, 2: overridden description ({@link ValidatorMessageHelper#descriptionDifferentFrom(TMember,TMember)} 3: additional members or error information (may be empty)
-CLF_REDEFINED_TYPE_NOT_SAME_TYPE=error;;;Type of {0} must equal type of {1} {2}.{3}
-# 0: overriding description ({@link ValidatorMessageHelper#descriptionDifferentFrom(TMember,TMember)}, 1: overridden/implemented/consumed, 2: overridden description ({@link ValidatorMessageHelper#descriptionDifferentFrom(TMember,TMember)}
-CLF_REDEFINED_BY_CONSUMED_TYPE_NOT_SAME_TYPE=error;;;Type of inherited {0} must equal type of {1} {2}.
-# 0: overriding description ({@link ValidatorMessageHelper#descriptionDifferentFrom(TMember,TMember)}, 1: overridden description ({@link ValidatorMessageHelper#descriptionDifferentFrom(TMember,TMember)}, 1: overridden/implemented/consumed, 3: signature type error message, 4: additional members or error information (may be empty)
-CLF_REDEFINED_MEMBER_TYPE_INVALID=error;;;Type of {0} does not conform to {2} {1}: {3}.{4}
-# 0: consumed/inherited, 1: overriding description ({@link ValidatorMessageHelper#descriptionDifferentFrom(TMember,TMember)}, 2: overridden/implemented/consumed, 3: overridden description ({@link ValidatorMessageHelper#descriptionDifferentFrom(TMember,TMember)}, 4: signature type error message
-CLF_REDEFINED_BY_CONSUMED_MEMBER_TYPE_INVALID=error;;;Type of {0} {1} does not conform to {2} {3}: {4}.
-# 0: comma separated description of conflicting members
-CLF_CONSUMED_MEMBER_SOLVABLE_CONFLICT=error;;;Redefine ambiguously consumed members: {0}.
-# 0: comma separated description of conflicting members
-CLF_CONSUMED_MEMBER_UNSOLVABLE_CONFLICT=error;;;Incompatible consumed members: {0}.
-# 0: inherited member leading to conflict, 1: comma separated description of conflicting members
-CLF_CONSUMED_INHERITED_MEMBER_UNSOLVABLE_CONFLICT=error;;;Inherited {0} cannot implement {1}.
-# 0: overriding description, should usually start with "Signature of " ({@link ValidatorMessageHelper#descriptionDifferentFrom(TMember,TMember)}, 1: overridden/implemented/consumed, 2: overridden description ({@link ValidatorMessageHelper#descriptionDifferentFrom(TMember,TMember)}, 3: signature type error message, 4: additional members or error information (may be empty)
-CLF_REDEFINED_METHOD_TYPE_CONFLICT=error;;;{0} does not conform to {1} {2}: {3}.{4}
-# 0: overriding description ({@link ValidatorMessageHelper#descriptionDifferentFrom(TMember,TMember)}, 1: overridden description ({@link ValidatorMessageHelper#descriptionDifferentFrom(TMember,TMember)}
-CLF_OVERRIDE_MEMBERTYPE_INCOMPATIBLE=error;;;Cannot override {1} with {0}.
-# TODO remove?! 0: overriding description ({@link ValidatorMessageHelper#descriptionDifferentFrom(TMember,TMember)}, 1: overridden description ({@link ValidatorMessageHelper#descriptionDifferentFrom(TMember,TMember)}
-CLF_CONSUMED_OVERRIDE_MEMBERTYPE_INCOMPATIBLE=error;;;Cannot override {1} with consumed {0}.
-# 0: getter/setter, 0: overridden descriptions (CSV) ({@link ValidatorMessageHelper#descriptionDifferentFrom(TMember,TMember)}
-CLF_CONSUMED_FIELD_ACCESSOR_PAIR_INCOMPLETE=error;;;Missing {0} to completely override consumed {1}.
-# no parameters required
-CLF_FIELD_CONST_FINAL=error;;;A field may not be declared both final and const.
-# no parameters required
-CLF_FIELD_CONST_STATIC=error;;;All const fields are static. Remove unnecessary modifier 'static'.
-# 0: name of const field
-CLF_FIELD_CONST_MISSING_INIT=error;;;Const field {0} must be provided with an initializer.
-# no parameters required
-CLF_FIELD_FINAL_STATIC=error;;;A field may not be declared both final and static. Use a const field instead.
-# 0: name of final field
-CLF_FIELD_FINAL_MISSING_INIT=error;;;Final field {0} must be provided with an initializer or must be initialized in the constructor.
-# 0: name of final field
-CLF_FIELD_FINAL_MISSING_INIT_IN_STATIC_POLYFILL=error;;;Final field {0} must be provided with an initializer or must be initialized in the constructor. HINT: You might want to check the polyfilled constructor.
-# 0: name of final field (that has an initializer expression)
-CLF_FIELD_FINAL_REINIT_IN_CTOR=error;;;Final field {0} has an initializer and may therefore not be initialized in the constructor.
-# no parameters required
-CLF_FIELD_OPTIONAL_OLD_SYNTAX=error;;;This syntax for optional fields is no longer allowed. Place the ? right after the field's name.
-
-# no parameters required
-CLF_IMPLEMENT_EXTEND_WITH_WILDCARD=error;;;Wildcards may not be used as type argument when declaring an extended or implemented type.
-# 0: "implement" or "extend", 0: name of interface, 1: name of type variable, 2: comma-separated list of type arguments
-CLF_IMPLEMENT_EXTEND_SAME_INTERFACE_INCONSISTENTLY=error;;;Cannot {0} interface {1} multiple times with different type arguments for {2}: {3}.
-# 0: overriding description ({@link ValidatorMessageHelper#descriptionDifferentFrom(TMember,TMember)}, 1: overridden description ({@link ValidatorMessageHelper#descriptionDifferentFrom(TMember,TMember)} 2: additional error information
-CLF_IMPLEMENT_MEMBERTYPE_INCOMPATIBLE=error;;;Cannot implement {1} with {0}.{2}
-# 0: descriptions of missing members, 1: the consumer
-CLF_IMPLEMENT_MIXIN_CONFLICTS=error;;;The {0} cannot be mixed in {1} due to conflicts.
-
-# 0: name of the current classifier, 1: abstract non overridden descriptions
-CLF_MISSING_IMPLEMENTATION=error;;;Class {0} must either be declared abstract or implement {1}.
-# 0: name of the current classifier, 1: abstract non overridden descriptions
-CLF_MISSING_IMPLEMENTATION_EXT=warning;;;External class {0} must either be declared abstract or explicit declare {1}.
-# 0: class, method, getter or setter
-CLF_ABSTRACT_FINAL=error;;;An abstract {0} cannot be declared final.
-# no parameters required, will be changed to error (IDE-1236)
-CLF_NO_FINAL_INTERFACE_MEMBER=warning;;;In interfaces, only methods may be declared final.
-# no parameters required
-CLF_NO_THIS_IN_STATIC_FIELD=error;;;The 'this' literal may not be used in initializers of static data fields.
-# no parameters required
-CLF_NO_THIS_IN_FIELD_OF_INTERFACE=error;;;In interfaces, the 'this' literal may not be used in initializers of data fields.
-# no parameters required
-CLF_NO_THIS_IN_STATIC_MEMBER_OF_INTERFACE=error;;;In interfaces, the 'this' literal may not be used in static methods or field accessors and in initializers of static data fields.
-# no parameters required
-CLF_INVALID_ACCESS_OF_STATIC_MEMBER_OF_INTERFACE=error;;;Static members of interfaces may only be accessed directly via the type name of their containing interface.
-# 0: method, getter or setter, 1: name of method/getter/setter
-CLF_STATIC_ABSTRACT=error;;;The {0} {1} may not be both static and abstract.
-# no parameters required
-CLF_ABSTRACT_BODY=error;;;Abstract methods do not specify a body.
-# 0: method, getter or setter, 1: member name, 2: class name
-CLF_ABSTRACT_MISSING=error;;;The abstract {0} {1} in class {2} can only be defined in an abstract class.
-# 0: method, getter or setter, 1: member name
-CLF_MISSING_BODY=error;;;The {0} {1} has to have either a body or must be defined abstract.
-# no parameters required
-CLF_MISSING_CTOR_BODY=error;;;Constructors must have a body.
-# no parameters required
-CLF_VOID_ACCESSOR=error;;;Void is not a valid type for getters and setters.
-# 0: accessor description, 1: verb, 2: missing accessor type
-CLF_UNMATCHED_ACCESSOR_OVERRIDE=error;;;{0} cannot be {1} without overriding the corresponding {2}.
-# 0: accessor description, 1: verb, 2: missing accessor type
-CLF_UNMATCHED_ACCESSOR_OVERRIDE_JS=warning;;;{0} should not be {1} without overriding the corresponding {2}.
-# 0: interface name
-CLF_MULTIPLE_ROLE_CONSUME=error;;;Cannot consume {0} multiple times.
-# 0: 'Classes' or 'Roles'
-CLF_EXT_EXTERNAL_N4JSD=error;;;{0} declared as external have to be placed in a file with file extension 'n4jsd'.
-# none
-CLF_EXT_PROVIDED_BY_RUNTIME_IN_RUNTIME_TYPE=error;;;Only runtime environments/libraries may specify elements provided by runtime.
-# no parameters required
-CLF_EXT_UNALLOWED_N4JSD=error;;;Only namespaces, classes, interfaces, enums, type aliases and functions declared as external as well as structurally typed interfaces are allowed in n4jsd files.
-# no parameters required
-CLF_EXT_EXPORTED=error;;;External elements have to be marked with modifier export.
-# no parameters required
-CLF_EXT_NOT_ANNOTATED_EXTEND_N4OBJECT=error;;;External classes annotated with @EcmaScript are not allowed to inherit from n4js classes.
-# 0: classes or interfaces
-CLF_EXT_CONSUME_NON_EXT=error;;;External {0} are not allowed to consume a non external interface.
-# 0: classes or interfaces
-CLF_EXT_IMPLEMENTS_NON_EXT=error;;;External {0} are not allowed to implement an interface from a non n4jsd file.
-# 0: classes or interfaces
-CLF_EXT_PUBLIC=error;;;External {0} have to be marked as public (and without @Internal).
-# no parameters required
-CLF_EXT_INTF_PUBLIC=error;;;Structural typed interfaces in n4jsd files have to be marked as public (and without @Internal).
-# 0: classes or interfaces
-CLF_EXT_EXTERNAL=error;;;External {0} have to be marked as external in n4jsd files.
-# 0: methods, getters or setters, 1: classes or interfaces
-CLF_EXT_NO_METHOD_BODY=error;;;{0} in external {1} have to have no body.
-# 0: classes or interfaces
-CLF_EXT_NO_FIELD_EXPR=error;;;Fields in external {0} have to have no right side.
-# no parameters required
-CLF_EXT_PUBLIC_CONSTRUCTOR=error;;;External classes annotated with @EcmaScript have to have a public constructor.
-# 0: classes or interfaces
-CLF_EXT_NO_OBSERV_ANNO=error;;;External {0} must not have the Observable annotation.
-# 0: methods, getters or setters, 1: classes or interfaces, 2: Observable or Nfon
-CLF_EXT_METHOD_NO_ANNO=error;;;{0} in external {1} must not have the {2} annotation.
-# no parameters required
-CLF_EXT_LITERAL_NO_VALUE=error;;;An enumeration literal in a n4jsd file isn't allowed to define a value.
-# no parameters required
-CLF_EXT_FUN_NO_BODY=error;;;External function declarations have to have no body.
-# 0 var or constant
-CLF_EXT_VAR_NO_VAL=error;;;External {0} declaration cannot be initialized.
-# spec: Component/Manifest/General-Constraint, no parameters required
-CLF_EXT_NO_MATCH=warning;;;For the given n4jsd file no corresponding external file resp. no matching implemented by expression can be found.
-# doc: validate duplicates between src/src-test and external (so there is e.g. file A.n4js that compiles to A.js that would be name conflict with A.js in external), spec: Component/Manifest/General-Contraint, 0: file, 1: path
-CLF_EXT_DUPLICATE_PATH_SRC_EXTERNAL=error;;;Duplicate external file {0}, has been already defined in {1}.
-# no parameters required
-CLF_IN_DEFINITION_PRJ_NON_N4JS=warning;;;Class declarations in definition projects should be annotated with @EcmaScript.
-
-# 0: annotation name, 1: type (interface or classifier)
-CLF_EXT_PROVIDES_IMPL_ONLY_IN_DEFFILES=error;;;@{0} must only be used in external {1} in n4jsd files.
-# 0: annotation name, 1: type (interface or classifier)
-CLF_EXT_PROVIDES_IMPL_ONLY_IN_INTERFACE_MEMBERS=error;;;@{0} must only be used in {1}.
-# 0: annotation name, 1: type (interface or classifier)
-CLF_EXT_PROVIDES_IMPL_ONLY_IN_N4JS_INTERFACES=error;;;@{0} must only be used in n4js interfaces or classes.
-
-
-# 0: type name, 1: access modifier name
-CLF_LOW_ACCESSOR_WITH_INTERNAL=error;;;A {0} with visibility {1} shouldn't be annotated with @Internal.
-# 0: 'extend' or 'implement', 1: type name, 2: description of members causing problems
-CLF_NON_ACCESSIBLE_ABSTRACT_MEMBERS=error;;;Cannot {0} {1}: cannot implement one or more non-accessible abstract members: {2}.
-# no parameters required
-CLF_MINIMAL_ACCESSIBILITY_IN_INTERFACES=error;;;Members of interfaces must not be declared private.
-# no parameters required
-CLF_SPEC_WRONG_TYPE=error;;;Annotation @Spec may only be used with formal parameters of type ~i~this.
-# 0: name of field, 1: type of member, 2: type system error message
-CLF_SPEC_WRONG_ADD_MEMBERTYPE=error;;;Type of structural member {0} of spec parameter must be a subtype of {1}: {2}.
-# no parameters required
-CLF_SPEC_MULTIPLE=error;;;Only a single formal parameter in each constructor may be annotated with @Spec.
-# 0: name of the superfluous property, 1: the type not defining the property
-CLF_SPEC_SUPERFLUOUS_PROPERTIES=warning;;;{0} is not defined in {1}; it will not have any effect in the spec constructor.
-# 0: name of the superfluous property, 1: the type not defining the property, 2: name of variable the object literal is assigned to
-CLF_SUPERFLUOUS_PROPERTIES=warning;;;{0} is not defined in {1}; it will not be accessible from {2}.
-# 0: name of the property, {1} built-in/provided by runtime interface
-CLF_SPEC_BUILT_IN_OR_PROVIDED_BY_RUNTIME_OR_EXTENAL_WITHOUT_N4JS_ANNOTATION=warning;;;{0} is a property of a built-in, provided by runtime, or external module with @EcmaScript annotation. Hence the interface {1} can not be initialized in a spec constructor.
-# 0:the cycle
-CLF_INHERITANCE_CYCLE=error;;;Inheritance cycle detected: {0}.
-# no param
-CLF_INTERNAL_BAD_WITH_PRIVATE_OR_PROJECT=error;;;@Internal is only allowed for public and protected.
-# no param
-CLF_CANNOT_CALL_ABSTRACT_SUPER_METHOD=error;;;Cannot call super method since it is abstract.
-# no param
-CLF_CANNOT_REFER_TO_DEFAULT_METHOD_WITH_SUPER=error;;;Cannot refer to default method of an implemented interface with super.
-
-# 0: name of polyfill, 1: 'class' or 'interface' including indefinite article
-CLF_POLYFILL_EXTEND_MISSING=error;;;Polyfill {0} must explicitly extend {1}.
-# 0: name of polyfill
-CLF_POLYFILL_NO_TOPLEVEL=error;;;Polyfill {0} can only extend top level class declaration.
-# 0: 'class' or 'interface', 1: name of correct classifier kind (without article), 2: name of correct classifier kind including indefinite article, 3: name of *incorrect* classifier kind including indefinite article
-CLF_POLYFILL_DIFFERENT_CLASSIFIER_KIND=error;;;Polyfill for {0} {1} must be {2}, not {3}.
-# 0: name of polyfill, 1: 'class' or 'interface', 2: name of extended class
-CLF_POLYFILL_DIFFERENT_NAME=error;;;Name of polyfill {0} must equal name of filled {1} {2}.
-# 0: name of polyfill, 1: name polyfill's module, 2: name of filled class' module
-CLF_POLYFILL_DIFFERENT_MODULE_SPECIFIER=error;;;Specifier {1} of module containing polyfill {0} must equal name of filled classes module specifier {2}.
-# 0: name of polyfill, 1: global/not global polyfill module, 2: not/empty global polyfill
-CLF_POLYFILL_DIFFERENT_GLOBALS=error;;;Module containing polyfill {0} is {1}, but filled classes module is {2}.
-# 0: name of polyfill
-CLF_POLYFILL_FILLED_NOT_PROVIDEDBYRUNTIME=error;;;Polyfill {0} cannot fill class not provided by runtime.
-# 0: name of polyfill
-CLF_POLYFILL_NOT_PROVIDEDBYRUNTIME=error;;;Polyfill {0} must be provided by runtime.
-# 0: name of polyfill
-CLF_POLYFILL_NO_IMPLEMENTS=error;;;Polyfill {0} must not implement any interfaces.
-# 0: name of polyfill
-CLF_POLYFILL_NO_EXTENDS_ADDITIONAL=error;;;Polyfill {0} must not extend any additional interfaces.
-# 0: name of polyfill
-CLF_POLYFILL_NOT_DIRECTLY_EXPORTED=error;;;Polyfill {0} must be exported.
-# 0: name of polyfill, 1: name of polyfill modifier, 2: name of filled modifier, 3: 'class' or 'interface'
-CLF_POLYFILL_DIFFERENT_MODIFIER=error;;;Polyfill {0} cannot be declared {1}, must be defined {2} just as the filled {3}.
-# 0: name of polyfill, 1: type system error message
-CLF_POLYFILL_CTOR_NOT_OVERRIDE_COMPATIBLE=error;;;Constructor of polyfill {0} must be override compatible with inherited constructor: {1}
-# 0: name of polyfill, 1: 'class' or 'interface'
-CLF_POLYFILL_DIFFERENT_TYPEPARS=error;;;Polyfill {0} must declare same type parameters as the filled {1}.
-# 0: name of polyfill
-CLF_POLYFILL_INCOMPLETE_TYPEARGS=error;;;Polyfill {0} must pass all type parameters to type arguments (even optional ones).
-# 0: name of polyfill, 1: type par, 2: type arg
-CLF_POLYFILL_TYPEPARS_DIFFER_TYPEARGS=error;;;Polyfill {0} must pass type parameters to type arguments in same order and without modifications, but {1} differs from {2}.
-# 0: list of modules name with polyfills, 0: member name
-CLF_POLYFILL_MULTIPOLYFILLS_MEMBER_CONFLICT=error;;;Polyfills in {0} provide member {1} - only one provider per member is allowed.
-# 0: name of polyfill
-CLF_POLYFILL_STATIC_FILLED_TYPE_NOT_AWARE=error;;;For static polyfills, the module of the filled type {0} must be annotated with @StaticPolyfillAware.
-# 0: name of polyfill, 1: file extension (.n4js or .n4jsd)
-CLF_POLYFILL_STATIC_DIFFERENT_VARIANT=error;;;Since static polyfill {0} is declared in an {1} file, the filled type must also be declared in an {1} file.
-
-# 0: string that is used as name for more than one literal
-ENM_DUPLICTAE_LITERALS=error;;;Multiple literals with name {0}.
-# no parameters required
-ENM_INVALID_VALUE_EXPRESSION=error;;;Only string literals and number literals are allowed as value of an enum literal.
-# 0: string with the name of the meta property
-ENM_LITERALS_HIDE_META=error;;;EnumLiteral cannot have the same name as Enum meta property <{0}>.
-# no parameters required
-ENM_WITHOUT_LITERALS=error;;;An enum type must declare at least one literal.
-# no parameters required
-ENM_BOTH_NUMBER_AND_STRING_BASED=error;;;An enum may not be annotated with both @NumberBased and @StringBased.
-# no parameters required
-ENM_ILLEGAL_NUMERIC_VALUE=error;;;Values of type number may only be used for literals of @NumberBased enums.
-# no parameters required
-ENM_ILLEGAL_STRING_VALUE=error;;;Values of literals in @NumberBased enums must be of type number.
-# no parameters required
-ENM_INVALID_USE_OF_NUM_OR_STR_BASED_ENUM=error;;;A @NumberBased or @StringBased enum may only be used in type annotations and in property access expressions to access either one of its literals or the static getter called 'literals'.
-
-# no parameters required
-# ITF_MEMBER_ACCESSIBILITY=error;;;Member of an interface must not have lower accessibility than the containing interface.
-# no parameters required
-ITF_NO_FINAL=error;;;Interfaces must not be declared final.
-# 0: name of field, 1: name of interface
-ITF_NO_FIELD_INITIALIZER=error;;;Cannot initialize field in interface. Only classes or interfaces implementing {1} can initialize {0}.
-# 0: property kind name, 1: structural /nominal /
-ITF_NO_PROPERTY_BODY=error;;;{0} in {1}interfaces must not have a body.
-# no parameters required
-ITF_CONSTRUCTOR_COVARIANCE=error;;;Constructors in interfaces must be annotated with @CovariantConstructor.
-# no parameters required
-ITF_IN_DEFINITION_PRJ_NON_N4JS=warning;;;Nominal interface declarations in definition projects should instead be structural (use '~').
-
-# no parameters required
-STRCT_ITF_CANNOT_EXTEND_INTERFACE=error;;;Structural interfaces cannot extend nominal interfaces.
-# no parameters required
-STRCT_ITF_CANNOT_CONTAIN_STATIC_MEMBERS=error;;;Structural interfaces cannot contain static members.
-# no parameters required
-STRCT_ITF_MEMBER_MUST_BE_PUBLIC=warning;;;Non-public members of structural interfaces are effectless.
-
-# 0: name of cyclic type aliases
-ALI_CYCLIC_TYPE_ALIAS=error;;;Cyclic type alias declaration: {0}.
-# no parameters required
-ALI_INVALID_MODIFIER=error;;;A type alias may be referenced {0} only if its aliased type may be referenced {0}.
-# 0: the string "{}"
-ALI_INVALID_TYPE_ALIAS_IN_TYPE_TYPE_REF=error;;;A type alias may be used inside type{0} or constructor{0} only if its aliased type may be used at this location.
-
-# 0: passed parameter count, 1: expected parameter count
-FUN_PARAM_COUNT=error;;;Passed parameter count {0} doesn't match with expected parameter count {1}.
-# no parameters required
-FUN_BLOCK=warning;;;Functions declarations should not be placed in blocks. Use a function expression or move the statement to the top of the outer function.
-# no parameters required
-FUN_BODY=error;;;Functions have to have a body.
-# 0: element description, 1: conflicting category
-FUN_NAME_RESERVED=error;;;{0} may be confused with {1}.
-# no parameters
-FUN_NAME_MISSING=error;;;Function declarations must have a name.
-# 0: formal parameter
-FUN_PARAM_OPTIONAL_WRONG_SYNTAX=error;;;Wrong syntax: Use {0}=undefined instead of ?.
-# no parameters
-FUN_PARAM_INITIALIZER_ILLEGAL_FORWARD_REFERENCE=error;;;Illegal forward reference to formal parameter of same function.
-# no parameters
-FUN_PARAM_INITIALIZER_ONLY_UNDEFINED_ALLOWED=error;;;Only ''undefined'' allowed for initializers of default parameters in function types.
-# 0: formal parameter
-# 1: identifier
-FUN_PARAM_INITIALIZER_ILLEGAL_REFERENCE_TO_BODY_VARIABLE=error;;;Initializer of parameter ''{0}'' cannot reference the identifier ''{1}'' declared in the body.
-# 0: formal parameter
-FUN_PARAM_INITIALIZER_ILLEGAL_AWAIT_CALL=error;;;Illegal await-expression in initializer of formal parameter ''{0}''.
-# 0: name of actually used generator type, 1: expected generator kind (synchronous or asynchronous), 2: name of expected generator type
-FUN_GENERATOR_RETURN_TYPE_MISMATCH=warning;;;Type {0} is intended for {1} generator functions; consider using type {2} instead.
-
-# no parameters required
-AST_SEPARATE_DEFAULT_EXPORT_WITHOUT_FROM=error;;;Missing from-clause in default re-export.
-# 0: element, 1: kind of value
-AST_ELEMENT_MISUSED_AS_VALUE_OR_TYPE=error;;;{0} cannot be used as a {1}.
-# no parameters required
-AST_INVALID_NEW_TARGET=error;;;Invalid new.target.
-# no parameters required
-AST_INVALID_YIELD_EXPRESSION=error;;;The parameter initializer of a generator may not contain a `yield` expression.
-# no parameters required
-AST_CONST_IN_STATEMENT_POSITION=error;;;Const variable statements must be on the top level or nested in a block.
-# no parameters required
-AST_LET_IN_STATEMENT_POSITION=error;;;Let declarations may not appear in statement position.
-# 0: name of blank const variable
-AST_CONST_HAS_NO_INITIALIZER=error;;;Const variable {0} must be provided with an initializer.
-# no parameters required
-AST_STR_NO_OCTALS=error;;;octal literals and octal escape sequences are not allowed in strict mode.
-# 0: operand (decrement or increment)
-AST_INVALID_OPERAND=error;;;Invalid {0} operand.
-# no parameters required
-AST_EXP_INVALID_LHS_ASS=error;;;Invalid assignment left-hand side.
-# 0: identifier
-AST_RESERVED_IDENTIFIER=error;;;{0} is a reserved identifier.
-# no parameters required
-AST_STR_NO_WITH_STMT=error;;;With statement not allowed.
-# no parameters required, not used yet in AST, was before in N4JSStrictValidator
-AST_STR_FUN_NOT_NESTED=error;;;Functions must only be declared on script level or as part of other expressions
-# no parameters required
-AST_INVALID_RETURN=error;;;return statement without enclosing function
-# no parameters required
-AST_INVALID_CONTINUE=error;;;continue statement without enclosing iteration
-# no parameters required
-AST_INVALID_BREAK=error;;;break statement without enclosing iteration or case block
-# no parameters required
-AST_INVALID_LABEL=error;;;Label must be of an enclosing iteration statement but may not cross function boundaries
-# no parameters required
-AST_THIS_WRONG_PLACE=error;;;The 'this' type isn't allowed on this place. (Please refer to Spec for valid use cases.)
-# 0: variable name
-AST_VAR_DECL_RECURSIVE=warning;;;Reference to variable {0} within the initializer expression of the declaration of {0}.
-# no parameters required
-AST_VAR_DECL_IN_FOR_INVALID_INIT=error;;;The iteration variable of a for..in or for..of loop must not be provided with an initializer.
-# no parameters required
-AST_INVALID_FOR_AWAIT=error;;;Only for..of loops may be used for asynchronous iteration with "for await".
-# no parameters required
-AST_INVALID_OPTIONAL_TYPE_PARAMS=error;;;Only type parameters of classes, interfaces, and type aliases may be declared optional.
-# no parameters required
-AST_NO_TYPE_ARGS_IN_CLASSIFIERTYPEREF=error;;;Only raw types can be used in classifier type references.
-# no parameters required
-AST_NO_FUNCTIONTYPEREFS_IN_CLASSIFIERTYPEREF=error;;;Function types are not allowed in classifier type references.
-# no parameters required
-AST_INVALID_EXPR_IN_LHS_DESTRUCTURING_PATTERN=error;;;Only a variable or nested destructuring pattern is allowed at this location within a destructuring pattern.
-# no parameters required
-AST_INVALID_PROPERTY_METHOD_IN_LHS_DESTRUCTURING_PATTERN=error;;;Property methods are not allowed within an object destructuring pattern.
-# no parameters required
-AST_INVALID_DEFAULT_EXPR_SINGLE_NAME_PROPERTY=error;;;A default value is only allowed within a destructuring pattern.
-# no parameters required
-AST_REST_MUST_APPEAR_AT_END=error;;;Rest operator only allowed on last element in an array destructuring pattern.
-# no parameters required
-AST_REST_WITH_INITIALIZER=error;;;Rest operator does not support an initializer.
-# no parameters required
-AST_TYPE_DECL_MISSING_NAME=error;;;Name missing in type declaration.
-# no type annotation for catch variable
-AST_CATCH_VAR_TYPED=error;;;Catch variable must not be typed.
-# 0: name of the JavaScript variant of the context
-AST_TOP_LEVEL_STATEMENTS=error;;;Top-level statements are not supported in {0} files.
-# No parameters
-AST_VAR_STMT_NO_DECL=error;;;A variable statement must at least contain one variable declaration.
-# 0: script annotation name
-AST_SCRIPT_ANNO_INVALID_PLACEMENT=error;;;The script annotation @@{0} must be placed at the top of the module.
-# 0: Forbidden Type e.g. null / undefined
-AST_BINARY_LOGICAL_EXPRESSION_MISSING_PART=error;;;The logical expression is missing the {0}.
-# no parameters required
-AST_IMPORT_CALL_SPREAD=error;;;The spread operator is not allowed in import calls.
-# 0: Invalid parent e.g. && / ||
-AST_INVALID_COALESCE_PARENT=error;;;Nullish coalescing expressions cannot be contained within an {0} operation.
-# 0: Invalid child e.g. && / ||
-AST_INVALID_COALESCE_CHILD=error;;;Nullish coalescing expressions cannot immediately contain an {0} operation.
-
-# 0: local variable name
-CFG_LOCAL_VAR_UNUSED=warning;;;The local variable {0} is never used
-# 0: local variable name
-CFG_USED_BEFORE_DECLARED=warning;;;Variable {0} is used before it is declared
-
-# 0: local variable name
-# 1: 'is' or 'may be'
-# 2: 'null' or 'undefined'
-# 3: reason (optional)
-DFG_NULL_DEREFERENCE=warning;;;Variable {0} {1} {2}{3}
-
-# 0: shadowing object, 1: shadowed object
-AST_NAME_SHADOW_WARN=warning;;;{0} shadows {1}.
-# 0: shadowing object, 1: shadowed object
-AST_NAME_SHADOW_ERR=error;;;{0} shadows {1}.
-# 0: hiding parameter 1: hidden parameter
-AST_GLOBAL_NAME_SHADOW_ERR=error;;;{0} shadows {1} from global scope.
-# 0: name
-AST_GLOBAL_JS_NAME_CONFLICT=error;;;Globally defined element named {0} must be defined in runtime environment.
-# 0: name
-AST_GLOBAL_NAME_CONFLICT=error;;;Globally defined element must not be named {0}.
-# 0: duplicating object, 1: duplicated object
-AST_NAME_DUPLICATE_ERR=error;;;{0} duplicates {1}.
-# 0: duplicating object, 1: duplicated object
-AST_NAME_DUPLICATE_WARN=warning;;;{0} duplicates {1}.
-
-
-# 0: grammar rule, 1: value
-VCO_DOUBLE_NEGATIVE=error;;;{0}-value may not be negative (value: {1}).
-# no parameters required
-VCO_DOUBLE_CONVERT_EMPTY_STR=error;;;Couldn't convert empty string to a double value.
-# 0: the string value
-VCO_DOUBLE_CONVERT_STR=error;;;Couldn't convert {0} to a double value.
-# 0: grammar rule, 1: value
-VCO_HEXINT_NEGATIVE=error;;;{0}-value may not be negative (value: {1}).
-# no parameters required
-VCO_HEXINT_CONVERT_EMPTY_STR=error;;;Couldn't convert empty string to an hex int value.
-# 0: the string value
-VCO_HEXINT_CONVERT_TOO_SHORT=error;;;Couldn't convert {0} to an int value.
-# 0: the string value
-VCO_HEXINT_CONVERT_STR=error;;;Couldn't convert {0} to an hex int value.
-# 0: grammar rule, 1: value
-VCO_BINARYINT_NEGATIVE=error;;;{0}-value may not be negative (value: {1}).
-# no parameters required
-VCO_BINARYINT_CONVERT_EMPTY_STR=error;;;Couldn't convert empty string to a binary int value.
-# 0: the string value
-VCO_BINARYINT_CONVERT_TOO_SHORT=error;;;Couldn't convert {0} to an int value.
-# 0: the string value
-VCO_BINARYINT_CONVERT_STR=error;;;Couldn't convert {0} to a binary int value.
-# 0: grammar rule, 1: value
-VCO_OCTALINT_NEGATIVE=error;;;{0}-value may not be negative (value: {1}).
-# no parameters required
-VCO_OCTALINT_CONVERT_EMPTY_STR=error;;;Couldn't convert empty string to an octal int value.
-# 0: the string value
-VCO_OCTALINT_CONVERT_TOO_SHORT=error;;;Couldn't convert {0} to an int value.
-# 0: the string value
-VCO_OCTALINT_LEADING_ZEROS=error;;;Don't use extra leading zeros {0}."
-# 0: the string value
-VCO_OCTALINT_CONVERT_STR=error;;;Couldn't convert {0} to an octal int value.
-# 0: grammar rule, 1: value
-VCO_SCIINT_NEGATIVE=error;;;{0}-value may not be negative (value: {1}).
-# no parameters required
-VCO_SCIINT_CONVERT_EMPTY_STR=error;;;Couldn't convert empty string to an scientific int value.
-# 0: the string value
-VCO_SCIINT_CONVERT_STR=error;;;Couldn't convert {0} to an scientific int value.
-# 0: identifier, 1: position
-VCO_IDENT_ESCAPE_SEQ=error;;;Illegal escape sequence in identifier {0} at position {1}.
-# 0: result, 1: identifier, 2: position
-VCO_IDENT_ILLEGAL_CHAR_WITH_RESULT=error;;;Illegal character in identifier ''{0}'' ({1}) at position {2}.
-# 0: identifier, 1: position
-VCO_IDENT_ILLEGAL_CHAR=error;;;Illegal character in identifier ''{0}'' at position {1}.
-# no parameters required
-VCO_JSXIDENT_WHITESPACE_COMMENT=error;;;JSX attribute names may not contain whitespace or comments. Attribute names ending with a '-' and directly followed by another attribute name are merged and must not contain whitespace or comments.
-# no parameters required
-VCO_STRING_DOUBLE_QUOTE=error;;;String literal is not properly closed by a double-quote.
-# no parameters required
-VCO_STRING_QUOTE=error;;;String literal is not properly closed by a quote.
-# no parameters required
-VCO_TEMPLATE_QUOTE=error;;;Template literal is not properly closed by a backtick.
-# no parameters required
-VCO_TEMPLATE_MIDDLE=error;;;Template literal is not properly closed by ${.
-# no parameters required
-VCO_TEMPLATE_IN_OPT_CHAIN=error;;;Tagged template expressions are not permitted in an optional chain.
-# no parameters required
-VCO_STRING_BAD_ESCAPE_WARN=warning;;;Bad escapement
-# no parameters required
-VCO_STRING_BAD_ESCAPE_ERROR=error;;;Bad escapement
-# no parameters required
-VCO_REGEX_INVALID=error;;;Invalid regular expression literal
-# 0: literal
-VCO_REGEX_ILLEGAL_ESCAPE=error;;;Illegal escape sequence in regular expression {0}
-# no parameters required
-VCO_REGEX_NAMED_GROUP=warning;;;Named capture groups are not supported on all platforms.
-# no parameters required
-VCO_NPE=error;;;A NullPointerException occurred. This indicates a missing value converter or a bug in its implementation.
-# 0: feature name
-VCO_NULL_FEATURE=error;;;ValueConverter returned null for primitive feature {0}
-
-
-# no parameters required
-BIT_SYMBOL_INVALID_USE=error;;;Invalid use of 'Symbol': may only be used to create symbols (i.e. Symbol()) or to access built-in symbols (e.g. Symbol.iterator).
-# no parameters required
-BIT_SYMBOL_NOT_A_CTOR=error;;;Symbol is not a constructor, use Symbol() without new.
-
-
-# no parameters required
-TYS_MISSING=error;;;Types model hasn't been built for this file. Please report this bug to a N4JS developer.
-# 0: expression
-TYS_CANNOT_TYPE=error;;;cannot type {0}.
-# 0: left expression, 1: right expression
-TYS_NO_SUBTYPE=error;;;{0} is not a subtype of {1}.
-# 0: expected type, 1: actual type
-TYS_NO_SUPERTYPE_WRITE_ACCESS=error;;;expecting write-access for type {0} but {1} is not a super type of {0}.
-# no parameters required
-TYS_NULL_OBJECT=error;;;passed null object to system at {0}.
-# no parameters required
-TYS_VOID_AT_WRONG_LOCATION=error;;;Type 'void' may only be used to declare the return type of functions and methods.
-# 0: member type, 1: member name, 2: type name
-TYS_MEMBER_NOT_IN_STRUCTURAL_TYPE_DEF_SITE=error;;;{0} {1} is not available for structurally defined type {2}.
-# 0: member type, 1: member name, 2: type name
-TYS_MEMBER_NOT_IN_STRUCTURAL_TYPE_USE_SITE=error;;;{0} {1} is not available for structurally referenced type {2}.
-# 0: member type, 1: member name, 2: type name
-TYS_MEMBER_NOT_IN_STRUCTURAL_FIELDS_TYPE_USE_SITE=error;;;{0} {1} is not available for fields-only-referenced type {2}.
-# no parameters required
-TYS_INSTANCEOF_NOT_SUPPORTED_FOR_USE_SITE_STRUCTURAL=error;;;'instanceof' cannot be used with use site structural typing.
-# 0: type name
-TYS_INSTANCEOF_NOT_SUPPORTED_FOR_BUILT_IN_INTERFACES=error;;;'instanceof' cannot be used with built-in interface {0}.
-# no parameters required
-TYS_INSTANCEOF_NOT_SUPPORTED_FOR_PRIMITIVE_TYPES=error;;;'instanceof' cannot be used with primitive types.
-# 0: property name
-TYS_PROPERTY_HAS_NO_SETTER=error;;;Property {0} has no setter.
-# 0: type name
-TYS_PRIMITIVE_TYPE_DYNAMIC=error;;;Primitive type {0} must not be referenced dynamically.
-# no parameters required
-TYS_COMPOUND_MISSING_GETTER=error;;;Missing getter on left-hand side of compound assignment.
-# no parameters required
-TYS_NON_VOID_ASYNC=error;;;Internal error: Only Promise allowed as inferred return type of an async FunctionDefinition
-# no parameters required
-TYS_NON_THIS_ASYNC=error;;;The return type of an async function is not allowed to refer to the this-type.
-# 0: type name
-TYS_FOR_IN_VAR_STRING=error;;;Type of for-in-loop variable must be a super type of string but {0} is not.
-# no parameters required
-TYS_ADDITIONAL_STRUCTURAL_MEMBERS_ON_TYPE_VARS=error;;;No additional structural members allowed on type variables, since they can cause collisions.
-# no parameters required
-TYS_FUNCTION_DISALLOWED_AS_TYPE=error;;;The name of a declared function may not be used as a type name.
-# no parameters required
-TYS_STRUCTURAL_PRIMITIVE=warning;;;Structural type operator ~ does not have any effect on primitive types.
-
-# no parameters required
-EXP_USE_OF_UNDEF_EXPR=warning;;;The type of this expression is 'undefined', so it will never evaluate to a value other than 'undefined'.
-# 0: actual type
-EXP_CALL_NOT_A_FUNCTION=error;;;Not a function or method: {0}.
-# 0: comma-separated list of conflicting callable type references
-EXP_CALL_CONFLICT_IN_INTERSECTION=error;;;More than one callable type in intersection: {0}.
-# no parameters required
-EXP_CALL_CLASS_CTOR=error;;;Cannot directly invoke class constructor functions; use 'new' instead.
-# 0: actual type
-EXP_NEW_NOT_A_CTOR=error;;;Not a reference to a constructor: {0}.
-# 0: intersection type with conflicting ctors or construct signatures
-EXP_NEW_CONFLICT_IN_INTERSECTION=error;;;More than one constructor or construct signature in intersection: {0}.
-# 0: type arg name of constructor, 1: static type
-EXP_NEW_WILDCARD_NO_COVARIANT_CTOR=error;;;Cannot instantiate {0}, because {1} does not have a @CovariantConstructor.
-# 0: type arg name of constructor
-EXP_NEW_WILDCARD_OR_TYPEVAR=error;;;Cannot instantiate {0}.
-# 0: abstract class, interface, 1: classifier name
-EXP_NEW_CANNOT_INSTANTIATE=error;;;Cannot instantiate {0} {1}.
-# 0: number of expected type args, 1: number of actual type args
-EXP_WRONG_NUMBER_OF_TYPEARGS=error;;;Incorrect number of type arguments: expected {0}, got {1}.
-# 0: class, interface, method, function 1: name of classifier/method/function, 2: number of expected type args, 3: number of actual type args
-EXP_WRONG_NUMBER_OF_TYPEARGS_FOR_ELEMENT=error;;;Incorrect number of type arguments for {0} {1}: expected {2}, got {3}.
-# 0: maximum number of element types in an ArrayN
-EXP_WRONG_NUMBER_OF_TYPEARGS_FOR_ITERABLE_N_SYNTAX=error;;;The ArrayN types are available for a maximum of {0} element types only (i.e. type Array{0}).
-# 0: upper or lower, 1: covariant or contravariant
-EXP_INCONSISTENT_VARIANCE_OF_TYPE_ARG=error;;;Cannot use wildcard with {0} bound as argument to a {1} type parameter.
-# 0: covariant or contravariant, 1: covariant or contravariant
-EXP_INCONSISTENT_VARIANCE_OF_TYPE_ARG_IN_OUT=error;;;Cannot combine {0} on use site with {1} on definition site.
-# 0: expected num of params, 1: actual num of params
-EXP_NUM_OF_ARGS_TOO_FEW=error;;;Incorrect number of arguments: expected {0}, got {1}.
-# 0: expected num of params, 1: actual num of params
-EXP_NUM_OF_ARGS_TOO_MANY=error;;;Incorrect number of arguments: expected {0}, got {1}.
-# 0: from type ref, 1: target type ref
-EXP_CAST_FAILED=error;;;Cannot cast from {0} to {1}
-# 0: from type ref, 1: target type ref
-EXP_CAST_UNNECESSARY=warning;;;Unnecessary cast from {0} to {1}
-# no parameter required
-EXP_CAST_INVALID_TARGET=error;;;Can only cast to class, interface, enum, function, primitive, union or intersection types
-# 0: recognized type, 2: result, e.g. NaN
-EXP_MATH_OPERATION_RESULT_IS_CONSTANT=warning;;;Operand {0} will always result in {1}.
-# 0: recognized type, 1: constant value
-EXP_MATH_OPERAND_IS_CONSTANT=warning;;;Operand of type {0} will be interpreted as {1}.
-# 0: recognized type, 2: result, e.g. NaN
-EXP_MATH_TYPE_NOT_PERMITTED=error;;;Operand of type {0} cannot be converted to number.
-# 0: left type 1: rght type 2: result
-EXP_WARN_CONSTANT_EQUALITY_TEST=warning;;;Neither {0} is a subtype of {1} nor {1} is a subtype of {0}. The expression will always evaluate to {2}.
-# 0: Forbidden Type e.g. null / undefined
-EXP_FORBIDDEN_TYPE_IN_BINARY_LOGICAL_EXPRESSION=error;;;{0} is not allowed on the left hand side of a logical expression.
-# 0: member description, 1: type of target, 2: declared this type (from @This annotation)
-EXP_ACCESS_INVALID_TYPE_OF_TARGET=error;;;Target of property access not a subtype of the declared @This type of {0}: {1} is not a subtype of {2}.
-# 0: method name
-EXP_METHOD_REF_UNATTACHED_FROM_RECEIVER=error;;;A reference to method {0} is created detached from a (correct) this-instance.
-# 0: await expression, 1 async annotation
-EXP_MISPLACED_AWAIT=error;;;{0} is allowed only inside functions annotated with {1}.
-# no parameter required
-EXP_MISSNG_AWAIT_FOR_ASYNC_TARGET=warning;;;Calling async function without await, Promise should be made explicit.
-# 0: Suspicious expression, 1: boolean value, 2:left-hand/right-hand
-EXP_WARN_DISPENSABLE_CONDITIONAL_EXPRESSION=warning;;;Dispensable use of conditional expression. The expression ''{0}'' always evaluates to {1}, so only the {2} side will ever be evaluated.
-# no parameter required
-EXP_AWAIT_NON_ASYNC=warning;;;await should only be used on expressions of type Promise,?> since otherwise it has no effect.
-# 0: recognized expression
-EXP_AWAIT_NON_ASYNC_SPECIAL=warning;;;await should not be used on ''{0}'' since it has no effect here.
-
-# no parameter required
-FUN_RETURNTYPE_VOID_FOR_SETTER_VIOLATED=error;;;Set accessors must not return anything.
-# 0: name of return type
-FUN_MISSING_RETURN_EXPRESSION=error;;;Return statement must have an expression of type {0}
-# no parameter required
-FUN_MISSING_RETURN_OR_THROW_STATEMENT=error;;;Missing return or throw statement.
-# no parameter required
-FUN_MISSING_ELSE_BRANCH_FOR_CONDITIONAL_LAST_CONTROL_FLOW=error;;;Last if statement on control flow path is missing required else branch.
-# no parameter required
-FUN_MISSING_RETURN_OR_THROW_STATEMENT_WHILE_CANNOT_BE_CHECKED=error;;;Missing return or throw statement after while-expression. Correct termination of while-loops cannot be verified. Please append return/throw.
-# no parameter required
-FUN_MISSING_RETURN_OR_THROW_STATEMENT_FOR_CANNOT_BE_CHECKED=error;;;Missing return or throw statement after for-expression. Correct termination of for-loops cannot be verified. Please append return/throw.
-# no parameter required
-FUN_DEAD_CODE=warning;;;Dead code.
-# 0: last executed statement name
-FUN_DEAD_CODE_WITH_PREDECESSOR=warning;;;Dead code. No execution possible after {0}.
-# no parameters required
-FUN_SETTER_CANT_BE_VARIADIC=error;;;Variadic parameter is not allowed in setter declarations.
-# no parameters required
-FUN_SETTER_CANT_BE_DEFAULT=error;;;Default parameter is not allowed in setter declarations.
-# no parameters required
-FUN_PARAM_VARIADIC_ONLY_LAST=error;;;Only the last formal parameter can be variadic.
-# 0: name of parameter
-FUN_PARAM_IMPLICIT_DEFAULT_PARAM=warning;;;This parameter is changed to the default parameter ''{0}=undefined'' since it follows a default parameter.
-# no parameter required
-FUN_PARAM_VARIADIC_WITH_INITIALIZER=error;;;Variadic parameters must not have a default initializer.
-# no parameter required
-FUN_SINGLE_EXP_LAMBDA_IMPLICIT_RETURN_ALLOWED_UNLESS_VOID=error;;;An arrow-function is used in a context where its body is expected to have some value as opposed to being void.
-# 0: type parameter name
-FUN_UNUSED_GENERIC_TYPE_PARAM=warning;;;Type variable {0} not used in parameters or return type.
-
-# no parameters required
-KEY_SUP_INVALID_USAGE=error;;;Keyword super may only be used in member access expressions, call expressions or new expressions.
-# no parameters required
-KEY_SUP_ACCESS_INVALID_LOC=error;;;Super member access may only be used in constructors, methods, getters, or setters.
-# no parameters required
-KEY_SUP_ACCESS_NO_EXTENDS=error;;;Super member access requires a declared super type.
-# no parameters required
-KEY_SUP_ACCESS_INVALID_LOC_INTERFACE=error;;;Super member access may not be used in interfaces.
-# no parameters required
-KEY_SUP_ACCESS_FIELD=error;;;Super member access may not be used to access a field.
-# no parameters required
-KEY_SUP_CTOR_INVALID_LOC=error;;;Super calls may only be used in constructors.
-# no parameters required
-KEY_SUP_NEW_NOT_SUPPORTED=error;;;Keyword super with in expressions is not supported yet.
-# no parameters required
-KEY_SUP_NESTED=error;;;Super call must not be nested in function expressions.
-# no parameters required
-KEY_SUP_CTOR_EXPRSTMT=error;;;Super constructor call must no be used in a composed expression.
-# 0: container in which super is nested (with line number).
-KEY_SUP_CTOR_NESTED=error;;;Super constructor call must only be directly contained in constructor body, i.e. not nested in {0}.
-# 0: container in which super is nested (with line number).
-KEY_SUP_CTOR_INVALID_EXPR_BEFORE=error;;;Super constructor call must not be preceded by {0}.
-# 0: super class name
-KEY_SUP_REQUIRE_EXPLICIT_SUPERCTOR_CALL=error;;;Must explicitly invoke constructor of super class {0}.
-# no parameters required
-KEY_SUP_CALL_NO_INDEXACCESS=error;;;Super member access may not be used with index access.
-
-# no parameters required
-KEY_THIS_REJECTED_IN_TOP_LEVEL_LAMBDA=error;;;In a top-level arrow function, the 'this' keyword refers to nothing.
-
-# no parameters required
-EXP_OPTIONAL_INVALID_PLACE=error;;;The optional modifier isn't allowed here.
-# 0: name of const variable
-EXP_ASSIGN_CONST_VARIABLE=error;;;Const variable {0} is read-only.
-# 0: names of legal built-in symbol
-EXP_INDEXED_ACCESS_SYMBOL_INVALID=error;;;Indexed access with built-in symbols is only allowed for {0}.
-# 0: name of built-in symbol, 1: name of expected receiver type
-EXP_INDEXED_ACCESS_SYMBOL_WRONG_TYPE=error;;;Access of property Symbol.{0} only allowed for instances of {1}, immediate instances of Object, and dynamic types.
-# 0: name of built-in symbol, 1: name of receiver type
-EXP_INDEXED_ACCESS_SYMBOL_READONLY=error;;;Access to property Symbol.{0} of an {1} is read-only.
-# no parameters required
-EXP_INDEXED_ACCESS_ENUM=error;;;Indexed access is not allowed for enumerations.
-# no parameters required
-EXP_INDEXED_ACCESS_FORBIDDEN=error;;;Indexed access is only allowed for strings, arrays and iterables and for immediate(!) instances of Object.
-# 0: index-key in indexed-access
-EXP_INDEXED_ACCESS_COMPUTED_NOTFOUND=error;;;Member {0} not found.
-# no parameters required
-EXP_INDEXED_ACCESS_IMPL_RESTRICTION=error;;;Implementation restriction: member name clashes with compiler-internal, synthetic, mangled name.
-# no parameters required
-EXP_PROMISIFY_INVALID_USE=error;;;@Promisify may only be applied to a call expression with a @Promisifiable function or method as target.
-# no parameters required
-EXP_COMPUTED_PROP_NAME_DISCOURAGED=warning;;;Computed property name using an expression other than a compile-time expression; this property won't be type-checked at compile time.
-# 0: detailed message
-EXP_COMPILE_TIME_MANDATORY=error;;;Not a compile-time expression: {0}.
-
-# 0: usage type ('invoke' or 'instantiate'), 1: name of interface with call/construct signature, 2: signature kind ('call' or 'construct')
-EXP_CALL_CONSTRUCT_SIG_OF_INTERFACE_DIRECTLY_USED=error;;;Cannot directly {0} interface {1}; its {2} signature applies to values of type {1}, not to {1} itself.
-
-
-# 0: type names, submessage -- full message is a concatenation of these messages
-COMP_SUBMESSAGES=error;;;{1} in {0}.
-
-# 0: member name
-UNI_UNCOMMON=error;;;Member {0} not present in all types of union or incompatible.
-# 0: member name, 1: list of types in union that do not contain a member of that name
-UNI_MISSING=error;;;Member {0} not present in all types of union; missing from: {1}.
-# 0: either "getters" or "setters", 1: member name, 2: either "read-only" or "write-only"
-UNI_INVALID_COMBINATION=error;;;Union combines fields and {0} with name {1} and therefore property {1} is {2}.
-# 0: member name
-UNI_INVALID_COMBINATION_SETTER_VS_READ_ONLY_FIELD=error;;;Union combines fields and setters with name {0} but still write-access is not allowed because one or more fields are read-only (const or @Final).
-# 0: member name, 1: list of kinds
-UNI_MULTIPLE_KINDS=error;;;Member {0} not of same kind in all types of union: {1}.
-# 0: member name, 1: list of types
-UNI_DIFFERENT_TYPES=error;;;Member {0} not of same type in all types of union: {1}.
-# no parameters required
-UNI_ANY_USED=warning;;;The use of the any type in a union type is discouraged.
-# no parameters required
-UNI_REDUNDANT_SUBTYPE=warning;;;The use of redundant subtypes is discouraged.
-
-
-# no parameters required
-INTER_ANY_USED=warning;;;The use of the any type in an intersection type is discouraged.
-# no parameters required
-INTER_ONLY_ONE_CLASS_ALLOWED=warning;;;An intersection type should not contain more than one class. Otherwise there cannot exist a value of such a type.
-# no parameters required
-INTER_TYEPARGS_ONLY_ONE_CLASS_ALLOWED=warning;;;Type arguments for the same covariant type parameter in an intersection type should not contain more than one class. Otherwise there cannot exist a value of such a type.
-# no parameters required
-INTER_WITH_ONE_GENERIC=warning;;;An intersection type should not contain different type arguments for the same invariant type parameter. Otherwise is can be instantiated only with undefined.
-# no parameters required
-INTER_REDUNDANT_SUPERTYPE=warning;;;The use of redundant supertypes is discouraged.
-# 0: method member name, 1: list of kinds
-INTER_MEMBER_TYPE_CONFLICT=error;;;Member method {0} is in conflict with non-method members in types of intersection: {1}.
-# 0: member name
-INTER_UNCOMMON=error;;;Member {0} is incompatible in types of intersection.
-
-# no parameters required
-ANN__N4JS_NO_EFFECT=warning;;;This annotation is deprecated and has no effect.
-# no parameters required
-ANN__ONLY_IN_N4JS=error;;;Annotations are a N4JS feature and cannot be used in JS mode.
-# 0: annotation name
-ANN_NOT_DEFINED=error;;;The annotation @{0} is not defined.
-# 0: annotation name, 1: expected number of arguments, 2: actual number of arguments
-ANN_WRONG_NUMBER_OF_ARGUMENTS=error;;;Wrong number of annotation arguments: @{0} expects {1} but got {2}.
-# 0: annotation name, 1: expected type
-ANN_WRONG_ARGUMENT_TYPE=error;;;The annotation @{0} expects a {1} here.
-# 0: annotation name
-ANN_DISALLOWED_AT_LOCATION=error;;;The annotation @{0} is disallowed for this location.
-# 0: annotation name, 1: list of language variants
-ANN_ONLY_ALLOWED_LOCATION_CONSTRUCTORS=error;;;The annotation @{0} may only be applied at a parameter of a constructor.
-# 0: name of annotation (without @)
-ANN_NON_REPEATABLE=error;;;Duplicate annotation of non-repeatable type @{0}.
-# 0: name of annotation
-ANN_UNNECESSARY=warning;;;Unnecessary @{0}.
-# no parameters required
-ANN_THIS_DISALLOWED_ON_STATIC_MEMBER_OF_INTERFACE=error;;;@This annotation not allowed on static members of interfaces.
-# 0: member description, 1: description of containing type, 2: required type
-ANN_THIS_NOT_SUBTYPE_OF_CONTAINING_TYPE=error;;;Declared @This type of {0} in {1} must be a subtype of {2}.
-# no parameters required
-ANN_POLY_STATIC_POLY_ONLY_IN_POLYFILL_MODULE=error;;;The annotation StaticPolyfill is only allowed in modules annotated as StaticPolyfillModule.
-# no parameters required
-ANN_POLY_AWARE_AND_MODULE_MUTUAL_EXCLUSIVE=error;;;A module cannot be annotated as filler and filling at the same time.
-# no parameters required
-ANN_PROMISIFIABLE_MISSING_CALLBACK=error;;;The annotation @Promisifiable is only allowed on functions/methods that take a function as a last argument (i.e. the callback).
-# no parameters required
-ANN_PROMISIFIABLE_BAD_CALLBACK_MORE_THAN_ONE_ERROR=error;;;The callback of a @Promisifiable function/method must not have more than one parameter of type Error.
-# no parameters required
-ANN_PROMISIFIABLE_BAD_CALLBACK_ERROR_NOT_FIRST_ARG=error;;;If the callback of a @Promisifiable function/method has a parameter of type Error, this parameter must be the first parameter.
-
-# 0: annotation name
-ANN_DISALLOWED_IN_NONDEFINTION_FILE=error;;;The annotation @{0} can only be applied in definition files.
-# 0: annotation name
-ANN_DISALLOWED_IN_NON_RUNTIME_COMPONENT=error;;;The annotation @{0} can only be applied in a runtime component.
-# 0: bug id
-ANN_UNUSED_IDEBUG=error;;;No matching error found, apparently bug IDEBUG-{0} has been fixed or does not occur here.
-# 0: name of the violating annotation.
-ANN_REQUIRES_TEST=error;;;Only methods annotated with @Test could be annotated with {0}.
-# 0: annotation name, 1: list of language variants
-ANN_ONL_ALLOWED_IN_VARIANTS=error;;;The annotation @{0} may only be applied in {1} files.
-# 0: annotation name, 1: list of language variants
-ANN_ONL_ALLOWED_AT_CLASSES_IN_N4JSD=error;;;The annotation @{0} may only be applied at classes in n4jsd files.
-# 0: annotation name, 1: list of language variants
-ANN_DISALLOWED_ON_SHAPES=error;;;Only nominal interfaces can be annotated with @{0}.
-
-# 0: annotation name
-ANN__TEST_ONLY_IN_TEST_SOURCES=warning;;;Test annotation @{0} may only be used in test source folders (defined in package.json).
-
-# 0: library name, 1: String of concatenated polyfilled things.
-POLY_ERROR_IN_RUNTIMEDEPENDENCY=error;;;Erroneous library {0} provides contradicting polyfills for {1}.
-# 0: String of concatenated library names, 1: String of concatenated polyfilled things.
-POLY_CLASH_IN_RUNTIMEDEPENDENCY=error;;;The libraries {0} provide polyfills for the same element {1} and cannot be used together.
-# 0: String of concatenated library names, 1: String of concatenated polyfilled things.
-POLY_CLASH_IN_RUNTIMEDEPENDENCY_MULTI=error;;;The libraries {0} provide polyfills for the same elements {1} and cannot be used together.
-# 0: String of conflicting static-polyfilling modules.
-POLY_CLASH_IN_STATIC_POLYFILL_MODULE=error;;;Only one module annotated with @@StaticPolyfillModule is allowed per project. Conflicting with {0}.
-# no param
-POLY_STATIC_POLYFILL_MODULE_ONLY_FILLING_CLASSES=error;;;Only top-level classes annotated as StaticPolyfill are allowed in a module annotated with StaticPolyfillModule.
-# no param
-POLY_IMPLEMENTING_INTERFACE_NOT_ALLOWED=error;;;The filling class cannot introduce additional interfaces; all interfaces must be declared on the filled class.
-
-# doc: detected dependency cycle 0:String describing the cycle.
-PROJECT_DEPENDENCY_CYCLE=error;;;Dependency cycle of the projects: {0}.
-# 0: ID of the non-existing project.
-NON_EXISTING_PROJECT=error;;;Project does not exist with project ID: {0}.
-# 0: ID of the non-existing project.
-MISSING_YARN_WORKSPACE=error;;;Project depends on workspace project {0} which is missing in the node_modules folder. Either install project {0} or introduce a yarn workspace of both of the projects.
-# 0: human readable name of the obsolete feature block.
-OBSOLETE_BLOCK=warning;;;Obsolete {0} block.
-# 0: project project ID, 1: human readable name of the project type, 2: human readable name of the feature.
-INVALID_PROJECT_TYPE_REF=warning;;;Project {0} of type {1} cannot be declared among the {2}.
-# 0: library project ID
-INVALID_API_PROJECT_DEPENDENCY=warning;;;Library project {0} with an implementation ID cannot be declared among the dependencies of an API project.
-# 0: violating feature/block name, 1: actual project type name
-INVALID_FEATURE_FOR_PROJECT_TYPE=warning;;;{0} cannot be specified for {1} projects.
-# 0: name used in duplicate
-DUPLICATE_PROJECT_REF=error;;;Duplicate project reference {0}.
-# 0: name of the containing folder, 1: name of the nested folder
-OUTPUT_AND_SOURCES_FOLDER_NESTING=error;;;{0} must not be located inside {1}.
-# no parameters required
-PROJECT_REFERENCES_ITSELF=error;;;Project cannot reference itself.
-# 0: the type of the deprecated project 1: alternatives
-DEPRECATED_PROJECT_TYPE=warning;;;Project type ''{0}'' is deprecated and will be removed soon. {1}
-# no parameters are required.
-MISMATCHING_TESTED_PROJECT_TYPES=warning;;;Tested projects should have the same project type.
-# 0: current project implementation ID, 1: the violating project's ID, 2: the implementation ID of the violating project
-MISMATCHING_IMPLEMENTATION_ID=warning;;;Implementation ID mismatch. Current project belongs to ''{0}'' implementation while {1} project belongs to ''{2}'' implementation.
-# 0: test library name
-SRCTEST_NO_TESTLIB_DEP=error;;;Project with source folder of type test should depend on {0}.
-# 0: ID of the violating transitive external project dependency, 1: ID of the workspace project that is required by an external one.
-EXTERNAL_PROJECT_REFERENCES_WORKSPACE_PROJECT=warning;;;Transitive external project dependency of project ''{0}'' requires a workspace project ''{1}''. Current project setup could result in runtime oddities. It is highly recommended to import project ''{0}'' into workspace as well.
-# 0: project type of containing project
-INVALID_FILE_TYPE_FOR_PROJECT_TYPE=error;;;An n4js file may not be contained in a project of type ''{0}''.
-# 0: resource name
-NO_PROJECT_FOUND=warning;;;No project found for resource {0}.
-# 0: part of the specifier that contains a dot, 1: the module specifier
-MOD_NAME_MUST_NOT_CONTAIN_DOTS=error;;;{0} of this module contain(s) the disallowed character ''.'' : ''{1}''.
-# 0: dependency name, 1: required version, 2: present version
-NO_MATCHING_VERSION=warning;;;Project {0} is required in version {1}, but only version {2} is present.
-# doc: checks if the module specifier wildcard can be resolved to an existing resource (not applied for implementation provided by runtime), spec: Component/Manifest/ModuleSpecifier-Constraint, 0: the module specifier
-NON_EXISTING_MODULE_SPECIFIER=warning;;;Module specifier {0} doesn't exist.
-# doc: checks for invalid wildcards, spec: Component/Manifest/ModuleSpecifierWildcardConstraints, 0: the invalid part of the wild card
-INVALID_WILDCARD=error;;;"{0}" isn't a valid character sequence in a wild card.
-# doc: disallow relative navigation, spec: Component/Manifest/ModuleSpecifierWildcardConstraints, no parameters required
-NO_RELATIVE_NAVIGATION=error;;;Relative navigation isn't allowed in a module specifier.
-# doc: disallow switching off semantic validation for n4js files, spec: Component/Manifest/ModuleSpecifier-Constraint, 0: module filter type (e.g. noValidate)
-DISALLOWED_NO_VALIDATE_FOR_N4JS=error;;;{0} paths shouldn't match n4js files.
-
-# 0: sub description, 1: extend/implement, 2: super description, 3: implements/extends
-SYN_KW_EXTENDS_IMPLEMENTS_MIXED_UP=error;;;The {0} cannot {1} {2}, use "{3}".
-# no parameters required
-SYN_KW_EXTENDS_IMPLEMENTS_WRONG_ORDER=error;;;Extended class must be declared before implemented interfaces.
-# 0: class description, 1: keyword, 2: super description
-CLF_WRONG_META_TYPE=error;;;The {0} cannot {1} {2}.
-# 0: modifier name, 1: type of element that may not have this modifier (e.g. 'class', 'interface', etc.)
-SYN_MODIFIER_INVALID=error;;;Modifier {0} is not allowed on a {1}.
-# 0: modifier name
-SYN_MODIFIER_DUPLICATE=error;;;Duplicate modifier {0}.
-# no parameters required
-SYN_MODIFIER_ACCESS_SEVERAL=error;;;Only a single access modifier may be provided.
-# 0: modifiers in correct order
-SYN_MODIFIER_BAD_ORDER=error;;;Modifiers should appear in this order: {0}.
-# 0: element {modifier|keyword}, 1: name of modifier or keyword element (e.g. public)
-SYN_UNNECESSARY_ELEMENT=warning;;;Unnecessary {0} {1}.
-# no parameters required
-EXP_ONLY_TOP_LEVEL_ELEMENTS=error;;;Only top level elements can be exported.
-# 0: element kind, 1: element name
-EXP_PRIVATE_ELEMENT=error;;;Private {0} {1} cannot be exported.
-
-# no parameters required
-DESTRUCT_EMPTY_PATTERN=error;;;Empty destructuring pattern (disallowed for time being, since ES6 implementations have different semantics).
-# 0: name of missing property, 1: type of value to be destructured
-DESTRUCT_PROP_MISSING=error;;;Value to be destructured does not contain a property, field or getter named "{0}": {1}.
-# 0: name of property that returned AbstractDescriptionWithError, 1: error message
-DESTRUCT_PROP_WITH_ERROR=error;;;Property named "{0}" is not readable: {1}.
-# 0: name of variable, 1: "at index N" or "of property NAME", 2: error message from type system (must not end in a dot!)
-DESTRUCT_TYPE_ERROR_VAR=error;;;Variable {0} cannot hold destructured value {1}: {2}.
-# 0: kind of destructuring pattern ("Array" or "Object" or "Nested array" or "Nested object"), 1: "destructured value at index N" or "destructured value of property NAME", 2: error message from type system (must not end in a dot!)
-DESTRUCT_TYPE_ERROR_PATTERN=error;;;{0} destructuring pattern cannot be applied to {1}: {2}.
-
-### Dependency Injection
-# 0: type name, 1: additional description identifying the place of the violating context (name of the member/parameter)
-DI_NOT_INJECTABLE=error;;;Type {0} is not injectable{1}: only user-defined, non-generic, nominally typed interfaces and classes are allowed.
-# no parameters are required
-DI_VARARGS_NOT_INJECTABLE=error;;;Injection of parameters that are variadic or optional is not supported.
-# 0: type name
-DI_MUST_BE_INJECTED=warning;;;Type {0} must be injected, because it contains or inherits one or more members annotated with @Inject.
-# 0: annotation name, 1: name of required annotation on containing class
-DI_ANN_ONLY_ON_CLASS_ANNOTATED_WITH=error;;;The annotation @{0} is only allowed on classes annotated with @{1}.
-# 0: annotation name, 1: name of required annotation on containing class
-DI_ANN_ONLY_ON_METHOD_IN_CLASS_ANNOTATED_WITH=error;;;The annotation @{0} is only allowed on methods contained in a class annotated with @{1}.
-# 0: annotation name, 1: name of required annotation on argument class
-DI_ANN_ARG_MUST_BE_ANNOTATED_WITH=error;;;Argument to annotation @{0} must be a class annotated with @{1}.
-# 0: the name of the violating annotation.
-DI_ANN_BIND_SECOND_MUST_BE_SUBTYPE_FIRST=error;;;Second argument to @{0} must be a subtype of the first.
-# no parameters required
-DI_ANN_PROVIDES_METHOD_MUST_RETURN_VALUE=error;;;A provider method must return a value.
-# no parameters required
-DI_ANN_INTERFACE_INJECTION_NOT_SUPPORTED=error;;;Injection inside interfaces is not supported.
-# no parameters required
-DI_ANN_INJECTOR_EXTENDS=error;;;Classes annotated with @GenerateInjector cannot extend other class.
-# 0: the binded type name
-DI_ANN_BIND_SINGLETON_TARGET_SHOULD_BE_DEFINED_AS_SINGLETON=error;;;{0} can be defined as a singleton if it is annotated with @Singleton on the definition site.
-# no parameters required
-DI_ANN_INJECTOR_CANNOT_BE_INJECTED_INTO_INJECTOR=error;;;Types annotated with @GenerateInjector cannot be injected. Use @WithParentInjector instead for creating nested injectors.
-# 0: the cyclic graph as a string
-DI_ANN_USE_INJECTOR_CYCLE=error;;;A cycle was detected among the parent injectors: {0}.
-# 0: the name of the unavailable field
-DI_FIELD_IS_NOT_INJECTED_YET=error;;;{0} is not yet injected at this point.
-# 0: super class type name, 1: violating type name
-DI_CTOR_BREAKS_INJECTION_CHAIN=warning;;;Constructor at super class {0} is annotated with @Inject. Omitting the @Inject annotation from constructor at class {1} could break injection chain.
-# no parameters required
-DI_ANN_BINDER_NOT_APPLICABLE=error;;;Annotation @Binder is applicable only for (exported) non-abstract class definitions.
-# no parameters required
-DI_ANN_BINDER_AND_INJECTOR_DONT_GO_TOGETHER=error;;;Annotations @Binder and @GenerateInjector may not be applied both on the same class definition.
-# no parameters required
-DI_ANN_DUPLICATE_BINDING=error;;;Duplicate @Binding-s (two different bindings share the same key, for the same @Binder).
-# no parameters required
-DI_ANN_BIND_ABSTRACT_TARGET=error;;;The target of a @Binding must be a non-abstract class.
-# no parameters required
-DI_ANN_INJECT_METHOD_NOT_SUPPORTED_YET=error;;;Method injection not supported yet.
-# no parameters required
-DI_ANN_BINDER_EXTENDS=error;;;Classes annotated with @Binder may not extend another class.
-# no parameters required
-DI_ANN_INJECTOR_CTOR_MUST_BE_INJECT=error;;;The constructor of an injector must itself be injected unless it declares no parameters.
-# no parameters required
-DI_ANN_INJECTOR_REQUIRED=error;;;Only types annotated with @GenerateInjector can be used here.
-# 0: list of missing binders (as a list of type names)
-DI_ANN_MISSING_PROVIDED_BINDERS=error;;;No binders are provided (third param for this callsite). The following binders are used by the injector and themselves require injection: {0}.
-# no parameters required
-DI_ANN_INJECTOR_MISSING=error;;;An instance of N4Injector is required here.
-# 0: list of missing binders (as a list of type names)
-DI_ANN_MISSING_NEEDED_BINDERS=error;;;Instances are missing for the following binders (they are used by the injector and themselves require injection): {0}.
-# no parameters required
-DI_API_INJECTED=error;;;The class being instantiated (or one of its super-types) has been marked @Injected in an API project.
-# no parameters required
-DI_ANN_INJECTED_NOT_APPLICABLE=error;;;@Injected annotates a class (abstract or not) defined in an API project.
-
-
-### JSX
-# 0: name of opening JSX element, 1: name of closing JSX element
-JSX_JSXELEMENT_OPENING_CLOSING_ELEMENT_NOT_MATCH=error;;;Opening element {0} does not match with closing element {1}.
-# 0: name of the type JSX element is binding to
-JSX_REACT_ELEMENT_NOT_FUNCTION_OR_CLASS_ERROR=error;;;JSX element is expected to bind to either a function or class, but bind to type {0} instead.
-# No parameter
-JSX_REACT_ELEMENT_CLASS_MUST_NOT_BE_ABSTRACT=error;;;JSX element class must not be abstract.
-# 0: name of the return type of the function that JSX element is binding to
-JSX_REACT_ELEMENT_FUNCTION_NOT_REACT_ELEMENT_ERROR=error;;;Expecting a function returning a value of type {0} but the return type is {1}.
-# no argument
-JSX_REACT_ELEMENT_CLASS_NOT_REACT_ELEMENT_ERROR=error;;;The referred class is not a subtype of React.Component
-# 0: name of the function that JSX element is binding to
-JSX_REACT_FUNCTIONAL_COMPONENT_CANNOT_START_WITH_LOWER_CASE=error;;;React functional component {0} cannot start with lower case.
-# 0: name of the class that JSX element is binding to
-JSX_REACT_CLASS_COMPONENT_CANNOT_START_WITH_LOWER_CASE=error;;;React class component {0} cannot start with lower case.
-# 0: name of JSX element is binding to
-JSX_JSXELEMENT_NOT_BIND_TO_REACT_COMPONENT=error;;;JSX element {0} does not bind to any valid React component.
-# 0: name of JSX element is binding to
-JSX_TAG_UNKNOWN=warning;;;Tag {0} is neither a known HTML tag nor an SVG tag.
-# 0: name of JSX property
-JSX_JSXPROPERTY_ATTRIBUTE_NON_OPTIONAL_PROPERTY_NOT_SPECIFIED=error;;;Non-optional property {0} should be specified.
-# 0: The name of attribute in spread operator, 1: type of the attribute, 2: the declared type of the corresponding property in "props"
-JSX_JSXSPREADATTRIBUTE_WRONG_SUBTYPE=error;;;Attribute {0} has wrong type because {1} not subtype of {2}.
-# 0: The name of attribute in spread operator, 1: name of JSX element
-JSX_JSXSPREADATTRIBUTE_NOT_DECLARED_IN_PROPS=warning;;;Attribute {0} is not a declared property in the props of {1}.
-# 0: The name of attribute in JSX property, 1: name of JSX element
-JSX_JSXSPROPERTYATTRIBUTE_NOT_DECLARED_IN_PROPS=warning;;;Attribute {0} is not a declared property in the props of {1}.
-# 0: JSX element in non-JSX file
-JSX_JSXELEMENT_IN_NON_JSX_RESOURCE=error;;;JSX element is expected to be placed in JSX like resource, was {0}.
-# No parameter
-JSX_REACT_NAMESPACE_NOT_ALLOWED=error;;;Namespace to react must be React.
-# No parameter
-JSX_REACT_NOT_RESOLVED=error;;;Cannot resolve JSX implementation.
-# No parameter
-JSX_NAME_CANNOT_BE_REACT=error;;;Element cannot be named React in N4JSX file.
-
-
-### THIRD PARTY
-# no parameters required
-THIRD_PARTY_BABEL_LET_CONST_IN_FUN_EXPR=warning;;;This code is prone to Babel bug #6302. If you use Babel in your build pipeline, you should rename this let/const or the containing function expression.
-
-
-### N4JS package.json
-# no parameters
-PKGJ_MISSING_DEPENDENCY_N4JS_RUNTIME=error;;;Missing dependency to 'n4js-runtime' (mandatory for all N4JS projects of type library, application, test).
-# no parameters
-PKGJ_WRONG_DEPENDENCY_N4JS_RUNTIME=error;;;Dependency to 'n4js-runtime' should be defined below key "dependencies", not "devDependencies".
-# 0: The package name without scope, as declared in the package.json, 1: project folder name
-PKGJ_PACKAGE_NAME_MISMATCH=warning;;;As a convention the package name "{0}" should match the name of the project folder "{1}" on the file system.
-# 0: The scope name, as declared in the package.json, 1: parent folder name
-PKGJ_SCOPE_NAME_MISMATCH=warning;;;As a convention the scope name "{0}" should match the name of the project folder's parent folder "{1}" on the file system.
-# 0: The project name without scope
-PKGJ_INVALID_PROJECT_NAME=error;;;The name "{0}" is not a valid package name.
-# 0: The scope name
-PKGJ_INVALID_SCOPE_NAME=error;;;The name "{0}" is not a valid scope name.
-# 0: Invalid source container type name
-PKGJ_INVALID_SOURCE_CONTAINER_TYPE=error;;;Invalid source container type "{0}".
-# 0: the non-existing path
-PKGJ_NON_EXISTING_PATH=error;;;Path {0} does not exist.
-# no parameters
-PKGJ_EMPTY_SOURCE_PATH=error;;;Source container paths must not be empty.
-# 0: the non-existing source container path
-PKGJ_NON_EXISTING_SOURCE_PATH=warning;;;Source container path {0} does not exist.
-# 0: the path 1: 'in'-clause with leading space (e.g. " in external, test")
-PKGJ_DUPLICATE_SOURCE_CONTAINER=warning;;;Duplicate path "{0}" has already been declared as source container{1}.
-# 0: the container source path
-PKGJ_NESTED_SOURCE_CONTAINER=error;;;A source container must not be nested within other source containers (nested in {0})
-# no parameters
-PKGJ_NO_OUTPUT_FOLDER=error;;;There is no output folder defined, so compilation isn't possible.
-# 0: the invalid path
-PKGJ_INVALID_PATH=error;;;"{0}" is not a valid path.
-# 0: the absolute path
-PKGJ_INVALID_ABSOLUTE_PATH=error;;;Path "{0}" must not be absolute.
-# 0: the non-directory path
-PKGJ_EXPECTED_DIRECTORY_PATH=error;;;Path "{0}" does not point to a directory.
-# 0: the non-existing main module specifier
-PKGJ_NON_EXISTING_MAIN_MODULE=error;;;Main module specifier {0} does not exist.
-# 0: invalid module filter type, 1: all valid module filter types
-PKGJ_INVALID_MODULE_FILTER_TYPE=error;;;Invalid module filter type "{0}". Valid filter types are {1}.
-# 0: invalid module specifier
-PKGJ_INVALID_MODULE_FILTER_SPECIFIER=error;;;Invalid module specifier. Use simple strings or object syntax instead.
-# no parameters
-PKGJ_INVALID_MODULE_FILTER_SPECIFIER_EMPTY=error;;;The filter specifier and declared source container must not be empty.
-# no parameters
-PKGJ_DUPLICATE_MODULE_FILTER_SPECIFIER=error;;;Duplicate module filter specifier.
-# no parameters
-PKGJ_SRC_IN_FILTER_IS_NO_DECLARED_SOURCE=error;;;The given source container "{0}" has not been declared as source container.
-# 0: the invalid part of a wildcard
-PKGJ_INVALID_WILDCARD=error;;;"{0}" is not a valid character sequence in a wildcard.
-# no parameters
-PKGJ_NO_RELATIVE_NAVIGATION=error;;;Relative navigation is not allowed in a module filter specifier.
-# 0: the module filter specifier
-PKGJ_MODULE_FILTER_DOES_NOT_MATCH=warning;;;Module filter "{0}" does not match any modules.
-# 0: module filter type (e.g. noValidate)
-PKGJ_FILTER_NO_N4JS_MATCH=error;;;Module filters of type {0} must not match N4JS modules/files.
-# no parameters
-PKGJ_APIIMPL_MISSING_IMPL_PROJECTS=error;;;When defining an implementation ID, you also have to define one or more API projects that are implemented by this project using property 'n4js.implementedProjects'.
-# no parameters
-PKGJ_APIIMPL_REFLEXIVE=error;;;An implementation project may not implement itself.
-# no parameters required
-PKGJ_APIIMPL_MISSING_IMPL_ID=error;;;When defining one or more implemented projects, you also have to define an implementation ID, using property "implementationId".
-# 0: invalid project type
-PKGJ_INVALID_PROJECT_TYPE=error;;;Invalid project type "{0}".
-# 0: project id 1: section label (e.g. required runtime libraries)
-PKGJ_PROJECT_REFERENCE_MUST_BE_DEPENDENCY=error;;;The project reference {0} in {1} must also be declared as explicit project dependency in 'dependencies' or 'devDependencies'.
-# 0: message
-PKGJ_SEMVER_ERROR=error;;;{0}
-# 0: message
-PKGJ_SEMVER_WARNING=warning;;;{0}
-# 0: version number string representation, 1: reason
-PKGJ_INVALID_VERSION_NUMBER=error;;;Invalid version number "{0}": {1}.
-# 0: version constraint string representation, 1: reason
-PKGJ_INVALID_VERSION_REQUIREMENT=warning;;;Invalid version requirement "{0}": {1}. Will assume empty string.
-# 0: project type
-PKGJ_PROJECT_TYPE_MANDATORY_OUTPUT_AND_SOURCES=error;;;Projects of type {0} must always declare an output folder and at least one source container.
-# no parameters
-PKGJ_EMPTY_PROJECT_REFERENCE=error;;;A project reference must not be empty.
-# no parameters
-PKGJ_EMPTY_INIT_MODULE=error;;;An init module specifier must not be empty.
-# 0: project type, 1: empty or 'not ', 2: property name
-PKGJ_DEFINES_PROPERTY=error;;;A project of type "{0}" must {1}define the property "{2}".
-# 0: property name
-PKGJ_PROPERTY_UNKNOWN=warning;;;Property "{0}" is unknown.
-# 0: implementation project name, 1: type definition project name
-PKGJ_IMPL_PROJECT_IS_MISSING_FOR_TYPE_DEF=warning;;;The implementation project {0} of type definition project {1} is missing from the dependencies section.
-# 0: "Source" or "Output code"
-PKGJ_REWRITE_MODULE_SPECIFIERS__EMPTY_SPECIFIER=error;;;{0} module specifier must not be empty.
-# no parameters
-PKGJ_REWRITE_MODULE_SPECIFIERS__INVALID_VALUE=error;;;String expected (i.e. the module specifier to use in the output code).
-
-# no parameters
-LTD_ILLEGAL_LOADTIME_REFERENCE=error;;;Load-time references to the same or other modules are not allowed within a runtime dependency cycle (except in extends/implements clauses).
-# 0: name of load-time dependency target module, 1: comma-separated list of other load-time dependency source modules (including the prefix "modules " or "module ")
-LTD_LOADTIME_DEPENDENCY_CONFLICT=error;;;A load-time dependency target module {0} must only be imported once within the same runtime dependency cycle, but {0} is also imported by {1}.
-# no parameters
-LTD_LOADTIME_DEPENDENCY_CYCLE=error;;;Load-time dependency cycles are disallowed, because successful resolution by Javascript engine cannot be guaranteed.
-# 0: name of load-time dependency target module, 1: modules that could heal this reference (including the prefix "one of the modules " or "module ")
-LTD_REFERENCE_TO_LOADTIME_DEPENDENCY_TARGET=error;;;When importing modules from a runtime cycle, those that are the target of a load-time dependency (marked with * below) may only be imported after first importing one of the others. Thus, import of module {0} must be preceded by an import of {1}.
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/IDEBUGValidator.xtend b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/IDEBUGValidator.xtend
index 772173a02c..58f6c72ce0 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/IDEBUGValidator.xtend
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/IDEBUGValidator.xtend
@@ -10,14 +10,15 @@
*/
package org.eclipse.n4js.validation.validators
+import java.util.Collection
+import java.util.HashSet
+import java.util.Map
import org.eclipse.n4js.AnnotationDefinition
import org.eclipse.n4js.n4JS.Annotation
+import org.eclipse.n4js.utils.validation.PostValidation
import org.eclipse.n4js.validation.AbstractMessageAdjustingN4JSValidator
import org.eclipse.n4js.validation.AbstractN4JSDeclarativeValidator
-import org.eclipse.n4js.utils.validation.PostValidation
-import java.util.Collection
-import java.util.HashSet
-import java.util.Map
+import org.eclipse.n4js.validation.IssueItem
import org.eclipse.xtext.validation.Check
import org.eclipse.xtext.validation.EValidatorRegistrar
@@ -78,7 +79,8 @@ class IDEBUGValidator extends AbstractMessageAdjustingN4JSValidator {
for (Annotation a: definedAnnotations.filter[!usedAnnotations.contains(it)]) {
if (!a.args.isEmpty) {
val bugID = a.args.get(0).valueAsString;
- addIssue(getMessageForANN_UNUSED_IDEBUG(bugID), a, ANN_UNUSED_IDEBUG);
+ val IssueItem issueItem = ANN_UNUSED_IDEBUG.toIssueItem(bugID);
+ addIssue(issueItem.message, a, issueItem.getID());
}
}
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSAccessModifierValidator.xtend b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSAccessModifierValidator.xtend
index 25c5b8d994..07ae6af2c9 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSAccessModifierValidator.xtend
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSAccessModifierValidator.xtend
@@ -24,8 +24,11 @@ import org.eclipse.n4js.n4JS.ModifierUtils
import org.eclipse.n4js.n4JS.N4ClassifierDefinition
import org.eclipse.n4js.n4JS.N4FieldDeclaration
import org.eclipse.n4js.n4JS.N4GetterDeclaration
+import org.eclipse.n4js.n4JS.N4InterfaceDeclaration
import org.eclipse.n4js.n4JS.N4JSPackage
+import org.eclipse.n4js.n4JS.N4MemberDeclaration
import org.eclipse.n4js.n4JS.N4MethodDeclaration
+import org.eclipse.n4js.n4JS.N4Modifier
import org.eclipse.n4js.n4JS.NamespaceExportSpecifier
import org.eclipse.n4js.n4JS.NamespaceImportSpecifier
import org.eclipse.n4js.n4JS.ObjectLiteral
@@ -53,6 +56,7 @@ import org.eclipse.n4js.utils.ContainerTypesHelper
import org.eclipse.n4js.utils.StaticPolyfillHelper
import org.eclipse.n4js.utils.StructuralTypesHelper
import org.eclipse.n4js.validation.AbstractN4JSDeclarativeValidator
+import org.eclipse.n4js.validation.IssueItem
import org.eclipse.n4js.validation.JavaScriptVariantHelper
import org.eclipse.xtext.nodemodel.ILeafNode
import org.eclipse.xtext.nodemodel.util.NodeModelUtils
@@ -62,9 +66,6 @@ import org.eclipse.xtext.validation.EValidatorRegistrar
import static org.eclipse.n4js.validation.IssueCodes.*
import static extension org.eclipse.n4js.typesystem.utils.RuleEnvironmentExtensions.*
-import org.eclipse.n4js.n4JS.N4MemberDeclaration
-import org.eclipse.n4js.n4JS.N4InterfaceDeclaration
-import org.eclipse.n4js.n4JS.N4Modifier
/**
*/
@@ -131,13 +132,13 @@ class N4JSAccessModifierValidator extends AbstractN4JSDeclarativeValidator {
// NOTE: we are using issue code UNSUPPORTED here, because the only reason for disallowing a visibility higher than
// private on non-exported types is that it is required/useful only with separate export declarations and such export
// declarations are UNSUPPORTED in N4JS(D) at the moment.
- val message = getMessageForUNSUPPORTED("non-exported " + tElem.keyword + " with a visibility higher than private");
+ val issueItem = UNSUPPORTED.toIssueItem("non-exported " + tElem.keyword + " with a visibility higher than private");
val node = findModifierNode(astNode, tElem.typeAccessModifier);
if (node !== null) {
- addIssue(message, astNode, node.getOffset(), node.getLength(), UNSUPPORTED);
+ addIssue(astNode, node.getOffset(), node.getLength(), issueItem);
} else {
val eObjectToNameFeature = findNameFeature(astNode);
- addIssue(message, eObjectToNameFeature.key, eObjectToNameFeature.value, UNSUPPORTED)
+ addIssue(eObjectToNameFeature.key, eObjectToNameFeature.value, issueItem)
}
}
}
@@ -168,8 +169,8 @@ class N4JSAccessModifierValidator extends AbstractN4JSDeclarativeValidator {
if (exportedElement instanceof AccessibleTypeElement) {
val tam = exportedElement.typeAccessModifier;
if (!(tam.ordinal > TypeAccessModifier.PRIVATE.ordinal)) {
- val msg = getMessageForEXP_PRIVATE_ELEMENT(exportedElement.keyword, exportedElement.name);
- addIssue(msg, idRef, EXP_PRIVATE_ELEMENT);
+ val IssueItem issueItem = EXP_PRIVATE_ELEMENT.toIssueItem(exportedElement.keyword, exportedElement.name);
+ addIssue(idRef, issueItem);
}
}
}
@@ -199,10 +200,10 @@ class N4JSAccessModifierValidator extends AbstractN4JSDeclarativeValidator {
null
}
if (typeAccessModifier !== null && typeAccessModifier.ordinal <= TypeAccessModifier.PROJECT.ordinal) {
- val message = getMessageForCLF_LOW_ACCESSOR_WITH_INTERNAL(exportableElement.keyword,
+ val IssueItem issueItem = CLF_LOW_ACCESSOR_WITH_INTERNAL.toIssueItem(exportableElement.keyword,
typeAccessModifier.keyword)
val eObjectToNameFeature = exportableElement.findNameFeature
- addIssue(message, eObjectToNameFeature.key, eObjectToNameFeature.value, CLF_LOW_ACCESSOR_WITH_INTERNAL)
+ addIssue(eObjectToNameFeature.key, eObjectToNameFeature.value, issueItem)
}
}
}
@@ -222,16 +223,14 @@ class N4JSAccessModifierValidator extends AbstractN4JSDeclarativeValidator {
if(parent instanceof TFormalParameter) {
return; // avoid duplicate error messages
} else if(parent instanceof N4FieldDeclaration || parent instanceof TField) {
- val message = messageForCLF_FIELD_OPTIONAL_OLD_SYNTAX;
val node = NodeModelUtils.findActualNodeFor(typeRefInAST)
if (node !== null) {
- addIssue(message, typeRefInAST, node.offset, node.length, CLF_FIELD_OPTIONAL_OLD_SYNTAX)
+ addIssue(typeRefInAST, node.offset, node.length, CLF_FIELD_OPTIONAL_OLD_SYNTAX.toIssueItem())
}
} else {
- val message = messageForEXP_OPTIONAL_INVALID_PLACE;
val node = NodeModelUtils.findActualNodeFor(typeRefInAST)
if (node !== null) {
- addIssue(message, typeRefInAST, node.offset, node.length, EXP_OPTIONAL_INVALID_PLACE)
+ addIssue(typeRefInAST, node.offset, node.length, EXP_OPTIONAL_INVALID_PLACE.toIssueItem())
}
}
}
@@ -254,22 +253,18 @@ class N4JSAccessModifierValidator extends AbstractN4JSDeclarativeValidator {
&& !n4member.declaredModifiers.contains(N4Modifier.PRIVATE) // see: CLF_MINIMAL_ACCESSIBILITY_IN_INTERFACES
&& !(n4member.eContainer as N4InterfaceDeclaration).declaredModifiers.contains(N4Modifier.PUBLIC)
) {
- val msg = getMessageForSTRCT_ITF_MEMBER_MUST_BE_PUBLIC;
- addIssue(msg, n4member, N4JSPackage.eINSTANCE.propertyNameOwner_DeclaredName, STRCT_ITF_MEMBER_MUST_BE_PUBLIC);
+ addIssue(n4member, N4JSPackage.eINSTANCE.propertyNameOwner_DeclaredName, STRCT_ITF_MEMBER_MUST_BE_PUBLIC.toIssueItem());
}
}
@Check
def checkFieldConstFinalValidCombinations(N4FieldDeclaration n4field) {
if (n4field.const && n4field.declaredStatic) {
- val msg = getMessageForCLF_FIELD_CONST_STATIC;
- addIssue(msg, n4field, N4JSPackage.eINSTANCE.propertyNameOwner_DeclaredName, CLF_FIELD_CONST_STATIC);
+ addIssue(n4field, N4JSPackage.eINSTANCE.propertyNameOwner_DeclaredName, CLF_FIELD_CONST_STATIC.toIssueItem());
} else if (n4field.const && n4field.final) {
- val msg = getMessageForCLF_FIELD_CONST_FINAL;
- addIssue(msg, n4field, N4JSPackage.eINSTANCE.propertyNameOwner_DeclaredName, CLF_FIELD_CONST_FINAL);
+ addIssue(n4field, N4JSPackage.eINSTANCE.propertyNameOwner_DeclaredName, CLF_FIELD_CONST_FINAL.toIssueItem());
} else if (n4field.final && n4field.declaredStatic) {
- val msg = getMessageForCLF_FIELD_FINAL_STATIC;
- addIssue(msg, n4field, N4JSPackage.eINSTANCE.propertyNameOwner_DeclaredName, CLF_FIELD_FINAL_STATIC);
+ addIssue(n4field, N4JSPackage.eINSTANCE.propertyNameOwner_DeclaredName, CLF_FIELD_FINAL_STATIC.toIssueItem());
}
}
@@ -280,8 +275,7 @@ class N4JSAccessModifierValidator extends AbstractN4JSDeclarativeValidator {
}
if (n4field.const && n4field.expression === null) {
- val msg = getMessageForCLF_FIELD_CONST_MISSING_INIT(n4field.name);
- addIssue(msg, n4field, N4JSPackage.eINSTANCE.propertyNameOwner_DeclaredName, CLF_FIELD_CONST_MISSING_INIT);
+ addIssue(n4field, N4JSPackage.eINSTANCE.propertyNameOwner_DeclaredName, CLF_FIELD_CONST_MISSING_INIT.toIssueItem(n4field.name));
}
}
@@ -315,14 +309,12 @@ class N4JSAccessModifierValidator extends AbstractN4JSDeclarativeValidator {
val boolean replacedByPolyfill = n4classifier.ownedCtor !== n4classifier.polyfilledOrOwnCtor;
if (replacedByPolyfill) {
finalFieldsWithoutInit.forEach [
- val msg = getMessageForCLF_FIELD_FINAL_MISSING_INIT_IN_STATIC_POLYFILL(it.name);
- addIssue(msg, it, N4JSPackage.eINSTANCE.propertyNameOwner_DeclaredName,
- CLF_FIELD_FINAL_MISSING_INIT_IN_STATIC_POLYFILL)
+ addIssue(it, N4JSPackage.eINSTANCE.propertyNameOwner_DeclaredName,
+ CLF_FIELD_FINAL_MISSING_INIT_IN_STATIC_POLYFILL.toIssueItem(it.name))
]
} else {
finalFieldsWithoutInit.forEach [
- val msg = getMessageForCLF_FIELD_FINAL_MISSING_INIT(it.name);
- addIssue(msg, it, N4JSPackage.eINSTANCE.propertyNameOwner_DeclaredName, CLF_FIELD_FINAL_MISSING_INIT)
+ addIssue(it, N4JSPackage.eINSTANCE.propertyNameOwner_DeclaredName, CLF_FIELD_FINAL_MISSING_INIT.toIssueItem(it.name))
]
}
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSAnnotationValidator.xtend b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSAnnotationValidator.xtend
index 13340744d7..cebe5fe6a4 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSAnnotationValidator.xtend
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSAnnotationValidator.xtend
@@ -28,6 +28,7 @@ import org.eclipse.n4js.n4JS.FormalParameter
import org.eclipse.n4js.n4JS.FunctionDeclaration
import org.eclipse.n4js.n4JS.FunctionDefinition
import org.eclipse.n4js.n4JS.N4ClassDeclaration
+import org.eclipse.n4js.n4JS.N4InterfaceDeclaration
import org.eclipse.n4js.n4JS.N4MemberDeclaration
import org.eclipse.n4js.n4JS.N4MethodDeclaration
import org.eclipse.n4js.n4JS.Script
@@ -45,7 +46,7 @@ import org.eclipse.n4js.types.utils.TypeUtils
import org.eclipse.n4js.typesystem.N4JSTypeSystem
import org.eclipse.n4js.utils.PromisifyHelper
import org.eclipse.n4js.validation.AbstractN4JSDeclarativeValidator
-import org.eclipse.n4js.validation.IssueCodes
+import org.eclipse.n4js.validation.IssueItem
import org.eclipse.n4js.validation.JavaScriptVariantHelper
import org.eclipse.n4js.workspace.WorkspaceAccess
import org.eclipse.xtext.EcoreUtil2
@@ -60,7 +61,6 @@ import static org.eclipse.n4js.validation.IssueCodes.*
import static extension org.eclipse.n4js.typesystem.utils.RuleEnvironmentExtensions.*
import static extension org.eclipse.n4js.utils.N4JSLanguageUtils.*
-import org.eclipse.n4js.n4JS.N4InterfaceDeclaration
/**
* Annotation validation rules for N4JS.
@@ -102,7 +102,7 @@ class N4JSAnnotationValidator extends AbstractN4JSDeclarativeValidator {
if (!jsVariantHelper.allowAnnotation(annotableElement)) {
// Annotation not allowed in other then N4JS modes:
if (annotableElement.annotations.size > 0) {
- addIssue(messageForANN__ONLY_IN_N4JS, annotableElement, annotableElement.annoFeature, ANN__ONLY_IN_N4JS)
+ addIssue(annotableElement, annotableElement.annoFeature, ANN__ONLY_IN_N4JS.toIssueItem())
}
return
}
@@ -115,7 +115,7 @@ class N4JSAnnotationValidator extends AbstractN4JSDeclarativeValidator {
if (a.name !== null) {
val def = AnnotationDefinition.find(a.name);
if (def === null) {
- addIssue(getMessageForANN_NOT_DEFINED(a.name), a, ANNOTATION__NAME, ANN_NOT_DEFINED);
+ addIssue(a, ANNOTATION__NAME, ANN_NOT_DEFINED.toIssueItem(a.name));
} else {
if (def.repeatable) {
if (foundNames.add(a.name)) {
@@ -125,7 +125,7 @@ class N4JSAnnotationValidator extends AbstractN4JSDeclarativeValidator {
}
} else {
if (! foundNames.add(a.name)) {
- addIssue(getMessageForANN_NON_REPEATABLE(a.name), a, ANNOTATION__NAME, ANN_NON_REPEATABLE);
+ addIssue(a, ANNOTATION__NAME, ANN_NON_REPEATABLE.toIssueItem(a.name));
} else {
internalCheckAnnotation(def, a);
}
@@ -205,7 +205,7 @@ class N4JSAnnotationValidator extends AbstractN4JSDeclarativeValidator {
if (definition.transitive && !definition.repeatable) {
if (definition.hasAnnotation(
EcoreUtil2.getContainerOfType(annotation.annotatedElement.eContainer, AnnotableElement))) {
- addIssue(getMessageForANN_UNNECESSARY(annotation.name), annotation, ANNOTATION__NAME, ANN_UNNECESSARY);
+ addIssue(annotation, ANNOTATION__NAME, ANN_UNNECESSARY.toIssueItem(annotation.name));
}
}
}
@@ -220,8 +220,8 @@ class N4JSAnnotationValidator extends AbstractN4JSDeclarativeValidator {
// less actual arguments than specified in the definition
if (expectedSize - actualSize >= 2) {
- addIssue(getMessageForANN_WRONG_NUMBER_OF_ARGUMENTS(definition.name, expectedSize - 1, actualSize),
- annotation, ANNOTATION__NAME, ANN_WRONG_NUMBER_OF_ARGUMENTS);
+ val IssueItem issueItem = ANN_WRONG_NUMBER_OF_ARGUMENTS.toIssueItem(definition.name, expectedSize - 1, actualSize);
+ addIssue(annotation, ANNOTATION__NAME, issueItem);
return false;
}
@@ -236,8 +236,8 @@ class N4JSAnnotationValidator extends AbstractN4JSDeclarativeValidator {
val argType = if (i + 1 > definition.argtypes.length) definition.argtypes.last else definition.argtypes.
get(i);
if (!argType.isInstance(arg)) {
- addIssue(getMessageForANN_WRONG_ARGUMENT_TYPE(definition.name, argType.name), annotation,
- ANNOTATION__ARGS, i, ANN_WRONG_ARGUMENT_TYPE);
+ val IssueItem issueItem = ANN_WRONG_ARGUMENT_TYPE.toIssueItem(definition.name, argType.name);
+ addIssue(annotation, ANNOTATION__ARGS, i, issueItem);
valid = false;
}
}
@@ -245,8 +245,8 @@ class N4JSAnnotationValidator extends AbstractN4JSDeclarativeValidator {
} else {
if (actualSize > expectedSize || (!definition.argsOptional && actualSize !== expectedSize)) {
- addIssue(getMessageForANN_WRONG_NUMBER_OF_ARGUMENTS(definition.name, expectedSize, actualSize),
- annotation, ANNOTATION__NAME, ANN_WRONG_NUMBER_OF_ARGUMENTS);
+ val IssueItem issueItem = ANN_WRONG_NUMBER_OF_ARGUMENTS.toIssueItem(definition.name, expectedSize, actualSize);
+ addIssue(annotation, ANNOTATION__NAME, issueItem);
return false;
}
}
@@ -263,12 +263,10 @@ class N4JSAnnotationValidator extends AbstractN4JSDeclarativeValidator {
val arg = annotation.args.get(i).value();
val argType = definition.argtypes.get(i);
if (!argType.isInstance(arg)) {
-
- addIssue(getMessageForANN_WRONG_ARGUMENT_TYPE(definition.name, argType.name), annotation,
- ANNOTATION__ARGS, i, ANN_WRONG_ARGUMENT_TYPE);
+ val IssueItem issueItem = ANN_WRONG_ARGUMENT_TYPE.toIssueItem(definition.name, argType.name);
+ addIssue(annotation, ANNOTATION__ARGS, i, issueItem);
valid = false;
}
-
}
return valid;
@@ -283,9 +281,9 @@ class N4JSAnnotationValidator extends AbstractN4JSDeclarativeValidator {
val element = annotation.annotatedElement;
if (!definition.javaScriptVariants.contains(jsVariantHelper.variantMode(element))) {
- val message = IssueCodes.getMessageForANN_ONL_ALLOWED_IN_VARIANTS(definition.name,
+ val IssueItem issueItem = ANN_ONL_ALLOWED_IN_VARIANTS.toIssueItem(definition.name,
orList(definition.javaScriptVariants.map[v | jsVariantHelper.getVariantName(v)]));
- addIssue(message, annotation, IssueCodes.ANN_ONL_ALLOWED_IN_VARIANTS);
+ addIssue(annotation, issueItem);
return false;
}
return true;
@@ -324,8 +322,8 @@ class N4JSAnnotationValidator extends AbstractN4JSDeclarativeValidator {
}
private def addWrongLocationIssue(Annotation annotation) {
- addIssue(getMessageForANN_DISALLOWED_AT_LOCATION(annotation.name), annotation, ANNOTATION__NAME,
- ANN_DISALLOWED_AT_LOCATION);
+ val IssueItem issueItem = ANN_DISALLOWED_AT_LOCATION.toIssueItem(annotation.name);
+ addIssue(annotation, ANNOTATION__NAME, issueItem);
}
/**
@@ -360,8 +358,7 @@ class N4JSAnnotationValidator extends AbstractN4JSDeclarativeValidator {
}
// constraint #1: @This not allowed on static members of interfaces
if (tMember.static && containingType instanceof TInterface) {
- val msg = getMessageForANN_THIS_DISALLOWED_ON_STATIC_MEMBER_OF_INTERFACE();
- addIssue(msg, annotation, ANNOTATION__NAME, ANN_THIS_DISALLOWED_ON_STATIC_MEMBER_OF_INTERFACE);
+ addIssue(annotation, ANNOTATION__NAME, ANN_THIS_DISALLOWED_ON_STATIC_MEMBER_OF_INTERFACE.toIssueItem());
return;
}
// constraint #2: declared this type must be subtype of the containing type
@@ -376,9 +373,9 @@ class N4JSAnnotationValidator extends AbstractN4JSDeclarativeValidator {
};
val G = element.newRuleEnvironment;
if (!ts.subtypeSucceeded(G, declThisTypeRef, containingTypeRef)) {
- val msg = getMessageForANN_THIS_NOT_SUBTYPE_OF_CONTAINING_TYPE(tMember.description,
+ val IssueItem issueItem = ANN_THIS_NOT_SUBTYPE_OF_CONTAINING_TYPE.toIssueItem(tMember.description,
containingType.description, containingTypeRef.typeRefAsString);
- addIssue(msg, annotation, ANNOTATION__ARGS, ANN_THIS_NOT_SUBTYPE_OF_CONTAINING_TYPE);
+ addIssue(annotation, ANNOTATION__ARGS, issueItem);
}
}
}
@@ -392,16 +389,16 @@ class N4JSAnnotationValidator extends AbstractN4JSDeclarativeValidator {
return;
}
if (!jsVariantHelper.isExternalMode(element)) {
- addIssue(getMessageForANN_DISALLOWED_IN_NONDEFINTION_FILE(annotation.name), annotation, ANNOTATION__NAME,
- ANN_DISALLOWED_IN_NONDEFINTION_FILE);
+ val IssueItem issueItem = ANN_DISALLOWED_IN_NONDEFINTION_FILE.toIssueItem(annotation.name);
+ addIssue(annotation, ANNOTATION__NAME, issueItem);
return;
}
if (element instanceof ExportDeclaration
&& (element as ExportDeclaration).exportedElement instanceof N4InterfaceDeclaration
&& ((element as ExportDeclaration).exportedElement as N4InterfaceDeclaration).typingStrategy === TypingStrategy.STRUCTURAL
) {
- addIssue(getMessageForANN_DISALLOWED_ON_SHAPES(annotation.name), annotation, ANNOTATION__NAME,
- ANN_DISALLOWED_ON_SHAPES);
+ val IssueItem issueItem = ANN_DISALLOWED_ON_SHAPES.toIssueItem(annotation.name);
+ addIssue(annotation, ANNOTATION__NAME, issueItem);
}
}
@@ -414,16 +411,16 @@ class N4JSAnnotationValidator extends AbstractN4JSDeclarativeValidator {
return;
}
if (!jsVariantHelper.isExternalMode(element)) {
- addIssue(getMessageForANN_ONL_ALLOWED_AT_CLASSES_IN_N4JSD(annotation.name), annotation, ANNOTATION__NAME,
- ANN_ONL_ALLOWED_AT_CLASSES_IN_N4JSD);
+ val IssueItem issueItem = ANN_ONL_ALLOWED_AT_CLASSES_IN_N4JSD.toIssueItem(annotation.name);
+ addIssue(annotation, ANNOTATION__NAME, issueItem);
return;
}
if (element instanceof ExportDeclaration
&& !((element as ExportDeclaration).exportedElement instanceof N4ClassDeclaration)
) {
- addIssue(getMessageForANN_ONL_ALLOWED_AT_CLASSES_IN_N4JSD(annotation.name), annotation, ANNOTATION__NAME,
- ANN_ONL_ALLOWED_AT_CLASSES_IN_N4JSD);
+ val IssueItem issueItem = ANN_ONL_ALLOWED_AT_CLASSES_IN_N4JSD.toIssueItem(annotation.name);
+ addIssue(annotation, ANNOTATION__NAME, issueItem);
return;
}
}
@@ -442,8 +439,8 @@ class N4JSAnnotationValidator extends AbstractN4JSDeclarativeValidator {
return;
}
if (!srcContainer.isTest) {
- val msg = getMessageForANN__TEST_ONLY_IN_TEST_SOURCES(annotation.name);
- addIssue(msg, annotation, ANNOTATION__NAME, ANN__TEST_ONLY_IN_TEST_SOURCES);
+ val IssueItem issueItem = ANN__TEST_ONLY_IN_TEST_SOURCES.toIssueItem(annotation.name);
+ addIssue(annotation, ANNOTATION__NAME, issueItem);
return;
}
}
@@ -461,8 +458,8 @@ class N4JSAnnotationValidator extends AbstractN4JSDeclarativeValidator {
}
}
}
- val msg = getMessageForANN_ONLY_ALLOWED_LOCATION_CONSTRUCTORS(annotation.name);
- addIssue(msg, annotation, ANNOTATION__NAME, ANN_ONLY_ALLOWED_LOCATION_CONSTRUCTORS);
+ val IssueItem issueItem = ANN_ONLY_ALLOWED_LOCATION_CONSTRUCTORS.toIssueItem(annotation.name);
+ addIssue(annotation, ANNOTATION__NAME, issueItem);
return false;
}
@@ -475,8 +472,8 @@ class N4JSAnnotationValidator extends AbstractN4JSDeclarativeValidator {
return
}
if (!jsVariantHelper.isExternalMode(element)) {
- addIssue(getMessageForANN_DISALLOWED_IN_NONDEFINTION_FILE(annotation.name), annotation, ANNOTATION__NAME,
- ANN_DISALLOWED_IN_NONDEFINTION_FILE);
+ val IssueItem issueItem = ANN_DISALLOWED_IN_NONDEFINTION_FILE.toIssueItem(annotation.name);
+ addIssue(annotation, ANNOTATION__NAME, issueItem);
return
}
val resource = element.eResource;
@@ -484,15 +481,15 @@ class N4JSAnnotationValidator extends AbstractN4JSDeclarativeValidator {
val project = workspaceAccess.findProjectByNestedLocation(annotation, projURI);
if (project === null) {
if (!N4Scheme.isResourceWithN4Scheme(resource)) { // built-in type definition files are not contained in a project
- val msg = getMessageForNO_PROJECT_FOUND(projURI);
+ val IssueItem issueItem = NO_PROJECT_FOUND.toIssueItem(projURI);
val script = EcoreUtil2.getContainerOfType(element, Script);
- addIssue(msg, script, NO_PROJECT_FOUND);
+ addIssue(script, issueItem);
}
} else {
val projectType = project.type;
if (projectType !== ProjectType.RUNTIME_ENVIRONMENT && projectType !== ProjectType.RUNTIME_LIBRARY) {
- addIssue(getMessageForANN_DISALLOWED_IN_NON_RUNTIME_COMPONENT(annotation.name), annotation,
- ANNOTATION__NAME, ANN_DISALLOWED_IN_NON_RUNTIME_COMPONENT);
+ val IssueItem issueItem = ANN_DISALLOWED_IN_NON_RUNTIME_COMPONENT.toIssueItem(annotation.name);
+ addIssue(annotation, ANNOTATION__NAME, issueItem);
return
}
}
@@ -507,8 +504,8 @@ class N4JSAnnotationValidator extends AbstractN4JSDeclarativeValidator {
return
}
if (!jsVariantHelper.isExternalMode(element)) {
- addIssue(getMessageForANN_DISALLOWED_IN_NONDEFINTION_FILE(annotation.name), annotation, ANNOTATION__NAME,
- ANN_DISALLOWED_IN_NONDEFINTION_FILE);
+ val IssueItem issueItem = ANN_DISALLOWED_IN_NONDEFINTION_FILE.toIssueItem(annotation.name);
+ addIssue(annotation, ANNOTATION__NAME, issueItem);
return
}
}
@@ -529,8 +526,7 @@ class N4JSAnnotationValidator extends AbstractN4JSDeclarativeValidator {
// mutual exclusive with poly-fill aware.
if (script.isContainedInStaticPolyfillAware) {
- addIssue(messageForANN_POLY_AWARE_AND_MODULE_MUTUAL_EXCLUSIVE, annotation, ANNOTATION__NAME,
- ANN_POLY_AWARE_AND_MODULE_MUTUAL_EXCLUSIVE)
+ addIssue(annotation, ANNOTATION__NAME, ANN_POLY_AWARE_AND_MODULE_MUTUAL_EXCLUSIVE.toIssueItem())
return
}
@@ -574,8 +570,8 @@ class N4JSAnnotationValidator extends AbstractN4JSDeclarativeValidator {
it.URI.toString
}
])
- addIssue(getMessageForPOLY_CLASH_IN_STATIC_POLYFILL_MODULE(msg_prefix + clashes), annotation,
- ANNOTATION__NAME, POLY_CLASH_IN_STATIC_POLYFILL_MODULE)
+ val IssueItem issueItem = POLY_CLASH_IN_STATIC_POLYFILL_MODULE.toIssueItem(msg_prefix + clashes);
+ addIssue(annotation, ANNOTATION__NAME, issueItem)
}
}
@@ -592,8 +588,7 @@ class N4JSAnnotationValidator extends AbstractN4JSDeclarativeValidator {
// inside a static-polyfill module (IDE-1735)
if (! element.isContainedInStaticPolyfillModule) { // transitively inherited
// not in a polyfill-module
- addIssue(messageForANN_POLY_STATIC_POLY_ONLY_IN_POLYFILL_MODULE, annotation, ANNOTATION__NAME,
- ANN_POLY_STATIC_POLY_ONLY_IN_POLYFILL_MODULE)
+ addIssue(annotation, ANNOTATION__NAME, ANN_POLY_STATIC_POLY_ONLY_IN_POLYFILL_MODULE.toIssueItem);
return
}
@@ -630,18 +625,15 @@ class N4JSAnnotationValidator extends AbstractN4JSDeclarativeValidator {
def private boolean holdsPromisifiablePreconditions(FunctionDefinition funDef) {
return switch (promisifyHelper.checkPromisifiablePreconditions(funDef)) {
case MISSING_CALLBACK: {
- addIssue(getMessageForANN_PROMISIFIABLE_MISSING_CALLBACK, PROMISIFIABLE.getAnnotation(funDef),
- ANN_PROMISIFIABLE_MISSING_CALLBACK);
+ addIssue(PROMISIFIABLE.getAnnotation(funDef), ANN_PROMISIFIABLE_MISSING_CALLBACK.toIssueItem());
false
}
case BAD_CALLBACK__MORE_THAN_ONE_ERROR: {
- addIssue(getMessageForANN_PROMISIFIABLE_BAD_CALLBACK_MORE_THAN_ONE_ERROR,
- PROMISIFIABLE.getAnnotation(funDef), ANN_PROMISIFIABLE_BAD_CALLBACK_MORE_THAN_ONE_ERROR);
+ addIssue(PROMISIFIABLE.getAnnotation(funDef), ANN_PROMISIFIABLE_BAD_CALLBACK_MORE_THAN_ONE_ERROR.toIssueItem());
false
}
case BAD_CALLBACK__ERROR_NOT_FIRST_ARG: {
- addIssue(getMessageForANN_PROMISIFIABLE_BAD_CALLBACK_ERROR_NOT_FIRST_ARG,
- PROMISIFIABLE.getAnnotation(funDef), ANN_PROMISIFIABLE_BAD_CALLBACK_ERROR_NOT_FIRST_ARG);
+ addIssue(PROMISIFIABLE.getAnnotation(funDef), ANN_PROMISIFIABLE_BAD_CALLBACK_ERROR_NOT_FIRST_ARG.toIssueItem());
false
}
case OK: {
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSClassValidator.xtend b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSClassValidator.xtend
index 32246c48c9..d643ae7ce7 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSClassValidator.xtend
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSClassValidator.xtend
@@ -11,6 +11,7 @@
package org.eclipse.n4js.validation.validators
import com.google.inject.Inject
+import java.util.List
import java.util.Map
import org.eclipse.emf.ecore.EObject
import org.eclipse.emf.ecore.EStructuralFeature
@@ -49,7 +50,7 @@ import org.eclipse.n4js.typesystem.utils.RuleEnvironmentExtensions
import org.eclipse.n4js.utils.ContainerTypesHelper
import org.eclipse.n4js.utils.N4JSLanguageUtils
import org.eclipse.n4js.validation.AbstractN4JSDeclarativeValidator
-import org.eclipse.n4js.validation.IssueCodes
+import org.eclipse.n4js.validation.IssueItem
import org.eclipse.n4js.validation.IssueUserDataKeys
import org.eclipse.n4js.validation.N4JSElementKeywordProvider
import org.eclipse.xtext.validation.Check
@@ -95,13 +96,11 @@ class N4JSClassValidator extends AbstractN4JSDeclarativeValidator implements Pol
if (classDecl?.definedType instanceof TClass) {
var clazz = classDecl.definedType as TClass;
if (!clazz.abstract && !clazz.directlyExported && clazz.hasTestMethods) {
- addIssue(getMessageForCLF_TEST_CLASS_NOT_EXPORTED, classDecl,
- N4_TYPE_DECLARATION__NAME, CLF_TEST_CLASS_NOT_EXPORTED
- );
+ addIssue(classDecl, N4_TYPE_DECLARATION__NAME, CLF_TEST_CLASS_NOT_EXPORTED.toIssueItem());
}
}
if (classDecl.typingStrategy === TypingStrategy.STRUCTURAL) {
- addIssue(getMessageForCLF_MUST_BE_NOMINAL, classDecl, N4JSPackage.eINSTANCE.n4ClassifierDeclaration_TypingStrategy, CLF_MUST_BE_NOMINAL);
+ addIssue(classDecl, N4JSPackage.eINSTANCE.n4ClassifierDeclaration_TypingStrategy, CLF_MUST_BE_NOMINAL.toIssueItem());
}
}
@@ -206,10 +205,10 @@ class N4JSClassValidator extends AbstractN4JSDeclarativeValidator implements Pol
val containingClassifier = field.containingType;
if (containingClassifier instanceof TInterface) {
if (N4JSLanguageUtils.builtInOrProvidedByRuntime(containingClassifier)) {
- val message = getMessageForCLF_SPEC_BUILT_IN_OR_PROVIDED_BY_RUNTIME_OR_EXTENAL_WITHOUT_N4JS_ANNOTATION(field.name, containingClassifier.name);
+ val IssueItem issueItem = CLF_SPEC_BUILT_IN_OR_PROVIDED_BY_RUNTIME_OR_EXTENAL_WITHOUT_N4JS_ANNOTATION.toIssueItem(field.name, containingClassifier.name);
val feature = if ((property.astElement as PropertyNameValuePair).property === null) PROPERTY_NAME_OWNER__DECLARED_NAME
else N4JSPackage.eINSTANCE.propertyNameValuePair_Property;
- addIssue(message, property.astElement, feature, CLF_SPEC_BUILT_IN_OR_PROVIDED_BY_RUNTIME_OR_EXTENAL_WITHOUT_N4JS_ANNOTATION);
+ addIssue(property.astElement, feature, issueItem);
}
}
}
@@ -248,8 +247,7 @@ class N4JSClassValidator extends AbstractN4JSDeclarativeValidator implements Pol
def private internalCheckAbstractFinal(TClass tClass) {
if (tClass.abstract && tClass.final) {
- val message = getMessageForCLF_ABSTRACT_FINAL("class");
- addIssue(message, tClass.astElement, N4_TYPE_DECLARATION__NAME, CLF_ABSTRACT_FINAL);
+ addIssue(tClass.astElement, N4_TYPE_DECLARATION__NAME, CLF_ABSTRACT_FINAL.toIssueItem("class"));
}
}
@@ -260,17 +258,17 @@ class N4JSClassValidator extends AbstractN4JSDeclarativeValidator implements Pol
if (superType instanceof PrimitiveType) {
if (!N4Scheme.isFromResourceWithN4Scheme(n4Class)) { // primitive types may be extended in built-in types
- val message = getMessageForCLF_EXTENDS_PRIMITIVE_GENERIC_TYPE(superType.name);
- addIssue(message, n4Class.superClassRef, null, CLF_EXTENDS_PRIMITIVE_GENERIC_TYPE);
+ val IssueItem issueItem = CLF_EXTENDS_PRIMITIVE_GENERIC_TYPE.toIssueItem(superType.name);
+ addIssue(n4Class.superClassRef, null, issueItem);
}
} else if (!(superType instanceof TClass)) {
if (superType instanceof TInterface) {
- val message = getMessageForSYN_KW_EXTENDS_IMPLEMENTS_MIXED_UP(n4Class.description, "extend",
+ val IssueItem issueItem = SYN_KW_EXTENDS_IMPLEMENTS_MIXED_UP.toIssueItem(n4Class.description, "extend",
superType.description, "implements");
- addIssue(message, n4Class.superClassRef, null, SYN_KW_EXTENDS_IMPLEMENTS_MIXED_UP);
+ addIssue(n4Class.superClassRef, null, issueItem);
} else {
- val message = getMessageForCLF_WRONG_META_TYPE(n4Class.description, "extend", superType.description);
- addIssue(message, n4Class.superClassRef, null, CLF_WRONG_META_TYPE);
+ val IssueItem issueItem = CLF_WRONG_META_TYPE.toIssueItem(n4Class.description, "extend", superType.description);
+ addIssue(n4Class.superClassRef, null, issueItem);
return false;
}
} else if(superType instanceof TClass) {
@@ -278,18 +276,22 @@ class N4JSClassValidator extends AbstractN4JSDeclarativeValidator implements Pol
// super class must not be final (except in case of polyfills)
if (superType.final && !(N4JSLanguageUtils.isNonStaticPolyfill(n4Class) || N4JSLanguageUtils.isStaticPolyfill(n4Class))) {
- val message = getMessageForCLF_EXTEND_FINAL(superType.name);
val superTypeAstElement = superType.eGet(TypesPackage.eINSTANCE.syntaxRelatedTElement_AstElement,
false) as EObject;
val superClassUri = if (superTypeAstElement!==null) EcoreUtil.getURI(superTypeAstElement).toString;
if (superClassUri !== null) {
- addIssue(message, n4Class.superClassRef, null, CLF_EXTEND_FINAL,
- IssueUserDataKeys.CLF_EXTEND_FINAL.SUPER_TYPE_DECLARATION_URI, superClassUri);
+ val IssueItem issueItem = CLF_EXTEND_FINAL.toIssueItemWithData(
+ List.of(IssueUserDataKeys.CLF_EXTEND_FINAL.SUPER_TYPE_DECLARATION_URI, superClassUri),
+ superType.name
+ );
+ addIssue(n4Class.superClassRef, null, issueItem);
} else {
- addIssue(message, n4Class.superClassRef, null, CLF_EXTEND_FINAL,
- IssueUserDataKeys.CLF_EXTEND_FINAL.SUPER_TYPE_DECLARATION_URI);
+ val IssueItem issueItem = CLF_EXTEND_FINAL.toIssueItemWithData(
+ List.of(IssueUserDataKeys.CLF_EXTEND_FINAL.SUPER_TYPE_DECLARATION_URI),
+ superType.name);
+ addIssue(n4Class.superClassRef, null, issueItem);
}
return false;
}
@@ -301,15 +303,15 @@ class N4JSClassValidator extends AbstractN4JSDeclarativeValidator implements Pol
// if super class is observable, then this class must be observable as well
if (superType.observable && !(n4Class.definedType as TClass).observable) {
- val message = getMessageForCLF_OBSERVABLE_MISSING(n4Class.name, superType.name);
- addIssue(message, n4Class, N4_TYPE_DECLARATION__NAME, CLF_OBSERVABLE_MISSING);
+ val IssueItem issueItem = CLF_OBSERVABLE_MISSING.toIssueItem(n4Class.name, superType.name);
+ addIssue(n4Class, N4_TYPE_DECLARATION__NAME, issueItem);
return false;
}
}
} else if (superTypeRef !== null && superTypeRef.isAliasResolved) {
// not all aliases are illegal after "extends", but if we get to this point we have an illegal case:
- val message = getMessageForCLF_WRONG_META_TYPE(n4Class.description, "extend", superTypeRef.typeRefAsStringWithAliasResolution);
- addIssue(message, n4Class.superClassRef, null, CLF_WRONG_META_TYPE);
+ val IssueItem issueItem = CLF_WRONG_META_TYPE.toIssueItem(n4Class.description, "extend", superTypeRef.typeRefAsStringWithAliasResolution);
+ addIssue(n4Class.superClassRef, null, issueItem);
return false;
}
return true;
@@ -319,10 +321,10 @@ class N4JSClassValidator extends AbstractN4JSDeclarativeValidator implements Pol
val receiverTypeRef = TypeUtils.createTypeRef(n4Class.definedType);
val superCtor = containerTypesHelper.fromContext(n4Class).findConstructor(superType);
if(superCtor!==null && !memberVisibilityChecker.isVisible(n4Class, receiverTypeRef, superCtor).visibility) {
- val message = getMessageForCLF_EXTEND_NON_ACCESSIBLE_CTOR(
+ val IssueItem issueItem = CLF_EXTEND_NON_ACCESSIBLE_CTOR.toIssueItem(
n4jsElementKeywordProvider.keyword(superType),
superType.name);
- addIssue(message, n4Class, N4_CLASS_DEFINITION__SUPER_CLASS_REF, CLF_EXTEND_NON_ACCESSIBLE_CTOR);
+ addIssue(n4Class, N4_CLASS_DEFINITION__SUPER_CLASS_REF, issueItem);
return false;
}
return true;
@@ -337,27 +339,26 @@ class N4JSClassValidator extends AbstractN4JSDeclarativeValidator implements Pol
// consumed type must be an interface
if (!(consumedType instanceof TInterface)) {
if (consumedType instanceof TClass && n4Class.superClassRef === null) {
- val message = getMessageForSYN_KW_EXTENDS_IMPLEMENTS_MIXED_UP(n4Class.description, "implement",
+ val IssueItem issueItem = SYN_KW_EXTENDS_IMPLEMENTS_MIXED_UP.toIssueItem(n4Class.description, "implement",
consumedType.description, "extends");
- addIssue(message, it, null, SYN_KW_EXTENDS_IMPLEMENTS_MIXED_UP);
+ addIssue(it, null, issueItem);
} else {
- val message = getMessageForCLF_WRONG_META_TYPE(n4Class.description, "implement",
+ val IssueItem issueItem = CLF_WRONG_META_TYPE.toIssueItem(n4Class.description, "implement",
consumedType.description);
- addIssue(message, it, null, CLF_WRONG_META_TYPE);
+ addIssue(it, null, issueItem);
}
} else {
val tIfc = consumedType as TInterface;
val cth = containerTypesHelper.fromContext(n4Class);
val hasCallConstructSig = cth.findCallSignature(tIfc) !== null || cth.findConstructSignature(tIfc) !== null;
if (hasCallConstructSig) {
- val message = getMessageForCLF_CALL_CONSTRUCT_SIG_CANNOT_IMPLEMENT();
- addIssue(message, it, null, CLF_CALL_CONSTRUCT_SIG_CANNOT_IMPLEMENT);
+ addIssue(it, null, CLF_CALL_CONSTRUCT_SIG_CANNOT_IMPLEMENT.toIssueItem());
}
}
} else if (consumedTypeRef !== null && consumedTypeRef.isAliasResolved) {
// not all aliases are illegal after "implements", but if we get to this point we have an illegal case:
- val message = getMessageForCLF_WRONG_META_TYPE(n4Class.description, "implement", consumedTypeRef.typeRefAsStringWithAliasResolution);
- addIssue(message, it, null, CLF_WRONG_META_TYPE);
+ val IssueItem issueItem = CLF_WRONG_META_TYPE.toIssueItem(n4Class.description, "implement", consumedTypeRef.typeRefAsStringWithAliasResolution);
+ addIssue(it, null, issueItem);
}
]
}
@@ -374,8 +375,7 @@ class N4JSClassValidator extends AbstractN4JSDeclarativeValidator implements Pol
val correctType = currFPar.declaredTypeRef instanceof ThisTypeRef
&& STRUCTURAL_FIELD_INITIALIZER === currFPar.declaredTypeRef.typingStrategy;
if (!correctType) {
- val message = messageForCLF_SPEC_WRONG_TYPE;
- addIssue(message, annSpec, null, CLF_SPEC_WRONG_TYPE);
+ addIssue(annSpec, null, CLF_SPEC_WRONG_TYPE.toIssueItem());
} else { // prevent consequential errors
holdsAdditionalSpecFieldMatchesOwnedFields(
n4ClassDeclaration,
@@ -388,8 +388,7 @@ class N4JSClassValidator extends AbstractN4JSDeclarativeValidator implements Pol
}
if (specAnnotations.size >= 2) {
for (currAnnSpec : specAnnotations) {
- val message = messageForCLF_SPEC_MULTIPLE;
- addIssue(message, currAnnSpec, null, CLF_SPEC_MULTIPLE);
+ addIssue(currAnnSpec, null, CLF_SPEC_MULTIPLE.toIssueItem());
}
}
}
@@ -415,16 +414,12 @@ class N4JSClassValidator extends AbstractN4JSDeclarativeValidator implements Pol
val smemberType = ts.tau(smember, TypeUtils.createTypeRef(tclass));
val subtypeRes = ts.subtype(G, smemberType, fieldType);
if (subtypeRes.failure) {
- val message = getMessageForCLF_SPEC_WRONG_ADD_MEMBERTYPE(smember.name, description(tfield),
+ val IssueItem issueItem = CLF_SPEC_WRONG_ADD_MEMBERTYPE.toIssueItem(smember.name, description(tfield),
trimTypesystemMessage(subtypeRes));
val errMember = (ctor.fpars.get(parIndex).declaredTypeRefInAST as StructuralTypeRef).structuralMembers.
get(memberIndex);
val sourceObject = (if (errMember.astElement !== null) errMember.astElement else errMember);
- addIssue(
- message,
- sourceObject,
- CLF_SPEC_WRONG_ADD_MEMBERTYPE
- );
+ addIssue(sourceObject, issueItem);
}
}
@@ -437,10 +432,9 @@ class N4JSClassValidator extends AbstractN4JSDeclarativeValidator implements Pol
def private boolean holdsNoCyclicInheritance(N4ClassDeclaration n4ClassDeclaration) {
val cls = n4ClassDeclaration.definedType as TClassifier;
val cycle = findCyclicInheritance(cls);
- if(cycle!==null) {
- val message = IssueCodes.getMessageForCLF_INHERITANCE_CYCLE(cycle.map[name].join(", "));
- addIssue(message, n4ClassDeclaration, N4JSPackage.Literals.N4_CLASS_DEFINITION__SUPER_CLASS_REF,
- IssueCodes.CLF_INHERITANCE_CYCLE);
+ if (cycle!==null) {
+ val IssueItem issueItem = CLF_INHERITANCE_CYCLE.toIssueItem(cycle.map[name].join(", "));
+ addIssue(n4ClassDeclaration, N4JSPackage.Literals.N4_CLASS_DEFINITION__SUPER_CLASS_REF, issueItem);
return false;
}
return true;
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSClassifierValidator.xtend b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSClassifierValidator.xtend
index c0b378a1dc..d3d673ae82 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSClassifierValidator.xtend
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSClassifierValidator.xtend
@@ -36,6 +36,7 @@ import org.eclipse.n4js.ts.types.TypeVariable
import org.eclipse.n4js.ts.types.util.Variance
import org.eclipse.n4js.utils.N4JSLanguageUtils
import org.eclipse.n4js.validation.AbstractN4JSDeclarativeValidator
+import org.eclipse.n4js.validation.IssueItem
import org.eclipse.xtext.naming.IQualifiedNameProvider
import org.eclipse.xtext.naming.QualifiedName
import org.eclipse.xtext.nodemodel.util.NodeModelUtils
@@ -76,7 +77,7 @@ class N4JSClassifierValidator extends AbstractN4JSDeclarativeValidator {
for(typeRefInAST : superTypeRefs) {
for(typeArgInAST : typeRefInAST.declaredTypeArgs) {
if(typeArgInAST instanceof Wildcard) {
- addIssue(getMessageForCLF_IMPLEMENT_EXTEND_WITH_WILDCARD, typeArgInAST, CLF_IMPLEMENT_EXTEND_WITH_WILDCARD);
+ addIssue(typeArgInAST, CLF_IMPLEMENT_EXTEND_WITH_WILDCARD.toIssueItem());
}
}
}
@@ -127,8 +128,7 @@ class N4JSClassifierValidator extends AbstractN4JSDeclarativeValidator {
val duplicates = names.computeStringOccurance.filter[value > 1]
for (dupe : duplicates) {
- val message = getMessageForCLF_MULTIPLE_ROLE_CONSUME(QualifiedNameUtils.toHumanReadableString(dupe.key))
- addIssue(message, source.astElement, eref, CLF_MULTIPLE_ROLE_CONSUME)
+ addIssue(source.astElement, eref, CLF_MULTIPLE_ROLE_CONSUME.toIssueItem(QualifiedNameUtils.toHumanReadableString(dupe.key)))
}
}
@@ -193,31 +193,27 @@ class N4JSClassifierValidator extends AbstractN4JSDeclarativeValidator {
if (! isFieldAccessorPair(firstDup, otherDup)) {
if (firstDup.constructor) {
if (createErrorForFirst) {
- val message = getMessageForCLF_DUP_CTOR(
+ val IssueItem issueItem = CLF_DUP_CTOR.toIssueItem(
NodeModelUtils::getNode(firstDup.astElement).startLine,
NodeModelUtils::getNode(otherDup.astElement).startLine
);
- addIssue(message, firstDup.astElement, N4JSPackage.Literals.PROPERTY_NAME_OWNER__DECLARED_NAME,
- CLF_DUP_CTOR)
+ addIssue(firstDup.astElement, N4JSPackage.Literals.PROPERTY_NAME_OWNER__DECLARED_NAME, issueItem)
createErrorForFirst = false;
}
- val message = getMessageForCLF_DUP_CTOR(
+ val IssueItem issueItem = CLF_DUP_CTOR.toIssueItem(
NodeModelUtils::getNode(otherDup.astElement).startLine,
NodeModelUtils::getNode(firstDup.astElement).startLine);
- addIssue(message, otherDup.astElement, N4JSPackage.Literals.PROPERTY_NAME_OWNER__DECLARED_NAME,
- CLF_DUP_CTOR)
+ addIssue(otherDup.astElement, N4JSPackage.Literals.PROPERTY_NAME_OWNER__DECLARED_NAME, issueItem);
} else {
if (createErrorForFirst) {
- val message = getMessageForCLF_DUP_MEMBER(firstDup.descriptionWithLine(),
+ val IssueItem issueItem = CLF_DUP_MEMBER.toIssueItem(firstDup.descriptionWithLine(),
otherDup.descriptionWithLine());
- addIssue(message, firstDup.astElement, N4JSPackage.Literals.PROPERTY_NAME_OWNER__DECLARED_NAME,
- CLF_DUP_MEMBER)
+ addIssue(firstDup.astElement, N4JSPackage.Literals.PROPERTY_NAME_OWNER__DECLARED_NAME, issueItem);
createErrorForFirst = false;
}
- val message = getMessageForCLF_DUP_MEMBER(otherDup.descriptionWithLine(),
+ val IssueItem issueItem = CLF_DUP_MEMBER.toIssueItem(otherDup.descriptionWithLine(),
firstDup.descriptionWithLine());
- addIssue(message, otherDup.astElement, N4JSPackage.Literals.PROPERTY_NAME_OWNER__DECLARED_NAME,
- CLF_DUP_MEMBER)
+ addIssue(otherDup.astElement, N4JSPackage.Literals.PROPERTY_NAME_OWNER__DECLARED_NAME, issueItem);
}
}
}
@@ -228,13 +224,12 @@ class N4JSClassifierValidator extends AbstractN4JSDeclarativeValidator {
if((n4TypeVar.declaredCovariant || n4TypeVar.declaredContravariant) &&
!(n4TypeVar.eContainer instanceof N4ClassifierDeclaration
&& n4TypeVar.eContainmentFeature===N4JSPackage.eINSTANCE.genericDeclaration_TypeVars)) {
- val message = messageForCLF_DEF_SITE_VARIANCE_ONLY_IN_CLASSIFIER;
val feature = if(n4TypeVar.declaredCovariant) {
N4JSPackage.eINSTANCE.n4TypeVariable_DeclaredCovariant
} else {
N4JSPackage.eINSTANCE.n4TypeVariable_DeclaredContravariant
};
- addIssue(message, n4TypeVar, feature, CLF_DEF_SITE_VARIANCE_ONLY_IN_CLASSIFIER);
+ addIssue(n4TypeVar, feature, CLF_DEF_SITE_VARIANCE_ONLY_IN_CLASSIFIER.toIssueItem());
}
}
@@ -251,9 +246,10 @@ class N4JSClassifierValidator extends AbstractN4JSDeclarativeValidator {
if(variance!==Variance.INV) {
val varianceOfPos = N4JSLanguageUtils.getVarianceOfPosition(typeRefInAST);
if(varianceOfPos!==null && variance!==varianceOfPos) {
- val msg = getMessageForCLF_TYPE_VARIABLE_AT_INVALID_POSITION(variance.getDescriptiveString(true),
+ val IssueItem issueItem = CLF_TYPE_VARIABLE_AT_INVALID_POSITION.toIssueItem(
+ variance.getDescriptiveString(true),
varianceOfPos.getDescriptiveString(false));
- addIssue(msg, typeRefInAST, CLF_TYPE_VARIABLE_AT_INVALID_POSITION);
+ addIssue(typeRefInAST, issueItem);
}
}
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSDeclaredNameValidator.xtend b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSDeclaredNameValidator.xtend
index 7c6cc857bb..d7e77c983a 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSDeclaredNameValidator.xtend
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSDeclaredNameValidator.xtend
@@ -81,6 +81,7 @@ import org.eclipse.xtext.validation.EValidatorRegistrar
import static org.eclipse.n4js.validation.IssueCodes.*
import org.eclipse.n4js.n4JS.PropertyNameValuePair
+import org.eclipse.n4js.validation.IssueItem
/**
*/
@@ -139,11 +140,10 @@ class N4JSDeclaredNameValidator extends AbstractN4JSDeclarativeValidator {
return;
}
- addIssue(
- StringExtensions.toFirstUpper(
- getMessageForAST_NAME_DUPLICATE_ERR(messageHelper.description(dupeEO, name),
- messageHelper.descriptionWithLine(baseEO, name))), dupeEO, findNameEAttribute(dupeEO),
- AST_NAME_DUPLICATE_ERR);
+ val IssueItem issueItem = AST_NAME_DUPLICATE_ERR.toIssueItem(
+ StringExtensions.toFirstUpper(messageHelper.description(dupeEO, name)),
+ messageHelper.descriptionWithLine(baseEO, name));
+ addIssue(dupeEO, findNameEAttribute(dupeEO), issueItem);
}
]);
]
@@ -167,12 +167,10 @@ class N4JSDeclaredNameValidator extends AbstractN4JSDeclarativeValidator {
if (BASE_JS_TYPES.contains(name)) {
val project = workspaceAccess.findProjectContaining(exportableElement);
if (project === null || project.type !== ProjectType.RUNTIME_ENVIRONMENT) {
- addIssue(getMessageForAST_GLOBAL_JS_NAME_CONFLICT(name), exportableElement,
- AST_GLOBAL_JS_NAME_CONFLICT);
+ addIssue(exportableElement, AST_GLOBAL_JS_NAME_CONFLICT.toIssueItem(name));
}
} else if (BASE_GLOBAL_NAMES.contains(name)) {
- addIssue(getMessageForAST_GLOBAL_NAME_CONFLICT(name), exportableElement,
- AST_GLOBAL_NAME_CONFLICT);
+ addIssue(exportableElement, AST_GLOBAL_NAME_CONFLICT.toIssueItem(name));
}
}
}
@@ -247,12 +245,10 @@ class N4JSDeclaredNameValidator extends AbstractN4JSDeclarativeValidator {
val globalObjectMember = globalEntry.value.head;
val localObjects = localNames.get(name);
for (innerScopeObject : localObjects) {
- addIssue(
- StringExtensions.toFirstUpper(
- getMessageForAST_GLOBAL_NAME_SHADOW_ERR(
- messageHelper.description(innerScopeObject, name),
- messageHelper.description(globalObjectMember, name))), innerScopeObject,
- findNameEAttribute(innerScopeObject), AST_GLOBAL_NAME_SHADOW_ERR);
+ val IssueItem issueItem = AST_GLOBAL_NAME_SHADOW_ERR.toIssueItem(
+ StringExtensions.toFirstUpper(messageHelper.description(innerScopeObject, name)),
+ messageHelper.description(globalObjectMember, name));
+ addIssue(innerScopeObject, findNameEAttribute(innerScopeObject), issueItem);
}
}
}
@@ -305,31 +301,26 @@ class N4JSDeclaredNameValidator extends AbstractN4JSDeclarativeValidator {
if (baseEO.equals(vee)) {
if (dupeEO instanceof FormalParameter) {
- addIssue(
- StringExtensions.toFirstUpper(
- getMessageForAST_NAME_SHADOW_ERR(
- messageHelper.description(dupeEO, name),
- messageHelper.description(baseEO, name))), dupeEO,
- findNameEAttribute(dupeEO), AST_NAME_SHADOW_ERR);
+ val IssueItem issueItem = AST_NAME_SHADOW_ERR.toIssueItem(
+ StringExtensions.toFirstUpper(messageHelper.description(dupeEO, name)),
+ messageHelper.description(baseEO, name));
+ addIssue(dupeEO, findNameEAttribute(dupeEO), issueItem);
} else {
- addIssue(
- StringExtensions.toFirstUpper(
- getMessageForAST_NAME_SHADOW_ERR(
- messageHelper.description(dupeEO, name),
- messageHelper.descriptionWithLine(baseEO, name))), dupeEO,
- findNameEAttribute(dupeEO), AST_NAME_SHADOW_ERR);
+ val IssueItem issueItem = AST_NAME_SHADOW_ERR.toIssueItem(
+ StringExtensions.toFirstUpper(messageHelper.description(dupeEO, name)),
+ messageHelper.descriptionWithLine(baseEO, name));
+ addIssue(dupeEO, findNameEAttribute(dupeEO), issueItem);
}
return;
}
// otherwise mark duplicates
if (dupeEO instanceof FormalParameter) {
- addIssue(
- StringExtensions.toFirstUpper(
- getMessageForAST_NAME_DUPLICATE_ERR(
- messageHelper.description(dupeEO, name),
- messageHelper.description(baseEO, name))), dupeEO,
- findNameEAttribute(dupeEO), AST_NAME_DUPLICATE_ERR);
+ val IssueItem issueItem = AST_NAME_DUPLICATE_ERR.toIssueItem(
+ StringExtensions.toFirstUpper(messageHelper.description(dupeEO, name)),
+ messageHelper.description(baseEO, name)
+ );
+ addIssue(dupeEO, findNameEAttribute(dupeEO), issueItem);
} else if ((dupeEO instanceof NamedImportSpecifier &&
baseEO instanceof NamedImportSpecifier) ||
(dupeEO instanceof NamespaceImportSpecifier &&
@@ -353,12 +344,10 @@ class N4JSDeclaredNameValidator extends AbstractN4JSDeclarativeValidator {
N4JSLanguageUtils.isNonStaticPolyfill(dupeEO as N4ClassifierDeclaration)
// TODO IDE-1735 does this check need to be activated for static polyfills?
)) {
- addIssue(
- StringExtensions.toFirstUpper(
- getMessageForAST_NAME_DUPLICATE_ERR(
- messageHelper.description(dupeEO, name),
- messageHelper.descriptionWithLine(baseEO, name))), dupeEO,
- findNameEAttribute(dupeEO), AST_NAME_DUPLICATE_ERR);
+ val IssueItem issueItem = AST_NAME_DUPLICATE_ERR.toIssueItem(
+ StringExtensions.toFirstUpper(messageHelper.description(dupeEO, name)),
+ messageHelper.descriptionWithLine(baseEO, name));
+ addIssue(dupeEO, findNameEAttribute(dupeEO), issueItem);
}
}
}
@@ -421,12 +410,10 @@ class N4JSDeclaredNameValidator extends AbstractN4JSDeclarativeValidator {
declaredLetConst.filter[fparNames.contains(declaredName)].forEach[dupeEO|
val name = dupeEO.declaredName;
val baseEO = fpars.filter[it.name==name].head;
- addIssue(
- StringExtensions.toFirstUpper(
- getMessageForAST_NAME_DUPLICATE_ERR(
- messageHelper.description(dupeEO, name),
- messageHelper.description(baseEO, name))), dupeEO,
- findNameEAttribute(dupeEO), AST_NAME_SHADOW_ERR);
+ val IssueItem issueItem = AST_NAME_DUPLICATE_ERR.toIssueItem(
+ StringExtensions.toFirstUpper(messageHelper.description(dupeEO, name)),
+ messageHelper.description(baseEO, name));
+ addIssue(dupeEO, findNameEAttribute(dupeEO), issueItem);
];
}
@@ -487,12 +474,10 @@ class N4JSDeclaredNameValidator extends AbstractN4JSDeclarativeValidator {
&& innerScopeObject.eContainer === outerScopeObject) {
// formal parameters hides containing function name
- addIssue(
- StringExtensions.toFirstUpper(
- getMessageForAST_NAME_SHADOW_ERR(
- messageHelper.description(innerScopeObject, name),
- messageHelper.description(outerScopeObject, name))), innerScopeObject,
- findNameEAttribute(innerScopeObject), AST_NAME_SHADOW_ERR);
+ val IssueItem issueItem = AST_NAME_SHADOW_ERR.toIssueItem(
+ StringExtensions.toFirstUpper(messageHelper.description(innerScopeObject, name)),
+ messageHelper.description(outerScopeObject, name));
+ addIssue(innerScopeObject, findNameEAttribute(innerScopeObject), issueItem);
return;
}
@@ -503,12 +488,10 @@ class N4JSDeclaredNameValidator extends AbstractN4JSDeclarativeValidator {
}
// but not containing function
- addIssue(
- StringExtensions.toFirstUpper(
- getMessageForAST_NAME_SHADOW_ERR(
- messageHelper.description(innerScopeObject, name),
- messageHelper.descriptionWithLine(outerScopeObject, name))),
- innerScopeObject, findNameEAttribute(innerScopeObject), AST_NAME_SHADOW_ERR);
+ val IssueItem issueItem = AST_NAME_SHADOW_ERR.toIssueItem(
+ StringExtensions.toFirstUpper(messageHelper.description(innerScopeObject, name)),
+ messageHelper.descriptionWithLine(outerScopeObject, name));
+ addIssue(innerScopeObject, findNameEAttribute(innerScopeObject), issueItem);
return;
}
@@ -520,23 +503,19 @@ class N4JSDeclaredNameValidator extends AbstractN4JSDeclarativeValidator {
//adding a warning, consider removing if it gets annoying
//in our platform code
if(jsVariantHelper.isN4JSMode(innerScopeObject)){
- addIssue(
- StringExtensions.toFirstUpper(
- getMessageForAST_NAME_SHADOW_WARN(
- messageHelper.description(innerScopeObject, name),
- messageHelper.descriptionWithLine(outerScopeObject, name))),
- innerScopeObject, findNameEAttribute(innerScopeObject), AST_NAME_SHADOW_WARN);
+ val IssueItem issueItem = AST_NAME_SHADOW_WARN.toIssueItem(
+ StringExtensions.toFirstUpper(messageHelper.description(innerScopeObject, name)),
+ messageHelper.descriptionWithLine(outerScopeObject, name));
+ addIssue(innerScopeObject, findNameEAttribute(innerScopeObject), issueItem);
return;
}
//if js mode
return;
}
- addIssue(
- StringExtensions.toFirstUpper(
- getMessageForAST_NAME_SHADOW_ERR(
- messageHelper.description(innerScopeObject, name),
- messageHelper.descriptionWithLine(outerScopeObject, name))),
- innerScopeObject, findNameEAttribute(innerScopeObject), AST_NAME_SHADOW_ERR);
+ val IssueItem issueItem = AST_NAME_SHADOW_ERR.toIssueItem(
+ StringExtensions.toFirstUpper(messageHelper.description(innerScopeObject, name)),
+ messageHelper.descriptionWithLine(outerScopeObject, name));
+ addIssue(innerScopeObject, findNameEAttribute(innerScopeObject), issueItem);
return;
}
return;
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSDependencyInjectionValidator.xtend b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSDependencyInjectionValidator.xtend
index 396dbc4182..5a7fe76468 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSDependencyInjectionValidator.xtend
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSDependencyInjectionValidator.xtend
@@ -59,6 +59,7 @@ import org.eclipse.n4js.typesystem.utils.TypeSystemHelper
import org.eclipse.n4js.utils.ContainerTypesHelper
import org.eclipse.n4js.utils.DeclMergingHelper
import org.eclipse.n4js.validation.AbstractN4JSDeclarativeValidator
+import org.eclipse.n4js.validation.IssueItem
import org.eclipse.n4js.xtext.scoping.IEObjectDescriptionWithError
import org.eclipse.xtext.scoping.IScopeProvider
import org.eclipse.xtext.validation.Check
@@ -142,12 +143,10 @@ class N4JSDependencyInjectionValidator extends AbstractN4JSDeclarativeValidator
val tClazz = staticType as TClass;
if (requiresInjection(tClazz, declMergingHelper)) {
- addIssue(getMessageForDI_MUST_BE_INJECTED(tClazz.typeAsString),
- newExpression, N4JSPackage.eINSTANCE.newExpression_Callee, DI_MUST_BE_INJECTED);
+ addIssue(newExpression, N4JSPackage.eINSTANCE.newExpression_Callee, DI_MUST_BE_INJECTED.toIssueItem(tClazz.typeAsString));
}
if (isMarkedInjected(tClazz, declMergingHelper)) {
- addIssue(getMessageForDI_API_INJECTED(),
- newExpression, N4JSPackage.eINSTANCE.newExpression_Callee, DI_API_INJECTED);
+ addIssue(newExpression, N4JSPackage.eINSTANCE.newExpression_Callee, DI_API_INJECTED.toIssueItem());
}
}
@@ -208,9 +207,7 @@ class N4JSDependencyInjectionValidator extends AbstractN4JSDeclarativeValidator
if (!injectedParentInjectors.empty) {
val currentName = currentType.name;
val superName = injectedParentInjectors.get(0)?.containingType?.name;
- addIssue(getMessageForDI_CTOR_BREAKS_INJECTION_CHAIN(superName, currentName),
- ctor, PROPERTY_NAME_OWNER__DECLARED_NAME, DI_CTOR_BREAKS_INJECTION_CHAIN
- )
+ addIssue(ctor, PROPERTY_NAME_OWNER__DECLARED_NAME, DI_CTOR_BREAKS_INJECTION_CHAIN.toIssueItem(superName, currentName));
return false;
}
}
@@ -260,7 +257,7 @@ class N4JSDependencyInjectionValidator extends AbstractN4JSDeclarativeValidator
val isInjectedCtor = INJECT.hasAnnotation(ctor)
if (!isInjectedCtor) {
// read-access "this.f" where f is injected is valid only in a constructor that is itself marked (at)Inject
- addIssue(getMessageForDI_FIELD_IS_NOT_INJECTED_YET(accessedField.name), propAccess, DI_FIELD_IS_NOT_INJECTED_YET);
+ addIssue(propAccess, DI_FIELD_IS_NOT_INJECTED_YET.toIssueItem(accessedField.name));
isValid = false;
} else {
// some param must exist whose type conforms to that of the injected field being read.
@@ -270,7 +267,7 @@ class N4JSDependencyInjectionValidator extends AbstractN4JSDeclarativeValidator
|| ts.subtypeSucceeded(G, it, accessedField?.typeRef)
];
if (!someParamSubtypesFieldType) {
- addIssue(getMessageForDI_FIELD_IS_NOT_INJECTED_YET(accessedField.name), propAccess, DI_FIELD_IS_NOT_INJECTED_YET);
+ addIssue(propAccess, DI_FIELD_IS_NOT_INJECTED_YET.toIssueItem(accessedField.name));
isValid = false;
}
}
@@ -336,7 +333,7 @@ class N4JSDependencyInjectionValidator extends AbstractN4JSDeclarativeValidator
return // invalid AST
}
if(injtorClassDecl.superClassRef !== null){
- addIssue(getMessageForDI_ANN_INJECTOR_EXTENDS(), ann, N4JSPackage.eINSTANCE.annotation_Name, DI_ANN_INJECTOR_EXTENDS);
+ addIssue(ann, N4JSPackage.eINSTANCE.annotation_Name, DI_ANN_INJECTOR_EXTENDS.toIssueItem());
}
// collect binding across all binders used by the injector of interest
val usedBindersAnns = USE_BINDER.getAllAnnotations(injtorClassDecl)
@@ -356,7 +353,7 @@ class N4JSDependencyInjectionValidator extends AbstractN4JSDeclarativeValidator
val injtorCtor = injtorClassDecl.ownedCtor
if ((null !== injtorCtor) && !(injtorCtor.fpars.isEmpty)) {
if (!INJECT.hasAnnotation(injtorCtor)) {
- addIssue(getMessageForDI_ANN_INJECTOR_CTOR_MUST_BE_INJECT(), injtorCtor, DI_ANN_INJECTOR_CTOR_MUST_BE_INJECT);
+ addIssue(injtorCtor, DI_ANN_INJECTOR_CTOR_MUST_BE_INJECT.toIssueItem());
}
}
}
@@ -409,8 +406,8 @@ class N4JSDependencyInjectionValidator extends AbstractN4JSDeclarativeValidator
// comparing structurally leads to flagging as duplicates, say, two different classes lacking members
val dupBinding = getDuplicate(extra, seen, G)
if (null !== dupBinding) {
- addIssue(getMessageForDI_ANN_DUPLICATE_BINDING(), useBinderAnn, N4JSPackage.eINSTANCE.annotation_Name, DI_ANN_DUPLICATE_BINDING);
- addIssue(getMessageForDI_ANN_DUPLICATE_BINDING(), dupBinding, N4JSPackage.eINSTANCE.annotation_Name, DI_ANN_DUPLICATE_BINDING);
+ addIssue(useBinderAnn, N4JSPackage.eINSTANCE.annotation_Name, DI_ANN_DUPLICATE_BINDING.toIssueItem());
+ addIssue(dupBinding, N4JSPackage.eINSTANCE.annotation_Name, DI_ANN_DUPLICATE_BINDING.toIssueItem());
} else {
seen.put(extra, useBinderAnn)
}
@@ -435,15 +432,15 @@ class N4JSDependencyInjectionValidator extends AbstractN4JSDeclarativeValidator
// TODO this assumes an ExportDeclaration may be annotated @Binder. Fix javadoc if so. Fix error message if not.
val binderClassDecl = getAnnotatedClass(binderAnn);
if(null === binderClassDecl || binderClassDecl.isAbstract){
- addIssue(getMessageForDI_ANN_BINDER_NOT_APPLICABLE(), binderAnn, N4JSPackage.eINSTANCE.annotation_Name, DI_ANN_BINDER_NOT_APPLICABLE);
+ addIssue(binderAnn, N4JSPackage.eINSTANCE.annotation_Name, DI_ANN_BINDER_NOT_APPLICABLE.toIssueItem());
return
}
if(binderClassDecl.superClassRef !== null){
- addIssue(getMessageForDI_ANN_BINDER_EXTENDS(), binderAnn, N4JSPackage.eINSTANCE.annotation_Name, DI_ANN_BINDER_EXTENDS);
+ addIssue(binderAnn, N4JSPackage.eINSTANCE.annotation_Name, DI_ANN_BINDER_EXTENDS.toIssueItem());
}
val binderTClazz = binderClassDecl.definedTypeAsClass;
if (GENERATE_INJECTOR.hasAnnotation(binderTClazz)) {
- addIssue(getMessageForDI_ANN_BINDER_AND_INJECTOR_DONT_GO_TOGETHER(), binderAnn, N4JSPackage.eINSTANCE.annotation_Name, DI_ANN_BINDER_AND_INJECTOR_DONT_GO_TOGETHER);
+ addIssue(binderAnn, N4JSPackage.eINSTANCE.annotation_Name, DI_ANN_BINDER_AND_INJECTOR_DONT_GO_TOGETHER.toIssueItem());
}
internalCheckNoDupBindings(BIND.getAllAnnotations(binderClassDecl), newRuleEnvironment(binderClassDecl))
}
@@ -461,8 +458,8 @@ class N4JSDependencyInjectionValidator extends AbstractN4JSDeclarativeValidator
// comparing structurally leads to flagging as duplicates, say, two different classes lacking members
val dupBinding = getDuplicate(extra, seen, G)
if (null !== dupBinding) {
- addIssue(getMessageForDI_ANN_DUPLICATE_BINDING(), binding, N4JSPackage.eINSTANCE.annotation_Name, DI_ANN_DUPLICATE_BINDING);
- addIssue(getMessageForDI_ANN_DUPLICATE_BINDING(), dupBinding, N4JSPackage.eINSTANCE.annotation_Name, DI_ANN_DUPLICATE_BINDING);
+ addIssue(binding, N4JSPackage.eINSTANCE.annotation_Name, DI_ANN_DUPLICATE_BINDING.toIssueItem());
+ addIssue(dupBinding, N4JSPackage.eINSTANCE.annotation_Name, DI_ANN_DUPLICATE_BINDING.toIssueItem());
} else {
seen.put(extra, binding)
}
@@ -535,11 +532,11 @@ class N4JSDependencyInjectionValidator extends AbstractN4JSDeclarativeValidator
} else {
val indexOf = visitedTypes.indexOf(type.name);
if (indexOf > -1) {
+ val IssueItem issueItem = DI_ANN_USE_INJECTOR_CYCLE.toIssueItem('''«visitedTypes.join(' > ')» > «type.name»''');
addIssue(
- getMessageForDI_ANN_USE_INJECTOR_CYCLE('''«visitedTypes.join(' > ')» > «type.name»'''),
it,
N4JSPackage.eINSTANCE.annotation_Name,
- DI_ANN_USE_INJECTOR_CYCLE
+ issueItem
);
return false
}
@@ -618,7 +615,7 @@ class N4JSDependencyInjectionValidator extends AbstractN4JSDeclarativeValidator
//check the container (classifier decl) of the annotated element (ie, field or constructor)
val annElemCont = annElem.eContainer;
if(annElemCont instanceof N4InterfaceDeclaration){
- addIssue(getMessageForDI_ANN_INTERFACE_INJECTION_NOT_SUPPORTED(), ann, N4JSPackage.eINSTANCE.annotation_Name, DI_ANN_INTERFACE_INJECTION_NOT_SUPPORTED);
+ addIssue(ann, N4JSPackage.eINSTANCE.annotation_Name, DI_ANN_INTERFACE_INJECTION_NOT_SUPPORTED.toIssueItem());
//no return, do other checks
}
@@ -636,10 +633,9 @@ class N4JSDependencyInjectionValidator extends AbstractN4JSDeclarativeValidator
valid = !AnnotationDefinition.GENERATE_INJECTOR.hasAnnotation(clazz)
if (!valid) {
addIssue(
- getMessageForDI_ANN_INJECTOR_CANNOT_BE_INJECTED_INTO_INJECTOR(),
ann,
N4JSPackage.eINSTANCE.annotation_Name,
- DI_ANN_INJECTOR_CANNOT_BE_INJECTED_INTO_INJECTOR
+ DI_ANN_INJECTOR_CANNOT_BE_INJECTED_INTO_INJECTOR.toIssueItem()
);
}
val type = clazz?.superClassRef?.declaredType;
@@ -662,9 +658,8 @@ class N4JSDependencyInjectionValidator extends AbstractN4JSDeclarativeValidator
defMember.fpars.forEach[ann.holdsIsInjectableType(it)]
} else {
// method injection not supported yet
- addIssue(getMessageForDI_ANN_INJECT_METHOD_NOT_SUPPORTED_YET(),
- ann, N4JSPackage.eINSTANCE.annotation_Name,
- DI_ANN_INJECT_METHOD_NOT_SUPPORTED_YET)
+ addIssue(ann, N4JSPackage.eINSTANCE.annotation_Name,
+ DI_ANN_INJECT_METHOD_NOT_SUPPORTED_YET.toIssueItem())
}
}
};
@@ -680,8 +675,7 @@ class N4JSDependencyInjectionValidator extends AbstractN4JSDeclarativeValidator
val classDecl = getAnnotatedClass(ann);
val tClass = classDecl?.definedType;
if(tClass!==null && !requiredDef.hasAnnotation(tClass)) {
- addIssue(getMessageForDI_ANN_ONLY_ON_CLASS_ANNOTATED_WITH(ann.name,requiredDef.name),
- ann, N4JSPackage.eINSTANCE.annotation_Name, DI_ANN_ONLY_ON_CLASS_ANNOTATED_WITH);
+ addIssue(ann, N4JSPackage.eINSTANCE.annotation_Name, DI_ANN_ONLY_ON_CLASS_ANNOTATED_WITH.toIssueItem(ann.name,requiredDef.name));
return false;
}
return true;
@@ -697,8 +691,7 @@ class N4JSDependencyInjectionValidator extends AbstractN4JSDeclarativeValidator
val methodDecl = getAnnotatedMethod(ann);
val tClass = methodDecl?.definedType?.eContainer;
if(tClass instanceof TClass && !requiredDef.hasAnnotation(tClass as TClass)) {
- addIssue(getMessageForDI_ANN_ONLY_ON_METHOD_IN_CLASS_ANNOTATED_WITH(ann.name,requiredDef.name),
- ann, N4JSPackage.eINSTANCE.annotation_Name, DI_ANN_ONLY_ON_METHOD_IN_CLASS_ANNOTATED_WITH);
+ addIssue(ann, N4JSPackage.eINSTANCE.annotation_Name, DI_ANN_ONLY_ON_METHOD_IN_CLASS_ANNOTATED_WITH.toIssueItem(ann.name,requiredDef.name));
return false;
}
return true;
@@ -720,10 +713,9 @@ class N4JSDependencyInjectionValidator extends AbstractN4JSDeclarativeValidator
val nonInjectableParams = tMethod.fpars.filter[fpar| !(fpar.typeRef.isInjectableType)]
nonInjectableParams.forEach[fpar|
addIssue(
- getMessageForDI_NOT_INJECTABLE(fpar.typeRef.typeRefAsString, ''' at «fpar.name»'''),
fpar.astElement,
N4JSPackage.eINSTANCE.abstractVariable_Name,
- DI_NOT_INJECTABLE
+ DI_NOT_INJECTABLE.toIssueItem(fpar.typeRef.typeRefAsString, ''' at «fpar.name»''')
);
];
@@ -734,8 +726,7 @@ class N4JSDependencyInjectionValidator extends AbstractN4JSDeclarativeValidator
val retTR = tMethod.returnTypeRef
val isVoidOrOptional = TypeUtils.isVoid(retTR) || tMethod.isReturnValueOptional;
if(isVoidOrOptional) {
- addIssue(messageForDI_ANN_PROVIDES_METHOD_MUST_RETURN_VALUE,
- methodDecl, N4JSPackage.Literals.PROPERTY_NAME_OWNER__DECLARED_NAME, DI_ANN_PROVIDES_METHOD_MUST_RETURN_VALUE);
+ addIssue(methodDecl, N4JSPackage.Literals.PROPERTY_NAME_OWNER__DECLARED_NAME, DI_ANN_PROVIDES_METHOD_MUST_RETURN_VALUE.toIssueItem());
return false;
}
return ann.holdsIsInjectableType(tMethod.returnTypeRef)
@@ -754,8 +745,7 @@ class N4JSDependencyInjectionValidator extends AbstractN4JSDeclarativeValidator
}
val argTypeRef = if(arg instanceof TypeRefAnnotationArgument) arg.typeRef else null;
if(!isTypeRefToTClassAnnotatedWith(argTypeRef, requiredDef)) {
- addIssue(getMessageForDI_ANN_ARG_MUST_BE_ANNOTATED_WITH(ann.name,requiredDef.name),
- arg, DI_ANN_ARG_MUST_BE_ANNOTATED_WITH);
+ addIssue(arg, DI_ANN_ARG_MUST_BE_ANNOTATED_WITH.toIssueItem(ann.name,requiredDef.name));
return false;
}
return true;
@@ -780,7 +770,7 @@ class N4JSDependencyInjectionValidator extends AbstractN4JSDeclarativeValidator
val arg0TypeRef = ann.getArgAsTypeRef(0);
val arg1TypeRef = ann.getArgAsTypeRef(1);
if(arg0TypeRef!==null && arg1TypeRef!==null && !ts.subtypeSucceeded(G, arg1TypeRef,arg0TypeRef)) {
- addIssue(getMessageForDI_ANN_BIND_SECOND_MUST_BE_SUBTYPE_FIRST(ann.name), ann.args.get(1), DI_ANN_BIND_SECOND_MUST_BE_SUBTYPE_FIRST)
+ addIssue(ann.args.get(1), DI_ANN_BIND_SECOND_MUST_BE_SUBTYPE_FIRST.toIssueItem(ann.name))
return false;
}
return true;
@@ -795,9 +785,7 @@ class N4JSDependencyInjectionValidator extends AbstractN4JSDeclarativeValidator
return true;
}
if (isVariadicOrOptional) {
- addIssue(getMessageForDI_VARARGS_NOT_INJECTABLE(), astElement,
- N4JSPackage.eINSTANCE.abstractVariable_Name, DI_VARARGS_NOT_INJECTABLE
- );
+ addIssue(astElement, N4JSPackage.eINSTANCE.abstractVariable_Name, DI_VARARGS_NOT_INJECTABLE.toIssueItem());
return false;
}
return ann.holdsIsInjectableType(typeRef, name);
@@ -821,7 +809,7 @@ class N4JSDependencyInjectionValidator extends AbstractN4JSDeclarativeValidator
return false
}
if (!isConcrete(targetTypeRef)) {
- addIssue(getMessageForDI_ANN_BIND_ABSTRACT_TARGET(), bindAnn, N4JSPackage.eINSTANCE.annotation_Name, DI_ANN_BIND_ABSTRACT_TARGET);
+ addIssue(bindAnn, N4JSPackage.eINSTANCE.annotation_Name, DI_ANN_BIND_ABSTRACT_TARGET.toIssueItem());
return false
}
return true
@@ -861,7 +849,7 @@ class N4JSDependencyInjectionValidator extends AbstractN4JSDeclarativeValidator
}
if (!typeRef.isInjectableType) {
val description = if (null === name) '''''' else ''' at «name»''';
- addIssue(getMessageForDI_NOT_INJECTABLE(typeRef.typeRefAsString, description), ann, DI_NOT_INJECTABLE);
+ addIssue(ann, DI_NOT_INJECTABLE.toIssueItem(typeRef.typeRefAsString, description));
return false;
}
return true;
@@ -1019,7 +1007,7 @@ class N4JSDependencyInjectionValidator extends AbstractN4JSDeclarativeValidator
private def internalCheckAnnotationInjected(Annotation ann) {
val classDecl = getAnnotatedClass(ann);
if(!isInjectedApplicable(classDecl)){
- addIssue(getMessageForDI_ANN_INJECTED_NOT_APPLICABLE(), ann, N4JSPackage.eINSTANCE.annotation_Name, DI_ANN_INJECTED_NOT_APPLICABLE);
+ addIssue(ann, N4JSPackage.eINSTANCE.annotation_Name, DI_ANN_INJECTED_NOT_APPLICABLE.toIssueItem());
return
}
// val tClass = classDecl?.definedTypeAsClass;
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSDestructureValidator.xtend b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSDestructureValidator.xtend
index 6dfe3a58a4..398e869746 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSDestructureValidator.xtend
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSDestructureValidator.xtend
@@ -40,6 +40,7 @@ import org.eclipse.n4js.typesystem.utils.RuleEnvironmentExtensions
import org.eclipse.n4js.utils.DestructureHelper
import org.eclipse.n4js.validation.AbstractN4JSDeclarativeValidator
import org.eclipse.n4js.validation.IssueCodes
+import org.eclipse.n4js.validation.IssueItem
import org.eclipse.xtext.scoping.IScope
import org.eclipse.xtext.validation.Check
import org.eclipse.xtext.validation.EValidatorRegistrar
@@ -80,8 +81,7 @@ class N4JSDestructureValidator extends AbstractN4JSDeclarativeValidator {
ObjectBindingPattern: pattern.properties.empty
};
if(isEmpty) {
- val message = IssueCodes.messageForDESTRUCT_EMPTY_PATTERN;
- addIssue(message, pattern, IssueCodes.DESTRUCT_EMPTY_PATTERN);
+ addIssue(pattern, IssueCodes.DESTRUCT_EMPTY_PATTERN.toIssueItem());
}
}
@@ -94,8 +94,7 @@ class N4JSDestructureValidator extends AbstractN4JSDeclarativeValidator {
ObjectLiteral: lhs.propertyAssignments.filter(PropertyNameValuePair).empty
}
if(empty) {
- val message = IssueCodes.messageForDESTRUCT_EMPTY_PATTERN;
- addIssue(message, lhs, IssueCodes.DESTRUCT_EMPTY_PATTERN);
+ addIssue(lhs, IssueCodes.DESTRUCT_EMPTY_PATTERN.toIssueItem());
}
}
}
@@ -163,7 +162,7 @@ class N4JSDestructureValidator extends AbstractN4JSDeclarativeValidator {
if(errMsg.length>0) {
val astElement = node.astElement;
val issueCode = mDescRef.get().issueCode;
- if (Set.of(VIS_ILLEGAL_MEMBER_ACCESS, VIS_WRONG_READ_WRITE_ACCESS).contains(issueCode)) {
+ if (Set.of(VIS_ILLEGAL_MEMBER_ACCESS.name(), VIS_WRONG_READ_WRITE_ACCESS.name()).contains(issueCode)) {
if (astElement instanceof BindingProperty && !(astElement as BindingProperty).isSingleNameBinding) {
// handled elsewhere: var {fieldPublic: a, fieldPrivate: b} = cls;
return true;
@@ -174,15 +173,13 @@ class N4JSDestructureValidator extends AbstractN4JSDeclarativeValidator {
}
}
- val msg = getMessageForDESTRUCT_PROP_WITH_ERROR(node.propName, errMsg.toString.trim.trimSuffix('.'));
val astNodeOfPropName = node.getEObjectAndFeatureForPropName();
- addIssue(msg, astNodeOfPropName.key, astNodeOfPropName.value, DESTRUCT_PROP_WITH_ERROR);
+ addIssue(astNodeOfPropName.key, astNodeOfPropName.value, DESTRUCT_PROP_WITH_ERROR.toIssueItem(node.propName, errMsg.toString.trim.trimSuffix('.')));
return false;
}
else if(propTypeRef===null) {
- val msg = getMessageForDESTRUCT_PROP_MISSING(node.propName, valueTypePerNode.get(parentNode)?.typeRefAsString);
val astNodeOfPropName = node.getEObjectAndFeatureForPropName();
- addIssue(msg, astNodeOfPropName.key, astNodeOfPropName.value, DESTRUCT_PROP_MISSING);
+ addIssue(astNodeOfPropName.key, astNodeOfPropName.value, DESTRUCT_PROP_MISSING.toIssueItem(node.propName, valueTypePerNode.get(parentNode)?.typeRefAsString));
return false;
}
}
@@ -236,11 +233,11 @@ class N4JSDestructureValidator extends AbstractN4JSDeclarativeValidator {
"of property '"+node.propName+"'"
};
var tsMsg = result.failureMessage.trimPrefix('failed: ').trimSuffix('.');
- val msg = getMessageForDESTRUCT_TYPE_ERROR_VAR(varName, elemDesc, tsMsg);
+ val IssueItem issueItem = DESTRUCT_TYPE_ERROR_VAR.toIssueItem(varName, elemDesc, tsMsg);
if(node.varDecl!==null) {
- addIssue(msg, node.varDecl, N4JSPackage.eINSTANCE.abstractVariable_Name, DESTRUCT_TYPE_ERROR_VAR)
+ addIssue(node.varDecl, N4JSPackage.eINSTANCE.abstractVariable_Name, issueItem)
} else {
- addIssue(msg, node.varRef, DESTRUCT_TYPE_ERROR_VAR);
+ addIssue(node.varRef, issueItem);
}
return false;
}
@@ -274,25 +271,25 @@ class N4JSDestructureValidator extends AbstractN4JSDeclarativeValidator {
"a value of type '"+valueTypeRef.typeRefAsString+"'"
};
var tsMsg = result.failureMessage.trimPrefix('failed: ').trimSuffix('.');
- val msg = getMessageForDESTRUCT_TYPE_ERROR_PATTERN(patternKind, elemDesc, tsMsg);
+ val IssueItem issueItem = DESTRUCT_TYPE_ERROR_PATTERN.toIssueItem(patternKind, elemDesc, tsMsg);
val astElem = node.astElement;
switch(astElem) {
PropertyNameValuePair:
- addIssue(msg, astElem, N4JSPackage.eINSTANCE.propertyNameValuePair_Expression, DESTRUCT_TYPE_ERROR_PATTERN)
+ addIssue(astElem, N4JSPackage.eINSTANCE.propertyNameValuePair_Expression, issueItem)
BindingProperty:
- addIssue(msg, astElem, N4JSPackage.eINSTANCE.bindingProperty_Value, DESTRUCT_TYPE_ERROR_PATTERN)
+ addIssue(astElem, N4JSPackage.eINSTANCE.bindingProperty_Value, issueItem)
VariableBinding:
- addIssue(msg, astElem, N4JSPackage.eINSTANCE.variableBinding_Pattern, DESTRUCT_TYPE_ERROR_PATTERN)
+ addIssue(astElem, N4JSPackage.eINSTANCE.variableBinding_Pattern, issueItem)
AssignmentExpression:
- addIssue(msg, astElem, N4JSPackage.eINSTANCE.assignmentExpression_Lhs, DESTRUCT_TYPE_ERROR_PATTERN)
+ addIssue(astElem, N4JSPackage.eINSTANCE.assignmentExpression_Lhs, issueItem)
ForStatement case !astElem.varDeclsOrBindings.empty:
- addIssue(msg, astElem, N4JSPackage.eINSTANCE.variableDeclarationContainer_VarDeclsOrBindings, DESTRUCT_TYPE_ERROR_PATTERN)
+ addIssue(astElem, N4JSPackage.eINSTANCE.variableDeclarationContainer_VarDeclsOrBindings, issueItem)
ForStatement case astElem.initExpr !== null:
- addIssue(msg, astElem, N4JSPackage.eINSTANCE.forStatement_InitExpr, DESTRUCT_TYPE_ERROR_PATTERN)
+ addIssue(astElem, N4JSPackage.eINSTANCE.forStatement_InitExpr, issueItem)
ForStatement case astElem.expression !== null:
- addIssue(msg, astElem, N4JSPackage.eINSTANCE.iterationStatement_Expression, DESTRUCT_TYPE_ERROR_PATTERN)
+ addIssue(astElem, N4JSPackage.eINSTANCE.iterationStatement_Expression, issueItem)
default:
- addIssue(msg, astElem, DESTRUCT_TYPE_ERROR_PATTERN)
+ addIssue(astElem, issueItem)
}
return false;
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSEnumValidator.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSEnumValidator.java
index 91b5fedf02..5cceabf23c 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSEnumValidator.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSEnumValidator.java
@@ -12,8 +12,6 @@
import static org.eclipse.n4js.validation.IssueCodes.ENM_DUPLICTAE_LITERALS;
import static org.eclipse.n4js.validation.IssueCodes.ENM_LITERALS_HIDE_META;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForENM_DUPLICTAE_LITERALS;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForENM_LITERALS_HIDE_META;
import static org.eclipse.n4js.validation.validators.StaticPolyfillValidatorExtension.internalCheckNotInStaticPolyfillModule;
import java.math.BigDecimal;
@@ -21,7 +19,6 @@
import java.util.stream.Collectors;
import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.n4js.AnnotationDefinition;
import org.eclipse.n4js.n4JS.IdentifierRef;
import org.eclipse.n4js.n4JS.N4EnumDeclaration;
@@ -68,8 +65,8 @@ public void register(EValidatorRegistrar registrar) {
public void checkEnumAnnotations(N4EnumDeclaration n4EnumDecl) {
if (AnnotationDefinition.NUMBER_BASED.hasAnnotation(n4EnumDecl)
&& AnnotationDefinition.STRING_BASED.hasAnnotation(n4EnumDecl)) {
- addIssue(IssueCodes.getMessageForENM_BOTH_NUMBER_AND_STRING_BASED(), n4EnumDecl,
- N4JSPackage.Literals.N4_TYPE_DECLARATION__NAME, IssueCodes.ENM_BOTH_NUMBER_AND_STRING_BASED);
+ addIssue(n4EnumDecl, N4JSPackage.Literals.N4_TYPE_DECLARATION__NAME,
+ IssueCodes.ENM_BOTH_NUMBER_AND_STRING_BASED);
}
}
@@ -96,18 +93,16 @@ public void checkNamesOfEnumLiterals(N4EnumDeclaration n4EnumDeclaration) {
// check enum literals duplicates
if (literals.size() > 1) {
- addIssue(getMessageForENM_DUPLICTAE_LITERALS(name), literals.get(0),
- N4JSPackage.Literals.N4_ENUM_LITERAL__NAME,
- ENM_DUPLICTAE_LITERALS);
+ addIssue(literals.get(0), N4JSPackage.Literals.N4_ENUM_LITERAL__NAME,
+ ENM_DUPLICTAE_LITERALS, name);
return;// one issue at the time!
}
// check enum literal name clash with meta property
if (builtInEnumMembersNames.contains(name)) {
- addIssue(getMessageForENM_LITERALS_HIDE_META(name), literals.get(0),
- N4JSPackage.Literals.N4_ENUM_LITERAL__NAME,
- ENM_LITERALS_HIDE_META);
+ addIssue(literals.get(0), N4JSPackage.Literals.N4_ENUM_LITERAL__NAME,
+ ENM_LITERALS_HIDE_META, name);
}
});
}
@@ -149,14 +144,12 @@ public void checkValuesOfEnumLiterals(N4EnumDeclaration n4EnumDecl) {
boolean isNumeric = actualValue instanceof BigDecimal;
if (enumKind == EnumKind.NumberBased) {
if (!isNumeric) {
- addIssue(IssueCodes.getMessageForENM_ILLEGAL_STRING_VALUE(), literal,
- N4JSPackage.Literals.N4_ENUM_LITERAL__VALUE_EXPRESSION,
+ addIssue(literal, N4JSPackage.Literals.N4_ENUM_LITERAL__VALUE_EXPRESSION,
IssueCodes.ENM_ILLEGAL_STRING_VALUE);
}
} else {
if (isNumeric) {
- addIssue(IssueCodes.getMessageForENM_ILLEGAL_NUMERIC_VALUE(), literal,
- N4JSPackage.Literals.N4_ENUM_LITERAL__VALUE_EXPRESSION,
+ addIssue(literal, N4JSPackage.Literals.N4_ENUM_LITERAL__VALUE_EXPRESSION,
IssueCodes.ENM_ILLEGAL_NUMERIC_VALUE);
}
}
@@ -210,14 +203,7 @@ public void checkUsageOfNumberOrStringBasedEnum(IdentifierRef identRef) {
}
}
// invalid usage!
- addIssue(IssueCodes.getMessageForENM_INVALID_USE_OF_NUM_OR_STR_BASED_ENUM(), identRef,
- IssueCodes.ENM_INVALID_USE_OF_NUM_OR_STR_BASED_ENUM);
+ addIssue(identRef, IssueCodes.ENM_INVALID_USE_OF_NUM_OR_STR_BASED_ENUM);
}
- // publish
- @Override
- public void addIssue(String message, EObject source, EStructuralFeature feature, String issueCode,
- String... issueData) {
- super.addIssue(message, source, feature, issueCode, issueData);
- }
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSExpressionValidator.xtend b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSExpressionValidator.xtend
index 55c4154ed6..75b37b8066 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSExpressionValidator.xtend
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSExpressionValidator.xtend
@@ -37,6 +37,7 @@ import org.eclipse.n4js.n4JS.EqualityExpression
import org.eclipse.n4js.n4JS.EqualityOperator
import org.eclipse.n4js.n4JS.Expression
import org.eclipse.n4js.n4JS.ExpressionStatement
+import org.eclipse.n4js.n4JS.ExpressionWithTarget
import org.eclipse.n4js.n4JS.IdentifierRef
import org.eclipse.n4js.n4JS.IndexedAccessExpression
import org.eclipse.n4js.n4JS.LiteralOrComputedPropertyName
@@ -126,6 +127,7 @@ import org.eclipse.n4js.utils.N4JSLanguageUtils.EnumKind
import org.eclipse.n4js.utils.PromisifyHelper
import org.eclipse.n4js.validation.AbstractN4JSDeclarativeValidator
import org.eclipse.n4js.validation.IssueCodes
+import org.eclipse.n4js.validation.IssueItem
import org.eclipse.n4js.validation.JavaScriptVariantHelper
import org.eclipse.n4js.validation.N4JSElementKeywordProvider
import org.eclipse.n4js.validation.ValidatorMessageHelper
@@ -139,7 +141,6 @@ import org.eclipse.xtext.validation.EValidatorRegistrar
import static org.eclipse.n4js.validation.IssueCodes.*
import static extension org.eclipse.n4js.typesystem.utils.RuleEnvironmentExtensions.*
-import org.eclipse.n4js.n4JS.ExpressionWithTarget
/**
*/
@@ -178,8 +179,8 @@ class N4JSExpressionValidator extends AbstractN4JSDeclarativeValidator {
@Check
def checkAwaitExpression(AwaitExpression awaitExpression) {
if (!N4JSLanguageUtils.isValidLocationForAwait(awaitExpression)) {
- val message = IssueCodes.getMessageForEXP_MISPLACED_AWAIT("await", "async");
- addIssue(message, awaitExpression, IssueCodes.EXP_MISPLACED_AWAIT);
+ val IssueItem issueItem = EXP_MISPLACED_AWAIT.toIssueItem("await", "async");
+ addIssue(awaitExpression, issueItem);
}
if( awaitExpression.getExpression() === null ){
@@ -215,12 +216,10 @@ class N4JSExpressionValidator extends AbstractN4JSDeclarativeValidator {
val boolean isUndef = typeRef.declaredType == G.undefinedType;
val boolean isNull = typeRef.declaredType == G.nullType;
if (!stUnions) {
- val message = IssueCodes.getMessageForEXP_AWAIT_NON_ASYNC();
- addIssue(message, awaitExpression, IssueCodes.EXP_AWAIT_NON_ASYNC);
+ addIssue(awaitExpression, EXP_AWAIT_NON_ASYNC.toIssueItem());
}
if (isUndef || isNull) {
- val message = IssueCodes.getMessageForEXP_AWAIT_NON_ASYNC_SPECIAL(typeRef.declaredType.name);
- addIssue(message, awaitExpression, IssueCodes.EXP_AWAIT_NON_ASYNC_SPECIAL);
+ addIssue(awaitExpression, EXP_AWAIT_NON_ASYNC_SPECIAL.toIssueItem(typeRef.declaredType.name));
}
}
@@ -259,10 +258,9 @@ class N4JSExpressionValidator extends AbstractN4JSDeclarativeValidator {
val G = propAccessExpr.newRuleEnvironment;
val targetTypeRef = ts.type(G, propAccessExpr.target);
if(!ts.subtypeSucceeded(G, targetTypeRef, declThisTypeRef)) {
- val msg = IssueCodes.getMessageForEXP_ACCESS_INVALID_TYPE_OF_TARGET(prop.description,
+ val IssueItem issueItem = EXP_ACCESS_INVALID_TYPE_OF_TARGET.toIssueItem(prop.description,
targetTypeRef.typeRefAsString, declThisTypeRef.typeRefAsString);
- addIssue(msg, propAccessExpr, N4JSPackage.eINSTANCE.parameterizedPropertyAccessExpression_Property,
- IssueCodes.TYS_NO_SUBTYPE);
+ addIssue(propAccessExpr, N4JSPackage.eINSTANCE.parameterizedPropertyAccessExpression_Property, issueItem);
}
}
}
@@ -332,10 +330,10 @@ class N4JSExpressionValidator extends AbstractN4JSDeclarativeValidator {
return
}
// no more whitelist checks
- val message = IssueCodes.getMessageForEXP_METHOD_REF_UNATTACHED_FROM_RECEIVER(method.name);
+ val message = EXP_METHOD_REF_UNATTACHED_FROM_RECEIVER.getMessage(method.name);
val source = propAccessExpression
val feature = N4JSPackage.eINSTANCE.parameterizedPropertyAccessExpression_Property
- warning(message, source, feature, IssueCodes.EXP_METHOD_REF_UNATTACHED_FROM_RECEIVER);
+ warning(message, source, feature, EXP_METHOD_REF_UNATTACHED_FROM_RECEIVER.name());
}
private def boolean isMethodEffectivelyFinal(TMethod method) {
@@ -364,10 +362,8 @@ class N4JSExpressionValidator extends AbstractN4JSDeclarativeValidator {
val targetIdRef = if (target instanceof IdentifierRef) target else null;
val isExceptionCase = target instanceof ThisLiteral; // avoid duplicate error messages
if (targetIdRef?.id !== prop.eContainer && !isExceptionCase) {
- val message = IssueCodes.getMessageForCLF_INVALID_ACCESS_OF_STATIC_MEMBER_OF_INTERFACE;
- addIssue(message, propAccessExpr,
- N4JSPackage.Literals.EXPRESSION_WITH_TARGET__TARGET,
- IssueCodes.CLF_INVALID_ACCESS_OF_STATIC_MEMBER_OF_INTERFACE);
+ addIssue(propAccessExpr, N4JSPackage.Literals.EXPRESSION_WITH_TARGET__TARGET,
+ CLF_INVALID_ACCESS_OF_STATIC_MEMBER_OF_INTERFACE.toIssueItem());
}
}
}
@@ -395,19 +391,18 @@ class N4JSExpressionValidator extends AbstractN4JSDeclarativeValidator {
if (!isCallable && !(callExpression.target instanceof SuperLiteral)) {
if (callablesCount > 1) {
val callableTypeRefsAsStr = callables.map[callableTypeRef.typeRefAsString].join(", ");
- val message = IssueCodes.getMessageForEXP_CALL_CONFLICT_IN_INTERSECTION(callableTypeRefsAsStr);
- addIssue(message, callExpression.target, null, IssueCodes.EXP_CALL_CONFLICT_IN_INTERSECTION);
+ val IssueItem issueItem = EXP_CALL_CONFLICT_IN_INTERSECTION.toIssueItem(callableTypeRefsAsStr);
+ addIssue(callExpression.target, issueItem);
} else if (tsh.isClassConstructorFunction(G, typeRef) || isClassifierTypeRefToAbstractClass(G, typeRef)) {
- val message = IssueCodes.getMessageForEXP_CALL_CLASS_CTOR;
- addIssue(message, callExpression.target, null, IssueCodes.EXP_CALL_CLASS_CTOR);
+ addIssue(callExpression.target, EXP_CALL_CLASS_CTOR.toIssueItem());
} else {
val staticType = if (typeRef instanceof TypeTypeRef) tsh.getStaticType(G, typeRef);
if (staticType instanceof TInterface && tsh.getCallSignature(callExpression.eResource, TypeUtils.createTypeRef(staticType)) !== null) {
- val message = IssueCodes.getMessageForEXP_CALL_CONSTRUCT_SIG_OF_INTERFACE_DIRECTLY_USED("invoke", staticType.name, "call");
- addIssue(message, callExpression.target, null, IssueCodes.EXP_CALL_CONSTRUCT_SIG_OF_INTERFACE_DIRECTLY_USED);
+ val IssueItem issueItem = EXP_CALL_CONSTRUCT_SIG_OF_INTERFACE_DIRECTLY_USED.toIssueItem("invoke", staticType.name, "call");
+ addIssue(callExpression.target, issueItem);
} else {
- val message = IssueCodes.getMessageForEXP_CALL_NOT_A_FUNCTION(typeRef.typeRefAsString);
- addIssue(message, callExpression.target, null, IssueCodes.EXP_CALL_NOT_A_FUNCTION);
+ val IssueItem issueItem = EXP_CALL_NOT_A_FUNCTION.toIssueItem(typeRef.typeRefAsString);
+ addIssue(callExpression.target, issueItem);
}
}
return;
@@ -473,8 +468,7 @@ class N4JSExpressionValidator extends AbstractN4JSDeclarativeValidator {
}
val shouldWarn = !isPromiseExplict;
if (shouldWarn) {
- val message = IssueCodes.getMessageForEXP_MISSNG_AWAIT_FOR_ASYNC_TARGET();
- addIssue(message, callExpression.target, IssueCodes.EXP_MISSNG_AWAIT_FOR_ASYNC_TARGET);
+ addIssue(callExpression.target, IssueCodes.EXP_MISSNG_AWAIT_FOR_ASYNC_TARGET.toIssueItem());
}
}
@@ -565,9 +559,8 @@ class N4JSExpressionValidator extends AbstractN4JSDeclarativeValidator {
val newables = tsh.getNewableTypeRefs(G, typeRef, newExpression, false);
if (newables.size > 1) {
val newableTypeRefsAsStr = newables.map[newableTypeRef.typeRefAsString].join(", ");
- val message = IssueCodes.getMessageForEXP_NEW_CONFLICT_IN_INTERSECTION(newableTypeRefsAsStr);
- addIssue(message, newExpression, N4JSPackage.eINSTANCE.newExpression_Callee,
- IssueCodes.EXP_NEW_CONFLICT_IN_INTERSECTION);
+ addIssue(newExpression, N4JSPackage.eINSTANCE.newExpression_Callee,
+ EXP_NEW_CONFLICT_IN_INTERSECTION.toIssueItem(newableTypeRefsAsStr));
return;
} else if (newables.size === 1) {
// special success case; but perform some further checks
@@ -603,54 +596,45 @@ class N4JSExpressionValidator extends AbstractN4JSDeclarativeValidator {
|| (staticType instanceof TClassifier && N4JSLanguageUtils.hasCovariantConstructor(staticType as TClassifier, declMergingHelper));
if (staticType === G.symbolObjectType) {
// error case #1: new Symbol()
- val message = IssueCodes.messageForBIT_SYMBOL_NOT_A_CTOR;
- addIssue(message, newExpression, N4JSPackage.eINSTANCE.newExpression_Callee,
- IssueCodes.BIT_SYMBOL_NOT_A_CTOR);
+ addIssue(newExpression, N4JSPackage.eINSTANCE.newExpression_Callee, BIT_SYMBOL_NOT_A_CTOR.toIssueItem());
return;
} else if (!isCtor && staticType instanceof TInterface && isDirectRef) {
// error case #2: trying to instantiate an interface
val tInterface = staticType as TInterface;
if (tInterface.constructSignature !== null) {
// special case: trying to directly instantiate an interface with a construct signature
- val message = IssueCodes.getMessageForEXP_CALL_CONSTRUCT_SIG_OF_INTERFACE_DIRECTLY_USED("instantiate", staticType.name, "construct");
- addIssue(message, newExpression, N4JSPackage.eINSTANCE.newExpression_Callee,
- IssueCodes.EXP_CALL_CONSTRUCT_SIG_OF_INTERFACE_DIRECTLY_USED);
+ val IssueItem issueItem = EXP_CALL_CONSTRUCT_SIG_OF_INTERFACE_DIRECTLY_USED.toIssueItem("instantiate", staticType.name, "construct");
+ addIssue(newExpression, N4JSPackage.eINSTANCE.newExpression_Callee, issueItem);
return;
}
- val message = IssueCodes.getMessageForEXP_NEW_CANNOT_INSTANTIATE(staticType.keyword, staticType.name);
- addIssue(message, newExpression, N4JSPackage.eINSTANCE.newExpression_Callee,
- IssueCodes.EXP_NEW_CANNOT_INSTANTIATE);
+ val IssueItem issueItem = EXP_NEW_CANNOT_INSTANTIATE.toIssueItem(staticType.keyword, staticType.name);
+ addIssue(newExpression, N4JSPackage.eINSTANCE.newExpression_Callee, issueItem);
return;
} else if (!isCtor && staticType instanceof TClass && (staticType as TClass).abstract && isDirectRef) {
// error case #3: trying to instantiate an abstract class
- val message = IssueCodes.getMessageForEXP_NEW_CANNOT_INSTANTIATE("abstract class", staticType.name);
- addIssue(message, newExpression, N4JSPackage.eINSTANCE.newExpression_Callee,
- IssueCodes.EXP_NEW_CANNOT_INSTANTIATE);
+ val IssueItem issueItem = EXP_NEW_CANNOT_INSTANTIATE.toIssueItem("abstract class", staticType.name);
+ addIssue(newExpression, N4JSPackage.eINSTANCE.newExpression_Callee, issueItem);
return;
} else if (isCtor && !isConcreteOrCovariant && staticType instanceof TClassifier) {
// error case #4: trying to instantiate "constructor{? extends C}", with C not having @CovariantConstructor
- val message = IssueCodes.getMessageForEXP_NEW_WILDCARD_NO_COVARIANT_CTOR(typeArg.typeRefAsString, staticType.typeAsString);
- addIssue(message, newExpression, N4JSPackage.eINSTANCE.newExpression_Callee,
- IssueCodes.EXP_NEW_WILDCARD_NO_COVARIANT_CTOR);
+ val IssueItem issueItem = EXP_NEW_WILDCARD_NO_COVARIANT_CTOR.toIssueItem(typeArg.typeRefAsString, staticType.typeAsString);
+ addIssue(newExpression, N4JSPackage.eINSTANCE.newExpression_Callee, issueItem);
return;
} else if (staticType instanceof TEnum) {
// error case #5: trying to instantiate an enum
- val message = IssueCodes.getMessageForEXP_NEW_CANNOT_INSTANTIATE("enum", staticType.name);
- addIssue(message, newExpression, N4JSPackage.eINSTANCE.newExpression_Callee,
- IssueCodes.EXP_NEW_CANNOT_INSTANTIATE);
+ val IssueItem issueItem = EXP_NEW_CANNOT_INSTANTIATE.toIssueItem("enum", staticType.name);
+ addIssue(newExpression, N4JSPackage.eINSTANCE.newExpression_Callee, issueItem);
return;
} else if (staticType instanceof TypeVariable ) {
// error case #6: trying to instantiate a type variable
- val message = IssueCodes.getMessageForEXP_NEW_CANNOT_INSTANTIATE("type variable", staticType.name);
- addIssue(message, newExpression, N4JSPackage.eINSTANCE.newExpression_Callee,
- IssueCodes.EXP_NEW_CANNOT_INSTANTIATE);
+ val IssueItem issueItem = EXP_NEW_CANNOT_INSTANTIATE.toIssueItem("type variable", staticType.name);
+ addIssue(newExpression, N4JSPackage.eINSTANCE.newExpression_Callee, issueItem);
return;
} else if (staticType === null || !isCtor || !isConcreteOrCovariant) {
// remaining cases
val name = typeRef.typeRefAsString;
- val message = IssueCodes.getMessageForEXP_NEW_WILDCARD_OR_TYPEVAR(name);
- addIssue(message, newExpression, N4JSPackage.eINSTANCE.newExpression_Callee,
- IssueCodes.EXP_NEW_WILDCARD_OR_TYPEVAR);
+ val IssueItem issueItem = EXP_NEW_WILDCARD_OR_TYPEVAR.toIssueItem(name);
+ addIssue(newExpression, N4JSPackage.eINSTANCE.newExpression_Callee, issueItem);
return;
}
@@ -677,8 +661,8 @@ class N4JSExpressionValidator extends AbstractN4JSDeclarativeValidator {
val container = constructSig?.eContainer;
if (container instanceof TInterface) { // avoid checking accessibility of construct signatures in StructuralTypeRefs/TStructuralTypes (they're always public)
if (!memberVisibilityChecker.isVisible(newExpression, calleeTypeRef, constructSig).visibility) {
- val message = IssueCodes.getMessageForVIS_NEW_CANNOT_INSTANTIATE_INVISIBLE_CONSTRUCTOR("construct signature", container.name);
- addIssue(message, newExpression, N4JSPackage.eINSTANCE.newExpression_Callee, IssueCodes.VIS_NEW_CANNOT_INSTANTIATE_INVISIBLE_CONSTRUCTOR);
+ val IssueItem issueItem = VIS_NEW_CANNOT_INSTANTIATE_INVISIBLE_CONSTRUCTOR.toIssueItem("construct signature", container.name);
+ addIssue(newExpression, N4JSPackage.eINSTANCE.newExpression_Callee, issueItem);
return false;
}
}
@@ -703,8 +687,8 @@ class N4JSExpressionValidator extends AbstractN4JSDeclarativeValidator {
/** Helper to issue the error case of having a new-expression on a non-constructor element */
private def issueNotACtor(TypeRef typeRef, NewExpression newExpression) {
- val message = IssueCodes.getMessageForEXP_NEW_NOT_A_CTOR(typeRef.typeRefAsString);
- addIssue(message, newExpression, N4JSPackage.eINSTANCE.newExpression_Callee, IssueCodes.EXP_NEW_NOT_A_CTOR)
+ val IssueItem issueItem = EXP_NEW_NOT_A_CTOR.toIssueItem(typeRef.typeRefAsString);
+ addIssue(newExpression, N4JSPackage.eINSTANCE.newExpression_Callee, issueItem);
}
/**
@@ -720,10 +704,8 @@ class N4JSExpressionValidator extends AbstractN4JSDeclarativeValidator {
val staticType = tsh.getStaticType(G, typeRef);
if (staticType instanceof TN4Classifier) {
if (staticType instanceof TInterface && N4Scheme.isFromResourceWithN4Scheme(staticType)) {
- val message = IssueCodes.
- getMessageForTYS_INSTANCEOF_NOT_SUPPORTED_FOR_BUILT_IN_INTERFACES(staticType.name);
- addIssue(message, relationalExpression, N4JSPackage.eINSTANCE.relationalExpression_Rhs,
- IssueCodes.TYS_INSTANCEOF_NOT_SUPPORTED_FOR_BUILT_IN_INTERFACES);
+ val IssueItem issueItem = TYS_INSTANCEOF_NOT_SUPPORTED_FOR_BUILT_IN_INTERFACES.toIssueItem(staticType.name);
+ addIssue(relationalExpression, N4JSPackage.eINSTANCE.relationalExpression_Rhs, issueItem);
}
}
}
@@ -735,9 +717,8 @@ class N4JSExpressionValidator extends AbstractN4JSDeclarativeValidator {
val rhsTypeRef = ts.tau((innerExpression instanceof UnaryExpression) ? innerExpression.expression : innerExpression);
if (!RuleEnvironmentExtensions.isNumeric(G, rhsTypeRef)) {
- val message = IssueCodes.getMessageForTYS_INSTANCEOF_NOT_SUPPORTED_FOR_USE_SITE_STRUCTURAL();
- addIssue(message, relationalExpression, N4JSPackage.eINSTANCE.relationalExpression_Rhs,
- IssueCodes.TYS_INSTANCEOF_NOT_SUPPORTED_FOR_USE_SITE_STRUCTURAL);
+ addIssue(relationalExpression, N4JSPackage.eINSTANCE.relationalExpression_Rhs,
+ TYS_INSTANCEOF_NOT_SUPPORTED_FOR_USE_SITE_STRUCTURAL.toIssueItem());
}
}
}
@@ -780,11 +761,9 @@ class N4JSExpressionValidator extends AbstractN4JSDeclarativeValidator {
val setterExists = containerTypesHelper.fromContext(expression).members(declaredType).filter(
TSetter).exists[name.equals(property.name)]
if (!setterExists) {
- val msg = IssueCodes.getMessageForTYS_PROPERTY_HAS_NO_SETTER(property.name)
- addIssue(msg, expression,
- N4JSPackage.Literals.PARAMETERIZED_PROPERTY_ACCESS_EXPRESSION__PROPERTY,
- IssueCodes.TYS_PROPERTY_HAS_NO_SETTER);
- return false;
+ addIssue(expression, N4JSPackage.Literals.PARAMETERIZED_PROPERTY_ACCESS_EXPRESSION__PROPERTY,
+ IssueCodes.TYS_PROPERTY_HAS_NO_SETTER.toIssueItem(property.name));
+ return false;
}
}
}
@@ -804,8 +783,7 @@ class N4JSExpressionValidator extends AbstractN4JSDeclarativeValidator {
val module = EcoreUtil2.getContainerOfType(expression, Script).module;
if (id.containingModule != module) {
// imported variable, class, etc.
- addIssue(IssueCodes.getMessageForIMP_IMPORTED_ELEMENT_READ_ONLY(expression.idAsText),
- expression, IssueCodes.IMP_IMPORTED_ELEMENT_READ_ONLY);
+ addIssue(expression, IMP_IMPORTED_ELEMENT_READ_ONLY.toIssueItem(expression.idAsText));
return false;
}
}
@@ -831,8 +809,7 @@ class N4JSExpressionValidator extends AbstractN4JSDeclarativeValidator {
val importedElmentText = NodeModelUtils.getTokenText(
NodeModelUtils.findActualNodeFor(expression));
- addIssue(IssueCodes.getMessageForIMP_IMPORTED_ELEMENT_READ_ONLY(importedElmentText),
- expression, IssueCodes.IMP_IMPORTED_ELEMENT_READ_ONLY);
+ addIssue(expression, IMP_IMPORTED_ELEMENT_READ_ONLY.toIssueItem(importedElmentText));
return false;
}
}
@@ -890,11 +867,9 @@ class N4JSExpressionValidator extends AbstractN4JSDeclarativeValidator {
Expression expr) {
val cmp = compareNumberOfArgsWithNumberOfFPars(fpars, args);
if (cmp < 0) { // too few
- addIssue(IssueCodes.getMessageForEXP_NUM_OF_ARGS_TOO_FEW(fpars.size, args.size), expr,
- IssueCodes.EXP_NUM_OF_ARGS_TOO_FEW);
+ addIssue(expr, EXP_NUM_OF_ARGS_TOO_FEW.toIssueItem(fpars.size, args.size));
} else if (cmp > 0) { // too many
- addIssue(IssueCodes.getMessageForEXP_NUM_OF_ARGS_TOO_MANY(fpars.size, args.size), expr,
- IssueCodes.EXP_NUM_OF_ARGS_TOO_MANY);
+ addIssue(expr, EXP_NUM_OF_ARGS_TOO_MANY.toIssueItem(fpars.size, args.size));
}
}
@@ -1000,21 +975,15 @@ class N4JSExpressionValidator extends AbstractN4JSDeclarativeValidator {
def issueMathResultIsConstant(String operand, String constResult, Expression location) {
- addIssue(IssueCodes.getMessageForEXP_MATH_OPERATION_RESULT_IS_CONSTANT(operand, constResult),
- location,
- IssueCodes.EXP_MATH_OPERATION_RESULT_IS_CONSTANT);
+ addIssue(location, EXP_MATH_OPERATION_RESULT_IS_CONSTANT.toIssueItem(operand, constResult));
}
def issueMathOperandIsConstant(String operandType, String constValue, Expression location) {
- addIssue(IssueCodes.getMessageForEXP_MATH_OPERAND_IS_CONSTANT(operandType, constValue),
- location,
- IssueCodes.EXP_MATH_OPERAND_IS_CONSTANT);
+ addIssue(location, EXP_MATH_OPERAND_IS_CONSTANT.toIssueItem(operandType, constValue));
}
def issueMathOperandTypeNotPermitted(String operandType, Expression location) {
- addIssue(IssueCodes.getMessageForEXP_MATH_TYPE_NOT_PERMITTED(operandType),
- location,
- IssueCodes.EXP_MATH_TYPE_NOT_PERMITTED);
+ addIssue(location, EXP_MATH_TYPE_NOT_PERMITTED.toIssueItem(operandType));
}
@@ -1079,10 +1048,7 @@ class N4JSExpressionValidator extends AbstractN4JSDeclarativeValidator {
if (! (leftSubOfRight || rightSubOfLeft)) {
// no subtype-relationship found, issue warning:
- addIssue(
- IssueCodes.
- getMessageForEXP_WARN_CONSTANT_EQUALITY_TEST(tlhs.warningNameOf, trhs.warningNameOf,
- ee.op === EqualityOperator::NSAME), ee, IssueCodes.EXP_WARN_CONSTANT_EQUALITY_TEST);
+ addIssue(ee, EXP_WARN_CONSTANT_EQUALITY_TEST.toIssueItem(tlhs.warningNameOf, trhs.warningNameOf, ee.op === EqualityOperator::NSAME));
}
}
@@ -1196,11 +1162,7 @@ class N4JSExpressionValidator extends AbstractN4JSDeclarativeValidator {
if (forbidden !== null) {
val theType = ts.tau(e)?.declaredType
if (theType === forbidden) {
- addIssue(
- IssueCodes.getMessageForEXP_FORBIDDEN_TYPE_IN_BINARY_LOGICAL_EXPRESSION(typeName),
- e,
- IssueCodes.EXP_FORBIDDEN_TYPE_IN_BINARY_LOGICAL_EXPRESSION
- );
+ addIssue(e, EXP_FORBIDDEN_TYPE_IN_BINARY_LOGICAL_EXPRESSION.toIssueItem(typeName));
}
}
}
@@ -1249,11 +1211,11 @@ class N4JSExpressionValidator extends AbstractN4JSDeclarativeValidator {
msg1 = "false";
msg2 = "right-hand";
}
- addIssue(IssueCodes.getMessageForEXP_WARN_DISPENSABLE_CONDITIONAL_EXPRESSION(
+ val IssueItem issueItem = EXP_WARN_DISPENSABLE_CONDITIONAL_EXPRESSION.toIssueItem(
NodeModelUtils.findActualNodeFor(expressionToCheck).text.trim,
msg1,
- msg2
- ), expressionToCheck, IssueCodes.EXP_WARN_DISPENSABLE_CONDITIONAL_EXPRESSION);
+ msg2);
+ addIssue(expressionToCheck, issueItem);
}
@@ -1312,8 +1274,8 @@ class N4JSExpressionValidator extends AbstractN4JSDeclarativeValidator {
if (BooleanExtensions::xor(S.isDynamic, T.isDynamic)) return;
if (ts.subtypeSucceeded(G, S, T)) { // Constraint 81.2 (Cast Validation At Compile-Time): 1
- addIssue(IssueCodes.getMessageForEXP_CAST_UNNECESSARY(S.typeRefAsString, T.typeRefAsString),
- castExpression, IssueCodes.EXP_CAST_UNNECESSARY);
+ val IssueItem issueItem = EXP_CAST_UNNECESSARY.toIssueItem(S.typeRefAsString, T.typeRefAsString);
+ addIssue(castExpression, issueItem);
} else {
val specialChecks = (T.declaredType instanceof ContainerType>)
|| (T.declaredType instanceof PrimitiveType)
@@ -1329,7 +1291,7 @@ class N4JSExpressionValidator extends AbstractN4JSDeclarativeValidator {
internalCheckCastExpression(G, S, T, castExpression, true, false);
} else {
// Constraint 78 (Cast Validation At Compile-Time): 2
- addIssue(IssueCodes.getMessageForEXP_CAST_INVALID_TARGET(), castExpression, IssueCodes.EXP_CAST_INVALID_TARGET);
+ addIssue(castExpression, EXP_CAST_INVALID_TARGET.toIssueItem());
}
}
}
@@ -1365,8 +1327,7 @@ class N4JSExpressionValidator extends AbstractN4JSDeclarativeValidator {
internalCheckCastExpression(G, S, it, castExpression, false, actualSourceTypeIsCPOE)
]) {
if (addIssues) {
- addIssue(IssueCodes.getMessageForEXP_CAST_FAILED(S.typeRefAsString, T.typeRefAsString),
- castExpression, IssueCodes.EXP_CAST_FAILED);
+ addIssue(castExpression, EXP_CAST_FAILED.toIssueItem(S.typeRefAsString, T.typeRefAsString));
}
return false;
}
@@ -1375,8 +1336,7 @@ class N4JSExpressionValidator extends AbstractN4JSDeclarativeValidator {
internalCheckCastExpression(G, S, it, castExpression, false, actualSourceTypeIsCPOE)
]) {
if (addIssues) {
- addIssue(IssueCodes.getMessageForEXP_CAST_FAILED(S.typeRefAsString, T.typeRefAsString),
- castExpression, IssueCodes.EXP_CAST_FAILED);
+ addIssue(castExpression, EXP_CAST_FAILED.toIssueItem(S.typeRefAsString, T.typeRefAsString));
}
return false;
}
@@ -1389,8 +1349,7 @@ class N4JSExpressionValidator extends AbstractN4JSDeclarativeValidator {
] && ! S.typeRefs.exists[ts.subtypeSucceeded(G, it, T)] // one type in composed is a subtype of target
) {
if (addIssues) {
- addIssue(IssueCodes.getMessageForEXP_CAST_FAILED(S.typeRefAsString, T.typeRefAsString),
- castExpression, IssueCodes.EXP_CAST_FAILED);
+ addIssue(castExpression, EXP_CAST_FAILED.toIssueItem(S.typeRefAsString, T.typeRefAsString));
}
return false;
}
@@ -1440,8 +1399,7 @@ class N4JSExpressionValidator extends AbstractN4JSDeclarativeValidator {
}
if (!castOK) {
if (addIssues) {
- addIssue(IssueCodes.getMessageForEXP_CAST_FAILED(S.typeRefAsString, T.typeRefAsString),
- castExpression, IssueCodes.EXP_CAST_FAILED);
+ addIssue(castExpression, EXP_CAST_FAILED.toIssueItem(S.typeRefAsString, T.typeRefAsString));
}
return false;
}
@@ -1452,8 +1410,7 @@ class N4JSExpressionValidator extends AbstractN4JSDeclarativeValidator {
actualSourceTypeIsCPOE
)) {
if (addIssues) {
- addIssue(IssueCodes.getMessageForEXP_CAST_FAILED(S.typeRefAsString, T.typeRefAsString),
- castExpression, IssueCodes.EXP_CAST_FAILED);
+ addIssue(castExpression, EXP_CAST_FAILED.toIssueItem(S.typeRefAsString, T.typeRefAsString));
}
return false;
}
@@ -1563,7 +1520,7 @@ class N4JSExpressionValidator extends AbstractN4JSDeclarativeValidator {
// allowed: index into exact-type Object instance (not subtype thereof)
} else if (accessedStaticType instanceof TEnum) { // Constraints 69.2
// disallowed: index access into an enum
- addIssue(messageForEXP_INDEXED_ACCESS_ENUM, indexedAccess, EXP_INDEXED_ACCESS_ENUM);
+ addIssue(indexedAccess, EXP_INDEXED_ACCESS_ENUM.toIssueItem());
} else if (indexIsNumeric && (targetTypeRef.isArrayLike || targetIsLiteralOfStringBasedEnum)) { // Constraints 69.3
// allowed: index into array-like with a numeric index
} else if (accessedBuiltInSymbol !== null) {
@@ -1595,8 +1552,7 @@ class N4JSExpressionValidator extends AbstractN4JSDeclarativeValidator {
val memberName = N4JSLanguageUtils.derivePropertyNameFromCompileTimeValue(indexValue);
if (N4JSLanguageUtils.SYMBOL_ITERATOR_MANGLED == memberName) {
// Implementation restriction: member name clashes with compiler-internal, synthetic, mangled name.
- addIssue(getMessageForEXP_INDEXED_ACCESS_IMPL_RESTRICTION(), indexedAccess,
- EXP_INDEXED_ACCESS_IMPL_RESTRICTION);
+ addIssue(indexedAccess, EXP_INDEXED_ACCESS_IMPL_RESTRICTION.toIssueItem());
return
}
if (receiverTypeRef.dynamic) {
@@ -1614,10 +1570,9 @@ class N4JSExpressionValidator extends AbstractN4JSDeclarativeValidator {
val isNonExistentMember = member===null || member.eIsProxy;
if (isNonExistentMember) {
if (indexIsNumeric) {
- addIssue(messageForEXP_INDEXED_ACCESS_FORBIDDEN, indexedAccess, EXP_INDEXED_ACCESS_FORBIDDEN);
+ addIssue(indexedAccess, EXP_INDEXED_ACCESS_FORBIDDEN.toIssueItem());
} else {
- addIssue(getMessageForEXP_INDEXED_ACCESS_COMPUTED_NOTFOUND(memberName), indexedAccess,
- EXP_INDEXED_ACCESS_COMPUTED_NOTFOUND);
+ addIssue(indexedAccess, EXP_INDEXED_ACCESS_COMPUTED_NOTFOUND.toIssueItem(memberName));
}
return;
}
@@ -1633,8 +1588,8 @@ class N4JSExpressionValidator extends AbstractN4JSDeclarativeValidator {
val symbolIterator = G.symbolObjectType.findOwnedMember("iterator", false, true);
val symbolAsyncIterator = G.symbolObjectType.findOwnedMember("asyncIterator", false, true);
if (accessedBuiltInSymbol !== symbolIterator && accessedBuiltInSymbol !== symbolAsyncIterator) {
- val msg = getMessageForEXP_INDEXED_ACCESS_SYMBOL_INVALID("Symbol.iterator and Symbol.asyncIterator");
- addIssue(msg, indexedAccess, N4JSPackage.Literals.INDEXED_ACCESS_EXPRESSION__INDEX, EXP_INDEXED_ACCESS_SYMBOL_INVALID);
+ val IssueItem issueItem = EXP_INDEXED_ACCESS_SYMBOL_INVALID.toIssueItem("Symbol.iterator and Symbol.asyncIterator");
+ addIssue(indexedAccess, N4JSPackage.Literals.INDEXED_ACCESS_EXPRESSION__INDEX, issueItem);
return false;
}
// check valid receiver type (currently only for instance of [Async]Iterable and immediate(!) instances of Object and dynamic types)
@@ -1648,16 +1603,16 @@ class N4JSExpressionValidator extends AbstractN4JSDeclarativeValidator {
receiverTypeRef.typingStrategy === TypingStrategy.NOMINAL;
val isDynamic = receiverTypeRef.dynamic;
if (!(isIterable || isObjectImmediate || isDynamic)) {
- val msg = getMessageForEXP_INDEXED_ACCESS_SYMBOL_WRONG_TYPE(accessedBuiltInSymbol.name, correspondingIterableTypeRef.declaredType.name);
- addIssue(msg, indexedAccess, N4JSPackage.Literals.INDEXED_ACCESS_EXPRESSION__INDEX, EXP_INDEXED_ACCESS_SYMBOL_WRONG_TYPE);
+ val IssueItem issueItem = EXP_INDEXED_ACCESS_SYMBOL_WRONG_TYPE.toIssueItem(accessedBuiltInSymbol.name, correspondingIterableTypeRef.declaredType.name);
+ addIssue(indexedAccess, N4JSPackage.Literals.INDEXED_ACCESS_EXPRESSION__INDEX, issueItem);
return false;
}
// check valid access (currently read-only, except for immediate(!) instances of Object and dynamic types)
if (!(isObjectImmediate || isDynamic)) {
val boolean writeAccess = ExpressionExtensions.isLeftHandSide(indexedAccess);
if (writeAccess) {
- val msg = getMessageForEXP_INDEXED_ACCESS_SYMBOL_READONLY(accessedBuiltInSymbol.name, correspondingIterableTypeRef.declaredType.name);
- addIssue(msg, indexedAccess, N4JSPackage.Literals.INDEXED_ACCESS_EXPRESSION__INDEX, EXP_INDEXED_ACCESS_SYMBOL_READONLY);
+ val IssueItem issueItem = EXP_INDEXED_ACCESS_SYMBOL_READONLY.toIssueItem(accessedBuiltInSymbol.name, correspondingIterableTypeRef.declaredType.name);
+ addIssue(indexedAccess, N4JSPackage.Literals.INDEXED_ACCESS_EXPRESSION__INDEX, issueItem);
return false;
}
}
@@ -1687,22 +1642,18 @@ class N4JSExpressionValidator extends AbstractN4JSDeclarativeValidator {
val id = lhs.id;
switch (id) {
VariableDeclaration case id.const: {
- addIssue(getMessageForEXP_ASSIGN_CONST_VARIABLE(id.name), lhs,
- EXP_ASSIGN_CONST_VARIABLE);
+ addIssue(lhs, EXP_ASSIGN_CONST_VARIABLE.toIssueItem(id.name));
return false;
}
TVariable case id.const: {
- addIssue(getMessageForEXP_ASSIGN_CONST_VARIABLE(id.name), lhs,
- EXP_ASSIGN_CONST_VARIABLE);
+ addIssue(lhs, EXP_ASSIGN_CONST_VARIABLE.toIssueItem(id.name));
return false;
}
TField case !id.writeable: {
// note: this case can happen only when referring to globals in GlobalObject (see file global.n4jsd);
// in all other cases of referencing a field, 'lhs' will be a PropertyAccessExpression (those cases
// will be handled in class AbstractMemberScope as part of scoping)
- addIssue(
- getMessageForVIS_WRONG_READ_WRITE_ACCESS("built-in constant", id.name, "read-only"),
- lhs, VIS_WRONG_READ_WRITE_ACCESS);
+ addIssue(lhs, VIS_WRONG_READ_WRITE_ACCESS.toIssueItem("built-in constant", id.name, "read-only"));
return false;
}
}
@@ -1712,7 +1663,7 @@ class N4JSExpressionValidator extends AbstractN4JSDeclarativeValidator {
@Check
def checkPromisify(PromisifyExpression promiExpr) {
if (!promisifyHelper.isPromisifiableExpression(promiExpr.expression)) {
- addIssue(getMessageForEXP_PROMISIFY_INVALID_USE, promiExpr, EXP_PROMISIFY_INVALID_USE);
+ addIssue(promiExpr, EXP_PROMISIFY_INVALID_USE.toIssueItem());
}
}
@@ -1732,8 +1683,7 @@ class N4JSExpressionValidator extends AbstractN4JSDeclarativeValidator {
if(context instanceof N4MemberDeclaration) {
val tMember = context.definedTypeElement;
if(tMember?.containingType instanceof TInterface && tMember.static) {
- val msg = getMessageForCLF_NO_THIS_IN_STATIC_MEMBER_OF_INTERFACE
- addIssue(msg, thisLiteral, CLF_NO_THIS_IN_STATIC_MEMBER_OF_INTERFACE);
+ addIssue(thisLiteral, CLF_NO_THIS_IN_STATIC_MEMBER_OF_INTERFACE.toIssueItem());
return;
}
}
@@ -1741,15 +1691,13 @@ class N4JSExpressionValidator extends AbstractN4JSDeclarativeValidator {
val tField = context.definedTypeElement;
// 2) not in initializers of data fields in interfaces
if(tField?.containingType instanceof TInterface) {
- val msg = getMessageForCLF_NO_THIS_IN_FIELD_OF_INTERFACE
- addIssue(msg, thisLiteral, CLF_NO_THIS_IN_FIELD_OF_INTERFACE);
+ addIssue(thisLiteral, CLF_NO_THIS_IN_FIELD_OF_INTERFACE.toIssueItem());
return;
}
// 3) not in initializers of static(!) data fields in classes
if(tField?.containingType instanceof TClass) {
if(tField.static) {
- val msg = getMessageForCLF_NO_THIS_IN_STATIC_FIELD
- addIssue(msg, thisLiteral, CLF_NO_THIS_IN_STATIC_FIELD);
+ addIssue(thisLiteral, CLF_NO_THIS_IN_STATIC_FIELD.toIssueItem());
return;
}
}
@@ -1759,7 +1707,7 @@ class N4JSExpressionValidator extends AbstractN4JSDeclarativeValidator {
@Check
def void checkTaggedTemplateString(TaggedTemplateString ttString) {
if (isInOptionalChaining(ttString)) {
- addIssue(getMessageForVCO_TEMPLATE_IN_OPT_CHAIN, ttString.template, VCO_TEMPLATE_IN_OPT_CHAIN);
+ addIssue(ttString.template, VCO_TEMPLATE_IN_OPT_CHAIN.toIssueItem());
}
}
@@ -1787,8 +1735,7 @@ class N4JSExpressionValidator extends AbstractN4JSDeclarativeValidator {
if(isExpressionOfComputedPropertyNameInObjectLiteral(expr)) {
// special case: in object literals, anything goes
// (but show a warning)
- addIssue(IssueCodes.getMessageForEXP_COMPUTED_PROP_NAME_DISCOURAGED, expr,
- IssueCodes.EXP_COMPUTED_PROP_NAME_DISCOURAGED);
+ addIssue(expr, IssueCodes.EXP_COMPUTED_PROP_NAME_DISCOURAGED.toIssueItem());
return;
}
createIssuesForEvalErrors(evalResult.errors);
@@ -1833,8 +1780,7 @@ class N4JSExpressionValidator extends AbstractN4JSDeclarativeValidator {
val astNode = error.astNode;
val feature = error.feature;
if(message!==null && astNode!==null) { // feature may be null, that is ok!
- val msgFull = getMessageForEXP_COMPILE_TIME_MANDATORY(message);
- addIssue(msgFull, astNode, feature, IssueCodes.EXP_COMPILE_TIME_MANDATORY);
+ addIssue(astNode, feature, EXP_COMPILE_TIME_MANDATORY.toIssueItem(message));
}
}
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSExternalValidator.xtend b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSExternalValidator.xtend
index d42a89dabc..2473ae7e47 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSExternalValidator.xtend
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSExternalValidator.xtend
@@ -47,6 +47,7 @@ import org.eclipse.n4js.types.utils.TypeUtils
import org.eclipse.n4js.utils.N4JSLanguageUtils
import org.eclipse.n4js.utils.N4JSLanguageUtils.EnumKind
import org.eclipse.n4js.validation.AbstractN4JSDeclarativeValidator
+import org.eclipse.n4js.validation.IssueItem
import org.eclipse.n4js.validation.JavaScriptVariantHelper
import org.eclipse.n4js.workspace.WorkspaceAccess
import org.eclipse.xtext.util.Tuples
@@ -89,8 +90,7 @@ class N4JSExternalValidator extends AbstractN4JSDeclarativeValidator {
@Check
def checkAnnotationsInN4JSDFile(Annotation annotation) {
if (AnnotationDefinition.N4JS.isAnnotation(annotation)) {
- val message = getMessageForANN__N4JS_NO_EFFECT();
- addIssue(message, annotation, ANN__N4JS_NO_EFFECT);
+ addIssue(annotation, ANN__N4JS_NO_EFFECT.toIssueItem());
}
}
@@ -105,8 +105,7 @@ class N4JSExternalValidator extends AbstractN4JSDeclarativeValidator {
if (clazz.external && jsVariantHelper.isExternalMode(clazz)) {
val projectType = workspaceAccess.findProjectContaining(clazz)?.type;
if (projectType === ProjectType.DEFINITION && !AnnotationDefinition.ECMASCRIPT.hasAnnotation(clazz)) {
- val message = getMessageForCLF_IN_DEFINITION_PRJ_NON_N4JS()
- addIssue(message, clazz, N4JSPackage.Literals.N4_TYPE_DECLARATION__NAME, CLF_IN_DEFINITION_PRJ_NON_N4JS)
+ addIssue(clazz, N4JSPackage.Literals.N4_TYPE_DECLARATION__NAME, CLF_IN_DEFINITION_PRJ_NON_N4JS.toIssueItem())
return;
}
}
@@ -124,8 +123,7 @@ class N4JSExternalValidator extends AbstractN4JSDeclarativeValidator {
val isStructural = TypeUtils.isStructural(interfaceDecl.typingStrategy);
val projectType = workspaceAccess.findProjectContaining(interfaceDecl)?.type;
if (!isStructural && projectType === ProjectType.DEFINITION) {
- val message = getMessageForITF_IN_DEFINITION_PRJ_NON_N4JS()
- addIssue(message, interfaceDecl, N4JSPackage.Literals.N4_TYPE_DECLARATION__NAME, ITF_IN_DEFINITION_PRJ_NON_N4JS)
+ addIssue(interfaceDecl, N4JSPackage.Literals.N4_TYPE_DECLARATION__NAME, ITF_IN_DEFINITION_PRJ_NON_N4JS.toIssueItem())
return;
}
}
@@ -143,8 +141,7 @@ class N4JSExternalValidator extends AbstractN4JSDeclarativeValidator {
private def boolean holdsExternalOnlyInDefinitionFile(N4TypeDeclaration typeDecl, String typesName) {
if (typeDecl.external && !jsVariantHelper.isExternalMode(typeDecl)) {
- val message = getMessageForCLF_EXT_EXTERNAL_N4JSD(typesName)
- addIssue(message, typeDecl, N4JSPackage.Literals.N4_TYPE_DECLARATION__NAME, CLF_EXT_EXTERNAL_N4JSD)
+ addIssue(typeDecl, N4JSPackage.Literals.N4_TYPE_DECLARATION__NAME, CLF_EXT_EXTERNAL_N4JSD.toIssueItem(typesName))
return false;
}
return true;
@@ -173,25 +170,22 @@ class N4JSExternalValidator extends AbstractN4JSDeclarativeValidator {
if (annodef.hasAnnotation(memberDecl)) {
if (!jsVariantHelper.isExternalMode(memberDecl)) {
- val msg = getMessageForCLF_EXT_PROVIDES_IMPL_ONLY_IN_DEFFILES(annodef.name, typeName);
- addIssue(msg, memberDecl, N4JSPackage.Literals.PROPERTY_NAME_OWNER__DECLARED_NAME,
- CLF_EXT_PROVIDES_IMPL_ONLY_IN_DEFFILES);
+ val IssueItem issueItem = CLF_EXT_PROVIDES_IMPL_ONLY_IN_DEFFILES.toIssueItem(annodef.name, typeName);
+ addIssue(memberDecl, N4JSPackage.Literals.PROPERTY_NAME_OWNER__DECLARED_NAME, issueItem);
return;
}
val N4ClassifierDefinition owner = memberDecl.owner;
if (!(metaType.isInstance(owner))) {
- val msg = getMessageForCLF_EXT_PROVIDES_IMPL_ONLY_IN_INTERFACE_MEMBERS(annodef.name, typeName);
- addIssue(msg, memberDecl, N4JSPackage.Literals.PROPERTY_NAME_OWNER__DECLARED_NAME,
- CLF_EXT_PROVIDES_IMPL_ONLY_IN_INTERFACE_MEMBERS);
+ val IssueItem issueItem = CLF_EXT_PROVIDES_IMPL_ONLY_IN_INTERFACE_MEMBERS.toIssueItem(annodef.name, typeName);
+ addIssue(memberDecl, N4JSPackage.Literals.PROPERTY_NAME_OWNER__DECLARED_NAME, issueItem);
return;
}
if (N4JSLanguageUtils.isShapeOrEcmaScript(owner)) {
- val msg = getMessageForCLF_EXT_PROVIDES_IMPL_ONLY_IN_N4JS_INTERFACES(annodef.name);
- addIssue(msg, memberDecl, N4JSPackage.Literals.PROPERTY_NAME_OWNER__DECLARED_NAME,
- CLF_EXT_PROVIDES_IMPL_ONLY_IN_N4JS_INTERFACES);
+ val IssueItem issueItem = CLF_EXT_PROVIDES_IMPL_ONLY_IN_N4JS_INTERFACES.toIssueItem(annodef.name);
+ addIssue(memberDecl, N4JSPackage.Literals.PROPERTY_NAME_OWNER__DECLARED_NAME, issueItem);
return;
}
@@ -205,8 +199,7 @@ class N4JSExternalValidator extends AbstractN4JSDeclarativeValidator {
@Check
def checkExternalFunctionsDefinedInN4JSDFile(FunctionDeclaration funDecl) {
if (funDecl.external && !jsVariantHelper.isExternalMode(funDecl)) {
- val message = getMessageForCLF_EXT_EXTERNAL_N4JSD("Functions")
- addIssue(message, funDecl, N4JSPackage.Literals.FUNCTION_DECLARATION__NAME, CLF_EXT_EXTERNAL_N4JSD)
+ addIssue(funDecl, N4JSPackage.Literals.FUNCTION_DECLARATION__NAME, CLF_EXT_EXTERNAL_N4JSD.toIssueItem("Functions"));
}
}
@@ -221,8 +214,7 @@ class N4JSExternalValidator extends AbstractN4JSDeclarativeValidator {
if (variableStatement.external &&
!jsVariantHelper.isExternalMode(variableStatement)) {
- val message = getMessageForCLF_EXT_EXTERNAL_N4JSD("Variables")
- addIssue(message, variableStatement, CLF_EXT_EXTERNAL_N4JSD)
+ addIssue(variableStatement, CLF_EXT_EXTERNAL_N4JSD.toIssueItem("Variables"));
}
variableStatement.varDecl.forEach [ evd |
@@ -232,8 +224,7 @@ class N4JSExternalValidator extends AbstractN4JSDeclarativeValidator {
} else {
"variable"
}
- val message = getMessageForCLF_EXT_VAR_NO_VAL(mod)
- addIssue(message, evd, CLF_EXT_VAR_NO_VAL)
+ addIssue(evd, CLF_EXT_VAR_NO_VAL.toIssueItem(mod))
}
]
}
@@ -298,8 +289,7 @@ class N4JSExternalValidator extends AbstractN4JSDeclarativeValidator {
val enumKind = N4JSLanguageUtils.getEnumKind(exported);
if (enumKind === EnumKind.Normal) { // note: literal in a number-/string-based enum may have value even in .n4jsd files!
for (literal : exported.literals.filter[it.valueExpression !== null]) {
- val message = getMessageForCLF_EXT_LITERAL_NO_VALUE
- addIssue(message, literal, N4JSPackage.Literals.N4_ENUM_LITERAL__VALUE_EXPRESSION, CLF_EXT_LITERAL_NO_VALUE)
+ addIssue(literal, N4JSPackage.Literals.N4_ENUM_LITERAL__VALUE_EXPRESSION, CLF_EXT_LITERAL_NO_VALUE.toIssueItem())
}
}
}
@@ -307,9 +297,8 @@ class N4JSExternalValidator extends AbstractN4JSDeclarativeValidator {
def private handleFunctionDeclaration(ExportDeclaration eo, FunctionDeclaration exported) {
// relaxed by IDEBUG-561: exported.validateFunctionIsPublicApi(eo)
if (exported.body !== null) {
- val message = getMessageForCLF_EXT_FUN_NO_BODY
val eObjectToNameFeature = exported.findNameFeature
- addIssue(message, eObjectToNameFeature.key, eObjectToNameFeature.value, CLF_EXT_FUN_NO_BODY)
+ addIssue(eObjectToNameFeature.key, eObjectToNameFeature.value, CLF_EXT_FUN_NO_BODY.toIssueItem())
}
}
@@ -340,19 +329,16 @@ class N4JSExternalValidator extends AbstractN4JSDeclarativeValidator {
return true;
}
- val message = messageForCLF_EXT_PROVIDED_BY_RUNTIME_IN_RUNTIME_TYPE
val eObjectToNameFeature = element.findNameFeature
- addIssue(message, eObjectToNameFeature.key, eObjectToNameFeature.value,
- CLF_EXT_PROVIDED_BY_RUNTIME_IN_RUNTIME_TYPE)
+ addIssue(eObjectToNameFeature.key, eObjectToNameFeature.value, CLF_EXT_PROVIDED_BY_RUNTIME_IN_RUNTIME_TYPE.toIssueItem())
return false;
}
def private validateNoObservableAtClassifier(ExportDeclaration ed, N4ClassifierDeclaration declaration,
String classesOrRolesOrInterface) {
if (AnnotationDefinition.OBSERVABLE.hasAnnotation(ed)) {
- val message = getMessageForCLF_EXT_NO_OBSERV_ANNO(classesOrRolesOrInterface)
val eObjectToNameFeature = declaration.findNameFeature
- addIssue(message, eObjectToNameFeature.key, eObjectToNameFeature.value, CLF_EXT_NO_OBSERV_ANNO)
+ addIssue(eObjectToNameFeature.key, eObjectToNameFeature.value, CLF_EXT_NO_OBSERV_ANNO.toIssueItem(classesOrRolesOrInterface))
}
}
@@ -365,24 +351,24 @@ class N4JSExternalValidator extends AbstractN4JSDeclarativeValidator {
private def validateNoObservableAtMember(N4ClassifierDeclaration declaration, String classesOrRolesOrInterface) {
for (member : declaration.ownedMembers.filter[AnnotationDefinition.OBSERVABLE.hasAnnotation(it)]) {
- val message = getMessageForCLF_EXT_METHOD_NO_ANNO(member.keyword.toFirstUpper + "s",
+ val IssueItem issueItem = CLF_EXT_METHOD_NO_ANNO.toIssueItem(member.keyword.toFirstUpper + "s",
classesOrRolesOrInterface, "Observable")
- addIssue(message, member, N4JSPackage.Literals.PROPERTY_NAME_OWNER__DECLARED_NAME, CLF_EXT_METHOD_NO_ANNO)
+ addIssue(member, N4JSPackage.Literals.PROPERTY_NAME_OWNER__DECLARED_NAME, issueItem)
}
}
private def validateNoNfonAtMember(N4ClassifierDeclaration declaration, String classesOrRolesOrInterface) {
for (member : declaration.ownedMembers.filter[AnnotationDefinition.NFON.hasAnnotation(it)]) {
- val message = getMessageForCLF_EXT_METHOD_NO_ANNO(member.keyword.toFirstUpper + "s",
+ val IssueItem issueItem = CLF_EXT_METHOD_NO_ANNO.toIssueItem(member.keyword.toFirstUpper + "s",
classesOrRolesOrInterface, "Nfon")
- addIssue(message, member, N4JSPackage.Literals.PROPERTY_NAME_OWNER__DECLARED_NAME, CLF_EXT_METHOD_NO_ANNO)
+ addIssue(member, N4JSPackage.Literals.PROPERTY_NAME_OWNER__DECLARED_NAME, issueItem)
}
}
private def validateNoFieldExpression(N4ClassifierDeclaration declaration, String classesOrRolesOrInterface) {
for (member : declaration.ownedFields.filter[expression !== null]) {
- val message = getMessageForCLF_EXT_NO_FIELD_EXPR(classesOrRolesOrInterface)
- addIssue(message, member, N4JSPackage.Literals.PROPERTY_NAME_OWNER__DECLARED_NAME, CLF_EXT_NO_FIELD_EXPR)
+ val IssueItem issueItem = CLF_EXT_NO_FIELD_EXPR.toIssueItem(classesOrRolesOrInterface)
+ addIssue(member, N4JSPackage.Literals.PROPERTY_NAME_OWNER__DECLARED_NAME, issueItem)
}
}
@@ -390,26 +376,23 @@ class N4JSExternalValidator extends AbstractN4JSDeclarativeValidator {
for (member : declaration.ownedMembers.filter[!(it instanceof N4FieldDeclaration)].filter [
body !== null
]) {
- val message = getMessageForCLF_EXT_NO_METHOD_BODY(member.keyword.toFirstUpper + "s",
+ val IssueItem issueItem = CLF_EXT_NO_METHOD_BODY.toIssueItem(member.keyword.toFirstUpper + "s",
classesOrRolesOrInterface)
- addIssue(message, member, N4JSPackage.Literals.PROPERTY_NAME_OWNER__DECLARED_NAME, CLF_EXT_NO_METHOD_BODY)
+ addIssue(member, N4JSPackage.Literals.PROPERTY_NAME_OWNER__DECLARED_NAME, issueItem)
}
}
def private validateEcmaScriptClassDoesntExtendN4Object(N4ClassDeclaration exported, TClass superType) {
if (superType !== null && (!superType.isExternal || !AnnotationDefinition.ECMASCRIPT.hasAnnotation(superType))) {
- val message = messageForCLF_EXT_NOT_ANNOTATED_EXTEND_N4OBJECT
val eObjectToNameFeature = exported.findNameFeature
- addIssue(message, eObjectToNameFeature.key, eObjectToNameFeature.value,
- CLF_EXT_NOT_ANNOTATED_EXTEND_N4OBJECT)
+ addIssue(eObjectToNameFeature.key, eObjectToNameFeature.value, CLF_EXT_NOT_ANNOTATED_EXTEND_N4OBJECT.toIssueItem())
}
}
def private validateClassifierIsExternal(N4ClassifierDefinition exported, String classifiers) {
if (!exported.external) {
- val message = getMessageForCLF_EXT_EXTERNAL(classifiers)
val eObjectToNameFeature = exported.findNameFeature
- addIssue(message, eObjectToNameFeature.key, eObjectToNameFeature.value, CLF_EXT_EXTERNAL)
+ addIssue(eObjectToNameFeature.key, eObjectToNameFeature.value, CLF_EXT_EXTERNAL.toIssueItem(classifiers))
}
}
@@ -423,20 +406,18 @@ class N4JSExternalValidator extends AbstractN4JSDeclarativeValidator {
private def validateConsumptionOfNonExternalInterface(N4ClassDeclaration exported, TInterface tinterface, String classifiers) {
if (!tinterface.external && tinterface.typingStrategy !== TypingStrategy.STRUCTURAL) {
- val message = getMessageForCLF_EXT_CONSUME_NON_EXT(classifiers)
val eObjectToNameFeature = exported.findNameFeature
- addIssue(message, eObjectToNameFeature.key, eObjectToNameFeature.value, CLF_EXT_CONSUME_NON_EXT)
+ addIssue(eObjectToNameFeature.key, eObjectToNameFeature.value, CLF_EXT_CONSUME_NON_EXT.toIssueItem(classifiers))
}
}
def private handleUnallowedElement(EObject eo) {
- val message = messageForCLF_EXT_UNALLOWED_N4JSD
val eObjectToNameFeature = eo.findNameFeature
if (eObjectToNameFeature === null) {
val offsetAndLength = eo.findOffsetAndLength
- addIssue(message, eo, offsetAndLength.key, offsetAndLength.value, CLF_EXT_UNALLOWED_N4JSD)
+ addIssue(eo, offsetAndLength.key, offsetAndLength.value, CLF_EXT_UNALLOWED_N4JSD.toIssueItem())
} else {
- addIssue(message, eObjectToNameFeature.key, eObjectToNameFeature.value, CLF_EXT_UNALLOWED_N4JSD)
+ addIssue(eObjectToNameFeature.key, eObjectToNameFeature.value, CLF_EXT_UNALLOWED_N4JSD.toIssueItem())
}
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSFunctionValidator.xtend b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSFunctionValidator.xtend
index f4d2f813b0..d6adcb7380 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSFunctionValidator.xtend
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSFunctionValidator.xtend
@@ -47,6 +47,7 @@ import org.eclipse.n4js.utils.N4JSLanguageHelper
import org.eclipse.n4js.utils.nodemodel.HiddenLeafAccess
import org.eclipse.n4js.utils.nodemodel.HiddenLeafAccess.HiddenLeafs
import org.eclipse.n4js.validation.AbstractN4JSDeclarativeValidator
+import org.eclipse.n4js.validation.IssueItem
import org.eclipse.n4js.validation.JavaScriptVariantHelper
import org.eclipse.xtext.EcoreUtil2
import org.eclipse.xtext.nodemodel.util.NodeModelUtils
@@ -104,11 +105,10 @@ class N4JSFunctionValidator extends AbstractN4JSDeclarativeValidator {
def checkFunctionExpressionInExpressionStatement(FunctionDeclaration functionDeclaration) {
val container = functionDeclaration.eContainer
if (container instanceof Block && jsVariantHelper.requireCheckFunctionExpressionInExpressionStatement(functionDeclaration)) {
- val msg = getMessageForFUN_BLOCK
if (functionDeclaration.name !== null) {
- addIssue(msg, functionDeclaration, N4JSPackage.Literals.FUNCTION_DECLARATION__NAME, FUN_BLOCK)
+ addIssue(functionDeclaration, N4JSPackage.Literals.FUNCTION_DECLARATION__NAME, FUN_BLOCK.toIssueItem());
} else {
- addIssue(msg, container, functionDeclaration.eContainmentFeature, FUN_BLOCK)
+ addIssue(container, functionDeclaration.eContainmentFeature, FUN_BLOCK.toIssueItem())
}
}
}
@@ -164,8 +164,7 @@ class N4JSFunctionValidator extends AbstractN4JSDeclarativeValidator {
if (isSetter) {
// Something else than void is returned -> Error
- val String msg = messageForFUN_RETURNTYPE_VOID_FOR_SETTER_VIOLATED
- addIssue(msg, rst, FUN_RETURNTYPE_VOID_FOR_SETTER_VIOLATED)
+ addIssue(rst, FUN_RETURNTYPE_VOID_FOR_SETTER_VIOLATED.toIssueItem())
return false;
} else {
// other cases are handled by type system (except setters).
@@ -197,7 +196,7 @@ class N4JSFunctionValidator extends AbstractN4JSDeclarativeValidator {
def checkFunctionName(FunctionDefinition definition) {
val name = definition.name.nullToEmpty;
val desc = validatorMessageHelper.description(definition);
- var errorMessage = "";
+ var IssueItem issueItem;
// Disable function name validation against keywords if not N4JS file.
if (jsVariantHelper.requireCheckFunctionName(definition)) {
@@ -205,26 +204,27 @@ class N4JSFunctionValidator extends AbstractN4JSDeclarativeValidator {
//IDEBUG-304 : allow keywords as member names
if(definition instanceof N4MethodDeclaration === false){
if (FUTURE_RESERVED_WORDS.contains(name)) {
- errorMessage = getMessageForFUN_NAME_RESERVED(desc, "future reserved word")
+ issueItem = FUN_NAME_RESERVED.toIssueItem(toFirstUpper(desc), "future reserved word")
}
if (N4JSLanguageConstants.YIELD_KEYWORD != name && languageHelper.getECMAKeywords.contains(name)) {
- errorMessage = getMessageForFUN_NAME_RESERVED(desc, "keyword")
+ issueItem = FUN_NAME_RESERVED.toIssueItem(toFirstUpper(desc), "keyword")
}
}
}
- if (!errorMessage.nullOrEmpty) {
+ if (issueItem !== null) {
var feature = switch (definition) {
FunctionDeclaration: FUNCTION_DECLARATION__NAME
N4MethodDeclaration: PROPERTY_NAME_OWNER__DECLARED_NAME
FunctionExpression: FUNCTION_EXPRESSION__NAME
default: null
}
- addIssue(toFirstUpper(errorMessage), definition, feature, FUN_NAME_RESERVED);
+ addIssue(definition, feature, issueItem);
+ return false;
}
- return errorMessage.nullOrEmpty
+ return true;
}
/**
@@ -289,8 +289,7 @@ class N4JSFunctionValidator extends AbstractN4JSDeclarativeValidator {
// check missing return-expression
if (returnTypeRef !== null && retStmt.expression === null) {
- val String msg = getMessageForFUN_MISSING_RETURN_EXPRESSION(returnTypeRef.typeRefAsString);
- addIssue(msg, retStmt, FUN_MISSING_RETURN_EXPRESSION);
+ addIssue(retStmt, FUN_MISSING_RETURN_EXPRESSION.toIssueItem(returnTypeRef.typeRefAsString));
return true;
}
@@ -322,10 +321,10 @@ class N4JSFunctionValidator extends AbstractN4JSDeclarativeValidator {
val off = firstNode.offset;
val len = hLeafs.offset - firstNode.offset;
- addIssue(messageForFUN_NAME_MISSING,functionDeclaration,off,len,FUN_NAME_MISSING);
+ addIssue(functionDeclaration,off,len,FUN_NAME_MISSING.toIssueItem());
} else {
// mark complete function.
- addIssue(messageForFUN_NAME_MISSING,functionDeclaration,FUN_NAME_MISSING);
+ addIssue(functionDeclaration,FUN_NAME_MISSING.toIssueItem());
}
}
@@ -335,8 +334,7 @@ class N4JSFunctionValidator extends AbstractN4JSDeclarativeValidator {
def checkFunctionDeclarationBody(FunctionDeclaration functionDeclaration) {
if (functionDeclaration.body === null && functionDeclaration.definedType instanceof TFunction &&
!(functionDeclaration.definedType as TFunction).external) {
- addIssue(getMessageForFUN_BODY, functionDeclaration, N4JSPackage.Literals.FUNCTION_DECLARATION__NAME,
- FUN_BODY)
+ addIssue(functionDeclaration, N4JSPackage.Literals.FUNCTION_DECLARATION__NAME, FUN_BODY.toIssueItem())
}
}
@@ -356,28 +354,24 @@ class N4JSFunctionValidator extends AbstractN4JSDeclarativeValidator {
private def internalCheckSetterParameters(T fpar, boolean isVariadic, boolean hasInitializerAssignment){
if (isVariadic) {
- val String msg = messageForFUN_SETTER_CANT_BE_VARIADIC
- addIssue(msg, fpar, FUN_SETTER_CANT_BE_VARIADIC)
+ addIssue(fpar, FUN_SETTER_CANT_BE_VARIADIC.toIssueItem())
}
if (hasInitializerAssignment) {
- val String msg = messageForFUN_SETTER_CANT_BE_DEFAULT
- addIssue(msg, fpar, FUN_SETTER_CANT_BE_DEFAULT)
+ addIssue(fpar, FUN_SETTER_CANT_BE_DEFAULT.toIssueItem())
}
}
@Check
def void checkOptionalModifier(FormalParameter fpar) {
if(fpar.declaredTypeRefInAST!==null && fpar.declaredTypeRefInAST.followedByQuestionMark) {
- val String msg = getMessageForFUN_PARAM_OPTIONAL_WRONG_SYNTAX(fpar.name)
- addIssue(msg, fpar, FUN_PARAM_OPTIONAL_WRONG_SYNTAX)
+ addIssue(fpar, FUN_PARAM_OPTIONAL_WRONG_SYNTAX.toIssueItem(fpar.name))
}
}
@Check
def void checkOptionalModifierT(TFormalParameter fpar) {
if(fpar.typeRef!==null && fpar.typeRef.followedByQuestionMark) {
- val String msg = getMessageForFUN_PARAM_OPTIONAL_WRONG_SYNTAX(fpar.typeRef?.declaredType?.name)
- addIssue(msg, fpar, FUN_PARAM_OPTIONAL_WRONG_SYNTAX)
+ addIssue(fpar, FUN_PARAM_OPTIONAL_WRONG_SYNTAX.toIssueItem(fpar.typeRef?.declaredType?.name))
}
}
@@ -407,7 +401,7 @@ class N4JSFunctionValidator extends AbstractN4JSDeclarativeValidator {
for (fp : fpars) {
// only 'undefined' as identifier allowed
if (fp.hasASTInitializer && !"undefined".equals(fp.astInitializer)) {
- addIssue( messageForFUN_PARAM_INITIALIZER_ONLY_UNDEFINED_ALLOWED, fp, FUN_PARAM_INITIALIZER_ONLY_UNDEFINED_ALLOWED )
+ addIssue(fp, FUN_PARAM_INITIALIZER_ONLY_UNDEFINED_ALLOWED.toIssueItem())
}
}
}
@@ -434,8 +428,7 @@ class N4JSFunctionValidator extends AbstractN4JSDeclarativeValidator {
val idRef = idRefs.next();
if (varDeclNamesInBody.contains(idRef.id.name)) {
val fpar = EcoreUtil2.getContainerOfType(idRef, FormalParameter);
- val String msg = getMessageForFUN_PARAM_INITIALIZER_ILLEGAL_REFERENCE_TO_BODY_VARIABLE(fpar.name, idRef.id.name);
- addIssue(msg, idRef, FUN_PARAM_INITIALIZER_ILLEGAL_REFERENCE_TO_BODY_VARIABLE)
+ addIssue(idRef, FUN_PARAM_INITIALIZER_ILLEGAL_REFERENCE_TO_BODY_VARIABLE.toIssueItem(fpar.name, idRef.id.name))
}
}
}
@@ -446,7 +439,7 @@ class N4JSFunctionValidator extends AbstractN4JSDeclarativeValidator {
for(fp:list) {
if(fp.definedVariable.hasInitializerAssignment) {
if(fp.variadic) {
- addIssue(messageForFUN_PARAM_VARIADIC_WITH_INITIALIZER, fp, FUN_PARAM_VARIADIC_WITH_INITIALIZER)
+ addIssue(fp, FUN_PARAM_VARIADIC_WITH_INITIALIZER.toIssueItem())
}
}
@@ -458,7 +451,7 @@ class N4JSFunctionValidator extends AbstractN4JSDeclarativeValidator {
for(fp:list) {
if(fp.hasInitializerAssignment) {
if(fp.variadic) {
- addIssue(messageForFUN_PARAM_VARIADIC_WITH_INITIALIZER, fp, FUN_PARAM_VARIADIC_WITH_INITIALIZER)
+ addIssue(fp, FUN_PARAM_VARIADIC_WITH_INITIALIZER.toIssueItem())
}
}
}
@@ -472,8 +465,7 @@ class N4JSFunctionValidator extends AbstractN4JSDeclarativeValidator {
if (funDef.isAsync && (null !== funDef.definedType)) {
val TypeRef tfunctionRetType = (funDef.definedType as TFunction).getReturnTypeRef();
if (TypeUtils.isVoid(tfunctionRetType)) {
- val message = messageForTYS_NON_VOID_ASYNC
- addIssue(message, funDef, TYS_NON_VOID_ASYNC)
+ addIssue(funDef, TYS_NON_VOID_ASYNC.toIssueItem())
}
}
}
@@ -485,8 +477,7 @@ class N4JSFunctionValidator extends AbstractN4JSDeclarativeValidator {
def checkNoThisAsyncMethod(FunctionDefinition funDef) {
if (funDef.isAsync) {
if (TypeUtils.isOrContainsThisType(funDef.declaredReturnTypeRef)) {
- val message = messageForTYS_NON_THIS_ASYNC
- addIssue(message, funDef, TYS_NON_THIS_ASYNC)
+ addIssue(funDef, TYS_NON_THIS_ASYNC.toIssueItem())
}
}
}
@@ -507,11 +498,11 @@ class N4JSFunctionValidator extends AbstractN4JSDeclarativeValidator {
val isGeneratorType = TypeUtils.isGenerator(returnTypeRefUB, G.builtInTypeScope);
val isAsyncGeneratorType = TypeUtils.isAsyncGenerator(returnTypeRefUB, G.builtInTypeScope);
if (async && isGeneratorType) {
- addIssue(getMessageForFUN_GENERATOR_RETURN_TYPE_MISMATCH(G.generatorType.name, "synchronous", G.asyncGeneratorType.name),
- returnTypeRefInAST, TypeRefsPackage.Literals.PARAMETERIZED_TYPE_REF__DECLARED_TYPE, FUN_GENERATOR_RETURN_TYPE_MISMATCH);
+ val IssueItem issueItem = FUN_GENERATOR_RETURN_TYPE_MISMATCH.toIssueItem(G.generatorType.name, "synchronous", G.asyncGeneratorType.name);
+ addIssue(returnTypeRefInAST, TypeRefsPackage.Literals.PARAMETERIZED_TYPE_REF__DECLARED_TYPE, issueItem);
} else if (!async && isAsyncGeneratorType) {
- addIssue(getMessageForFUN_GENERATOR_RETURN_TYPE_MISMATCH(G.asyncGeneratorType.name, "asynchronous", G.generatorType.name),
- returnTypeRefInAST, TypeRefsPackage.Literals.PARAMETERIZED_TYPE_REF__DECLARED_TYPE, FUN_GENERATOR_RETURN_TYPE_MISMATCH);
+ val IssueItem issueItem = FUN_GENERATOR_RETURN_TYPE_MISMATCH.toIssueItem(G.asyncGeneratorType.name, "asynchronous", G.generatorType.name);
+ addIssue(returnTypeRefInAST, TypeRefsPackage.Literals.PARAMETERIZED_TYPE_REF__DECLARED_TYPE, issueItem);
}
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSImportValidator.xtend b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSImportValidator.xtend
index d41ead21cc..b5204fbda8 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSImportValidator.xtend
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSImportValidator.xtend
@@ -13,6 +13,7 @@ package org.eclipse.n4js.validation.validators
import java.util.List
import java.util.Map
import javax.inject.Inject
+import org.eclipse.emf.common.notify.Notifier
import org.eclipse.emf.ecore.EObject
import org.eclipse.n4js.n4JS.EmptyStatement
import org.eclipse.n4js.n4JS.ExportDeclaration
@@ -30,7 +31,9 @@ import org.eclipse.n4js.ts.types.TModule
import org.eclipse.n4js.utils.Log
import org.eclipse.n4js.validation.AbstractN4JSDeclarativeValidator
import org.eclipse.n4js.validation.IssueCodes
+import org.eclipse.n4js.validation.IssueItem
import org.eclipse.n4js.validation.JavaScriptVariantHelper
+import org.eclipse.n4js.workspace.N4JSProjectConfigSnapshot
import org.eclipse.n4js.workspace.WorkspaceAccess
import org.eclipse.xtext.nodemodel.util.NodeModelUtils
import org.eclipse.xtext.validation.Check
@@ -40,8 +43,6 @@ import static org.eclipse.n4js.validation.IssueCodes.*
import static extension org.eclipse.n4js.n4JS.N4JSASTUtils.*
import static extension org.eclipse.n4js.tooling.organizeImports.ImportSpecifiersUtil.*
-import org.eclipse.emf.common.notify.Notifier
-import org.eclipse.n4js.workspace.N4JSProjectConfigSnapshot
/** Validations for the import statements. */
@Log
@@ -73,7 +74,7 @@ class N4JSImportValidator extends AbstractN4JSDeclarativeValidator {
def checkMultipleDefaultExports(Script script) {
val defaultExports = script.eAllContents.filter(ExportDeclaration).filter[isDefaultExport].toList;
defaultExports.tail.forEach[
- addIssue(getMessageForIMP_DEFAULT_EXPORT_DUPLICATE, it, N4JSPackage.eINSTANCE.exportDeclaration_DefaultExport, IMP_DEFAULT_EXPORT_DUPLICATE);
+ addIssue(it, N4JSPackage.eINSTANCE.exportDeclaration_DefaultExport, IMP_DEFAULT_EXPORT_DUPLICATE.toIssueItem());
]
}
@@ -93,20 +94,14 @@ class N4JSImportValidator extends AbstractN4JSDeclarativeValidator {
if (impModule !== null && !impModule.eIsProxy()) {
if (importSpecifier.declaredDynamic) {
if (jsVariantHelper.isN4JSMode(impModule)) {
- addIssue(
- getMessageForIMP_DYNAMIC_IMPORT_N4JS(impModule.moduleSpecifier),
- importSpecifier, IMP_DYNAMIC_IMPORT_N4JS);
+ addIssue(importSpecifier, IMP_DYNAMIC_IMPORT_N4JS.toIssueItem(impModule.moduleSpecifier));
} else if (jsVariantHelper.isExternalMode(impModule)) {
val variant = fileExtensionCalculator.getXpectAwareFileExtension(impModule);
- addIssue(
- getMessageForIMP_DYNAMIC_IMPORT_N4JSD(variant, impModule.moduleSpecifier),
- importSpecifier, IMP_DYNAMIC_IMPORT_N4JSD);
+ addIssue(importSpecifier, IMP_DYNAMIC_IMPORT_N4JSD.toIssueItem(variant, impModule.moduleSpecifier));
}
} else {
if (jsVariantHelper.isPlainJS(impModule)) {
- addIssue(
- getMessageForIMP_STATIC_IMPORT_PLAIN_JS(impModule.moduleSpecifier),
- importSpecifier, IMP_STATIC_IMPORT_PLAIN_JS);
+ addIssue(importSpecifier, IMP_STATIC_IMPORT_PLAIN_JS.toIssueItem(impModule.moduleSpecifier));
}
}
if (importSpecifier instanceof NamedImportSpecifier) {
@@ -119,12 +114,12 @@ class N4JSImportValidator extends AbstractN4JSDeclarativeValidator {
if (isDependingOn(importSpecifier, impModulePrj, impElemPrj)) {
// that's how it should be: re-export
} else {
- val msg = getMessageForIMP_IMPORTED_ELEMENT_FROM_REEXPORTING_PROJECT(
+ val IssueItem issueItem = IMP_IMPORTED_ELEMENT_FROM_REEXPORTING_PROJECT.toIssueItem(
importSpecifier.importedElementAsText,
impElemPrj.n4JSPackageName.toString,
impModulePrj.n4JSPackageName.toString
);
- addIssue(msg, importSpecifier, IMP_IMPORTED_ELEMENT_FROM_REEXPORTING_PROJECT);
+ addIssue(importSpecifier, issueItem);
}
}
}
@@ -337,10 +332,9 @@ class N4JSImportValidator extends AbstractN4JSDeclarativeValidator {
}
private def regUnresolvedImport(ParameterizedTypeRef ref, String name, Map eObjectToIssueCode) {
- val issueCode = IssueCodes.IMP_UNRESOLVED
+ val issueCode = IMP_UNRESOLVED.name();
if (eObjectToIssueCode.put(ref, issueCode) === null) {
- val message = IssueCodes.getMessageForIMP_UNRESOLVED(name)
- addIssue(message, ref, issueCode)
+ addIssue(ref, IMP_UNRESOLVED.toIssueItem(name));
}
}
@@ -375,29 +369,25 @@ class N4JSImportValidator extends AbstractN4JSDeclarativeValidator {
* reported for given import declaration.
*/
private def addIssueScatteredImport(ImportDeclaration importDecl) {
- val issueCode = IssueCodes.IMP_DISCOURAGED_PLACEMENT
- val message = IssueCodes.getMessageForIMP_DISCOURAGED_PLACEMENT
- addIssue(message, importDecl, issueCode)
+ addIssue(importDecl, IMP_DISCOURAGED_PLACEMENT.toIssueItem())
}
private def addLocalNameCollision(ImportSpecifier duplicate, String name, String reason,
Map eObjectToIssueCode) {
if (eObjectToIssueCode.get(duplicate) === null) {
- val issueCode = IssueCodes.IMP_LOCAL_NAME_CONFLICT
- val message = IssueCodes.getMessageForIMP_LOCAL_NAME_CONFLICT(name, reason)
- addIssue(message, duplicate, issueCode)
- eObjectToIssueCode.put(duplicate, issueCode)
+ val IssueItem issueItem = IMP_LOCAL_NAME_CONFLICT.toIssueItem(name, reason);
+ addIssue(duplicate, issueItem)
+ eObjectToIssueCode.put(duplicate, issueItem.ID);
}
}
private def addIssueDuplicateNamespaceImportDeclaration(NamespaceImportSpecifier specifier,
NamespaceImportSpecifier duplicate, ImportDeclaration duplicateImportDeclaration,
Map eObjectToIssueCode) {
- val String issueCode = IssueCodes.IMP_STMT_DUPLICATE_NAMESPACE
+ val String issueCode = IMP_STMT_DUPLICATE_NAMESPACE.name();
if (eObjectToIssueCode.get(specifier) === null) {
- val message = IssueCodes.getMessageForIMP_STMT_DUPLICATE_NAMESPACE(specifier.alias,
- duplicate.importedModule.qualifiedName)
- addIssue(message, duplicateImportDeclaration, issueCode)
+ val IssueItem issueItem = IMP_STMT_DUPLICATE_NAMESPACE.toIssueItem(specifier.alias, duplicate.importedModule.qualifiedName);
+ addIssue(duplicateImportDeclaration, issueItem)
}
duplicateImportDeclaration.importSpecifiers.forEach [ is |
@@ -416,57 +406,52 @@ class N4JSImportValidator extends AbstractN4JSDeclarativeValidator {
private def addIssueDuplicateNamedImportDeclaration(NamedImportSpecifier specifier,
NamedImportSpecifier duplicate, ImportDeclaration duplicateImportDeclaration,
Map eObjectToIssueCode) {
- val String issueCode = IssueCodes.IMP_STMT_DUPLICATE_NAMED
- if (eObjectToIssueCode.get(specifier) === null) {
- val message = IssueCodes.getMessageForIMP_STMT_DUPLICATE_NAMED(specifier.usedName,
- duplicate.importedModule.qualifiedName)
- addIssue(message, duplicateImportDeclaration, issueCode)
- }
+
+ val String issueCode = IMP_STMT_DUPLICATE_NAMED.name();
+ if (eObjectToIssueCode.get(specifier) === null) {
+ val IssueItem issueItem = IMP_STMT_DUPLICATE_NAMED.toIssueItem(specifier.usedName, duplicate.importedModule.qualifiedName);
+ addIssue(duplicateImportDeclaration, issueItem)
+ }
- duplicateImportDeclaration.importSpecifiers.forEach [ is |
- eObjectToIssueCode.put(specifier, issueCode)
- ]
+ duplicateImportDeclaration.importSpecifiers.forEach [ is |
+ eObjectToIssueCode.put(specifier, issueCode)
+ ]
}
private def addIssueDuplicateNamespace(ImportProvidedElement ipe, NamespaceImportSpecifier duplicateImportSpecifier,
NamespaceImportSpecifier firstImportSpecifier, Map eObjectToIssueCode) {
if (eObjectToIssueCode.get(duplicateImportSpecifier) === null) {
- val issueCode = IssueCodes.IMP_DUPLICATE_NAMESPACE
- val msg = IssueCodes.getMessageForIMP_DUPLICATE_NAMESPACE(ipe.localName,
- firstImportSpecifier.importedModule.qualifiedName, firstImportSpecifier.alias)
- addIssue(msg, duplicateImportSpecifier, issueCode)
- eObjectToIssueCode.put(duplicateImportSpecifier, issueCode)
+ val IssueItem issueItem = IMP_DUPLICATE_NAMESPACE.toIssueItem(ipe.localName, firstImportSpecifier.importedModule.qualifiedName, firstImportSpecifier.alias)
+ addIssue(duplicateImportSpecifier, issueItem)
+ eObjectToIssueCode.put(duplicateImportSpecifier, issueItem.getID());
}
}
private def addIssueDuplicate(ImportSpecifier specifier, String actualName, TModule module,
String firstImportName, Map eObjectToIssueCode) {
- var String issueCode = IssueCodes.IMP_DUPLICATE
if (eObjectToIssueCode.get(specifier) === null) {
- val message = IssueCodes.getMessageForIMP_DUPLICATE(actualName, module.qualifiedName,
- firstImportName)
- addIssue(message, specifier, issueCode)
- eObjectToIssueCode.put(specifier, issueCode)
+ val IssueItem issueItem = IMP_DUPLICATE.toIssueItem(actualName, module.qualifiedName, firstImportName);
+ addIssue(specifier, issueItem);
+ eObjectToIssueCode.put(specifier, issueItem.getID());
}
}
private def addIssueUnresolved(ImportSpecifier specifier, Map eObjectToIssueCode) {
- var String issueCode = IssueCodes.IMP_UNRESOLVED
+ var String issueCode = IMP_UNRESOLVED.name();
if (eObjectToIssueCode.get(specifier) === null) {
if (!isChildOfUnresolvedImportDecl(specifier)) { // avoid redundant follow-up error messages
- val message = IssueCodes.getMessageForIMP_UNRESOLVED(computeUnusedOrUnresolvedMessage(specifier))
- addIssue(message, specifier, issueCode)
+ val IssueItem issueItem = IMP_UNRESOLVED.toIssueItem(computeUnusedOrUnresolvedMessage(specifier));
+ addIssue(specifier, issueItem);
}
eObjectToIssueCode.put(specifier, issueCode)
}
}
private def addIssueUnusedImport(ImportSpecifier specifier, Map eObjectToIssueCode) {
- val issueCode = IssueCodes.IMP_UNUSED_IMPORT
if (eObjectToIssueCode.get(specifier) === null) {
- val message = IssueCodes.getMessageForIMP_UNUSED_IMPORT(computeUnusedOrUnresolvedMessage(specifier))
- addIssue(message, specifier, issueCode)
- eObjectToIssueCode.put(specifier, issueCode)
+ val IssueItem issueItem = IMP_UNUSED_IMPORT.toIssueItem(computeUnusedOrUnresolvedMessage(specifier));
+ addIssue(specifier, issueItem);
+ eObjectToIssueCode.put(specifier, issueItem.getID());
}
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSInjectorCallsitesValidator.xtend b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSInjectorCallsitesValidator.xtend
index ea7112f1db..2a9499686c 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSInjectorCallsitesValidator.xtend
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSInjectorCallsitesValidator.xtend
@@ -189,8 +189,7 @@ class N4JSInjectorCallsitesValidator extends AbstractN4JSDeclarativeValidator {
return
}
val missing = bindersForWhichInstancesAreNeeded.map[binder| binder.typeAsString].join(", ")
- val msg = getMessageForDI_ANN_MISSING_PROVIDED_BINDERS(missing);
- addIssue(msg, callExpression, DI_ANN_MISSING_PROVIDED_BINDERS);
+ addIssue(callExpression, DI_ANN_MISSING_PROVIDED_BINDERS.toIssueItem(missing));
}
/**
@@ -206,7 +205,7 @@ class N4JSInjectorCallsitesValidator extends AbstractN4JSDeclarativeValidator {
}
}
}
- addIssue(getMessageForDI_ANN_INJECTOR_REQUIRED(), ctorOfDICArg, DI_ANN_INJECTOR_REQUIRED);
+ addIssue(ctorOfDICArg, DI_ANN_INJECTOR_REQUIRED.toIssueItem());
return null
}
@@ -239,7 +238,7 @@ class N4JSInjectorCallsitesValidator extends AbstractN4JSDeclarativeValidator {
return
}
}
- addIssue(getMessageForDI_NOT_INJECTABLE(ctorArgTypeRef.typeRefAsString, ''), ctorArg, DI_NOT_INJECTABLE);
+ addIssue(ctorArg, DI_NOT_INJECTABLE.toIssueItem(ctorArgTypeRef.typeRefAsString, ''));
}
/**
@@ -278,7 +277,7 @@ class N4JSInjectorCallsitesValidator extends AbstractN4JSDeclarativeValidator {
if (isAllowedAsInjectorInstance(tr.declaredType)) {
return
}
- addIssue(getMessageForDI_ANN_INJECTOR_MISSING(), expr, DI_ANN_INJECTOR_MISSING);
+ addIssue(expr, DI_ANN_INJECTOR_MISSING.toIssueItem());
}
/**
@@ -303,8 +302,7 @@ class N4JSInjectorCallsitesValidator extends AbstractN4JSDeclarativeValidator {
return
}
val missing = missingBinders.map[binder| binder.typeAsString].join(", ")
- val msg = getMessageForDI_ANN_MISSING_NEEDED_BINDERS(missing);
- addIssue(msg, callExpression, DI_ANN_MISSING_NEEDED_BINDERS);
+ addIssue(callExpression, DI_ANN_MISSING_NEEDED_BINDERS.toIssueItem(missing));
}
/**
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSInterfaceValidator.xtend b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSInterfaceValidator.xtend
index ea686a4299..5160a174d4 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSInterfaceValidator.xtend
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSInterfaceValidator.xtend
@@ -26,7 +26,7 @@ import org.eclipse.n4js.ts.types.TInterface
import org.eclipse.n4js.ts.types.TypingStrategy
import org.eclipse.n4js.typesystem.utils.RuleEnvironmentExtensions
import org.eclipse.n4js.validation.AbstractN4JSDeclarativeValidator
-import org.eclipse.n4js.validation.IssueCodes
+import org.eclipse.n4js.validation.IssueItem
import org.eclipse.xtext.validation.Check
import org.eclipse.xtext.validation.EValidatorRegistrar
@@ -75,15 +75,13 @@ class N4JSInterfaceValidator extends AbstractN4JSDeclarativeValidator implements
// publish this method.
public override void addIssue(String message, EObject source, EStructuralFeature feature, String issueCode,
String... issueData) {
- super.addIssue(message,source,feature,issueCode,issueData)
+ super.addIssue(message,source,feature,issueCode,issueData)
}
def private internalCheckNotFinal(N4InterfaceDeclaration n4InterfaceDeclaration) {
if (AnnotationDefinition.FINAL.hasAnnotation(n4InterfaceDeclaration)) {
- val msg = IssueCodes.getMessageForITF_NO_FINAL
- addIssue(msg, n4InterfaceDeclaration, N4JSPackage.Literals.N4_TYPE_DECLARATION__NAME,
- IssueCodes.ITF_NO_FINAL)
+ addIssue(n4InterfaceDeclaration, N4JSPackage.Literals.N4_TYPE_DECLARATION__NAME, ITF_NO_FINAL.toIssueItem());
}
}
@@ -93,8 +91,7 @@ class N4JSInterfaceValidator extends AbstractN4JSDeclarativeValidator implements
for (member : n4Interface.ownedMembers) {
if (member instanceof N4FieldDeclaration) {
if (member.expression !== null) {
- addIssue(IssueCodes.getMessageForITF_NO_FIELD_INITIALIZER(member.name, n4Interface.name),
- member.expression, IssueCodes.ITF_NO_FIELD_INITIALIZER)
+ addIssue(member.expression, ITF_NO_FIELD_INITIALIZER.toIssueItem(member.name, n4Interface.name));
}
}
if (member instanceof N4MethodDeclaration) {
@@ -102,21 +99,18 @@ class N4JSInterfaceValidator extends AbstractN4JSDeclarativeValidator implements
if (member.isCallSignature || member.isConstructSignature) {
// specialized validation: N4JSMemberValidator#holdsCallConstructSignatureConstraints()
} else {
- addIssue(IssueCodes.getMessageForITF_NO_PROPERTY_BODY("Methods", "structural "),
- member.body, IssueCodes.ITF_NO_PROPERTY_BODY)
+ addIssue(member.body, ITF_NO_PROPERTY_BODY.toIssueItem("Methods", "structural "));
}
}
}
if (member instanceof N4GetterDeclaration) {
if (member.body !== null) {
- addIssue(IssueCodes.getMessageForITF_NO_PROPERTY_BODY("Getters", "structural "),
- member.body, IssueCodes.ITF_NO_PROPERTY_BODY)
+ addIssue(member.body, ITF_NO_PROPERTY_BODY.toIssueItem("Getters", "structural "));
}
}
if (member instanceof N4SetterDeclaration) {
if (member.body !== null) {
- addIssue(IssueCodes.getMessageForITF_NO_PROPERTY_BODY("Setters", "structural "),
- member.body, IssueCodes.ITF_NO_PROPERTY_BODY)
+ addIssue(member.body, ITF_NO_PROPERTY_BODY.toIssueItem("Setters", "structural "));
}
}
}
@@ -135,27 +129,25 @@ class N4JSInterfaceValidator extends AbstractN4JSDeclarativeValidator implements
if (n4Interface.typingStrategy === TypingStrategy.STRUCTURAL
&& extendedType.typingStrategy !== TypingStrategy.STRUCTURAL
) {
- addIssue(IssueCodes.getMessageForSTRCT_ITF_CANNOT_EXTEND_INTERFACE(), superIfc, null, IssueCodes.STRCT_ITF_CANNOT_EXTEND_INTERFACE)
+ addIssue(superIfc, null, STRCT_ITF_CANNOT_EXTEND_INTERFACE.toIssueItem());
}
} else {
if (extendedType instanceof PrimitiveType) {
if (!N4Scheme.isFromResourceWithN4Scheme(n4Interface)) { // primitive types may be extended in built-in types
- val message = getMessageForCLF_EXTENDS_PRIMITIVE_GENERIC_TYPE(extendedType.name);
- addIssue(message, superIfc, null, CLF_EXTENDS_PRIMITIVE_GENERIC_TYPE)
+ addIssue(superIfc, null, CLF_EXTENDS_PRIMITIVE_GENERIC_TYPE.toIssueItem(extendedType.name));
}
} else if (RuleEnvironmentExtensions.isAnyDynamic(RuleEnvironmentExtensions.newRuleEnvironment(extendedType), extendedTypeRef)) {
// allow any+ as a supertype (motivated from type alias being any+ used in d.ts files
} else {
- val message = IssueCodes.getMessageForCLF_WRONG_META_TYPE(n4Interface.description, "extend",
- extendedType.description);
- addIssue(message, superIfc, null, IssueCodes.CLF_WRONG_META_TYPE)
+ val IssueItem issueItem = CLF_WRONG_META_TYPE.toIssueItem(n4Interface.description, "extend", extendedType.description);
+ addIssue(superIfc, null, issueItem);
}
}
} else if (extendedTypeRef !== null && extendedTypeRef.isAliasResolved) {
// not all aliases are illegal after "extends", but if we get to this point we have an illegal case:
- val message = getMessageForCLF_WRONG_META_TYPE(n4Interface.description, "extend", extendedTypeRef.typeRefAsStringWithAliasResolution);
- addIssue(message, superIfc, null, CLF_WRONG_META_TYPE);
+ val IssueItem issueItem = CLF_WRONG_META_TYPE.toIssueItem(n4Interface.description, "extend", extendedTypeRef.typeRefAsStringWithAliasResolution);
+ addIssue(superIfc, null, issueItem);
}
}
}
@@ -165,8 +157,8 @@ class N4JSInterfaceValidator extends AbstractN4JSDeclarativeValidator implements
val cycle = findCyclicInheritance(ifc);
if(cycle!==null) {
val miscreant = n4InterfaceDeclaration.superInterfaceRefs.findFirst[typeRef?.declaredType===cycle.get(1)];
- val message = IssueCodes.getMessageForCLF_INHERITANCE_CYCLE(cycle.map[name].join(", "));
- addIssue(message, miscreant, IssueCodes.CLF_INHERITANCE_CYCLE);
+ val IssueItem issueItem = CLF_INHERITANCE_CYCLE.toIssueItem(cycle.map[name].join(", "));
+ addIssue(miscreant, issueItem);
return false;
}
return true;
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSLambdaValidator.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSLambdaValidator.java
index e9649ff594..e840fed752 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSLambdaValidator.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSLambdaValidator.java
@@ -63,8 +63,7 @@ private void rejectUsagesOfThisInTopLevelLambda(ArrowFunction topLevelLambda) {
Iterator thisUsages = LambdaUtils.thisLiterals(topLevelLambda.getBody());
while (thisUsages.hasNext()) {
EObject thisUsage = thisUsages.next();
- String message = IssueCodes.getMessageForKEY_THIS_REJECTED_IN_TOP_LEVEL_LAMBDA();
- addIssue(message, thisUsage, IssueCodes.KEY_THIS_REJECTED_IN_TOP_LEVEL_LAMBDA);
+ addIssue(thisUsage, IssueCodes.KEY_THIS_REJECTED_IN_TOP_LEVEL_LAMBDA);
}
}
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSMemberRedefinitionValidator.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSMemberRedefinitionValidator.java
index 87b50db632..5171506789 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSMemberRedefinitionValidator.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSMemberRedefinitionValidator.java
@@ -35,31 +35,6 @@
import static org.eclipse.n4js.validation.IssueCodes.CLF_REDEFINED_TYPE_NOT_SAME_TYPE;
import static org.eclipse.n4js.validation.IssueCodes.CLF_UNMATCHED_ACCESSOR_OVERRIDE;
import static org.eclipse.n4js.validation.IssueCodes.CLF_UNMATCHED_ACCESSOR_OVERRIDE_JS;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForCLF_CONSUMED_FIELD_ACCESSOR_PAIR_INCOMPLETE;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForCLF_CONSUMED_INHERITED_MEMBER_UNSOLVABLE_CONFLICT;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForCLF_CONSUMED_MEMBER_SOLVABLE_CONFLICT;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForCLF_CONSUMED_MEMBER_UNSOLVABLE_CONFLICT;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForCLF_IMPLEMENT_MEMBERTYPE_INCOMPATIBLE;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForCLF_MISSING_IMPLEMENTATION;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForCLF_MISSING_IMPLEMENTATION_EXT;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForCLF_NON_ACCESSIBLE_ABSTRACT_MEMBERS;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForCLF_OVERRIDEN_CONCRETE_WITH_ABSTRACT;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForCLF_OVERRIDE_ANNOTATION;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForCLF_OVERRIDE_CONST;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForCLF_OVERRIDE_FIELD_REQUIRES_ACCESSOR_PAIR;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForCLF_OVERRIDE_FINAL;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForCLF_OVERRIDE_MEMBERTYPE_INCOMPATIBLE;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForCLF_OVERRIDE_NON_EXISTENT;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForCLF_OVERRIDE_NON_EXISTENT_INTERFACE;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForCLF_OVERRIDE_VISIBILITY;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForCLF_OVERRIDE_WITH_FINAL_OR_CONST_FIELD;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForCLF_PSEUDO_REDEFINED_SPEC_CTOR_INCOMPATIBLE;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForCLF_REDEFINED_MEMBER_TYPE_INVALID;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForCLF_REDEFINED_METHOD_TYPE_CONFLICT;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForCLF_REDEFINED_NON_ACCESSIBLE;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForCLF_REDEFINED_TYPE_NOT_SAME_TYPE;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForCLF_UNMATCHED_ACCESSOR_OVERRIDE;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForCLF_UNMATCHED_ACCESSOR_OVERRIDE_JS;
import java.util.ArrayList;
import java.util.Collection;
@@ -117,6 +92,8 @@
import org.eclipse.n4js.utils.N4JSLanguageUtils;
import org.eclipse.n4js.utils.UtilN4;
import org.eclipse.n4js.validation.AbstractN4JSDeclarativeValidator;
+import org.eclipse.n4js.validation.IssueCodes;
+import org.eclipse.n4js.validation.IssueItem;
import org.eclipse.n4js.validation.IssueUserDataKeys;
import org.eclipse.n4js.validation.JavaScriptVariantHelper;
import org.eclipse.n4js.validation.utils.MemberCube;
@@ -279,13 +256,12 @@ private boolean checkSpecConstructorOverrideCompatibility(TClassifier tClassifie
inheritedConstructor, declMergingHelper);
final Result subtypeResult = isSubTypeResult(inheritedConstructor, rightThisContext, inheritedConstructor);
if (subtypeResult.isFailure()) {
- final String msg = getMessageForCLF_PSEUDO_REDEFINED_SPEC_CTOR_INCOMPATIBLE(
+ final EObject astNode = tClassifier.getAstElement(); // ok, because tClassifier is coming from AST
+ addIssue(astNode, N4JSPackage.eINSTANCE.getN4TypeDeclaration_Name(),
+ CLF_PSEUDO_REDEFINED_SPEC_CTOR_INCOMPATIBLE,
validatorMessageHelper.description(inheritedConstructor),
validatorMessageHelper.description(tClassifier),
validatorMessageHelper.description(rightThisContext));
- final EObject astNode = tClassifier.getAstElement(); // ok, because tClassifier is coming from AST
- addIssue(msg, astNode, N4JSPackage.eINSTANCE.getN4TypeDeclaration_Name(),
- CLF_PSEUDO_REDEFINED_SPEC_CTOR_INCOMPATIBLE);
return false;
}
return true;
@@ -367,18 +343,14 @@ private boolean constraints_66_NonOverride(MemberMatrix mm) {
if (member.isStatic() && mm.hasNonImplemented() && !mm.hasInherited() && !mm.hasImplemented()) {
// special case of false @Override annotation: "overriding" a static member of an interface
final TMember other = mm.nonImplemented().iterator().next(); // simply take the first one
- String message = getMessageForCLF_OVERRIDE_NON_EXISTENT_INTERFACE(
+ addIssue(member.getAstElement(), N4JSPackage.Literals.PROPERTY_NAME_OWNER__DECLARED_NAME,
+ CLF_OVERRIDE_NON_EXISTENT_INTERFACE,
validatorMessageHelper.description(member),
validatorMessageHelper.description(other));
- addIssue(message, member.getAstElement(),
- N4JSPackage.Literals.PROPERTY_NAME_OWNER__DECLARED_NAME,
- CLF_OVERRIDE_NON_EXISTENT_INTERFACE);
} else {
// standard case of false @Override annotation
- String message = getMessageForCLF_OVERRIDE_NON_EXISTENT(keywordProvider.keyword(member),
- member.getName());
- addIssue(message, member.getAstElement(),
- N4JSPackage.Literals.PROPERTY_NAME_OWNER__DECLARED_NAME, CLF_OVERRIDE_NON_EXISTENT);
+ addIssue(member.getAstElement(), N4JSPackage.Literals.PROPERTY_NAME_OWNER__DECLARED_NAME,
+ CLF_OVERRIDE_NON_EXISTENT, keywordProvider.keyword(member), member.getName());
}
}
}
@@ -910,20 +882,20 @@ private boolean isClassExtendsInterface(TClassifier classifier, TMember m) {
private void messageMissingImplementations(List abstractMembers) {
TClassifier classifier = getCurrentClassifier();
if (!jsVariantHelper.allowMissingImplementation(classifier)) {
- String message = getMessageForCLF_MISSING_IMPLEMENTATION(classifier.getName(),
+ addIssue(CLF_MISSING_IMPLEMENTATION,
+ classifier.getName(),
validatorMessageHelper.descriptions(abstractMembers));
- addIssue(message, CLF_MISSING_IMPLEMENTATION);
} else {
- String message = getMessageForCLF_MISSING_IMPLEMENTATION_EXT(classifier.getName(),
+ addIssue(CLF_MISSING_IMPLEMENTATION_EXT,
+ classifier.getName(),
validatorMessageHelper.descriptions(abstractMembers));
- addIssue(message, CLF_MISSING_IMPLEMENTATION_EXT);
}
}
- private void addIssue(String message, String issueCode) {
+ private void addIssue(IssueCodes issueCode, String... msgValues) {
N4ClassifierDefinition classifier = getCurrentClassifierDefinition();
EStructuralFeature nameFeature = classifier.eClass().getEStructuralFeature("name");
- addIssue(message, classifier, nameFeature, issueCode);
+ addIssue(classifier, nameFeature, issueCode, msgValues);
}
private void messageImpossibleExtendsImplements(N4ClassifierDefinition n4ClassifierDefinition,
@@ -934,11 +906,11 @@ private void messageImpossibleExtendsImplements(N4ClassifierDefinition n4Classif
final Type type = superTypeRefNode.getTypeRef().getDeclaredType();
final String mode = type instanceof TInterface
&& !(n4ClassifierDefinition instanceof N4InterfaceDeclaration) ? "implement" : "extend";
- final String message = getMessageForCLF_NON_ACCESSIBLE_ABSTRACT_MEMBERS(mode,
+ addIssue(superTypeRefNode.eContainer(), superTypeRefNode.eContainingFeature(),
+ CLF_NON_ACCESSIBLE_ABSTRACT_MEMBERS,
+ mode,
validatorMessageHelper.description(type),
validatorMessageHelper.descriptions(entry.getValue()));
- addIssue(message, superTypeRefNode.eContainer(), superTypeRefNode.eContainingFeature(),
- CLF_NON_ACCESSIBLE_ABSTRACT_MEMBERS);
}
}
@@ -980,13 +952,11 @@ private void messageMissingOverrideAnnotation(MemberMatrix mm,
String redefinitionVerb = MemberRedefinitionUtils.getRedefinitionVerb(filteredOverriddenMembers,
getCurrentClassifier());
- String message = getMessageForCLF_OVERRIDE_ANNOTATION(
+ addIssue(overriding.getAstElement(), N4JSPackage.Literals.PROPERTY_NAME_OWNER__DECLARED_NAME,
+ CLF_OVERRIDE_ANNOTATION,
validatorMessageHelper.descriptionDifferentFrom(overriding, overriddenMembers),
redefinitionVerb,
validatorMessageHelper.descriptions(filteredOverriddenMembers));
-
- addIssue(message, overriding.getAstElement(), N4JSPackage.Literals.PROPERTY_NAME_OWNER__DECLARED_NAME,
- CLF_OVERRIDE_ANNOTATION);
}
}
}
@@ -994,11 +964,11 @@ private void messageMissingOverrideAnnotation(MemberMatrix mm,
private void messageFieldOverrideNeedsAccessorPair(TMember overriding, TMember overridden) {
if (overriding.getContainingType() == getCurrentClassifier()) {
String missingAccessor = overriding.isGetter() ? "setter" : "getter";
- String message = getMessageForCLF_OVERRIDE_FIELD_REQUIRES_ACCESSOR_PAIR(
+ addIssue(overriding.getAstElement(), N4JSPackage.Literals.PROPERTY_NAME_OWNER__DECLARED_NAME,
+ CLF_OVERRIDE_FIELD_REQUIRES_ACCESSOR_PAIR,
validatorMessageHelper.descriptionDifferentFrom(overriding, overridden),
- validatorMessageHelper.descriptionDifferentFrom(overridden, overriding), missingAccessor);
- addIssue(message, overriding.getAstElement(), N4JSPackage.Literals.PROPERTY_NAME_OWNER__DECLARED_NAME,
- CLF_OVERRIDE_FIELD_REQUIRES_ACCESSOR_PAIR);
+ validatorMessageHelper.descriptionDifferentFrom(overridden, overriding),
+ missingAccessor);
} else {
throw new IllegalStateException("must not happen as member is not consumed");
}
@@ -1007,8 +977,6 @@ private void messageFieldOverrideNeedsAccessorPair(TMember overriding, TMember o
private void messageOverrideMemberTypeConflict(RedefinitionType redefinitionType, TMember overriding,
TMember overridden, Result result, MemberMatrix mm) {
- String message;
- String code;
String redefinitionTypeName = redefinitionType.name();
if (redefinitionType == RedefinitionType.implemented &&
Iterables.contains(mm.implemented(), overriding)) {
@@ -1022,28 +990,25 @@ private void messageOverrideMemberTypeConflict(RedefinitionType redefinitionType
}
String extraMessage = cfOtherImplementedMembers(mm, overriding, overridden);
-
+ IssueItem issueItem;
if (overriding.isField() && overridden.isField() && !((TField) overridden).isConst()) {
- code = CLF_REDEFINED_TYPE_NOT_SAME_TYPE;
- message = getMessageForCLF_REDEFINED_TYPE_NOT_SAME_TYPE(
+ issueItem = CLF_REDEFINED_TYPE_NOT_SAME_TYPE.toIssueItem(
overridingSource + validatorMessageHelper.descriptionDifferentFrom(overriding, overridden),
redefinitionTypeName,
validatorMessageHelper.descriptionDifferentFrom(overridden, overriding),
extraMessage);
} else if (overriding.isMethod() && overridden.isMethod()) {
- code = CLF_REDEFINED_METHOD_TYPE_CONFLICT;
String descRaw = validatorMessageHelper.descriptionDifferentFrom(overriding, overridden);
String desc = (descRaw.toLowerCase().contains("signature") ? "" : "signature of ")
+ overridingSource + descRaw;
- message = getMessageForCLF_REDEFINED_METHOD_TYPE_CONFLICT(
+ issueItem = CLF_REDEFINED_METHOD_TYPE_CONFLICT.toIssueItem(
UtilN4.toUpperCaseFirst(desc),
redefinitionTypeName,
validatorMessageHelper.descriptionDifferentFrom(overridden, overriding),
validatorMessageHelper.trimTypesystemMessage(result),
extraMessage);
} else {
- code = CLF_REDEFINED_MEMBER_TYPE_INVALID;
- message = getMessageForCLF_REDEFINED_MEMBER_TYPE_INVALID(
+ issueItem = CLF_REDEFINED_MEMBER_TYPE_INVALID.toIssueItem(
overridingSource + validatorMessageHelper.descriptionDifferentFrom(overriding, overridden),
validatorMessageHelper.descriptionDifferentFrom(overridden, overriding),
redefinitionTypeName,
@@ -1051,73 +1016,69 @@ private void messageOverrideMemberTypeConflict(RedefinitionType redefinitionType
extraMessage);
}
- addIssueToMemberOrInterfaceReference(redefinitionType, overriding, overridden, message, code);
+ addIssueToMemberOrInterfaceReference(redefinitionType, overriding, overridden, issueItem);
}
private void messageOverrideAbstract(RedefinitionType redefinitionType, TMember overriding, TMember overridden) {
- String message = getMessageForCLF_OVERRIDEN_CONCRETE_WITH_ABSTRACT(
+ IssueItem issueItem = CLF_OVERRIDEN_CONCRETE_WITH_ABSTRACT.toIssueItem(
validatorMessageHelper.descriptionDifferentFrom(overriding, overridden),
validatorMessageHelper.descriptionDifferentFrom(overridden, overriding));
- addIssueToMemberOrInterfaceReference(redefinitionType, overriding, overridden, message,
- CLF_OVERRIDEN_CONCRETE_WITH_ABSTRACT);
+ addIssueToMemberOrInterfaceReference(redefinitionType, overriding, overridden, issueItem);
}
private void messageOverrideAccessibilityReduced(RedefinitionType redefinitionType, TMember overriding,
TMember overridden) {
- String message = getMessageForCLF_OVERRIDE_VISIBILITY(
+ IssueItem issueItem = CLF_OVERRIDE_VISIBILITY.toIssueItemWithData(
+ List.of(IssueUserDataKeys.CLF_OVERRIDE_VISIBILITY.OVERRIDDEN_MEMBER_ACCESS_MODIFIER,
+ overridden.getMemberAccessModifier().getName(),
+ IssueUserDataKeys.CLF_OVERRIDE_VISIBILITY.OVERRIDDEN_MEMBER_NAME,
+ overridden.getName(),
+ IssueUserDataKeys.CLF_OVERRIDE_VISIBILITY.SUPER_CLASS_NAME,
+ overridden.getContainingType().getName()),
validatorMessageHelper.descriptionDifferentFrom(overriding, overridden),
validatorMessageHelper.descriptionDifferentFrom(overridden, overriding));
- addIssueToMemberOrInterfaceReference(redefinitionType, overriding, overridden, message,
- CLF_OVERRIDE_VISIBILITY,
- IssueUserDataKeys.CLF_OVERRIDE_VISIBILITY.OVERRIDDEN_MEMBER_ACCESS_MODIFIER,
- overridden.getMemberAccessModifier().getName(),
- IssueUserDataKeys.CLF_OVERRIDE_VISIBILITY.OVERRIDDEN_MEMBER_NAME, overridden.getName(),
- IssueUserDataKeys.CLF_OVERRIDE_VISIBILITY.SUPER_CLASS_NAME, overridden.getContainingType().getName());
+ addIssueToMemberOrInterfaceReference(redefinitionType, overriding, overridden, issueItem);
}
private void messageOverrideNonAccessible(@SuppressWarnings("unused") RedefinitionType redefinitionType,
N4ClassifierDefinition contextDef, Type contextType, TMember overriding, TMember overridden) {
- String message = getMessageForCLF_REDEFINED_NON_ACCESSIBLE(
+ IssueItem issueItem = CLF_REDEFINED_NON_ACCESSIBLE.toIssueItem(
validatorMessageHelper.descriptionDifferentFrom(overriding, overridden),
validatorMessageHelper.descriptionDifferentFrom(overridden, overriding));
if (overriding.getContainingType() == contextType) {
- addIssue(message, overriding.getAstElement(), N4JSPackage.Literals.PROPERTY_NAME_OWNER__DECLARED_NAME,
- CLF_REDEFINED_NON_ACCESSIBLE);
+ addIssue(overriding.getAstElement(), N4JSPackage.Literals.PROPERTY_NAME_OWNER__DECLARED_NAME, issueItem);
} else if (contextDef instanceof N4TypeDeclaration) {
- addIssue(message, contextDef, N4JSPackage.Literals.N4_TYPE_DECLARATION__NAME,
- CLF_REDEFINED_NON_ACCESSIBLE);
+ addIssue(contextDef, N4JSPackage.Literals.N4_TYPE_DECLARATION__NAME, issueItem);
} else {
- addIssue(message, contextDef, CLF_REDEFINED_NON_ACCESSIBLE);
+ addIssue(contextDef, issueItem);
}
}
private void messageOverrideFinal(RedefinitionType redefinitionType, TMember overriding, TMember overridden) {
- String message = getMessageForCLF_OVERRIDE_FINAL(
+ IssueItem issueItem = CLF_OVERRIDE_FINAL.toIssueItemWithData(
+ List.of(CLF_OVERRIDE_FINAL.name(),
+ IssueUserDataKeys.CLF_OVERRIDE_FINAL.OVERRIDDEN_MEMBER_URI,
+ EcoreUtil.getURI(overridden).toString()),
validatorMessageHelper.descriptionDifferentFrom(overriding, overridden),
validatorMessageHelper.descriptionDifferentFrom(overridden, overriding));
- addIssueToMemberOrInterfaceReference(redefinitionType, overriding, overridden, message,
- CLF_OVERRIDE_FINAL,
- IssueUserDataKeys.CLF_OVERRIDE_FINAL.OVERRIDDEN_MEMBER_URI,
- EcoreUtil.getURI(overridden).toString());
+ addIssueToMemberOrInterfaceReference(redefinitionType, overriding, overridden, issueItem);
}
private void messageOverrideWithFinalOrConstField(RedefinitionType redefinitionType, TMember overriding,
TMember overridden) {
String badModifier = overriding.isConst() ? "const" : "final";
String prefix = overridden instanceof TField ? "non-" + badModifier + " " : "";
- String message = getMessageForCLF_OVERRIDE_WITH_FINAL_OR_CONST_FIELD(
+ IssueItem issueItem = CLF_OVERRIDE_WITH_FINAL_OR_CONST_FIELD.toIssueItem(
prefix + validatorMessageHelper.descriptionDifferentFrom(overridden, overriding),
badModifier);
- addIssueToMemberOrInterfaceReference(redefinitionType, overriding, overridden, message,
- CLF_OVERRIDE_WITH_FINAL_OR_CONST_FIELD);
+ addIssueToMemberOrInterfaceReference(redefinitionType, overriding, overridden, issueItem);
}
private void messageOverrideConst(RedefinitionType redefinitionType, TMember overriding, TField overridden) {
- String message = getMessageForCLF_OVERRIDE_CONST(
+ IssueItem issueItem = CLF_OVERRIDE_CONST.toIssueItem(
validatorMessageHelper.descriptionDifferentFrom(overriding, overridden),
validatorMessageHelper.descriptionDifferentFrom(overridden, overriding));
- addIssueToMemberOrInterfaceReference(redefinitionType, overriding, overridden, message,
- CLF_OVERRIDE_CONST);
+ addIssueToMemberOrInterfaceReference(redefinitionType, overriding, overridden, issueItem);
}
/**
@@ -1126,19 +1087,18 @@ private void messageOverrideConst(RedefinitionType redefinitionType, TMember ove
*/
private void messageOverrideMetaTypeIncompatible(RedefinitionType redefinitionType, TMember overriding,
TMember overridden, MemberMatrix mm) {
+
if (redefinitionType == RedefinitionType.overridden) {
- String message = getMessageForCLF_OVERRIDE_MEMBERTYPE_INCOMPATIBLE(
+ IssueItem issueItem = CLF_OVERRIDE_MEMBERTYPE_INCOMPATIBLE.toIssueItem(
validatorMessageHelper.descriptionDifferentFrom(overriding, overridden),
validatorMessageHelper.descriptionDifferentFrom(overridden, overriding));
- addIssueToMemberOrInterfaceReference(redefinitionType, overriding, overridden, message,
- CLF_OVERRIDE_MEMBERTYPE_INCOMPATIBLE);
+ addIssueToMemberOrInterfaceReference(redefinitionType, overriding, overridden, issueItem);
} else { // consumed method implicitly overrides:
- String message = getMessageForCLF_IMPLEMENT_MEMBERTYPE_INCOMPATIBLE(
- validatorMessageHelper.descriptionDifferentFrom(overriding, overridden),
+ IssueItem issueItem = CLF_IMPLEMENT_MEMBERTYPE_INCOMPATIBLE.toIssueItem(
validatorMessageHelper.descriptionDifferentFrom(overridden, overriding),
+ validatorMessageHelper.descriptionDifferentFrom(overriding, overridden),
cfOtherImplementedMembers(mm, overridden));
- addIssueToMemberOrInterfaceReference(redefinitionType, overriding, overridden, message,
- CLF_IMPLEMENT_MEMBERTYPE_INCOMPATIBLE);
+ addIssueToMemberOrInterfaceReference(redefinitionType, overriding, overridden, issueItem);
}
}
@@ -1154,31 +1114,25 @@ private String cfOtherImplementedMembers(MemberMatrix mm, TMember... filteredMem
}
private void messageIncompatibleMembersToImplement(Iterable implementedMembers) {
- String message = getMessageForCLF_CONSUMED_MEMBER_UNSOLVABLE_CONFLICT(
- validatorMessageHelper.descriptions(implementedMembers));
- addIssue(message, CLF_CONSUMED_MEMBER_UNSOLVABLE_CONFLICT);
+ addIssue(CLF_CONSUMED_MEMBER_UNSOLVABLE_CONFLICT, validatorMessageHelper.descriptions(implementedMembers));
}
private void messageIncompatibleInheritedMembersToImplement(TMember inheritedMember,
Iterable implementedMembers) {
- String message = getMessageForCLF_CONSUMED_INHERITED_MEMBER_UNSOLVABLE_CONFLICT(
+ addIssue(CLF_CONSUMED_INHERITED_MEMBER_UNSOLVABLE_CONFLICT,
validatorMessageHelper.description(inheritedMember),
validatorMessageHelper.descriptions(implementedMembers));
- addIssue(message, CLF_CONSUMED_INHERITED_MEMBER_UNSOLVABLE_CONFLICT);
}
private void messageConflictingMixins(List extends TMember> conflictingMembers) {
- String message = getMessageForCLF_CONSUMED_MEMBER_SOLVABLE_CONFLICT(
- validatorMessageHelper.descriptions(conflictingMembers));
- addIssue(message, CLF_CONSUMED_MEMBER_SOLVABLE_CONFLICT);
+ addIssue(CLF_CONSUMED_MEMBER_SOLVABLE_CONFLICT, validatorMessageHelper.descriptions(conflictingMembers));
}
private void messageMissingAccessor(String missingAccessor, List extends TMember> conflictingMembers) {
// CLF_IMPLEMENT_MIXIN_MISSING_ACCESSOR
- String message = getMessageForCLF_CONSUMED_FIELD_ACCESSOR_PAIR_INCOMPLETE(
+ addIssue(CLF_CONSUMED_FIELD_ACCESSOR_PAIR_INCOMPLETE,
missingAccessor,
validatorMessageHelper.descriptions(conflictingMembers));
- addIssue(message, CLF_CONSUMED_FIELD_ACCESSOR_PAIR_INCOMPLETE);
}
private void messageMissingOwnedAccessor(FieldAccessor accessor) {
@@ -1199,33 +1153,29 @@ private void messageMissingOwnedAccessor(FieldAccessor accessor) {
private void messageMissingOwnedAccessorN4JS(String accessorDescription, String verb, String counterpartDescription,
FieldAccessor accessor) {
- String message = getMessageForCLF_UNMATCHED_ACCESSOR_OVERRIDE(accessorDescription, verb,
+ IssueItem issueItem = CLF_UNMATCHED_ACCESSOR_OVERRIDE.toIssueItem(accessorDescription, verb,
counterpartDescription);
- addIssue(message, accessor.getAstElement(),
- N4JSPackage.Literals.PROPERTY_NAME_OWNER__DECLARED_NAME, CLF_UNMATCHED_ACCESSOR_OVERRIDE);
+ addIssue(accessor.getAstElement(), N4JSPackage.Literals.PROPERTY_NAME_OWNER__DECLARED_NAME, issueItem);
}
private void messageMissingOwnedAccessorJS(String accessorDescription, String verb, String counterpartDescription,
FieldAccessor accessor) {
- String message = getMessageForCLF_UNMATCHED_ACCESSOR_OVERRIDE_JS(accessorDescription, verb,
+ IssueItem issueItem = CLF_UNMATCHED_ACCESSOR_OVERRIDE_JS.toIssueItem(accessorDescription, verb,
counterpartDescription);
- addIssue(message, accessor.getAstElement(),
- N4JSPackage.Literals.PROPERTY_NAME_OWNER__DECLARED_NAME, CLF_UNMATCHED_ACCESSOR_OVERRIDE_JS);
+ addIssue(accessor.getAstElement(), N4JSPackage.Literals.PROPERTY_NAME_OWNER__DECLARED_NAME, issueItem);
}
private void messageMissingOwnedAccessorCorrespondingConsumedAccessor(FieldAccessor accessor,
N4ClassifierDefinition definition) {
- String message = getMessageForCLF_UNMATCHED_ACCESSOR_OVERRIDE(
+ IssueItem issueItem = CLF_UNMATCHED_ACCESSOR_OVERRIDE.toIssueItem(
org.eclipse.xtext.util.Strings.toFirstUpper(validatorMessageHelper.description(accessor)),
"consumed",
accessor instanceof TSetter ? "getter" : "setter");
- addIssue(message, definition,
- N4JSPackage.Literals.N4_TYPE_DECLARATION__NAME, CLF_UNMATCHED_ACCESSOR_OVERRIDE);
+ addIssue(definition, N4JSPackage.Literals.N4_TYPE_DECLARATION__NAME, issueItem);
}
private void addIssueToMemberOrInterfaceReference(RedefinitionType redefinitionType, TMember overriding,
- TMember implemented,
- String message, String issueCode, String... issueData) {
+ TMember implemented, IssueItem issueItem) {
if (redefinitionType == RedefinitionType.overridden
&& overriding.getContainingType() != getCurrentClassifier()) {
@@ -1234,9 +1184,7 @@ private void addIssueToMemberOrInterfaceReference(RedefinitionType redefinitionT
TClassifier currentClassifier = getCurrentClassifier();
if (overriding.getContainingType() == currentClassifier) {
- addIssue(message, overriding.getAstElement(), N4JSPackage.Literals.PROPERTY_NAME_OWNER__DECLARED_NAME,
- issueCode,
- issueData);
+ addIssue(overriding.getAstElement(), N4JSPackage.Literals.PROPERTY_NAME_OWNER__DECLARED_NAME, issueItem);
} else {
MemberCollector memberCollector = containerTypesHelper.fromContext(getCurrentClassifierDefinition());
ContainerType> bequestingType = memberCollector.directSuperTypeBequestingMember(currentClassifier,
@@ -1250,7 +1198,7 @@ private void addIssueToMemberOrInterfaceReference(RedefinitionType redefinitionT
EStructuralFeature feature = refInAST.eContainingFeature();
List> list = (List>) getCurrentClassifierDefinition().eGet(feature);
int index = list.indexOf(refInAST);
- addIssue(message, getCurrentClassifierDefinition(), feature, index, issueCode, issueData);
+ addIssue(getCurrentClassifierDefinition(), feature, index, issueItem);
}
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSMemberValidator.xtend b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSMemberValidator.xtend
index c1b8ef36e6..d13f67b191 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSMemberValidator.xtend
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSMemberValidator.xtend
@@ -49,7 +49,6 @@ import org.eclipse.n4js.utils.ContainerTypesHelper
import org.eclipse.n4js.utils.DeclMergingHelper
import org.eclipse.n4js.utils.N4JSLanguageUtils
import org.eclipse.n4js.validation.AbstractN4JSDeclarativeValidator
-import org.eclipse.n4js.validation.IssueCodes
import org.eclipse.n4js.validation.JavaScriptVariantHelper
import org.eclipse.xtext.EcoreUtil2
import org.eclipse.xtext.nodemodel.util.NodeModelUtils
@@ -126,8 +125,7 @@ class N4JSMemberValidator extends AbstractN4JSDeclarativeValidator {
val name = owner.name
if (name !== null) {
if (!owner.isValidName) {
- val message = IssueCodes.getMessageForAST_RESERVED_IDENTIFIER(name);
- addIssue(message, owner, PROPERTY_NAME_OWNER__DECLARED_NAME, IssueCodes.AST_RESERVED_IDENTIFIER);
+ addIssue(owner, PROPERTY_NAME_OWNER__DECLARED_NAME, AST_RESERVED_IDENTIFIER.toIssueItem(name));
}
}
}
@@ -237,8 +235,7 @@ class N4JSMemberValidator extends AbstractN4JSDeclarativeValidator {
return;
for (sm : ptrsInAST.astStructuralMembers) {
- val message = IssueCodes.getMessageForTYS_ADDITIONAL_STRUCTURAL_MEMBERS_ON_TYPE_VARS()
- addIssue(message, sm, TYS_ADDITIONAL_STRUCTURAL_MEMBERS_ON_TYPE_VARS)
+ addIssue(sm, TYS_ADDITIONAL_STRUCTURAL_MEMBERS_ON_TYPE_VARS.toIssueItem())
}
}
@@ -262,20 +259,16 @@ class N4JSMemberValidator extends AbstractN4JSDeclarativeValidator {
// name may be null (invalid file), we do not need an NPE here
if (name !== null && name.startsWith('$')) {
- val message = IssueCodes.getMessageForCLF_NAME_DOLLAR()
- addIssue(message, member.astElement, PROPERTY_NAME_OWNER__DECLARED_NAME, CLF_NAME_DOLLAR)
+ addIssue(member.astElement, PROPERTY_NAME_OWNER__DECLARED_NAME, CLF_NAME_DOLLAR.toIssueItem());
}
}
def private internalCheckAbstractAndFinal(TMember member) {
if (member.final) {
if (member.abstract) {
- val message = IssueCodes.getMessageForCLF_ABSTRACT_FINAL(member.keyword)
- addIssue(message, member.astElement, PROPERTY_NAME_OWNER__DECLARED_NAME, IssueCodes.CLF_ABSTRACT_FINAL)
+ addIssue(member.astElement, PROPERTY_NAME_OWNER__DECLARED_NAME, CLF_ABSTRACT_FINAL.toIssueItem(member.keyword))
} else if (member.containingType instanceof TInterface && !(member instanceof TMethod)) {
- val message = IssueCodes.getMessageForCLF_NO_FINAL_INTERFACE_MEMBER()
- addIssue(message, member.astElement, PROPERTY_NAME_OWNER__DECLARED_NAME,
- IssueCodes.CLF_NO_FINAL_INTERFACE_MEMBER)
+ addIssue(member.astElement, PROPERTY_NAME_OWNER__DECLARED_NAME, CLF_NO_FINAL_INTERFACE_MEMBER.toIssueItem());
}
}
}
@@ -287,9 +280,7 @@ class N4JSMemberValidator extends AbstractN4JSDeclarativeValidator {
val parent = member.eContainer;
if (parent instanceof TInterface) {
if (parent.typingStrategy === TypingStrategy.STRUCTURAL) {
- val message = IssueCodes.getMessageForSTRCT_ITF_CANNOT_CONTAIN_STATIC_MEMBERS();
- addIssue(message, member.astElement, PROPERTY_NAME_OWNER__DECLARED_NAME,
- IssueCodes.STRCT_ITF_CANNOT_CONTAIN_STATIC_MEMBERS);
+ addIssue(member.astElement, PROPERTY_NAME_OWNER__DECLARED_NAME, STRCT_ITF_CANNOT_CONTAIN_STATIC_MEMBERS.toIssueItem());
return false;
}
}
@@ -322,8 +313,7 @@ class N4JSMemberValidator extends AbstractN4JSDeclarativeValidator {
private def holdsConstructorModifiers(TMethod constructor) {
if ((constructor.abstract && !(constructor.containingType instanceof TInterface)) // ctor in interface may be abstract (actually it *must* be abstract)
|| constructor.static || constructor.final || constructor.hasIllegalOverride) {
- val message = getMessageForCLF_CTOR_ILLEGAL_MODIFIER
- addIssue(message, constructor.astElement, PROPERTY_NAME_OWNER__DECLARED_NAME, CLF_CTOR_ILLEGAL_MODIFIER)
+ addIssue(constructor.astElement, PROPERTY_NAME_OWNER__DECLARED_NAME, CLF_CTOR_ILLEGAL_MODIFIER.toIssueItem())
return false;
}
return true;
@@ -340,8 +330,7 @@ class N4JSMemberValidator extends AbstractN4JSDeclarativeValidator {
*/
private def boolean holdsConstructorInInterfaceDoesNotHaveBody(TMethod constructor) {
if (constructor.containingType instanceof TInterface && !constructor.hasNoBody) {
- addIssue(getMessageForITF_NO_PROPERTY_BODY("Constructors", ""), constructor.astElement, PROPERTY_NAME_OWNER__DECLARED_NAME,
- ITF_NO_PROPERTY_BODY);
+ addIssue(constructor.astElement, PROPERTY_NAME_OWNER__DECLARED_NAME, ITF_NO_PROPERTY_BODY.toIssueItem("Constructors", ""));
return false;
}
return true;
@@ -353,8 +342,7 @@ class N4JSMemberValidator extends AbstractN4JSDeclarativeValidator {
private def boolean holdsConstructorInInterfaceRequiresCovarianceAnnotation(TMethod constructor) {
val container = constructor.containingType;
if (container instanceof TInterface && !N4JSLanguageUtils.hasCovariantConstructor(container as TInterface, declMergingHelper)) {
- addIssue(getMessageForITF_CONSTRUCTOR_COVARIANCE, constructor.astElement,
- PROPERTY_NAME_OWNER__DECLARED_NAME, ITF_CONSTRUCTOR_COVARIANCE);
+ addIssue(constructor.astElement, PROPERTY_NAME_OWNER__DECLARED_NAME, ITF_CONSTRUCTOR_COVARIANCE.toIssueItem());
return false;
}
return true;
@@ -366,8 +354,7 @@ class N4JSMemberValidator extends AbstractN4JSDeclarativeValidator {
private def boolean holdsConstructorNoReturnType(TMethod constructor) {
val constructorDecl = constructor.astElement as N4MethodDeclaration;
if (constructorDecl.declaredReturnTypeRefInAST !== null) {
- addIssue(getMessageForCLF_CTOR_RETURN_TYPE, constructorDecl,
- FUNCTION_DEFINITION__DECLARED_RETURN_TYPE_REF_NODE, CLF_CTOR_RETURN_TYPE);
+ addIssue(constructorDecl, FUNCTION_DEFINITION__DECLARED_RETURN_TYPE_REF_NODE, CLF_CTOR_RETURN_TYPE.toIssueItem());
return false;
}
return true;
@@ -384,8 +371,7 @@ class N4JSMemberValidator extends AbstractN4JSDeclarativeValidator {
val constructorDecl = method.astElement as N4MethodDeclaration;
val offsetLength = findTypeVariablesOffset(constructorDecl);
- addIssue(IssueCodes.messageForCLF_CTOR_NO_TYPE_PARAMETERS, constructorDecl, offsetLength.key,
- offsetLength.value, IssueCodes.CLF_CTOR_NO_TYPE_PARAMETERS);
+ addIssue(constructorDecl, offsetLength.key, offsetLength.value, CLF_CTOR_NO_TYPE_PARAMETERS.toIssueItem());
return false;
}
@@ -426,10 +412,9 @@ class N4JSMemberValidator extends AbstractN4JSDeclarativeValidator {
if (! existsSuperCall) {
val className = (ctor.eContainer as IdentifiableElement).name;
addIssue(
- getMessageForKEY_SUP_REQUIRE_EXPLICIT_SUPERCTOR_CALL(className),
constructor.astElement,
PROPERTY_NAME_OWNER__DECLARED_NAME,
- KEY_SUP_REQUIRE_EXPLICIT_SUPERCTOR_CALL
+ KEY_SUP_REQUIRE_EXPLICIT_SUPERCTOR_CALL.toIssueItem(className)
)
return false;
} // else: ok so far, more checks on super call are performed in N4JSExpressionValidator
@@ -449,26 +434,26 @@ class N4JSMemberValidator extends AbstractN4JSDeclarativeValidator {
if (isCallSig || isConstructSig) {
// constraint: only in .n4jsd files
if (!jsVariantHelper.isExternalMode(astNode)) {
- addIssue(getMessageForCLF_CALL_CONSTRUCT_SIG_ONLY_IN_N4JSD, astNode, CLF_CALL_CONSTRUCT_SIG_ONLY_IN_N4JSD);
+ addIssue(astNode, CLF_CALL_CONSTRUCT_SIG_ONLY_IN_N4JSD.toIssueItem());
return false;
}
// constraint: only in shapes and EcmaScript classes
val owner = if (methodInAST.isLeft) methodInAST.getLeft.owner; // owners of TStructMethods are never annotated with @N4JS
if (methodInAST.isLeft && !N4JSLanguageUtils.isShapeOrEcmaScript(owner)) {
- addIssue(getMessageForCLF_CALL_CONSTRUCT_SIG_NOT_IN_N4JS, astNode, CLF_CALL_CONSTRUCT_SIG_NOT_IN_N4JS);
+ addIssue(astNode, CLF_CALL_CONSTRUCT_SIG_NOT_IN_N4JS.toIssueItem());
return false;
}
// constraint: must not have a body
val body = if (methodInAST.isLeft) methodInAST.getLeft.body; // TStructMethods never have a body
if (body !== null) {
- addIssue(getMessageForCLF_CALL_CONSTRUCT_SIG_BODY, astNode, CLF_CALL_CONSTRUCT_SIG_BODY);
+ addIssue(astNode, CLF_CALL_CONSTRUCT_SIG_BODY.toIssueItem());
return false;
}
// constraint: not more than one call/construct signature per class
val haveDuplicate = (if (isCallSig) allCallSigs else allConstructSigs).size >= 2;
if (haveDuplicate) {
val kind = if (isCallSig) "call" else "construct";
- addIssue(getMessageForCLF_CALL_CONSTRUCT_SIG_DUPLICATE(kind), astNode, CLF_CALL_CONSTRUCT_SIG_DUPLICATE);
+ addIssue(astNode, CLF_CALL_CONSTRUCT_SIG_DUPLICATE.toIssueItem(kind));
return false;
}
// constraint: private not allowed in interfaces
@@ -485,7 +470,7 @@ class N4JSMemberValidator extends AbstractN4JSDeclarativeValidator {
if (isConstructSig) {
// constraint: only in classes
if (!(astNode.eContainer instanceof N4InterfaceDeclaration || astNode.eContainer instanceof StructuralTypeRef)) {
- addIssue(messageForCLF_CONSTRUCT_SIG_ONLY_IN_INTERFACE, astNode, CLF_CONSTRUCT_SIG_ONLY_IN_INTERFACE);
+ addIssue(astNode, CLF_CONSTRUCT_SIG_ONLY_IN_INTERFACE.toIssueItem());
return false;
}
// constraint: must have non-void return type
@@ -496,7 +481,7 @@ class N4JSMemberValidator extends AbstractN4JSDeclarativeValidator {
};
val returnTypeRef = definedFunction?.returnTypeRef;
if (returnTypeRef === null || TypeUtils.isVoid(returnTypeRef)) {
- addIssue(messageForCLF_CONSTRUCT_SIG_VOID_RETURN_TYPE, astNode, CLF_CONSTRUCT_SIG_VOID_RETURN_TYPE);
+ addIssue(astNode, CLF_CONSTRUCT_SIG_VOID_RETURN_TYPE.toIssueItem());
return false;
}
}
@@ -513,11 +498,9 @@ class N4JSMemberValidator extends AbstractN4JSDeclarativeValidator {
if (requireCheckForMissingBody && !memberIsAbstract &&
(member.astElement as N4MemberDeclaration).body === null) {
if (member.isConstructor) {
- addIssue(messageForCLF_MISSING_CTOR_BODY, member.astElement, PROPERTY_NAME_OWNER__DECLARED_NAME,
- IssueCodes.CLF_MISSING_CTOR_BODY)
+ addIssue(member.astElement, PROPERTY_NAME_OWNER__DECLARED_NAME, CLF_MISSING_CTOR_BODY.toIssueItem())
} else {
- val message = IssueCodes.getMessageForCLF_MISSING_BODY(member.keyword, member.name)
- addIssue(message, member.astElement, PROPERTY_NAME_OWNER__DECLARED_NAME, IssueCodes.CLF_MISSING_BODY)
+ addIssue(member.astElement, PROPERTY_NAME_OWNER__DECLARED_NAME, CLF_MISSING_BODY.toIssueItem(member.keyword, member.name))
}
return false;
}
@@ -532,8 +515,7 @@ class N4JSMemberValidator extends AbstractN4JSDeclarativeValidator {
if (container instanceof TN4Classifier) {
val isStructural = container.typingStrategy === TypingStrategy.STRUCTURAL;
if (member.abstract && member.static && !container.external && !isStructural) {
- addIssue(getMessageForCLF_STATIC_ABSTRACT(member.keyword, member.name), member.astElement,
- PROPERTY_NAME_OWNER__DECLARED_NAME, CLF_STATIC_ABSTRACT)
+ addIssue(member.astElement, PROPERTY_NAME_OWNER__DECLARED_NAME, CLF_STATIC_ABSTRACT.toIssueItem(member.keyword, member.name))
return false;
}
}
@@ -542,8 +524,7 @@ class N4JSMemberValidator extends AbstractN4JSDeclarativeValidator {
def private boolean holdsAbstractMethodMustHaveNoBody(TMember member) {
if (member.abstract && (member.astElement as N4MemberDeclaration).body !== null) {
- val message = IssueCodes.getMessageForCLF_ABSTRACT_BODY
- addIssue(message, member.astElement, PROPERTY_NAME_OWNER__DECLARED_NAME, IssueCodes.CLF_ABSTRACT_BODY)
+ addIssue(member.astElement, PROPERTY_NAME_OWNER__DECLARED_NAME, CLF_ABSTRACT_BODY.toIssueItem())
return false;
}
return true;
@@ -553,9 +534,7 @@ class N4JSMemberValidator extends AbstractN4JSDeclarativeValidator {
if (member.abstract) {
val classifier = EcoreUtil2.getContainerOfType(member, TClassifier)
if (classifier !== null && !classifier.abstract) {
- val message = IssueCodes.getMessageForCLF_ABSTRACT_MISSING(member.keyword, member.name, classifier.name)
- addIssue(message, member.astElement, PROPERTY_NAME_OWNER__DECLARED_NAME,
- IssueCodes.CLF_ABSTRACT_MISSING)
+ addIssue(member.astElement, PROPERTY_NAME_OWNER__DECLARED_NAME, CLF_ABSTRACT_MISSING.toIssueItem(member.keyword, member.name, classifier.name))
return false;
}
}
@@ -572,9 +551,7 @@ class N4JSMemberValidator extends AbstractN4JSDeclarativeValidator {
val hasPrivateModifier = (memberAccessModifier === MemberAccessModifier.PRIVATE)
val hasProjectModifier = (memberAccessModifier === MemberAccessModifier.PROJECT)
if (hasPrivateModifier || hasProjectModifier) {
- val message = IssueCodes.getMessageForCLF_INTERNAL_BAD_WITH_PRIVATE_OR_PROJECT();
- addIssue(message, tmember.astElement, PROPERTY_NAME_OWNER__DECLARED_NAME,
- IssueCodes.CLF_INTERNAL_BAD_WITH_PRIVATE_OR_PROJECT);
+ addIssue(tmember.astElement, PROPERTY_NAME_OWNER__DECLARED_NAME, CLF_INTERNAL_BAD_WITH_PRIVATE_OR_PROJECT.toIssueItem());
}
}
}
@@ -586,9 +563,7 @@ class N4JSMemberValidator extends AbstractN4JSDeclarativeValidator {
if (member.containingType instanceof TInterface) {
val memberAccessModifier = member.memberAccessModifier
if (memberAccessModifier === MemberAccessModifier.PRIVATE) {
- val message = IssueCodes.getMessageForCLF_MINIMAL_ACCESSIBILITY_IN_INTERFACES();
- addIssue(message, member.astElement, PROPERTY_NAME_OWNER__DECLARED_NAME,
- IssueCodes.CLF_MINIMAL_ACCESSIBILITY_IN_INTERFACES);
+ addIssue(member.astElement, PROPERTY_NAME_OWNER__DECLARED_NAME, CLF_MINIMAL_ACCESSIBILITY_IN_INTERFACES.toIssueItem());
return false;
}
}
@@ -598,8 +573,7 @@ class N4JSMemberValidator extends AbstractN4JSDeclarativeValidator {
def private internalCheckGetterType(N4GetterDeclaration n4GetterDeclaration) {
val getterType = n4GetterDeclaration.declaredTypeRef?.declaredType;
if (getterType !== null && getterType instanceof VoidType) {
- val message = IssueCodes.messageForCLF_VOID_ACCESSOR;
- addIssue(message, n4GetterDeclaration, PROPERTY_NAME_OWNER__DECLARED_NAME, IssueCodes.CLF_VOID_ACCESSOR);
+ addIssue(n4GetterDeclaration, PROPERTY_NAME_OWNER__DECLARED_NAME, CLF_VOID_ACCESSOR.toIssueItem());
}
}
@@ -626,11 +600,9 @@ class N4JSMemberValidator extends AbstractN4JSDeclarativeValidator {
val structuralFieldDuplicate = structuralMembersByNameAndStatic.get(it).head
val existingClassifierMember = membersByNameAndStatic.get(it).headExceptNonExistantGetters(structFieldInitMode)
if (existingClassifierMember?.memberAccessModifier == MemberAccessModifier.PUBLIC) {
- val message = getMessageForCLF_DUP_MEMBER(structuralFieldDuplicate.descriptionWithLine,
- existingClassifierMember.descriptionWithLine);
val index = thisTypeRefStructInAST.structuralMembers.indexOf(structuralFieldDuplicate)
- addIssue(message, thisTypeRefStructInAST,
- TypeRefsPackage.Literals.STRUCTURAL_TYPE_REF__AST_STRUCTURAL_MEMBERS, index, CLF_DUP_MEMBER)
+ addIssue(thisTypeRefStructInAST, TypeRefsPackage.Literals.STRUCTURAL_TYPE_REF__AST_STRUCTURAL_MEMBERS, index,
+ CLF_DUP_MEMBER.toIssueItem(structuralFieldDuplicate.descriptionWithLine, existingClassifierMember.descriptionWithLine));
}
}
]
@@ -662,9 +634,9 @@ class N4JSMemberValidator extends AbstractN4JSDeclarativeValidator {
def checkFixmeUsedWithTestAnnotation(N4MethodDeclaration methodDecl) {
ANNOTATIONS_REQUIRE_TEST.forEach [ annotation |
if (annotation.hasAnnotation(methodDecl) && !TEST_METHOD.hasAnnotation(methodDecl)) {
- addIssue(getMessageForANN_REQUIRES_TEST('''@«annotation.name»'''), methodDecl.annotations.findFirst [
+ addIssue(methodDecl.annotations.findFirst [
name == annotation.name
- ], N4JSPackage.eINSTANCE.annotation_Name, ANN_REQUIRES_TEST);
+ ], N4JSPackage.eINSTANCE.annotation_Name, ANN_REQUIRES_TEST.toIssueItem('''@«annotation.name»'''));
}
];
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSModuleValidator.xtend b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSModuleValidator.xtend
index 00d2039fae..7a94be2ef8 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSModuleValidator.xtend
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSModuleValidator.xtend
@@ -29,7 +29,7 @@ import org.eclipse.n4js.ts.types.TModule
import org.eclipse.n4js.ts.types.TypesPackage
import org.eclipse.n4js.utils.URIUtils
import org.eclipse.n4js.validation.AbstractN4JSDeclarativeValidator
-import org.eclipse.n4js.validation.IssueCodes
+import org.eclipse.n4js.validation.IssueItem
import org.eclipse.n4js.validation.N4JSResourceValidator
import org.eclipse.n4js.workspace.WorkspaceAccess
import org.eclipse.xtext.EcoreUtil2
@@ -44,6 +44,8 @@ import org.eclipse.xtext.resource.impl.ResourceDescriptionsProvider
import org.eclipse.xtext.validation.Check
import org.eclipse.xtext.validation.EValidatorRegistrar
+import static org.eclipse.n4js.validation.IssueCodes.*
+
import static extension org.eclipse.n4js.utils.N4JSLanguageUtils.*
/**
@@ -85,8 +87,7 @@ class N4JSModuleValidator extends AbstractN4JSDeclarativeValidator {
if (nodes.size > 0) {
val offset = nodes.get(0).offset;
if (offset !== 0) {
- val message = IssueCodes.getMessageForSCR_HASHBANG_WRONG_LOCATION();
- addIssue(message, script, N4JSPackage.eINSTANCE.script_Hashbang, IssueCodes.SCR_HASHBANG_WRONG_LOCATION);
+ addIssue(script, N4JSPackage.eINSTANCE.script_Hashbang, SCR_HASHBANG_WRONG_LOCATION.toIssueItem());
}
}
}
@@ -268,14 +269,12 @@ class N4JSModuleValidator extends AbstractN4JSDeclarativeValidator {
val filePathStr = sortedMutVisibleResourceURIs
.filter[implModule != it]
.map[segmentsList.drop(1).join('/')].join("; ");
- val message = IssueCodes.getMessageForCLF_DUP_DEF_MODULE(module.qualifiedName, implModuleStr, filePathStr);
- addIssue(message, script, IssueCodes.CLF_DUP_DEF_MODULE);
+ addIssue(script, CLF_DUP_DEF_MODULE.toIssueItem(module.qualifiedName, implModuleStr, filePathStr));
} else {
// collision of implementation modules
// list all locations - give the user the possibility to check by himself.
val filePathStr = sortedMutVisibleResourceURIs.map[segmentsList.drop(1).join('/')].join("; ");
- val message = IssueCodes.getMessageForCLF_DUP_MODULE(module.qualifiedName, filePathStr);
- addIssue(message, script, IssueCodes.CLF_DUP_MODULE);
+ addIssue(script, CLF_DUP_MODULE.toIssueItem(module.qualifiedName, filePathStr));
}
}
}
@@ -297,11 +296,11 @@ class N4JSModuleValidator extends AbstractN4JSDeclarativeValidator {
/**
* Annotates the script with a an error marker on the first AST element or the first none-empty line.
*/
- private def void addIssue(String message, Script script, String issueCode) {
+ private def void addIssue(Script script, IssueItem issueItem) {
val first = script.scriptElements.head;
if(first !== null){
- addIssue(message, first, issueCode);
+ addIssue(first, issueItem);
return;
}
val resource = script.eResource as XtextResource;
@@ -315,7 +314,7 @@ class N4JSModuleValidator extends AbstractN4JSDeclarativeValidator {
start = matcher.start;
end = matcher.end;
}
- addIssue(message, script, start, end - start, issueCode);
+ addIssue(script, start, end - start, issueItem);
}
private def static String replaceJSXByJS(String ext) {
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSNameValidator.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSNameValidator.java
index 2e70eeaf0b..842726071a 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSNameValidator.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSNameValidator.java
@@ -27,14 +27,6 @@
import static org.eclipse.n4js.validation.IssueCodes.CLF_NAME_DOLLAR;
import static org.eclipse.n4js.validation.IssueCodes.CLF_NAME_INDISTINGUISHABLE;
import static org.eclipse.n4js.validation.IssueCodes.CLF_NAME_RESERVED;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForCLF_NAME_CONFLICTS_WITH_CONSTRUCTOR;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForCLF_NAME_CONTAINS_DISCOURAGED_CHARACTER;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForCLF_NAME_DIFFERS_TYPE;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForCLF_NAME_DOES_NOT_START_LOWERCASE;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForCLF_NAME_DOES_NOT_START_UPPERCASE;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForCLF_NAME_DOLLAR;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForCLF_NAME_INDISTINGUISHABLE;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForCLF_NAME_RESERVED;
import java.util.Collection;
@@ -51,6 +43,7 @@
import org.eclipse.n4js.typesystem.N4JSTypeSystem;
import org.eclipse.n4js.utils.N4JSLanguageHelper;
import org.eclipse.n4js.validation.AbstractN4JSDeclarativeValidator;
+import org.eclipse.n4js.validation.IssueItem;
import org.eclipse.n4js.validation.JavaScriptVariantHelper;
import org.eclipse.xtext.util.Strings;
import org.eclipse.xtext.validation.Check;
@@ -123,11 +116,10 @@ private boolean isNotChecked(N4TypeDeclaration n4TypeDeclaration) {
private boolean holdsTypeNameNotIndistinguishable(N4TypeDeclaration element, String suffix,
Collection category) {
if (category.contains(element.getName()) && !"yield".equals(element.getName())) {
- final String message = getMessageForCLF_NAME_INDISTINGUISHABLE(validatorMessageHelper.description(element),
+ final IssueItem issueItem = CLF_NAME_INDISTINGUISHABLE.toIssueItem(
+ Strings.toFirstUpper(validatorMessageHelper.description(element)),
suffix);
- addIssue(Strings.toFirstUpper(message), element,
- N4_TYPE_DECLARATION__NAME,
- CLF_NAME_INDISTINGUISHABLE);
+ addIssue(element, N4_TYPE_DECLARATION__NAME, issueItem);
return false;
}
return true;
@@ -135,12 +127,9 @@ private boolean holdsTypeNameNotIndistinguishable(N4TypeDeclaration element, Str
private boolean holdsDoesNotStartWithLowerCaseLetter(N4TypeDeclaration declaration) {
if (Character.isLowerCase(declaration.getName().charAt(0))) {
- final String msg = getMessageForCLF_NAME_DOES_NOT_START_UPPERCASE(keywordProvider.keyword(declaration));
- addIssue(
- Strings.toFirstUpper(msg),
- declaration,
- N4_TYPE_DECLARATION__NAME,
- CLF_NAME_DOES_NOT_START_UPPERCASE);
+ final IssueItem issueItem = CLF_NAME_DOES_NOT_START_UPPERCASE.toIssueItem(
+ Strings.toFirstUpper(keywordProvider.keyword(declaration)));
+ addIssue(declaration, N4_TYPE_DECLARATION__NAME, issueItem);
return false;
}
return true;
@@ -176,9 +165,8 @@ && holdsNameMayNotBeConfusedWith(n4Member, "access modifier", ACCESS_MODIFIERS)
private boolean holdsDoesNotEqualWithConstructor(final N4MemberDeclaration n4Member) {
if (n4Member.isStatic() && CONSTRUCTOR.equals(getDeclarationName(n4Member))) {
- final String message = getMessageForCLF_NAME_CONFLICTS_WITH_CONSTRUCTOR();
- addIssue(message, n4Member, N4JSMetaModelUtils.getElementNameFeature(n4Member),
- CLF_NAME_CONFLICTS_WITH_CONSTRUCTOR);
+ final IssueItem issueItem = CLF_NAME_CONFLICTS_WITH_CONSTRUCTOR.toIssueItem();
+ addIssue(n4Member, N4JSMetaModelUtils.getElementNameFeature(n4Member), issueItem);
return false;
}
return true;
@@ -190,11 +178,9 @@ private boolean holdsDoesNotContainDiscouragedCharacter(final N4MemberDeclaratio
final String declarationName = getDeclarationName(n4Member);
if (!declarationName.startsWith("$") && declarationName.contains(discouragedCharacter)) {
final String discouragedCharacterLabel = DISCOURAGED_CHARACTERS.get(discouragedCharacter);
- final String message = getMessageForCLF_NAME_CONTAINS_DISCOURAGED_CHARACTER(discouragedCharacterLabel);
- addIssue(message,
- n4Member,
- N4JSMetaModelUtils.getElementNameFeature(n4Member),
- CLF_NAME_CONTAINS_DISCOURAGED_CHARACTER);
+ final IssueItem issueItem = CLF_NAME_CONTAINS_DISCOURAGED_CHARACTER
+ .toIssueItem(discouragedCharacterLabel);
+ addIssue(n4Member, N4JSMetaModelUtils.getElementNameFeature(n4Member), issueItem);
return false;
}
}
@@ -232,12 +218,9 @@ private boolean holdsDoesNotStartWithUpperCaseLetter(N4MemberDeclaration n4Membe
}
if (Character.isUpperCase(n4Member.getName().charAt(0))) {
- final String msg = getMessageForCLF_NAME_DOES_NOT_START_LOWERCASE(keywordProvider.keyword(n4Member));
- addIssue(
- Strings.toFirstUpper(msg),
- n4Member,
- N4JSMetaModelUtils.getElementNameFeature(n4Member),
- CLF_NAME_DOES_NOT_START_LOWERCASE);
+ final IssueItem issueItem = CLF_NAME_DOES_NOT_START_LOWERCASE.toIssueItem(
+ Strings.toFirstUpper(keywordProvider.keyword(n4Member)));
+ addIssue(n4Member, N4JSMetaModelUtils.getElementNameFeature(n4Member), issueItem);
return false;
}
return true;
@@ -278,8 +261,8 @@ && holdsDoesNotContainDiscouragedCharacter(variable)) {
private boolean holdsDoesNotEqualWithConstructor(final AbstractVariable> variable) {
if (CONSTRUCTOR.equals(getVariableName(variable))) {
- final String message = getMessageForCLF_NAME_CONFLICTS_WITH_CONSTRUCTOR();
- addIssue(message, variable, ABSTRACT_VARIABLE__NAME, CLF_NAME_CONFLICTS_WITH_CONSTRUCTOR);
+ final IssueItem issueItem = CLF_NAME_CONFLICTS_WITH_CONSTRUCTOR.toIssueItem();
+ addIssue(variable, ABSTRACT_VARIABLE__NAME, issueItem);
return false;
}
return true;
@@ -288,8 +271,8 @@ private boolean holdsDoesNotEqualWithConstructor(final AbstractVariable> varia
private boolean holdsDoesNotStartWithDollarSign(final AbstractVariable> variable) {
// name may be null (invalid file), we do not need an NPE here
if (getVariableName(variable).startsWith("$")) {
- final String message = getMessageForCLF_NAME_DOLLAR();
- addIssue(message, variable, ABSTRACT_VARIABLE__NAME, CLF_NAME_DOLLAR);
+ final IssueItem issueItem = CLF_NAME_DOLLAR.toIssueItem();
+ addIssue(variable, ABSTRACT_VARIABLE__NAME, issueItem);
return false;
}
return true;
@@ -317,12 +300,9 @@ private boolean holdsStartWithLowercaseLetter(AbstractVariable> variable) {
final char first = variable.getName().charAt(0);
if (Character.isLetter(first) && !Character.isLowerCase(first)) {
- final String msg = getMessageForCLF_NAME_DOES_NOT_START_LOWERCASE(keywordProvider.keyword(variable));
- addIssue(
- Strings.toFirstUpper(msg),
- variable,
- ABSTRACT_VARIABLE__NAME,
- CLF_NAME_DOES_NOT_START_LOWERCASE);
+ final IssueItem issueItem = CLF_NAME_DOES_NOT_START_LOWERCASE.toIssueItem(
+ Strings.toFirstUpper(keywordProvider.keyword(variable)));
+ addIssue(variable, ABSTRACT_VARIABLE__NAME, issueItem);
return false;
}
return true;
@@ -336,11 +316,9 @@ private boolean holdsNoTypeNameOrNameEqualsType(NamedElement namedElement) {
if (typeRef != null && typeRef.getDeclaredType() != null) {
String typeName = typeRef.getDeclaredType().getName();
if (!Strings.isEmpty(typeName) && !name.equals(typeName)) {
- final String message = getMessageForCLF_NAME_DIFFERS_TYPE(
- validatorMessageHelper.description(namedElement), name, typeName);
- addIssue(Strings.toFirstUpper(message), namedElement,
- N4JSMetaModelUtils.getElementNameFeature(namedElement),
- CLF_NAME_DIFFERS_TYPE);
+ final IssueItem issueItem = CLF_NAME_DIFFERS_TYPE.toIssueItem(
+ Strings.toFirstUpper(validatorMessageHelper.description(namedElement)), name, typeName);
+ addIssue(namedElement, N4JSMetaModelUtils.getElementNameFeature(namedElement), issueItem);
return false;
}
}
@@ -352,10 +330,10 @@ private boolean holdsNoTypeNameOrNameEqualsType(NamedElement namedElement) {
private boolean holdsNameMayNotBeConfusedWith(NamedElement element, String suffix, Collection category) {
// N4JSFV#checkFunctionName is responsible for the validation of function definitions
if (category.contains(element.getName()) && !(element instanceof FunctionDefinition)) {
- final String message = getMessageForCLF_NAME_RESERVED(validatorMessageHelper.description(element),
+ final IssueItem issueItem = CLF_NAME_RESERVED.toIssueItem(
+ Strings.toFirstUpper(validatorMessageHelper.description(element)),
suffix);
- addIssue(Strings.toFirstUpper(message), element, N4JSMetaModelUtils.getElementNameFeature(element),
- CLF_NAME_RESERVED);
+ addIssue(element, N4JSMetaModelUtils.getElementNameFeature(element), issueItem);
return false;
}
return true;
@@ -367,11 +345,9 @@ private boolean holdsDoesNotContainDiscouragedCharacter(final AbstractVariable
final String declarationName = getVariableName(variable);
if (!declarationName.startsWith(discouragedCharacter) && declarationName.contains(discouragedCharacter)) {
final String discouragedCharacterLabel = DISCOURAGED_CHARACTERS.get(discouragedCharacter);
- final String message = getMessageForCLF_NAME_CONTAINS_DISCOURAGED_CHARACTER(discouragedCharacterLabel);
- addIssue(message,
- variable,
- ABSTRACT_VARIABLE__NAME,
- CLF_NAME_CONTAINS_DISCOURAGED_CHARACTER);
+ final IssueItem issueItem = CLF_NAME_CONTAINS_DISCOURAGED_CHARACTER
+ .toIssueItem(discouragedCharacterLabel);
+ addIssue(variable, ABSTRACT_VARIABLE__NAME, issueItem);
return false;
}
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSStatementValidator.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSStatementValidator.java
index d40d8d5cfa..3eaef27467 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSStatementValidator.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSStatementValidator.java
@@ -11,10 +11,9 @@
package org.eclipse.n4js.validation.validators;
import static org.eclipse.n4js.utils.N4JSLanguageUtils.isContainedInStaticPolyfillModule;
+import static org.eclipse.n4js.validation.IssueCodes.EXP_MISPLACED_AWAIT;
import static org.eclipse.n4js.validation.IssueCodes.POLY_STATIC_POLYFILL_MODULE_ONLY_FILLING_CLASSES;
import static org.eclipse.n4js.validation.IssueCodes.TYS_FOR_IN_VAR_STRING;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForPOLY_STATIC_POLYFILL_MODULE_ONLY_FILLING_CLASSES;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForTYS_FOR_IN_VAR_STRING;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.n4js.n4JS.AssignmentExpression;
@@ -38,7 +37,6 @@
import org.eclipse.n4js.typesystem.utils.RuleEnvironmentExtensions;
import org.eclipse.n4js.utils.N4JSLanguageUtils;
import org.eclipse.n4js.validation.AbstractN4JSDeclarativeValidator;
-import org.eclipse.n4js.validation.IssueCodes;
import org.eclipse.n4js.validation.JavaScriptVariantHelper;
import org.eclipse.xtext.validation.Check;
import org.eclipse.xtext.validation.EValidatorRegistrar;
@@ -108,8 +106,7 @@ public void checkVariableStatement(Statement statement) {
return;
// it is a static polyfill module
- addIssue(getMessageForPOLY_STATIC_POLYFILL_MODULE_ONLY_FILLING_CLASSES(), statement,
- POLY_STATIC_POLYFILL_MODULE_ONLY_FILLING_CLASSES);
+ addIssue(statement, POLY_STATIC_POLYFILL_MODULE_ONLY_FILLING_CLASSES.toIssueItem());
}
}
@@ -152,8 +149,7 @@ public void checkForInLoop(ForStatement forStatement) {
Result res = typeSystem.subtype(G, RuleEnvironmentExtensions.stringTypeRef(G), loopVarType);
if (!res.isSuccess()) {
- addIssue(getMessageForTYS_FOR_IN_VAR_STRING(loopVarType.getTypeRefAsString()), location,
- TYS_FOR_IN_VAR_STRING);
+ addIssue(location, TYS_FOR_IN_VAR_STRING.toIssueItem(loopVarType.getTypeRefAsString()));
}
}
@@ -171,8 +167,8 @@ public void checkForAwaitOfLoop(ForStatement forStatement) {
}
if (!N4JSLanguageUtils.isValidLocationForAwait(forStatement)) {
- addIssue(IssueCodes.getMessageForEXP_MISPLACED_AWAIT("for-await-of", "async"), forStatement,
- N4JSPackage.Literals.FOR_STATEMENT__AWAIT, IssueCodes.EXP_MISPLACED_AWAIT);
+ addIssue(forStatement, N4JSPackage.Literals.FOR_STATEMENT__AWAIT,
+ EXP_MISPLACED_AWAIT.toIssueItem("for-await-of", "async"));
}
}
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSSuperValidator.xtend b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSSuperValidator.xtend
index 3cb92fd4a5..a5a1965d67 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSSuperValidator.xtend
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSSuperValidator.xtend
@@ -27,14 +27,15 @@ import org.eclipse.n4js.n4JS.ReturnStatement
import org.eclipse.n4js.n4JS.SuperLiteral
import org.eclipse.n4js.n4JS.ThisLiteral
import org.eclipse.n4js.ts.types.TField
+import org.eclipse.n4js.ts.types.TMethod
import org.eclipse.n4js.utils.EcoreUtilN4
import org.eclipse.n4js.validation.AbstractN4JSDeclarativeValidator
+import org.eclipse.n4js.validation.IssueItem
import org.eclipse.xtext.EcoreUtil2
import org.eclipse.xtext.validation.Check
import org.eclipse.xtext.validation.EValidatorRegistrar
import static org.eclipse.n4js.validation.IssueCodes.*
-import org.eclipse.n4js.ts.types.TMethod
/**
* Validate use of super keyword.
@@ -67,14 +68,12 @@ class N4JSSuperValidator extends AbstractN4JSDeclarativeValidator {
// new super
// error: not supported yet
- val message = messageForKEY_SUP_NEW_NOT_SUPPORTED
- addIssue(message, superLiteral.eContainer, superLiteral.eContainmentFeature, KEY_SUP_NEW_NOT_SUPPORTED);
+ addIssue(superLiteral.eContainer, superLiteral.eContainmentFeature, KEY_SUP_NEW_NOT_SUPPORTED.toIssueItem());
} else {
// Constraint 99:
// error: invalid usage
- val message = messageForKEY_SUP_INVALID_USAGE
- addIssue(message, superLiteral.eContainer, superLiteral.eContainmentFeature, KEY_SUP_INVALID_USAGE);
+ addIssue(superLiteral.eContainer, superLiteral.eContainmentFeature, KEY_SUP_INVALID_USAGE.toIssueItem());
}
}
@@ -100,7 +99,7 @@ class N4JSSuperValidator extends AbstractN4JSDeclarativeValidator {
if (cexpr.eContainer instanceof ExpressionStatement) {
return true;
}
- addIssue(messageForKEY_SUP_CTOR_EXPRSTMT, cexpr, superLiteral.eContainmentFeature, KEY_SUP_CTOR_EXPRSTMT);
+ addIssue(cexpr, superLiteral.eContainmentFeature, KEY_SUP_CTOR_EXPRSTMT.toIssueItem());
return false;
}
@@ -116,14 +115,14 @@ class N4JSSuperValidator extends AbstractN4JSDeclarativeValidator {
}
if (!(block instanceof Block && block.eContainer === containingMemberDecl)) {
- val msg = getMessageForKEY_SUP_CTOR_NESTED(
+ val IssueItem issueItem = KEY_SUP_CTOR_NESTED.toIssueItem(
descriptionWithLine(
if (block instanceof Block) {
block.eContainer
} else {
block
}));
- addIssue(msg, superLiteral.eContainer, superLiteral.eContainmentFeature, KEY_SUP_CTOR_NESTED);
+ addIssue(superLiteral.eContainer, superLiteral.eContainmentFeature, issueItem);
return false;
}
@@ -140,25 +139,22 @@ class N4JSSuperValidator extends AbstractN4JSDeclarativeValidator {
if (stmt === exprStmt) return true;
if (stmt instanceof ReturnStatement) {
- val msg = getMessageForKEY_SUP_CTOR_INVALID_EXPR_BEFORE(descriptionWithLine(stmt));
- addIssue(msg, superLiteral.eContainer, superLiteral.eContainmentFeature,
- KEY_SUP_CTOR_INVALID_EXPR_BEFORE);
+ addIssue(superLiteral.eContainer, superLiteral.eContainmentFeature,
+ KEY_SUP_CTOR_INVALID_EXPR_BEFORE.toIssueItem(descriptionWithLine(stmt)));
return false;
}
val thisKeyword = EcoreUtilN4.getAllContentsFiltered(stmt, [! (it instanceof FunctionOrFieldAccessor)]).
findFirst[it instanceof ThisLiteral || it instanceof ReturnStatement];
if (thisKeyword !== null) {
- val msg = getMessageForKEY_SUP_CTOR_INVALID_EXPR_BEFORE(descriptionWithLine(thisKeyword));
- addIssue(msg, superLiteral.eContainer, superLiteral.eContainmentFeature,
- KEY_SUP_CTOR_INVALID_EXPR_BEFORE);
+ addIssue(superLiteral.eContainer, superLiteral.eContainmentFeature,
+ KEY_SUP_CTOR_INVALID_EXPR_BEFORE.toIssueItem(descriptionWithLine(thisKeyword)));
return false;
}
}
// must not happen
- val msg = getMessageForKEY_SUP_CTOR_NESTED(descriptionWithLine(exprStmt.eContainer));
- addIssue(msg, superLiteral.eContainer, superLiteral.eContainmentFeature, KEY_SUP_CTOR_NESTED);
+ addIssue(superLiteral.eContainer, superLiteral.eContainmentFeature, KEY_SUP_CTOR_NESTED.toIssueItem(descriptionWithLine(exprStmt.eContainer)));
return false;
}
@@ -182,9 +178,9 @@ class N4JSSuperValidator extends AbstractN4JSDeclarativeValidator {
(literalContainer as ParameterizedPropertyAccessExpression).property instanceof TMethod) {
val method = (literalContainer as ParameterizedPropertyAccessExpression).property as TMethod;
if (method.abstract) {
- addIssue(messageForCLF_CANNOT_CALL_ABSTRACT_SUPER_METHOD, literalContainer,
+ addIssue(literalContainer,
N4JSPackage.Literals.PARAMETERIZED_PROPERTY_ACCESS_EXPRESSION__PROPERTY,
- CLF_CANNOT_CALL_ABSTRACT_SUPER_METHOD);
+ CLF_CANNOT_CALL_ABSTRACT_SUPER_METHOD.toIssueItem());
return false;
}
}
@@ -197,13 +193,13 @@ class N4JSSuperValidator extends AbstractN4JSDeclarativeValidator {
private def boolean holdsSuperIsReceiverOfCall(SuperLiteral superLiteral) {
if (superLiteral.eContainer instanceof ParameterizedPropertyAccessExpression &&
(superLiteral.eContainer as ParameterizedPropertyAccessExpression).property instanceof TField) {
- addIssue(messageForKEY_SUP_ACCESS_FIELD, superLiteral.eContainer as ParameterizedPropertyAccessExpression,
- N4JSPackage.Literals.PARAMETERIZED_PROPERTY_ACCESS_EXPRESSION__PROPERTY, KEY_SUP_ACCESS_FIELD);
+ addIssue(superLiteral.eContainer as ParameterizedPropertyAccessExpression,
+ N4JSPackage.Literals.PARAMETERIZED_PROPERTY_ACCESS_EXPRESSION__PROPERTY, KEY_SUP_ACCESS_FIELD.toIssueItem());
return false;
}
if (superLiteral.eContainer instanceof IndexedAccessExpression) {
- addIssue(messageForKEY_SUP_CALL_NO_INDEXACCESS, superLiteral.eContainer as IndexedAccessExpression,
- N4JSPackage.Literals.EXPRESSION_WITH_TARGET__TARGET, KEY_SUP_CALL_NO_INDEXACCESS);
+ addIssue(superLiteral.eContainer as IndexedAccessExpression,
+ N4JSPackage.Literals.EXPRESSION_WITH_TARGET__TARGET, KEY_SUP_CALL_NO_INDEXACCESS.toIssueItem());
return false;
}
return true;
@@ -214,7 +210,7 @@ class N4JSSuperValidator extends AbstractN4JSDeclarativeValidator {
*/
private def boolean holdsSuperCallNotNested(SuperLiteral superLiteral, N4MemberDeclaration containingMemberDecl) {
if (EcoreUtil2.getContainerOfType(superLiteral.eContainer, FunctionOrFieldAccessor) !== containingMemberDecl) {
- addIssue(messageForKEY_SUP_NESTED, superLiteral.eContainer, superLiteral.eContainmentFeature, KEY_SUP_NESTED);
+ addIssue(superLiteral.eContainer, superLiteral.eContainmentFeature, KEY_SUP_NESTED.toIssueItem());
return false;
}
return true;
@@ -230,8 +226,7 @@ class N4JSSuperValidator extends AbstractN4JSDeclarativeValidator {
return false;
}
if (containingMemberDecl?.eContainer instanceof N4InterfaceDeclaration) {
- addIssue(messageForKEY_SUP_ACCESS_INVALID_LOC_INTERFACE, superLiteral.eContainer, superLiteral.eContainmentFeature,
- KEY_SUP_ACCESS_INVALID_LOC_INTERFACE);
+ addIssue(superLiteral.eContainer, superLiteral.eContainmentFeature, KEY_SUP_ACCESS_INVALID_LOC_INTERFACE.toIssueItem());
return false;
}
return true;
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSSyntaxValidator.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSSyntaxValidator.java
index c3082a5d57..f7bc7a0286 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSSyntaxValidator.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSSyntaxValidator.java
@@ -14,10 +14,14 @@
import static org.eclipse.n4js.N4JSLanguageConstants.EXTENDS_KEYWORD;
import static org.eclipse.n4js.N4JSLanguageConstants.IMPLEMENTS_KEYWORD;
import static org.eclipse.n4js.validation.IssueCodes.AST_CATCH_VAR_TYPED;
+import static org.eclipse.n4js.validation.IssueCodes.EXP_ONLY_TOP_LEVEL_ELEMENTS;
import static org.eclipse.n4js.validation.IssueCodes.SYN_KW_EXTENDS_IMPLEMENTS_MIXED_UP;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForAST_CATCH_VAR_TYPED;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForSYN_KW_EXTENDS_IMPLEMENTS_MIXED_UP;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForSYN_KW_EXTENDS_IMPLEMENTS_WRONG_ORDER;
+import static org.eclipse.n4js.validation.IssueCodes.SYN_KW_EXTENDS_IMPLEMENTS_WRONG_ORDER;
+import static org.eclipse.n4js.validation.IssueCodes.SYN_MODIFIER_ACCESS_SEVERAL;
+import static org.eclipse.n4js.validation.IssueCodes.SYN_MODIFIER_BAD_ORDER;
+import static org.eclipse.n4js.validation.IssueCodes.SYN_MODIFIER_DUPLICATE;
+import static org.eclipse.n4js.validation.IssueCodes.SYN_MODIFIER_INVALID;
+import static org.eclipse.n4js.validation.IssueCodes.SYN_UNNECESSARY_ELEMENT;
import java.util.HashSet;
import java.util.List;
@@ -42,7 +46,7 @@
import org.eclipse.n4js.ts.types.TInterface;
import org.eclipse.n4js.ts.types.Type;
import org.eclipse.n4js.validation.AbstractN4JSDeclarativeValidator;
-import org.eclipse.n4js.validation.IssueCodes;
+import org.eclipse.n4js.validation.IssueItem;
import org.eclipse.xtext.AbstractElement;
import org.eclipse.xtext.Alternatives;
import org.eclipse.xtext.Keyword;
@@ -94,21 +98,18 @@ private boolean holdsNoInvalidObsoleteOrDuplicateModifiers(ModifiableElement ele
final boolean duplicate = !checked.add(mod);
if (!ModifierUtils.isValid(elem, mod)) {
final ILeafNode node = ModifierUtils.getNodeForModifier(elem, idx);
- addIssue(IssueCodes.getMessageForSYN_MODIFIER_INVALID(mod.getName(), keywordProvider.keyword(elem)),
- elem, node.getOffset(), node.getLength(),
- IssueCodes.SYN_MODIFIER_INVALID);
+ addIssue(elem, node.getOffset(), node.getLength(),
+ SYN_MODIFIER_INVALID.toIssueItem(mod.getName(), keywordProvider.keyword(elem)));
hasIssue = true;
} else if (duplicate) {
final ILeafNode node = ModifierUtils.getNodeForModifier(elem, idx);
- addIssue(IssueCodes.getMessageForSYN_MODIFIER_DUPLICATE(mod.getName()),
- elem, node.getOffset(), node.getLength(),
- IssueCodes.SYN_MODIFIER_DUPLICATE);
+ addIssue(elem, node.getOffset(), node.getLength(),
+ SYN_MODIFIER_DUPLICATE.toIssueItem(mod.getName()));
hasIssue = true;
} else if (ModifierUtils.isObsolete(elem, mod)) {
final ILeafNode node = ModifierUtils.getNodeForModifier(elem, idx);
- addIssue(IssueCodes.getMessageForSYN_UNNECESSARY_ELEMENT("modifier", mod.getName()),
- elem, node.getOffset(), node.getLength(),
- IssueCodes.SYN_UNNECESSARY_ELEMENT);
+ addIssue(elem, node.getOffset(), node.getLength(),
+ SYN_UNNECESSARY_ELEMENT.toIssueItem("modifier", mod.getName()));
hasIssue = true;
}
}
@@ -127,9 +128,8 @@ private boolean holdsNotMoreThanOneAccessModifier(ModifiableElement elem) {
final boolean isAccessModifier = ModifierUtils.isAccessModifier(mod);
if (hasAccessModifier && isAccessModifier) {
final ILeafNode node = ModifierUtils.getNodeForModifier(elem, idx);
- addIssue(IssueCodes.getMessageForSYN_MODIFIER_ACCESS_SEVERAL(),
- elem, node.getOffset(), node.getLength(),
- IssueCodes.SYN_MODIFIER_ACCESS_SEVERAL);
+ addIssue(elem, node.getOffset(), node.getLength(),
+ SYN_MODIFIER_ACCESS_SEVERAL.toIssueItem());
hasIssue = true;
}
hasAccessModifier |= isAccessModifier;
@@ -157,10 +157,9 @@ private boolean holdsCorrectOrder(ModifiableElement elem) {
final ILeafNode nodeFirst = ModifierUtils.getNodeForModifier(elem, 0);
final ILeafNode nodeLast = ModifierUtils.getNodeForModifier(elem,
elem.getDeclaredModifiers().size() - 1);
- addIssue(IssueCodes.getMessageForSYN_MODIFIER_BAD_ORDER(modifiersStr),
- elem, nodeFirst.getOffset(),
+ addIssue(elem, nodeFirst.getOffset(),
nodeLast.getOffset() - nodeFirst.getOffset() + nodeLast.getLength(),
- IssueCodes.SYN_MODIFIER_BAD_ORDER);
+ SYN_MODIFIER_BAD_ORDER.toIssueItem(modifiersStr));
return false;
}
return true;
@@ -175,9 +174,8 @@ public void checkExportedKeyword(ExportDeclaration element) {
ICompositeNode node = NodeModelUtils.findActualNodeFor(element);
ILeafNode keywordNode = findLeafWithKeyword(element, "{", node, EXPORT_KEYWORD, false);
if (keywordNode != null) {
- addIssue(IssueCodes.getMessageForEXP_ONLY_TOP_LEVEL_ELEMENTS(),
- element, keywordNode.getTotalOffset(), keywordNode.getLength(),
- IssueCodes.EXP_ONLY_TOP_LEVEL_ELEMENTS);
+ addIssue(element, keywordNode.getTotalOffset(), keywordNode.getLength(),
+ EXP_ONLY_TOP_LEVEL_ELEMENTS.toIssueItem());
}
}
}
@@ -207,12 +205,12 @@ public void checkClassDefinition(N4ClassDefinition n4ClassDefinition) {
List extends IdentifiableElement> interfaces = StreamSupport.stream(
tclass.getImplementedInterfaceRefs().spliterator(), false)
.map(ref -> (TInterface) (ref.getDeclaredType())).collect(Collectors.toList());
- String message = getMessageForSYN_KW_EXTENDS_IMPLEMENTS_MIXED_UP(
+ IssueItem issueItem = SYN_KW_EXTENDS_IMPLEMENTS_MIXED_UP.toIssueItem(
validatorMessageHelper.description(tclass), "extend",
"interface" + (interfaces.size() > 1 ? "s " : " ") + validatorMessageHelper.names(interfaces),
IMPLEMENTS_KEYWORD);
- addIssue(message, n4ClassDefinition, keywordNode.getTotalOffset(),
- keywordNode.getLength(), SYN_KW_EXTENDS_IMPLEMENTS_MIXED_UP);
+ addIssue(n4ClassDefinition, keywordNode.getTotalOffset(),
+ keywordNode.getLength(), issueItem);
}
}
@@ -255,12 +253,12 @@ public void checkInterfaceDeclaration(N4InterfaceDeclaration n4InterfaceDecl) {
return Stream.empty();
})
.collect(Collectors.toList());
- String message = getMessageForSYN_KW_EXTENDS_IMPLEMENTS_MIXED_UP(
+ IssueItem issueItem = SYN_KW_EXTENDS_IMPLEMENTS_MIXED_UP.toIssueItem(
validatorMessageHelper.description(tinterface), "implement",
"interface" + (interfaces.size() > 1 ? "s " : " ") + validatorMessageHelper.names(interfaces),
EXTENDS_KEYWORD);
- addIssue(message, n4InterfaceDecl, keywordNode.getTotalOffset(),
- keywordNode.getLength(), SYN_KW_EXTENDS_IMPLEMENTS_MIXED_UP);
+ addIssue(n4InterfaceDecl, keywordNode.getTotalOffset(),
+ keywordNode.getLength(), issueItem);
}
}
@@ -283,9 +281,8 @@ private boolean holdsCorrectOrderOfExtendsImplements(N4ClassDefinition semanticE
int extendsOffset = extendsNode.getOffset();
int implementsOffset = implementsNode.getOffset();
if (extendsOffset > implementsOffset) {
- String message = getMessageForSYN_KW_EXTENDS_IMPLEMENTS_WRONG_ORDER();
- addIssue(message, semanticElement, extendsOffset, EXTENDS_KEYWORD.length(),
- IssueCodes.SYN_KW_EXTENDS_IMPLEMENTS_WRONG_ORDER);
+ addIssue(semanticElement, extendsOffset, EXTENDS_KEYWORD.length(),
+ SYN_KW_EXTENDS_IMPLEMENTS_WRONG_ORDER.toIssueItem());
return false;
}
return true;
@@ -366,9 +363,8 @@ private ILeafNode doFindLeafWithKeyword(EObject semanticElement, String stopAtKe
@Check
public void checkCatchVariable(CatchVariable catchVariable) {
if (catchVariable.getDeclaredTypeRefInAST() != null) {
- addIssue(getMessageForAST_CATCH_VAR_TYPED(), catchVariable,
- N4JSPackage.Literals.TYPED_ELEMENT__DECLARED_TYPE_REF_NODE,
- AST_CATCH_VAR_TYPED);
+ addIssue(catchVariable, N4JSPackage.Literals.TYPED_ELEMENT__DECLARED_TYPE_REF_NODE,
+ AST_CATCH_VAR_TYPED.toIssueItem());
}
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSTypeAliasValidator.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSTypeAliasValidator.java
index 9a38804c37..dca081dc2a 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSTypeAliasValidator.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSTypeAliasValidator.java
@@ -10,6 +10,12 @@
*/
package org.eclipse.n4js.validation.validators;
+import static org.eclipse.n4js.validation.IssueCodes.ALI_CYCLIC_TYPE_ALIAS;
+import static org.eclipse.n4js.validation.IssueCodes.ALI_INVALID_MODIFIER;
+import static org.eclipse.n4js.validation.IssueCodes.ALI_INVALID_TYPE_ALIAS_IN_TYPE_TYPE_REF;
+import static org.eclipse.n4js.validation.IssueCodes.TYS_PRIMITIVE_TYPE_DYNAMIC;
+import static org.eclipse.n4js.validation.IssueCodes.TYS_STRUCTURAL_PRIMITIVE;
+
import java.util.Collections;
import java.util.Stack;
import java.util.stream.Collectors;
@@ -30,7 +36,6 @@
import org.eclipse.n4js.utils.N4JSLanguageUtils;
import org.eclipse.n4js.utils.RecursionGuard;
import org.eclipse.n4js.validation.AbstractN4JSDeclarativeValidator;
-import org.eclipse.n4js.validation.IssueCodes;
import org.eclipse.xtext.validation.Check;
import org.eclipse.xtext.validation.EValidatorRegistrar;
import org.eclipse.xtext.xbase.lib.IteratorExtensions;
@@ -76,9 +81,8 @@ public void checkCyclicAliasDeclaration(N4TypeAliasDeclaration n4TypeAliasDecl)
return; // no cycle
}
String cycleStr = cycle.stream().map(TypeAlias::getName).collect(Collectors.joining(" -> "));
- addIssue(IssueCodes.getMessageForALI_CYCLIC_TYPE_ALIAS(cycleStr),
- n4TypeAliasDecl, N4JSPackage.Literals.N4_TYPE_DECLARATION__NAME,
- IssueCodes.ALI_CYCLIC_TYPE_ALIAS);
+ addIssue(n4TypeAliasDecl, N4JSPackage.Literals.N4_TYPE_DECLARATION__NAME,
+ ALI_CYCLIC_TYPE_ALIAS.toIssueItem(cycleStr));
}
/**
@@ -143,25 +147,21 @@ public void checkTypeModifiersOfAlias(ParameterizedTypeRef typeRefInAST) {
final TypeRef typeRefResolved = tsh.resolveTypeAliasFlat(G, typeRefInAST);
if (typeRefInAST.isDynamic()) {
if (!(typeRefResolved instanceof ParameterizedTypeRef)) {
- addIssue(IssueCodes.getMessageForALI_INVALID_MODIFIER("dynamically"),
- typeRefInAST, IssueCodes.ALI_INVALID_MODIFIER);
+ addIssue(typeRefInAST, ALI_INVALID_MODIFIER.toIssueItem("dynamically"));
} else {
final Type declType = typeRefResolved.getDeclaredType();
if (!N4JSLanguageUtils.mayBeReferencedDynamically(declType)) {
- addIssue(IssueCodes.getMessageForTYS_PRIMITIVE_TYPE_DYNAMIC(declType.getName()),
- typeRefInAST, IssueCodes.TYS_PRIMITIVE_TYPE_DYNAMIC);
+ addIssue(typeRefInAST, TYS_PRIMITIVE_TYPE_DYNAMIC.toIssueItem(declType.getName()));
}
}
}
if (typeRefInAST.isUseSiteStructuralTyping()) {
if (!(typeRefResolved instanceof ParameterizedTypeRef)) {
- addIssue(IssueCodes.getMessageForALI_INVALID_MODIFIER("structurally"),
- typeRefInAST, IssueCodes.ALI_INVALID_MODIFIER);
+ addIssue(typeRefInAST, ALI_INVALID_MODIFIER.toIssueItem("structurally"));
} else {
final Type declType = typeRefResolved.getDeclaredType();
if (!N4JSLanguageUtils.mayBeReferencedStructurally(declType)) {
- addIssue(IssueCodes.getMessageForTYS_STRUCTURAL_PRIMITIVE(),
- typeRefInAST, IssueCodes.TYS_STRUCTURAL_PRIMITIVE);
+ addIssue(typeRefInAST, TYS_STRUCTURAL_PRIMITIVE.toIssueItem());
}
}
}
@@ -174,8 +174,7 @@ public void checkTypeModifiersOfAlias(ParameterizedTypeRef typeRefInAST) {
// (note: no need to cover cases ThisTypeRefNominal and WildcardOldNotation from rule TypeArgInTypeTypeRef
// in TypeExpressions.xtext, because this-types and wildcards cannot appear as actual type of an alias)
if (!isValidTypeArgInTypeTypeRef) {
- addIssue(IssueCodes.getMessageForALI_INVALID_TYPE_ALIAS_IN_TYPE_TYPE_REF("{}"),
- typeRefInAST, IssueCodes.ALI_INVALID_TYPE_ALIAS_IN_TYPE_TYPE_REF);
+ addIssue(typeRefInAST, ALI_INVALID_TYPE_ALIAS_IN_TYPE_TYPE_REF.toIssueItem("{}"));
}
}
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSTypeValidator.xtend b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSTypeValidator.xtend
index c02b89722d..2e7936d725 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSTypeValidator.xtend
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSTypeValidator.xtend
@@ -102,6 +102,7 @@ import static org.eclipse.n4js.validation.IssueCodes.*
import static extension org.eclipse.n4js.typesystem.utils.RuleEnvironmentExtensions.*
import org.eclipse.emf.ecore.EStructuralFeature
+import org.eclipse.n4js.validation.IssueItem
/**
* Class for validating the N4JS types.
@@ -159,8 +160,7 @@ class N4JSTypeValidator extends AbstractN4JSDeclarativeValidator {
return;
}
val ubInAST = typeVar.declaredUpperBoundNode.typeRefInAST; // never 'null' because 'typeVar.declaredUpperBound' returned non-null value
- val message = getMessageForCLF_UPPER_BOUND_FINAL(declType.name, typeVar.name);
- addIssue(message, ubInAST, PARAMETERIZED_TYPE_REF__DECLARED_TYPE, CLF_UPPER_BOUND_FINAL);
+ addIssue(ubInAST, PARAMETERIZED_TYPE_REF__DECLARED_TYPE, CLF_UPPER_BOUND_FINAL.toIssueItem(declType.name, typeVar.name));
}
};
];
@@ -171,7 +171,7 @@ class N4JSTypeValidator extends AbstractN4JSDeclarativeValidator {
if (script.module === null) {
val rootNode = NodeModelUtils.getNode(script)
if (rootNode !== null) {
- addIssue(IssueCodes.getMessageForTYS_MISSING, script, rootNode.offset, rootNode.length, TYS_MISSING);
+ addIssue(script, rootNode.offset, rootNode.length, TYS_MISSING.toIssueItem());
}
}
}
@@ -202,7 +202,7 @@ class N4JSTypeValidator extends AbstractN4JSDeclarativeValidator {
*/
def private void internalCheckStructuralPrimitiveTypeRef(ParameterizedTypeRef typeRefInAST) {
if (typeRefInAST.typingStrategy != TypingStrategy.NOMINAL && !N4JSLanguageUtils.mayBeReferencedStructurally(typeRefInAST.declaredType)) {
- addIssue(IssueCodes.messageForTYS_STRUCTURAL_PRIMITIVE, typeRefInAST, TYS_STRUCTURAL_PRIMITIVE);
+ addIssue(typeRefInAST, TYS_STRUCTURAL_PRIMITIVE.toIssueItem());
}
}
@@ -210,14 +210,11 @@ class N4JSTypeValidator extends AbstractN4JSDeclarativeValidator {
// IDE-785 uses ParamterizedTypeRefs in ClassifierTypeRefs. Currently Type Arguments are not supported in ClassifierTypeRefs, so
// we actively forbid them here. Will be loosened for IDE-1310
if (!paramTypeRefInAST.declaredTypeArgs.isEmpty) {
- addIssue(IssueCodes.getMessageForAST_NO_TYPE_ARGS_IN_CLASSIFIERTYPEREF, paramTypeRefInAST,
- AST_NO_TYPE_ARGS_IN_CLASSIFIERTYPEREF)
+ addIssue(paramTypeRefInAST, AST_NO_TYPE_ARGS_IN_CLASSIFIERTYPEREF.toIssueItem());
} else if (paramTypeRefInAST instanceof FunctionTypeRef) {
- addIssue(IssueCodes.getMessageForAST_NO_FUNCTIONTYPEREFS_IN_CLASSIFIERTYPEREF, paramTypeRefInAST,
- AST_NO_FUNCTIONTYPEREFS_IN_CLASSIFIERTYPEREF)
+ addIssue(paramTypeRefInAST, AST_NO_FUNCTIONTYPEREFS_IN_CLASSIFIERTYPEREF.toIssueItem());
} else if (paramTypeRefInAST.declaredType instanceof TFunction) {
- addIssue(IssueCodes.getMessageForAST_NO_FUNCTIONTYPEREFS_IN_CLASSIFIERTYPEREF, paramTypeRefInAST,
- AST_NO_FUNCTIONTYPEREFS_IN_CLASSIFIERTYPEREF)
+ addIssue(paramTypeRefInAST, AST_NO_FUNCTIONTYPEREFS_IN_CLASSIFIERTYPEREF.toIssueItem());
}
}
@@ -232,7 +229,7 @@ class N4JSTypeValidator extends AbstractN4JSDeclarativeValidator {
if (!(thisTypeRefInAST.isUsedStructurallyAsFormalParametersInTheConstructor
|| thisTypeRefInAST.isUsedAtCovariantPositionInClassifierDeclaration
|| thisTypeRefInAST.isUsedInVariableWithSyntaxError)) {
- addIssue(IssueCodes.getMessageForAST_THIS_WRONG_PLACE, thisTypeRefInAST, IssueCodes.AST_THIS_WRONG_PLACE);
+ addIssue(thisTypeRefInAST, AST_THIS_WRONG_PLACE.toIssueItem());
}
}
@@ -292,7 +289,7 @@ class N4JSTypeValidator extends AbstractN4JSDeclarativeValidator {
// we have a type reference to 'Symbol'
val isAllowed = isExtendsClauseInRuntimeLibrary(typeRefInAST);
if (!isAllowed) {
- addIssue(IssueCodes.getMessageForBIT_SYMBOL_INVALID_USE, typeRefInAST, BIT_SYMBOL_INVALID_USE);
+ addIssue(typeRefInAST, BIT_SYMBOL_INVALID_USE.toIssueItem());
}
}
}
@@ -314,8 +311,7 @@ class N4JSTypeValidator extends AbstractN4JSDeclarativeValidator {
if (refInAST.dynamic) {
val Type t = refInAST.declaredType;
if (!N4JSLanguageUtils.mayBeReferencedDynamically(t)) {
- addIssue(IssueCodes.getMessageForTYS_PRIMITIVE_TYPE_DYNAMIC(t.name), refInAST,
- TYS_PRIMITIVE_TYPE_DYNAMIC);
+ addIssue(refInAST, TYS_PRIMITIVE_TYPE_DYNAMIC.toIssueItem(t.name));
}
}
}
@@ -338,8 +334,7 @@ class N4JSTypeValidator extends AbstractN4JSDeclarativeValidator {
val hiddenType = hiddenTypeDscr?.getEObjectOrProxy;
if (hiddenType instanceof Type &&
!(IEObjectDescriptionWithError.isErrorDescription(hiddenTypeDscr))) {
- val message = getMessageForVIS_TYPE_PARAMETER_HIDES_TYPE(name, hiddenType.keyword);
- addIssue(message, it, VIS_TYPE_PARAMETER_HIDES_TYPE);
+ addIssue(it, VIS_TYPE_PARAMETER_HIDES_TYPE.toIssueItem(name, hiddenType.keyword));
}
}
]
@@ -376,8 +371,7 @@ class N4JSTypeValidator extends AbstractN4JSDeclarativeValidator {
if (m === null) {
// no getter at all
- val message = messageForTYS_COMPOUND_MISSING_GETTER
- addIssue(message, assExpr.lhs, TYS_COMPOUND_MISSING_GETTER);
+ addIssue(assExpr.lhs, TYS_COMPOUND_MISSING_GETTER.toIssueItem());
} else if (m instanceof TGetter) {
val TGetter getter = m;
var G = assExpr.newRuleEnvironment;
@@ -418,10 +412,9 @@ class N4JSTypeValidator extends AbstractN4JSDeclarativeValidator {
val ifcName = (tv.eContainer as TInterface).name;
val tvName = "invariant " + tv.name;
val typeRefsStr = badSubst.map[typeRefAsString].join(", ");
- val message = getMessageForCLF_IMPLEMENT_EXTEND_SAME_INTERFACE_INCONSISTENTLY(mode,
+ val IssueItem issueItem = CLF_IMPLEMENT_EXTEND_SAME_INTERFACE_INCONSISTENTLY.toIssueItem(mode,
ifcName, tvName, typeRefsStr);
- addIssue(message, classifierDecl, N4JSPackage.eINSTANCE.n4TypeDeclaration_Name,
- CLF_IMPLEMENT_EXTEND_SAME_INTERFACE_INCONSISTENTLY);
+ addIssue(classifierDecl, N4JSPackage.eINSTANCE.n4TypeDeclaration_Name, issueItem);
}
}
}
@@ -466,10 +459,7 @@ class N4JSTypeValidator extends AbstractN4JSDeclarativeValidator {
return; // all good
}
if (singleExprArrowFunction.declaredReturnTypeRefInAST === null) { // show specialized error message only if return type of arrow function was inferred (i.e. not declared explicitly)
- val message = IssueCodes.
- getMessageForFUN_SINGLE_EXP_LAMBDA_IMPLICIT_RETURN_ALLOWED_UNLESS_VOID();
- addIssue(message, expression,
- IssueCodes.FUN_SINGLE_EXP_LAMBDA_IMPLICIT_RETURN_ALLOWED_UNLESS_VOID);
+ addIssue(expression, IssueCodes.FUN_SINGLE_EXP_LAMBDA_IMPLICIT_RETURN_ALLOWED_UNLESS_VOID.toIssueItem());
return;
}
}
@@ -484,9 +474,8 @@ class N4JSTypeValidator extends AbstractN4JSDeclarativeValidator {
if (result.failure) {
// use custom error message, because otherwise it will be completely confusing
- val message = getMessageForTYS_NO_SUPERTYPE_WRITE_ACCESS(expectedTypeRef.typeRefAsString,
- inferredType.typeRefAsString);
- addIssue(message, expression, TYS_NO_SUPERTYPE_WRITE_ACCESS)
+ val IssueItem issueItem = TYS_NO_SUPERTYPE_WRITE_ACCESS.toIssueItem(expectedTypeRef.typeRefAsString, inferredType.typeRefAsString);
+ addIssue(expression, issueItem);
}
} else {
@@ -607,11 +596,11 @@ class N4JSTypeValidator extends AbstractN4JSDeclarativeValidator {
}
}
if (isSpecArgument) {
- val message = getMessageForCLF_SPEC_SUPERFLUOUS_PROPERTIES(property.name, typeRef.typeRefAsString);
- addIssue(message, astElement, feature, CLF_SPEC_SUPERFLUOUS_PROPERTIES);
+ val IssueItem issueItem = CLF_SPEC_SUPERFLUOUS_PROPERTIES.toIssueItem(property.name, typeRef.typeRefAsString);
+ addIssue(astElement, feature, issueItem);
} else if (!expectedMembersPlusNotAccessibles.contains(property.name)) {
- val message = getMessageForCLF_SUPERFLUOUS_PROPERTIES(property.name, typeRef.typeRefAsString, lhsName);
- addIssue(message, astElement, feature, CLF_SUPERFLUOUS_PROPERTIES);
+ val IssueItem issueItem = CLF_SUPERFLUOUS_PROPERTIES.toIssueItem(property.name, typeRef.typeRefAsString, lhsName);
+ addIssue(astElement, feature, issueItem);
}
}
};
@@ -655,7 +644,7 @@ class N4JSTypeValidator extends AbstractN4JSDeclarativeValidator {
val isUndefinedLiteral = if (expression instanceof IdentifierRef)
expression.id === undefinedField;
if (!isUndefinedLiteral) {
- addIssue(getMessageForEXP_USE_OF_UNDEF_EXPR, expression, EXP_USE_OF_UNDEF_EXPR);
+ addIssue(expression, EXP_USE_OF_UNDEF_EXPR.toIssueItem());
}
}
}
@@ -721,7 +710,7 @@ class N4JSTypeValidator extends AbstractN4JSDeclarativeValidator {
*/
@Check
def void checkUnionTypeContainsNoAny(UnionTypeExpression ute) {
- checkComposedTypeRefContainsNoAny(ute, messageForUNI_ANY_USED, UNI_ANY_USED, true);
+ checkComposedTypeRefContainsNoAny(ute, UNI_ANY_USED.toIssueItem(), true);
}
/**
@@ -730,11 +719,10 @@ class N4JSTypeValidator extends AbstractN4JSDeclarativeValidator {
*/
@Check
def void checkIntersectionTypeContainsNoAny(IntersectionTypeExpression ite) {
- checkComposedTypeRefContainsNoAny(ite, messageForINTER_ANY_USED, INTER_ANY_USED, false);
+ checkComposedTypeRefContainsNoAny(ite, INTER_ANY_USED.toIssueItem(), false);
}
- def private void checkComposedTypeRefContainsNoAny(ComposedTypeRef ctr, String msg, String issueCode,
- boolean soleVoidAllowesAny) {
+ def private void checkComposedTypeRefContainsNoAny(ComposedTypeRef ctr, IssueItem issueItem, boolean soleVoidAllowesAny) {
val G = ctr.newRuleEnvironment;
val anyType = G.anyType;
val voidType = G.voidType;
@@ -748,7 +736,7 @@ class N4JSTypeValidator extends AbstractN4JSDeclarativeValidator {
if (!dontShowWarning) {
for (TypeRef anyTR : anyTypeRefs) {
- addIssue(msg, anyTR, issueCode);
+ addIssue(anyTR, issueItem);
}
}
}
@@ -768,8 +756,7 @@ class N4JSTypeValidator extends AbstractN4JSDeclarativeValidator {
tRefs.removeAll(intersectionTR);
for (TypeRef tClassR : tRefs) {
- val message = messageForUNI_REDUNDANT_SUBTYPE;
- addIssue(message, tClassR, UNI_REDUNDANT_SUBTYPE);
+ addIssue(tClassR, UNI_REDUNDANT_SUBTYPE.toIssueItem());
}
}
}
@@ -807,16 +794,14 @@ class N4JSTypeValidator extends AbstractN4JSDeclarativeValidator {
if (byTypes.keySet.size>1) {
if (covariantTypeArgValidation) {
- val message = messageForINTER_TYEPARGS_ONLY_ONE_CLASS_ALLOWED;
for (TypeRef tClassR : intersectionTR) {
if (! (tClassR.eContainer instanceof TypeVariable)) { // nested, type ref coming from def site
- addIssue(message, tClassR, INTER_TYEPARGS_ONLY_ONE_CLASS_ALLOWED);
+ addIssue(tClassR, INTER_TYEPARGS_ONLY_ONE_CLASS_ALLOWED.toIssueItem());
}
}
} else {
- val message = messageForINTER_ONLY_ONE_CLASS_ALLOWED;
for (TypeRef tClassR : intersectionTR) {
- addIssue(message, tClassR, INTER_ONLY_ONE_CLASS_ALLOWED);
+ addIssue(tClassR, INTER_ONLY_ONE_CLASS_ALLOWED.toIssueItem());
}
}
} else {
@@ -855,10 +840,9 @@ class N4JSTypeValidator extends AbstractN4JSDeclarativeValidator {
// all common super types, at least Object, as type arg would work! no warning.
} else {
// instantiation not possible except with undefined
- val message = messageForINTER_WITH_ONE_GENERIC;
for (TypeRef tClassR : intersectionTR) {
if (! (tClassR.eContainer instanceof TypeVariable)) { // nested, type ref coming from def site
- addIssue(message, tClassR, INTER_WITH_ONE_GENERIC);
+ addIssue(tClassR, INTER_WITH_ONE_GENERIC.toIssueItem());
}
}
}
@@ -894,8 +878,7 @@ class N4JSTypeValidator extends AbstractN4JSDeclarativeValidator {
tClassRefs.removeAll(intersectionTR);
for (TypeRef tClassR : tClassRefs) {
- val message = messageForINTER_REDUNDANT_SUPERTYPE;
- addIssue(message, tClassR, INTER_REDUNDANT_SUPERTYPE);
+ addIssue(tClassR, INTER_REDUNDANT_SUPERTYPE.toIssueItem());
}
}
@@ -915,8 +898,7 @@ class N4JSTypeValidator extends AbstractN4JSDeclarativeValidator {
var haveOptional = false;
for (n4TypeParam : genDecl.typeVars) {
if (haveOptional && !n4TypeParam.optional) {
- val message = messageForTYP_TYPE_PARAM_MANDATORY_AFTER_OPTIONAL;
- addIssue(message, n4TypeParam, N4JSPackage.Literals.N4_TYPE_VARIABLE__NAME, TYP_TYPE_PARAM_MANDATORY_AFTER_OPTIONAL);
+ addIssue(n4TypeParam, N4JSPackage.Literals.N4_TYPE_VARIABLE__NAME, TYP_TYPE_PARAM_MANDATORY_AFTER_OPTIONAL.toIssueItem());
return false;
}
haveOptional = haveOptional || n4TypeParam.optional;
@@ -955,8 +937,7 @@ class N4JSTypeValidator extends AbstractN4JSDeclarativeValidator {
// create error markers
if (!forwardReferences.empty) {
for (badRef : forwardReferences) {
- val message = messageForTYP_TYPE_PARAM_DEFAULT_REFERENCES_LATER_TYPE_PARAM;
- addIssue(message, badRef, TypeRefsPackage.Literals.PARAMETERIZED_TYPE_REF__DECLARED_TYPE, TYP_TYPE_PARAM_DEFAULT_REFERENCES_LATER_TYPE_PARAM);
+ addIssue(badRef, TypeRefsPackage.Literals.PARAMETERIZED_TYPE_REF__DECLARED_TYPE, TYP_TYPE_PARAM_DEFAULT_REFERENCES_LATER_TYPE_PARAM.toIssueItem());
}
return false;
}
@@ -974,8 +955,8 @@ class N4JSTypeValidator extends AbstractN4JSDeclarativeValidator {
if (defaultArgInAST !== null && defaultArg !== null && ub !== null) {
val result = ts.subtype(G, defaultArg, ub);
if (result.failure) {
- val message = getMessageForTYP_TYPE_PARAM_DEFAULT_NOT_SUBTYPE_OF_BOUND(n4TypeParam.name, result.compiledFailureMessage);
- addIssue(message, n4TypeParam, N4JSPackage.Literals.N4_TYPE_VARIABLE__DECLARED_DEFAULT_ARGUMENT_NODE, TYP_TYPE_PARAM_DEFAULT_NOT_SUBTYPE_OF_BOUND);
+ val IssueItem issueItem = TYP_TYPE_PARAM_DEFAULT_NOT_SUBTYPE_OF_BOUND.toIssueItem(n4TypeParam.name, result.compiledFailureMessage);
+ addIssue(n4TypeParam, N4JSPackage.Literals.N4_TYPE_VARIABLE__DECLARED_DEFAULT_ARGUMENT_NODE, issueItem);
haveInvalidDefault = true;
}
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSVariableValidator.xtend b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSVariableValidator.xtend
index 8de8cbc7d8..15134e5cac 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSVariableValidator.xtend
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSVariableValidator.xtend
@@ -21,10 +21,11 @@ import org.eclipse.n4js.n4JS.ParenExpression
import org.eclipse.n4js.n4JS.VariableDeclaration
import org.eclipse.n4js.postprocessing.ASTMetaInfoUtils
import org.eclipse.n4js.validation.AbstractN4JSDeclarativeValidator
-import org.eclipse.n4js.validation.IssueCodes
import org.eclipse.xtext.validation.Check
import org.eclipse.xtext.validation.EValidatorRegistrar
+import static org.eclipse.n4js.validation.IssueCodes.*
+
/**
* Validations for variable declarations and variables.
*/
@@ -47,8 +48,7 @@ class N4JSVariableValidator extends AbstractN4JSDeclarativeValidator {
// TODO: GH-331, remove cases where also the 'UsedBeforeDeclared' issue is raised
val refs = varDecl.expression.collectIdentifierRefsTo(varDecl,newArrayList);
for(IdentifierRef currRef : refs) {
- val message = IssueCodes.getMessageForAST_VAR_DECL_RECURSIVE(varDecl.name)
- addIssue(message, currRef, null, IssueCodes.AST_VAR_DECL_RECURSIVE)
+ addIssue(currRef, null, AST_VAR_DECL_RECURSIVE.toIssueItem(varDecl.name));
}
}
}
@@ -61,8 +61,7 @@ class N4JSVariableValidator extends AbstractN4JSDeclarativeValidator {
val tVariable = varDecl.definedVariable;
if (tVariable !== null && ASTMetaInfoUtils.getLocalVariableReferences(tVariable).empty) {
- val message = IssueCodes.getMessageForCFG_LOCAL_VAR_UNUSED(varDecl.name);
- addIssue(message, varDecl, findNameFeature(varDecl).value, IssueCodes.CFG_LOCAL_VAR_UNUSED); // deactivated during tests
+ addIssue(varDecl, findNameFeature(varDecl).value, CFG_LOCAL_VAR_UNUSED.toIssueItem(varDecl.name)); // deactivated during tests
}
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSXValidator.xtend b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSXValidator.xtend
index b957b9f799..ce7a7cace4 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSXValidator.xtend
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/N4JSXValidator.xtend
@@ -37,7 +37,7 @@ import org.eclipse.n4js.typesystem.N4JSTypeSystem
import org.eclipse.n4js.typesystem.utils.TypeSystemHelper
import org.eclipse.n4js.utils.ResourceType
import org.eclipse.n4js.validation.AbstractN4JSDeclarativeValidator
-import org.eclipse.n4js.validation.IssueCodes
+import org.eclipse.n4js.validation.IssueItem
import org.eclipse.xtext.validation.Check
import org.eclipse.xtext.validation.EValidatorRegistrar
@@ -77,8 +77,7 @@ class N4JSXValidator extends AbstractN4JSDeclarativeValidator {
if (resType == ResourceType.N4JSX || resType == ResourceType.JSX) {
return;
}
- val message = getMessageForJSX_JSXELEMENT_IN_NON_JSX_RESOURCE(resType.name)
- addIssue(message,jsxElem, JSX_JSXELEMENT_IN_NON_JSX_RESOURCE);
+ addIssue(jsxElem, JSX_JSXELEMENT_IN_NON_JSX_RESOURCE.toIssueItem(resType.name));
}
@@ -97,7 +96,7 @@ class N4JSXValidator extends AbstractN4JSDeclarativeValidator {
val firstJSXAbstractElement = script.eAllContents.findFirst[it instanceof JSXAbstractElement]
if (firstJSXAbstractElement !== null && reactHelper.getJsxBackendModule(script.eResource) === null)
- addIssue(getMessageForJSX_REACT_NOT_RESOLVED(), firstJSXAbstractElement, JSX_REACT_NOT_RESOLVED);
+ addIssue(firstJSXAbstractElement, JSX_REACT_NOT_RESOLVED.toIssueItem());
}
/** Make sure the namespace to react module is React. */
@@ -112,9 +111,7 @@ class N4JSXValidator extends AbstractN4JSDeclarativeValidator {
val importedModule = importSpecifier.importedModule;
if (reactModule !== null && importedModule === reactModule) {
if (importSpecifier.alias != ReactHelper.REACT_NAMESPACE_NAME) {
- addIssue(
- getMessageForJSX_REACT_NAMESPACE_NOT_ALLOWED(),
- importSpecifier, JSX_REACT_NAMESPACE_NOT_ALLOWED);
+ addIssue(importSpecifier, JSX_REACT_NAMESPACE_NOT_ALLOWED.toIssueItem());
}
}
}
@@ -131,12 +128,10 @@ class N4JSXValidator extends AbstractN4JSDeclarativeValidator {
if ((jsxElem.jsxClosingName !==null) && !(openingName == closingName)) {
//Only check if the closing element exists, e.g. not null
- val message = getMessageForJSX_JSXELEMENT_OPENING_CLOSING_ELEMENT_NOT_MATCH(openingName, closingName);
addIssue(
- message,
jsxElem,
JSX_ELEMENT__JSX_CLOSING_NAME,
- JSX_JSXELEMENT_OPENING_CLOSING_ELEMENT_NOT_MATCH
+ JSX_JSXELEMENT_OPENING_CLOSING_ELEMENT_NOT_MATCH.toIssueItem(openingName, closingName)
);
}
}
@@ -160,12 +155,10 @@ class N4JSXValidator extends AbstractN4JSDeclarativeValidator {
// If the JSX element name starts with lower case, warning if it is unknown HTML tag
if (!N4JSGlobals.HTML_TAGS.contains(refName)
&& !N4JSGlobals.SVG_TAGS.contains(refName)) {
- val message = getMessageForJSX_TAG_UNKNOWN(refName);
addIssue(
- message,
jsxElem,
JSX_ELEMENT__JSX_ELEMENT_NAME,
- JSX_TAG_UNKNOWN
+ JSX_TAG_UNKNOWN.toIssueItem(refName)
);
}
} else if (G.isAnyDynamic(exprTypeRef)) {
@@ -176,13 +169,11 @@ class N4JSXValidator extends AbstractN4JSDeclarativeValidator {
) {
// JSX element name starts with an upper case, error because it does not bind to a class or function
// See Req. IDE-241115
- val message = getMessageForJSX_REACT_ELEMENT_CLASS_MUST_NOT_BE_ABSTRACT();
- addIssue(message, expr, JSX_REACT_ELEMENT_CLASS_MUST_NOT_BE_ABSTRACT);
+ addIssue(expr, JSX_REACT_ELEMENT_CLASS_MUST_NOT_BE_ABSTRACT.toIssueItem());
} else {
// JSX element name starts with an upper case, error because it does not bind to a class or function
// See Req. IDE-241115
- val message = getMessageForJSX_REACT_ELEMENT_NOT_FUNCTION_OR_CLASS_ERROR(exprTypeRef.typeRefAsString);
- addIssue(message, expr, JSX_REACT_ELEMENT_NOT_FUNCTION_OR_CLASS_ERROR);
+ addIssue(expr, JSX_REACT_ELEMENT_NOT_FUNCTION_OR_CLASS_ERROR.toIssueItem(exprTypeRef.typeRefAsString));
}
return;
}
@@ -210,20 +201,16 @@ class N4JSXValidator extends AbstractN4JSDeclarativeValidator {
val String refName = expr.refName
if ((refName !== null) && (!refName.isEmpty) && Character::isLowerCase(refName.charAt(0))) {
if (isFunctionalComponent) {
- val message = getMessageForJSX_REACT_FUNCTIONAL_COMPONENT_CANNOT_START_WITH_LOWER_CASE(refName);
addIssue(
- message,
jsxElem,
JSX_ELEMENT__JSX_ELEMENT_NAME,
- JSX_REACT_FUNCTIONAL_COMPONENT_CANNOT_START_WITH_LOWER_CASE
+ JSX_REACT_FUNCTIONAL_COMPONENT_CANNOT_START_WITH_LOWER_CASE.toIssueItem(refName)
);
} else {
- val message = IssueCodes.getMessageForJSX_REACT_CLASS_COMPONENT_CANNOT_START_WITH_LOWER_CASE(refName);
addIssue(
- message,
jsxElem,
JSX_ELEMENT__JSX_ELEMENT_NAME,
- JSX_REACT_CLASS_COMPONENT_CANNOT_START_WITH_LOWER_CASE
+ JSX_REACT_CLASS_COMPONENT_CANNOT_START_WITH_LOWER_CASE.toIssueItem(refName)
);
}
}
@@ -245,15 +232,11 @@ class N4JSXValidator extends AbstractN4JSDeclarativeValidator {
val actualReturnTypeRef = exprTypeRef.returnTypeRef;
val result = ts.subtype(G, actualReturnTypeRef, expectedReturnTypeRef);
if (result.failure) {
- val message = IssueCodes.getMessageForJSX_REACT_ELEMENT_FUNCTION_NOT_REACT_ELEMENT_ERROR(
+ val IssueItem issueItem = JSX_REACT_ELEMENT_FUNCTION_NOT_REACT_ELEMENT_ERROR.toIssueItem(
expectedReturnTypeRef.typeRefAsString,
actualReturnTypeRef.typeRefAsString
);
- addIssue(
- message,
- expr,
- JSX_REACT_ELEMENT_FUNCTION_NOT_REACT_ELEMENT_ERROR
- );
+ addIssue(expr, issueItem);
}
}
@@ -274,8 +257,7 @@ class N4JSXValidator extends AbstractN4JSDeclarativeValidator {
val actualTypeRef = TypeUtils.createTypeRef(tclass, TypingStrategy.DEFAULT, true);
val resultSubType = ts.subtype(G, actualTypeRef, expectedTypeRef)
if (resultSubType.failure) {
- val message = getMessageForJSX_REACT_ELEMENT_CLASS_NOT_REACT_ELEMENT_ERROR();
- addIssue(message, expr, JSX_REACT_ELEMENT_CLASS_NOT_REACT_ELEMENT_ERROR);
+ addIssue(expr, JSX_REACT_ELEMENT_CLASS_NOT_REACT_ELEMENT_ERROR.toIssueItem());
}
}
@@ -295,14 +277,13 @@ class N4JSXValidator extends AbstractN4JSDeclarativeValidator {
//they are mainly intended for error cases, not valid code. Probably it should be any+ instead.
//This requires refactoring else where
if (result instanceof UnknownTypeRef) {
- val message = IssueCodes.getMessageForJSX_JSXSPROPERTYATTRIBUTE_NOT_DECLARED_IN_PROPS(propertyAttribute.propertyAsText,
+ val IssueItem issueItem = JSX_JSXSPROPERTYATTRIBUTE_NOT_DECLARED_IN_PROPS.toIssueItem(propertyAttribute.propertyAsText,
jsxElem?.jsxElementName?.expression?.refName);
- addIssue(
- message,
- propertyAttribute,
- JSX_PROPERTY_ATTRIBUTE__PROPERTY,
- JSX_JSXSPROPERTYATTRIBUTE_NOT_DECLARED_IN_PROPS
- );
+ addIssue(
+ propertyAttribute,
+ JSX_PROPERTY_ATTRIBUTE__PROPERTY,
+ issueItem
+ );
}
}
@@ -341,13 +322,12 @@ class N4JSXValidator extends AbstractN4JSDeclarativeValidator {
val fieldOrGetterInPropsTypeRef = ts.tau(fieldOrGetterInProps, propsType);
val result = ts.subtype(G, attributeInSpreadOperatorTypeRef, fieldOrGetterInPropsTypeRef);
if (result.failure) {
- val message = IssueCodes.getMessageForJSX_JSXSPREADATTRIBUTE_WRONG_SUBTYPE(attributeInSpreadOperator.name,
+ val IssueItem issueItem = JSX_JSXSPREADATTRIBUTE_WRONG_SUBTYPE.toIssueItem(attributeInSpreadOperator.name,
attributeInSpreadOperatorTypeRef.typeRefAsString, fieldOrGetterInPropsTypeRef.typeRefAsString);
addIssue(
- message,
spreadAttribute,
JSX_SPREAD_ATTRIBUTE__EXPRESSION,
- IssueCodes.JSX_JSXSPREADATTRIBUTE_WRONG_SUBTYPE
+ issueItem
);
}
}
@@ -365,13 +345,11 @@ class N4JSXValidator extends AbstractN4JSDeclarativeValidator {
return;
if (elem.name == ReactHelper.REACT_NAMESPACE_NAME) {
- val message = IssueCodes.getMessageForJSX_NAME_CANNOT_BE_REACT();
- addIssue(
- message,
- elem,
- findNameFeature(elem).value,
- IssueCodes.JSX_NAME_CANNOT_BE_REACT
- );
+ addIssue(
+ elem,
+ findNameFeature(elem).value,
+ JSX_NAME_CANNOT_BE_REACT.toIssueItem()
+ );
}
}
@@ -408,13 +386,10 @@ class N4JSXValidator extends AbstractN4JSDeclarativeValidator {
].map [ fieldOrGetter | fieldOrGetter.name ].join(",");
if (!missingFieldsStringRep.isEmpty) {
- val message = IssueCodes.
- getMessageForJSX_JSXPROPERTY_ATTRIBUTE_NON_OPTIONAL_PROPERTY_NOT_SPECIFIED(missingFieldsStringRep);
addIssue(
- message,
jsxElem,
JSX_ELEMENT__JSX_ELEMENT_NAME,
- JSX_JSXPROPERTY_ATTRIBUTE_NON_OPTIONAL_PROPERTY_NOT_SPECIFIED
+ JSX_JSXPROPERTY_ATTRIBUTE_NON_OPTIONAL_PROPERTY_NOT_SPECIFIED.toIssueItem(missingFieldsStringRep)
);
}
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/PolyfillValidatorFragment.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/PolyfillValidatorFragment.java
index bcbbd81214..71fbb8d08e 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/PolyfillValidatorFragment.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/PolyfillValidatorFragment.java
@@ -24,6 +24,7 @@
import static org.eclipse.n4js.validation.IssueCodes.CLF_POLYFILL_EXTEND_MISSING;
import static org.eclipse.n4js.validation.IssueCodes.CLF_POLYFILL_FILLED_NOT_PROVIDEDBYRUNTIME;
import static org.eclipse.n4js.validation.IssueCodes.CLF_POLYFILL_INCOMPLETE_TYPEARGS;
+import static org.eclipse.n4js.validation.IssueCodes.CLF_POLYFILL_MULTIPOLYFILLS_MEMBER_CONFLICT;
import static org.eclipse.n4js.validation.IssueCodes.CLF_POLYFILL_NOT_DIRECTLY_EXPORTED;
import static org.eclipse.n4js.validation.IssueCodes.CLF_POLYFILL_NOT_PROVIDEDBYRUNTIME;
import static org.eclipse.n4js.validation.IssueCodes.CLF_POLYFILL_NO_EXTENDS_ADDITIONAL;
@@ -32,23 +33,6 @@
import static org.eclipse.n4js.validation.IssueCodes.CLF_POLYFILL_STATIC_FILLED_TYPE_NOT_AWARE;
import static org.eclipse.n4js.validation.IssueCodes.CLF_POLYFILL_TYPEPARS_DIFFER_TYPEARGS;
import static org.eclipse.n4js.validation.IssueCodes.POLY_STATIC_POLYFILL_MODULE_ONLY_FILLING_CLASSES;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForCLF_POLYFILL_DIFFERENT_CLASSIFIER_KIND;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForCLF_POLYFILL_DIFFERENT_GLOBALS;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForCLF_POLYFILL_DIFFERENT_MODIFIER;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForCLF_POLYFILL_DIFFERENT_MODULE_SPECIFIER;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForCLF_POLYFILL_DIFFERENT_NAME;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForCLF_POLYFILL_DIFFERENT_TYPEPARS;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForCLF_POLYFILL_EXTEND_MISSING;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForCLF_POLYFILL_FILLED_NOT_PROVIDEDBYRUNTIME;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForCLF_POLYFILL_INCOMPLETE_TYPEARGS;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForCLF_POLYFILL_NOT_DIRECTLY_EXPORTED;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForCLF_POLYFILL_NOT_PROVIDEDBYRUNTIME;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForCLF_POLYFILL_NO_EXTENDS_ADDITIONAL;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForCLF_POLYFILL_NO_IMPLEMENTS;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForCLF_POLYFILL_STATIC_DIFFERENT_VARIANT;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForCLF_POLYFILL_STATIC_FILLED_TYPE_NOT_AWARE;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForCLF_POLYFILL_TYPEPARS_DIFFER_TYPEARGS;
-import static org.eclipse.n4js.validation.IssueCodes.getMessageForPOLY_STATIC_POLYFILL_MODULE_ONLY_FILLING_CLASSES;
import java.util.ArrayList;
import java.util.Collections;
@@ -79,7 +63,7 @@
import org.eclipse.n4js.ts.types.TypesPackage;
import org.eclipse.n4js.ts.types.TypingStrategy;
import org.eclipse.n4js.utils.N4JSLanguageUtils;
-import org.eclipse.n4js.validation.IssueCodes;
+import org.eclipse.n4js.validation.IssueItem;
import org.eclipse.n4js.validation.N4JSElementKeywordProvider;
import org.eclipse.xtext.naming.IQualifiedNameProvider;
import org.eclipse.xtext.resource.IContainer;
@@ -130,8 +114,8 @@ private static class PolyfillValidationState {
String name;
}
- private void addIssue(PolyfillValidationState state, String msg, String issueCode) {
- state.host.addIssue(msg, state.n4Classifier, N4_TYPE_DECLARATION__NAME, issueCode);
+ private void addIssue(PolyfillValidationState state, IssueItem issueItem) {
+ state.host.addIssue(issueItem.message, state.n4Classifier, N4_TYPE_DECLARATION__NAME, issueItem.getID());
}
/**
@@ -206,8 +190,8 @@ && holdsSinglePolyfillSource(state))) //
// § 140.1 only static polyfills are allowed in StaticPolyfillModule.
if (!isStaticPolyFill && isContainedInStaticPolyfillModule(n4Classifier)) {
// n4Classifier is top-level by default
- validator.addIssue(getMessageForPOLY_STATIC_POLYFILL_MODULE_ONLY_FILLING_CLASSES(), n4Classifier,
- N4_TYPE_DECLARATION__NAME, POLY_STATIC_POLYFILL_MODULE_ONLY_FILLING_CLASSES);
+ validator.addIssue(POLY_STATIC_POLYFILL_MODULE_ONLY_FILLING_CLASSES.getMessage(), n4Classifier,
+ N4_TYPE_DECLARATION__NAME, POLY_STATIC_POLYFILL_MODULE_ONLY_FILLING_CLASSES.name());
return false;
}
@@ -220,8 +204,7 @@ && holdsSinglePolyfillSource(state))) //
private boolean holdsFilledClassIsStaticPolyfillAware(PolyfillValidationState state) {
if (!(isContainedInStaticPolyfillAware(state.filledType))) { // (Static Polyfill) 139.5
- final String msg = getMessageForCLF_POLYFILL_STATIC_FILLED_TYPE_NOT_AWARE(state.name);
- addIssue(state, msg, CLF_POLYFILL_STATIC_FILLED_TYPE_NOT_AWARE);
+ addIssue(state, CLF_POLYFILL_STATIC_FILLED_TYPE_NOT_AWARE.toIssueItem(state.name));
return false;
}
@@ -238,8 +221,7 @@ private boolean holdsSameJavascriptVariant(PolyfillValidationState state) {
&& fillerModule.isN4jsdModule() != filledModule.isN4jsdModule()) {
final String fileExt = fillerModule.isN4jsdModule() ? N4JSGlobals.N4JSD_FILE_EXTENSION
: N4JSGlobals.N4JS_FILE_EXTENSION;
- final String msg = getMessageForCLF_POLYFILL_STATIC_DIFFERENT_VARIANT(state.name, "." + fileExt);
- addIssue(state, msg, CLF_POLYFILL_STATIC_DIFFERENT_VARIANT);
+ addIssue(state, CLF_POLYFILL_STATIC_DIFFERENT_VARIANT.toIssueItem(state.name, "." + fileExt));
return false;
}
return true;
@@ -251,9 +233,8 @@ private boolean holdsSameJavascriptVariant(PolyfillValidationState state) {
private boolean holdsExplicitExtends(PolyfillValidationState state) {
final TypeReferenceNode filledTypeRef = state.superClassifierNode;
if (filledTypeRef == null) { // (Polyfill Class) 156.1
- final String msg = getMessageForCLF_POLYFILL_EXTEND_MISSING(state.name,
- keywordProvider.keywordWithIndefiniteArticle(state.polyType));
- addIssue(state, msg, CLF_POLYFILL_EXTEND_MISSING);
+ addIssue(state, CLF_POLYFILL_EXTEND_MISSING.toIssueItem(state.name,
+ keywordProvider.keywordWithIndefiniteArticle(state.polyType)));
return false;
}
return true;
@@ -261,11 +242,10 @@ private boolean holdsExplicitExtends(PolyfillValidationState state) {
private boolean holdPolyfillClassifierKind(PolyfillValidationState state) {
if (state.polyType.eClass() != state.filledType.eClass()) {
- final String msg = getMessageForCLF_POLYFILL_DIFFERENT_CLASSIFIER_KIND(
+ addIssue(state, CLF_POLYFILL_DIFFERENT_CLASSIFIER_KIND.toIssueItem(
keywordProvider.keyword(state.filledType), state.name,
keywordProvider.keywordWithIndefiniteArticle(state.filledType),
- keywordProvider.keywordWithIndefiniteArticle(state.polyType));
- addIssue(state, msg, CLF_POLYFILL_DIFFERENT_CLASSIFIER_KIND);
+ keywordProvider.keywordWithIndefiniteArticle(state.polyType)));
return false;
}
return true;
@@ -276,17 +256,16 @@ private boolean holdPolyfillClassifierKind(PolyfillValidationState state) {
*/
private boolean holdPolyfillName(PolyfillValidationState state) {
if (!state.name.equals(state.filledType.getName())) { // (Polyfill Class) 156.2
- final String msg = getMessageForCLF_POLYFILL_DIFFERENT_NAME(state.name,
- keywordProvider.keyword(state.filledType), state.filledType.getName());
- addIssue(state, msg, CLF_POLYFILL_DIFFERENT_NAME);
+ addIssue(state, CLF_POLYFILL_DIFFERENT_NAME.toIssueItem(state.name,
+ keywordProvider.keyword(state.filledType), state.filledType.getName()));
return false;
}
final boolean isGlobalFilled = GLOBAL.hasAnnotation(state.filledType);
final boolean isGlobalPoly = GLOBAL.hasAnnotation(state.polyType);
if (isGlobalFilled != isGlobalPoly) { // (Polyfill Class) 156.2
- final String msg = getMessageForCLF_POLYFILL_DIFFERENT_GLOBALS(
+ IssueItem issueItem = CLF_POLYFILL_DIFFERENT_GLOBALS.toIssueItem(
state.name, isGlobalPoly ? "global" : "not global", isGlobalFilled ? "global" : "not global");
- addIssue(state, msg, CLF_POLYFILL_DIFFERENT_GLOBALS);
+ addIssue(state, issueItem);
return false;
}
if (!isGlobalFilled) {
@@ -295,10 +274,11 @@ private boolean holdPolyfillName(PolyfillValidationState state) {
if (polyModule != null && filledModule != null) { // avoid consequential errors
if (!polyModule.getModuleSpecifier().equals(filledModule.getModuleSpecifier())) { // (Polyfill Class)
// 156.2
- final String msg = getMessageForCLF_POLYFILL_DIFFERENT_MODULE_SPECIFIER(state.name,
+ final IssueItem issueItem = CLF_POLYFILL_DIFFERENT_MODULE_SPECIFIER.toIssueItem(
+ state.name,
polyModule.getModuleSpecifier(),
filledModule.getModuleSpecifier());
- addIssue(state, msg, CLF_POLYFILL_DIFFERENT_MODULE_SPECIFIER);
+ addIssue(state, issueItem);
return false;
}
}
@@ -311,13 +291,11 @@ private boolean holdPolyfillName(PolyfillValidationState state) {
*/
private boolean holdsProvidedByRuntime(PolyfillValidationState state) {
if (!state.polyType.isProvidedByRuntime()) {
- final String msg = getMessageForCLF_POLYFILL_NOT_PROVIDEDBYRUNTIME(state.name);
- addIssue(state, msg, CLF_POLYFILL_NOT_PROVIDEDBYRUNTIME);
+ addIssue(state, CLF_POLYFILL_NOT_PROVIDEDBYRUNTIME.toIssueItem(state.name));
return false;
}
if (!state.filledType.isProvidedByRuntime()) {
- final String msg = getMessageForCLF_POLYFILL_FILLED_NOT_PROVIDEDBYRUNTIME(state.name);
- addIssue(state, msg, CLF_POLYFILL_FILLED_NOT_PROVIDEDBYRUNTIME);
+ addIssue(state, CLF_POLYFILL_FILLED_NOT_PROVIDEDBYRUNTIME.toIssueItem(state.name));
return false;
}
@@ -330,14 +308,12 @@ private boolean holdsProvidedByRuntime(PolyfillValidationState state) {
private boolean holdsNoImplementsOrConsumes(PolyfillValidationState state) {
if (state.n4Classifier instanceof N4ClassDeclaration) {
if (!((N4ClassDeclaration) state.n4Classifier).getImplementedInterfaceRefs().isEmpty()) {
- final String msg = getMessageForCLF_POLYFILL_NO_IMPLEMENTS(state.name);
- addIssue(state, msg, CLF_POLYFILL_NO_IMPLEMENTS);
+ addIssue(state, CLF_POLYFILL_NO_IMPLEMENTS.toIssueItem(state.name));
return false;
}
} else if (state.n4Classifier instanceof N4InterfaceDeclaration) {
if (((N4InterfaceDeclaration) state.n4Classifier).getSuperInterfaceRefs().size() > 1) {
- final String msg = getMessageForCLF_POLYFILL_NO_EXTENDS_ADDITIONAL(state.name);
- addIssue(state, msg, CLF_POLYFILL_NO_EXTENDS_ADDITIONAL);
+ addIssue(state, CLF_POLYFILL_NO_EXTENDS_ADDITIONAL.toIssueItem(state.name));
return false;
}
}
@@ -346,8 +322,7 @@ private boolean holdsNoImplementsOrConsumes(PolyfillValidationState state) {
private boolean holdsIsDirectlyExported(PolyfillValidationState state) {
if (!state.polyType.isDirectlyExported()) {
- final String msg = getMessageForCLF_POLYFILL_NOT_DIRECTLY_EXPORTED(state.name);
- addIssue(state, msg, CLF_POLYFILL_NOT_DIRECTLY_EXPORTED);
+ addIssue(state, CLF_POLYFILL_NOT_DIRECTLY_EXPORTED.toIssueItem(state.name));
return false;
}
return true;
@@ -359,11 +334,11 @@ private boolean holdsIsDirectlyExported(PolyfillValidationState state) {
private boolean holdsEqualModifiers(PolyfillValidationState state) {
boolean result = true;
if (state.polyType.getTypeAccessModifier() != state.filledType.getTypeAccessModifier()) {
- final String msg = getMessageForCLF_POLYFILL_DIFFERENT_MODIFIER(state.name,
+ final IssueItem issueItem = CLF_POLYFILL_DIFFERENT_MODIFIER.toIssueItem(state.name,
keywordProvider.keyword(state.polyType.getTypeAccessModifier()),
keywordProvider.keyword(state.filledType.getTypeAccessModifier()),
keywordProvider.keyword(state.filledType));
- addIssue(state, msg, CLF_POLYFILL_DIFFERENT_MODIFIER);
+ addIssue(state, issueItem);
result = false;
}
result &= holdsEqualModifier(state, "abstract", state.polyType.isAbstract(), state.filledType.isAbstract());
@@ -376,11 +351,11 @@ private boolean holdsEqualModifiers(PolyfillValidationState state) {
private boolean holdsEqualModifier(PolyfillValidationState state, String modifierName, boolean poly,
boolean filled) {
if (poly != filled) {
- final String msg = getMessageForCLF_POLYFILL_DIFFERENT_MODIFIER(state.name,
+ final IssueItem issueItem = CLF_POLYFILL_DIFFERENT_MODIFIER.toIssueItem(state.name,
(poly ? "" : "non-") + modifierName,
(filled ? "" : "non-") + modifierName,
keywordProvider.keyword(state.filledType));
- addIssue(state, msg, CLF_POLYFILL_DIFFERENT_MODIFIER);
+ addIssue(state, issueItem);
return false;
}
return true;
@@ -391,11 +366,11 @@ private boolean holdsEqualTypingStrategy(PolyfillValidationState state, TypingSt
poly = poly == TypingStrategy.DEFAULT ? TypingStrategy.NOMINAL : poly;
filled = filled == TypingStrategy.DEFAULT ? TypingStrategy.NOMINAL : filled;
if (poly != filled) {
- final String msg = getMessageForCLF_POLYFILL_DIFFERENT_MODIFIER(state.name,
+ final IssueItem issueItem = CLF_POLYFILL_DIFFERENT_MODIFIER.toIssueItem(state.name,
(poly != TypingStrategy.NOMINAL ? "definition-site " : "") + keywordProvider.keyword(poly),
(filled != TypingStrategy.NOMINAL ? "definition-site " : "") + keywordProvider.keyword(filled),
keywordProvider.keyword(state.filledType));
- addIssue(state, msg, CLF_POLYFILL_DIFFERENT_MODIFIER);
+ addIssue(state, issueItem);
return false;
}
return true;
@@ -411,9 +386,9 @@ private boolean holdsEqualTypeVariables(PolyfillValidationState state) {
final String typeVars2 = Joiner.on(',').join(
state.filledType.getTypeVars().stream().map(v -> v.getTypeAsString()).toArray());
if (!typeVars1.equals(typeVars2)) {
- final String msg = getMessageForCLF_POLYFILL_DIFFERENT_TYPEPARS(state.name,
+ final IssueItem issueItem = CLF_POLYFILL_DIFFERENT_TYPEPARS.toIssueItem(state.name,
keywordProvider.keyword(state.filledType));
- addIssue(state, msg, CLF_POLYFILL_DIFFERENT_TYPEPARS);
+ addIssue(state, issueItem);
return false;
}
@@ -428,8 +403,8 @@ private boolean holdsEqualTypeVariables(PolyfillValidationState state) {
if (args.size() < expectedTypeParamCountMin || args.size() > expectedTypeParamCountMax) {
return true; // consequential error
} else if (args.size() != expectedTypeParamCountMax) {
- final String msg = getMessageForCLF_POLYFILL_INCOMPLETE_TYPEARGS(state.name);
- addIssue(state, msg, CLF_POLYFILL_INCOMPLETE_TYPEARGS);
+ final IssueItem issueItem = CLF_POLYFILL_INCOMPLETE_TYPEARGS.toIssueItem(state.name);
+ addIssue(state, issueItem);
return false;
}
for (int i = state.polyType.getTypeVars().size() - 1; i >= 0; i--) {
@@ -438,8 +413,9 @@ private boolean holdsEqualTypeVariables(PolyfillValidationState state) {
String argString = arg.getTypeRefAsString();
String parString = par.getName();
if (!argString.equals(parString)) {
- final String msg = getMessageForCLF_POLYFILL_TYPEPARS_DIFFER_TYPEARGS(state.name, parString, argString);
- addIssue(state, msg, CLF_POLYFILL_TYPEPARS_DIFFER_TYPEARGS);
+ final IssueItem issueItem = CLF_POLYFILL_TYPEPARS_DIFFER_TYPEARGS.toIssueItem(state.name, parString,
+ argString);
+ addIssue(state, issueItem);
return false;
}
}
@@ -522,9 +498,10 @@ private boolean holdsSinglePolyfillSource(PolyfillValidationState state) {
String memberAxis = myMember.getContainingType().getName() + "." + myMember.getName();
// Issue on filled Member-name declaration:
- String msg = IssueCodes.getMessageForCLF_POLYFILL_MULTIPOLYFILLS_MEMBER_CONFLICT(uris, memberAxis);
- state.host.addIssue(msg, myMember.getAstElement(), N4JSPackage.Literals.PROPERTY_NAME_OWNER__DECLARED_NAME,
- IssueCodes.CLF_POLYFILL_MULTIPOLYFILLS_MEMBER_CONFLICT);
+ IssueItem issueItem = CLF_POLYFILL_MULTIPOLYFILLS_MEMBER_CONFLICT.toIssueItem(uris, memberAxis);
+ state.host.addIssue(issueItem.message, myMember.getAstElement(),
+ N4JSPackage.Literals.PROPERTY_NAME_OWNER__DECLARED_NAME,
+ issueItem.getID());
}
return true;
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/RuntimeDependencyValidator.xtend b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/RuntimeDependencyValidator.xtend
index ae4dfd4bc1..ec0ad75891 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/RuntimeDependencyValidator.xtend
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/RuntimeDependencyValidator.xtend
@@ -24,12 +24,12 @@ import org.eclipse.n4js.postprocessing.RuntimeDependencyProcessor
import org.eclipse.n4js.resource.N4JSResource
import org.eclipse.n4js.ts.types.TModule
import org.eclipse.n4js.validation.AbstractN4JSDeclarativeValidator
-import org.eclipse.n4js.validation.IssueCodes
import org.eclipse.xtext.EcoreUtil2
import org.eclipse.xtext.validation.Check
import org.eclipse.xtext.validation.EValidatorRegistrar
import static org.eclipse.n4js.utils.N4JSLanguageUtils.*
+import static org.eclipse.n4js.validation.IssueCodes.*
/**
* Validations related to runtime dependencies (in particular, illegal load-time dependency cycles).
@@ -68,9 +68,8 @@ class RuntimeDependencyValidator extends AbstractN4JSDeclarativeValidator {
val hasCycle = (targetModule === containingModule && !containingModule.cyclicModulesRuntime.empty)
|| (targetModule !== containingModule && containingModule.cyclicModulesRuntime.contains(targetModule));
if (hasCycle) {
- val message = IssueCodes.getMessageForLTD_ILLEGAL_LOADTIME_REFERENCE()
- + '\n' + dependencyCycleToString(containingModule, false, INDENT);
- addIssue(message, idRef, IssueCodes.LTD_ILLEGAL_LOADTIME_REFERENCE);
+ val cycleStr = '\n' + dependencyCycleToString(containingModule, false, INDENT);
+ addIssue(idRef, LTD_ILLEGAL_LOADTIME_REFERENCE.toIssueItem(cycleStr));
}
}
@@ -105,9 +104,8 @@ class RuntimeDependencyValidator extends AbstractN4JSDeclarativeValidator {
def private boolean holdsNotAnIllegalModuleRefWithinLoadtimeCycle(TModule containingModule, ModuleRef moduleRef) {
val targetModule = moduleRef.module;
if (containingModule.cyclicModulesLoadtimeForInheritance.contains(targetModule)) {
- val message = IssueCodes.getMessageForLTD_LOADTIME_DEPENDENCY_CYCLE() + "\n"
- + dependencyCycleToString(targetModule, true, INDENT);
- addIssue(message, moduleRef, N4JSPackage.eINSTANCE.moduleRef_Module, IssueCodes.LTD_LOADTIME_DEPENDENCY_CYCLE);
+ val cycleStr = "\n" + dependencyCycleToString(targetModule, true, INDENT);
+ addIssue(moduleRef, N4JSPackage.eINSTANCE.moduleRef_Module, LTD_LOADTIME_DEPENDENCY_CYCLE.toIssueItem(cycleStr));
return false;
}
return true;
@@ -143,18 +141,14 @@ class RuntimeDependencyValidator extends AbstractN4JSDeclarativeValidator {
// ERROR: referring to a multi-LTD-target from within the dependency cycle cluster (Req. GH-1678, Constraint 2)
// --> load-time dependency conflict
val otherLTDSources = otherLTDSourcesToString(containingModule, targetModule);
- val message = IssueCodes.getMessageForLTD_LOADTIME_DEPENDENCY_CONFLICT(targetModule.simpleName, otherLTDSources) + "\n"
- + "Containing runtime dependency cycle cluster:\n"
- + dependencyCycleToString(targetModule, false, INDENT);
- addIssue(message, moduleRef, N4JSPackage.eINSTANCE.moduleRef_Module, IssueCodes.LTD_LOADTIME_DEPENDENCY_CONFLICT);
+ val cycleStr = "\nContaining runtime dependency cycle cluster:\n" + dependencyCycleToString(targetModule, false, INDENT);
+ addIssue(moduleRef, N4JSPackage.eINSTANCE.moduleRef_Module, LTD_LOADTIME_DEPENDENCY_CONFLICT.toIssueItem(targetModule.simpleName, otherLTDSources, cycleStr));
return false;
} else {
// ERROR: referring to an LTD target from outside the dependency cycle cluster (Req. GH-1678, Constraint 3)
val healingModulesStr = healingModulesToString(targetModule);
- val message = IssueCodes.getMessageForLTD_REFERENCE_TO_LOADTIME_DEPENDENCY_TARGET(targetModule.simpleName, healingModulesStr) + "\n"
- + "Containing runtime dependency cycle cluster:\n"
- + dependencyCycleToString(targetModule, false, INDENT);
- addIssue(message, moduleRef, N4JSPackage.eINSTANCE.moduleRef_Module, IssueCodes.LTD_REFERENCE_TO_LOADTIME_DEPENDENCY_TARGET);
+ val cycleStr = "\nContaining runtime dependency cycle cluster:\n" + dependencyCycleToString(targetModule, false, INDENT);
+ addIssue(moduleRef, N4JSPackage.eINSTANCE.moduleRef_Module, LTD_REFERENCE_TO_LOADTIME_DEPENDENCY_TARGET.toIssueItem(targetModule.simpleName, healingModulesStr, cycleStr));
return true; // because we assume a healing import will be added by transpiler, this module reference can be treated as healing in calling method
}
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/StaticPolyfillValidatorExtension.xtend b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/StaticPolyfillValidatorExtension.xtend
index 6493f59c1c..3f8fddb082 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/StaticPolyfillValidatorExtension.xtend
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/StaticPolyfillValidatorExtension.xtend
@@ -16,9 +16,9 @@ import org.eclipse.n4js.n4JS.N4EnumDeclaration
import org.eclipse.n4js.n4JS.N4InterfaceDeclaration
import org.eclipse.n4js.n4JS.N4JSPackage
import org.eclipse.n4js.n4JS.Script
-import org.eclipse.n4js.validation.IssueCodes
import org.eclipse.n4js.n4JS.N4ClassDeclaration
+import static org.eclipse.n4js.validation.IssueCodes.*
import static extension org.eclipse.n4js.utils.N4JSLanguageUtils.*
/**
@@ -30,9 +30,8 @@ public class StaticPolyfillValidatorExtension {
/** §143 (Restriction on static-polyfilling): §143.1 only classes in staticPolyfillModule allowed. */
public static def internalCheckNotInStaticPolyfillModule(N4InterfaceDeclaration n4InterfaceDeclaration, N4JSInterfaceValidator host) {
if (n4InterfaceDeclaration.isContainedInStaticPolyfillModule) {
- val msg = IssueCodes.messageForPOLY_STATIC_POLYFILL_MODULE_ONLY_FILLING_CLASSES;
- host.addIssue(msg, n4InterfaceDeclaration, N4JSPackage.Literals.N4_TYPE_DECLARATION__NAME,
- IssueCodes.POLY_STATIC_POLYFILL_MODULE_ONLY_FILLING_CLASSES);
+ host.addIssue(n4InterfaceDeclaration, N4JSPackage.Literals.N4_TYPE_DECLARATION__NAME,
+ POLY_STATIC_POLYFILL_MODULE_ONLY_FILLING_CLASSES.toIssueItem());
}
}
@@ -40,9 +39,8 @@ public class StaticPolyfillValidatorExtension {
/** §143 (Restriction on static-polyfilling): §143.1 only classes in staticPolyfillModule allowed. */
public static def internalCheckNotInStaticPolyfillModule(N4EnumDeclaration n4EnumDecl, N4JSEnumValidator host) {
if (n4EnumDecl.isContainedInStaticPolyfillModule) {
- val msg = IssueCodes.messageForPOLY_STATIC_POLYFILL_MODULE_ONLY_FILLING_CLASSES;
- host.addIssue(msg, n4EnumDecl, N4JSPackage.Literals.N4_TYPE_DECLARATION__NAME,
- IssueCodes.POLY_STATIC_POLYFILL_MODULE_ONLY_FILLING_CLASSES);
+ host.addIssue(n4EnumDecl, N4JSPackage.Literals.N4_TYPE_DECLARATION__NAME,
+ POLY_STATIC_POLYFILL_MODULE_ONLY_FILLING_CLASSES.toIssueItem());
}
}
@@ -54,9 +52,8 @@ public class StaticPolyfillValidatorExtension {
if( cont instanceof Script)
{
if ( functionDeclaration.isContainedInStaticPolyfillModule ) {
- val msg = IssueCodes.messageForPOLY_STATIC_POLYFILL_MODULE_ONLY_FILLING_CLASSES;
- host.addIssue(msg, functionDeclaration, N4JSPackage.Literals.FUNCTION_DECLARATION__NAME,
- IssueCodes.POLY_STATIC_POLYFILL_MODULE_ONLY_FILLING_CLASSES);
+ host.addIssue(functionDeclaration, N4JSPackage.Literals.FUNCTION_DECLARATION__NAME,
+ POLY_STATIC_POLYFILL_MODULE_ONLY_FILLING_CLASSES.toIssueItem());
}
}
}
@@ -65,10 +62,8 @@ public class StaticPolyfillValidatorExtension {
public static def internalCheckPolyFilledClassWithAdditionalInterface(N4ClassDeclaration classDeclaration, N4JSClassValidator host) {
if( classDeclaration.isStaticPolyfill ) {
if( ! classDeclaration.implementedInterfaceRefs.isEmpty ) {
- val msg = IssueCodes.messageForPOLY_IMPLEMENTING_INTERFACE_NOT_ALLOWED;
- host.addIssue(msg, classDeclaration, N4JSPackage.Literals.N4_CLASS_DEFINITION__IMPLEMENTED_INTERFACE_REFS,
- IssueCodes.POLY_IMPLEMENTING_INTERFACE_NOT_ALLOWED);
-
+ host.addIssue(classDeclaration, N4JSPackage.Literals.N4_CLASS_DEFINITION__IMPLEMENTED_INTERFACE_REFS,
+ POLY_IMPLEMENTING_INTERFACE_NOT_ALLOWED.toIssueItem());
}
}
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/ThirdPartyValidator.xtend b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/ThirdPartyValidator.xtend
index 7f7fbcefa3..447b7ae056 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/ThirdPartyValidator.xtend
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/ThirdPartyValidator.xtend
@@ -52,9 +52,7 @@ class ThirdPartyValidator extends AbstractN4JSDeclarativeValidator {
|| stmnt.varStmtKeyword === VariableStatementKeyword.CONST) {
for (varDecl : stmnt.varDecl) {
if (varDecl.name == funName) {
- addIssue(messageForTHIRD_PARTY_BABEL_LET_CONST_IN_FUN_EXPR,
- varDecl, N4JSPackage.eINSTANCE.abstractVariable_Name,
- THIRD_PARTY_BABEL_LET_CONST_IN_FUN_EXPR);
+ addIssue(varDecl, N4JSPackage.eINSTANCE.abstractVariable_Name, THIRD_PARTY_BABEL_LET_CONST_IN_FUN_EXPR.toIssueItem());
}
}
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/UnsupportedFeatureValidator.xtend b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/UnsupportedFeatureValidator.xtend
index 2b7faf98b6..52c78939c8 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/UnsupportedFeatureValidator.xtend
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/UnsupportedFeatureValidator.xtend
@@ -30,13 +30,13 @@ import org.eclipse.n4js.n4JS.PropertySpread
import org.eclipse.n4js.utils.ResourceType
import org.eclipse.n4js.validation.ASTStructureValidator
import org.eclipse.n4js.validation.AbstractN4JSDeclarativeValidator
-import org.eclipse.n4js.validation.IssueCodes
import org.eclipse.n4js.validation.JavaScriptVariantHelper
import org.eclipse.xtext.nodemodel.util.NodeModelUtils
import org.eclipse.xtext.validation.Check
import org.eclipse.xtext.validation.EValidatorRegistrar
import static org.eclipse.n4js.utils.N4JSLanguageUtils.*
+import static org.eclipse.n4js.validation.IssueCodes.*
/**
* Validations to show an error for unsupported language features, mostly ECMAScript6 features.
@@ -167,16 +167,14 @@ class UnsupportedFeatureValidator extends AbstractN4JSDeclarativeValidator {
}
def private void unsupported(String msg, EObject source, EStructuralFeature feature) {
addIssue(
- IssueCodes.getMessageForUNSUPPORTED(msg),
source, feature,
- IssueCodes.UNSUPPORTED);
+ UNSUPPORTED.toIssueItem(msg));
}
def private void unsupported(String msg, EObject source, int offset, int length) {
addIssue(
- IssueCodes.getMessageForUNSUPPORTED(msg),
source,
offset, length,
- IssueCodes.UNSUPPORTED);
+ UNSUPPORTED.toIssueItem(msg));
}
/**
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/flowgraphs/DeadCodeValidator.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/flowgraphs/DeadCodeValidator.java
index 8c46a5ada3..d604e46f23 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/flowgraphs/DeadCodeValidator.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/flowgraphs/DeadCodeValidator.java
@@ -21,6 +21,7 @@
import org.eclipse.n4js.n4JS.ReturnStatement;
import org.eclipse.n4js.n4JS.ThrowStatement;
import org.eclipse.n4js.validation.IssueCodes;
+import org.eclipse.n4js.validation.IssueItem;
import org.eclipse.n4js.validation.N4JSElementKeywordProvider;
import org.eclipse.n4js.validation.validators.N4JSFlowgraphValidator;
@@ -55,13 +56,11 @@ private void internalCheckDeadCode(N4JSFlowgraphValidator fVali) {
for (DeadCodeRegion dcRegion : deadCodeRegions) {
String stmtDescription = getStatementDescription(dcRegion);
- String errCode = IssueCodes.FUN_DEAD_CODE;
- String msg = IssueCodes.getMessageForFUN_DEAD_CODE();
+ IssueItem issueItem = IssueCodes.FUN_DEAD_CODE.toIssueItem();
if (stmtDescription != null) {
- msg = IssueCodes.getMessageForFUN_DEAD_CODE_WITH_PREDECESSOR(stmtDescription);
- errCode = IssueCodes.FUN_DEAD_CODE_WITH_PREDECESSOR;
+ issueItem = IssueCodes.FUN_DEAD_CODE_WITH_PREDECESSOR.toIssueItem(stmtDescription);
}
- fVali.addIssue(msg, dcRegion.getContainer(), dcRegion.getOffset(), dcRegion.getLength(), errCode);
+ fVali.addIssue(dcRegion.getContainer(), dcRegion.getOffset(), dcRegion.getLength(), issueItem);
}
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/flowgraphs/MissingReturnOrThrowValidator.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/flowgraphs/MissingReturnOrThrowValidator.java
index 3a12eba755..98a355e6cf 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/flowgraphs/MissingReturnOrThrowValidator.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/flowgraphs/MissingReturnOrThrowValidator.java
@@ -49,8 +49,7 @@ private void internalCheckMissingReturnDisallowed(N4JSFlowgraphValidator fVali)
Collection mrtFunctions = mrta.getMRTFunctions();
for (FunctionOrFieldAccessor fofa : mrtFunctions) {
EStructuralFeature highlightFeature = getMarkedElement(fofa);
- String msg = IssueCodes.getMessageForFUN_MISSING_RETURN_OR_THROW_STATEMENT();
- fVali.addIssue(msg, fofa, highlightFeature, IssueCodes.FUN_MISSING_RETURN_OR_THROW_STATEMENT);
+ fVali.addIssue(fofa, highlightFeature, IssueCodes.FUN_MISSING_RETURN_OR_THROW_STATEMENT.toIssueItem());
}
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/flowgraphs/NullUndefinedValidator.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/flowgraphs/NullUndefinedValidator.java
index 00a25f425b..ef4c2a093b 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/flowgraphs/NullUndefinedValidator.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/flowgraphs/NullUndefinedValidator.java
@@ -10,6 +10,8 @@
*/
package org.eclipse.n4js.validation.validators.flowgraphs;
+import static org.eclipse.n4js.validation.IssueCodes.DFG_NULL_DEREFERENCE;
+
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@@ -26,7 +28,7 @@
import org.eclipse.n4js.n4JS.FunctionExpression;
import org.eclipse.n4js.n4JS.N4JSASTUtils;
import org.eclipse.n4js.utils.FindReferenceHelper;
-import org.eclipse.n4js.validation.IssueCodes;
+import org.eclipse.n4js.validation.IssueItem;
import org.eclipse.n4js.validation.validators.N4JSFlowgraphValidator;
import org.eclipse.n4js.workspace.N4JSSourceFolderSnapshot;
import org.eclipse.n4js.workspace.WorkspaceAccess;
@@ -73,8 +75,8 @@ private void internalCheckNullDereference(N4JSFlowgraphValidator fVali) {
String isOrMaybe = getAssertionString(ndr, isLeakingToClosure);
String nullOrUndefined = getNullOrUndefinedString(ndr);
String reason = getReason(ndr);
- String msg = IssueCodes.getMessageForDFG_NULL_DEREFERENCE(varName, isOrMaybe, nullOrUndefined, reason);
- fVali.addIssue(msg, ndr.cfe, IssueCodes.DFG_NULL_DEREFERENCE); // deactivated during tests
+ IssueItem issueItem = DFG_NULL_DEREFERENCE.toIssueItem(varName, isOrMaybe, nullOrUndefined, reason);
+ fVali.addIssue(ndr.cfe, issueItem); // deactivated during tests
}
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/flowgraphs/UsedBeforeDeclaredValidator.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/flowgraphs/UsedBeforeDeclaredValidator.java
index d38153021d..335546f73a 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/flowgraphs/UsedBeforeDeclaredValidator.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/flowgraphs/UsedBeforeDeclaredValidator.java
@@ -44,8 +44,7 @@ private void internalCheckUsedBeforeDeclared(N4JSFlowgraphValidator fVali) {
for (IdentifierRef idRef : usedBeforeDeclared) {
String varName = idRef.getId().getName();
- String msg = IssueCodes.getMessageForCFG_USED_BEFORE_DECLARED(varName);
- fVali.addIssue(msg, idRef, IssueCodes.CFG_USED_BEFORE_DECLARED);
+ fVali.addIssue(idRef, IssueCodes.CFG_USED_BEFORE_DECLARED.toIssueItem(varName));
}
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/packagejson/AbstractPackageJSONValidatorExtension.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/packagejson/AbstractPackageJSONValidatorExtension.java
index f291bcdd9e..bd8b3bcbcf 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/packagejson/AbstractPackageJSONValidatorExtension.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/packagejson/AbstractPackageJSONValidatorExtension.java
@@ -319,8 +319,8 @@ protected boolean isResponsible(Map context, EObject eObject) {
protected void checkIsPresent(EObject issueTarget, Multimap documentValues,
String propertyPath) {
if (!documentValues.containsKey(propertyPath)) {
- addIssue(JSONIssueCodes.getMessageForJSON_MISSING_PROPERTY(propertyPath), issueTarget,
- JSONIssueCodes.JSON_MISSING_PROPERTY);
+ addIssue(JSONIssueCodes.JSON_MISSING_PROPERTY.getMessage(propertyPath), issueTarget,
+ JSONIssueCodes.JSON_MISSING_PROPERTY.name());
}
}
@@ -359,9 +359,9 @@ protected void addIssue(String message, EObject source, EStructuralFeature featu
* considered and then the issue severities of the bundle that provides an extension.
*/
private Severity getJSONSeverity(String issueCode) {
- final Severity jsonSeverity = JSONIssueCodes.getDefaultSeverity(issueCode);
- if (null != jsonSeverity) {
- return jsonSeverity;
+ Severity severity = JSONIssueCodes.getSeverityForName(issueCode);
+ if (severity != null) {
+ return severity;
}
return getIssueSeverities(getContext(), getCurrentObject()).getSeverity(issueCode);
}
@@ -394,9 +394,9 @@ protected boolean checkIsType(JSONValue value, EClass valueClass, String locatio
return false;
}
if (!valueClass.isInstance(value)) {
- addIssue(JSONIssueCodes.getMessageForJSON_EXPECTED_DIFFERENT_VALUE_TYPE(getJSONValueDescription(valueClass),
+ addIssue(JSONIssueCodes.JSON_EXPECTED_DIFFERENT_VALUE_TYPE.getMessage(getJSONValueDescription(valueClass),
getJSONValueDescription(value), locationClause), value,
- JSONIssueCodes.JSON_EXPECTED_DIFFERENT_VALUE_TYPE);
+ JSONIssueCodes.JSON_EXPECTED_DIFFERENT_VALUE_TYPE.name());
return false;
}
return true;
@@ -410,8 +410,8 @@ protected boolean checkIsType(JSONValue value, EClass valueClass, String locatio
*/
protected boolean checkIsNonEmptyString(JSONStringLiteral stringLiteral, PackageJsonProperties property) {
if (stringLiteral.getValue().isEmpty()) {
- addIssue(JSONIssueCodes.getMessageForJSON_EMPTY_STRING(property.name), stringLiteral,
- JSONIssueCodes.JSON_EMPTY_STRING);
+ addIssue(JSONIssueCodes.JSON_EMPTY_STRING.getMessage(property.name), stringLiteral,
+ JSONIssueCodes.JSON_EMPTY_STRING.name());
return false;
}
return true;
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/packagejson/N4JSProjectSetupJsonValidatorExtension.xtend b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/packagejson/N4JSProjectSetupJsonValidatorExtension.xtend
index 6454794096..2bc35b0df2 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/packagejson/N4JSProjectSetupJsonValidatorExtension.xtend
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/packagejson/N4JSProjectSetupJsonValidatorExtension.xtend
@@ -33,6 +33,7 @@ import java.util.Stack
import org.apache.log4j.Logger
import org.eclipse.emf.common.util.URI
import org.eclipse.emf.ecore.EObject
+import org.eclipse.emf.ecore.EStructuralFeature
import org.eclipse.emf.ecore.resource.Resource
import org.eclipse.n4js.N4JSGlobals
import org.eclipse.n4js.json.JSON.JSONArray
@@ -64,7 +65,7 @@ import org.eclipse.n4js.utils.ModuleFilterUtils
import org.eclipse.n4js.utils.NodeModulesDiscoveryHelper
import org.eclipse.n4js.utils.ProjectDescriptionLoader
import org.eclipse.n4js.utils.Strings
-import org.eclipse.n4js.validation.IssueCodes
+import org.eclipse.n4js.validation.IssueItem
import org.eclipse.n4js.validation.N4JSElementKeywordProvider
import org.eclipse.n4js.validation.helper.SourceContainerAwareDependencyProvider
import org.eclipse.n4js.workspace.N4JSProjectConfigSnapshot
@@ -304,22 +305,19 @@ public class N4JSProjectSetupJsonValidatorExtension extends AbstractPackageJSONV
if (keyS.size > 1) {
// case a: multiple dependencies clash
- val issMsg = if (polyFilledMemberAsStrings.size == 1) {
- IssueCodes.getMessageForPOLY_CLASH_IN_RUNTIMEDEPENDENCY(libsString, userPresentablePolyFills)
+ val IssueItem issueItem = if (polyFilledMemberAsStrings.size == 1) {
+ POLY_CLASH_IN_RUNTIMEDEPENDENCY.toIssueItem(libsString, userPresentablePolyFills)
} else {
- IssueCodes.
- getMessageForPOLY_CLASH_IN_RUNTIMEDEPENDENCY_MULTI(libsString, userPresentablePolyFills)
+ POLY_CLASH_IN_RUNTIMEDEPENDENCY_MULTI.toIssueItem(libsString, userPresentablePolyFills)
}
// add Issue for each
keyS.forEach [
- addIssue(issMsg, it, IssueCodes.POLY_CLASH_IN_RUNTIMEDEPENDENCY)
+ addIssue(it, issueItem)
]
} else {
// case b: not error-free:
- val issMsg = IssueCodes.
- getMessageForPOLY_ERROR_IN_RUNTIMEDEPENDENCY(libsString, userPresentablePolyFills)
- addIssue(issMsg, keyS.head, IssueCodes.POLY_ERROR_IN_RUNTIMEDEPENDENCY)
+ addIssue(keyS.head, POLY_ERROR_IN_RUNTIMEDEPENDENCY.toIssueItem(libsString, userPresentablePolyFills));
}
@@ -376,8 +374,7 @@ public class N4JSProjectSetupJsonValidatorExtension extends AbstractPackageJSONV
for (projectCycleName : projectCycle) {
if (projectCycleName.endsWith("/" + dependencyPair.name)) {
val dependencyCycle = Strings.join(", ", projectCycle);
- val message = getMessageForPROJECT_DEPENDENCY_CYCLE(dependencyCycle);
- addIssue(message, dependencyPair, JSONPackage.Literals.NAME_VALUE_PAIR__NAME, PROJECT_DEPENDENCY_CYCLE);
+ addIssue(dependencyPair, JSONPackage.Literals.NAME_VALUE_PAIR__NAME, PROJECT_DEPENDENCY_CYCLE.toIssueItem(dependencyCycle));
}
}
}
@@ -415,7 +412,7 @@ public class N4JSProjectSetupJsonValidatorExtension extends AbstractPackageJSONV
}
if(!anyDependsOnTestLibrary(wc, #[project])){
- addIssuePreferred(#[], getMessageForSRCTEST_NO_TESTLIB_DEP(N4JSGlobals.MANGELHAFT), SRCTEST_NO_TESTLIB_DEP);
+ addIssuePreferred(#[], SRCTEST_NO_TESTLIB_DEP.toIssueItem(N4JSGlobals.MANGELHAFT));
}
}
@@ -482,9 +479,8 @@ public class N4JSProjectSetupJsonValidatorExtension extends AbstractPackageJSONV
return allProjects.containsKey(projectId) && refProjectType != allProjects.get(projectId)?.type
]) {
addIssue(
- messageForMISMATCHING_TESTED_PROJECT_TYPES,
testedProjectsValue,
- MISMATCHING_TESTED_PROJECT_TYPES);
+ MISMATCHING_TESTED_PROJECT_TYPES.toIssueItem());
}
}
}
@@ -515,9 +511,7 @@ public class N4JSProjectSetupJsonValidatorExtension extends AbstractPackageJSONV
val dependencyProjectName = pcs.getProjectIdForPackageName(pair.name);
val actualImplementationId = allProjects.get(dependencyProjectName)?.implementationId;
if (actualImplementationId !== null && actualImplementationId != expectedImplementationId) {
- val message = getMessageForMISMATCHING_IMPLEMENTATION_ID(expectedImplementationId,
- pair.name, actualImplementationId);
- addIssue(message, pair, MISMATCHING_IMPLEMENTATION_ID);
+ addIssue(pair, MISMATCHING_IMPLEMENTATION_ID.toIssueItem(expectedImplementationId, pair.name, actualImplementationId));
}
];
}
@@ -564,11 +558,9 @@ public class N4JSProjectSetupJsonValidatorExtension extends AbstractPackageJSONV
val workspaceDependency = actualDirectDependencies.findFirst[!external];
if (null !== workspaceDependency) {
val workspaceDependencyId = workspaceDependency.name;
- val message = getMessageForEXTERNAL_PROJECT_REFERENCES_WORKSPACE_PROJECT(actualId, workspaceDependencyId);
addIssue(
- message,
dependenciesValue,
- EXTERNAL_PROJECT_REFERENCES_WORKSPACE_PROJECT
+ EXTERNAL_PROJECT_REFERENCES_WORKSPACE_PROJECT.toIssueItem(actualId, workspaceDependencyId)
);
return;
}
@@ -616,15 +608,13 @@ public class N4JSProjectSetupJsonValidatorExtension extends AbstractPackageJSONV
val matchingDevDep = devDependencies.findFirst[name == N4JSGlobals.N4JS_RUNTIME.rawName];
if (matchingDevDep === null) {
// dependency to 'n4js-runtime' missing entirely
- val msg = IssueCodes.getMessageForPKGJ_MISSING_DEPENDENCY_N4JS_RUNTIME;
val projectTypeValue = getDocumentValues(PROJECT_TYPE).head;
if (projectTypeValue !== null) { // should always be non-null, because we check for 3 non-default project types above!
- addIssue(msg, projectTypeValue, IssueCodes.PKGJ_MISSING_DEPENDENCY_N4JS_RUNTIME);
+ addIssue(projectTypeValue, PKGJ_MISSING_DEPENDENCY_N4JS_RUNTIME.toIssueItem());
}
} else {
// dependency to 'n4js-runtime' defined in wrong section (under 'devDependencies' instead of 'dependencies')
- val msg = IssueCodes.getMessageForPKGJ_WRONG_DEPENDENCY_N4JS_RUNTIME;
- addIssue(msg, matchingDevDep, IssueCodes.PKGJ_WRONG_DEPENDENCY_N4JS_RUNTIME);
+ addIssue(matchingDevDep, PKGJ_WRONG_DEPENDENCY_N4JS_RUNTIME.toIssueItem());
}
}
}
@@ -663,8 +653,7 @@ public class N4JSProjectSetupJsonValidatorExtension extends AbstractPackageJSONV
for (projectPair : libraryDependenciesWithImplId) {
val reference = projectPair.key;
- addIssue(IssueCodes.getMessageForINVALID_API_PROJECT_DEPENDENCY(reference.referencedProjectName), reference.astRepresentation,
- IssueCodes.INVALID_API_PROJECT_DEPENDENCY);
+ addIssue(reference.astRepresentation, INVALID_API_PROJECT_DEPENDENCY.toIssueItem(reference.referencedProjectName));
}
}
@@ -740,8 +729,7 @@ public class N4JSProjectSetupJsonValidatorExtension extends AbstractPackageJSONV
// make sure an implementationId has been declared
val JSONValue implementationIdValue = getSingleDocumentValue(IMPLEMENTATION_ID);
if (!references.isEmpty() && implementationIdValue === null ) {
- addIssue(IssueCodes.getMessageForPKGJ_APIIMPL_MISSING_IMPL_ID(), implementedProjectsValue.eContainer,
- JSONPackage.Literals.NAME_VALUE_PAIR__NAME, IssueCodes.PKGJ_APIIMPL_MISSING_IMPL_ID);
+ addIssue(implementedProjectsValue.eContainer, JSONPackage.Literals.NAME_VALUE_PAIR__NAME, PKGJ_APIIMPL_MISSING_IMPL_ID.toIssueItem());
}
}
}
@@ -797,18 +785,16 @@ public class N4JSProjectSetupJsonValidatorExtension extends AbstractPackageJSONV
if (filterSpecifier?.getSpecifierWithWildcard !== null) {
if (filterSpecifier.getSpecifierWithWildcard.contains(wrongWildcardPattern)) {
addIssue(
- getMessageForPKGJ_INVALID_WILDCARD(wrongWildcardPattern),
filterSpecifierTraceable.astElement,
- PKGJ_INVALID_WILDCARD
+ PKGJ_INVALID_WILDCARD.toIssueItem(wrongWildcardPattern)
)
return false
}
val wrongRelativeNavigation = "../"
if (filterSpecifier.getSpecifierWithWildcard.contains(wrongRelativeNavigation)) {
addIssue(
- getMessageForPKGJ_NO_RELATIVE_NAVIGATION,
filterSpecifierTraceable.astElement,
- PKGJ_NO_RELATIVE_NAVIGATION
+ PKGJ_NO_RELATIVE_NAVIGATION.toIssueItem()
)
return false
}
@@ -829,8 +815,7 @@ public class N4JSProjectSetupJsonValidatorExtension extends AbstractPackageJSONV
};
if ((moduleSpecifierWithWildcardFromAST !== null && moduleSpecifierWithWildcardFromAST.empty)
|| (sourceContainerFromAST !== null && sourceContainerFromAST.empty)) {
- addIssue(IssueCodes.getMessageForPKGJ_INVALID_MODULE_FILTER_SPECIFIER_EMPTY(),
- filterSpecifierTraceable.astElement, IssueCodes.PKGJ_INVALID_MODULE_FILTER_SPECIFIER_EMPTY);
+ addIssue(filterSpecifierTraceable.astElement, PKGJ_INVALID_MODULE_FILTER_SPECIFIER_EMPTY.toIssueItem());
return false;
}
@@ -855,8 +840,7 @@ public class N4JSProjectSetupJsonValidatorExtension extends AbstractPackageJSONV
.filter[e | e.value == false].map[e | e.key]
for (ASTTraceable filterSpecifier : unmatchedSpecifiers) {
- val msg = getMessageForPKGJ_MODULE_FILTER_DOES_NOT_MATCH(filterSpecifier.element.getSpecifierWithWildcard);
- addIssue(msg, filterSpecifier.astElement, PKGJ_MODULE_FILTER_DOES_NOT_MATCH);
+ addIssue(filterSpecifier.astElement, PKGJ_MODULE_FILTER_DOES_NOT_MATCH.toIssueItem(filterSpecifier.element.getSpecifierWithWildcard));
}
}
@@ -927,8 +911,7 @@ public class N4JSProjectSetupJsonValidatorExtension extends AbstractPackageJSONV
private def addNoValidationForN4JSFilesIssue(ASTTraceable filterSpecifier) {
val moduleFilterType = (filterSpecifier.astElement.eContainer.eContainer as NameValuePair).name;
- addIssue(getMessageForPKGJ_FILTER_NO_N4JS_MATCH(moduleFilterType), filterSpecifier.astElement,
- PKGJ_FILTER_NO_N4JS_MATCH);
+ addIssue(filterSpecifier.astElement, PKGJ_FILTER_NO_N4JS_MATCH.toIssueItem(moduleFilterType));
}
/**
@@ -958,8 +941,7 @@ public class N4JSProjectSetupJsonValidatorExtension extends AbstractPackageJSONV
// check whether the feature can be used with the current project type
if (!supportedTypesPredicate.apply(type)) {
- addIssue(getMessageForINVALID_FEATURE_FOR_PROJECT_TYPE(featureDescription.toFirstUpper, type.label),
- issueTarget, INVALID_FEATURE_FOR_PROJECT_TYPE);
+ addIssue(issueTarget, INVALID_FEATURE_FOR_PROJECT_TYPE.toIssueItem(featureDescription.toFirstUpper, type.label));
return false;
}
@@ -1157,8 +1139,7 @@ public class N4JSProjectSetupJsonValidatorExtension extends AbstractPackageJSONV
// check for empty project ID
if (refId === null || refId.isEmpty) {
- addIssue(IssueCodes.getMessageForPKGJ_EMPTY_PROJECT_REFERENCE(), ref.astRepresentation,
- IssueCodes.PKGJ_EMPTY_PROJECT_REFERENCE)
+ addIssue(ref.astRepresentation, PKGJ_EMPTY_PROJECT_REFERENCE.toIssueItem())
return;
}
@@ -1168,9 +1149,12 @@ public class N4JSProjectSetupJsonValidatorExtension extends AbstractPackageJSONV
// type cannot be resolved from index, hence project does not exist in workspace.
if (null === project || null === project.type) {
if (!currentProject.isExternal) {
- val msg = getMessageForNON_EXISTING_PROJECT(refName);
val packageVersion = if (ref.npmVersion === null) "" else ref.npmVersion.toString;
- addIssue(msg, ref.astRepresentation, null, NON_EXISTING_PROJECT, refName, packageVersion);
+ val IssueItem issueItem = NON_EXISTING_PROJECT.toIssueItemWithData(
+ List.of(refName, packageVersion),
+ refName
+ );
+ addIssue(ref.astRepresentation, null, issueItem);
}
return;
} else {
@@ -1208,9 +1192,8 @@ public class N4JSProjectSetupJsonValidatorExtension extends AbstractPackageJSONV
val nameOfProjectDefinedByReferencedProject = referencedProject?.definesPackage?.toString;
if (nameOfProjectDefinedByReferencedProject !== null) {
if (!allReferencedProjectNames.contains(nameOfProjectDefinedByReferencedProject)) {
- val msg = IssueCodes.getMessageForPKGJ_IMPL_PROJECT_IS_MISSING_FOR_TYPE_DEF(
- nameOfProjectDefinedByReferencedProject, ref.referencedProjectName);
- addIssue(msg, ref.astRepresentation, IssueCodes.PKGJ_IMPL_PROJECT_IS_MISSING_FOR_TYPE_DEF);
+ val IssueItem issueItem = PKGJ_IMPL_PROJECT_IS_MISSING_FOR_TYPE_DEF.toIssueItem(nameOfProjectDefinedByReferencedProject, ref.referencedProjectName);
+ addIssue(ref.astRepresentation, issueItem);
}
}
}
@@ -1251,8 +1234,7 @@ public class N4JSProjectSetupJsonValidatorExtension extends AbstractPackageJSONV
references.forEach[reference |
if (!declaredDependencies.containsKey(reference.referencedProjectName)) {
- addIssue(IssueCodes.getMessageForPKGJ_PROJECT_REFERENCE_MUST_BE_DEPENDENCY(reference.referencedProjectName, sectionLabel),
- reference.astRepresentation, IssueCodes.PKGJ_PROJECT_REFERENCE_MUST_BE_DEPENDENCY);
+ addIssue(reference.astRepresentation, PKGJ_PROJECT_REFERENCE_MUST_BE_DEPENDENCY.toIssueItem(reference.referencedProjectName, sectionLabel));
}
]
}
@@ -1283,8 +1265,11 @@ public class N4JSProjectSetupJsonValidatorExtension extends AbstractPackageJSONV
val desiredStr = SemverSerializer.serialize(desiredVersion);
val availableStr = SemverSerializer.serialize(availableVersion);
- val msg = getMessageForNO_MATCHING_VERSION(ref.referencedProjectName, desiredStr, availableStr);
- addIssue(msg, ref.astRepresentation, null, NO_MATCHING_VERSION, ref.referencedProjectId, desiredVersion.toString);
+ val IssueItem issueItem = NO_MATCHING_VERSION.toIssueItemWithData(
+ List.of(ref.referencedProjectId, desiredVersion.toString),
+ ref.referencedProjectName, desiredStr, availableStr
+ );
+ addIssue(ref.astRepresentation, null, issueItem);
}
/**
@@ -1328,16 +1313,15 @@ public class N4JSProjectSetupJsonValidatorExtension extends AbstractPackageJSONV
}
private def addProjectReferencesItselfIssue(EObject target) {
- addIssue(messageForPROJECT_REFERENCES_ITSELF, target, PROJECT_REFERENCES_ITSELF);
+ addIssue(target, PROJECT_REFERENCES_ITSELF.toIssueItem());
}
private def addInvalidProjectTypeIssue(EObject target, String projectName, ProjectType type, String sectionLabel) {
- addIssue(getMessageForINVALID_PROJECT_TYPE_REF(projectName, type.label, sectionLabel),
- target, INVALID_PROJECT_TYPE_REF);
+ addIssue(target, INVALID_PROJECT_TYPE_REF.toIssueItem(projectName, type.label, sectionLabel));
}
private def addDuplicateProjectReferenceIssue(EObject target, String name) {
- addIssue(getMessageForDUPLICATE_PROJECT_REF(name), target, DUPLICATE_PROJECT_REF);
+ addIssue(target, DUPLICATE_PROJECT_REF.toIssueItem(name));
}
/**
@@ -1348,21 +1332,21 @@ public class N4JSProjectSetupJsonValidatorExtension extends AbstractPackageJSONV
*
* If there is no {@code name} property, adds an issue to the whole document (see {@link #getDocument()}).
*/
- private def void addIssuePreferred(Iterable extends EObject> preferredTargets, String message, String issueCode) {
+ private def void addIssuePreferred(Iterable extends EObject> preferredTargets, IssueItem issueItem) {
// add issue to preferred targets
if (!preferredTargets.filterNull.empty) {
preferredTargets.filterNull
- .forEach[t | addIssue(message, t, issueCode); ]
+ .forEach[t | addIssue(t, issueItem); ]
return;
}
// fall back to property 'name'
val nameValue = getSingleDocumentValue(NAME);
if (nameValue !== null) {
- addIssue(message, nameValue, issueCode);
+ addIssue(nameValue, issueItem);
return;
}
// finally fall back to document
- addIssue(message, document, issueCode)
+ addIssue(document, issueItem)
}
/**
@@ -1384,4 +1368,13 @@ public class N4JSProjectSetupJsonValidatorExtension extends AbstractPackageJSONV
private def Predicate forN4jsProjects(Predicate predicate) {
return [pcs | predicate.apply(pcs.type)];
}
+
+
+ def private void addIssue(EObject source, EStructuralFeature feature, IssueItem issueItem) {
+ super.addIssue(issueItem.message, source, feature, issueItem.ID, issueItem.data);
+ }
+
+ def private void addIssue(EObject source, IssueItem issueItem) {
+ super.addIssue(issueItem.message, source, null, issueItem.ID, issueItem.data);
+ }
}
diff --git a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/packagejson/PackageJsonValidatorExtension.java b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/packagejson/PackageJsonValidatorExtension.java
index 83aa0d0475..1a39371e4a 100644
--- a/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/packagejson/PackageJsonValidatorExtension.java
+++ b/plugins/org.eclipse.n4js/src/org/eclipse/n4js/validation/validators/packagejson/PackageJsonValidatorExtension.java
@@ -33,6 +33,35 @@
import static org.eclipse.n4js.packagejson.PackageJsonProperties.VENDOR_ID;
import static org.eclipse.n4js.packagejson.PackageJsonProperties.VENDOR_NAME;
import static org.eclipse.n4js.packagejson.PackageJsonProperties.VERSION;
+import static org.eclipse.n4js.validation.IssueCodes.OUTPUT_AND_SOURCES_FOLDER_NESTING;
+import static org.eclipse.n4js.validation.IssueCodes.PKGJ_APIIMPL_MISSING_IMPL_PROJECTS;
+import static org.eclipse.n4js.validation.IssueCodes.PKGJ_APIIMPL_REFLEXIVE;
+import static org.eclipse.n4js.validation.IssueCodes.PKGJ_DEFINES_PROPERTY;
+import static org.eclipse.n4js.validation.IssueCodes.PKGJ_DUPLICATE_MODULE_FILTER_SPECIFIER;
+import static org.eclipse.n4js.validation.IssueCodes.PKGJ_DUPLICATE_SOURCE_CONTAINER;
+import static org.eclipse.n4js.validation.IssueCodes.PKGJ_EMPTY_SOURCE_PATH;
+import static org.eclipse.n4js.validation.IssueCodes.PKGJ_EXPECTED_DIRECTORY_PATH;
+import static org.eclipse.n4js.validation.IssueCodes.PKGJ_INVALID_ABSOLUTE_PATH;
+import static org.eclipse.n4js.validation.IssueCodes.PKGJ_INVALID_MODULE_FILTER_SPECIFIER;
+import static org.eclipse.n4js.validation.IssueCodes.PKGJ_INVALID_MODULE_FILTER_TYPE;
+import static org.eclipse.n4js.validation.IssueCodes.PKGJ_INVALID_PATH;
+import static org.eclipse.n4js.validation.IssueCodes.PKGJ_INVALID_PROJECT_NAME;
+import static org.eclipse.n4js.validation.IssueCodes.PKGJ_INVALID_PROJECT_TYPE;
+import static org.eclipse.n4js.validation.IssueCodes.PKGJ_INVALID_SCOPE_NAME;
+import static org.eclipse.n4js.validation.IssueCodes.PKGJ_INVALID_SOURCE_CONTAINER_TYPE;
+import static org.eclipse.n4js.validation.IssueCodes.PKGJ_INVALID_VERSION_NUMBER;
+import static org.eclipse.n4js.validation.IssueCodes.PKGJ_NESTED_SOURCE_CONTAINER;
+import static org.eclipse.n4js.validation.IssueCodes.PKGJ_NON_EXISTING_MAIN_MODULE;
+import static org.eclipse.n4js.validation.IssueCodes.PKGJ_NON_EXISTING_SOURCE_PATH;
+import static org.eclipse.n4js.validation.IssueCodes.PKGJ_PACKAGE_NAME_MISMATCH;
+import static org.eclipse.n4js.validation.IssueCodes.PKGJ_PROJECT_TYPE_MANDATORY_OUTPUT_AND_SOURCES;
+import static org.eclipse.n4js.validation.IssueCodes.PKGJ_PROPERTY_UNKNOWN;
+import static org.eclipse.n4js.validation.IssueCodes.PKGJ_REWRITE_MODULE_SPECIFIERS__EMPTY_SPECIFIER;
+import static org.eclipse.n4js.validation.IssueCodes.PKGJ_REWRITE_MODULE_SPECIFIERS__INVALID_VALUE;
+import static org.eclipse.n4js.validation.IssueCodes.PKGJ_SCOPE_NAME_MISMATCH;
+import static org.eclipse.n4js.validation.IssueCodes.PKGJ_SEMVER_ERROR;
+import static org.eclipse.n4js.validation.IssueCodes.PKGJ_SEMVER_WARNING;
+import static org.eclipse.n4js.validation.IssueCodes.PKGJ_SRC_IN_FILTER_IS_NO_DECLARED_SOURCE;
import java.io.File;
import java.nio.file.InvalidPathException;
@@ -52,6 +81,7 @@
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.n4js.N4JSGlobals;
import org.eclipse.n4js.json.JSON.JSONArray;
@@ -81,6 +111,7 @@
import org.eclipse.n4js.utils.ProjectDescriptionUtils.ProjectNameInfo;
import org.eclipse.n4js.utils.io.FileUtils;
import org.eclipse.n4js.validation.IssueCodes;
+import org.eclipse.n4js.validation.IssueItem;
import org.eclipse.n4js.workspace.N4JSProjectConfigSnapshot;
import org.eclipse.n4js.workspace.WorkspaceAccess;
import org.eclipse.n4js.workspace.locations.FileURI;
@@ -150,14 +181,12 @@ public void checkName(JSONValue projectNameValue) {
// make sure the name conforms to the IDENTIFIER_PATTERN
if (!ProjectDescriptionUtils.isValidPlainPackageName(projectNameWithoutScope)) {
- addIssue(IssueCodes.getMessageForPKGJ_INVALID_PROJECT_NAME(projectNameWithoutScope),
- projectNameValue, IssueCodes.PKGJ_INVALID_PROJECT_NAME);
+ addIssue(projectNameValue, PKGJ_INVALID_PROJECT_NAME.toIssueItem(projectNameWithoutScope));
}
if (scopeName != null) {
String scopeNameWithoutPrefix = scopeName.substring(1);
if (!ProjectDescriptionUtils.isValidScopeName(scopeNameWithoutPrefix)) {
- String msg = IssueCodes.getMessageForPKGJ_INVALID_SCOPE_NAME(scopeNameWithoutPrefix);
- addIssue(msg, projectNameValue, IssueCodes.PKGJ_INVALID_SCOPE_NAME);
+ addIssue(projectNameValue, PKGJ_INVALID_SCOPE_NAME.toIssueItem(scopeNameWithoutPrefix));
}
}
@@ -167,16 +196,14 @@ public void checkName(JSONValue projectNameValue) {
// make sure the project name equals the name of the project folder
if (!projectNameWithoutScope.equals(nameInfo.projectFolderName)) {
- String msg = IssueCodes.getMessageForPKGJ_PACKAGE_NAME_MISMATCH(
- projectNameWithoutScope, nameInfo.projectFolderName);
- addIssue(msg, projectNameLiteral, IssueCodes.PKGJ_PACKAGE_NAME_MISMATCH);
+ addIssue(projectNameLiteral,
+ PKGJ_PACKAGE_NAME_MISMATCH.toIssueItem(projectNameWithoutScope, nameInfo.projectFolderName));
}
// make sure the scope name (if any) equals the name of the parent folder
// (i.e. the folder containing the project folder)
if (scopeName != null && !scopeName.equals(nameInfo.parentFolderName)) {
- String msg = IssueCodes.getMessageForPKGJ_SCOPE_NAME_MISMATCH(scopeName, nameInfo.parentFolderName);
- addIssue(msg, projectNameLiteral, IssueCodes.PKGJ_SCOPE_NAME_MISMATCH);
+ addIssue(projectNameLiteral, PKGJ_SCOPE_NAME_MISMATCH.toIssueItem(scopeName, nameInfo.parentFolderName));
}
}
@@ -198,8 +225,7 @@ public void checkVersion(JSONValue versionValue) {
if (npmVersion != null) {
reason = "Given string is parsed as " + getVersionRequirementType(npmVersion);
}
- String msg = IssueCodes.getMessageForPKGJ_INVALID_VERSION_NUMBER(versionString, reason);
- addIssue(msg, versionValue, IssueCodes.PKGJ_INVALID_VERSION_NUMBER);
+ addIssue(versionValue, PKGJ_INVALID_VERSION_NUMBER.toIssueItem(versionString, reason));
return;
}
@@ -209,8 +235,7 @@ public void checkVersion(JSONValue versionValue) {
if (!simpleVersion.getComparators().isEmpty()) {
String comparator = SemverSerializer.serialize(simpleVersion.getComparators().get(0));
String reason = "Version numbers must not have comparators: '" + comparator + "'";
- String msg = IssueCodes.getMessageForPKGJ_INVALID_VERSION_NUMBER(versionString, reason);
- addIssue(msg, versionValue, IssueCodes.PKGJ_INVALID_VERSION_NUMBER);
+ addIssue(versionValue, PKGJ_INVALID_VERSION_NUMBER.toIssueItem(versionString, reason));
return;
}
}
@@ -226,7 +251,6 @@ private IParseResult validateSemver(JSONValue versionValue, String versionString
INode firstErrorNode = errorIterator.next();
String reason = firstErrorNode.getSyntaxErrorMessage().getMessage();
- String msg = IssueCodes.getMessageForPKGJ_INVALID_VERSION_NUMBER(versionString, reason);
ICompositeNode actualNode = NodeModelUtils.findActualNodeFor(versionValue);
int actOffset = actualNode.getOffset();
@@ -234,32 +258,28 @@ private IParseResult validateSemver(JSONValue versionValue, String versionString
int offset = actOffset + firstErrorNode.getOffset() + 1; // +1 due to " char
int lengthTmp = actLength - firstErrorNode.getOffset() - 2; // -2 due to "" chars
int length = Math.max(1, lengthTmp);
- addIssue(msg, versionValue, offset, length, IssueCodes.PKGJ_INVALID_VERSION_NUMBER);
+ addIssue(versionValue, offset, length, PKGJ_INVALID_VERSION_NUMBER.toIssueItem(versionString, reason));
}
return parseResult;
}
List issues = semverHelper.validate(parseResult);
for (Issue issue : issues) {
- String msg = "";
- String issueCode = IssueCodes.PKGJ_INVALID_VERSION_NUMBER;
+ IssueItem issueItem;
switch (issue.getSeverity()) {
case WARNING:
- msg = IssueCodes.getMessageForPKGJ_SEMVER_WARNING(issue.getMessage());
- issueCode = IssueCodes.PKGJ_SEMVER_WARNING;
- break;
- case ERROR:
- msg = IssueCodes.getMessageForPKGJ_SEMVER_ERROR(issue.getMessage());
- issueCode = IssueCodes.PKGJ_SEMVER_ERROR;
+ issueItem = PKGJ_SEMVER_WARNING.toIssueItem(issue.getMessage());
break;
default:
+ case ERROR:
+ issueItem = PKGJ_SEMVER_ERROR.toIssueItem(issue.getMessage());
break;
}
ICompositeNode actualNode = NodeModelUtils.findActualNodeFor(versionValue);
int offset = actualNode.getOffset() + issue.getOffset() + 1;
int length = issue.getLength();
- addIssue(msg, versionValue, offset, length, issueCode);
+ addIssue(versionValue, offset, length, issueItem);
}
return parseResult;
@@ -348,9 +368,8 @@ public void checkN4JSSection(JSONValue n4jsSection) {
for (NameValuePair nameValuePair : n4jsSectionJO.getNameValuePairs()) {
String nvpName = nameValuePair.getName();
if (!allN4JSPropertyNames.contains(nvpName)) {
- String msg = IssueCodes.getMessageForPKGJ_PROPERTY_UNKNOWN(nvpName);
- addIssue(msg, nameValuePair, JSONPackage.Literals.NAME_VALUE_PAIR__NAME,
- IssueCodes.PKGJ_PROPERTY_UNKNOWN);
+ addIssue(nameValuePair, JSONPackage.Literals.NAME_VALUE_PAIR__NAME,
+ PKGJ_PROPERTY_UNKNOWN.toIssueItem(nvpName));
}
}
}
@@ -371,8 +390,7 @@ public void checkProjectType(JSONValue projectTypeValue) {
// check type can be parsed successfully
if (type == null) {
- addIssue(IssueCodes.getMessageForPKGJ_INVALID_PROJECT_TYPE(projectTypeString),
- projectTypeValue, IssueCodes.PKGJ_INVALID_PROJECT_TYPE);
+ addIssue(projectTypeValue, PKGJ_INVALID_PROJECT_TYPE.toIssueItem(projectTypeString));
return;
}
@@ -384,8 +402,7 @@ public void checkProjectType(JSONValue projectTypeValue) {
if (isDefType != hasDefPck) {
EObject issueObj = propDefinesPck == null ? projectTypeValue : propDefinesPck.eContainer();
String not = propDefinesPck == null ? "" : "not ";
- String msg = IssueCodes.getMessageForPKGJ_DEFINES_PROPERTY(type.toString(), not, "definesPackage");
- addIssue(msg, issueObj, IssueCodes.PKGJ_DEFINES_PROPERTY);
+ addIssue(issueObj, PKGJ_DEFINES_PROPERTY.toIssueItem(type.toString(), not, "definesPackage"));
}
if (isRequiresOutputAndSourceFolder(type)) {
@@ -393,8 +410,8 @@ public void checkProjectType(JSONValue projectTypeValue) {
final boolean hasSources = getSingleDocumentValue(SOURCES) != null;
final boolean hasOutput = getSingleDocumentValue(OUTPUT) != null;
if (!hasSources || !hasOutput) {
- String msg = IssueCodes.getMessageForPKGJ_PROJECT_TYPE_MANDATORY_OUTPUT_AND_SOURCES(projectTypeString);
- addIssue(msg, projectTypeValue, IssueCodes.PKGJ_PROJECT_TYPE_MANDATORY_OUTPUT_AND_SOURCES);
+ addIssue(projectTypeValue,
+ PKGJ_PROJECT_TYPE_MANDATORY_OUTPUT_AND_SOURCES.toIssueItem(projectTypeString));
}
}
}
@@ -487,8 +504,7 @@ public void checkSourceContainers() {
for (JSONStringLiteral duplicate : duplicateGroup) {
final String inClause = createInSourceContainerTypeClause(duplicate, duplicateGroup);
- addIssue(IssueCodes.getMessageForPKGJ_DUPLICATE_SOURCE_CONTAINER(normalizedPath, inClause),
- duplicate, IssueCodes.PKGJ_DUPLICATE_SOURCE_CONTAINER);
+ addIssue(duplicate, PKGJ_DUPLICATE_SOURCE_CONTAINER.toIssueItem(normalizedPath, inClause));
}
}
@@ -535,8 +551,7 @@ private void internalCheckNoNestedSourceContainers(final List
.sorted((s1, s2) -> s1.length() - s2.length()) // sort by ascending length
.collect(Collectors.joining(", "));
- addIssue(IssueCodes.getMessageForPKGJ_NESTED_SOURCE_CONTAINER(containersDescription), path.astElement,
- IssueCodes.PKGJ_NESTED_SOURCE_CONTAINER);
+ addIssue(path.astElement, PKGJ_NESTED_SOURCE_CONTAINER.toIssueItem(containersDescription));
}
}
@@ -544,8 +559,7 @@ private void internalCheckNoNestedSourceContainers(final List
private boolean internalCheckSourceContainerLiteral(JSONStringLiteral containerLiteral) {
// check path for empty strings
if (containerLiteral.getValue().isEmpty()) {
- addIssue(IssueCodes.getMessageForPKGJ_EMPTY_SOURCE_PATH(), containerLiteral,
- IssueCodes.PKGJ_EMPTY_SOURCE_PATH);
+ addIssue(containerLiteral, PKGJ_EMPTY_SOURCE_PATH.toIssueItem());
return false;
}
@@ -567,8 +581,7 @@ public void checkMainModule(JSONValue mainModuleValue) {
if (mainModuleSpecifier.isEmpty() || !isExistingModule(mainModuleLiteral)) {
final String specifierToShow = mainModuleSpecifier.isEmpty() ? "" : mainModuleSpecifier;
- addIssue(IssueCodes.getMessageForPKGJ_NON_EXISTING_MAIN_MODULE(specifierToShow),
- mainModuleLiteral, IssueCodes.PKGJ_NON_EXISTING_MAIN_MODULE);
+ addIssue(mainModuleLiteral, PKGJ_NON_EXISTING_MAIN_MODULE.toIssueItem(specifierToShow));
}
}
@@ -592,9 +605,8 @@ public void checkImplementationId(JSONValue value) {
// at this point we may assume that the implementationId was set
if ((implementedProjectsValue == null || implementedProjectsValue.getElements().isEmpty())) {
// missing implemented projects
- addIssue(IssueCodes.getMessageForPKGJ_APIIMPL_MISSING_IMPL_PROJECTS(),
- implementationId.eContainer(), JSONPackage.Literals.NAME_VALUE_PAIR__NAME,
- IssueCodes.PKGJ_APIIMPL_MISSING_IMPL_PROJECTS);
+ addIssue(implementationId.eContainer(), JSONPackage.Literals.NAME_VALUE_PAIR__NAME,
+ PKGJ_APIIMPL_MISSING_IMPL_PROJECTS.toIssueItem());
}
}
@@ -631,8 +643,7 @@ public void checkImplementedProjects(JSONValue value) {
for (JSONStringLiteral implementedProjectLiteral : implementedProjectLiterals) {
if (implementedProjectLiteral.getValue().equals(declaredProjectNameValue.getValue())) {
// reflexive implementation
- addIssue(IssueCodes.getMessageForPKGJ_APIIMPL_REFLEXIVE(), implementedProjectLiteral,
- IssueCodes.PKGJ_APIIMPL_REFLEXIVE);
+ addIssue(implementedProjectLiteral, PKGJ_APIIMPL_REFLEXIVE.toIssueItem());
}
}
}
@@ -664,15 +675,12 @@ public void checkRewriteModuleSpecifiers(JSONValue value) {
continue; // syntax error
}
if (n.isEmpty()) {
- addIssue(IssueCodes.getMessageForPKGJ_REWRITE_MODULE_SPECIFIERS__EMPTY_SPECIFIER("Source"), nvp,
- JSONPackage.eINSTANCE.getNameValuePair_Name(),
- IssueCodes.PKGJ_REWRITE_MODULE_SPECIFIERS__EMPTY_SPECIFIER);
+ addIssue(nvp, JSONPackage.eINSTANCE.getNameValuePair_Name(),
+ PKGJ_REWRITE_MODULE_SPECIFIERS__EMPTY_SPECIFIER.toIssueItem("Source"));
} else if (!(v instanceof JSONStringLiteral)) {
- addIssue(IssueCodes.getMessageForPKGJ_REWRITE_MODULE_SPECIFIERS__INVALID_VALUE(), v,
- IssueCodes.PKGJ_REWRITE_MODULE_SPECIFIERS__INVALID_VALUE);
+ addIssue(v, PKGJ_REWRITE_MODULE_SPECIFIERS__INVALID_VALUE.toIssueItem());
} else if (((JSONStringLiteral) v).getValue().isEmpty()) {
- addIssue(IssueCodes.getMessageForPKGJ_REWRITE_MODULE_SPECIFIERS__EMPTY_SPECIFIER("Output code"), v,
- IssueCodes.PKGJ_REWRITE_MODULE_SPECIFIERS__EMPTY_SPECIFIER);
+ addIssue(v, PKGJ_REWRITE_MODULE_SPECIFIERS__EMPTY_SPECIFIER.toIssueItem("Output code"));
}
}
}
@@ -735,8 +743,8 @@ private void internalCheckOutput(String outputPath, Optional astOutpu
// forbid output folder for 'definition' projects
final ProjectType projectType = getProjectType();
if (projectType == ProjectType.DEFINITION && astOutputValue.isPresent()) {
- String message = IssueCodes.getMessageForPKGJ_DEFINES_PROPERTY(projectType.name(), "not ", "output");
- addIssue(message, astOutputValue.get().eContainer(), IssueCodes.PKGJ_DEFINES_PROPERTY);
+ addIssue(astOutputValue.get().eContainer(),
+ PKGJ_DEFINES_PROPERTY.toIssueItem(projectType.name(), "not ", "output"));
}
// do not perform check for projects which do not require an output folder
if (!isRequiresOutputAndSourceFolder(projectType)) {
@@ -761,10 +769,8 @@ private void internalCheckOutput(String outputPath, Optional astOutpu
final String containingFolder = ("A " + srcFrgmtName + " folder");
final String nestedFolder = astOutputValue.isPresent() ? "the output folder"
: "the default output folder \"" + OUTPUT.defaultValue + "\"";
- final String message = IssueCodes
- .getMessageForOUTPUT_AND_SOURCES_FOLDER_NESTING(containingFolder, nestedFolder);
-
- addIssue(message, sourceContainerSpecifier, IssueCodes.OUTPUT_AND_SOURCES_FOLDER_NESTING);
+ addIssue(sourceContainerSpecifier,
+ OUTPUT_AND_SOURCES_FOLDER_NESTING.toIssueItem(containingFolder, nestedFolder));
}
// if "output" AST element is available (outputPath is not a default value)
@@ -773,10 +779,8 @@ private void internalCheckOutput(String outputPath, Optional astOutpu
if (isContainedOrEqual(absoluteOutputLocation, absoluteSourceLocation)) {
final String containingFolder = "The output folder";
final String nestedFolder = ("a " + srcFrgmtName + " folder");
- final String message = IssueCodes
- .getMessageForOUTPUT_AND_SOURCES_FOLDER_NESTING(containingFolder, nestedFolder);
-
- addIssue(message, astOutputValue.get(), IssueCodes.OUTPUT_AND_SOURCES_FOLDER_NESTING);
+ addIssue(astOutputValue.get(),
+ OUTPUT_AND_SOURCES_FOLDER_NESTING.toIssueItem(containingFolder, nestedFolder));
}
}
}
@@ -827,10 +831,8 @@ private void internalCheckModuleFilterEntry(NameValuePair moduleFilterPair) {
// make sure the module filter type could be parsed successfully
if (filterType == null) {
- final String message = IssueCodes.getMessageForPKGJ_INVALID_MODULE_FILTER_TYPE(
- moduleFilterPair.getName(), "noValidate");
- addIssue(message, moduleFilterPair, JSONPackage.Literals.NAME_VALUE_PAIR__NAME,
- IssueCodes.PKGJ_INVALID_MODULE_FILTER_TYPE);
+ addIssue(moduleFilterPair, JSONPackage.Literals.NAME_VALUE_PAIR__NAME,
+ PKGJ_INVALID_MODULE_FILTER_TYPE.toIssueItem(moduleFilterPair.getName(), "noValidate"));
}
// check type of RHS
@@ -877,8 +879,7 @@ private void internalCheckModuleFilterEntry(NameValuePair moduleFilterPair) {
.forEach(duplicate -> duplicateFilterSpecifiers.add(duplicate.astRepresentation));
for (JSONValue duplicateFilterSpecifier : duplicateFilterSpecifiers) {
- addIssue(IssueCodes.getMessageForPKGJ_DUPLICATE_MODULE_FILTER_SPECIFIER(),
- duplicateFilterSpecifier, IssueCodes.PKGJ_DUPLICATE_MODULE_FILTER_SPECIFIER);
+ addIssue(duplicateFilterSpecifier, PKGJ_DUPLICATE_MODULE_FILTER_SPECIFIER.toIssueItem());
}
}
@@ -890,9 +891,8 @@ private void checkModuleFilterSpecifier(ValidationModuleFilterSpecifier specifie
// make sure moduleFilterSpecifier.sourceContainerPath has been declared as source container
if (specifier.sourceContainerPath != null &&
!sourceContainerPaths.contains(specifier.sourceContainerPath)) {
- addIssue(
- IssueCodes.getMessageForPKGJ_SRC_IN_FILTER_IS_NO_DECLARED_SOURCE(specifier.sourceContainerPath),
- specifier.astRepresentation, IssueCodes.PKGJ_SRC_IN_FILTER_IS_NO_DECLARED_SOURCE);
+ addIssue(specifier.astRepresentation,
+ PKGJ_SRC_IN_FILTER_IS_NO_DECLARED_SOURCE.toIssueItem(specifier.sourceContainerPath));
}
}
}
@@ -966,8 +966,7 @@ && checkIsType(moduleFilterPair.getValue(), JSONPackage.Literals.JSON_STRING_LIT
}
// otherwise 'value' does not represent a valid module filter specifier
- addIssue(IssueCodes.getMessageForPKGJ_INVALID_MODULE_FILTER_SPECIFIER(), value,
- IssueCodes.PKGJ_INVALID_MODULE_FILTER_SPECIFIER);
+ addIssue(value, PKGJ_INVALID_MODULE_FILTER_SPECIFIER.toIssueItem());
return null;
}
@@ -1009,20 +1008,17 @@ private boolean holdsValidRelativePath(JSONStringLiteral pathLiteral) {
final Path path = Paths.get(pathLiteral.getValue());
// check for path being relative
if (path.isAbsolute()) {
- addIssue(IssueCodes.getMessageForPKGJ_INVALID_ABSOLUTE_PATH(pathLiteral.getValue()),
- pathLiteral, IssueCodes.PKGJ_INVALID_ABSOLUTE_PATH);
+ addIssue(pathLiteral, PKGJ_INVALID_ABSOLUTE_PATH.toIssueItem(pathLiteral.getValue()));
return false;
}
// check for the use of the '*' character (e.g. invalid wildcards)
if (pathLiteral.getValue().contains("*")) {
- addIssue(IssueCodes.getMessageForPKGJ_INVALID_PATH(pathLiteral.getValue()),
- pathLiteral, IssueCodes.PKGJ_INVALID_PATH);
+ addIssue(pathLiteral, PKGJ_INVALID_PATH.toIssueItem(pathLiteral.getValue()));
return false;
}
return true;
} catch (InvalidPathException e) {
- addIssue(IssueCodes.getMessageForPKGJ_INVALID_PATH(pathLiteral.getValue()),
- pathLiteral, IssueCodes.PKGJ_INVALID_PATH);
+ addIssue(pathLiteral, PKGJ_INVALID_PATH.toIssueItem(pathLiteral.getValue()));
return false;
}
}
@@ -1063,14 +1059,12 @@ private boolean holdsExistingDirectoryPath(JSONStringLiteral pathLiteral) {
final File file = new File(baseResourcePath.toString(), relativePath);
if (!file.exists()) {
- addIssue(IssueCodes.getMessageForPKGJ_NON_EXISTING_SOURCE_PATH(relativePath),
- pathLiteral, IssueCodes.PKGJ_NON_EXISTING_SOURCE_PATH);
+ addIssue(pathLiteral, PKGJ_NON_EXISTING_SOURCE_PATH.toIssueItem(relativePath));
return false;
}
if (!file.isDirectory()) {
- addIssue(IssueCodes.getMessageForPKGJ_EXPECTED_DIRECTORY_PATH(relativePath),
- pathLiteral, IssueCodes.PKGJ_EXPECTED_DIRECTORY_PATH);
+ addIssue(pathLiteral, PKGJ_EXPECTED_DIRECTORY_PATH.toIssueItem(relativePath));
return false;
}
@@ -1200,9 +1194,8 @@ private Multimap> doGetSourceContai
// check that sourceContainerType represents a valid source container type
if (containerType == null) {
- addIssue(IssueCodes.getMessageForPKGJ_INVALID_SOURCE_CONTAINER_TYPE(sourceContainerType),
- pair, JSONPackage.Literals.NAME_VALUE_PAIR__NAME,
- IssueCodes.PKGJ_INVALID_SOURCE_CONTAINER_TYPE);
+ addIssue(pair, JSONPackage.Literals.NAME_VALUE_PAIR__NAME,
+ PKGJ_INVALID_SOURCE_CONTAINER_TYPE.toIssueItem(sourceContainerType));
continue;
}
@@ -1245,4 +1238,16 @@ private SourceContainerType getSourceContainerType(JSONStringLiteral containerSp
.eContainer();
return PackageJsonUtils.parseSourceContainerType(containerTypeAssignment.getName());
}
+
+ private void addIssue(EObject source, int offset, int length, IssueItem issueItem) {
+ super.addIssue(issueItem.message, source, offset, length, issueItem.getID(), issueItem.data);
+ }
+
+ private void addIssue(EObject source, EStructuralFeature feature, IssueItem issueItem) {
+ super.addIssue(issueItem.message, source, feature, issueItem.getID(), issueItem.data);
+ }
+
+ private void addIssue(EObject source, IssueItem issueItem) {
+ super.addIssue(issueItem.message, source, null, issueItem.getID(), issueItem.data);
+ }
}
diff --git a/testhelpers/org.eclipse.n4js.ide.tests.helper/src/org/eclipse/n4js/ide/tests/helper/server/AbstractIdeTest.java b/testhelpers/org.eclipse.n4js.ide.tests.helper/src/org/eclipse/n4js/ide/tests/helper/server/AbstractIdeTest.java
index 8e3a8cb022..e685512ae6 100644
--- a/testhelpers/org.eclipse.n4js.ide.tests.helper/src/org/eclipse/n4js/ide/tests/helper/server/AbstractIdeTest.java
+++ b/testhelpers/org.eclipse.n4js.ide.tests.helper/src/org/eclipse/n4js/ide/tests/helper/server/AbstractIdeTest.java
@@ -1573,9 +1573,10 @@ protected Collection getIssuesInFile(FileURI uri) {
*/
protected List getIssuesInFile(FileURI fileURI, boolean withIgnoredIssues) {
Stream issuesInFile = languageClient.getIssues(fileURI).stream();
+ Set ignoredIssueCodes = getIgnoredIssueCodes();
if (!withIgnoredIssues) {
issuesInFile = issuesInFile.filter(
- issue -> issue.getCode() == null || !getIgnoredIssueCodes().contains(issue.getCode().getLeft()));
+ issue -> issue.getCode() == null || !ignoredIssueCodes.contains(issue.getCode().getLeft()));
}
return issuesInFile.collect(Collectors.toList());
}
diff --git a/testhelpers/org.eclipse.n4js.ide.tests.helper/src/org/eclipse/n4js/ide/tests/helper/server/AbstractOrganizeImportsTest.java b/testhelpers/org.eclipse.n4js.ide.tests.helper/src/org/eclipse/n4js/ide/tests/helper/server/AbstractOrganizeImportsTest.java
index 847c21f250..4e5686060c 100644
--- a/testhelpers/org.eclipse.n4js.ide.tests.helper/src/org/eclipse/n4js/ide/tests/helper/server/AbstractOrganizeImportsTest.java
+++ b/testhelpers/org.eclipse.n4js.ide.tests.helper/src/org/eclipse/n4js/ide/tests/helper/server/AbstractOrganizeImportsTest.java
@@ -48,14 +48,14 @@ public abstract class AbstractOrganizeImportsTest extends AbstractStructuredIdeT
private final Set IGNORED_ISSUE_CODES = Sets.newHashSet(Iterables.concat(
N4JSLanguageConstants.DEFAULT_SUPPRESSED_ISSUE_CODES_FOR_TESTS,
Sets.newHashSet(
- IssueCodes.IMP_DUPLICATE,
- IssueCodes.IMP_DUPLICATE_ALIAS,
- IssueCodes.IMP_DUPLICATE_NAMESPACE,
- IssueCodes.IMP_STMT_DUPLICATE_NAMED,
- IssueCodes.IMP_STMT_DUPLICATE_NAMESPACE,
- IssueCodes.IMP_AMBIGUOUS,
- IssueCodes.IMP_UNUSED_IMPORT,
- IssueCodes.IMP_UNRESOLVED)));
+ IssueCodes.IMP_DUPLICATE.name(),
+ IssueCodes.IMP_DUPLICATE_ALIAS.name(),
+ IssueCodes.IMP_DUPLICATE_NAMESPACE.name(),
+ IssueCodes.IMP_STMT_DUPLICATE_NAMED.name(),
+ IssueCodes.IMP_STMT_DUPLICATE_NAMESPACE.name(),
+ IssueCodes.IMP_AMBIGUOUS.name(),
+ IssueCodes.IMP_UNUSED_IMPORT.name(),
+ IssueCodes.IMP_UNRESOLVED.name())));
/** Configuration of organize imports tests. */
protected static class TestOrganizeImportsConfiguration {
diff --git a/testhelpers/org.eclipse.n4js.tests.helper/src/org/eclipse/n4js/N4JSParseHelper.java b/testhelpers/org.eclipse.n4js.tests.helper/src/org/eclipse/n4js/N4JSParseHelper.java
index e932b742d9..e9b166fc60 100644
--- a/testhelpers/org.eclipse.n4js.tests.helper/src/org/eclipse/n4js/N4JSParseHelper.java
+++ b/testhelpers/org.eclipse.n4js.tests.helper/src/org/eclipse/n4js/N4JSParseHelper.java
@@ -25,6 +25,7 @@
import org.eclipse.emf.ecore.resource.Resource.Diagnostic;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.n4js.n4JS.Script;
+import org.eclipse.n4js.validation.IssueCodes;
import org.eclipse.n4js.validation.JavaScriptVariant;
import org.eclipse.xtext.diagnostics.AbstractDiagnostic;
import org.eclipse.xtext.resource.FileExtensionProvider;
@@ -139,7 +140,7 @@ public void assertNoParseErrors(Script script) {
/**
* Like {@link #assertNoParseErrors(Script)}, but ignoring all issues with the given issue codes.
*/
- public void assertNoParseErrors(Script script, Set ignoredIssueCodes) {
+ public void assertNoParseErrors(Script script, Set ignoredIssueCodes) {
List errors = script.eResource().getErrors();
if (ignoredIssueCodes != null) {
errors = FluentIterable.from(errors)
@@ -159,9 +160,14 @@ private void setFileExtension(String ext) {
this.fileExtension = ext;
}
- private String getIssueCode(Diagnostic diagnostic) {
+ private IssueCodes getIssueCode(Diagnostic diagnostic) {
if (diagnostic instanceof AbstractDiagnostic) {
- return ((AbstractDiagnostic) diagnostic).getCode();
+ String codeName = ((AbstractDiagnostic) diagnostic).getCode();
+ try {
+ return IssueCodes.valueOf(codeName);
+ } catch (Exception e) {
+ // ignore
+ }
}
return null;
}
diff --git a/testhelpers/org.eclipse.n4js.tests.helper/src/org/eclipse/n4js/N4JSTestHelper.java b/testhelpers/org.eclipse.n4js.tests.helper/src/org/eclipse/n4js/N4JSTestHelper.java
index 287b94bd49..cc831ddb00 100644
--- a/testhelpers/org.eclipse.n4js.tests.helper/src/org/eclipse/n4js/N4JSTestHelper.java
+++ b/testhelpers/org.eclipse.n4js.tests.helper/src/org/eclipse/n4js/N4JSTestHelper.java
@@ -19,6 +19,7 @@
import org.eclipse.n4js.n4JS.Script;
import org.eclipse.n4js.resource.N4JSResource;
import org.eclipse.n4js.utils.URIUtils;
+import org.eclipse.n4js.validation.IssueCodes;
import org.eclipse.xtext.resource.XtextResourceSet;
import org.eclipse.xtext.xbase.lib.Pair;
import org.junit.Assert;
@@ -59,7 +60,7 @@ public Script parseAndValidateSuccessfully(CharSequence code) {
/**
* Like {@link #parseAndValidateSuccessfully(CharSequence)}, but ignoring issues with the given issue codes.
*/
- public Script parseAndValidateSuccessfullyIgnoring(CharSequence code, String... ignoredIssueCodes) {
+ public Script parseAndValidateSuccessfullyIgnoring(CharSequence code, IssueCodes... ignoredIssueCodes) {
try {
final Script script = parseHelper.parseN4js(code);
parseHelper.assertNoParseErrors(script, new HashSet<>(Arrays.asList(ignoredIssueCodes)));
diff --git a/testhelpers/org.eclipse.n4js.tests.helper/src/org/eclipse/n4js/N4JSValidationTestHelper.java b/testhelpers/org.eclipse.n4js.tests.helper/src/org/eclipse/n4js/N4JSValidationTestHelper.java
index 70c400cf35..8565bc553e 100644
--- a/testhelpers/org.eclipse.n4js.tests.helper/src/org/eclipse/n4js/N4JSValidationTestHelper.java
+++ b/testhelpers/org.eclipse.n4js.tests.helper/src/org/eclipse/n4js/N4JSValidationTestHelper.java
@@ -13,7 +13,6 @@
import static org.junit.Assert.fail;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -28,6 +27,7 @@
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.n4js.n4JS.N4JSPackage;
import org.eclipse.n4js.tests.issues.IssueUtils;
+import org.eclipse.n4js.validation.IssueCodes;
import org.eclipse.xtext.diagnostics.Severity;
import org.eclipse.xtext.testing.validation.ValidationTestHelper;
import org.eclipse.xtext.validation.Issue;
@@ -47,7 +47,7 @@ public class N4JSValidationTestHelper extends ValidationTestHelper {
* @param ignoredIssueCodes
* Issue codes which should be ignored
*/
- public void assertNoIssuesExcept(EObject model, String... ignoredIssueCodes) {
+ public void assertNoIssuesExcept(EObject model, IssueCodes... ignoredIssueCodes) {
Resource resource = model.eResource();
List issues = validate(resource);
issues = removeIssuesWithCode(issues, false, ignoredIssueCodes);
@@ -64,7 +64,7 @@ public void assertNoIssuesExcept(EObject model, String... ignoredIssueCodes) {
* @param ignoredIssueCodes
* Issue codes which should be ignored
*/
- public void assertNoErrorsExcept(EObject model, String... ignoredIssueCodes) {
+ public void assertNoErrorsExcept(EObject model, IssueCodes... ignoredIssueCodes) {
Resource resource = model.eResource();
List issues = validate(resource);
issues = removeIssuesWithCode(issues, true, ignoredIssueCodes);
@@ -83,7 +83,7 @@ public void assertNoErrorsExcept(EObject model, String... ignoredIssueCodes) {
* @param expectedErrors
* The expected errors.
*/
- public void assertErrorsExcept(EObject model, String[] ignoredIssueCodes, String... expectedErrors) {
+ public void assertErrorsExcept(EObject model, IssueCodes[] ignoredIssueCodes, String... expectedErrors) {
if (expectedErrors.length == 0) {
// use above method for better error messages:
assertNoErrorsExcept(model, ignoredIssueCodes);
@@ -102,8 +102,11 @@ public void assertErrorsExcept(EObject model, String[] ignoredIssueCodes, String
Assert.assertEquals("Actual errors differ from expected errors", expectedErrorsSorted, actualErrorsSorted);
}
- private List removeIssuesWithCode(List issues, boolean removeWarningsAndInfos, String... codes) {
- Set excludedIssueCodes = new HashSet<>(Arrays.asList(codes));
+ private List removeIssuesWithCode(List issues, boolean removeWarningsAndInfos, IssueCodes... codes) {
+ Set excludedIssueCodes = new HashSet<>();
+ for (IssueCodes issueCode : codes) {
+ excludedIssueCodes.add(issueCode.name());
+ }
return issues.stream()
.filter(issue -> (!removeWarningsAndInfos || issue.getSeverity() == Severity.ERROR)
&& !excludedIssueCodes.contains(issue.getCode()))
diff --git a/tests/org.eclipse.n4js.bugreports.tests/xt-pending/IDEBUG_0267_thisTypeInFunctionTEofFields.n4js.xt b/tests/org.eclipse.n4js.bugreports.tests/xt-pending/IDEBUG_0267_thisTypeInFunctionTEofFields.n4js.xt
index 9a50da5e57..e039119382 100644
--- a/tests/org.eclipse.n4js.bugreports.tests/xt-pending/IDEBUG_0267_thisTypeInFunctionTEofFields.n4js.xt
+++ b/tests/org.eclipse.n4js.bugreports.tests/xt-pending/IDEBUG_0267_thisTypeInFunctionTEofFields.n4js.xt
@@ -14,6 +14,6 @@
class A {}
class Foo {
- // XPECT FIXME noerrors --> "The this type isn't allowed on this place. You can only use it as return type of instance methods or structurally on use site in the constructor."
+ // XPECT FIXME noerrors --> "The 'this' type isn't allowed on this place. You can only use it as return type of instance methods or structurally on use site in the constructor."
a: A<{function(this): void}>;
}
diff --git a/tests/org.eclipse.n4js.bugreports.tests/xt-tests/GHOLD_0021_InstanceOfPrimitiveTypes.n4js.xt b/tests/org.eclipse.n4js.bugreports.tests/xt-tests/GHOLD_0021_InstanceOfPrimitiveTypes.n4js.xt
index bd6bdc5d42..a6705abab1 100644
--- a/tests/org.eclipse.n4js.bugreports.tests/xt-tests/GHOLD_0021_InstanceOfPrimitiveTypes.n4js.xt
+++ b/tests/org.eclipse.n4js.bugreports.tests/xt-tests/GHOLD_0021_InstanceOfPrimitiveTypes.n4js.xt
@@ -20,16 +20,16 @@ var a = new A();
// Use instanceof with class on rhs XPECT noerrors -->
a instanceof A;
-// Use instanceof with int on rhs XPECT errors --> "instanceof cannot be used with primitive types." at "int"
+// Use instanceof with int on rhs XPECT errors --> "'instanceof' cannot be used with primitive types." at "int"
a instanceof int;
-// Use instanceof with number on rhs XPECT errors --> "instanceof cannot be used with primitive types." at "number"
+// Use instanceof with number on rhs XPECT errors --> "'instanceof' cannot be used with primitive types." at "number"
a instanceof number;
-// Use instanceof with string on rhs XPECT errors --> "instanceof cannot be used with primitive types." at "string"
+// Use instanceof with string on rhs XPECT errors --> "'instanceof' cannot be used with primitive types." at "string"
a instanceof string;
-// Use instanceof with nested paranthesis structure on rhs XPECT errors --> "instanceof cannot be used with primitive types." at "string"
+// Use instanceof with nested paranthesis structure on rhs XPECT errors --> "'instanceof' cannot be used with primitive types." at "string"
a instanceof (((string)));
diff --git a/tests/org.eclipse.n4js.bugreports.tests/xt-tests/IDEBUG_0279_functionTypeBounds.n4js.xt b/tests/org.eclipse.n4js.bugreports.tests/xt-tests/IDEBUG_0279_functionTypeBounds.n4js.xt
index be91c56d61..71a33474dc 100644
--- a/tests/org.eclipse.n4js.bugreports.tests/xt-tests/IDEBUG_0279_functionTypeBounds.n4js.xt
+++ b/tests/org.eclipse.n4js.bugreports.tests/xt-tests/IDEBUG_0279_functionTypeBounds.n4js.xt
@@ -45,7 +45,7 @@ var g : G extends A>;
g.ptr(a);
// XPECT errors --> "any is not a subtype of ? extends A." at "top"
g.ptr(top);
-// no errors, but a warning XPECT warnings --> "The type of this expression is undefined, so it will never evaluate to a value other than undefined." at "bot"
+// no errors, but a warning XPECT warnings --> "The type of this expression is 'undefined', so it will never evaluate to a value other than 'undefined'." at "bot"
g.ptr(bot);
// XPECT noerrors -->
diff --git a/tests/org.eclipse.n4js.expectmatrix.tests/xt-tests/matrix/Class_x_This/01_in_methods.n4js.xt b/tests/org.eclipse.n4js.expectmatrix.tests/xt-tests/matrix/Class_x_This/01_in_methods.n4js.xt
index 5bee9858da..2c9badc555 100644
--- a/tests/org.eclipse.n4js.expectmatrix.tests/xt-tests/matrix/Class_x_This/01_in_methods.n4js.xt
+++ b/tests/org.eclipse.n4js.expectmatrix.tests/xt-tests/matrix/Class_x_This/01_in_methods.n4js.xt
@@ -16,13 +16,13 @@
/////////////////////////
class A {
- // cannot use this as field type XPECT errors --> "The this type isn't allowed on this place. (Please refer to Spec for valid use cases.)" at "this"
+ // cannot use this as field type XPECT errors --> "The 'this' type isn't allowed on this place. (Please refer to Spec for valid use cases.)" at "this"
t : this;
// this as return type XPECT noerrors -->
f() : this { return this; }
- // cannot use this in static methods X!PECT errors --> "The this type isn't allowed on this place. You can only use it as return type of instance methods or structurally on use site in the constructor." at "this"
+ // cannot use this in static methods X!PECT errors --> "The 'this' type isn't allowed on this place. You can only use it as return type of instance methods or structurally on use site in the constructor." at "this"
// this in static methods only for n4jsd-files, this in body not instance-type but class type.
// XPECT errors --> "constructor{this[A]} is not a subtype of this[A]." at "this"
static fStatic() : this { return this; }
diff --git a/tests/org.eclipse.n4js.expectmatrix.tests/xt-tests/matrix/Role_x_This/01_in_methods.n4js.xt b/tests/org.eclipse.n4js.expectmatrix.tests/xt-tests/matrix/Role_x_This/01_in_methods.n4js.xt
index 52935d19f7..b8cdd51c79 100644
--- a/tests/org.eclipse.n4js.expectmatrix.tests/xt-tests/matrix/Role_x_This/01_in_methods.n4js.xt
+++ b/tests/org.eclipse.n4js.expectmatrix.tests/xt-tests/matrix/Role_x_This/01_in_methods.n4js.xt
@@ -16,7 +16,7 @@
/////////////////////////
interface A {
- // cannot use this as field type XPECT errors --> "The this type isn't allowed on this place. (Please refer to Spec for valid use cases.)" at "this"
+ // cannot use this as field type XPECT errors --> "The 'this' type isn't allowed on this place. (Please refer to Spec for valid use cases.)" at "this"
t : this;
// this as return type XPECT noerrors -->
diff --git a/tests/org.eclipse.n4js.ide.tests.helper.tests/src/org/eclipse/n4js/ide/tests/helper/server/xt/tests/IssueConfigurationTest.java b/tests/org.eclipse.n4js.ide.tests.helper.tests/src/org/eclipse/n4js/ide/tests/helper/server/xt/tests/IssueConfigurationTest.java
index 4d3b1e0793..79ff309ba6 100644
--- a/tests/org.eclipse.n4js.ide.tests.helper.tests/src/org/eclipse/n4js/ide/tests/helper/server/xt/tests/IssueConfigurationTest.java
+++ b/tests/org.eclipse.n4js.ide.tests.helper.tests/src/org/eclipse/n4js/ide/tests/helper/server/xt/tests/IssueConfigurationTest.java
@@ -30,10 +30,10 @@ public void test() throws Exception {
// The test file IssuesConfiguration.n4js.xt is based on the assumption that certain issues are suppressed in
// all tests by default. Make sure this test fails if the default suppression no longer meets this expectation:
Set suppressed = N4JSLanguageConstants.DEFAULT_SUPPRESSED_ISSUE_CODES_FOR_TESTS;
- assertTrue(suppressed.contains(IssueCodes.DFG_NULL_DEREFERENCE));
- assertTrue(suppressed.contains(IssueCodes.CFG_LOCAL_VAR_UNUSED));
- assertFalse(suppressed.contains(IssueCodes.CLF_NAME_DOES_NOT_START_UPPERCASE));
- assertFalse(suppressed.contains(IssueCodes.CLF_NAME_DOES_NOT_START_LOWERCASE));
+ assertTrue(suppressed.contains(IssueCodes.DFG_NULL_DEREFERENCE.name()));
+ assertTrue(suppressed.contains(IssueCodes.CFG_LOCAL_VAR_UNUSED.name()));
+ assertFalse(suppressed.contains(IssueCodes.CLF_NAME_DOES_NOT_START_UPPERCASE.name()));
+ assertFalse(suppressed.contains(IssueCodes.CLF_NAME_DOES_NOT_START_LOWERCASE.name()));
run("probands/IssueConfiguration", suppressed);
assertEventNames("testSuiteStarted - org.eclipse.n4js.ide.tests.helper.server.xt.tests.XtTestSetupTestMockup\n"
diff --git a/tests/org.eclipse.n4js.ide.tests/src/org/eclipse/n4js/ide/tests/bugreports/GH_1943_ExceptionInCaseOfSemverSyntaxErrorTest.java b/tests/org.eclipse.n4js.ide.tests/src/org/eclipse/n4js/ide/tests/bugreports/GH_1943_ExceptionInCaseOfSemverSyntaxErrorTest.java
index d4b668c968..e11d610fdb 100644
--- a/tests/org.eclipse.n4js.ide.tests/src/org/eclipse/n4js/ide/tests/bugreports/GH_1943_ExceptionInCaseOfSemverSyntaxErrorTest.java
+++ b/tests/org.eclipse.n4js.ide.tests/src/org/eclipse/n4js/ide/tests/bugreports/GH_1943_ExceptionInCaseOfSemverSyntaxErrorTest.java
@@ -49,8 +49,8 @@ public void testVersionConstraintWithSyntaxError() {
startAndWaitForLspServer();
assertIssues2(Pair.of(
"ProjectMain/" + PACKAGE_JSON, List.of(
- "(Error, [10:19 - 10:21], Invalid version number \"^1..3\": no viable alternative at input '.'.)",
- "(Error, [11:17 - 11:21], Invalid version number \"^.2.3\": no viable alternative at input '.'.)")));
+ "(Error, [10:19 - 10:21], Invalid version number '^1..3': no viable alternative at input '.'.)",
+ "(Error, [11:17 - 11:21], Invalid version number '^.2.3': no viable alternative at input '.'.)")));
assertNoErrorsInLogOrOutput();
}
}
diff --git a/tests/org.eclipse.n4js.ide.tests/src/org/eclipse/n4js/ide/tests/builder/IncrementalBuilderReexportTest.java b/tests/org.eclipse.n4js.ide.tests/src/org/eclipse/n4js/ide/tests/builder/IncrementalBuilderReexportTest.java
index 3a09e30e9f..70d9350c89 100644
--- a/tests/org.eclipse.n4js.ide.tests/src/org/eclipse/n4js/ide/tests/builder/IncrementalBuilderReexportTest.java
+++ b/tests/org.eclipse.n4js.ide.tests/src/org/eclipse/n4js/ide/tests/builder/IncrementalBuilderReexportTest.java
@@ -29,7 +29,7 @@ public class IncrementalBuilderReexportTest extends AbstractIncrementalBuilderTe
protected Set getIgnoredIssueCodes() {
// note: this test is testing internal infrastructure for a feature not available in N4JS[D] (only in .d.ts)
HashSet iic = new HashSet<>(super.getIgnoredIssueCodes());
- iic.add(IssueCodes.UNSUPPORTED);
+ iic.add(IssueCodes.UNSUPPORTED.name());
return iic;
}
diff --git a/tests/org.eclipse.n4js.ide.tests/src/org/eclipse/n4js/ide/tests/builder/IncrementalBuilderWorkspaceChangesTest.java b/tests/org.eclipse.n4js.ide.tests/src/org/eclipse/n4js/ide/tests/builder/IncrementalBuilderWorkspaceChangesTest.java
index 4def66d57b..6c246c317f 100644
--- a/tests/org.eclipse.n4js.ide.tests/src/org/eclipse/n4js/ide/tests/builder/IncrementalBuilderWorkspaceChangesTest.java
+++ b/tests/org.eclipse.n4js.ide.tests/src/org/eclipse/n4js/ide/tests/builder/IncrementalBuilderWorkspaceChangesTest.java
@@ -214,7 +214,7 @@ class MainClass {};
assertIssues2(Pair.of(
"MainProject/package.json", List.of(
- "(Warning, [1:9 - 1:25], As a convention the package name \"RenamedProject\" should match the name of the project folder \"MainProject\" on the file system.)")));
+ "(Warning, [1:9 - 1:25], As a convention the package name 'RenamedProject' should match the name of the project folder 'MainProject' on the file system.)")));
}
@Test
@@ -249,7 +249,7 @@ public m() {}
assertIssues2(
Pair.of("MainProject/package.json", List.of(
- "(Warning, [1:9 - 1:25], As a convention the package name \"RenamedProject\" should match the name of the project folder \"MainProject\" on the file system.)")));
+ "(Warning, [1:9 - 1:25], As a convention the package name 'RenamedProject' should match the name of the project folder 'MainProject' on the file system.)")));
}
@Test
@@ -284,7 +284,7 @@ public m() {}
assertIssues2(Map.of(
"OtherProject/package.json", List.of(
- " (Warning, [1:9 - 1:25], As a convention the package name \"RenamedProject\" should match the name of the project folder \"OtherProject\" on the file system.)"),
+ " (Warning, [1:9 - 1:25], As a convention the package name 'RenamedProject' should match the name of the project folder 'OtherProject' on the file system.)"),
"MainProject/package.json", List.of(
" (Error, [16:3 - 16:21], Project does not exist with project ID: OtherProject.)"),
"Main.n4js", List.of(
@@ -302,7 +302,7 @@ public m() {}
assertIssues2(Map.of(
"OtherProject/package.json", List.of(
- "(Warning, [1:9 - 1:25], As a convention the package name \"RenamedProject\" should match the name of the project folder \"OtherProject\" on the file system.)")));
+ "(Warning, [1:9 - 1:25], As a convention the package name 'RenamedProject' should match the name of the project folder 'OtherProject' on the file system.)")));
}
@Test
diff --git a/tests/org.eclipse.n4js.ide.tests/src/org/eclipse/n4js/ide/tests/builder/YarnDifferentPackageNames.java b/tests/org.eclipse.n4js.ide.tests/src/org/eclipse/n4js/ide/tests/builder/YarnDifferentPackageNames.java
index e288533359..03b341b558 100644
--- a/tests/org.eclipse.n4js.ide.tests/src/org/eclipse/n4js/ide/tests/builder/YarnDifferentPackageNames.java
+++ b/tests/org.eclipse.n4js.ide.tests/src/org/eclipse/n4js/ide/tests/builder/YarnDifferentPackageNames.java
@@ -68,7 +68,7 @@ public void twoEqualProjectNames() throws Exception {
startAndWaitForLspServer();
assertIssues2(Map.of("library-project/package.json", List.of(
- "(Warning, [1:10 - 1:38], As a convention the package name \"library-project-other-name\" should match the name of the project folder \"library-project\" on the file system.)")));
+ "(Warning, [1:10 - 1:38], As a convention the package name 'library-project-other-name' should match the name of the project folder 'library-project' on the file system.)")));
assertOutputFileExists("main-project", "MainModule");
assertOutputFileExists("library-project", "LibraryModule");
diff --git a/tests/org.eclipse.n4js.jsdoc2spec.tests/src/org/eclipse/n4js/jsdoc2spec/adoc/JSDoc2AdocFullTest.java b/tests/org.eclipse.n4js.jsdoc2spec.tests/src/org/eclipse/n4js/jsdoc2spec/adoc/JSDoc2AdocFullTest.java
index 2e7fd8a9fa..022fd9fea1 100644
--- a/tests/org.eclipse.n4js.jsdoc2spec.tests/src/org/eclipse/n4js/jsdoc2spec/adoc/JSDoc2AdocFullTest.java
+++ b/tests/org.eclipse.n4js.jsdoc2spec.tests/src/org/eclipse/n4js/jsdoc2spec/adoc/JSDoc2AdocFullTest.java
@@ -72,7 +72,7 @@ protected void fullTest(String projectName)
FileURI packageJsonURI = toFileURI(getProjectLocation()).appendSegments(projectName, N4JSGlobals.PACKAGE_JSON);
assertIssues(Map.of(
packageJsonURI, Lists.newArrayList(
- "(Error, [4:17 - 4:26], Missing dependency to n4js-runtime (mandatory for all N4JS projects of type library, application, test).)")));
+ "(Error, [4:17 - 4:26], Missing dependency to 'n4js-runtime' (mandatory for all N4JS projects of type library, application, test).)")));
String systemSeparator = System.getProperty("line.separator", "\n");
try {
diff --git a/tests/org.eclipse.n4js.json.xpect.tests/xt-tests/validation/DuplicateKeys.json.xt b/tests/org.eclipse.n4js.json.xpect.tests/xt-tests/validation/DuplicateKeys.json.xt
index 63ad619411..3f0af4aba3 100644
--- a/tests/org.eclipse.n4js.json.xpect.tests/xt-tests/validation/DuplicateKeys.json.xt
+++ b/tests/org.eclipse.n4js.json.xpect.tests/xt-tests/validation/DuplicateKeys.json.xt
@@ -13,7 +13,7 @@
{
"a": 1,
"b": 2,
- // Duplicate key is detected by validation XPECT warnings --> "Property a duplicates property a (line 14)." at ""a""
+ // Duplicate key is detected by validation XPECT warnings --> "Duplicate property a (line 14)." at ""a""
"a": "str",
"nested": {
// Differently nested key is not detected as duplicate XPECT noerrors
diff --git a/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/n4jsx/lang/tests/parser/JSXParserTest.java b/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/n4jsx/lang/tests/parser/JSXParserTest.java
index c803b3c3e4..c3d45e1ef6 100644
--- a/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/n4jsx/lang/tests/parser/JSXParserTest.java
+++ b/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/n4jsx/lang/tests/parser/JSXParserTest.java
@@ -218,7 +218,7 @@ public void testInvalidAttributeNames_01() throws Exception {
parseWithError("""
""",
- "JSX attribute names may not contain whitespace or comments. Attribute names ending with a - and directly followed by another attribute name are merged and must not contain whitespace or comments.");
+ "JSX attribute names may not contain whitespace or comments. Attribute names ending with a '-' and directly followed by another attribute name are merged and must not contain whitespace or comments.");
}
@Test
@@ -226,7 +226,7 @@ public void testInvalidAttributeNames_02() throws Exception {
parseWithError("""
""",
- "JSX attribute names may not contain whitespace or comments. Attribute names ending with a - and directly followed by another attribute name are merged and must not contain whitespace or comments.");
+ "JSX attribute names may not contain whitespace or comments. Attribute names ending with a '-' and directly followed by another attribute name are merged and must not contain whitespace or comments.");
}
@Test
@@ -234,7 +234,7 @@ public void testInvalidAttributeNames_03() throws Exception {
parseWithError("""
""",
- "JSX attribute names may not contain whitespace or comments. Attribute names ending with a - and directly followed by another attribute name are merged and must not contain whitespace or comments.");
+ "JSX attribute names may not contain whitespace or comments. Attribute names ending with a '-' and directly followed by another attribute name are merged and must not contain whitespace or comments.");
}
@Test
diff --git a/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/scoping/builtin/BuiltInTypesDefinitionTest.java b/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/scoping/builtin/BuiltInTypesDefinitionTest.java
index f6bbb1f88e..983ecedcf2 100644
--- a/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/scoping/builtin/BuiltInTypesDefinitionTest.java
+++ b/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/scoping/builtin/BuiltInTypesDefinitionTest.java
@@ -97,7 +97,8 @@ private void doValidatePredefinedTypes(XtextResourceSet rs, boolean loadOnDemand
+ join("\n ", allIssues),
allIssues.size() == 1 && allIssues.get(0).getSeverity() == Severity.WARNING);
validationTestHelper.assertWarning(resource, N4JSPackage.Literals.N4_FIELD_DECLARATION,
- IssueCodes.CLF_NO_FINAL_INTERFACE_MEMBER, "In interfaces, only methods may be declared final.");
+ IssueCodes.CLF_NO_FINAL_INTERFACE_MEMBER.name(),
+ "In interfaces, only methods may be declared final.");
} else {
assertTrue(resourceName + " must not contain any validation issues, but got:\n "
+ join("\n ", allIssues), allIssues.isEmpty());
diff --git a/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/tests/parser/N4_SyntaxErrorTest.java b/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/tests/parser/N4_SyntaxErrorTest.java
index a88db00f66..8c1ebdfc77 100644
--- a/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/tests/parser/N4_SyntaxErrorTest.java
+++ b/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/tests/parser/N4_SyntaxErrorTest.java
@@ -10,6 +10,7 @@
*/
package org.eclipse.n4js.tests.parser;
+import static org.eclipse.n4js.validation.IssueCodes.AST_INVALID_FOR_AWAIT;
import static org.eclipse.xtext.xbase.lib.IterableExtensions.last;
import java.util.List;
@@ -32,7 +33,6 @@
import org.eclipse.n4js.ts.typeRefs.FunctionTypeExpression;
import org.eclipse.n4js.ts.typeRefs.TypeTypeRef;
import org.eclipse.n4js.utils.Strings;
-import org.eclipse.n4js.validation.IssueCodes;
import org.eclipse.xtext.linking.impl.XtextLinkingDiagnostic;
import org.eclipse.xtext.nodemodel.ICompositeNode;
import org.eclipse.xtext.nodemodel.impl.InvariantChecker;
@@ -556,7 +556,7 @@ public void testForAwaitOf01() {
""");
List errors = script.eResource().getErrors();
assertEquals(1, errors.size());
- assertEquals(IssueCodes.AST_INVALID_FOR_AWAIT, ((XtextLinkingDiagnostic) errors.get(0)).getCode());
+ assertEquals(AST_INVALID_FOR_AWAIT.name(), ((XtextLinkingDiagnostic) errors.get(0)).getCode());
}
@Test
@@ -566,7 +566,7 @@ public void testForAwaitOf02() {
""");
List errors = script.eResource().getErrors();
assertEquals(1, errors.size());
- assertEquals(IssueCodes.AST_INVALID_FOR_AWAIT, ((XtextLinkingDiagnostic) errors.get(0)).getCode());
+ assertEquals(AST_INVALID_FOR_AWAIT.name(), ((XtextLinkingDiagnostic) errors.get(0)).getCode());
}
@Test
diff --git a/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/tests/parser/regex/RegexInN4JSParserTest.java b/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/tests/parser/regex/RegexInN4JSParserTest.java
index 3b63286346..a6ccfb006b 100644
--- a/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/tests/parser/regex/RegexInN4JSParserTest.java
+++ b/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/tests/parser/regex/RegexInN4JSParserTest.java
@@ -58,7 +58,7 @@ public void testRegExCaptureGroupWarning_01() throws Exception {
List warnings = script.eResource().getWarnings();
assertEquals(1, warnings.size());
XtextSyntaxDiagnostic error = (XtextSyntaxDiagnostic) warnings.get(0);
- assertEquals(IssueCodes.getMessageForVCO_REGEX_NAMED_GROUP(), error.getMessage());
+ assertEquals(IssueCodes.VCO_REGEX_NAMED_GROUP.getMessage(), error.getMessage());
assertEquals(3, error.getLength());
assertEquals(1, error.getLine());
assertEquals(4, error.getOffset());
@@ -70,7 +70,7 @@ public void testRegExCaptureGroupWarning_02() throws Exception {
List warnings = script.eResource().getWarnings();
assertEquals(2, warnings.size());
XtextSyntaxDiagnostic error = (XtextSyntaxDiagnostic) IterableExtensions.last(warnings);
- assertEquals(IssueCodes.getMessageForVCO_REGEX_NAMED_GROUP(), error.getMessage());
+ assertEquals(IssueCodes.VCO_REGEX_NAMED_GROUP.getMessage(), error.getMessage());
assertEquals(2, error.getLength());
assertEquals(1, error.getLine());
assertEquals(11, error.getOffset());
@@ -94,7 +94,7 @@ public void testRegExCaptureGroupWarning_04() throws Exception {
List warnings = script.eResource().getWarnings();
assertEquals(1, warnings.size());
XtextSyntaxDiagnostic error = (XtextSyntaxDiagnostic) warnings.get(0);
- assertEquals(IssueCodes.getMessageForVCO_REGEX_NAMED_GROUP(), error.getMessage());
+ assertEquals(IssueCodes.VCO_REGEX_NAMED_GROUP.getMessage(), error.getMessage());
assertEquals(5, error.getLength());
assertEquals(2, error.getLine());
assertEquals(7, error.getOffset());
@@ -106,7 +106,7 @@ public void testRegExCaptureGroupWarningAfterEscapeSequence_01() throws Exceptio
List warnings = script.eResource().getWarnings();
assertEquals(1, warnings.size());
XtextSyntaxDiagnostic error = (XtextSyntaxDiagnostic) warnings.get(0);
- assertEquals(IssueCodes.getMessageForVCO_REGEX_NAMED_GROUP(), error.getMessage());
+ assertEquals(IssueCodes.VCO_REGEX_NAMED_GROUP.getMessage(), error.getMessage());
assertEquals(4, error.getLength());
assertEquals(1, error.getLine());
assertEquals(12, error.getOffset());
@@ -118,7 +118,7 @@ public void testRegExCaptureGroupWarningAfterEscapeSequence_02() throws Exceptio
List warnings = script.eResource().getWarnings();
assertEquals(1, warnings.size());
XtextSyntaxDiagnostic error = (XtextSyntaxDiagnostic) warnings.get(0);
- assertEquals(IssueCodes.getMessageForVCO_REGEX_NAMED_GROUP(), error.getMessage());
+ assertEquals(IssueCodes.VCO_REGEX_NAMED_GROUP.getMessage(), error.getMessage());
assertEquals(4, error.getLength());
assertEquals(1, error.getLine());
assertEquals(14, error.getOffset());
@@ -130,7 +130,7 @@ public void testRegExCaptureGroupWarningAfterEscapeSequence_03() throws Exceptio
List warnings = script.eResource().getWarnings();
assertEquals(1, warnings.size());
XtextSyntaxDiagnostic error = (XtextSyntaxDiagnostic) warnings.get(0);
- assertEquals(IssueCodes.getMessageForVCO_REGEX_NAMED_GROUP(), error.getMessage());
+ assertEquals(IssueCodes.VCO_REGEX_NAMED_GROUP.getMessage(), error.getMessage());
assertEquals(4, error.getLength());
assertEquals(1, error.getLine());
assertEquals(14, error.getOffset());
@@ -142,7 +142,7 @@ public void testRegExCaptureGroupWarningAfterEscapeSequence_04() throws Exceptio
List warnings = script.eResource().getWarnings();
assertEquals(1, warnings.size());
XtextSyntaxDiagnostic error = (XtextSyntaxDiagnostic) warnings.get(0);
- assertEquals(IssueCodes.getMessageForVCO_REGEX_NAMED_GROUP(), error.getMessage());
+ assertEquals(IssueCodes.VCO_REGEX_NAMED_GROUP.getMessage(), error.getMessage());
assertEquals(4, error.getLength());
assertEquals(1, error.getLine());
assertEquals(23, error.getOffset());
@@ -154,7 +154,7 @@ public void testRegExIllegalEscapeSequence_01() throws Exception {
List errors = script.eResource().getErrors();
assertEquals(1, errors.size());
XtextSyntaxDiagnostic error = (XtextSyntaxDiagnostic) errors.get(0);
- assertEquals(IssueCodes.getMessageForVCO_REGEX_ILLEGAL_ESCAPE("/\\u1/"), error.getMessage());
+ assertEquals(IssueCodes.VCO_REGEX_ILLEGAL_ESCAPE.getMessage("/\\u1/"), error.getMessage());
assertEquals(1, error.getLength());
assertEquals(1, error.getLine());
assertEquals(4, error.getOffset());
diff --git a/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/tests/scoping/AT_084_Test.java b/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/tests/scoping/AT_084_Test.java
index 4916a3b696..b18e470794 100644
--- a/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/tests/scoping/AT_084_Test.java
+++ b/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/tests/scoping/AT_084_Test.java
@@ -10,6 +10,14 @@
*/
package org.eclipse.n4js.tests.scoping;
+import static org.eclipse.n4js.validation.IssueCodes.IMP_AMBIGUOUS;
+import static org.eclipse.n4js.validation.IssueCodes.IMP_LOCAL_NAME_CONFLICT;
+import static org.eclipse.n4js.validation.IssueCodes.IMP_NOT_EXPORTED;
+import static org.eclipse.n4js.validation.IssueCodes.IMP_UNUSED_IMPORT;
+import static org.eclipse.n4js.validation.IssueCodes.VIS_ILLEGAL_FUN_ACCESS;
+import static org.eclipse.n4js.validation.IssueCodes.VIS_ILLEGAL_MEMBER_ACCESS;
+import static org.eclipse.n4js.validation.IssueCodes.VIS_ILLEGAL_TYPE_ACCESS;
+import static org.eclipse.n4js.validation.IssueCodes.VIS_ILLEGAL_VARIABLE_ACCESS;
import static org.eclipse.xtext.xbase.lib.IteratorExtensions.filter;
import static org.eclipse.xtext.xbase.lib.IteratorExtensions.head;
@@ -20,7 +28,6 @@
import org.eclipse.n4js.ts.typeRefs.ParameterizedTypeRef;
import org.eclipse.n4js.ts.typeRefs.TypeRefsPackage;
import org.eclipse.n4js.ts.types.TModule;
-import org.eclipse.n4js.validation.IssueCodes;
import org.eclipse.xtext.resource.XtextResourceSet;
import org.eclipse.xtext.testing.InjectWith;
import org.eclipse.xtext.testing.XtextRunner;
@@ -70,10 +77,10 @@ export public class Dup {}
var d = new Dup();
""", URI.createURI("C.n4js"), rs), "A", "B");
- valTestHelper.assertError(script, N4JSPackage.Literals.IDENTIFIER_REF, IssueCodes.IMP_AMBIGUOUS,
+ valTestHelper.assertError(script, N4JSPackage.Literals.IDENTIFIER_REF, IMP_AMBIGUOUS.name(),
"The type Dup is ambiguously imported from A and B");
valTestHelper.assertError(script, N4JSPackage.Literals.NAMED_IMPORT_SPECIFIER,
- IssueCodes.IMP_LOCAL_NAME_CONFLICT, "Name Dup is already used as name for named import Dup from A.");
+ IMP_LOCAL_NAME_CONFLICT.name(), "Name Dup is already used as name for named import Dup from A.");
}
/**
@@ -95,10 +102,10 @@ public void test_02() throws Exception {
var d = dup
""", URI.createURI("C.n4js"), rs);
- valTestHelper.assertError(script, N4JSPackage.Literals.IDENTIFIER_REF, IssueCodes.IMP_AMBIGUOUS,
+ valTestHelper.assertError(script, N4JSPackage.Literals.IDENTIFIER_REF, IMP_AMBIGUOUS.name(),
"The variable dup is ambiguously imported from A and B");
valTestHelper.assertError(script, N4JSPackage.Literals.NAMED_IMPORT_SPECIFIER,
- IssueCodes.IMP_LOCAL_NAME_CONFLICT, "Name dup is already used as name for named import Dup from A.");
+ IMP_LOCAL_NAME_CONFLICT.name(), "Name dup is already used as name for named import Dup from A.");
}
@Test
@@ -117,13 +124,13 @@ public void test_03() throws Exception {
var d = dup
""", URI.createURI("C.n4js"), rs);
- valTestHelper.assertNoError(script, IssueCodes.IMP_AMBIGUOUS);
- valTestHelper.assertNoIssue(script, N4JSPackage.Literals.NAMED_IMPORT_SPECIFIER, IssueCodes.IMP_UNUSED_IMPORT);
+ valTestHelper.assertNoError(script, IMP_AMBIGUOUS.name());
+ valTestHelper.assertNoIssue(script, N4JSPackage.Literals.NAMED_IMPORT_SPECIFIER, IMP_UNUSED_IMPORT.name());
// Since A.dup cannot be linked, import is unused, but also marked with linking error;
- valTestHelper.assertError(script, N4JSPackage.Literals.NAMED_IMPORT_SPECIFIER, IssueCodes.IMP_NOT_EXPORTED,
+ valTestHelper.assertError(script, N4JSPackage.Literals.NAMED_IMPORT_SPECIFIER, IMP_NOT_EXPORTED.name(),
"Element dup is not exported.");
valTestHelper.assertError(script, N4JSPackage.Literals.NAMED_IMPORT_SPECIFIER,
- IssueCodes.IMP_LOCAL_NAME_CONFLICT, "Name dup is already used as name for named import dup from A.");
+ IMP_LOCAL_NAME_CONFLICT.name(), "Name dup is already used as name for named import dup from A.");
}
@Test
@@ -141,13 +148,13 @@ public void test_04() throws Exception {
var d = dup
""", URI.createURI("C.n4js"), rs);
- valTestHelper.assertNoError(script, IssueCodes.IMP_AMBIGUOUS);
- valTestHelper.assertNoIssue(script, N4JSPackage.Literals.NAMED_IMPORT_SPECIFIER, IssueCodes.IMP_UNUSED_IMPORT);
+ valTestHelper.assertNoError(script, IMP_AMBIGUOUS.name());
+ valTestHelper.assertNoIssue(script, N4JSPackage.Literals.NAMED_IMPORT_SPECIFIER, IMP_UNUSED_IMPORT.name());
// Since A.dup cannot be linked, an error is shown
- valTestHelper.assertError(script, N4JSPackage.Literals.NAMED_IMPORT_SPECIFIER, IssueCodes.IMP_NOT_EXPORTED,
+ valTestHelper.assertError(script, N4JSPackage.Literals.NAMED_IMPORT_SPECIFIER, IMP_NOT_EXPORTED.name(),
"Element dup is not exported.");
valTestHelper.assertError(script, N4JSPackage.Literals.NAMED_IMPORT_SPECIFIER,
- IssueCodes.IMP_LOCAL_NAME_CONFLICT, "Name dup is already used as name for named import dup from A.");
+ IMP_LOCAL_NAME_CONFLICT.name(), "Name dup is already used as name for named import dup from A.");
}
@Test
@@ -164,11 +171,11 @@ public void test_05() throws Exception {
import {dup} from "B";
var d = dup
""", URI.createURI("C.n4js"), rs), "A", "B");
- valTestHelper.assertNoError(script, IssueCodes.IMP_AMBIGUOUS);
+ valTestHelper.assertNoError(script, IMP_AMBIGUOUS.name());
valTestHelper.assertError(script, N4JSPackage.Literals.NAMED_IMPORT_SPECIFIER,
- IssueCodes.VIS_ILLEGAL_VARIABLE_ACCESS, "The variable dup is not visible.");
+ VIS_ILLEGAL_VARIABLE_ACCESS.name(), "The variable dup is not visible.");
valTestHelper.assertError(script, N4JSPackage.Literals.NAMED_IMPORT_SPECIFIER,
- IssueCodes.IMP_LOCAL_NAME_CONFLICT, "Name dup is already used as name for named import dup from A.");
+ IMP_LOCAL_NAME_CONFLICT.name(), "Name dup is already used as name for named import dup from A.");
}
@Test
@@ -186,12 +193,12 @@ public void test_06() throws Exception {
var d = dup
""", URI.createURI("C.n4js"), rs), "C", "B");
- valTestHelper.assertNoError(script, IssueCodes.IMP_AMBIGUOUS);
+ valTestHelper.assertNoError(script, IMP_AMBIGUOUS.name());
valTestHelper.assertError(script, N4JSPackage.Literals.NAMED_IMPORT_SPECIFIER,
- IssueCodes.IMP_LOCAL_NAME_CONFLICT, "Name dup is already used as name for named import dup from A.");
+ IMP_LOCAL_NAME_CONFLICT.name(), "Name dup is already used as name for named import dup from A.");
valTestHelper.assertError(script, N4JSPackage.Literals.NAMED_IMPORT_SPECIFIER,
- IssueCodes.VIS_ILLEGAL_VARIABLE_ACCESS, "The variable dup is not visible.");
- valTestHelper.assertError(script, N4JSPackage.Literals.IDENTIFIER_REF, IssueCodes.VIS_ILLEGAL_VARIABLE_ACCESS,
+ VIS_ILLEGAL_VARIABLE_ACCESS.name(), "The variable dup is not visible.");
+ valTestHelper.assertError(script, N4JSPackage.Literals.IDENTIFIER_REF, VIS_ILLEGAL_VARIABLE_ACCESS.name(),
"The variable dup is not visible.");
}
@@ -210,12 +217,12 @@ public void test_07() throws Exception {
var d = dup
""", URI.createURI("C.n4js"), rs), "C", "B");
- valTestHelper.assertNoError(script, IssueCodes.IMP_AMBIGUOUS);
+ valTestHelper.assertNoError(script, IMP_AMBIGUOUS.name());
valTestHelper.assertError(script, N4JSPackage.Literals.NAMED_IMPORT_SPECIFIER,
- IssueCodes.IMP_LOCAL_NAME_CONFLICT, "Name dup is already used as name for named import dup from A.");
+ IMP_LOCAL_NAME_CONFLICT.name(), "Name dup is already used as name for named import dup from A.");
valTestHelper.assertError(script, N4JSPackage.Literals.NAMED_IMPORT_SPECIFIER,
- IssueCodes.VIS_ILLEGAL_VARIABLE_ACCESS, "The variable dup is not visible.");
- valTestHelper.assertError(script, N4JSPackage.Literals.IDENTIFIER_REF, IssueCodes.VIS_ILLEGAL_VARIABLE_ACCESS,
+ VIS_ILLEGAL_VARIABLE_ACCESS.name(), "The variable dup is not visible.");
+ valTestHelper.assertError(script, N4JSPackage.Literals.IDENTIFIER_REF, VIS_ILLEGAL_VARIABLE_ACCESS.name(),
"The variable dup is not visible.");
}
@@ -243,7 +250,7 @@ class A {}
import {A} from "A";
""", URI.createURI("C.n4js"), rs), "C", "B");
- valTestHelper.assertError(script, N4JSPackage.Literals.NAMED_IMPORT_SPECIFIER, IssueCodes.IMP_NOT_EXPORTED,
+ valTestHelper.assertError(script, N4JSPackage.Literals.NAMED_IMPORT_SPECIFIER, IMP_NOT_EXPORTED.name(),
"Element A is not exported.");
}
@@ -257,7 +264,7 @@ export public class A {}
import {A} from "A";
""", URI.createURI("C.n4js"), rs), "C", "B");
- valTestHelper.assertWarning(script, N4JSPackage.Literals.NAMED_IMPORT_SPECIFIER, IssueCodes.IMP_UNUSED_IMPORT,
+ valTestHelper.assertWarning(script, N4JSPackage.Literals.NAMED_IMPORT_SPECIFIER, IMP_UNUSED_IMPORT.name(),
"The import of A is unused.");
}
@@ -272,7 +279,7 @@ class A {}
var a: N.A = null
""", URI.createURI("C.n4js"), rs), "C", "B");
- valTestHelper.assertError(script, TypeRefsPackage.Literals.PARAMETERIZED_TYPE_REF, IssueCodes.IMP_NOT_EXPORTED,
+ valTestHelper.assertError(script, TypeRefsPackage.Literals.PARAMETERIZED_TYPE_REF, IMP_NOT_EXPORTED.name(),
"Element A is not exported.");
}
@@ -288,7 +295,7 @@ class A {}
""", URI.createURI("C.n4js"), rs), "C", "B");
valTestHelper.assertError(script, TypeRefsPackage.Literals.PARAMETERIZED_TYPE_REF,
- IssueCodes.VIS_ILLEGAL_TYPE_ACCESS, "The type A is not visible");
+ VIS_ILLEGAL_TYPE_ACCESS.name(), "The type A is not visible");
}
@Test
@@ -303,7 +310,7 @@ class A {}
""", URI.createURI("C.n4js"), rs), "C", "B");
valTestHelper.assertError(script, N4JSPackage.Literals.PARAMETERIZED_PROPERTY_ACCESS_EXPRESSION,
- IssueCodes.IMP_NOT_EXPORTED, "Element A is not exported.");
+ IMP_NOT_EXPORTED.name(), "Element A is not exported.");
}
@Test
@@ -317,9 +324,9 @@ class A {}
var a = A
""", URI.createURI("C.n4js"), rs), "C", "B");
- valTestHelper.assertError(script, N4JSPackage.Literals.NAMED_IMPORT_SPECIFIER, IssueCodes.IMP_NOT_EXPORTED,
+ valTestHelper.assertError(script, N4JSPackage.Literals.NAMED_IMPORT_SPECIFIER, IMP_NOT_EXPORTED.name(),
"Element A is not exported.");
- valTestHelper.assertError(script, N4JSPackage.Literals.IDENTIFIER_REF, IssueCodes.VIS_ILLEGAL_TYPE_ACCESS,
+ valTestHelper.assertError(script, N4JSPackage.Literals.IDENTIFIER_REF, VIS_ILLEGAL_TYPE_ACCESS.name(),
"The type A is not visible");
}
@@ -334,7 +341,7 @@ class A {}
var a: N.A = ""
""", URI.createURI("C.n4js"), rs), "C", "B");
- valTestHelper.assertError(script, TypeRefsPackage.Literals.PARAMETERIZED_TYPE_REF, IssueCodes.IMP_NOT_EXPORTED,
+ valTestHelper.assertError(script, TypeRefsPackage.Literals.PARAMETERIZED_TYPE_REF, IMP_NOT_EXPORTED.name(),
"Element A is not exported.");
}
@@ -352,7 +359,7 @@ export class A {}
var a: N.A = ""
""", URI.createURI("C.n4js?C|B"), rs), "C", "B");
- valTestHelper.assertNoError(script, IssueCodes.VIS_ILLEGAL_TYPE_ACCESS);
+ valTestHelper.assertNoError(script, VIS_ILLEGAL_TYPE_ACCESS.name());
ParameterizedTypeRef typeRef = head(filter(script.eAllContents(), ParameterizedTypeRef.class));
Assert.assertEquals("A.n4js?C|B", typeRef.getDeclaredType().eResource().getURI().toString());
}
@@ -383,7 +390,7 @@ public void test_17() throws Exception {
""", URI.createURI("B.n4js"), rs), "B", "C");
valTestHelper.assertError(script, N4JSPackage.Literals.PARAMETERIZED_PROPERTY_ACCESS_EXPRESSION,
- IssueCodes.VIS_ILLEGAL_VARIABLE_ACCESS, "The variable s is not visible");
+ VIS_ILLEGAL_VARIABLE_ACCESS.name(), "The variable s is not visible");
}
@Test
@@ -440,7 +447,7 @@ public void test_21() throws Exception {
""", URI.createURI("B.n4js"), rs), "B", "C");
valTestHelper.assertError(script, N4JSPackage.Literals.PARAMETERIZED_PROPERTY_ACCESS_EXPRESSION,
- IssueCodes.VIS_ILLEGAL_FUN_ACCESS, "The function f is not visible");
+ VIS_ILLEGAL_FUN_ACCESS.name(), "The function f is not visible");
}
@Test
@@ -497,9 +504,9 @@ public void test_25() throws Exception {
""", URI.createURI("B.n4js"), rs), "B", "C");
valTestHelper.assertError(script, N4JSPackage.Literals.PARAMETERIZED_PROPERTY_ACCESS_EXPRESSION,
- IssueCodes.VIS_ILLEGAL_TYPE_ACCESS, "The type E is not visible");
+ VIS_ILLEGAL_TYPE_ACCESS.name(), "The type E is not visible");
valTestHelper.assertError(script, N4JSPackage.Literals.PARAMETERIZED_PROPERTY_ACCESS_EXPRESSION,
- IssueCodes.VIS_ILLEGAL_MEMBER_ACCESS, "The enum literal Literal is not visible");
+ VIS_ILLEGAL_MEMBER_ACCESS.name(), "The enum literal Literal is not visible");
}
@Test
@@ -550,7 +557,7 @@ export public class Sub extends Base {}
""", URI.createURI("B.n4js"), rs), "B", "C");
valTestHelper.assertError(script, N4JSPackage.Literals.PARAMETERIZED_PROPERTY_ACCESS_EXPRESSION,
- IssueCodes.VIS_ILLEGAL_MEMBER_ACCESS, "The method m is not visible");
+ VIS_ILLEGAL_MEMBER_ACCESS.name(), "The method m is not visible");
}
@Test
@@ -585,7 +592,7 @@ private m(): void {}
""", URI.createURI("B.n4js"), rs), "A", "B");
valTestHelper.assertError(script, N4JSPackage.Literals.PARAMETERIZED_PROPERTY_ACCESS_EXPRESSION,
- IssueCodes.VIS_ILLEGAL_MEMBER_ACCESS, "The method m is not visible");
+ VIS_ILLEGAL_MEMBER_ACCESS.name(), "The method m is not visible");
}
@Test
@@ -624,6 +631,6 @@ export class C extends B {}
""", URI.createURI("B.n4js"), rs), "A", "C");
valTestHelper.assertError(script, N4JSPackage.Literals.PARAMETERIZED_PROPERTY_ACCESS_EXPRESSION,
- IssueCodes.VIS_ILLEGAL_MEMBER_ACCESS, "The method m is not visible");
+ VIS_ILLEGAL_MEMBER_ACCESS.name(), "The method m is not visible");
}
}
diff --git a/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/tests/scoping/AT_556_MemberAccessTest.java b/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/tests/scoping/AT_556_MemberAccessTest.java
index 85661375cf..8d2ea601b3 100644
--- a/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/tests/scoping/AT_556_MemberAccessTest.java
+++ b/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/tests/scoping/AT_556_MemberAccessTest.java
@@ -10,6 +10,7 @@
*/
package org.eclipse.n4js.tests.scoping;
+import static org.eclipse.n4js.validation.IssueCodes.VIS_ILLEGAL_MEMBER_ACCESS;
import static org.junit.Assert.fail;
import org.eclipse.emf.common.util.URI;
@@ -17,7 +18,6 @@
import org.eclipse.n4js.n4JS.N4JSPackage;
import org.eclipse.n4js.n4JS.Script;
import org.eclipse.n4js.ts.types.TModule;
-import org.eclipse.n4js.validation.IssueCodes;
import org.eclipse.xtext.resource.XtextResourceSet;
import org.eclipse.xtext.testing.InjectWith;
import org.eclipse.xtext.testing.XtextRunner;
@@ -69,7 +69,7 @@ export public class C {
valTestHelper.assertNoErrors(script);
else
valTestHelper.assertError(script, N4JSPackage.Literals.PARAMETERIZED_PROPERTY_ACCESS_EXPRESSION,
- IssueCodes.VIS_ILLEGAL_MEMBER_ACCESS, "The method m is not visible");
+ VIS_ILLEGAL_MEMBER_ACCESS.name(), "The method m is not visible");
} catch (Exception e) {
fail();
}
@@ -112,7 +112,7 @@ export public class C {
valTestHelper.assertNoErrors(script);
else
valTestHelper.assertError(script, N4JSPackage.Literals.PARAMETERIZED_PROPERTY_ACCESS_EXPRESSION,
- IssueCodes.VIS_ILLEGAL_MEMBER_ACCESS, "The method m is not visible");
+ VIS_ILLEGAL_MEMBER_ACCESS.name(), "The method m is not visible");
} catch (Exception e) {
fail();
@@ -136,7 +136,7 @@ export public class C {
valTestHelper.assertNoErrors(script);
else
valTestHelper.assertError(script, N4JSPackage.Literals.PARAMETERIZED_PROPERTY_ACCESS_EXPRESSION,
- IssueCodes.VIS_ILLEGAL_MEMBER_ACCESS, "The method m is not visible");
+ VIS_ILLEGAL_MEMBER_ACCESS.name(), "The method m is not visible");
} catch (Exception e) {
fail();
@@ -192,7 +192,7 @@ class E extends D {
valTestHelper.assertNoErrors(scriptNoAPI);
else
valTestHelper.assertError(scriptNoAPI, N4JSPackage.Literals.PARAMETERIZED_PROPERTY_ACCESS_EXPRESSION,
- IssueCodes.VIS_ILLEGAL_MEMBER_ACCESS, "The method %s1 is not visible".formatted(member));
+ VIS_ILLEGAL_MEMBER_ACCESS.name(), "The method %s1 is not visible".formatted(member));
} catch (Exception e) {
fail();
@@ -507,6 +507,6 @@ class C {
}
""", URI.createURI("B.n4js"), rs), "A", "C");
valTestHelper.assertError(script, N4JSPackage.Literals.PARAMETERIZED_PROPERTY_ACCESS_EXPRESSION,
- IssueCodes.VIS_ILLEGAL_MEMBER_ACCESS, "The method a is not visible");
+ VIS_ILLEGAL_MEMBER_ACCESS.name(), "The method a is not visible");
}
}
diff --git a/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/tests/scoping/ExportDefinitionInCyclicResourcesTest.java b/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/tests/scoping/ExportDefinitionInCyclicResourcesTest.java
index 0c8c3e4f2c..28d742ee16 100644
--- a/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/tests/scoping/ExportDefinitionInCyclicResourcesTest.java
+++ b/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/tests/scoping/ExportDefinitionInCyclicResourcesTest.java
@@ -24,6 +24,7 @@
import org.eclipse.n4js.resource.N4JSResource;
import org.eclipse.n4js.tests.scoping.ExportDefinitionInCyclicResourcesTest.N4JSInjectorProviderWithoutCycleDetection;
import org.eclipse.n4js.ts.types.ExportDefinition;
+import org.eclipse.n4js.validation.IssueCodes;
import org.eclipse.xtext.linking.lazy.LazyLinkingResource;
import org.eclipse.xtext.resource.XtextResourceSet;
import org.eclipse.xtext.testing.InjectWith;
@@ -590,7 +591,7 @@ private void assertErrors(Script script, List expectedErrors) {
N4JSResource res = (N4JSResource) script.eResource();
res.performPostProcessing();
parserHelper.assertNoParseErrors(script);
- validationTestHelper.assertErrorsExcept(script, new String[] { UNSUPPORTED },
+ validationTestHelper.assertErrorsExcept(script, new IssueCodes[] { UNSUPPORTED },
expectedErrors.toArray(new String[0]));
}
diff --git a/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/tests/scoping/ExportDefinitionTest.java b/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/tests/scoping/ExportDefinitionTest.java
index 1cac5d7c82..dbb69a7ea8 100644
--- a/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/tests/scoping/ExportDefinitionTest.java
+++ b/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/tests/scoping/ExportDefinitionTest.java
@@ -95,7 +95,7 @@ public class Cls {}
assertEquals("Cls", elems.get(1).getName().toString());
assertSame(cls, elems.get(1).getEObjectOrProxy());
assertTrue(elems.get(1) instanceof IEObjectDescriptionWithError);
- assertEquals(IMP_NOT_EXPORTED, ((IEObjectDescriptionWithError) elems.get(1)).getIssueCode());
+ assertEquals(IMP_NOT_EXPORTED.name(), ((IEObjectDescriptionWithError) elems.get(1)).getIssueCode());
}
@Test
@@ -288,6 +288,6 @@ public void testOnlyIndirectlyExported_variable() throws Exception {
assertEquals("v", elems.get(1).getName().toString());
assertSame(v, elems.get(1).getEObjectOrProxy());
assertTrue(elems.get(1) instanceof IEObjectDescriptionWithError);
- assertEquals(IMP_NOT_EXPORTED, ((IEObjectDescriptionWithError) elems.get(1)).getIssueCode());
+ assertEquals(IMP_NOT_EXPORTED.name(), ((IEObjectDescriptionWithError) elems.get(1)).getIssueCode());
}
}
diff --git a/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/tests/scoping/StaticScopingTest.java b/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/tests/scoping/StaticScopingTest.java
index 2947eac8a5..f056753957 100644
--- a/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/tests/scoping/StaticScopingTest.java
+++ b/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/tests/scoping/StaticScopingTest.java
@@ -10,6 +10,8 @@
*/
package org.eclipse.n4js.tests.scoping;
+import static org.eclipse.n4js.validation.IssueCodes.CFG_LOCAL_VAR_UNUSED;
+import static org.eclipse.n4js.validation.IssueCodes.DFG_NULL_DEREFERENCE;
import static org.eclipse.xtext.xbase.lib.IterableExtensions.filter;
import static org.eclipse.xtext.xbase.lib.IterableExtensions.map;
import static org.eclipse.xtext.xbase.lib.IterableExtensions.size;
@@ -21,6 +23,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
+import java.util.Set;
import org.eclipse.n4js.N4JSInjectorProvider;
import org.eclipse.n4js.n4JS.N4JSPackage;
@@ -39,7 +42,6 @@
import org.eclipse.n4js.typesystem.utils.RuleEnvironmentExtensions;
import org.eclipse.n4js.typesystem.utils.TypeSystemHelper;
import org.eclipse.n4js.utils.Strings;
-import org.eclipse.n4js.validation.IssueCodes;
import org.eclipse.xtext.resource.IEObjectDescription;
import org.eclipse.xtext.scoping.IScopeProvider;
import org.eclipse.xtext.testing.InjectWith;
@@ -77,8 +79,8 @@ public class StaticScopingTest {
IScopeProvider scopeProvider;
public List getIssues(Script script) {
- return toList(filter(valTestHelper.validate(script), issue -> issue.getCode() != IssueCodes.CFG_LOCAL_VAR_UNUSED
- && issue.getCode() != IssueCodes.DFG_NULL_DEREFERENCE));
+ return toList(filter(valTestHelper.validate(script),
+ issue -> !Set.of(CFG_LOCAL_VAR_UNUSED.name(), DFG_NULL_DEREFERENCE.name()).contains(issue.getCode())));
}
@Test
diff --git a/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/tests/validation/AT_225_ValidateConflictingImportOnlyOnFirstUsageOfConcreteTypeTest.java b/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/tests/validation/AT_225_ValidateConflictingImportOnlyOnFirstUsageOfConcreteTypeTest.java
index cbc14cdf63..2162583095 100644
--- a/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/tests/validation/AT_225_ValidateConflictingImportOnlyOnFirstUsageOfConcreteTypeTest.java
+++ b/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/tests/validation/AT_225_ValidateConflictingImportOnlyOnFirstUsageOfConcreteTypeTest.java
@@ -117,7 +117,7 @@ public void test_05() throws Exception {
var a: A
""", rs);
valTestHelper.assertError(script, TypeRefsPackage.Literals.PARAMETERIZED_TYPE_REF,
- IssueCodes.IMP_AMBIGUOUS_WILDCARD, "The type A is ambiguously imported from a.A and b.A");
+ IssueCodes.IMP_AMBIGUOUS_WILDCARD.name(), "The type A is ambiguously imported from a.A and b.A");
}
@Test
@@ -130,7 +130,7 @@ public void test_06() throws Exception {
var a: A
""", rs);
valTestHelper.assertError(script, TypeRefsPackage.Literals.PARAMETERIZED_TYPE_REF,
- IssueCodes.IMP_AMBIGUOUS_WILDCARD, "The type A is ambiguously imported from b.A and a.A");
+ IssueCodes.IMP_AMBIGUOUS_WILDCARD.name(), "The type A is ambiguously imported from b.A and a.A");
}
// ================
@@ -141,7 +141,7 @@ public void spec_DuplicatedImportStatement_A() throws Exception {
import * as N from 'a/X';
""", rs);
valTestHelper.assertError(script, N4JSPackage.Literals.IMPORT_DECLARATION,
- IssueCodes.IMP_STMT_DUPLICATE_NAMESPACE,
+ IssueCodes.IMP_STMT_DUPLICATE_NAMESPACE.name(),
"Duplicate namespace import statement with name N and imported module a/X.");
}
@@ -151,7 +151,8 @@ public void spec_DuplicatedImportStatement_B() throws Exception {
import { X } from 'a/X';
import { X } from 'a/X';
""", rs);
- valTestHelper.assertError(script, N4JSPackage.Literals.IMPORT_DECLARATION, IssueCodes.IMP_STMT_DUPLICATE_NAMED,
+ valTestHelper.assertError(script, N4JSPackage.Literals.IMPORT_DECLARATION,
+ IssueCodes.IMP_STMT_DUPLICATE_NAMED.name(),
"Duplicate named import statement with local name X and imported module a/X.");
}
@@ -162,7 +163,8 @@ public void spec_DuplicatedImport_A() throws Exception {
import * as N2 from 'a/X';
var x: N1.X;
""", rs);
- valTestHelper.assertError(script, N4JSPackage.Literals.IMPORT_SPECIFIER, IssueCodes.IMP_DUPLICATE_NAMESPACE,
+ valTestHelper.assertError(script, N4JSPackage.Literals.IMPORT_SPECIFIER,
+ IssueCodes.IMP_DUPLICATE_NAMESPACE.name(),
"Element N2.X of a/X is already imported in namespace N1.");
}
@@ -172,7 +174,7 @@ public void spec_DuplicatedImport_B() throws Exception {
import { Z } from 'a/X';
import { Z as Z1 } from 'a/X';
""", rs);
- valTestHelper.assertError(script, N4JSPackage.Literals.IMPORT_SPECIFIER, IssueCodes.IMP_DUPLICATE,
+ valTestHelper.assertError(script, N4JSPackage.Literals.IMPORT_SPECIFIER, IssueCodes.IMP_DUPLICATE.name(),
"Z from a/X is already imported as Z.");
}
@@ -182,7 +184,7 @@ public void spec_DuplicatedImport_C() throws Exception {
import { Z as Z1 } from 'a/X';
import { Z } from 'a/X';
""", rs);
- valTestHelper.assertError(script, N4JSPackage.Literals.IMPORT_SPECIFIER, IssueCodes.IMP_DUPLICATE,
+ valTestHelper.assertError(script, N4JSPackage.Literals.IMPORT_SPECIFIER, IssueCodes.IMP_DUPLICATE.name(),
"Z from a/X is already imported as Z1.");
}
@@ -192,7 +194,7 @@ public void spec_DuplicatedImport_D() throws Exception {
import { Z as Z1 } from 'a/X';
import { Z as Z2 } from 'a/X';
""", rs);
- valTestHelper.assertError(script, N4JSPackage.Literals.IMPORT_SPECIFIER, IssueCodes.IMP_DUPLICATE,
+ valTestHelper.assertError(script, N4JSPackage.Literals.IMPORT_SPECIFIER, IssueCodes.IMP_DUPLICATE.name(),
"Z from a/X is already imported as Z1.");
}
@@ -202,7 +204,7 @@ public void spec_DuplicatedImport_E() throws Exception {
import * as NX from 'a/X';
import { Z } from 'a/X';
""", rs);
- valTestHelper.assertError(script, N4JSPackage.Literals.IMPORT_SPECIFIER, IssueCodes.IMP_DUPLICATE,
+ valTestHelper.assertError(script, N4JSPackage.Literals.IMPORT_SPECIFIER, IssueCodes.IMP_DUPLICATE.name(),
"Z from a/X is already imported as NX.Z.");
}
@@ -212,7 +214,7 @@ public void spec_DuplicatedImport_F() throws Exception {
import { Z } from 'a/X';
import * as NX from 'a/X';
""", rs);
- valTestHelper.assertError(script, N4JSPackage.Literals.IMPORT_SPECIFIER, IssueCodes.IMP_DUPLICATE,
+ valTestHelper.assertError(script, N4JSPackage.Literals.IMPORT_SPECIFIER, IssueCodes.IMP_DUPLICATE.name(),
"Z from a/X is already imported as Z.");
}
@@ -222,7 +224,8 @@ public void spec_NameConflict_A() throws Exception {
import * as NX from 'a/X';
import * as NX from 'b/Y';
""", rs);
- valTestHelper.assertError(script, N4JSPackage.Literals.IMPORT_SPECIFIER, IssueCodes.IMP_LOCAL_NAME_CONFLICT,
+ valTestHelper.assertError(script, N4JSPackage.Literals.IMPORT_SPECIFIER,
+ IssueCodes.IMP_LOCAL_NAME_CONFLICT.name(),
"Name NX is already used as namespace name for a/X.");
}
@@ -232,7 +235,8 @@ public void spec_NameConflict_B() throws Exception {
import { X } from 'a/X';
import { Y as X } from 'b/Y';
""", rs);
- valTestHelper.assertError(script, N4JSPackage.Literals.IMPORT_SPECIFIER, IssueCodes.IMP_LOCAL_NAME_CONFLICT,
+ valTestHelper.assertError(script, N4JSPackage.Literals.IMPORT_SPECIFIER,
+ IssueCodes.IMP_LOCAL_NAME_CONFLICT.name(),
"Name X is already used as name for named import X from a/X.");
}
@@ -242,7 +246,8 @@ public void spec_NameConflict_C() throws Exception {
import { X as N } from 'a/X';
import * as N from 'b/Y';
""", rs);
- valTestHelper.assertError(script, N4JSPackage.Literals.IMPORT_SPECIFIER, IssueCodes.IMP_LOCAL_NAME_CONFLICT,
+ valTestHelper.assertError(script, N4JSPackage.Literals.IMPORT_SPECIFIER,
+ IssueCodes.IMP_LOCAL_NAME_CONFLICT.name(),
"Name N is already used as alias name for named import X from a/X.");
}
@@ -252,7 +257,8 @@ public void spec_NameConflict_D() throws Exception {
import * as N from 'a/X';
import { Y as N } from 'b/Y';
""", rs);
- valTestHelper.assertError(script, N4JSPackage.Literals.IMPORT_SPECIFIER, IssueCodes.IMP_LOCAL_NAME_CONFLICT,
+ valTestHelper.assertError(script, N4JSPackage.Literals.IMPORT_SPECIFIER,
+ IssueCodes.IMP_LOCAL_NAME_CONFLICT.name(),
"Name N is already used as namespace name for a/X.");
}
@@ -262,7 +268,8 @@ public void spec_NameConflict_E() throws Exception {
import { X } from 'a/X';
class X{};
""", rs);
- valTestHelper.assertError(script, N4JSPackage.Literals.N4_CLASS_DECLARATION, IssueCodes.AST_NAME_DUPLICATE_ERR,
+ valTestHelper.assertError(script, N4JSPackage.Literals.N4_CLASS_DECLARATION,
+ IssueCodes.AST_NAME_DUPLICATE_ERR.name(),
"Class X duplicates named import X (line 1).");
}
@@ -272,7 +279,8 @@ public void spec_NameConflict_F() throws Exception {
import * as X from 'a/X';
class X{};
""", rs);
- valTestHelper.assertError(script, N4JSPackage.Literals.N4_CLASS_DECLARATION, IssueCodes.AST_NAME_DUPLICATE_ERR,
+ valTestHelper.assertError(script, N4JSPackage.Literals.N4_CLASS_DECLARATION,
+ IssueCodes.AST_NAME_DUPLICATE_ERR.name(),
"Class X duplicates namespace import specifier X (line 1).");
}
@@ -299,7 +307,7 @@ public void spec_AccessAlaisedName() throws Exception {
var x: X;
""", rs);
valTestHelper.assertError(script, TypeRefsPackage.Literals.PARAMETERIZED_TYPE_REF,
- IssueCodes.IMP_PLAIN_ACCESS_OF_ALIASED_TYPE, "X has been imported as XXX.");
+ IssueCodes.IMP_PLAIN_ACCESS_OF_ALIASED_TYPE.name(), "X has been imported as XXX.");
}
@Test
@@ -309,7 +317,7 @@ public void spec_AccessNamespacedName() throws Exception {
var x: X;
""", rs);
valTestHelper.assertError(script, TypeRefsPackage.Literals.PARAMETERIZED_TYPE_REF,
- IssueCodes.IMP_PLAIN_ACCESS_OF_NAMESPACED_TYPE, "X has been imported as N.X.");
+ IssueCodes.IMP_PLAIN_ACCESS_OF_NAMESPACED_TYPE.name(), "X has been imported as N.X.");
}
}
diff --git a/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/tests/validation/AutomaticCancelationTest.java b/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/tests/validation/AutomaticCancelationTest.java
index 7adcaa96b9..1b7a6a876f 100644
--- a/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/tests/validation/AutomaticCancelationTest.java
+++ b/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/tests/validation/AutomaticCancelationTest.java
@@ -110,7 +110,7 @@ public void testCancelIndicatorGetsInvokedAutomatically() throws Exception {
"The field a (line 3) duplicates field a (line 2)."
};
for (String expectedErrorMsg : expectedErrorMsgs) {
- vth.assertError(s, N4JSPackage.Literals.N4_MEMBER_DECLARATION, IssueCodes.CLF_DUP_MEMBER,
+ vth.assertError(s, N4JSPackage.Literals.N4_MEMBER_DECLARATION, IssueCodes.CLF_DUP_MEMBER.name(),
expectedErrorMsg);
}
diff --git a/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/tests/validation/N4JSValidatorTest.java b/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/tests/validation/N4JSValidatorTest.java
index 7b48da982b..b4527a56cd 100644
--- a/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/tests/validation/N4JSValidatorTest.java
+++ b/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/tests/validation/N4JSValidatorTest.java
@@ -47,7 +47,8 @@ public void testCircularInit() throws Exception {
var v = v
""");
assertTrue(program.eResource().getErrors().isEmpty());
- valTestHelper.assertWarning(program, N4JSPackage.Literals.IDENTIFIER_REF, IssueCodes.AST_VAR_DECL_RECURSIVE);
+ valTestHelper.assertWarning(program, N4JSPackage.Literals.IDENTIFIER_REF,
+ IssueCodes.AST_VAR_DECL_RECURSIVE.name());
}
@Test
@@ -66,8 +67,8 @@ class X {
"The field a (line 3) duplicates field a (line 2).");
for (String it : expectedErrorMsgs) {
- valTestHelper.assertError(program, N4JSPackage.Literals.N4_MEMBER_DECLARATION, IssueCodes.CLF_DUP_MEMBER,
- it);
+ valTestHelper.assertError(program, N4JSPackage.Literals.N4_MEMBER_DECLARATION,
+ IssueCodes.CLF_DUP_MEMBER.name(), it);
}
}
@@ -99,8 +100,8 @@ class X {
"The setter d (line 9) duplicates field d (line 5).");
for (String it : expectedErrorMsgs) {
- valTestHelper.assertError(program, N4JSPackage.Literals.N4_MEMBER_DECLARATION, IssueCodes.CLF_DUP_MEMBER,
- it);
+ valTestHelper.assertError(program, N4JSPackage.Literals.N4_MEMBER_DECLARATION,
+ IssueCodes.CLF_DUP_MEMBER.name(), it);
}
}
@@ -120,7 +121,8 @@ class A {
// bindings ok?
valTestHelper.assertNoErrors(program);
- valTestHelper.assertNoWarnings(program, N4JSPackage.Literals.N4_MEMBER_DECLARATION, IssueCodes.CLF_DUP_MEMBER);
+ valTestHelper.assertNoWarnings(program, N4JSPackage.Literals.N4_MEMBER_DECLARATION,
+ IssueCodes.CLF_DUP_MEMBER.name());
}
@Test
@@ -145,6 +147,6 @@ class B extends A {
// bindings ok?
valTestHelper.assertNoErrors(program);
valTestHelper.assertNoWarnings(program, N4JSPackage.Literals.N4_MEMBER_DECLARATION,
- IssueCodes.CLF_OVERRIDE_ANNOTATION);
+ IssueCodes.CLF_OVERRIDE_ANNOTATION.name());
}
}
diff --git a/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/typesystem/AbstractScriptAssembler.java b/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/typesystem/AbstractScriptAssembler.java
index efcd43aa06..9f8b57c88f 100644
--- a/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/typesystem/AbstractScriptAssembler.java
+++ b/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/typesystem/AbstractScriptAssembler.java
@@ -28,6 +28,8 @@
import org.eclipse.n4js.n4JS.VariableDeclaration;
import org.eclipse.n4js.n4JS.VariableStatement;
import org.eclipse.n4js.ts.typeRefs.TypeRef;
+import org.eclipse.n4js.utils.Strings;
+import org.eclipse.n4js.validation.IssueCodes;
import org.eclipse.n4js.validation.JavaScriptVariant;
import org.eclipse.xtext.EcoreUtil2;
import org.eclipse.xtext.testing.util.ParseHelper;
@@ -125,11 +127,11 @@ protected Script setupScript(CharSequence scriptSrc, JavaScriptVariant variant,
return setupScript(scriptSrc, variant, null, expectedIssueCount);
}
- protected Script setupScript(CharSequence scriptSrc, JavaScriptVariant variant, String[] expectedMessages) {
+ protected Script setupScript(CharSequence scriptSrc, JavaScriptVariant variant, IssueCodes[] expectedMessages) {
return setupScript(scriptSrc, variant, expectedMessages, -1);
}
- protected Script setupScript(CharSequence scriptSrc, JavaScriptVariant variant, String[] expectedMessages,
+ protected Script setupScript(CharSequence scriptSrc, JavaScriptVariant variant, IssueCodes[] expectedMessages,
int expectedIssueCount) {
try {
@@ -140,7 +142,8 @@ protected Script setupScript(CharSequence scriptSrc, JavaScriptVariant variant,
assertEquals(join(",", map(issues, Issue::toString)) + "\nin\n" + scriptSrc, expectedIssueCount,
issues.size());
} else {
- assertEquals(String.join(",", expectedMessages), join(",", map(issues, Issue::getCode)));
+ assertEquals(Strings.join(",", ic -> ic.name(), expectedMessages),
+ join(",", map(issues, Issue::getCode)));
}
// newly created top level vars and
diff --git a/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/typesystem/AbstractTypeSystemHelperTests.java b/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/typesystem/AbstractTypeSystemHelperTests.java
index 2055696a58..d8ecfd9315 100644
--- a/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/typesystem/AbstractTypeSystemHelperTests.java
+++ b/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/typesystem/AbstractTypeSystemHelperTests.java
@@ -37,6 +37,7 @@
import org.eclipse.n4js.typesystem.utils.Result;
import org.eclipse.n4js.typesystem.utils.RuleEnvironment;
import org.eclipse.n4js.typesystem.utils.TypeSystemHelper;
+import org.eclipse.n4js.validation.IssueCodes;
import org.eclipse.n4js.validation.JavaScriptVariant;
import org.eclipse.xtext.xbase.lib.Pair;
@@ -135,10 +136,10 @@ public void assertSubTypeOfRef(String propertyRefName, SubTypeRelationForTest su
* {@link TypeRef#getTypeRefAsString()} is used.
*/
public void assertJoin(String expectedType, String... typeExpressionsToBeJoined) {
- assertJoin(new String[0], expectedType, typeExpressionsToBeJoined);
+ assertJoin(new IssueCodes[0], expectedType, typeExpressionsToBeJoined);
}
- public void assertJoin(String[] expectedMessages, String expectedType, String... typeExpressionsToBeJoined) {
+ public void assertJoin(IssueCodes[] expectedMessages, String expectedType, String... typeExpressionsToBeJoined) {
RuleEnvironment G = assembler.prepareScriptAndCreateRuleEnvironment(expectedMessages,
typeExpressionsToBeJoined);
Iterable typeRefs = map(Arrays.asList(typeExpressionsToBeJoined), tExp -> assembler.getTypeRef(tExp));
@@ -152,10 +153,10 @@ public void assertJoin(String[] expectedMessages, String expectedType, String...
* {@link TypeRef#getTypeRefAsString()} is used.
*/
public void assertMeet(String expectedType, String... typeExpressionsToBeMeet) {
- assertMeet(new String[0], expectedType, typeExpressionsToBeMeet);
+ assertMeet(new IssueCodes[0], expectedType, typeExpressionsToBeMeet);
}
- public void assertMeet(String[] expectedMessages, String expectedType, String... typeExpressionsToBeMeet) {
+ public void assertMeet(IssueCodes[] expectedMessages, String expectedType, String... typeExpressionsToBeMeet) {
RuleEnvironment G = assembler.prepareScriptAndCreateRuleEnvironment(expectedMessages, typeExpressionsToBeMeet);
Iterable typeRefs = map(Arrays.asList(typeExpressionsToBeMeet), tExp -> assembler.getTypeRef(tExp));
TypeRef meet = TypeUtils.copy(tsh.meet(G, typeRefs));
diff --git a/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/typesystem/JoinComputer_IntersectionTypesTest.java b/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/typesystem/JoinComputer_IntersectionTypesTest.java
index 6a5f3fcc08..b3accfd304 100644
--- a/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/typesystem/JoinComputer_IntersectionTypesTest.java
+++ b/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/typesystem/JoinComputer_IntersectionTypesTest.java
@@ -48,11 +48,11 @@ public void testJoinAssumptions() {
@Test
public void testJoinIntersectionWithElementFromIntersection() {
- assertJoin(new String[] { IssueCodes.INTER_REDUNDANT_SUPERTYPE }, "A", "A", "intersection{A,B}");
- assertJoin(new String[] { IssueCodes.INTER_REDUNDANT_SUPERTYPE }, "B", "B", "intersection{A,B}");
+ assertJoin(new IssueCodes[] { IssueCodes.INTER_REDUNDANT_SUPERTYPE }, "A", "A", "intersection{A,B}");
+ assertJoin(new IssueCodes[] { IssueCodes.INTER_REDUNDANT_SUPERTYPE }, "B", "B", "intersection{A,B}");
assertJoin("R1", "R1", "intersection{A,R1}");
assertJoin("N4Object", "D", "intersection{A,R1}", "A");
- assertJoin(new String[] { IssueCodes.INTER_REDUNDANT_SUPERTYPE }, "A", "B", "intersection{A,B}", "A");
+ assertJoin(new IssueCodes[] { IssueCodes.INTER_REDUNDANT_SUPERTYPE }, "A", "B", "intersection{A,B}", "A");
}
@Test
@@ -60,7 +60,7 @@ public void testJoinWithIntersections() {
assertJoin("intersection{I1,R1}", "intersection{I1,R1}", "intersection{I1,R1}");
assertJoin("intersection{I1,R1}", "intersection{I1,R1,Q1}", "intersection{I1,R1}");
assertJoin("intersection{A,R1}", "intersection{A,R1}", "intersection{B,R1}");
- assertJoin(new String[] { IssueCodes.INTER_REDUNDANT_SUPERTYPE, IssueCodes.INTER_REDUNDANT_SUPERTYPE }, "B",
+ assertJoin(new IssueCodes[] { IssueCodes.INTER_REDUNDANT_SUPERTYPE, IssueCodes.INTER_REDUNDANT_SUPERTYPE }, "B",
"intersection{A,B}", "intersection{A,B}");
}
diff --git a/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/typesystem/JoinComputer_UnionTypesTest.java b/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/typesystem/JoinComputer_UnionTypesTest.java
index f2c63d2b3f..75d0df3ce4 100644
--- a/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/typesystem/JoinComputer_UnionTypesTest.java
+++ b/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/typesystem/JoinComputer_UnionTypesTest.java
@@ -47,16 +47,17 @@ public void testJoinAsumptions() {
@Test
public void testJoinSimpleWithUnions() {
- assertJoin(new String[] { IssueCodes.UNI_REDUNDANT_SUBTYPE }, "A", "A", "union{A,B}");
- assertJoin(new String[] { IssueCodes.UNI_REDUNDANT_SUBTYPE }, "A", "union{A,B}", "A");
- assertJoin(new String[] { IssueCodes.UNI_REDUNDANT_SUBTYPE }, "A", "A", "union{B,A}");
+ assertJoin(new IssueCodes[] { IssueCodes.UNI_REDUNDANT_SUBTYPE }, "A", "A", "union{A,B}");
+ assertJoin(new IssueCodes[] { IssueCodes.UNI_REDUNDANT_SUBTYPE }, "A", "union{A,B}", "A");
+ assertJoin(new IssueCodes[] { IssueCodes.UNI_REDUNDANT_SUBTYPE }, "A", "A", "union{B,A}");
}
@Test
public void testJoinUnionWithUnions() {
- assertJoin(new String[] { IssueCodes.UNI_REDUNDANT_SUBTYPE, IssueCodes.UNI_REDUNDANT_SUBTYPE }, "union{A,B,C}",
+ assertJoin(new IssueCodes[] { IssueCodes.UNI_REDUNDANT_SUBTYPE, IssueCodes.UNI_REDUNDANT_SUBTYPE },
+ "union{A,B,C}",
"union{A,B}", "union{B,C}");
- assertJoin(new String[] { IssueCodes.UNI_REDUNDANT_SUBTYPE }, "B", "C", "union{B,C}");
+ assertJoin(new IssueCodes[] { IssueCodes.UNI_REDUNDANT_SUBTYPE }, "B", "C", "union{B,C}");
}
@Test
@@ -67,9 +68,9 @@ public void testJoinWithUnionsAndGenerics() {
// lower A ^ union{A,B} = B
// union{A,B} ... B
// TODO: why not G?
- assertJoin(new String[] { IssueCodes.UNI_REDUNDANT_SUBTYPE }, "G extends A>", "G ", "G");
+ assertJoin(new IssueCodes[] { IssueCodes.UNI_REDUNDANT_SUBTYPE }, "G extends A>", "G", "G");
- assertJoin(new String[] { IssueCodes.UNI_REDUNDANT_SUBTYPE }, "union{A,B,G}", "G ", "union{A,B}");
+ assertJoin(new IssueCodes[] { IssueCodes.UNI_REDUNDANT_SUBTYPE }, "union{A,B,G }", "G ", "union{A,B}");
}
}
diff --git a/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/typesystem/MeetComputer_UnionTypesTest.java b/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/typesystem/MeetComputer_UnionTypesTest.java
index 8b493a7f4c..6167e65ad2 100644
--- a/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/typesystem/MeetComputer_UnionTypesTest.java
+++ b/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/typesystem/MeetComputer_UnionTypesTest.java
@@ -34,10 +34,10 @@ public void prepareTypeDefs() {
@Test
public void testMeetWithUnion() {
- assertMeet(new String[] { IssueCodes.UNI_REDUNDANT_SUBTYPE }, "B", "A", "union{A,B}");
- assertMeet(new String[] { IssueCodes.UNI_REDUNDANT_SUBTYPE }, "B", "B", "union{A,B}");
- assertMeet(new String[] { IssueCodes.UNI_REDUNDANT_SUBTYPE }, "C", "A", "union{B,C}");
- assertMeet(new String[] { IssueCodes.UNI_REDUNDANT_SUBTYPE }, "C", "C", "union{B,C}");
+ assertMeet(new IssueCodes[] { IssueCodes.UNI_REDUNDANT_SUBTYPE }, "B", "A", "union{A,B}");
+ assertMeet(new IssueCodes[] { IssueCodes.UNI_REDUNDANT_SUBTYPE }, "B", "B", "union{A,B}");
+ assertMeet(new IssueCodes[] { IssueCodes.UNI_REDUNDANT_SUBTYPE }, "C", "A", "union{B,C}");
+ assertMeet(new IssueCodes[] { IssueCodes.UNI_REDUNDANT_SUBTYPE }, "C", "C", "union{B,C}");
}
}
diff --git a/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/typesystem/TypeRefsToVariablesAssembler.java b/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/typesystem/TypeRefsToVariablesAssembler.java
index 70a56e5fdb..7d4e34665d 100644
--- a/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/typesystem/TypeRefsToVariablesAssembler.java
+++ b/tests/org.eclipse.n4js.lang.tests/src/org/eclipse/n4js/typesystem/TypeRefsToVariablesAssembler.java
@@ -13,6 +13,7 @@
import org.eclipse.n4js.n4JS.Script;
import org.eclipse.n4js.typesystem.utils.RuleEnvironment;
import org.eclipse.n4js.typesystem.utils.RuleEnvironmentExtensions;
+import org.eclipse.n4js.validation.IssueCodes;
import org.eclipse.n4js.validation.JavaScriptVariant;
import org.eclipse.xtext.xbase.lib.Pair;
@@ -29,10 +30,10 @@
public class TypeRefsToVariablesAssembler extends AbstractScriptAssembler {
/**
- * Convenience method for method {@link #prepareScriptAndCreateRuleEnvironment(String[], String...)}.
+ * Convenience method for method {@link #prepareScriptAndCreateRuleEnvironment(IssueCodes[], String...)}.
*/
public RuleEnvironment prepareScriptAndCreateRuleEnvironment(String... typeExpressions) {
- return prepareScriptAndCreateRuleEnvironment(new String[0], JavaScriptVariant.n4js, typeExpressions);
+ return prepareScriptAndCreateRuleEnvironment(new IssueCodes[0], JavaScriptVariant.n4js, typeExpressions);
}
/**
@@ -50,21 +51,23 @@ public RuleEnvironment prepareScriptAndCreateRuleEnvironment(String... typeExpre
*
* @return the rule environment to be used when type system rules are called.
*/
- public RuleEnvironment prepareScriptAndCreateRuleEnvironment(String[] expectedMessages, String... typeExpressions) {
+ public RuleEnvironment prepareScriptAndCreateRuleEnvironment(IssueCodes[] expectedMessages,
+ String... typeExpressions) {
return prepareScriptAndCreateRuleEnvironment(expectedMessages, JavaScriptVariant.n4js, typeExpressions);
}
- public RuleEnvironment prepareScriptAndCreateRuleEnvironment(String[] expectedMessages, JavaScriptVariant variant,
+ public RuleEnvironment prepareScriptAndCreateRuleEnvironment(IssueCodes[] expectedMessages,
+ JavaScriptVariant variant,
String... typeExpressions) {
return doPrepareScriptAndCreateRuleEnvironment(expectedMessages, variant, typeExpressions).getValue();
}
public Pair