Java 类org.eclipse.jface.text.IDocumentExtension3 实例源码

项目:pgcodekeeper    文件:SqlSourceViewer.java   
@Override
protected void inputChanged(Object newInput, Object oldInput) {
    if (oldInput instanceof IDocumentExtension3) {
        IDocumentExtension3 doc = (IDocumentExtension3) oldInput;
        doc.setDocumentPartitioner(SQLEditorCommonDocumentProvider.SQL_PARTITIONING, null);
        partitioner.disconnect();
    }

    if (newInput instanceof IDocumentExtension3) {
        IDocumentExtension3 extension3 = (IDocumentExtension3) newInput;
        partitioner.connect((IDocument) newInput);
        extension3.setDocumentPartitioner(
                SQLEditorCommonDocumentProvider.SQL_PARTITIONING, partitioner);
    }
    super.inputChanged(newInput, oldInput);
}
项目:Tarski    文件:VisualizationSubscriber.java   
private ITypedRegion getPartition(final String partitionContentType) {
  final IDocumentExtension3 extension = (IDocumentExtension3) this.document;
  ITypedRegion[] computePartitioning = null;
  try {
    computePartitioning = extension.computePartitioning(IDocumentExtension3.DEFAULT_PARTITIONING,
        0, this.document.getLength(), false);
  } catch (BadLocationException | BadPartitioningException e) {
    e.printStackTrace();
  }

  for (final ITypedRegion iTypedRegion : computePartitioning) {
    if (iTypedRegion.getType().equals(partitionContentType)) {
      return iTypedRegion;
    }
  }
  return null;
}
项目:Tarski    文件:SynchronizationManager.java   
private ITypedRegion getPartition(final String partitionContentType) {
  final IDocumentExtension3 extension = (IDocumentExtension3) this.document;
  ITypedRegion[] computePartitioning = null;
  try {
    computePartitioning = extension.computePartitioning(IDocumentExtension3.DEFAULT_PARTITIONING,
        0, this.document.getLength(), false);
  } catch (BadLocationException | BadPartitioningException e) {
    e.printStackTrace();
  }

  for (final ITypedRegion iTypedRegion : computePartitioning) {
    if (iTypedRegion.getType().equals(partitionContentType)) {
      return iTypedRegion;
    }
  }
  return null;
}
项目:hybris-commerce-eclipse-plugin    文件:DocumentProvider.java   
@Override
protected IDocument createDocument(Object element) throws CoreException {

    IDocument document = super.createDocument(element);
    //IDocumentPartitioner partitioner = createDocumentPartitioner();
    IDocumentPartitioner partitioner = new ImpexDocumentPartitioner();

    if ((document instanceof IDocumentExtension3)) {
        IDocumentExtension3 extension3 = (IDocumentExtension3) document;
        extension3.setDocumentPartitioner(Activator.IMPEX_PARTITIONING, partitioner);
    }
    else {
        document.setDocumentPartitioner(partitioner);
    }

    partitioner.connect(document);
    return document;
}
项目:ncl30-eclipse    文件:NCLEditor.java   
@Override
protected void configureSourceViewerDecorationSupport(
        SourceViewerDecorationSupport support) {

    super.configureSourceViewerDecorationSupport(support);
    char[] matchChars = { '<', '>' }; // which brackets to match

    ICharacterPairMatcher matcher = new DefaultCharacterPairMatcher(
            matchChars, IDocumentExtension3.DEFAULT_PARTITIONING);

    support.setCharacterPairMatcher(matcher);
    support.setMatchingCharacterPainterPreferenceKeys(
            EDITOR_MATCHING_BRACKETS, EDITOR_MATCHING_BRACKETS_COLOR);

    // Enable bracket highlighting in the preference store
    IPreferenceStore store = getPreferenceStore();
    store.setDefault(EDITOR_MATCHING_BRACKETS, true);
    store.setDefault(EDITOR_MATCHING_BRACKETS_COLOR, "128,128,128");

}
项目:brainfuck    文件:BfTemplateCompletionProcessor.java   
@Override
protected String extractPrefix(ITextViewer viewer, int offset) {
    try {
        if (offset == 0) {
            return "";
        }
        if (!(viewer.getDocument() instanceof IDocumentExtension3)) {
            return super.extractPrefix(viewer, offset);
        }
        IDocumentExtension3 document3 = (IDocumentExtension3) viewer.getDocument();
        ITypedRegion previousRegion = document3.getPartition(EditorConstants.BF_PARTITIONING, offset - 1, false);
        if (EditorConstants.PARTITION_TYPE_TEMPLATE_PARAMETERS.equals(previousRegion.getType())) {
            return viewer.getDocument().get(previousRegion.getOffset(), previousRegion.getLength());
        }
    } 
    catch (BadLocationException | BadPartitioningException ex) {
        BfActivator.getDefault().logError("Prefix for Template could not be computed", ex);
    }
    return super.extractPrefix(viewer, offset);
}
项目:brainfuck    文件:BfSourceViewerConfiguration.java   
@Override
public IRegion getHoverRegion(ITextViewer textViewer, int offset) {
    IRegion region = new Region(offset, 0);
    try {
        IDocument doc = textViewer.getDocument();

        if (doc instanceof IDocumentExtension3) {
            IDocumentExtension3 ext3 = (IDocumentExtension3) doc;
            region = ext3.getPartition(EditorConstants.BF_PARTITIONING, offset, true);
        }
        else {
            region = doc.getPartition(offset);
        }
    }
    catch (BadPartitioningException | BadLocationException ex) {
        BfActivator.getDefault().logError("Partitioning Problem", ex);
    }
    return region;
}
项目:vTM-eclipse    文件:TrafficScriptSetup.java   
/**
 * Setup the TrafficScript Partitioner for .zts files
 */
