org.eclipse.jface.text.IDocumentPartitioner Java Examples

The following examples show how to use org.eclipse.jface.text.IDocumentPartitioner. 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: DocumentUtils.java    From http4e with Apache License 2.0 6 votes vote down vote up
public static IDocument createDocument2() {
    IDocument document = new Document();
    if( document != null) {
        IDocumentPartitioner partitioner = new XMLPartitioner(
                new XMLPartitionScanner(), new String[] {
                        XMLPartitionScanner.XML_START_TAG,
                        XMLPartitionScanner.XML_PI,
                        XMLPartitionScanner.XML_DOCTYPE,
                        XMLPartitionScanner.XML_END_TAG,
                        XMLPartitionScanner.XML_TEXT,
                        XMLPartitionScanner.XML_CDATA,
                        XMLPartitionScanner.XML_COMMENT });
        partitioner.connect(document);
        document.setDocumentPartitioner(partitioner);
    }
    return document;
}
 
Example #2
Source File: CommonDocumentProvider.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void disconnect(Object element)
{
	FileInfo fileInfo = getFileInfo(element);

	if (fileInfo != null && fileInfo.fCount == 1)
	{
		IDocument document = getDocument(element);

		if (document != null)
		{
			IDocumentPartitioner partitioner = document.getDocumentPartitioner();

			if (partitioner != null)
			{
				partitioner.disconnect();
				document.setDocumentPartitioner(null);
			}
		}
	}

	super.disconnect(element);
}
 
Example #3
Source File: CompositeDocumentProvider.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void connect(Object element) throws CoreException {
	super.connect(element);

	IDocument document = getDocument(element);
	if (document != null) {
		CompositePartitionScanner partitionScanner = new CompositePartitionScanner(defaultPartitioningConfiguration.createSubPartitionScanner(),
				primaryPartitioningConfiguration.createSubPartitionScanner(), partitionerSwitchStrategy);
		IDocumentPartitioner partitioner = new ExtendedFastPartitioner(partitionScanner, TextUtils.combine(new String[][] { CompositePartitionScanner.SWITCHING_CONTENT_TYPES,
				defaultPartitioningConfiguration.getContentTypes(), primaryPartitioningConfiguration.getContentTypes() }));
		partitionScanner.setPartitioner((IExtendedPartitioner) partitioner);
		partitioner.connect(document);
		document.setDocumentPartitioner(partitioner);
		CommonEditorPlugin.getDefault().getDocumentScopeManager()
				.registerConfigurations(document, new IPartitioningConfiguration[] { defaultPartitioningConfiguration, primaryPartitioningConfiguration });
	}
}
 
Example #4
Source File: PartitionUtils.java    From xds-ide with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Sets document's partitioner. 
 *
 * @param document the document to be processed
 * @param partitioningType the partitioning for which to set the partitioner
 * @param partitioner the document's new partitioner
 * 
 * @see org.eclipse.jface.text.IDocumentExtension3#setDocumentPartitioner(IDocument,String,IDocumentPartitioner)
 * @see IDocumentPartitioningListener
 */
public static void setDocumentPartitioning( IDocument document
                                          , String partitioningType
                                          , IDocumentPartitioner partitioner ) 
{
    // Setting the partitioner will trigger a partitionChanged listener that
    // will attempt to use the partitioner to initialize the document's
    // partitions. Therefore, need to connect first.
    partitioner.connect(document);
    if (document instanceof IDocumentExtension3) {
        IDocumentExtension3 extension3= (IDocumentExtension3) document;
        extension3.setDocumentPartitioner(partitioningType, partitioner);
    } else {
        document.setDocumentPartitioner(partitioner);
    }
}
 
Example #5
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 #6
Source File: SourceEditor.java    From textuml with Eclipse Public License 1.0 6 votes vote down vote up
public SourceEditor() {
    setSourceViewerConfiguration(new TextUMLSourceViewerConfiguration(this));
    // set the document provider to create the partitioner
    setDocumentProvider(new FileDocumentProvider() {
        protected IDocument createDocument(Object element) throws CoreException {
            IDocument document = super.createDocument(element);
            if (document != null) {
                // this will create partitions
                IDocumentPartitioner partitioner = new FastPartitioner(new PartitionScanner(),
                        ContentTypes.CONFIGURED_CONTENT_TYPES);
                partitioner.connect(document);
                document.setDocumentPartitioner(partitioner);
            }
            return document;
        }
    });
}
 
