mirror of
https://github.com/sigmasternchen/xtext-core
synced 2025-03-16 08:48:55 +00:00
commit
056d64c14e
5 changed files with 32 additions and 14 deletions
|
@ -29,6 +29,7 @@ import static org.eclipse.xtext.GrammarUtil.*
|
|||
|
||||
import static extension org.eclipse.xtext.xtext.generator.model.TypeReference.*
|
||||
import static extension org.eclipse.xtext.xtext.generator.util.GrammarUtil2.*
|
||||
import org.eclipse.xtext.resource.IBatchLinkableResource
|
||||
|
||||
class ImportNamespacesScopingFragment2 extends AbstractInheritingFragment {
|
||||
|
||||
|
@ -97,7 +98,12 @@ class ImportNamespacesScopingFragment2 extends AbstractInheritingFragment {
|
|||
|
||||
protected def contributeRuntimeGuiceBindings() {
|
||||
val bindingFactory = new GuiceModuleAccess.BindingFactory
|
||||
bindingFactory.addTypeToType(IScopeProvider.typeRef, grammar.scopeProviderClass)
|
||||
val targetType = if (language.grammar.inheritsXbase) {
|
||||
"org.eclipse.xtext.xbase.scoping.batch.IBatchScopeProvider".typeRef
|
||||
} else {
|
||||
IScopeProvider.typeRef
|
||||
}
|
||||
bindingFactory.addTypeToType(targetType, grammar.scopeProviderClass)
|
||||
|
||||
bindingFactory.addConfiguredBinding(IScopeProvider.simpleName + 'Delegate',
|
||||
'''binder.bind(«IScopeProvider».class).annotatedWith(«Names».named(«AbstractDeclarativeScopeProvider».NAMED_DELEGATE)).to(«getDelegateScopeProvider».class);''')
|
||||
|
|
|
@ -178,12 +178,12 @@ public class ReferenceFinder implements IReferenceFinder {
|
|||
URI sourceURI = null;
|
||||
if (doProcess(sourceCandidate, targetURIs)) {
|
||||
for(EReference ref: sourceCandidate.eClass().getEAllReferences()) {
|
||||
if(sourceCandidate.eIsSet(ref)) {
|
||||
Object value = sourceCandidate.eGet(ref, false);
|
||||
if(sourceCandidate.eIsSet(ref) && value != null) {
|
||||
if(ref.isContainment()) {
|
||||
Object content = sourceCandidate.eGet(ref, false);
|
||||
if(ref.isMany()) {
|
||||
@SuppressWarnings("unchecked")
|
||||
InternalEList<EObject> contentList = (InternalEList<EObject>) content;
|
||||
InternalEList<EObject> contentList = (InternalEList<EObject>) value;
|
||||
for(int i=0; i<contentList.size(); ++i) {
|
||||
EObject childElement = contentList.basicGet(i);
|
||||
if(!childElement.eIsProxy()) {
|
||||
|
@ -191,14 +191,13 @@ public class ReferenceFinder implements IReferenceFinder {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
EObject childElement = (EObject) content;
|
||||
EObject childElement = (EObject) value;
|
||||
if(!childElement.eIsProxy()) {
|
||||
findLocalReferencesFromElement(targetURIs, childElement, localResource, acceptor);
|
||||
}
|
||||
}
|
||||
} else if (!ref.isContainer()) {
|
||||
if (doProcess(ref, targetURIs)) {
|
||||
Object value = sourceCandidate.eGet(ref, false);
|
||||
if(ref.isMany()) {
|
||||
@SuppressWarnings("unchecked")
|
||||
InternalEList<EObject> values = (InternalEList<EObject>) value;
|
||||
|
|
|
@ -51,16 +51,17 @@ public class DynamicResourceClusteringPolicy implements IResourceClusteringPolic
|
|||
if (alreadyProcessed == 0)
|
||||
return true;
|
||||
final long maxMemory = Runtime.getRuntime().maxMemory();
|
||||
if (maxMemory > Runtime.getRuntime().totalMemory() + minimumFreeMemory)
|
||||
final long totalMemory = Runtime.getRuntime().totalMemory();
|
||||
if (maxMemory > totalMemory + minimumFreeMemory)
|
||||
return true;
|
||||
final long freeMemory = Runtime.getRuntime().freeMemory();
|
||||
if (freeMemory < minimumFreeMemory) {
|
||||
logClusterCapped(resourceSet, alreadyProcessed, freeMemory, maxMemory);
|
||||
logClusterCapped(resourceSet, alreadyProcessed, freeMemory, totalMemory);
|
||||
return false;
|
||||
} else if (alreadyProcessed < minimumClusterSize) {
|
||||
return true;
|
||||
} else if (freeMemory < maxMemory / 100 * minimumPercentFreeMemory) {
|
||||
logClusterCapped(resourceSet, alreadyProcessed, freeMemory, maxMemory);
|
||||
logClusterCapped(resourceSet, alreadyProcessed, freeMemory, totalMemory);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -78,7 +79,8 @@ public class DynamicResourceClusteringPolicy implements IResourceClusteringPolic
|
|||
}
|
||||
if (!hasLoggedAboutIncreasingHeap) {
|
||||
hasLoggedAboutIncreasingHeap = true;
|
||||
LOGGER.error("Your total heap size ("+(totalMemory >> 20)+"m) is too small. Please increase the maximum heap for your running JVM!");
|
||||
LOGGER.warn("Your total heap size (" + (totalMemory >> 20) + "m) is too small (free: " + (freeMemory >> 20) + "m, max: "
|
||||
+ (Runtime.getRuntime().maxMemory() >> 20) + "m). Please increase the maximum heap for your running JVM!");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -85,10 +85,14 @@ public class GrammarConstraintProvider implements IGrammarConstraintProvider {
|
|||
|
||||
protected void collectBounds(ISemState state, int[] current, Set<ISemState> visited, int[] min, int[] max) {
|
||||
int featureID = state.getFeatureID();
|
||||
int previousValue = -1;
|
||||
boolean newVisit = false;
|
||||
if (featureID >= 0) {
|
||||
if (current[featureID] == IGrammarConstraintProvider.MAX)
|
||||
return;
|
||||
if (visited.add(state))
|
||||
previousValue = current[featureID];
|
||||
newVisit = visited.add(state);
|
||||
if (newVisit)
|
||||
current[featureID]++;
|
||||
else
|
||||
current[featureID] = IGrammarConstraintProvider.MAX;
|
||||
|
@ -99,8 +103,13 @@ public class GrammarConstraintProvider implements IGrammarConstraintProvider {
|
|||
}
|
||||
return;
|
||||
}
|
||||
for (ISemState follower : state.getFollowers())
|
||||
collectBounds(follower, current.clone(), Sets.newHashSet(visited), min, max);
|
||||
for (ISemState follower : state.getFollowers()) {
|
||||
collectBounds(follower, current, visited, min, max);
|
||||
}
|
||||
if (previousValue >= 0)
|
||||
current[featureID] = previousValue;
|
||||
if (newVisit)
|
||||
visited.remove(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -32,6 +32,8 @@ public class NoJdtTestLanguageGenerator extends AbstractGenerator {
|
|||
return greeting.getName();
|
||||
}
|
||||
});
|
||||
fsa.generateFile("greetings.txt", "People to greet: " + IteratorExtensions.join(names, ", "));
|
||||
String fileName = resource.getURI().lastSegment();
|
||||
if(fileName == null) fileName = "greetings";
|
||||
fsa.generateFile(fileName+".txt", "People to greet: " + IteratorExtensions.join(names, ", "));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue