Skip to content

Commit

Permalink
"duplicate" issue codes in Xbase
Browse files Browse the repository at this point in the history
  • Loading branch information
LorenzoBettini committed Feb 5, 2024
1 parent c3058a5 commit 42c3838
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -953,10 +953,10 @@ public void clearPreferences() {
@Test public void testClassUniqueNames() throws Exception {
var source = "class Foo {} class Foo {}";
XtendClass clazz = clazz(source);
helper.assertError(clazz, XTEND_CLASS, DUPLICATE_TYPE_NAME,
helper.assertError(clazz, XTEND_CLASS, DUPLICATE_TYPE,
source.indexOf("Foo"), "Foo".length(),
"type", "already defined");
helper.assertError(clazz, XTEND_CLASS, DUPLICATE_TYPE_NAME,
helper.assertError(clazz, XTEND_CLASS, DUPLICATE_TYPE,
source.lastIndexOf("Foo"), "Foo".length(),
"type", "already defined");
}
Expand All @@ -981,14 +981,14 @@ public void clearPreferences() {

@Test public void testTypesUniqueNames() throws Exception {
XtendFile file = file("class Foo {} interface Foo {} annotation Foo {}");
helper.assertError(file, XTEND_INTERFACE, DUPLICATE_TYPE_NAME, "type", "already defined");
helper.assertError(file, XTEND_ANNOTATION_TYPE, DUPLICATE_TYPE_NAME, "type", "already defined");
helper.assertError(file, XTEND_INTERFACE, DUPLICATE_TYPE, "type", "already defined");
helper.assertError(file, XTEND_ANNOTATION_TYPE, DUPLICATE_TYPE, "type", "already defined");
}

@Test public void testNestedTypesUniqueNames() throws Exception {
XtendFile file = file("class C { static class Foo {} interface Foo {} annotation Foo {} }");
helper.assertError(file, XTEND_INTERFACE, DUPLICATE_TYPE_NAME, "Duplicate nested type Foo");
helper.assertError(file, XTEND_ANNOTATION_TYPE, DUPLICATE_TYPE_NAME, "Duplicate nested type Foo");
helper.assertError(file, XTEND_INTERFACE, DUPLICATE_TYPE, "Duplicate nested type Foo");
helper.assertError(file, XTEND_ANNOTATION_TYPE, DUPLICATE_TYPE, "Duplicate nested type Foo");
}

@Test public void testNestedTypesOuterNameShadowing() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ private IssueCodes() {
public static final String WRONG_PACKAGE = ISSUE_CODE_PREFIX + "wrong_package";
public static final String WRONG_FILE = ISSUE_CODE_PREFIX + "wrong_file";
public static final String DUPLICATE_METHOD = ISSUE_CODE_PREFIX + "duplicate_method";
public static final String DUPLICATE_FIELD = ISSUE_CODE_PREFIX + "duplicate_field";
public static final String DUPLICATE_TYPE_NAME = org.eclipse.xtext.xbase.validation.IssueCodes.DUPLICATE_TYPE;
public static final String CONFLICTING_DEFAULT_METHODS = ISSUE_CODE_PREFIX + "conflicting_default_methods";
public static final String MISSING_ABSTRACT = ISSUE_CODE_PREFIX + "missing_abstract";
public static final String MISSING_ABSTRACT_IN_ANONYMOUS = ISSUE_CODE_PREFIX + "missing_abstract_in_anonymous";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ public void checkMemberNamesAreUnique(XtendTypeDeclaration xtendType) {
Collection<XtendTypeDeclaration> types = name2type.get(name);
if(types.size() >1) {
for(XtendTypeDeclaration type: types)
error("Duplicate nested type " + name, type, XtendPackage.Literals.XTEND_TYPE_DECLARATION__NAME, DUPLICATE_TYPE_NAME);
error("Duplicate nested type " + name, type, XtendPackage.Literals.XTEND_TYPE_DECLARATION__NAME, DUPLICATE_TYPE);
}
}
for(JvmType type: type2extension.keySet()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ public class IssueCodes extends org.eclipse.xtext.validation.IssueCodes {
* @since 2.34
*/
public static final String DUPLICATE_PARAMETER_NAME = ISSUE_CODE_PREFIX + "duplicate_parameter_name";
/**
* @since 2.34
*/
public static final String DUPLICATE_FIELD = ISSUE_CODE_PREFIX + "duplicate_field";

private IssueCodes() {
}
Expand Down

0 comments on commit 42c3838

Please sign in to comment.