use of org.eclipse.n4js.packagejson.PackageJsonProperties.SOURCES in project n4js by eclipse.
the class PackageJsonValidatorExtension method checkSourceContainers.
/**
* Validates the source container section of N4JS package.json files
*/
@CheckProperty(property = SOURCES)
public void checkSourceContainers() {
// obtain source-container-related content of the section and validate its structure
Multimap<SourceContainerType, List<JSONStringLiteral>> sourceContainers = getSourceContainers();
final List<JSONStringLiteral> allDeclaredSourceContainers = sourceContainers.entries().stream().flatMap(entry -> entry.getValue().stream()).collect(Collectors.toList());
// check each source container sub-section (e.g. sources, external, etc.)
final List<JSONStringLiteral> validSourceContainerLiterals = allDeclaredSourceContainers.stream().filter(l -> internalCheckSourceContainerLiteral(l)).collect(Collectors.toList());
// find all groups of duplicate paths
final List<List<JSONStringLiteral>> containerDuplicates = findPathDuplicates(allDeclaredSourceContainers);
for (List<JSONStringLiteral> duplicateGroup : containerDuplicates) {
// indicates whether the duplicates are spread across multiple container types (e.g. external, sources)
final String normalizedPath = FileUtils.normalize(duplicateGroup.get(0).getValue());
for (JSONStringLiteral duplicate : duplicateGroup) {
final String inClause = createInSourceContainerTypeClause(duplicate, duplicateGroup);
addIssue(IssueCodes.getMessageForPKGJ_DUPLICATE_SOURCE_CONTAINER(normalizedPath, inClause), duplicate, IssueCodes.PKGJ_DUPLICATE_SOURCE_CONTAINER);
}
}
// check for nested source containers (within valid source container literals)
internalCheckNoNestedSourceContainers(validSourceContainerLiterals);
}
Aggregations