@Override public String getSimpleName() { return this.getQualifiedName().getLastSegment(); }
public QualifiedName resolve(QualifiedName relativeName) { if (relativeName.isEmpty()) return null; if (hasWildCard) { return importedNamespacePrefix.append(relativeName); } else { if (!ignoreCase) { if (relativeName.getSegmentCount()==1 && relativeName.getLastSegment().equals(importedNamespacePrefix.getLastSegment())) { return importedNamespacePrefix; } } else { if (relativeName.getSegmentCount()==1 && relativeName.getLastSegment().equalsIgnoreCase(importedNamespacePrefix.getLastSegment())) { return importedNamespacePrefix.skipLast(1).append(relativeName.getLastSegment()); } } } return null; }
protected boolean isLegacyMatch(int index, QualifiedName relativeName) { QualifiedName importedName = importNames.get(index); return importedName != null && relativeName.getSegmentCount() == 1 && importedName.getLastSegment().equals(relativeName.getFirstSegment()); }
@Override protected void doGetDescriptions(JvmType type, JvmType knownType, int index, List<IEObjectDescription> result) { super.doGetDescriptions(type, knownType, index, result); QualifiedName importName = importNames.get(index); if (type == knownType && importName != null) { result.add(EObjectDescription.create(QualifiedName.create(importName.getLastSegment()), type)); } }
@Override public boolean isDisallowedName(QualifiedName name) { final String id = name.getLastSegment(); return Utils.isHiddenMember(id) || super.isDisallowedName(name); }
protected QualifiedName getOwnerClassName(QualifiedName nestedClassName) { String lastSegment = nestedClassName.getLastSegment(); int trimIndex = lastSegment.lastIndexOf('$'); if(trimIndex == -1) return nestedClassName.skipLast(1); else return nestedClassName.skipLast(1).append(lastSegment.substring(0, trimIndex)); }
@Override protected JvmType findNestedType(JvmType result, int index, QualifiedName name) { if (result.eContainer() instanceof JvmDeclaredType && name.getSegmentCount() == 1) { QualifiedName importName = importNames.get(index); if (importName != null && importName.getLastSegment().equals(name.getFirstSegment())) { return result; } } return super.findNestedType(result, index, name); }
@Override public String getNameLabel(final Object element) { String _switchResult = null; boolean _matched = false; if (element instanceof EObject) { _matched=true; _switchResult = SimpleAttributeResolver.NAME_RESOLVER.apply(((EObject)element)); } if (!_matched) { if (element instanceof IEObjectDescription) { _matched=true; _switchResult = ((IEObjectDescription)element).getName().getLastSegment(); } } if (!_matched) { _switchResult = null; } return _switchResult; } }
protected QualifiedName internalResolve(QualifiedName relativeName) { QualifiedName importedNamespace = getImportedNamespacePrefix(); if (importedNamespace.getLastSegment().equals(relativeName.getFirstSegment())) { return importedNamespace.skipLast(1).append(relativeName); } return null; } }
public boolean isOperatorFromExtension(XAbstractFeatureCall featureCall, String concreteSyntax, QualifiedName operatorSymbol, Class<?> definingExtensionClass) { if(!equal(concreteSyntax, operatorSymbol.getLastSegment())) return false; List<QualifiedName> methodNames = getMethodNames(featureCall, operatorSymbol); JvmDeclaredType definingJvmType = (JvmDeclaredType) typeReferences.findDeclaredType(definingExtensionClass, featureCall); if (definingJvmType == null) return false; JvmIdentifiableElement feature = featureCall.getFeature(); if (definingJvmType != feature.eContainer()) { return false; } for (QualifiedName methodName : methodNames) { if (methodName.getLastSegment().equals(feature.getSimpleName())) { return true; } } return false; }
protected String getDisplayString(EObject element, String qualifiedNameAsString, String shortName) { if (qualifiedNameAsString == null) qualifiedNameAsString = shortName; if (qualifiedNameAsString == null) { if (element != null) qualifiedNameAsString = labelProvider.getText(element); else return null; } QualifiedName qualifiedName = qualifiedNameConverter.toQualifiedName(qualifiedNameAsString); if(qualifiedName.getSegmentCount() >1) { return qualifiedName.getLastSegment() + " - " + qualifiedNameAsString; } return qualifiedNameAsString; }
@Override protected QualifiedName resolveNonWildcard(QualifiedName relativeName) { if (relativeName.getSegmentCount()==1) { // legacy import support, e.g. import java.util.Map$Entry allows to use Map$Entry as the simple name if (getImportedNamespacePrefix().getLastSegment().equals(relativeName.getFirstSegment())) { return getImportedNamespacePrefix(); } return internalResolve(relativeName); } else { StringBuilder concatenated = new StringBuilder(); for(int i = 0; i < relativeName.getSegmentCount(); i++) { String segment = relativeName.getSegment(i); if (segment.indexOf('$') == -1) { if (concatenated.length() != 0) { concatenated.append('$'); } concatenated.append(segment); } else { return null; } } return internalResolve(QualifiedName.create(concatenated.toString())); } }
/** * Create a new {@link ImportNormalizer} for the given namespace. * @param namespace the namespace. * @param ignoreCase <code>true</code> if the resolver should be case insensitive. * @return a new {@link ImportNormalizer} or <code>null</code> if the namespace cannot be converted to a valid * qualified name. */ protected ImportNormalizer createImportedNamespaceResolver(final String namespace, boolean ignoreCase) { if (Strings.isEmpty(namespace)) return null; QualifiedName importedNamespace = qualifiedNameConverter.toQualifiedName(namespace); if (importedNamespace == null || importedNamespace.isEmpty()) { return null; } boolean hasWildCard = ignoreCase ? importedNamespace.getLastSegment().equalsIgnoreCase(getWildCard()) : importedNamespace.getLastSegment().equals(getWildCard()); if (hasWildCard) { if (importedNamespace.getSegmentCount() <= 1) return null; return doCreateImportNormalizer(importedNamespace.skipLast(1), true, ignoreCase); } else { return doCreateImportNormalizer(importedNamespace, false, ignoreCase); } }
/** * Create a new {@link ImportNormalizer} for the given namespace. * @param namespace the namespace. * @param ignoreCase <code>true</code> if the resolver should be case insensitive. * @return a new {@link ImportNormalizer} or <code>null</code> if the namespace cannot be converted to a valid * qualified name. */ protected ImportNormalizer createImportedNamespaceResolver(final String namespace, boolean ignoreCase) { if (Strings.isEmpty(namespace)) return null; QualifiedName importedNamespace = qualifiedNameConverter.toQualifiedName(namespace); if (importedNamespace == null || importedNamespace.getSegmentCount() < 1) { return null; } boolean hasWildCard = ignoreCase ? importedNamespace.getLastSegment().equalsIgnoreCase(getWildCard()) : importedNamespace.getLastSegment().equals(getWildCard()); if (hasWildCard) { if (importedNamespace.getSegmentCount() <= 1) return null; return doCreateImportNormalizer(importedNamespace.skipLast(1), true, ignoreCase); } else { return doCreateImportNormalizer(importedNamespace, false, ignoreCase); } }
/** * Create a new {@link ImportNormalizer} for the given namespace. * @param namespace the namespace. * @param ignoreCase <code>true</code> if the resolver should be case insensitive. * @return a new {@link ImportNormalizer} or <code>null</code> if the namespace cannot be converted to a valid * qualified name. */ protected ImportNormalizer createImportedNamespaceResolver(final String namespace, boolean ignoreCase) { if (Strings.isEmpty(namespace)) return null; QualifiedName importedNamespace = qualifiedNameConverter.toQualifiedName(namespace); if (importedNamespace == null || importedNamespace.isEmpty()) { return null; } boolean hasWildcard = ignoreCase ? importedNamespace.getLastSegment().equalsIgnoreCase(getWildcard()) : importedNamespace.getLastSegment().equals(getWildcard()); if (hasWildcard) { if (importedNamespace.getSegmentCount() <= 1) return null; return doCreateImportNormalizer(importedNamespace.skipLast(1), true, ignoreCase); } else { return doCreateImportNormalizer(importedNamespace, false, ignoreCase); } }
public static void createMenuEventMapping(GuiElementEventMapping guiElemEventMapping, XMAComponent xmaComponent, XMAPage xmaPage) { for (EventFunction eventFunction : guiElemEventMapping.getEventFunctions()) { XMAFunction xmaFunction = getXMAFunctionForEventFunction(eventFunction,xmaComponent,xmaPage); MenuItem menuItem = Util.getMenuItemForName(xmaPage,PomNameProvider.INSTANCE.getFullyQualifiedName(guiElemEventMapping.getControl()).getLastSegment()); menuItem.setXMAFunction(xmaFunction); } }
protected void addNameAndDescription(final ContentAssistEntry entry, final EObject element, final String qualifiedNameAsString, final String shortName) { final QualifiedName qualifiedName = this.getQualifiedNameConverter().toQualifiedName(qualifiedNameAsString); int _segmentCount = qualifiedName.getSegmentCount(); boolean _greaterThan = (_segmentCount > 1); if (_greaterThan) { entry.setLabel(qualifiedName.getLastSegment()); entry.setDescription(qualifiedNameAsString); } else { entry.setLabel(qualifiedNameAsString); } }
@Override protected void generateImportStatement(QualifiedName qualifiedName, ExtraLanguageAppendable appendable, IExtraLanguageGeneratorContext context) { final String typeName = qualifiedName.getLastSegment(); final QualifiedName packageName = qualifiedName.skipLast(1); appendable.append("from "); //$NON-NLS-1$ appendable.append(packageName.toString()); appendable.append(" import "); //$NON-NLS-1$ appendable.append(typeName); appendable.newLine(); }
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; }
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; }