protected Collection<org.emftext.language.xpath3.resource.xpath3.ui.Xpath3CompletionProposal> handleEnumAttribute( org.emftext.language.xpath3.resource.xpath3.mopp.Xpath3ExpectedTerminal expectedTerminal, org.emftext.language.xpath3.resource.xpath3.mopp.Xpath3ExpectedStructuralFeature expectedFeature, EEnum enumType, String prefix, EObject container) { Collection<EEnumLiteral> enumLiterals = enumType.getELiterals(); Collection<org.emftext.language.xpath3.resource.xpath3.ui.Xpath3CompletionProposal> result = new LinkedHashSet< org.emftext.language.xpath3.resource.xpath3.ui.Xpath3CompletionProposal>(); for (EEnumLiteral literal : enumLiterals) { String unResolvedLiteral = literal.getLiteral(); // use token resolver to get de-resolved value of the literal org.emftext.language.xpath3.resource.xpath3.IXpath3TokenResolverFactory tokenResolverFactory = metaInformation.getTokenResolverFactory(); org.emftext.language.xpath3.resource.xpath3.IXpath3TokenResolver tokenResolver = tokenResolverFactory.createTokenResolver(expectedFeature.getTokenName()); String resolvedLiteral = tokenResolver.deResolve(unResolvedLiteral, expectedFeature.getFeature(), container); boolean matchesPrefix = matches(resolvedLiteral, prefix); result.add( new org.emftext.language.xpath3.resource.xpath3.ui.Xpath3CompletionProposal( expectedTerminal, resolvedLiteral, prefix, matchesPrefix, expectedFeature.getFeature(), container)); } return result; }
protected Collection<org.emftext.language.xpath3.resource.xpath3.ui.Xpath3CompletionProposal> handleNCReference( org.emftext.language.xpath3.resource.xpath3.mopp.Xpath3ExpectedTerminal expectedTerminal, EObject container, EReference reference, String prefix, String tokenName) { // proposals for non-containment references are derived by calling the reference // resolver switch in fuzzy mode. org.emftext.language.xpath3.resource.xpath3.IXpath3ReferenceResolverSwitch resolverSwitch = metaInformation.getReferenceResolverSwitch(); org.emftext.language.xpath3.resource.xpath3.IXpath3TokenResolverFactory tokenResolverFactory = metaInformation.getTokenResolverFactory(); org.emftext.language.xpath3.resource.xpath3.IXpath3ReferenceResolveResult<EObject> result = new org.emftext.language.xpath3.resource.xpath3.mopp.Xpath3ReferenceResolveResult<EObject>( true); resolverSwitch.resolveFuzzy(prefix, container, reference, 0, result); Collection<org.emftext.language.xpath3.resource.xpath3.IXpath3ReferenceMapping<EObject>> mappings = result.getMappings(); if (mappings != null) { Collection<org.emftext.language.xpath3.resource.xpath3.ui.Xpath3CompletionProposal> resultSet = new LinkedHashSet< org.emftext.language.xpath3.resource.xpath3.ui.Xpath3CompletionProposal>(); for (org.emftext.language.xpath3.resource.xpath3.IXpath3ReferenceMapping<EObject> mapping : mappings) { Image image = null; if (mapping instanceof org.emftext.language.xpath3.resource.xpath3.mopp.Xpath3ElementMapping<?>) { org.emftext.language.xpath3.resource.xpath3.mopp.Xpath3ElementMapping<?> elementMapping = (org.emftext.language.xpath3.resource.xpath3.mopp.Xpath3ElementMapping<?>) mapping; Object target = elementMapping.getTargetElement(); // de-resolve reference to obtain correct identifier org.emftext.language.xpath3.resource.xpath3.IXpath3TokenResolver tokenResolver = tokenResolverFactory.createTokenResolver(tokenName); final String identifier = tokenResolver.deResolve(elementMapping.getIdentifier(), reference, container); if (target instanceof EObject) { image = getImage((EObject) target); } boolean matchesPrefix = matches(identifier, prefix); org.emftext.language.xpath3.resource.xpath3.ui.Xpath3CompletionProposal proposal = new org.emftext.language.xpath3.resource.xpath3.ui.Xpath3CompletionProposal( expectedTerminal, identifier, prefix, matchesPrefix, reference, container, image); proposal.setReferenceTarget(target); resultSet.add(proposal); } } return resultSet; } return Collections.emptyList(); }
protected Collection<org.emftext.language.xpath3.resource.xpath3.ui.Xpath3CompletionProposal> handleAttribute( org.emftext.language.xpath3.resource.xpath3.mopp.Xpath3ExpectedTerminal expectedTerminal, org.emftext.language.xpath3.resource.xpath3.mopp.Xpath3ExpectedStructuralFeature expectedFeature, EObject container, EAttribute attribute, String prefix) { Collection<org.emftext.language.xpath3.resource.xpath3.ui.Xpath3CompletionProposal> resultSet = new LinkedHashSet< org.emftext.language.xpath3.resource.xpath3.ui.Xpath3CompletionProposal>(); Object[] defaultValues = attributeValueProvider.getDefaultValues(attribute); if (defaultValues != null) { for (Object defaultValue : defaultValues) { if (defaultValue != null) { org.emftext.language.xpath3.resource.xpath3.IXpath3TokenResolverFactory tokenResolverFactory = metaInformation.getTokenResolverFactory(); String tokenName = expectedFeature.getTokenName(); if (tokenName != null) { org.emftext.language.xpath3.resource.xpath3.IXpath3TokenResolver tokenResolver = tokenResolverFactory.createTokenResolver(tokenName); if (tokenResolver != null) { String defaultValueAsString = tokenResolver.deResolve(defaultValue, attribute, container); boolean matchesPrefix = matches(defaultValueAsString, prefix); resultSet.add( new org.emftext.language.xpath3.resource.xpath3.ui.Xpath3CompletionProposal( expectedTerminal, defaultValueAsString, prefix, matchesPrefix, expectedFeature.getFeature(), container)); } } } } } return resultSet; }