Search in sources :

Example 26 with IDocumentPartitioner

use of org.eclipse.jface.text.IDocumentPartitioner in project webtools.sourceediting by eclipse.

the class JSPJavaCompletionProposalComputer method computeContextInformation.

/**
 * @see org.eclipse.wst.xml.ui.internal.contentassist.AbstractXMLCompletionProposalComputer#computeContextInformation(org.eclipse.wst.sse.ui.contentassist.CompletionProposalInvocationContext, org.eclipse.core.runtime.IProgressMonitor)
 */
public List computeContextInformation(CompletionProposalInvocationContext context, IProgressMonitor monitor) {
    ITextViewer viewer = context.getViewer();
    int documentOffset = context.getInvocationOffset();
    List results = new ArrayList();
    // need to compute context info here, if it's JSP, call java computer
    IDocument doc = viewer.getDocument();
    IDocumentPartitioner dp = null;
    if (doc instanceof IDocumentExtension3) {
        dp = ((IDocumentExtension3) doc).getDocumentPartitioner(IStructuredPartitioning.DEFAULT_STRUCTURED_PARTITIONING);
    }
    if (dp != null) {
        // IDocumentPartitioner dp = viewer.getDocument().getDocumentPartitioner();
        String type = dp.getPartition(documentOffset).getType();
        if (type == IJSPPartitions.JSP_DEFAULT || type == IJSPPartitions.JSP_CONTENT_JAVA) {
            // get context info from completion results...
            List proposals = computeCompletionProposals(context, monitor);
            for (int i = 0; i < proposals.size(); i++) {
                IContextInformation ci = ((ICompletionProposal) proposals.get(i)).getContextInformation();
                if (ci != null)
                    results.add(ci);
            }
        }
    }
    return results;
}
Also used : IDocumentExtension3(org.eclipse.jface.text.IDocumentExtension3) IDocumentPartitioner(org.eclipse.jface.text.IDocumentPartitioner) ICompletionProposal(org.eclipse.jface.text.contentassist.ICompletionProposal) ArrayList(java.util.ArrayList) IContextInformation(org.eclipse.jface.text.contentassist.IContextInformation) ITextRegionList(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList) ArrayList(java.util.ArrayList) List(java.util.List) IDocument(org.eclipse.jface.text.IDocument) ITextViewer(org.eclipse.jface.text.ITextViewer)

Example 27 with IDocumentPartitioner

use of org.eclipse.jface.text.IDocumentPartitioner in project webtools.sourceediting by eclipse.

the class TestXSLHyperlinkDetector method loadXSLFile.

protected void loadXSLFile() throws ResourceAlreadyExists, ResourceInUse, IOException, CoreException {
    IModelManager modelManager = StructuredModelManager.getModelManager();
    model = modelManager.getNewModelForEdit(file, true);
    document = model.getStructuredDocument();
    IDocumentPartitioner partitioner = defaultPartitioner.newInstance();
    partitioner.connect(document);
    document.setDocumentPartitioner(partitioner);
}
Also used : IDocumentPartitioner(org.eclipse.jface.text.IDocumentPartitioner) IModelManager(org.eclipse.wst.sse.core.internal.provisional.IModelManager)

Example 28 with IDocumentPartitioner

use of org.eclipse.jface.text.IDocumentPartitioner in project webtools.sourceediting by eclipse.

the class TestXSLLineStyleProvider method loadXSLFile.

protected void loadXSLFile() throws ResourceAlreadyExists, ResourceInUse, IOException, CoreException {
    IModelManager modelManager = StructuredModelManager.getModelManager();
    model = modelManager.getNewModelForEdit(file, true);
    document = model.getStructuredDocument();
    IDocumentPartitioner partitioner = defaultPartitioner.newInstance();
    partitioner.connect(document);
    document.setDocumentPartitioner(partitioner);
}
Also used : IDocumentPartitioner(org.eclipse.jface.text.IDocumentPartitioner) IModelManager(org.eclipse.wst.sse.core.internal.provisional.IModelManager)

Example 29 with IDocumentPartitioner

use of org.eclipse.jface.text.IDocumentPartitioner in project webtools.sourceediting by eclipse.

the class TestStructuredTextPartitionerForXSL method testXSLNewInstance.

@Test
public void testXSLNewInstance() {
    StructuredTextPartitionerForXSL textPartioner = new StructuredTextPartitionerForXSL();
    IDocumentPartitioner documentPartitioner = textPartioner.newInstance();
    assertTrue("Did not retrieve StructuredTextPartitionerForXSL", documentPartitioner instanceof StructuredTextPartitionerForXSL);
}
Also used : IDocumentPartitioner(org.eclipse.jface.text.IDocumentPartitioner) StructuredTextPartitionerForXSL(org.eclipse.wst.xsl.core.internal.text.rules.StructuredTextPartitionerForXSL) Test(org.junit.Test)

Example 30 with IDocumentPartitioner

use of org.eclipse.jface.text.IDocumentPartitioner in project webtools.sourceediting by eclipse.

the class TestStructuredPartitionerXML method testGetPartitionType.

public void testGetPartitionType() {
    IStructuredModel model = null;
    try {
        model = getModelForEdit("testfiles/xml/example01.xml");
        if (model != null) {
            IStructuredDocument sDoc = model.getStructuredDocument();
            assertTrue("sDoc implementation not instance of IDocumentExtension3", sDoc instanceof IDocumentExtension3);
            IDocumentPartitioner partitioner = ((IDocumentExtension3) sDoc).getDocumentPartitioner(IStructuredPartitioning.DEFAULT_STRUCTURED_PARTITIONING);
            assertTrue("paritioner doesn't implement IStructuredTextPartitioner", partitioner instanceof IStructuredTextPartitioner);
            IStructuredTextPartitioner stp = (IStructuredTextPartitioner) partitioner;
            String defaultPartitionType = stp.getDefaultPartitionType();
            assertTrue("wrong default partition type was: [" + defaultPartitionType + "] should be: [" + IXMLPartitions.XML_DEFAULT + "]", defaultPartitionType.equals(IXMLPartitions.XML_DEFAULT));
        } else {
            assertTrue("could not retrieve structured model", false);
        }
    } finally {
        if (model != null)
            model.releaseFromEdit();
    }
}
Also used : IDocumentExtension3(org.eclipse.jface.text.IDocumentExtension3) IDocumentPartitioner(org.eclipse.jface.text.IDocumentPartitioner) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument) IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel) IStructuredTextPartitioner(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredTextPartitioner)

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