@Override public boolean apply(IEObjectDescription input) { return !isFiltered(input.getQualifiedName()); } });
@Override public QualifiedName getQualifiedName() { return delegate.getQualifiedName(); }
@Override public boolean apply(IEObjectDescription input) { return !isFiltered(input.getQualifiedName()); } });
@Override public boolean apply(IEObjectDescription input) { return !isFiltered(input.getQualifiedName()); } });
public QualifiedName getQualifiedName() { return delegate.getQualifiedName(); }
protected boolean isQualifiedNameEqual(IEObjectDescription desc1, IEObjectDescription desc2) { return desc1.getQualifiedName().equals(desc2.getQualifiedName()); }
public Object text(IEObjectDescription element) { return element.getQualifiedName() + " - " + element.getEClass().getName(); }
protected String getSymbolName(final IEObjectDescription description) { return this.getSymbolName(description.getQualifiedName()); }
protected boolean filter(final IEObjectDescription description, final String query) { return description.getQualifiedName().toLowerCase().toString().contains(query.toLowerCase()); }
public int compare(IEObjectDescription o1, IEObjectDescription o2) { int diff = o1.getQualifiedName().compareToIgnoreCase(o2.getQualifiedName()); if (diff == 0) { String className1 = o1.getEClass().getName(); String className2 = o2.getEClass().getName(); if(className1 == null) diff = className2 == null ? 0 : -1; else diff = className2 == null ? 1 : className1.compareToIgnoreCase(className2); if (diff == 0) { diff = o1.getEObjectURI().toString().compareTo(o2.getEObjectURI().toString()); } } return diff; } });
public SimpleNameDescription(QualifiedName qName, EObject resolvedObject, IEObjectDescription source) { this.simpleName = qName; this.object = resolvedObject; this.qualifiedName = source.getQualifiedName(); Preconditions.checkArgument(!this.object.eIsProxy()); Preconditions.checkNotNull(this.simpleName); Preconditions.checkNotNull(this.qualifiedName); Map<String, String> userData = null; for (final String key : source.getUserDataKeys()) { if (userData == null) { userData = Maps.newHashMapWithExpectedSize(2); } userData.put(key, source.getUserData(key)); } this.userData = userData; }
protected boolean isNameMatches(SearchPattern searchPattern, IEObjectDescription eObjectDescription, Collection<String> namespaceDelimiters) { String qualifiedName = qualifiedNameConverter.toString(eObjectDescription.getQualifiedName()); if (qualifiedName!=null) { if(searchPattern.matches(qualifiedName)) { return true; } for(String namespaceDelimiter : namespaceDelimiters) { int index = qualifiedName.lastIndexOf(namespaceDelimiter); if(index!=-1 && searchPattern.matches(qualifiedName.substring(index+1))) { return true; } } } return false; }
@Override public IEObjectDescription getSingleElement(EObject object) { Iterator<IEObjectDescription> elements = getElements(object).iterator(); if (elements.hasNext()) { IEObjectDescription result = elements.next(); String resultName = result.getName().toString(); while(elements.hasNext()) { IEObjectDescription candidate = elements.next(); String candidateName = candidate.getName().toString(); if (candidateName.length() < resultName.length()) { result = candidate; resultName = candidateName; } else if (candidateName.length() == resultName.length()) { // prefer '.' over '$' if (candidate.getQualifiedName().getSegmentCount() > result.getQualifiedName().getSegmentCount()) { result = candidate; resultName = candidateName; } } } return result; } return null; }
public String getJavaStubSource(IEObjectDescription description, IResourceDescription resourceDescription) { if(isNestedType(description) || !isJvmDeclaredType(description)) { return null; } Multimap<QualifiedName, IEObjectDescription> owner2nested = LinkedHashMultimap.create(); for(IEObjectDescription other: resourceDescription.getExportedObjects()) { if(isJvmDeclaredType(other) && isNestedType(other)) owner2nested.put(getOwnerClassName(other.getQualifiedName()), other); } StringBuilder classSignatureBuilder = new StringBuilder(); QualifiedName qualifiedName = description.getQualifiedName(); if (qualifiedName.getSegments().size() > 1) { String string = qualifiedName.toString(); classSignatureBuilder.append("package " + string.substring(0, string.lastIndexOf('.')) + ";"); } appendType(description, owner2nested, classSignatureBuilder); return classSignatureBuilder.toString(); }
protected void appendType(final IEObjectDescription description, Multimap<QualifiedName, IEObjectDescription> owner2nested, StringBuilder classSignatureBuilder) { classSignatureBuilder.append("\npublic "); if(isNestedType(description)) classSignatureBuilder.append("static "); if (description.getEClass() == TypesPackage.Literals.JVM_GENERIC_TYPE) { if (description.getUserData(JvmTypesResourceDescriptionStrategy.IS_INTERFACE) != null) { classSignatureBuilder.append("interface "); } else { classSignatureBuilder.append("class "); } } else if (description.getEClass() == TypesPackage.Literals.JVM_ENUMERATION_TYPE) { classSignatureBuilder.append("enum "); } else if (description.getEClass() == TypesPackage.Literals.JVM_ANNOTATION_TYPE) { classSignatureBuilder.append("@interface "); } String lastSegment = description.getQualifiedName().getLastSegment(); int trimIndex = lastSegment.lastIndexOf('$'); String simpleName = lastSegment.substring(trimIndex + 1); classSignatureBuilder.append(simpleName); String typeParameters = description.getUserData(JvmTypesResourceDescriptionStrategy.TYPE_PARAMETERS); if (typeParameters != null) { classSignatureBuilder.append(typeParameters); } classSignatureBuilder.append("{"); for(IEObjectDescription nested: owner2nested.get(description.getQualifiedName())) { appendType(nested, owner2nested, classSignatureBuilder); } classSignatureBuilder.append("\n}"); }
@Override protected IStatus run(IProgressMonitor monitor) { long startTime = System.currentTimeMillis(); while (iterator.hasNext()) { IEObjectDescription next = iterator.next(); if (next.getQualifiedName() != null && next.getEObjectURI() != null && next.getEClass() != null) { matches.add(next); long endTime = System.currentTimeMillis(); if (matches.size() == dialog.getHeightInChars() || endTime - startTime > TIME_THRESHOLD) { if (monitor.isCanceled()) { return Status.CANCEL_STATUS; } dialog.updateMatches(sortedCopy(matches), false); startTime = endTime; } } } dialog.updateMatches(sortedCopy(matches), true); return Status.OK_STATUS; }
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; }
protected StyledString getStyledDisplayString(IEObjectDescription description) { return getStyledDisplayString(description.getEObjectOrProxy(), qualifiedNameConverter.toString(description.getQualifiedName()), qualifiedNameConverter.toString(description.getName())); }
protected boolean containsReferenceText(Delta delta, QualifiedName exp) { DESC: for (IEObjectDescription desc : delta.getDescriptions()) { QualifiedName cand = desc.getQualifiedName(); if (cand.getSegmentCount() >= exp.getSegmentCount()) { for (int i = 1; i <= exp.getSegmentCount(); i++) { String expSeg = exp.getSegment(exp.getSegmentCount() - i); String candSeg = cand.getSegment(cand.getSegmentCount() - i); if (!expSeg.equals(candSeg)) { continue DESC; } } } return true; } return false; }
@Check(CheckType.NORMAL) public void checkDuplicateViewSpecificationAcrossFiles(final ViewSpecification viewSpecification) { final Iterable<IEObjectDescription> descriptions = this.getVisibleEObjectDescriptions(viewSpecification, ModelPackage.Literals.VIEW_SPECIFICATION); for (final IEObjectDescription desc : descriptions) { if (((Objects.equal(desc.getQualifiedName().toString(), viewSpecification.getId()) && (!Objects.equal(desc.getEObjectOrProxy(), viewSpecification))) && (!Objects.equal(desc.getEObjectURI().trimFragment(), viewSpecification.eResource().getURI())))) { String _id = viewSpecification.getId(); String _plus = ("The part id " + _id); String _plus_1 = (_plus + " is already defined"); this.error(_plus_1, this.modelPackage.getViewSpecification_Id(), EmfParsleyDslValidator.DUPLICATE_ELEMENT); return; } } }