org.eclipse.xtext.resource.CompilerPhases Java Examples

The following examples show how to use org.eclipse.xtext.resource.CompilerPhases. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WriteNewResourceDescriptionsImplementation.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
public WriteNewResourceDescriptionsImplementation(N4ClusteringBuilderState state, BuildData buildData,
		IResourceDescriptions oldState,
		CurrentDescriptions newState, IProgressMonitor monitor,
		IBuildLogger buildLogger,
		IResourceLoader globalIndexResourceLoader,
		IResourceClusteringPolicy clusteringPolicy, CompilerPhases compilerPhases) {
	this.compilerPhases = compilerPhases;
	this.clusteringPolicy = clusteringPolicy;
	this.globalIndexResourceLoader = globalIndexResourceLoader;
	this.state = state;
	this.buildData = buildData;
	this.oldState = oldState;
	this.newState = newState;
	this.progress = SubMonitor.convert(monitor, buildData.getToBeUpdated().size());
	this.buildLogger = buildLogger;
	this.resourceSet = buildData.getResourceSet();
	this.currentProject = state.getBuiltProject(buildData);
}
 
Example #2
Source File: JvmDeclaredTypeImplCustom.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
protected Map<String, Set<JvmDeclaredType>> internalGetAllNestedTypesMap(final Set<JvmDeclaredType> processedTypes) {
	try {
		if (allNestedTypesByName == null) {
			final Set<JvmDeclaredType> processedSuperTypes = processedTypes == null ? Sets.<JvmDeclaredType>newHashSet() : processedTypes;
			allNestedTypesByName = doSynchronized(new Provider<Map<String, Set<JvmDeclaredType>>>() {
				@Override
				public Map<String, Set<JvmDeclaredType>> get() {
					if (allNestedTypesByName != null)
						return allNestedTypesByName;
					Map<String, Set<JvmDeclaredType>> result = Maps.newLinkedHashMap();
					processTypes(result, getMembers());
					Map<String, Set<JvmDeclaredType>> cumulated = Maps.newLinkedHashMap();
					for (JvmTypeReference superTypeReference : getSuperTypes()) {
						JvmType superType = getRawType(superTypeReference);
						if (superType instanceof JvmDeclaredTypeImplCustom && !superType.eIsProxy()
								&& !processedSuperTypes.contains(superType)) {
							processedSuperTypes.add((JvmDeclaredType) superType);
							Map<String, Set<JvmDeclaredType>> superTypeMap = ((JvmDeclaredTypeImplCustom) superType)
									.internalGetAllNestedTypesMap(processedSuperTypes);
							processedSuperTypes.remove(superType);
							for(Map.Entry<String, Set<JvmDeclaredType>> entry: superTypeMap.entrySet()) {
								if (!result.containsKey(entry.getKey())) {
									processTypes(cumulated, entry.getValue());
								}
							}
						}
					}
					result.putAll(cumulated);
					Runnable runnable = new Runnable() {
						@Override
						public void run() {
							doSynchronized(new Provider<Object>() {
								@Override
								public Object get() {
									allNestedTypesByName = null;
									return null;
								}});
						}
					};
					requestNotificationOnChange(runnable);
					return result;
				}
			});
		}
		return allNestedTypesByName;
	} finally {
		// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=474238
		// no caching for Xtext-based resources during indexing
		if (eResource() instanceof XtextResource) {
			XtextResource xtextResource = (XtextResource) eResource();
			CompilerPhases compilerPhases = xtextResource.getResourceServiceProvider().get(CompilerPhases.class);
			if (compilerPhases.isIndexing(xtextResource.getResourceSet())) {
				allNestedTypesByName = null;
			}
		}
	}
}