當前位置: 首頁>>代碼示例>>Java>>正文


Java EcoreUtil.getAdapter方法代碼示例

本文整理匯總了Java中org.eclipse.emf.ecore.util.EcoreUtil.getAdapter方法的典型用法代碼示例。如果您正苦於以下問題:Java EcoreUtil.getAdapter方法的具體用法?Java EcoreUtil.getAdapter怎麽用?Java EcoreUtil.getAdapter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.emf.ecore.util.EcoreUtil的用法示例。


在下文中一共展示了EcoreUtil.getAdapter方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: updateMarkers

import org.eclipse.emf.ecore.util.EcoreUtil; //導入方法依賴的package包/類
@Override
protected void updateMarkers(Delta delta, ResourceSet resourceSet, IProgressMonitor monitor) {
	Measurement mes = dcValidations.getMeasurement("validation");
	super.updateMarkers(delta, resourceSet, monitor);
	mes.end();

	if (resourceSet != null) { // resourceSet is null during clean build
		mes = dcTranspilation.getMeasurement("transpilation");
		IBuildParticipantInstruction instruction = (IBuildParticipantInstruction) EcoreUtil.getAdapter(
				resourceSet.eAdapters(), IBuildParticipantInstruction.class);
		if (instruction == null) {
			throw new IllegalStateException();
		}
		try {
			instruction.process(delta, resourceSet, monitor);
		} catch (CoreException e) {
			handleCoreException(e);
		}
		mes.end();
	}

}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:23,代碼來源:N4JSGenerateImmediatelyBuilderState.java

示例2: getOrCreate

