Java Code Examples for org.eclipse.xtext.naming.QualifiedName#startsWith()
The following examples show how to use
org.eclipse.xtext.naming.QualifiedName#startsWith() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KnownTypesScope.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
protected JvmType getExactMatch(JvmType type, int index, QualifiedName name) { String qn = type.getQualifiedName(); if (Strings.isEmpty(qn)) { return null; } QualifiedName typeName = QualifiedName.create(Strings.split(qn, '.')); if (name.equals(typeName)) { return type; } if (name.startsWith(typeName)) { JvmType result = findNestedType(type, index, name.skipFirst(typeName.getSegmentCount()-1)); return result; } if (name.getSegmentCount() > typeName.getSegmentCount()) { if (typeName.skipLast(1).equals(name.skipLast(1))) { if (typeName.getLastSegment().equals(name.skipFirst(typeName.getSegmentCount() - 1).toString("$"))) { return type; } } } return null; }
Example 2
Source File: ImportNormalizer.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
public QualifiedName deresolve(QualifiedName fullyQualifiedName) { if (hasWildCard) { if (!ignoreCase) { if (fullyQualifiedName.startsWith(importedNamespacePrefix) && fullyQualifiedName.getSegmentCount() != importedNamespacePrefix.getSegmentCount()) { return fullyQualifiedName.skipFirst(importedNamespacePrefix.getSegmentCount()); } } else { if (fullyQualifiedName.startsWithIgnoreCase(importedNamespacePrefix) && fullyQualifiedName.getSegmentCount() != importedNamespacePrefix.getSegmentCount()) { return fullyQualifiedName.skipFirst(importedNamespacePrefix.getSegmentCount()); } } } else { if (!ignoreCase) { if (fullyQualifiedName.equals(importedNamespacePrefix)) return QualifiedName.create(fullyQualifiedName.getLastSegment()); } else { if (fullyQualifiedName.equalsIgnoreCase(importedNamespacePrefix)) return QualifiedName.create(fullyQualifiedName.getLastSegment()); } } return null; }
Example 3
Source File: EObjectDescriptionProvider.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
protected QualifiedName computeSimpleName(Multimap<EObject, IEObjectDescription> descs, IEObjectDescription desc) { QualifiedName name = desc.getQualifiedName(); int segmentCount = name.getSegmentCount(); if (segmentCount < 2) { return name; } EObject container = desc.getEObjectOrProxy().eContainer(); while (container != null) { Collection<IEObjectDescription> candidates = descs.get(container); for (IEObjectDescription cand : candidates) { QualifiedName candName = cand.getQualifiedName(); int candCount = candName.getSegmentCount(); if (candCount < segmentCount && name.startsWith(candName)) { return name.skipFirst(candCount); } } container = container.eContainer(); } return name; }
Example 4
Source File: NestedTypeAwareImportNormalizerWithDotSeparator.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Override public QualifiedName deresolve(QualifiedName fullyQualifiedName) { if (hasWildCard()) { if (fullyQualifiedName.startsWith(getImportedNamespacePrefix()) && fullyQualifiedName.getSegmentCount() != getImportedNamespacePrefix().getSegmentCount()) { return fullyQualifiedName.skipFirst(getImportedNamespacePrefix().getSegmentCount()); } } else { if (fullyQualifiedName.equals(getImportedNamespacePrefix())) { return QualifiedName.create(fullyQualifiedName.getLastSegment()); } if (fullyQualifiedName.startsWith(getImportedNamespacePrefix())) { return fullyQualifiedName.skipFirst(getImportedNamespacePrefix().getSegmentCount() - 1); } int segmentCount = fullyQualifiedName.getSegmentCount(); List<String> segments = Lists.newArrayListWithExpectedSize(segmentCount); for(int i = 0; i < segmentCount; i++) { String segment = fullyQualifiedName.getSegment(i); segments.addAll(Strings.split(segment, '$')); } if (segments.size() > segmentCount) { QualifiedName withoutDollars = QualifiedName.create(segments); if (withoutDollars.startsWith(getImportedNamespacePrefix())) { return withoutDollars.skipFirst(getImportedNamespacePrefix().getSegmentCount() - 1); } } } return null; }
Example 5
Source File: SARLValidator.java From sarl with Apache License 2.0 | 5 votes |
/** Check for reserved annotations. * * @param annotationTarget thee target to test. */ @Check public void checkReservedAnnotation(XtendAnnotationTarget annotationTarget) { if (!isIgnored(USED_RESERVED_SARL_ANNOTATION)) { if (annotationTarget.getAnnotations().isEmpty() || !isRelevantAnnotationTarget(annotationTarget)) { return; } final QualifiedName reservedPackage = this.qualifiedNameConverter.toQualifiedName( EarlyExit.class.getPackage().getName()); final String earlyExitAnnotation = EarlyExit.class.getName(); final String errorOnCallAnnotation = ErrorOnCall.class.getName(); final String warningOnCallAnnotation = WarningOnCall.class.getName(); final String infoOnCallAnnotation = InfoOnCall.class.getName(); for (final XAnnotation annotation : annotationTarget.getAnnotations()) { final JvmType type = annotation.getAnnotationType(); if (type != null && !type.eIsProxy()) { if (Objects.equal(type.getIdentifier(), earlyExitAnnotation)) { // Special case: EarlyExit is allowed on events for declaring early-exit events if (!(annotationTarget instanceof SarlEvent)) { addIssue( MessageFormat.format(Messages.SARLValidator_87, type.getSimpleName()), annotation, USED_RESERVED_SARL_ANNOTATION); } } else if (!Objects.equal(type.getIdentifier(), errorOnCallAnnotation) && !Objects.equal(type.getIdentifier(), warningOnCallAnnotation) && !Objects.equal(type.getIdentifier(), infoOnCallAnnotation)) { final QualifiedName annotationName = this.qualifiedNameConverter.toQualifiedName( type.getIdentifier()); if (annotationName.startsWith(reservedPackage)) { addIssue( MessageFormat.format(Messages.SARLValidator_87, type.getSimpleName()), annotation, USED_RESERVED_SARL_ANNOTATION); } } } } } }