Example #7
Source File: XtextDocumentProvider.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Override
protected IDocument createDocument(Object element) throws CoreException {
	IDocument document = null;
	if (isWorkspaceExternalEditorInput(element)) {
		document= createEmptyDocument();
		if (setDocumentContent(document, (IEditorInput) element, getEncoding(element))) {
			setupDocument(element, document);
		}
	} else {
		document = super.createDocument(element);
	}
	if (document != null) {
		IDocumentPartitioner partitioner = documentPartitioner.get();
		partitioner.connect(document);
		document.setDocumentPartitioner(partitioner);
	}
	return document;
}
 
Example #8
Source File: XMLDocumentProvider.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void connect(Object element) throws CoreException
{
	super.connect(element);

	IDocument document = getDocument(element);
	if (document != null)
	{
		CompositePartitionScanner partitionScanner = new CompositePartitionScanner(XMLSourceConfiguration
				.getDefault().createSubPartitionScanner(), new NullSubPartitionScanner(),
				new NullPartitionerSwitchStrategy());
		IDocumentPartitioner partitioner = new ExtendedFastPartitioner(partitionScanner, XMLSourceConfiguration
				.getDefault().getContentTypes());
		partitionScanner.setPartitioner((IExtendedPartitioner) partitioner);
		partitioner.connect(document);
		document.setDocumentPartitioner(partitioner);
		CommonEditorPlugin.getDefault().getDocumentScopeManager()
				.registerConfiguration(document, XMLSourceConfiguration.getDefault());
	}
}
 
Example #9
Source File: PyPartitionScanner.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Checks if the partitioner is correctly set in the document.
 * @return the partitioner that is set in the document
 */
public static IDocumentPartitioner checkPartitionScanner(IDocument document,
        IGrammarVersionProvider grammarVersionProvider) {
    if (document == null) {
        return null;
    }

    IDocumentExtension3 docExtension = (IDocumentExtension3) document;
    IDocumentPartitioner partitioner = docExtension.getDocumentPartitioner(IPythonPartitions.PYTHON_PARTITION_TYPE);
    if (partitioner == null) {
        addPartitionScanner(document, grammarVersionProvider);
        //get it again for the next check
        partitioner = docExtension.getDocumentPartitioner(IPythonPartitions.PYTHON_PARTITION_TYPE);
    }
    if (!(partitioner instanceof PyPartitioner)) {
        Log.log("Partitioner should be subclass of PyPartitioner. It is " + partitioner.getClass());
    }

    return partitioner;
}
 
Example #10
Source File: PyPartitionScanner.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * @see http://help.eclipse.org/help31/index.jsp?topic=/org.eclipse.platform.doc.isv/guide/editors_documents.htm
 * @see http://jroller.com/page/bobfoster -  Saturday July 16, 2005
 * @param document the document where we want to add the partitioner
 * @return the added document partitioner (or null)
 */
public static IDocumentPartitioner addPartitionScanner(IDocument document,
        IGrammarVersionProvider grammarVersionProvider) {
    if (document != null) {
        IDocumentExtension3 docExtension = (IDocumentExtension3) document;
        IDocumentPartitioner curr = docExtension.getDocumentPartitioner(IPythonPartitions.PYTHON_PARTITION_TYPE);

        if (curr == null) {
            //set the new one
            PyPartitioner partitioner = createPyPartitioner();
            partitioner.connect(document);
            docExtension.setDocumentPartitioner(IPythonPartitions.PYTHON_PARTITION_TYPE, partitioner);
            return partitioner;
        } else {
            return curr;
        }
    }
    return null;
}
 
Example #11
Source File: PySelection.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Get the current line up to where the cursor is without any comments or literals.
 */
public String getLineContentsToCursor(boolean removeComments, boolean removeLiterals) throws BadLocationException {
    if (removeComments == false || removeLiterals == false) {
        throw new RuntimeException("Currently only accepts removing the literals and comments.");
    }
    int cursorOffset = getAbsoluteCursorOffset();

    IRegion lineInformationOfOffset = doc.getLineInformationOfOffset(cursorOffset);
    IDocumentPartitioner partitioner = PyPartitionScanner.checkPartitionScanner(doc);
    if (partitioner == null) {
        throw new RuntimeException("Partitioner not set up.");
    }

    StringBuffer buffer = new StringBuffer();
    int offset = lineInformationOfOffset.getOffset();
    int length = lineInformationOfOffset.getLength();
    for (int i = offset; i <= offset + length && i < cursorOffset; i++) {
        String contentType = partitioner.getContentType(i);
        if (contentType.equals(IPythonPartitions.PY_DEFAULT)) {
            buffer.append(doc.getChar(i));
        } else {
            buffer.append(' ');
        }
    }
    return buffer.toString();
}
 