import org.eclipse.emf.ecore.util.EcoreUtil; //導入方法依賴的package包/類
@Override
public CacheAdapter getOrCreate(Resource resource) {
	// copied from super method, but we expect N4JSCacheAdapter here
	// note: if you got a cast exception here (because the adapter is not an N4JSCacheAdapter but a simple one),
	// you probably have loaded a resource via the wrong scope provider. That is, you probably tried to
	// load a non-N4JS resource with an n4js provider (maybe vice versa...).
	// In order to solve that problem, use the org.eclipse.xtext.resource.IResourceServiceProvider.Registry
	// to get the correct providers for the N4JS language.
	// a nice example is found in:
	// org.eclipse.n4js.validation.validators.N4JSProjectSetupValidator.getAllPolyfills(Resource)
	N4JSCacheAdapter adapter = (N4JSCacheAdapter) EcoreUtil.getAdapter(resource.eAdapters(), CacheAdapter.class);
	if (adapter == null) {
		adapter = new N4JSCacheAdapter(); // changed from CacheAdapter to N4JSCacheAdapter
		resource.eAdapters().add(adapter);
		adapter.setResource(resource);
	}
	return adapter;
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:19,代碼來源:N4JSCache.java

示例3: invokeInternal

import org.eclipse.emf.ecore.util.EcoreUtil; //導入方法依賴的package包/類
@Override
protected void invokeInternal(WorkflowContext ctx, ProgressMonitor monitor,
		Issues issues) {
	ResourceSet resourceSet = getResourceSet();

	// due to some Xcore peculiarity we have to access the IAllContainerState here
	// to trigger some lazy init logic
	IAllContainersState allContainerState = (IAllContainersState) EcoreUtil.getAdapter(resourceSet.eAdapters(),
			IAllContainersState.class);
	allContainerState.isEmpty("");

	Multimap<String, URI> uris = getPathTraverser().resolvePathes(pathes,
			new Predicate<URI>() {
		@Override
		public boolean apply(URI input) {
			return input.fileExtension().equals(XCORE_FILE_EXT);
		}
	});
	List<Resource> resources = new ArrayList<>();
	for (URI uri : uris.values()) {
		LOGGER.info(uri);
		try {
			resources.add(parse(uri, resourceSet));
		} catch (Exception e) {
			LOGGER.error("Problem during loading of resource @ " + uri, e);
		}
	}
	installIndex(resourceSet);
	for (Resource r : resources) {
		EcoreUtil.resolveAll(r);
		for (Diagnostic x : r.getErrors()) {
			issues.addError(x.getMessage(), x);
		}

	}
	ctx.set(slot, resources);
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:38,代碼來源:XcoreReader.java

示例4: registerBuiltInTypeScope

import org.eclipse.emf.ecore.util.EcoreUtil; //導入方法依賴的package包/類
/**
 * Assign the given scope to the given resource set by means of an Adapter.
 */
public static void registerBuiltInTypeScope(BuiltInTypeScope scope, ResourceSet context) {
	if (EcoreUtil.getAdapter(context.eAdapters(), BuiltInTypeScope.class) != null) {
		throw new IllegalStateException("Attempt to install adapter for BuiltInTypeScope twice");
	}
	BuiltInTypeScopeAccess adapter = new BuiltInTypeScopeAccess(scope);
	context.eAdapters().add(adapter);
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:11,代碼來源:BuiltInTypeScopeAccess.java

示例5: get

import org.eclipse.emf.ecore.util.EcoreUtil; //導入方法依賴的package包/類
/**
 * Obtains an instance in the context of the given resourceSet.
 * <p>
 * This is the preferred method of creating a BuiltInTypeScope if code needs to access built-in types. But note that
 * there are convenience methods available in RuleEnvironmentExtensions; so, if a RuleEnvironment is already
 * available those methods should be used.
 */
public static BuiltInTypeScope get(ResourceSet resourceSet) {
	BuiltInTypeScopeAccess result = (BuiltInTypeScopeAccess) EcoreUtil.getAdapter(resourceSet.eAdapters(),
			BuiltInTypeScope.class);
	if (result == null) {
		throw new IllegalStateException("Missing adapter for BuiltInTypeScope");
	}
	return result.getScope();
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:16,代碼來源:BuiltInTypeScope.java

示例6: build

import org.eclipse.emf.ecore.util.EcoreUtil; //導入方法依賴的package包/類
@Override
public void build(IBuildContext context, IProgressMonitor monitor) throws CoreException {
	IBuildParticipantInstruction delegate = (IBuildParticipantInstruction) EcoreUtil.getAdapter(context
			.getResourceSet().eAdapters(), IBuildParticipantInstruction.class);
	if (delegate == null) {
		if (context.getBuildType() == BuildType.CLEAN) {
			super.build(context, monitor);
		}
	} else {
		delegate.finish(context.getDeltas(), monitor);
		if (delegate.isRebuild()) {
			context.needRebuild();
		}
	}
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:16,代碼來源:N4JSBuilderParticipant.java

示例7: installIndex

import org.eclipse.emf.ecore.util.EcoreUtil; //導入方法依賴的package包/類
private void installIndex(ResourceSet resourceSet) {
	// Fill index
	ResourceDescriptionsData index = new OrderedResourceDescriptionsData(
			Collections.<IResourceDescription> emptyList());
	List<Resource> resources = Lists.newArrayList(resourceSet.getResources());
	for (Resource resource : resources) {
		index(resource, resource.getURI(), index);
	}
	Adapter existing = EcoreUtil.getAdapter(resourceSet.eAdapters(), ResourceDescriptionsData.class);
	if (existing != null) {
		resourceSet.eAdapters().remove(existing);
	}
	ResourceDescriptionsData.ResourceSetAdapter.installResourceDescriptionsData(resourceSet, index);
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:15,代碼來源:N4JSRuntimeCore.java

示例8: get

import org.eclipse.emf.ecore.util.EcoreUtil; //導入方法依賴的package包/類
/**
 * Obtains an instance in the context of the given resourceSet.
 */
public static VirtualBaseTypeScope get(ResourceSet resourceSet) {
	VirtualBaseTypeScopeAccess result = (VirtualBaseTypeScopeAccess) EcoreUtil.getAdapter(resourceSet.eAdapters(),
			VirtualBaseTypeScope.class);
	if (result == null) {
		throw new IllegalStateException("Missing adapter for VirtualBaseTypeScope");
	}
	return result.getScope();
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:12,代碼來源:VirtualBaseTypeScope.java

示例9: registerVirtualBaseTypeScope

import org.eclipse.emf.ecore.util.EcoreUtil; //導入方法依賴的package包/類
/**
 * Registers an instance of the {@link VirtualBaseTypeScope} for the given context {@link ResourceSet}.
 */
public static void registerVirtualBaseTypeScope(VirtualBaseTypeScope scope, ResourceSet context) {
	if (EcoreUtil.getAdapter(context.eAdapters(), VirtualBaseTypeScope.class) != null) {
		throw new IllegalStateException("Attempt to install adapter for VirtualBaseTypeScope twice");
	}
	VirtualBaseTypeScopeAccess adapter = new VirtualBaseTypeScopeAccess(scope);
	context.eAdapters().add(adapter);
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:11,代碼來源:VirtualBaseTypeScopeAccess.java

示例10: registerGlobalObjectScope

import org.eclipse.emf.ecore.util.EcoreUtil; //導入方法依賴的package包/類
/**
 * Registers an instance of the {@link GlobalObjectScope} for the given context {@link ResourceSet}.
 */
public static void registerGlobalObjectScope(GlobalObjectScope scope, ResourceSet context) {
	if (EcoreUtil.getAdapter(context.eAdapters(), GlobalObjectScope.class) != null) {
		throw new IllegalStateException("Attempt to install adapter for GlobalObjectScope twice");
	}
	GlobalObjectScopeAccess adapter = new GlobalObjectScopeAccess(scope);
	context.eAdapters().add(adapter);
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:11,代碼來源:GlobalObjectScopeAccess.java

示例11: get

import org.eclipse.emf.ecore.util.EcoreUtil; //導入方法依賴的package包/類
/**
 * Obtains an instance in the context of the given resourceSet.
 */
public static GlobalObjectScope get(ResourceSet resourceSet) {
	GlobalObjectScopeAccess result = (GlobalObjectScopeAccess) EcoreUtil.getAdapter(resourceSet.eAdapters(),
			GlobalObjectScope.class);
	if (result == null) {
		throw new IllegalStateException("Missing adapter for GlobalObjectScope");
	}
	return result.getScope();
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:12,代碼來源:GlobalObjectScope.java


注:本文中的org.eclipse.emf.ecore.util.EcoreUtil.getAdapter方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。