本文整理汇总了Java中org.eclipse.xtext.util.Tuples类的典型用法代码示例。如果您正苦于以下问题:Java Tuples类的具体用法?Java Tuples怎么用?Java Tuples使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Tuples类属于org.eclipse.xtext.util包,在下文中一共展示了Tuples类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getStorages
import org.eclipse.xtext.util.Tuples; //导入依赖的package包/类
@Override
public Iterable<Pair<IStorage, IProject>> getStorages(URI uri) {
if (uri.isArchive()) {
URIBasedStorage storage = new URIBasedStorage(uri);
String authority = uri.authority();
URI archiveFileURI = URI.createURI(authority.substring(0, authority.length() - 1));
Optional<? extends IN4JSEclipseProject> optionalProject = eclipseCore.findProject(archiveFileURI);
if (optionalProject.isPresent()) {
return Collections.singletonList(Tuples.<IStorage, IProject> create(storage, optionalProject.get()
.getProject()));
} else {
return Collections.singletonList(Tuples.create(storage, null));
}
} else {
return Collections.emptyList();
}
}
开发者ID:eclipse,项目名称:n4js,代码行数:18,代码来源:NfarStorageMapper.java
示例2: load
import org.eclipse.xtext.util.Tuples; //导入依赖的package包/类
@Override
public Optional<Pair<ExternalProject, ProjectDescription>> load(final URI rootLocation) throws Exception {
if (null != rootLocation && rootLocation.isFile()) {
final File projectRoot = new File(rootLocation.toFileString());
if (projectRoot.exists() && projectRoot.isDirectory()) {
final URI manifestLocation = rootLocation.appendSegment(IN4JSProject.N4MF_MANIFEST);
final ProjectDescription projectDescription = packageManager.loadManifest(manifestLocation);
if (null != projectDescription) {
final ExternalProject project = new ExternalProject(projectRoot, NATURE_ID, BUILDER_ID);
return Optional.of(Tuples.create(project, projectDescription));
}
}
}
return Optional.absent();
}
开发者ID:eclipse,项目名称:n4js,代码行数:18,代码来源:ExternalProjectCacheLoader.java
示例3: getFullyQualifiedName
import org.eclipse.xtext.util.Tuples; //导入依赖的package包/类
@Override
public QualifiedName getFullyQualifiedName(final EObject obj) {
return cache.get(Tuples.pair(obj, getCacheKey()), obj.eResource(), new Provider<QualifiedName>() {
@Override
public QualifiedName get() {
EObject temp = obj;
String name = nameDispatcher.invoke(temp);
if (Strings.isEmpty(name))
return null;
QualifiedName qualifiedName = QualifiedName.create(name);
if(!isRecurseParent(obj))
return qualifiedName;
QualifiedName parentsQualifiedName = getFullyQualifiedName(obj.eContainer());
if (parentsQualifiedName == null)
return null;
else
return parentsQualifiedName.append(qualifiedName);
}
});
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:23,代码来源:EcoreQualifiedNameProvider.java
示例4: detachNodeModel
import org.eclipse.xtext.util.Tuples; //导入依赖的package包/类
protected List<Pair<EObject, ICompositeNode>> detachNodeModel(EObject eObject) {
EcoreUtil.resolveAll(eObject);
List<Pair<EObject, ICompositeNode>> result = Lists.newArrayList();
Iterator<Object> iterator = EcoreUtil.getAllContents(eObject.eResource(), false);
while (iterator.hasNext()) {
EObject object = (EObject) iterator.next();
Iterator<Adapter> adapters = object.eAdapters().iterator();
while (adapters.hasNext()) {
Adapter adapter = adapters.next();
if (adapter instanceof ICompositeNode) {
adapters.remove();
result.add(Tuples.create(object, (ICompositeNode) adapter));
break;
}
}
}
return result;
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:19,代码来源:SerializerTester.java
示例5: collectMatchingLocations
import org.eclipse.xtext.util.Tuples; //导入依赖的package包/类
protected Map<SourceRelativeURI, List<Pair<ILocationData, AbstractTraceRegion>>> collectMatchingLocations(
SourceRelativeURI expectedAssociatedPath) {
Map<SourceRelativeURI, List<Pair<ILocationData, AbstractTraceRegion>>> result = Maps
.newHashMapWithExpectedSize(2);
Iterator<AbstractTraceRegion> treeIterator = treeIterator();
while (treeIterator.hasNext()) {
AbstractTraceRegion next = treeIterator.next();
SourceRelativeURI associatedPath = next.getAssociatedSrcRelativePath();
List<Pair<ILocationData, AbstractTraceRegion>> matchingLocations = getCollectingList(associatedPath,
expectedAssociatedPath, result);
for (ILocationData locationData : next.getAssociatedLocations()) {
if (associatedPath == null) {
matchingLocations = getCollectingList(locationData.getSrcRelativePath(), expectedAssociatedPath, result);
}
if (matchingLocations != null) {
matchingLocations.add(Tuples.create(locationData, next));
}
}
}
return result;
}
开发者ID:eclipse,项目名称:xtext-core,代码行数:22,代码来源:AbstractTraceRegion.java
示例6: validateQuantities
import org.eclipse.xtext.util.Tuples; //导入依赖的package包/类
protected List<IConcreteSyntaxDiagnostic> validateQuantities(IQuantities quants, ISyntaxConstraint rule) {
List<IConcreteSyntaxDiagnostic> diag = new ArrayList<IConcreteSyntaxDiagnostic>();
Map<ISyntaxConstraint, Pair<Integer, Integer>> minmax = Maps.newHashMap();
for (Map.Entry<EStructuralFeature, Collection<ISyntaxConstraint>> e : quants.groupByFeature().entrySet()) {
int min = UNDEF, max = 0;
Set<ISyntaxConstraint> involved = new HashSet<ISyntaxConstraint>();
for (ISyntaxConstraint a : e.getValue()) {
involved.add(a);
int mi = intervalProvider.getMin(quants, a, involved);
if (mi != UNDEF)
min = min == UNDEF ? mi : mi + min;
int ma = intervalProvider.getMax(quants, a, involved, null);
if (ma != UNDEF && max != MAX)
max = ma == MAX ? ma : max + ma;
minmax.put(a, Tuples.create(mi, ma));
}
int actual = quants.getFeatureQuantity(e.getKey());
if (actual < min || actual > max)
diag.add(diagnosticProvider.createFeatureQuantityDiagnostic(rule, quants, e.getKey(), actual, min, max,
involved));
}
// System.out.println("Validation: " + obj.toString(minmax));
return diag;
}
开发者ID:eclipse,项目名称:xtext-core,代码行数:25,代码来源:ConcreteSyntaxValidator.java
示例7: unloadRoot
import org.eclipse.xtext.util.Tuples; //导入依赖的package包/类
@Override
public void unloadRoot(EObject root) {
// Content adapters should be removed the same way as they are added: top-down.
// Fragments are recursive, so we need them to be calculated before proxifying the container.
// OTOH, some model elements resolve their children when being proxified (e.g. EPackageImpl).
// => first calculate all fragments, then proxify elements starting form root.
List<Pair<EObject, URI>> elementsToUnload = newArrayList();
elementsToUnload.add(Tuples.create(root, EcoreUtil.getURI(root)));
root.eAdapters().clear();
for (Iterator<EObject> i = EcoreUtil.getAllProperContents(root, false); i.hasNext();) {
EObject element = i.next();
elementsToUnload.add(Tuples.create(element, EcoreUtil.getURI(element)));
element.eAdapters().clear();
}
for (Pair<EObject,URI> elementToUnload : elementsToUnload) {
((InternalEObject) elementToUnload.getFirst()).eSetProxyURI(elementToUnload.getSecond());
}
}
开发者ID:eclipse,项目名称:xtext-core,代码行数:19,代码来源:IReferableElementsUnloader.java
示例8: getFullyQualifiedName
import org.eclipse.xtext.util.Tuples; //导入依赖的package包/类
@Override
public QualifiedName getFullyQualifiedName(final EObject obj) {
return cache.get(Tuples.pair(obj, "fqn"), obj.eResource(), new Provider<QualifiedName>(){
@Override
public QualifiedName get() {
EObject temp = obj;
QualifiedName qualifiedNameFromDispatcher = qualifiedName.invoke(temp);
if (qualifiedNameFromDispatcher!=null)
return qualifiedNameFromDispatcher;
String name = getResolver().apply(temp);
if (Strings.isEmpty(name))
return null;
QualifiedName qualifiedNameFromConverter = converter.toQualifiedName(name);
while (temp.eContainer() != null) {
temp = temp.eContainer();
QualifiedName parentsQualifiedName = getFullyQualifiedName(temp);
if (parentsQualifiedName != null)
return parentsQualifiedName.append(qualifiedNameFromConverter);
}
return qualifiedNameFromConverter;
}
});
}
开发者ID:eclipse,项目名称:xtext-core,代码行数:25,代码来源:DefaultDeclarativeQualifiedNameProvider.java
示例9: findKeywordPairs
import org.eclipse.xtext.util.Tuples; //导入依赖的package包/类
public List<Pair<Keyword, Keyword>> findKeywordPairs(String leftKw, String rightKw) {
ArrayList<Pair<Keyword, Keyword>> pairs = new ArrayList<Pair<Keyword, Keyword>>();
for (AbstractRule ar : getRules())
if (ar instanceof ParserRule && !GrammarUtil.isDatatypeRule((ParserRule) ar)) {
Stack<Keyword> openings = new Stack<Keyword>();
TreeIterator<EObject> i = ar.eAllContents();
while (i.hasNext()) {
EObject o = i.next();
if (o instanceof Keyword) {
Keyword k = (Keyword) o;
if (leftKw.equals(k.getValue()))
openings.push(k);
else if (rightKw.equals(k.getValue())) {
if (openings.size() > 0)
pairs.add(Tuples.create(openings.pop(), k));
}
}
}
}
return pairs;
}
开发者ID:eclipse,项目名称:xtext-core,代码行数:22,代码来源:AbstractElementFinder.java
示例10: findNext
import org.eclipse.xtext.util.Tuples; //导入依赖的package包/类
protected Triple<INode, AbstractElement, EObject> findNext(INode node, boolean prune) {
INode current = next(node, prune);
while (current != null) {
if (current instanceof ILeafNode && ((ILeafNode) current).isHidden()) {
current = next(current, true);
continue;
}
EObject ge = current.getGrammarElement();
if (ge instanceof AbstractElement && isEObjectNode(current))
return Tuples.create(current, (AbstractElement) ge, getEObjectNodeEObject(current));
else if (GrammarUtil.isAssigned(ge) && !GrammarUtil.isEObjectRuleCall(ge)) {
if (ge instanceof CrossReference)
return Tuples.create(current, ((CrossReference) ge).getTerminal(), null);
else
return Tuples.create(current, (AbstractElement) ge, null);
} else
current = next(current, false);
}
return null;
}
开发者ID:eclipse,项目名称:xtext-core,代码行数:21,代码来源:SemanticNodeIterator.java
示例11: isValueValid
import org.eclipse.xtext.util.Tuples; //导入依赖的package包/类
protected boolean isValueValid(ISemState state, int index, Object value) {
List<AbstractElement> candidates = state.getToBeValidatedAssignedElements();
if (candidates.isEmpty())
return true;
Pair<AbstractElement, Integer> key = Tuples.create(state.getAssignedGrammarElement(), index);
if (valid.get(key) == Boolean.TRUE)
return true;
ISemanticNode semanticNode = getNode(state.getFeatureID(), index);
INode node = semanticNode == null ? null : semanticNode.getNode();
Multimap<AbstractElement, ISerializationContext> assignments = ArrayListMultimap.create();
for (AbstractElement ele : candidates)
assignments.put(ele, context);
Set<AbstractElement> found = assignmentFinder.findAssignmentsByValue(eObject, assignments, value, node);
boolean result = found.contains(state.getAssignedGrammarElement());
valid.put(key, result);
return result;
}
开发者ID:eclipse,项目名称:xtext-core,代码行数:20,代码来源:BacktrackingSemanticSequencer.java
示例12: addReplacer
import org.eclipse.xtext.util.Tuples; //导入依赖的package包/类
@Override
public void addReplacer(ITextReplacer replacer) {
if (!this.getRegion().contains(replacer.getRegion())) {
String frameTitle = getClass().getSimpleName();
ITextSegment frameRegion = getRegion();
String replacerTitle = replacer.getClass().getSimpleName();
ITextSegment replacerRegion = replacer.getRegion();
RegionsOutsideFrameException exception = new RegionsOutsideFrameException(frameTitle, frameRegion,
Tuples.create(replacerTitle, replacerRegion));
getRequest().getExceptionHandler().accept(exception);
return;
}
try {
getReplacers().add(replacer, getFormatter().createTextReplacerMerger());
} catch (ConflictingRegionsException e) {
getRequest().getExceptionHandler().accept(e);
}
}
开发者ID:eclipse,项目名称:xtext-core,代码行数:19,代码来源:FormattableDocument.java
示例13: findSplitState
import org.eclipse.xtext.util.Tuples; //导入依赖的package包/类
protected <T> Pair<Integer, StateAlias<T>> findSplitState(StateAlias<T> state, Integer depth,
Set<StateAlias<T>> visited) {
if (!visited.add(state))
return null;
Pair<Integer, StateAlias<T>> result;
if (state.getOutgoing().size() > 0 && state.getIncoming().size() > 0
&& state.getOutgoing().size() + state.getIncoming().size() > 2)
result = Tuples.create(depth, state);
else
result = null;
for (StateAlias<T> out : state.getOutgoing()) {
Pair<Integer, StateAlias<T>> cand = findSplitState(out, depth + 1, visited);
if (cand != null && (result == null || isPreferredSplitState(cand, result)))
result = cand;
}
return result;
}
开发者ID:eclipse,项目名称:xtext-core,代码行数:18,代码来源:NfaToProduction.java
示例14: getContainingInfo
import org.eclipse.xtext.util.Tuples; //导入依赖的package包/类
/**
* Gets the containing info for an expression.
* <p>
* The containing info for an expression consists of
* <ul>
* <li>the EObject that contains the expression,
* <li>the containment EReference of that containing EObject
* <li>if the multiplicity is > 1, the index of the expression in the containing EReference; else -1
* </ul>
*
* @param expression
* the expression to get the containing info for
* @return the containing info for {@code expression}
*/
protected Triple<EObject, EReference, Integer> getContainingInfo(final IExpression expression) {
if (expression == null) {
return null;
}
if (expression.eIsProxy()) {
return null;
}
EReference containmentReference = expression.eContainmentFeature();
if (containmentReference == null) {
return null;
}
EObject container = expression.eContainer();
int index = (containmentReference.isMany()) ? ((List<?>) container.eGet(containmentReference)).indexOf(expression) : -1;
return Tuples.create(container, containmentReference, index);
}
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:30,代码来源:AbstractTypeProvider.java
示例15: loadResource
import org.eclipse.xtext.util.Tuples; //导入依赖的package包/类
/**
* Load the {@link Resource} with the given {@link URI} and publish the load result.
*
* @param uri
* the {@link URI} of the {@link Resource} to be loaded
*/
protected void loadResource(final URI uri) {
Throwable exception = null;
Resource resource = null;
currentlyProcessedUris.add(uri);
try {
resource = doLoadResource(uri);
// CHECKSTYLE:OFF
} catch (Throwable t) {
// CHECKSTYLE:ON
exception = t;
}
currentlyProcessedUris.remove(uri);
publishLoadResult(Tuples.create(uri, resource, exception));
}
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:23,代码来源:ParallelResourceLoader.java
示例16: prepareMocksBase
import org.eclipse.xtext.util.Tuples; //导入依赖的package包/类
/**
* Prepare mocks for all tests.
*/
public static void prepareMocksBase() {
oldDesc = mock(IResourceDescription.class);
newDesc = mock(IResourceDescription.class);
delta = mock(Delta.class);
resource = mock(Resource.class);
uriCorrect = mock(URI.class);
when(uriCorrect.isPlatformResource()).thenReturn(true);
when(uriCorrect.isFile()).thenReturn(true);
when(uriCorrect.toFileString()).thenReturn(DUMMY_PATH);
when(uriCorrect.toPlatformString(true)).thenReturn(DUMMY_PATH);
when(delta.getNew()).thenReturn(newDesc);
when(delta.getOld()).thenReturn(oldDesc);
when(delta.getUri()).thenReturn(uriCorrect);
when(resource.getURI()).thenReturn(uriCorrect);
file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(uriCorrect.toPlatformString(true)));
Iterable<Pair<IStorage, IProject>> storages = singleton(Tuples.<IStorage, IProject> create(file, file.getProject()));
mapperCorrect = mock(Storage2UriMapperImpl.class);
when(mapperCorrect.getStorages(uriCorrect)).thenReturn(storages);
}
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:23,代码来源:AbstractUtilTest.java
示例17: internalComputeCompletionProposals
import org.eclipse.xtext.util.Tuples; //导入依赖的package包/类
/**
* Internally compute completion proposals.
*
* @param cursorPosition
* the position of the cursor in the {@link IXtextDocument}
* @param xtextDocument
* the {@link IXtextDocument}
* @return a pair of {@link ICompletionProposal}[] and {@link BadLocationException}. If the tail argument is not {@code null}, an exception occurred in the UI
* thread.
*/
private Pair<ICompletionProposal[], BadLocationException> internalComputeCompletionProposals(final int cursorPosition, final IXtextDocument xtextDocument) {
XtextSourceViewerConfiguration configuration = get(XtextSourceViewerConfiguration.class);
Shell shell = new Shell();
try {
ISourceViewer sourceViewer = getSourceViewer(shell, xtextDocument, configuration);
IContentAssistant contentAssistant = configuration.getContentAssistant(sourceViewer);
String contentType = xtextDocument.getContentType(cursorPosition);
IContentAssistProcessor processor = contentAssistant.getContentAssistProcessor(contentType);
if (processor != null) {
return Tuples.create(processor.computeCompletionProposals(sourceViewer, cursorPosition), null);
}
return Tuples.create(new ICompletionProposal[0], null);
} catch (BadLocationException e) {
return Tuples.create(new ICompletionProposal[0], e);
} finally {
shell.dispose();
}
}
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:29,代码来源:AcfContentAssistProcessorTestBuilder.java
示例18: internalGetSelectedAstElements
import org.eclipse.xtext.util.Tuples; //导入依赖的package包/类
protected Pair<EObject, EObject> internalGetSelectedAstElements(EObject eObject, ITextRegion currentSelection) {
ITextRegion textRegion = getTextRegion(eObject);
while (textRegion.getOffset() == currentSelection.getOffset()) {
EObject container = eObject.eContainer();
if (container != null) {
for (EObject obj : container.eContents()) {
ITextRegion region = getTextRegion(obj);
if (getEndOffset(region) == getEndOffset(currentSelection)) {
Pair<EObject, EObject> parentMatch = internalGetSelectedAstElements(eObject.eContainer(), currentSelection);
if (parentMatch != null)
return parentMatch;
return Tuples.create(eObject, obj);
}
}
} else {
if (textRegion.equals(currentSelection))
return Tuples.create(eObject, eObject);
return null;
}
eObject = container;
textRegion = getTextRegion(eObject);
}
return null;
}
开发者ID:cplutte,项目名称:bts,代码行数:25,代码来源:AstSelectionProvider.java
示例19: mergePendingDeltas
import org.eclipse.xtext.util.Tuples; //导入依赖的package包/类
protected Pair<IResourceDescription.Event, Integer> mergePendingDeltas() {
Map<URI, IResourceDescription.Delta> uriToDelta = Maps.newLinkedHashMap();
Iterator<IResourceDescription.Delta> iter = pendingChanges.iterator();
int size = 0;
while(iter.hasNext()) {
IResourceDescription.Delta delta = iter.next();
URI uri = delta.getUri();
IResourceDescription.Delta prev = uriToDelta.get(uri);
if (prev == null) {
uriToDelta.put(uri, delta);
} else if (prev.getOld() != delta.getNew()){
uriToDelta.put(uri, createDelta(delta, prev));
} else {
uriToDelta.remove(uri);
}
size++;
}
IResourceDescription.Event event = new ResourceDescriptionChangeEvent(uriToDelta.values(), dirtyStateManager);
return Tuples.create(event, size);
}
开发者ID:cplutte,项目名称:bts,代码行数:21,代码来源:DirtyStateEditorSupport.java
示例20: getStorages
import org.eclipse.xtext.util.Tuples; //导入依赖的package包/类
@Override
public Iterable<Pair<IStorage, IProject>> getStorages(final URI uri) {
final IN4JSEclipseProject project = eclipseCore.findProject(uri).orNull();
if (null != project && project.exists()) {
final IProject resourceProject = project.getProject();
return singleton(Tuples.create(new URIBasedStorage(uri), resourceProject));
}
return emptyList();
}
开发者ID:eclipse,项目名称:n4js,代码行数:10,代码来源:N4JSExternalLibraryStorage2UriMapperContribution.java
注:本文中的org.eclipse.xtext.util.Tuples类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论