use of org.eclipse.n4js.packagejson.PackageJsonProperties.IMPLEMENTED_PROJECTS in project n4js by eclipse.
the class PackageJsonValidatorExtension method checkImplementedProjects.
/**
* Validates basic properties of the list of {@code n4js.implementedProjects}.
*/
@CheckProperty(property = IMPLEMENTED_PROJECTS)
public void checkImplementedProjects(JSONValue value) {
// check for correct types of implementedProjects
if (!checkIsType(value, JSONPackage.Literals.JSON_ARRAY, "as list of implemented projects")) {
return;
}
// check for correct types of all implementedProjects elements (they represent project references)
final List<JSONValue> implementedProjectValues = ((JSONArray) value).getElements();
List<JSONStringLiteral> implementedProjectLiterals = implementedProjectValues.stream().map(v -> {
if (!checkIsType(v, JSONPackage.Literals.JSON_STRING_LITERAL, "as implemented project reference")) {
return null;
}
return ((JSONStringLiteral) v);
}).filter(p -> p != null).collect(Collectors.toList());
// obtain the declared project name (name property)
final JSONStringLiteral declaredProjectNameValue = getSingleDocumentValue(NAME, JSONStringLiteral.class);
// exit early if project name cannot be determined
if (declaredProjectNameValue == null) {
return;
}
for (JSONStringLiteral implementedProjectLiteral : implementedProjectLiterals) {
if (implementedProjectLiteral.getValue().equals(declaredProjectNameValue.getValue())) {
// reflexive implementation
addIssue(IssueCodes.getMessageForPKGJ_APIIMPL_REFLEXIVE(), implementedProjectLiteral, IssueCodes.PKGJ_APIIMPL_REFLEXIVE);
}
}
}
Aggregations