use of org.eclipse.xtext.resource.IEObjectDescription in project xtext-eclipse by eclipse.
the class XtextEObjectSearchDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite container) {
Composite parent = (Composite) super.createDialogArea(container);
if (enableStyledLabels && labelProvider instanceof IStyledLabelProvider) {
final Table table = getTableViewer().getTable();
final IStyledLabelProvider styledLabelProvider = (IStyledLabelProvider) labelProvider;
TableOwnerDrawSupport.install(table);
Listener listener = new Listener() {
@Override
public void handleEvent(Event event) {
handleSetData(event);
}
protected void handleSetData(Event event) {
TableItem item = (TableItem) event.item;
IEObjectDescription description = (IEObjectDescription) item.getData();
if (description != null) {
StyledString styledString = styledLabelProvider.getStyledText(description);
String displayString = styledString.toString();
StyleRange[] styleRanges = styledString.getStyleRanges();
item.setText(displayString);
TableOwnerDrawSupport.storeStyleRanges(item, 0, styleRanges);
}
}
};
table.addListener(SWT.SetData, listener);
}
messageLabel = new Label(parent, SWT.NONE);
setDefaultGridData(messageLabel);
EObjectDescriptionContentProvider contentProvider = new EObjectDescriptionContentProvider();
getTableViewer().setContentProvider(contentProvider);
getTableViewer().addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
ISelection selection = event.getSelection();
if (selection instanceof IStructuredSelection) {
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
if (!structuredSelection.isEmpty()) {
Object firstElement = structuredSelection.getFirstElement();
if (firstElement instanceof IEObjectDescription) {
IEObjectDescription eObjectDescription = (IEObjectDescription) firstElement;
URI resourceURI = eObjectDescription.getEObjectURI().trimFragment();
if (resourceURI.isPlatform()) {
messageLabel.setText(resourceURI.toPlatformString(true));
} else if (resourceURI.isFile()) {
messageLabel.setText(resourceURI.toFileString());
} else {
messageLabel.setText(resourceURI.toString());
}
return;
}
}
}
// $NON-NLS-1$
messageLabel.setText("");
}
});
applyFilter();
return parent;
}
use of org.eclipse.xtext.resource.IEObjectDescription in project xtext-core by eclipse.
the class AbstractHierarchyBuilder method getDescription.
protected IEObjectDescription getDescription(final URI objectURI) {
final IResourceDescription resourceDescription = this.getIndexData().getResourceDescription(objectURI.trimFragment());
if ((resourceDescription == null)) {
return null;
}
final Function1<IEObjectDescription, Boolean> _function = (IEObjectDescription it) -> {
URI _eObjectURI = it.getEObjectURI();
return Boolean.valueOf(Objects.equal(_eObjectURI, objectURI));
};
return IterableExtensions.<IEObjectDescription>findFirst(resourceDescription.getExportedObjects(), _function);
}
use of org.eclipse.xtext.resource.IEObjectDescription in project xtext-core by eclipse.
the class DefaultCallHierarchyBuilder method buildRoots.
@Override
public Collection<IHierarchyNode> buildRoots(final URI rootURI, final IProgressMonitor monitor) {
final IEObjectDescription rootDeclaration = this.findDeclaration(rootURI);
if ((rootDeclaration == null)) {
return CollectionLiterals.<IHierarchyNode>emptyList();
}
IHierarchyNode _createRoot = this.createRoot(rootDeclaration);
return Collections.<IHierarchyNode>unmodifiableList(CollectionLiterals.<IHierarchyNode>newArrayList(_createRoot));
}
use of org.eclipse.xtext.resource.IEObjectDescription in project xtext-core by eclipse.
the class NamesAreUniqueValidator method doCheckUniqueNames.
public void doCheckUniqueNames(Resource resource, CancelIndicator cancelIndicator) {
final IResourceServiceProvider resourceServiceProvider = resourceServiceProviderRegistry.getResourceServiceProvider(resource.getURI());
if (resourceServiceProvider == null)
return;
IResourceDescription.Manager manager = resourceServiceProvider.getResourceDescriptionManager();
if (manager != null) {
IResourceDescription description = manager.getResourceDescription(resource);
if (description != null) {
Iterable<IEObjectDescription> descriptions = description.getExportedObjects();
helper.checkUniqueNames(descriptions, cancelIndicator, this);
}
}
}
use of org.eclipse.xtext.resource.IEObjectDescription in project n4js by eclipse.
the class N4JSClassifierWizardModelValidator method getClassifierObjectDescriptionForFQN.
/**
* Returns with the index entry representing a classifier for the given classifier FQN argument.
*
* @param fqn
* the fully qualified name of the classifier.
* @return the index entry representing the classifier.
*/
protected IEObjectDescription getClassifierObjectDescriptionForFQN(String fqn) {
QualifiedName name = qualifiedNameConverter.toQualifiedName(fqn);
Iterable<IEObjectDescription> foundObjects = descriptions.getExportedObjects(TypesPackage.eINSTANCE.getTClassifier(), name, false);
return Iterables.getFirst(foundObjects, null);
}
Aggregations