Example #12
Source File: DocumentUtils.java    From http4e with Apache License 2.0 6 votes vote down vote up
public static IDocument createDocument1(){
   IDocument doc = new Document(){
      public String getDefaultLineDelimiter(){
         return String.valueOf(AssistConstants.LINE_DELIM_NL) /*super.getDefaultLineDelimiter()*/;
      }
   };
   IDocumentPartitioner partitioner = new DefaultPartitioner(
         new HPartitionScanner(), 
         new String[] {
             HPartitionScanner.COMMENT,
             HPartitionScanner.PROPERTY_VALUE});
   partitioner.connect(doc);
   doc.setDocumentPartitioner(partitioner);
   
   return doc;  
}
 
Example #13
Source File: SimpleDocumentProvider.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void connect(Object element) throws CoreException {
	super.connect(element);

	IDocument document = this.getDocument(element);
	if (document != null) {
		IPartitioningConfiguration configuration = this.getPartitioningConfiguration();
		IDocumentPartitioner partitioner = new ExtendedFastPartitioner(this.createPartitionScanner(), configuration.getContentTypes());

		partitioner.connect(document);
		document.setDocumentPartitioner(partitioner);

		CommonEditorPlugin.getDefault().getDocumentScopeManager().registerConfiguration(document, configuration);
	}
}
 
Example #14
Source File: JavaTextTools.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Sets up the Java document partitioner for the given document for the given partitioning.
 *
 * @param document the document to be set up
 * @param partitioning the document partitioning
 * @since 3.0
 */
public void setupJavaDocumentPartitioner(IDocument document, String partitioning) {
	IDocumentPartitioner partitioner= createDocumentPartitioner();
	if (document instanceof IDocumentExtension3) {
		IDocumentExtension3 extension3= (IDocumentExtension3) document;
		extension3.setDocumentPartitioner(partitioning, partitioner);
	} else {
		document.setDocumentPartitioner(partitioner);
	}
	partitioner.connect(document);
}
 
Example #15
Source File: StructuredDocumentCloner.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
public IStructuredDocument clone(IDocument original) {
  IModelManager modelManager = StructuredModelManager.getModelManager();
  String modelId = getModelId(original);
  if (modelId == null) {
    GWTPluginLog.logError("Could not get a model ID for the document to be formatted.");
    return null;
  }

  /*
   * The XML formatter requires a managed model (discovered by it crashing
   * when given an unmanaged model.) Unfortunately, we cannot create a managed
   * in-memory (i.e. non-file backed) model via IModelManager API (there is
   * one method that may work, but it is deprecated.) Instead, we copy the
   * existing model into a temp model with ID "temp".
   */
  try {
    IStructuredModel modelClone = modelManager.copyModelForEdit(modelId,
        "structuredDocumentClonerModel" + nextId.getAndIncrement());
    modelClone.setBaseLocation(getModelBaseLocation(original));

    IStructuredDocument documentClone = modelClone.getStructuredDocument();
    documentClone.set(original.get());

    // Create and connect the partitioner to the document
    IDocumentPartitioner tempPartitioner = documentPartitionerFactory.createDocumentPartitioner();
    ((IDocumentExtension3) documentClone).setDocumentPartitioner(
        partitioning, tempPartitioner);
    tempPartitioner.connect(documentClone);

    // Save the cloned model so we can release it later
    modelClones.put(documentClone, modelClone);

    return documentClone;
  } catch (ResourceInUse e1) {
    GWTPluginLog.logError(e1,
        "Could not copy the original model to be formatted.");
    return null;
  }
}
 
Example #16
Source File: PropertiesFileDocumentSetupParticipant.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @param document the document
 * @see org.eclipse.core.filebuffers.IDocumentSetupParticipant#setup(org.eclipse.jface.text.IDocument)
 */
public static void setupDocument(IDocument document) {
	IDocumentPartitioner partitioner= createDocumentPartitioner();
	if (document instanceof IDocumentExtension3) {
		IDocumentExtension3 extension3= (IDocumentExtension3) document;
		extension3.setDocumentPartitioner(IPropertiesFilePartitions.PROPERTIES_FILE_PARTITIONING, partitioner);
	} else {
		document.setDocumentPartitioner(partitioner);
	}
	partitioner.connect(document);
}
 
