Java Code Examples for org.eclipse.jface.text.Document#setDocumentPartitioner()

The following examples show how to use org.eclipse.jface.text.Document#setDocumentPartitioner() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EvaluateConstantExpressionPage.java    From tlaplus with MIT License 6 votes vote down vote up
/**
    * Gets the data provider for the current page
    */
   @Override
public void loadData() throws CoreException {
	final TLCOutputSourceRegistry modelCheckSourceRegistry = TLCOutputSourceRegistry.getModelCheckSourceRegistry();
	final TLCModelLaunchDataProvider provider = modelCheckSourceRegistry.getProvider(getModel());
	if (provider != null) {
		provider.addDataPresenter(this);
	} else {
		// no data provider
		m_expressionOutput.getTextWidget().setText("");
	}
   	
	final Document document = new Document(getModel().getEvalExpression());
	final IDocumentPartitioner partitioner = new TLAFastPartitioner(
			TLAEditorActivator.getDefault().getTLAPartitionScanner(), TLAPartitionScanner.TLA_PARTITION_TYPES);
	document.setDocumentPartitioner(TLAPartitionScanner.TLA_PARTITIONING, partitioner);
	partitioner.connect(document);
	m_expressionInput.setDocument(document);
}
 
Example 2
Source File: ResultPage.java    From tlaplus with MIT License 6 votes vote down vote up
/**
    * Gets the data provider for the current page
    */
   @Override
public void loadData() throws CoreException {
   	final TLCOutputSourceRegistry modelCheckSourceRegistry = TLCOutputSourceRegistry.getModelCheckSourceRegistry();
   	final TLCModelLaunchDataProvider provider = modelCheckSourceRegistry.getProvider(getModel());
	if (provider != null) {
		provider.addDataPresenter(this);
	} else {
		// no data provider
		reinit();
	}

	// constant expression
	final Document document = new Document(getModel().getEvalExpression());
	final IDocumentPartitioner partitioner = new TLAFastPartitioner(
			TLAEditorActivator.getDefault().getTLAPartitionScanner(), TLAPartitionScanner.TLA_PARTITION_TYPES);
	document.setDocumentPartitioner(TLAPartitionScanner.TLA_PARTITIONING, partitioner);
	partitioner.connect(document);
	if (expressionEvalInput != null) {
		expressionEvalInput.setDocument(document);
	}
}
 
Example 3
Source File: TypeScriptAutoIndentStrategy.java    From typescript.java with MIT License 6 votes vote down vote up
/**
 * Installs a java partitioner with <code>document</code>.
 *
 * @param document the document
 */
private static void installJavaStuff(Document document) {
	String[] types= new String[] {
								  IJavaScriptPartitions.JAVA_DOC,
								  IJavaScriptPartitions.JAVA_MULTI_LINE_COMMENT,
								  IJavaScriptPartitions.JAVA_SINGLE_LINE_COMMENT,
								  IJavaScriptPartitions.JAVA_STRING,
								  IJavaScriptPartitions.JAVASCRIPT_TEMPLATE_LITERAL,
								  IJavaScriptPartitions.JAVA_CHARACTER,
								  IJSXPartitions.JSX,
								  IDocument.DEFAULT_CONTENT_TYPE
	};
	FastPartitioner partitioner= new FastPartitioner(new FastTypeScriptPartitionScanner(), types);
	partitioner.connect(document);
	document.setDocumentPartitioner(IJavaScriptPartitions.JAVA_PARTITIONING, partitioner);
}
 
Example 4
Source File: JavaFormatter.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Installs a java partitioner with <code>document</code>.
 *
 * @param document the document
 */
private static void installJavaStuff(Document document) {
	String[] types= new String[] {
								  IJavaPartitions.JAVA_DOC,
								  IJavaPartitions.JAVA_MULTI_LINE_COMMENT,
								  IJavaPartitions.JAVA_SINGLE_LINE_COMMENT,
								  IJavaPartitions.JAVA_STRING,
								  IJavaPartitions.JAVA_CHARACTER,
								  IDocument.DEFAULT_CONTENT_TYPE
	};
	FastPartitioner partitioner= new FastPartitioner(new FastJavaPartitionScanner(), types);
	partitioner.connect(document);
	document.setDocumentPartitioner(IJavaPartitions.JAVA_PARTITIONING, partitioner);
}
 
Example 5
Source File: JavaAutoIndentStrategy.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Installs a java partitioner with <code>document</code>.
 *
 * @param document the document
 */
private static void installJavaStuff(Document document) {
	String[] types= new String[] {
								  IJavaPartitions.JAVA_DOC,
								  IJavaPartitions.JAVA_MULTI_LINE_COMMENT,
								  IJavaPartitions.JAVA_SINGLE_LINE_COMMENT,
								  IJavaPartitions.JAVA_STRING,
								  IJavaPartitions.JAVA_CHARACTER,
								  IDocument.DEFAULT_CONTENT_TYPE
	};
	FastPartitioner partitioner= new FastPartitioner(new FastJavaPartitionScanner(), types);
	partitioner.connect(document);
	document.setDocumentPartitioner(IJavaPartitions.JAVA_PARTITIONING, partitioner);
}
 
Example 6
Source File: PartitionCodeReaderTest.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
public String setupDocument(Document document) {
    IPartitionTokenScanner scanner = new RuleBasedPartitionScanner();
    FastPartitioner partitioner = new FastPartitioner(scanner, new String[] { IDocument.DEFAULT_CONTENT_TYPE });
    String[] managingPositionCategories = partitioner.getManagingPositionCategories();
    String category = managingPositionCategories[0];
    document.setDocumentPartitioner(partitioner);
    document.addPositionCategory(category);
    return category;
}
 
Example 7
Source File: TypeScriptAutoIndentStrategy.java    From typescript.java with MIT License 2 votes vote down vote up
/**
 * Installs a java partitioner with <code>document</code>.
 *
 * @param document the document
 */
private static void removeJavaStuff(Document document) {
	document.setDocumentPartitioner(IJavaScriptPartitions.JAVA_PARTITIONING, null);
}
 
Example 8
Source File: JavaAutoIndentStrategy.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Installs a java partitioner with <code>document</code>.
 *
 * @param document the document
 */
private static void removeJavaStuff(Document document) {
	document.setDocumentPartitioner(IJavaPartitions.JAVA_PARTITIONING, null);
}