@Override public QualifiedName resolve(QualifiedName relativeName) { QualifiedName prefix = getImportedNamespacePrefix(); if (relativeName.getSegmentCount() > 1 && !alias.isEmpty() && relativeName.startsWith(alias)) { relativeName = relativeName.skipFirst(1); } return prefix.append(relativeName); } }
@Override public QualifiedName deresolve(QualifiedName fullyQualifiedName) { if (fullyQualifiedName.startsWith(getImportedNamespacePrefix())) { int segmentCount = getImportedNamespacePrefix().getSegmentCount(); return alias.append(fullyQualifiedName.skipFirst(segmentCount)); } return null; }
@Override public Iterable<IEObjectDescription> getElements(QualifiedName name) { JvmTypeReference superType = Iterables.getLast(anonymousType.getSuperTypes(), null); if (superType == null) return Collections.emptyList(); JvmType type = superType.getType(); if (type == null) return Collections.emptyList(); QualifiedName typeName = qualifiedNameConverter.toQualifiedName(type.getQualifiedName('.')); if (typeName.getSegmentCount() > name.getSegmentCount()) { typeName = typeName.skipFirst(typeName.getSegmentCount() - name.getSegmentCount()); } if (!typeName.equals(name)) { if (name.getSegmentCount() == 1 && name.getFirstSegment().indexOf('$') > 0) { QualifiedName splitted = QualifiedName.create(Strings.split(name.getFirstSegment(), '$')); typeName = qualifiedNameConverter.toQualifiedName(type.getQualifiedName('.')); if (typeName.getSegmentCount() > splitted.getSegmentCount()) { typeName = typeName.skipFirst(typeName.getSegmentCount() - splitted.getSegmentCount()); } if (!typeName.equals(splitted)) { return Collections.emptyList(); } } else { return Collections.emptyList(); } } IEObjectDescription typeDescription = EObjectDescription.create(name, anonymousType); return createFeatureDescriptions(Collections.singletonList(typeDescription)); }
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; }
if (fullyQualifiedName.startsWith(getImportedNamespacePrefix()) && fullyQualifiedName.getSegmentCount() != getImportedNamespacePrefix().getSegmentCount()) { return fullyQualifiedName.skipFirst(getImportedNamespacePrefix().getSegmentCount()); int dollar = lastImportedSegment.lastIndexOf('$'); if (dollar == -1) { return fullyQualifiedName.skipFirst(getImportedNamespacePrefix().getSegmentCount() - 1); } else { return QualifiedName.create(lastSegment.substring(dollar +1));
withDollar = type.eContainer() instanceof JvmType ? type.getQualifiedName('$').substring(packageName.length() + 1) : null; result.add(EObjectDescription.create(withDot.skipFirst(qualifiedPackageName.getSegmentCount()), type)); if (withDollar != null) { result.add(EObjectDescription.create(withDollar, type));
@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; }
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; }
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; }