/* Override */
public void setup( IDocument document )
{     
   if (document instanceof IDocumentExtension3) {
      IDocumentExtension3 extension3 = (IDocumentExtension3) document;

      IDocumentPartitioner partitioner = new FastPartitioner( 
         ZXTMPlugin.getDefault().getTrafficScriptPartitioner(),
         Partition.getAllPartitionIds()
      );

      extension3.setDocumentPartitioner(
         TrafficScriptPartitioner.TS_PARTITIONER, 
         partitioner 
      );

      partitioner.connect( document );

   }

}
项目:Eclipse-Postfix-Code-Completion    文件:PropertyValueScanner.java   
public boolean isWordStart(char c) {
    if ('=' != c && ':' != c || fDocument == null)
        return false;

    try {
        // check whether it is the first '=' in the logical line

        int i=fOffset-2;
        while (Character.isWhitespace(fDocument.getChar(i))) {
            i--;
        }

        ITypedRegion partition= null;
        if (fDocument instanceof IDocumentExtension3)
            partition= ((IDocumentExtension3)fDocument).getPartition(IPropertiesFilePartitions.PROPERTIES_FILE_PARTITIONING, i, false);
        return partition != null && IDocument.DEFAULT_CONTENT_TYPE.equals(partition.getType());
    } catch (BadLocationException ex) {
        return false;
    } catch (BadPartitioningException e) {
        return false;
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:AddBlockCommentAction.java   
@Override
protected void runInternal(ITextSelection selection, IDocumentExtension3 docExtension, Edit.EditFactory factory) throws BadLocationException, BadPartitioningException {
    int selectionOffset= selection.getOffset();
    int selectionEndOffset= selectionOffset + selection.getLength();
    List<Edit> edits= new LinkedList<Edit>();
    ITypedRegion partition= docExtension.getPartition(IJavaPartitions.JAVA_PARTITIONING, selectionOffset, false);

    handleFirstPartition(partition, edits, factory, selectionOffset);

    while (partition.getOffset() + partition.getLength() < selectionEndOffset) {
        partition= handleInteriorPartition(partition, edits, factory, docExtension);
    }

    handleLastPartition(partition, edits, factory, selectionEndOffset);

    executeEdits(edits);
}
项目:editorconfig-eclipse    文件:PropertyValueScanner.java   
@Override
public boolean isWordStart(char c) {
    if ('=' != c && ':' != c || fDocument == null)
        return false;

    try {
        // check whether it is the first '=' in the logical line

        int i = fOffset - 2;
        while (Character.isWhitespace(fDocument.getChar(i))) {
            i--;
        }

        ITypedRegion partition = null;
        if (fDocument instanceof IDocumentExtension3)
            partition = ((IDocumentExtension3) fDocument)
                    .getPartition(IEditorConfigPartitions.EDITOR_CONFIG_PARTITIONING, i, false);
        return partition != null && IDocument.DEFAULT_CONTENT_TYPE.equals(partition.getType());
    } catch (BadLocationException ex) {
        return false;
    } catch (BadPartitioningException e) {
        return false;
    }
}
项目:editorconfig-eclipse    文件:SectionScanner.java   
@Override
public boolean isWordStart(char c) {
    if ('=' != c && ':' != c || fDocument == null)
        return false;

    try {
        // check whether it is the first '=' in the logical line

        int i = fOffset - 2;
        while (Character.isWhitespace(fDocument.getChar(i))) {
            i--;
        }

        ITypedRegion partition = null;
        if (fDocument instanceof IDocumentExtension3)
            partition = ((IDocumentExtension3) fDocument)
                    .getPartition(IEditorConfigPartitions.EDITOR_CONFIG_PARTITIONING, i, false);
        return partition != null && IDocument.DEFAULT_CONTENT_TYPE.equals(partition.getType());
    } catch (BadLocationException ex) {
        return false;
    } catch (BadPartitioningException e) {
        return false;
    }
}
项目:WP3    文件:VisualizationSubscriber.java   
private ITypedRegion getPartition(final String partitionContentType) {
  final IDocumentExtension3 extension = (IDocumentExtension3) this.document;
  ITypedRegion[] computePartitioning = null;
  try {
    computePartitioning = extension.computePartitioning(IDocumentExtension3.DEFAULT_PARTITIONING,
        0, this.document.getLength(), false);
  } catch (BadLocationException | BadPartitioningException e) {
    e.printStackTrace();
  }

  for (final ITypedRegion iTypedRegion : computePartitioning) {
    if (iTypedRegion.getType().equals(partitionContentType)) {
      return iTypedRegion;
    }
  }
  return null;
}
项目:WP3    文件:SynchronizationManager.java   
private ITypedRegion getPartition(final String partitionContentType) {
  final IDocumentExtension3 extension = (IDocumentExtension3) this.document;
  ITypedRegion[] computePartitioning = null;
  try {
    computePartitioning = extension.computePartitioning(IDocumentExtension3.DEFAULT_PARTITIONING,
        0, this.document.getLength(), false);
  } catch (BadLocationException | BadPartitioningException e) {
    e.printStackTrace();
  }

  for (final ITypedRegion iTypedRegion : computePartitioning) {
    if (iTypedRegion.getType().equals(partitionContentType)) {
      return iTypedRegion;
    }
  }
  return null;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:PropertyValueScanner.java   
public boolean isWordStart(char c) {
    if ('=' != c && ':' != c || fDocument == null)
        return false;

    try {
        // check whether it is the first '=' in the logical line

        int i=fOffset-2;
        while (Character.isWhitespace(fDocument.getChar(i))) {
            i--;
        }

        ITypedRegion partition= null;
        if (fDocument instanceof IDocumentExtension3)
            partition= ((IDocumentExtension3)fDocument).getPartition(IPropertiesFilePartitions.PROPERTIES_FILE_PARTITIONING, i, false);
        return partition != null && IDocument.DEFAULT_CONTENT_TYPE.equals(partition.getType());
    } catch (BadLocationException ex) {
        return false;
    } catch (BadPartitioningException e) {
        return false;
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:AddBlockCommentAction.java   
@Override
protected void runInternal(ITextSelection selection, IDocumentExtension3 docExtension, Edit.EditFactory factory) throws BadLocationException, BadPartitioningException {
    int selectionOffset= selection.getOffset();
    int selectionEndOffset= selectionOffset + selection.getLength();
    List<Edit> edits= new LinkedList<Edit>();
    ITypedRegion partition= docExtension.getPartition(IJavaPartitions.JAVA_PARTITIONING, selectionOffset, false);

    handleFirstPartition(partition, edits, factory, selectionOffset);

    while (partition.getOffset() + partition.getLength() < selectionEndOffset) {
        partition= handleInteriorPartition(partition, edits, factory, docExtension);
    }

    handleLastPartition(partition, edits, factory, selectionEndOffset);

    executeEdits(edits);
}
项目:rustyeclipse    文件:RustTextDocumentProvider.java   
@Override
protected FileInfo createFileInfo(Object element) throws CoreException {
    FileInfo info = super.createFileInfo(element);
    if(info==null){
        info = createEmptyFileInfo();
    }
    IDocument document = info.fTextFileBuffer.getDocument();
    if (document != null) {

        /* register your partitioner and other things here 
                      same way as in your first document provider */
        if (document instanceof IDocumentExtension3) {
            IDocumentExtension3 extension3= (IDocumentExtension3) document;
            IDocumentPartitioner partitioner= new FastPartitioner(RustCorePlugin.getDefault().scanners().rustPartitionScanner(), RustPartitionScanner.PARTITION_TYPES);
            extension3.setDocumentPartitioner(RustConstants.RUST_PARTITIONING, partitioner);
            partitioner.connect(document);
        }
    }
    return info;
}
项目:rustyeclipse    文件:RustDocumentProvider.java   
@Override
    protected @Nullable IDocument createDocument(@Nullable Object element) throws CoreException {
//      IDocument document = super.createDocument(element);
//      if (document != null) {
//          IDocumentPartitioner partitioner =
//              new FastPartitioner(
//                  new RustPartitionScanner(),
//                  new String[] {
//                      RustPartitionScanner.RUST_MULTILINE_COMMENT });
//          partitioner.connect(document);
//          document.setDocumentPartitioner(partitioner);
//      }
//      return document;

        IDocument document = super.createDocument(element);
        if (document instanceof IDocumentExtension3) {
            IDocumentExtension3 extension3= (IDocumentExtension3) document;
            IDocumentPartitioner partitioner= new FastPartitioner(RustCorePlugin.getDefault().scanners().rustPartitionScanner(), RustPartitionScanner.PARTITION_TYPES);
            extension3.setDocumentPartitioner(RustConstants.RUST_PARTITIONING, partitioner);
            partitioner.connect(document);
        }
        return document;
    }
项目:Pydev    文件:DocUtils.java   
@SuppressWarnings({ "rawtypes", "unchecked" })
public static String[] getAllDocumentContentTypes(IDocument document) throws BadPartitioningException {
    if (document instanceof IDocumentExtension3) {
        IDocumentExtension3 ext = (IDocumentExtension3) document;
        String[] partitionings = ext.getPartitionings();

        Set contentTypes = new HashSet();
        contentTypes.add(IDocument.DEFAULT_CONTENT_TYPE);

        int len = partitionings.length;
        for (int i = 0; i < len; i++) {
            String[] legalContentTypes = ext.getLegalContentTypes(partitionings[i]);
            int len2 = legalContentTypes.length;
            for (int j = 0; j < len2; j++) {
                contentTypes.add(legalContentTypes[j]);
            }
            contentTypes.addAll(Arrays.asList(legalContentTypes));
        }
        return (String[]) contentTypes.toArray(new String[contentTypes.size()]);
    }
    return document.getLegalContentTypes();
}
项目:Pydev    文件:PyPartitionScanner.java   
/**
 * 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;
}
项目:Pydev    文件:PyPartitionScanner.java   
/**
 * @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;
}
项目:goclipse    文件:AbstractDocumentScanner.java   
protected AbstractDocumentScanner(IDocument document, String partitioning, String contentType) {
    this.document = assertNotNull(document);
    this.partitioning = partitioning;

    this.source = document.get();

    if(partitioning == null) {
        this.contentType = IDocument.DEFAULT_CONTENT_TYPE;
        this.documentExt3 = null;
        this.partitioner = null;
    } else {
        Assert.isLegal(partitioning != null);
        Assert.isLegal(contentType != null);
        this.contentType = contentType;

        this.documentExt3 = tryCast(document, IDocumentExtension3.class);
        Assert.isLegal(documentExt3 != null, "document must support IDocumentExtension3");
        this.partitioner = documentExt3.getDocumentPartitioner(partitioning);
        Assert.isLegal(partitioner != null, "document must have a partitioner for " + partitioning);
    }
}
项目:pgcodekeeper    文件:SQLEditorCommonDocumentProvider.java   
void setupDocument(IDocument document) {
    if (document instanceof IDocumentExtension3) {
        IDocumentExtension3 ext= (IDocumentExtension3) document;
        IDocumentPartitioner partitioner= createRecipePartitioner();
        partitioner.connect(document);
        ext.setDocumentPartitioner(SQL_PARTITIONING, partitioner);
    }
}
项目:vertigo-chroma-kspplugin    文件:DocumentUtils.java   
/**
 * Indique si l'offset d'un document donné se trouve dans une région donnée.
 * 
 * @param document Document.
 * @param offset Offset.
 * @param contentType Content type de la région.
 * @return
 */
public static boolean isContentType(IDocument document, int offset, KspRegionType regionType) {
    try {
        /* Extrait le type de la partition. */
        IDocumentExtension3 de3 = (IDocumentExtension3) document;
        String regionContentType = de3.getContentType(KspRegionType.PARTITIONING, offset, true);

        /* Vérifie que la région correspond. */
        return regionType.getContentType().equals(regionContentType);
    } catch (BadLocationException | BadPartitioningException e) {
        ErrorUtils.handle(e);
    }

    return false;
}
项目:vertigo-chroma-kspplugin    文件:DocumentUtils.java   
/**
 * Indique si une sélection d'un document représente exactement une région de string (aux double quote près).
 * 
 * @param document Document.
 * @param selection Sélection de texte.
 * @return <code>true</code> si c'est exactement une région de string.
 */
public static boolean isExactKspString(IDocument document, ITextSelection selection) {
    IDocumentExtension3 extension = (IDocumentExtension3) document;
    try {
        /* Charge les régions du document couverte par la sélecion. */
        ITypedRegion[] regions = extension.computePartitioning(KspRegionType.PARTITIONING, selection.getOffset(), selection.getLength(), false);

        /* Vérifie qu'on a une seule région. */
        if (regions.length != 1) {
            return false;
        }

        /* Charge la région entière */
        ITypedRegion region = extension.getPartition(KspRegionType.PARTITIONING, selection.getOffset(), false);

        /* Vérifie que c'est une région de string KSP. */
        if (!region.getType().equals(KspRegionType.STRING.getContentType())) {
            return false;
        }

        /* Vérifie que la région couvre exactement la sélection */
        int selectionWithQuoteOffset = selection.getOffset() - 1; // Prend en compte la double quote ouvrante.
        int selectionWithQuoteLength = selection.getLength() + 2; // Prend en compte les deux double quote.
        if (region.getOffset() == selectionWithQuoteOffset && region.getLength() == selectionWithQuoteLength) {
            return true;
        }
    } catch (BadLocationException | BadPartitioningException e) {
        ErrorUtils.handle(e);
    }

    return false;
}
项目:vertigo-chroma-kspplugin    文件:KspDocumentSetupParticipant.java   
@Override
public void setup(IDocument document) {
    /* Définit un partitionnement du document. */
    IDocumentPartitioner p = new FastPartitioner(createKspPartitionScanner(), TYPES);
    IDocumentExtension3 de3 = (IDocumentExtension3) document;
    de3.setDocumentPartitioner(KspRegionType.PARTITIONING, p);
    p.connect(document);
}
项目:LibertyEiffel-Eclipse-Plugin    文件:EiffelDocumentProvider.java   
@Override
protected IDocument createDocument(Object element) throws CoreException {
    IDocument document = super.createDocument(element);

    if (document instanceof IDocumentExtension3) {
        IDocumentExtension3 extension3 = (IDocumentExtension3) document;
        IDocumentPartitioner partitioner = new FastPartitioner(EiffelEditorPlugin
                .getPartitionScanner(), EiffelPartitionScanner.PARTITION_TYPE);
        extension3.setDocumentPartitioner(EiffelEditorPlugin.MY_PARTITIONING, partitioner);
        partitioner.connect(document);
    }

    return document;
}
项目:GradleEditor    文件:GradleEditor.java   
@Override
protected void configureSourceViewerDecorationSupport(SourceViewerDecorationSupport support) {
    super.configureSourceViewerDecorationSupport(support);

    char[] matchChars = { '(', ')', '[', ']', '{', '}' }; // which brackets
                                                          // to match
    matcher = new DefaultCharacterPairMatcher(matchChars, IDocumentExtension3.DEFAULT_PARTITIONING);
    support.setCharacterPairMatcher(matcher);
    support.setMatchingCharacterPainterPreferenceKeys(EDITOR_MATCHING_BRACKETS, EDITOR_MATCHING_BRACKETS_COLOR);

    // Enable bracket highlighting in the preference store
    IPreferenceStore store = getPreferenceStore();
    store.setDefault(EDITOR_MATCHING_BRACKETS, true);
    store.setDefault(EDITOR_MATCHING_BRACKETS_COLOR, "128,128,128");
}
项目:ftc    文件:TweakedLinkedModeUI.java   
/**
 * Returns all possible content types of <code>document</code>.
 *
 * @param document
 *            the document
 * @return all possible content types of <code>document</code>
 * @throws BadPartitioningException
 *             if partitioning is invalid for this document
 * @since 3.1
 */
private String[] getContentTypes(IDocument document) throws BadPartitioningException {
    if (document instanceof IDocumentExtension3) {
        IDocumentExtension3 ext = (IDocumentExtension3) document;
        String[] partitionings = ext.getPartitionings();
        Set contentTypes = new HashSet(20);
        for (int i = 0; i < partitionings.length; i++) {
            contentTypes.addAll(Arrays.asList(ext.getLegalContentTypes(partitionings[i])));
        }
        contentTypes.add(IDocument.DEFAULT_CONTENT_TYPE);
        return (String[]) contentTypes.toArray(new String[contentTypes.size()]);
    }
    return document.getLegalContentTypes();
}
项目:ftc    文件:SqlDocumentSetupParticipant.java   
@Override
public void setup(IDocument document) {
    if (document instanceof IDocumentExtension3) {
        IDocumentExtension3 extension3= (IDocumentExtension3) document;
        IDocumentPartitioner partitioner= new FastPartitioner(SqlCommentPartitionScanner.getDefault(), SqlCommentPartitionScanner.partition_types);
        extension3.setDocumentPartitioner(FtcPlugin.SQL_PARTITIONING, partitioner);
        partitioner.connect(document);
    }
}
项目:texlipse    文件:BibSetupParticipant.java   
public void setup(IDocument document) {
    if (document instanceof IDocumentExtension3) {
        IDocumentExtension3 extension3 = (IDocumentExtension3) document;
        IDocumentPartitioner partitioner = 
            new FastPartitioner(new BibPartitionScanner(), BibPartitionScanner.BIB_PARTITION_TYPES);
        extension3.setDocumentPartitioner(BibEditor.BIB_PARTITIONING, partitioner);
        partitioner.connect(document);
    }
}
项目:texlipse    文件:TexDocumentSetupParticipant.java   
public void setup(IDocument document) {
    if (document instanceof IDocumentExtension3) {
        IDocumentExtension3 extension3= (IDocumentExtension3) document;

        IDocumentPartitioner partitioner = 
            new FastPartitioner(
                    new FastLaTeXPartitionScanner(), 
                    FastLaTeXPartitionScanner.TEX_PARTITION_TYPES);

        extension3.setDocumentPartitioner(TexEditor.TEX_PARTITIONING, partitioner);

        partitioner.connect(document);

    }   
}
项目:texlipse    文件:TexAutoIndentStrategy.java   
public void customizeDocumentCommand(IDocument document, DocumentCommand command) {
    if (this.indent) {
        if (itemSetted && autoItem && command.length == 0 && command.text != null
                && TextUtilities.endsWith(document.getLegalLineDelimiters(), command.text) != -1) {
            dropItem(document, command);
        } else if (command.length == 0 && command.text != null
                &&  TextUtilities.endsWith(document.getLegalLineDelimiters(), command.text) != -1) {
            smartIndentAfterNewLine(document, command);
        } else if ("}".equals(command.text)) {
            smartIndentAfterBrace(document, command);
        } else {
            itemSetted = false;
        }
    }

    if (TexAutoIndentStrategy.hardWrap && command.length == 0 && command.text != null) {
        try {
            final String contentType = ((IDocumentExtension3) document).getContentType(
                    TexEditor.TEX_PARTITIONING, command.offset, true);
            // Do not wrap in verbatim partitions
            if (!FastLaTeXPartitionScanner.TEX_VERBATIM.equals(contentType)) {
                hlw.doWrapB(document, command, lineLength);
            }
        }
        catch (Exception e) {
            // If we cannot retrieve the current content type, do not break lines
        }
    }
}
项目:tlaplus    文件:TLADocumentSetupParticipant.java   
public void setup(IDocument document) {
    if (document instanceof IDocumentExtension3) {
        IDocumentExtension3 extension3= (IDocumentExtension3) document;
        IDocumentPartitioner partitioner= new TLAFastPartitioner(TLAEditorActivator.getDefault().getTLAPartitionScanner(), TLAPartitionScanner.TLA_PARTITION_TYPES);
                                            // Changed from FastPartitioner by LL on 12 Aug 2012
        extension3.setDocumentPartitioner(TLAPartitionScanner.TLA_PARTITIONING, partitioner);
        partitioner.connect(document);
    }
}
项目:fluentmark    文件:FluentMkEditor.java   
private void connectPartitioningToElement(IEditorInput input, IDocument document) {
    if (document instanceof IDocumentExtension3) {
        IDocumentExtension3 extension = (IDocumentExtension3) document;
        if (extension.getDocumentPartitioner(Partitions.MK_PARTITIONING) == null) {
            FluentMkDocumentSetupParticipant participant = new FluentMkDocumentSetupParticipant(tools);
            participant.setup(document);
        }
    }
}
项目:fluentmark    文件:FluentMkTextTools.java   
/**
 * Sets up the document partitioner for the given document for the given partitioning.
 */
public void setupDocumentPartitioner(IDocument document, String partitioning) {
    IDocumentPartitioner partitioner = createDocumentPartitioner();
    if (partitioner != null) {
        partitioner.connect(document);
        if (document instanceof IDocumentExtension3) {
            IDocumentExtension3 extension3 = (IDocumentExtension3) document;
            extension3.setDocumentPartitioner(partitioning, partitioner);
        } else {
            document.setDocumentPartitioner(partitioner);
        }
    }
}
项目:bts    文件:XtextEditor.java   
@Override
protected int getLineStartPosition(final IDocument document, final String line, final int length,
        final int offset) {

    String type = IDocument.DEFAULT_CONTENT_TYPE;
    try {
        type = TextUtilities.getContentType(document, IDocumentExtension3.DEFAULT_PARTITIONING, offset, false);
    } catch (BadLocationException exception) {
        // Should not happen
    }

    int lineStartPosition = super.getLineStartPosition(document, line, length, offset);
    if (tokenTypeToPartitionTypeMapperExtension.isMultiLineComment(type)
            || tokenTypeToPartitionTypeMapperExtension.isSingleLineComment(type)) {
        try {
            IRegion lineInformation = document.getLineInformationOfOffset(offset);
            int offsetInLine = offset - lineInformation.getOffset();
            return getCommentLineStartPosition(line, length, offsetInLine, lineStartPosition);
        } catch(BadLocationException e) {
            // Should not happen
        }
    } 
    if (type.equals(IDocument.DEFAULT_CONTENT_TYPE)) {
        if (isStartOfSingleLineComment(line, length, lineStartPosition) && !isStartOfMultiLineComment(line, length, lineStartPosition)) {
            return getTextStartPosition(line, length, lineStartPosition + 1);
        }
    }
    return lineStartPosition;
}
项目:JuliaDT    文件:JuliaEditor.java   
protected void connectPartitioningToElement(IEditorInput input, IDocument document) {
  if (document instanceof IDocumentExtension3) {
    IDocumentExtension3 extension = (IDocumentExtension3) document;
    if (extension.getDocumentPartitioner(JuliaPartition.JULIA_PARTITIONING) == null) {
      JuliaTextTools tools = JuliaEditorPlugin.getDefault().getTextTools();
      tools.setupDocumentPartitioner(document, JuliaPartition.JULIA_PARTITIONING);
    }
  }
}
项目:gwt-eclipse-plugin    文件:StructuredDocumentCloner.java   
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;
  }
}
项目:brainfuck    文件:BfDocSetupParticipant.java   
@Override
public void setup(IDocument document) {

    if (document instanceof IDocumentExtension3) {
        final IDocumentExtension3 ext3 = (IDocumentExtension3) document;

        IDocumentPartitioner partitioner = new FastPartitioner(new BfPartitionScanner(), EditorConstants.BRAINFUCK_PARTITION_TYPES);
        partitioner.connect(document);
        ext3.setDocumentPartitioner(EditorConstants.BF_PARTITIONING, partitioner);
    }
}