use of org.eclipse.n4js.ts.types.TVariable in project n4js by eclipse.
the class N4JSResourceDescription method getCrossRefTypeAcceptor.
private IAcceptor<EObject> getCrossRefTypeAcceptor(final Set<EObject> crossRefTypesAddHere) {
IAcceptor<EObject> acceptor = new IAcceptor<EObject>() {
@Override
public void accept(EObject to) {
if (to instanceof Type || to instanceof TVariable || to instanceof TEnumLiteral) {
crossRefTypesAddHere.add(to);
}
// Add declared type of a field to cross ref types
if (to instanceof TFunction) {
TypeRef returnTypeRef = ((TFunction) to).getReturnTypeRef();
crossRefTypesAddHere.add(returnTypeRef.getDeclaredType());
}
if (to instanceof TField) {
TypeRef typeRef = ((TField) to).getTypeRef();
crossRefTypesAddHere.add(typeRef.getDeclaredType());
}
// In case of TMember, add the containing type as well
if (to instanceof TMember) {
TMember casted = (TMember) to;
ContainerType<?> declaringType = casted.getContainingType();
crossRefTypesAddHere.add(declaringType);
}
}
};
return acceptor;
}
use of org.eclipse.n4js.ts.types.TVariable in project n4js by eclipse.
the class N4JSResourceDescriptionStrategy method createEObjectDescriptions.
@Override
public boolean createEObjectDescriptions(final EObject eObject, IAcceptor<IEObjectDescription> acceptor) {
if (getQualifiedNameProvider() == null)
return false;
if (eObject instanceof TModule) {
TModule module = (TModule) eObject;
internalCreateEObjectDescriptionForRoot(module, acceptor);
for (Type type : module.getTopLevelTypes()) {
internalCreateEObjectDescription(type, acceptor);
}
for (TVariable variable : module.getVariables()) {
internalCreateEObjectDescription(variable, acceptor);
}
}
// export is only possible for top-level elements
return false;
}
use of org.eclipse.n4js.ts.types.TVariable in project n4js by eclipse.
the class VisibilityAwareIdentifiableScope method isAccepted.
@Override
protected boolean isAccepted(IEObjectDescription description) {
EObject proxyOrInstance = description.getEObjectOrProxy();
if (proxyOrInstance instanceof TVariable && !proxyOrInstance.eIsProxy()) {
TVariable type = (TVariable) proxyOrInstance;
TypeVisibility visibility = checker.isVisible(this.contextResource, type);
if (!visibility.visibility) {
this.accessModifierSuggestionStore.put(description.getEObjectURI().toString(), visibility.accessModifierSuggestion);
}
return visibility.visibility;
}
return super.isAccepted(description);
}
use of org.eclipse.n4js.ts.types.TVariable in project n4js by eclipse.
the class N4JSDReader method readScripts.
/**
* Reads all N4JSD files in project and scans for types. No further information is added yet. Reads all types into a
* map with fully qualified type name (inclusive module spec) as key, the type info only contains the types, no
* other information yet.
*
* @param specInfoByName
* map of fqn of types or reqid keys to their corresponding spec info.
* @throws InterruptedException
* thrown when user cancels the operation
*/
private void readScripts(Multimap<String, SpecInfo> specInfoByName, IN4JSProject project, ResourceSet resSet, SubMonitorMsg monitor) throws InterruptedException {
ImmutableList<? extends IN4JSSourceContainer> srcCont = project.getSourceContainers();
List<IN4JSSourceContainer> srcContFilter = new LinkedList<>();
int count = 0;
for (IN4JSSourceContainer container : srcCont) {
if (container.isSource() || container.isTest()) {
count += Iterables.size(container);
srcContFilter.add(container);
}
}
SubMonitorMsg sub = monitor.convert(count);
for (IN4JSSourceContainer container : srcContFilter) {
for (URI uri : container) {
String ext = uri.fileExtension();
if ("n4js".equals(ext) || "n4jsd".equals(ext)) {
try {
Resource resource = resSet.getResource(uri, true);
if (resource != null) {
Script script = (Script) (resource.getContents().isEmpty() ? null : resource.getContents().get(0));
if (script == null) {
// throw new IllegalStateException("Error parsing " + uri);
continue;
}
N4JSResource.postProcess(resource);
for (Type type : getRealTopLevelTypes(script)) {
createTypeSpecInfo(type, specInfoByName);
}
for (TVariable tvar : script.getModule().getVariables()) {
createTVarSpecInfo(tvar, specInfoByName);
}
}
} catch (Exception ex) {
ex.printStackTrace();
String msg = "Error processing " + uri + ": " + ex.getMessage();
throw new IllegalArgumentException(msg, ex);
}
}
sub.worked(1);
sub.checkCanceled();
}
}
}
use of org.eclipse.n4js.ts.types.TVariable in project n4js by eclipse.
the class SpecModuleFile method add.
/**
* Adds another region change entry to this file.
*/
@Override
public void add(SpecSection specElem) {
if (!(specElem instanceof SpecIdentifiableElementSection))
return;
SpecIdentifiableElementSection specIE = (SpecIdentifiableElementSection) specElem;
EObject container = specIE.idElement.eContainer();
if (container instanceof Type) {
addTypeElement((Type) container, specIE);
return;
}
if (specIE.idElement instanceof TFunction) {
functions.add(specIE);
allSections.add(specIE);
return;
}
if (specIE.idElement instanceof TVariable) {
variables.add(specIE);
allSections.add(specIE);
return;
}
if (specIE.idElement instanceof Type) {
addTypeElement((Type) specIE.idElement, specIE);
return;
}
throw new RuntimeException("Missing Implementation");
}
Aggregations