mirror of
https://github.com/sigmasternchen/xtext-core
synced 2025-03-16 16:58:56 +00:00
[refactoring] facade for ResourceSet for Xtext-specific config
see https://bugs.eclipse.org/bugs/show_bug.cgi?id=459290#c1 Change-Id: Iad613aa3fb3747914738c37af8cdd7f7d03c7bb1
This commit is contained in:
parent
32599d1e59
commit
e5d778fda0
1 changed files with 49 additions and 0 deletions
|
@ -0,0 +1,49 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 itemis AG (http://www.itemis.eu) and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*******************************************************************************/
|
||||
package org.eclipse.xtext.resource;
|
||||
|
||||
import org.eclipse.emf.common.notify.Notifier;
|
||||
import org.eclipse.emf.ecore.resource.ResourceSet;
|
||||
import org.eclipse.xtext.EcoreUtil2;
|
||||
import org.eclipse.xtext.resource.impl.ResourceDescriptionsProvider;
|
||||
|
||||
/**
|
||||
* An Xtext-specific facade over an EMF ResourceSet.
|
||||
*
|
||||
* This class provides a nicer API for Xtext-specific configuration of a ResourceSet.
|
||||
*
|
||||
* @author Moritz Eysholdt - Initial contribution and API
|
||||
* @since 2.8
|
||||
*/
|
||||
public class ResourceSetContext {
|
||||
|
||||
public static ResourceSetContext get(Notifier context) {
|
||||
ResourceSet resourceSet = EcoreUtil2.getResourceSet(context);
|
||||
return new ResourceSetContext(resourceSet);
|
||||
}
|
||||
|
||||
private final ResourceSet resourceSet;
|
||||
|
||||
public ResourceSetContext(ResourceSet ressourceSet) {
|
||||
super();
|
||||
this.resourceSet = ressourceSet;
|
||||
}
|
||||
|
||||
public ResourceSet getRessourceSet() {
|
||||
return resourceSet;
|
||||
}
|
||||
|
||||
public boolean isBuilder() {
|
||||
return resourceSet.getLoadOptions().containsKey(ResourceDescriptionsProvider.NAMED_BUILDER_SCOPE);
|
||||
}
|
||||
|
||||
public boolean isEditor() {
|
||||
return !isBuilder() && !resourceSet.getLoadOptions().containsKey(ResourceDescriptionsProvider.LIVE_SCOPE);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue