use of org.eclipse.n4js.workspace.N4JSSourceFolderSnapshotForPackageJson in project n4js by eclipse.
the class N4JSLanguageHelper method isDirectoryWithPackageJson.
private boolean isDirectoryWithPackageJson(IResourceDescriptions index, TModule targetModule, QualifiedName targetQN) {
// NOTE: the following approach would be a more elegant implementation of this method, but would require a
// different computation of FQNs for package.json files in source folders (in N4JSQualifiedNameProvider):
// @formatter:off
// Iterable<IEObjectDescription> matchingPackageJsonDesc = index.getExportedObjects(
// JSONPackage.Literals.JSON_DOCUMENT,
// targetQN.append(N4JSQualifiedNameProvider.PACKAGE_JSON_SEGMENT), false);
// if (matchingPackageJsonDesc.iterator().hasNext()) {
// return true;
// }
// @formatter:on
N4JSProjectConfigSnapshot targetProject = replaceDefinitionProjectByDefinedProject(targetModule, workspaceAccess.findProjectContaining(targetModule), true);
if (targetProject == null) {
return false;
}
int segCount = targetQN.getSegments().size();
String[] segments = new String[segCount + 1];
for (int i = 0; i < segCount; i++) {
segments[i] = targetQN.getSegments().get(i);
}
segments[segCount] = N4JSGlobals.PACKAGE_JSON;
for (N4JSSourceFolderSnapshot srcFolder : targetProject.getSourceFolders()) {
if (srcFolder instanceof N4JSSourceFolderSnapshotForPackageJson) {
continue;
}
FileURI packageJsonURI = srcFolder.getPathAsFileURI().appendSegments(segments);
if (index.getResourceDescription(packageJsonURI.toURI()) != null) {
return true;
}
}
return false;
}
Aggregations