Example #17
Source File: XMLDocumentProvider.java    From codeexamples-eclipse with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected IDocument createDocument(Object element) throws CoreException {
	IDocument document = super.createDocument(element);
	if (document != null) {
		IDocumentPartitioner partitioner = new FastPartitioner(new XMLPartitionScanner(),
				new String[] { XMLPartitionScanner.XML_TAG, XMLPartitionScanner.XML_COMMENT });
		partitioner.connect(document);
		document.setDocumentPartitioner(partitioner);
	}
	return document;
}
 
Example #18
Source File: JSDocumentProvider.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @see DocumentProvider#createDocument(java.lang.Object)
 */
protected IDocument createDocument( Object element ) throws CoreException
{
	IDocument document = super.createDocument( element );
	if ( document != null )
	{
		IDocumentPartitioner partitioner = new DefaultPartitioner( new JSPartitionScanner( ),
				colorTokens );
		partitioner.connect( document );
		document.setDocumentPartitioner( partitioner );
	}
	return document;
}
 
Example #19
Source File: ReportDocumentProvider.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected IDocument createDocument( Object element ) throws CoreException
{
	IDocument document = super.createDocument( element );
	if ( document != null )
	{
		IDocumentPartitioner partitioner = new FastPartitioner( new XMLPartitionScanner( ),
				new String[]{
						XMLPartitionScanner.XML_TAG,
						XMLPartitionScanner.XML_COMMENT
				} );
		partitioner.connect( document );
		document.setDocumentPartitioner( partitioner );
	}
	return document;
}
 
Example #20
Source File: XMLDocumentProvider.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
@Override
protected IDocument createDocument(Object element) throws CoreException {
  IDocument document = super.createDocument(element);
  if (document != null) {
    IDocumentPartitioner partitioner = new DefaultPartitioner(new XMLPartitionScanner(),
            new String[] { XMLPartitionScanner.XML_TAG, XMLPartitionScanner.XML_COMMENT });
    partitioner.connect(document);
    document.setDocumentPartitioner(partitioner);
  }
  return document;
}
 
Example #21
Source File: IDEFileReportDocumentProvider.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected IDocument createDocument( Object element ) throws CoreException
{
	IDocument document = super.createDocument( element );
	if ( document != null )
	{
		IDocumentPartitioner partitioner = new FastPartitioner( new XMLPartitionScanner( ),
				new String[]{
						XMLPartitionScanner.XML_TAG,
						XMLPartitionScanner.XML_COMMENT
				} );
		partitioner.connect( document );
		document.setDocumentPartitioner( partitioner );
	}
	return document;
}
 
Example #22
Source File: EditorConfigDocumentSetupParticipant.java    From editorconfig-eclipse with Apache License 2.0 5 votes vote down vote up
public static void setupDocument(IDocument document) {
	IDocumentPartitioner partitioner = createDocumentPartitioner();
	if (document instanceof IDocumentExtension3) {
		IDocumentExtension3 extension3 = (IDocumentExtension3) document;
		extension3.setDocumentPartitioner(IEditorConfigPartitions.EDITOR_CONFIG_PARTITIONING, partitioner);
	} else {
		document.setDocumentPartitioner(partitioner);
	}
	partitioner.connect(document);
}
 
Example #23
Source File: AbstractFormatterPreferencePage.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @param composite
 */
public SourceViewer createSourcePreview(Composite composite, IScriptFormatterFactory factory)
{
	IPreferenceStore generalTextStore = EditorsUI.getPreferenceStore();
	// TODO - Note that we pass the factory's preferences store and not calling to this.getPrefereceStore.
	// In case we decide to unify the preferences into the this plugin, we might need to change this.
	IPreferenceStore store = new ChainedPreferenceStore(new IPreferenceStore[] { factory.getPreferenceStore(),
			generalTextStore });
	SourceViewer fPreviewViewer = createPreviewViewer(composite, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL
			| SWT.BORDER, store);
	if (fPreviewViewer == null)
	{
		return null;
	}
	SourceViewerConfiguration configuration = (SourceViewerConfiguration) factory
			.createSimpleSourceViewerConfiguration(fColorManager, store, null, false);
	fPreviewViewer.configure(configuration);
	if (fPreviewViewer.getTextWidget().getTabs() == 0)
	{
		fPreviewViewer.getTextWidget().setTabs(4);
	}
	new ScriptSourcePreviewerUpdater(fPreviewViewer, configuration, store);
	fPreviewViewer.setEditable(false);
	IDocument document = new Document();
	fPreviewViewer.setDocument(document);
	IPartitioningConfiguration partitioningConfiguration = (IPartitioningConfiguration) factory
			.getPartitioningConfiguration();
	CompositePartitionScanner partitionScanner = new CompositePartitionScanner(
			partitioningConfiguration.createSubPartitionScanner(), new NullSubPartitionScanner(),
			new NullPartitionerSwitchStrategy());
	IDocumentPartitioner partitioner = new ExtendedFastPartitioner(partitionScanner,
			partitioningConfiguration.getContentTypes());
	partitionScanner.setPartitioner((IExtendedPartitioner) partitioner);
	partitioner.connect(document);
	document.setDocumentPartitioner(partitioner);
	return fPreviewViewer;
}
 
