public IXtextDocument getDocument() { return currentEditor.getDocument(); }
protected void handleProjectionDisabled() { if (editor.getDocument() != null) { editor.getDocument().removeModelListener(this); } }
protected void waitForReconciler(final XtextEditor editor) { editor.getDocument().readOnly(new IUnitOfWork.Void<XtextResource>() { @Override public void process(XtextResource state) throws Exception { // do nothing } }); }
protected void waitForReconciler(final XtextEditor editor) { editor.getDocument().readOnly(new IUnitOfWork.Void<XtextResource>() { @Override public void process(XtextResource state) throws Exception { // do nothing } }); }
public void waitForReconciler(XtextEditor editor) { editor.getDocument().readOnly(new IUnitOfWork.Void<XtextResource>() { @Override public void process(XtextResource state) throws Exception { // this doesn't execute before the reconciler has finished } }); }
public IXtextDocument getXtextDocument(URI uri) { IEditorPart editor = editorOpener.open(uri, false); if (editor instanceof XtextEditor) { XtextEditor xtextEditor = (XtextEditor) editor; return xtextEditor.getDocument(); } return null; }
protected IOutlineNode getOutlineTree(CharSequence modelAsText) throws Exception { file = IResourcesSetupUtil.createFile(TEST_PROJECT + "/test." + fileExtension, modelAsText.toString()); editor = openEditor(file); document = editor.getDocument(); return treeProvider.createRoot(document); }
public Object execute(final ExecutionEvent event) throws ExecutionException { final XtextEditor xtextEditor = EditorUtils.getActiveXtextEditor(event); if (xtextEditor != null) { final IXtextDocument document = xtextEditor.getDocument(); document.readOnly(new IUnitOfWork.Void<XtextResource>() { @Override public void process(XtextResource state) throws Exception { final QuickOutlinePopup quickOutlinePopup = createPopup(xtextEditor.getEditorSite().getShell()); quickOutlinePopup.setEditor(xtextEditor); quickOutlinePopup.setInput(document); quickOutlinePopup.setEvent((Event) event.getTrigger()); quickOutlinePopup.open(); } }); } return null; }
protected Pair<URI, IXtextDocument> getEntry(IWorkbenchPartReference partRef) { IWorkbenchPart part = partRef.getPart(false); if (part instanceof XtextEditor) { XtextEditor xtextEditor = (XtextEditor) part; URI resourceURI = getResourceURI(xtextEditor); IXtextDocument document = xtextEditor.getDocument(); if (resourceURI != null && document != null) return Tuples.create(resourceURI, document); } return null; }
private ValidationJob newValidationJob(XtextEditor editor) { MarkerIssueProcessor markerIssueProcessor = new MarkerIssueProcessor(editor.getResource(), markerCreator, markerTypeProvider); ValidationJob validationJob = new ValidationJob(resourceValidator, editor.getDocument(), markerIssueProcessor, CheckMode.NORMAL_AND_FAST); return validationJob; } }
@Override protected String getQualifiedName(ExecutionEvent event) { XtextEditor activeXtextEditor = EditorUtils.getActiveXtextEditor(event); if (activeXtextEditor == null) { return null; } final ITextSelection selection = getTextSelection(activeXtextEditor); return activeXtextEditor.getDocument().readOnly(new IUnitOfWork<String, XtextResource>() { public String exec(XtextResource xTextResource) throws Exception { EObject selectedElement = getSelectedName(selection, xTextResource); return getQualifiedName(selectedElement); } }); }
protected void assertState(String string, XtextEditor editor) { int cursor = string.indexOf('|'); assertEquals(string.replace("|", ""), editor.getDocument().get()); ITextSelection selection = (ITextSelection) editor.getSelectionProvider().getSelection(); assertEquals("unexpected cursor position:",cursor, selection.getOffset()); }
protected void calculateProjectionAnnotationModel(boolean allowCollapse) { ProjectionAnnotationModel projectionAnnotationModel = this.viewer.getProjectionAnnotationModel(); if (projectionAnnotationModel != null) { // make a defensive copy as we modify the folded positions in subsequent operations Collection<FoldedPosition> foldedPositions = Sets.newLinkedHashSet(foldingRegionProvider.getFoldingRegions(editor.getDocument())); Annotation[] newRegions = mergeFoldingRegions(foldedPositions, projectionAnnotationModel); updateFoldingRegions(allowCollapse, projectionAnnotationModel, foldedPositions, newRegions); } }
protected void assertState(String string, XtextEditor editor) { int cursor = string.indexOf('|'); assertEquals(string.replace("|", ""), editor.getDocument().get()); ITextSelection selection = (ITextSelection) editor.getSelectionProvider().getSelection(); assertEquals("unexpected cursor position:",cursor, selection.getOffset()); }
protected void assertState(XtextEditor editor, String string) { int cursor = string.indexOf('|'); assertEquals(string.replace("|", ""), editor.getDocument().get()); ITextSelection selection = (ITextSelection) editor.getSelectionProvider().getSelection(); assertEquals("unexpected cursor position:",cursor, selection.getOffset()); }
public Object execute(ExecutionEvent event) throws ExecutionException { try { XtextEditor editor = EditorUtils.getActiveXtextEditor(event); if (editor != null) { final ITextSelection selection = (ITextSelection) editor.getSelectionProvider().getSelection(); editor.getDocument().readOnly(new IUnitOfWork.Void<XtextResource>() { @Override public void process(XtextResource state) throws Exception { EObject target = eObjectAtOffsetHelper.resolveElementAt(state, selection.getOffset()); findReferences(target); } }); } } catch (Exception e) { LOG.error(Messages.FindReferencesHandler_3, e); } return null; }
protected void assertState(String string, XtextEditor editor) { int cursor = string.indexOf('|'); assertEquals(string.replace("|", ""), editor.getDocument().get()); ITextSelection selection = (ITextSelection) editor.getSelectionProvider().getSelection(); assertEquals("unexpected cursor position:",cursor, selection.getOffset()); }
protected void handleProjectionEnabled() { handleProjectionDisabled(); if (isInstalled()) { initialize(); editor.getDocument().addModelListener(this); } }
@Override public void run() { ITextSelection selection = (ITextSelection) xtextEditor.getSelectionProvider().getSelection(); ITextRegion currentEditorSelection = new TextRegion(selection.getOffset(), selection.getLength()); ITextRegion nextSelection = xtextEditor.getDocument().readOnly(createTextSelectionWork(currentEditorSelection)); if (nextSelection == null || nextSelection == ITextRegion.EMPTY_REGION || nextSelection.equals(currentEditorSelection)) { return; } xtextEditor.selectAndReveal(nextSelection.getOffset(), nextSelection.getLength()); }
public Object execute(ExecutionEvent event) throws ExecutionException { XtextEditor xtextEditor = EditorUtils.getActiveXtextEditor(event); if (xtextEditor != null) { IValidationIssueProcessor issueProcessor; IXtextDocument xtextDocument = xtextEditor.getDocument(); IResource resource = xtextEditor.getResource(); if(resource != null) issueProcessor = new MarkerIssueProcessor(resource, markerCreator, markerTypeProvider); else issueProcessor = new AnnotationIssueProcessor(xtextDocument, xtextEditor.getInternalSourceViewer().getAnnotationModel(), issueResolutionProvider); ValidationJob validationJob = new ValidationJob(resourceValidator, xtextDocument, issueProcessor, CheckMode.ALL); validationJob.schedule(); } return this; } }