use of org.eclipse.jface.text.ITextViewer in project eclipse.platform.text by eclipse.
the class LinkedModeUI method ensureAnnotationModelInstalled.
private void ensureAnnotationModelInstalled() {
LinkedPositionAnnotations lpa = fCurrentTarget.fAnnotationModel;
if (lpa != null) {
ITextViewer viewer = fCurrentTarget.getViewer();
if (viewer instanceof ISourceViewer) {
ISourceViewer sv = (ISourceViewer) viewer;
IAnnotationModel model = sv.getAnnotationModel();
if (model instanceof IAnnotationModelExtension) {
IAnnotationModelExtension ext = (IAnnotationModelExtension) model;
IAnnotationModel ourModel = ext.getAnnotationModel(getUniqueKey());
if (ourModel == null) {
ext.addAnnotationModel(getUniqueKey(), lpa);
}
}
}
}
}
use of org.eclipse.jface.text.ITextViewer in project eclipse.platform.text by eclipse.
the class LinkedModeUI method select.
private void select() {
ITextViewer viewer = fCurrentTarget.getViewer();
if (viewer instanceof ITextViewerExtension5) {
ITextViewerExtension5 extension5 = (ITextViewerExtension5) viewer;
extension5.exposeModelRange(new Region(fFramePosition.offset, fFramePosition.length));
} else if (!viewer.overlapsWithVisibleRegion(fFramePosition.offset, fFramePosition.length)) {
viewer.resetVisibleRegion();
}
viewer.revealRange(fFramePosition.offset, fFramePosition.length);
viewer.setSelectedRange(fFramePosition.offset, fFramePosition.length);
}
use of org.eclipse.jface.text.ITextViewer in project mylyn.docs by eclipse.
the class FileRefHyperlinkDetectorTest method testNoHyperlinkInDocument.
@Test
public void testNoHyperlinkInDocument() throws CoreException {
ImmutableList<String> fileRefPatterns = ImmutableList.of("include::(.+)\\[\\]", "image::(.+)\\[\\]");
FileRefHyperlinkDetector fileRefHyperlinkDetector = new FileRefHyperlinkDetector(project, fileRefPatterns);
ITextViewer mockTextViewer = mock(ITextViewer.class);
when(mockTextViewer.getDocument()).thenReturn(new Document("Some contents without hyperlink in it."));
IHyperlink[] detectHyperlinks = fileRefHyperlinkDetector.detectHyperlinks(mockTextViewer, new Region(7, 15), false);
assertThat(detectHyperlinks, is(nullValue()));
}
use of org.eclipse.jface.text.ITextViewer in project mylyn.docs by eclipse.
the class IncrementalFindHandler method execute.
public Object execute(ExecutionEvent event) throws ExecutionException {
ITextViewer viewer = getTextViewer(event);
if (viewer != null) {
IFindReplaceTarget findReplaceTarget = viewer.getFindReplaceTarget();
if (findReplaceTarget.canPerformFind()) {
if (findReplaceTarget instanceof IFindReplaceTargetExtension) {
IFindReplaceTargetExtension extension = (IFindReplaceTargetExtension) findReplaceTarget;
extension.beginSession();
}
}
}
return null;
}
use of org.eclipse.jface.text.ITextViewer in project n4js by eclipse.
the class HyperlinkXpectMethod method hyperlinks.
/**
* @param expectation
* a list of expected URIs to jump to by this hyperlink
* @param resource
* the resource under test
* @param region
* the offset where hyperlinking should be invoked
* @throws Exception
* some exceptions
*/
@ParameterParser(syntax = "('at' arg2=STRING)?")
@Xpect
public void hyperlinks(// arg0
@CommaSeparatedValuesExpectation ICommaSeparatedValuesExpectation expectation, // arg1
@ThisResource XtextResource resource, // arg2
RegionWithCursor region) throws Exception {
ContentAssistProcessorTestBuilder fixture = n4ContentAssistProcessorTestBuilderHelper.createTestBuilderForResource(resource);
String currentModelToParse = resource.getParseResult().getRootNode().getText();
IXtextDocument xtextDocument = fixture.getDocument(resource, currentModelToParse);
// in case of cross-file hyperlinks, we have to make sure the target resources are fully resolved
final ResourceSet resSet = resource.getResourceSet();
for (Resource currRes : new ArrayList<>(resSet.getResources())) N4JSResource.postProcess(currRes);
ITextViewer sourceViewer = fixture.getSourceViewer(currentModelToParse, xtextDocument);
IHyperlink[] hyperlinks = hyperlinkDetector.detectHyperlinks(sourceViewer, new Region(region.getGlobalCursorOffset(), 0), true);
// cleaned up resource, otherwise #createTestBuilder() above will fail next time this method is called
XtextResourceCleanUtil.cleanXtextResource(resource);
ArrayList<String> result = Lists.newArrayList();
if (hyperlinks != null) {
for (IHyperlink hyperlink : hyperlinks) {
result.add(getTargetDescription(resource, hyperlink));
}
}
expectation.assertEquals(result);
}
Aggregations