Search in sources :

Example 36 with IDocumentPartitioner

use of org.eclipse.jface.text.IDocumentPartitioner in project xtext-xtend by eclipse.

the class ImportAwareActionTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    this.document = this.<XtextDocument>get(XtextDocument.class);
    IDocumentPartitioner partitioner = this.<IDocumentPartitioner>get(IDocumentPartitioner.class);
    partitioner.connect(this.document);
    this.document.setDocumentPartitioner(partitioner);
}
Also used : IDocumentPartitioner(org.eclipse.jface.text.IDocumentPartitioner) XtextDocument(org.eclipse.xtext.ui.editor.model.XtextDocument)

Example 37 with IDocumentPartitioner

use of org.eclipse.jface.text.IDocumentPartitioner in project dbeaver by dbeaver.

the class JSONTextEditor method setupDocument.

private void setupDocument() {
    IDocument document = getDocument();
    if (document != null) {
        IDocumentPartitioner partitioner = new FastPartitioner(new JSONPartitionScanner(), new String[] { JSONPartitionScanner.JSON_STRING });
        partitioner.connect(document);
        ((IDocumentExtension3) document).setDocumentPartitioner(JSONPartitionScanner.JSON_PARTITIONING, partitioner);
    }
}
Also used : IDocumentExtension3(org.eclipse.jface.text.IDocumentExtension3) IDocumentPartitioner(org.eclipse.jface.text.IDocumentPartitioner) FastPartitioner(org.eclipse.jface.text.rules.FastPartitioner) IDocument(org.eclipse.jface.text.IDocument)

Example 38 with IDocumentPartitioner

use of org.eclipse.jface.text.IDocumentPartitioner in project dbeaver by dbeaver.

the class XMLEditor method setupDocument.

private void setupDocument() {
    IDocument document = getDocument();
    if (document != null) {
        IDocumentPartitioner partitioner = new FastPartitioner(new XMLPartitionScanner(), new String[] { XMLPartitionScanner.XML_TAG, XMLPartitionScanner.XML_COMMENT });
        partitioner.connect(document);
        ((IDocumentExtension3) document).setDocumentPartitioner(XMLPartitionScanner.XML_PARTITIONING, partitioner);
    }
}
Also used : IDocumentExtension3(org.eclipse.jface.text.IDocumentExtension3) IDocumentPartitioner(org.eclipse.jface.text.IDocumentPartitioner) FastPartitioner(org.eclipse.jface.text.rules.FastPartitioner) IDocument(org.eclipse.jface.text.IDocument)

Example 39 with IDocumentPartitioner

use of org.eclipse.jface.text.IDocumentPartitioner in project xtext-eclipse by eclipse.

the class StreamContentDocumentProvider method setupDocument.

protected void setupDocument(Object element, IDocument document) {
    String content = getString(element);
    document.set(content);
    IDocumentPartitioner partitioner = documentPartitioner.get();
    partitioner.connect(document);
    document.setDocumentPartitioner(partitioner);
    XtextResource resource = createResource(element);
    loadResource(element, resource);
    if (resource != null) {
        ((XtextDocument) document).setInput(resource);
    }
}
Also used : IDocumentPartitioner(org.eclipse.jface.text.IDocumentPartitioner) XtextResource(org.eclipse.xtext.resource.XtextResource) XtextDocument(org.eclipse.xtext.ui.editor.model.XtextDocument)

Example 40 with IDocumentPartitioner

use of org.eclipse.jface.text.IDocumentPartitioner in project cubrid-manager by CUBRID.

the class QueryEditorPart method getQuerySQLStartPos.

/**
	 * Get query SQL start position
	 *
	 * @param document PersistentDocument
	 * @param queries String
	 * @param cursorPosOffset int
	 * @return int
	 */
private static int getQuerySQLStartPos(SQLDocument document, String queries, int cursorPosOffset) {
    // TODO #664 check whether xml queries?
    char[] buffer = queries.toCharArray();
    IDocumentPartitioner docPartitioner = document.getDocumentPartitioner(ISQLPartitions.SQL_PARTITIONING);
    int start = cursorPosOffset;
    for (int i = start; i >= 0; i--) {
        if (buffer[i] == ';') {
            String contentType = docPartitioner == null ? IDocument.DEFAULT_CONTENT_TYPE : docPartitioner.getContentType(i);
            boolean isBreak = !ISQLPartitions.SQL_MULTI_LINE_COMMENT.equals(contentType) && !ISQLPartitions.SQL_SINGLE_LINE_COMMENT.equals(contentType) && !ISQLPartitions.SQL_STRING.equals(contentType);
            if (isBreak) {
                break;
            }
        }
        start--;
    }
    start++;
    for (int i = start; i < buffer.length; i++) {
        if (buffer[i] == '\n' || buffer[i] == '\r' || buffer[i] == ' ') {
            start++;
        } else {
            break;
        }
    }
    return start;
}
Also used : IDocumentPartitioner(org.eclipse.jface.text.IDocumentPartitioner) Point(org.eclipse.swt.graphics.Point)

Aggregations

IDocumentPartitioner (org.eclipse.jface.text.IDocumentPartitioner)72 IDocument (org.eclipse.jface.text.IDocument)27 IDocumentExtension3 (org.eclipse.jface.text.IDocumentExtension3)27 FastPartitioner (org.eclipse.jface.text.rules.FastPartitioner)25 IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)12 IStructuredModel (org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)9 IFile (org.eclipse.core.resources.IFile)7 IModelManager (org.eclipse.wst.sse.core.internal.provisional.IModelManager)7 IStructuredTextPartitioner (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredTextPartitioner)6 BadLocationException (org.eclipse.jface.text.BadLocationException)5 ITypedRegion (org.eclipse.jface.text.ITypedRegion)5 DocumentEvent (org.eclipse.jface.text.DocumentEvent)4 IDocumentListener (org.eclipse.jface.text.IDocumentListener)4 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 ITextFileBuffer (org.eclipse.core.filebuffers.ITextFileBuffer)3 IPath (org.eclipse.core.runtime.IPath)3 XtextDocument (org.eclipse.xtext.ui.editor.model.XtextDocument)3 SQLDocument (com.cubrid.common.ui.query.editor.SQLDocument)2 SQLPartitionScanner (com.cubrid.common.ui.query.editor.SQLPartitionScanner)2