use of org.eclipse.n4js.ts.types.TModule in project n4js by eclipse.
the class AmbiguousImportDescription method getMessage.
@Override
public String getMessage() {
StringBuilder typeListStr = new StringBuilder();
IdentifiableElement first = (IdentifiableElement) EcoreUtil.resolve(getEObjectOrProxy(), context);
String typeIdent = first instanceof Type ? "type" : "variable";
TModule module = (TModule) first.eContainer();
typeListStr.append(module.getQualifiedName());
Set<IdentifiableElement> uniqueTypes = Sets.newLinkedHashSet(elements);
uniqueTypes.remove(first);
Iterator<IdentifiableElement> iter = uniqueTypes.iterator();
while (iter.hasNext()) {
IdentifiableElement type = iter.next();
if (iter.hasNext()) {
typeListStr.append(", ");
} else {
typeListStr.append(" and ");
}
typeListStr.append(((TModule) type.eContainer()).getQualifiedName());
}
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(getName(), "stub");
}
return "Unknown ambiguous import issue: " + this.issueCode + " for " + context + ".";
}
use of org.eclipse.n4js.ts.types.TModule in project n4js by eclipse.
the class ImportProvidedElementLabelprovider method getText.
@Override
public String getText(Object element) {
if (element instanceof ImportableObject) {
ImportableObject io = (ImportableObject) element;
return getText(io.getTe());
}
if (element instanceof ImportProvidedElement) {
ImportProvidedElement ele = ((ImportProvidedElement) element);
TModule tm = ((ImportDeclaration) ele.getImportSpecifier().eContainer()).getModule();
return ele.getLocalName() + " from " + findLocation(tm);
}
if (element instanceof IEObjectDescription) {
IEObjectDescription ieod = (IEObjectDescription) element;
EObject eo = ieod.getEObjectOrProxy();
if (eo instanceof TExportableElement && !eo.eIsProxy()) {
return getText(eo);
}
return ieod.getName().getLastSegment() + " from " + qualifiedNameConverter.toString(ieod.getName().skipLast(1));
}
if (element instanceof TExportableElement) {
TExportableElement te = (TExportableElement) element;
return te.getName() + " (exported as " + te.getExportedName() + ") from " + findLocation(te.getContainingModule());
}
return n4Labelprovider.getText(element);
}
use of org.eclipse.n4js.ts.types.TModule in project n4js by eclipse.
the class ImportsFactory method createImportDeclaration.
private ImportDeclaration createImportDeclaration(Adapter nodelessMarker, String moduleName) {
ImportDeclaration ret = N4JS_FACTORY.createImportDeclaration();
TModule tmodule = TYPES_FACTORY.createTModule();
tmodule.setQualifiedName(moduleName);
ret.setModule(tmodule);
ret.eAdapters().add(nodelessMarker);
return ret;
}
use of org.eclipse.n4js.ts.types.TModule in project n4js by eclipse.
the class ImportsFactory method createNamedImport.
/**
* Creates a new named import of 'name' from 'module'
*/
private ImportDeclaration createNamedImport(String name, IN4JSProject contextProject, TExportableElement te, Adapter nodelessMarker) {
TModule tmodule = te.getContainingModule();
IN4JSProject targetProject = core.findProject(te.eResource().getURI()).orNull();
String moduleQN;
if (targetProject != null && tmodule.getQualifiedName().toString().equals(targetProject.getMainModule())) {
// If the project has a main module, use project import instead.
moduleQN = targetProject.getProjectId();
} else {
// Standard case
moduleQN = te.getContainingModule().getQualifiedName();
}
QualifiedName qn = qualifiedNameConverter.toQualifiedName(moduleQN);
String firstSegment = qn.getFirstSegment();
IN4JSProject project = ImportSpecifierUtil.getDependencyWithID(firstSegment, contextProject);
return createImportDeclaration(qn, name, project, nodelessMarker, this::addNamedImport);
}
use of org.eclipse.n4js.ts.types.TModule in project n4js by eclipse.
the class ProjectCompareHelper method findImplementation.
private TModule findImplementation(TModule moduleApi, IN4JSProject projectImpl, ResourceSet resourceSet, IResourceDescriptions index) {
final String fqnStr = moduleApi.getQualifiedName();
final URI uri = artifactHelper.findArtifact(projectImpl, fqnStr, Optional.of(N4JSGlobals.N4JS_FILE_EXTENSION));
if (uri == null)
return null;
final IResourceDescription resDesc = index.getResourceDescription(uri);
if (resDesc == null)
return null;
final TModule moduleImpl = getModuleFrom(resourceSet, resDesc);
return moduleImpl;
}
Aggregations