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;
}
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);
}
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);
}
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);
}
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();
}
}
Aggregations