Example #24
Source File: CSSMergeViewer.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected IDocumentPartitioner getDocumentPartitioner()
{
	IDocumentPartitioner partitioner = new ExtendedFastPartitioner(new CSSSourcePartitionScannerJFlex(),
			CSSSourceConfiguration.getDefault().getContentTypes());
	return partitioner;
}
 
Example #25
Source File: PatternExpressionModelBuilder.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private List<ITypedRegion> allGroovyPartitions(IDocument document) {
    final IDocumentPartitioner partitioner = document.getDocumentPartitioner();
    final ITypedRegion[] regions = partitioner.computePartitioning(0, document.getLength());
    final List<ITypedRegion> groovyPartions = new ArrayList<>();
    for (int i = 0; i < regions.length; i++) {
        final ITypedRegion partition = regions[i];
        if (PatternExpressionViewer.GROOVY_EXPRESSION_CONTENT_TYPE.equals(partition.getType())) {
            groovyPartions.add(partition);
        }
    }
    return groovyPartions;
}
 
Example #26
Source File: JSMergeViewer.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected IDocumentPartitioner getDocumentPartitioner()
{
	IDocumentPartitioner partitioner = new ExtendedFastPartitioner(new JSSourcePartitionScannerJFlex(),
			JSSourceConfiguration.getDefault().getContentTypes());
	return partitioner;
}
 
Example #27
Source File: XMLMergeViewer.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected IDocumentPartitioner getDocumentPartitioner()
{
	CompositePartitionScanner partitionScanner = new CompositePartitionScanner(XMLSourceConfiguration.getDefault()
			.createSubPartitionScanner(), new NullSubPartitionScanner(), new NullPartitionerSwitchStrategy());
	IDocumentPartitioner partitioner = new ExtendedFastPartitioner(partitionScanner, XMLSourceConfiguration
			.getDefault().getContentTypes());
	return partitioner;
}
 
Example #28
Source File: SVGDocumentProvider.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void connect(Object element) throws CoreException
{
	super.connect(element);

	IDocument document = getDocument(element);

	if (document != null)
	{
		CompositePartitionScanner partitionScanner = new CompositePartitionScanner( //
			SVGSourceConfiguration.getDefault().createSubPartitionScanner(), //
			new NullSubPartitionScanner(), //
			new NullPartitionerSwitchStrategy() //
		);
		IDocumentPartitioner partitioner = new ExtendedFastPartitioner( //
			partitionScanner, //
			SVGSourceConfiguration.getDefault().getContentTypes() //
		);

		partitionScanner.setPartitioner((IExtendedPartitioner) partitioner);
		partitioner.connect(document);
		document.setDocumentPartitioner(partitioner);

		CommonEditorPlugin.getDefault().getDocumentScopeManager().registerConfiguration( //
			document, //
			SVGSourceConfiguration.getDefault() //
		);
	}
}
 
Example #29
Source File: SVGMergeViewer.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected IDocumentPartitioner getDocumentPartitioner()
{
	CompositePartitionScanner partitionScanner = new CompositePartitionScanner( //
			SVGSourceConfiguration.getDefault().createSubPartitionScanner(), //
			new NullSubPartitionScanner(), //
			new NullPartitionerSwitchStrategy() //
	);
	IDocumentPartitioner partitioner = new ExtendedFastPartitioner( //
			partitionScanner, //
			SVGSourceConfiguration.getDefault().getContentTypes() //
	);
	return partitioner;
}
 
Example #30
Source File: PyPartitionScannerTest.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
public void testPartitioning() throws Exception {
    Document doc = new Document("class Foo: #comment\n" +
            "    pass\n");
    IDocumentPartitioner partitioner = PyPartitionScanner.addPartitionScanner(doc, null);
    assertEquals(IPythonPartitions.PY_DEFAULT, partitioner.getContentType(5));
    assertEquals(IPythonPartitions.PY_COMMENT, partitioner.getContentType(15));
}