Examples of ITypedRegion


Examples of org.eclipse.jface.text.ITypedRegion

        ISelection selection = ((TMLEditor) editorPart).getSelectionProvider().getSelection();
        if (selection instanceof ITextSelection) {
          int selectionOffset = ((TextSelection)selection).getOffset();
          IDocument doc = ((TMLEditor)editorPart).getDocumentProvider().getDocument(editorPart.getEditorInput());
          if (doc != null) {
            ITypedRegion partition;
            try {
              partition = doc.getPartition(selectionOffset);
              if (partition.getType().equals(TMLScriptPartitionScanner.TMLSCRIPT)) {
                return Snippet.CONTEXT_TMLScript;
              }
            } catch (BadLocationException e) {
            }         
          }       
View Full Code Here

Examples of org.eclipse.jface.text.ITypedRegion

      if (selection != null && selection instanceof ITextSelection) {
        ITextSelection textSelection = (ITextSelection)selection;
        IDocument doc = editor.getDocumentProvider().getDocument(editor.getEditorInput());
        if (doc != null) {
          try {
            ITypedRegion region = doc.getPartition(textSelection.getOffset());           
           
            // comment handling for TMLScriptEditor
            if (editorPart instanceof TMLScriptEditor) {
              if (region.getType().equals(TMLScriptPartitionScanner.MCOMMENT)) {
                removeTMLScriptComment(doc, region);
              } else if(editorPart instanceof TMLScriptEditor){
                createTMLScriptComment(doc, textSelection);
              }
            }
           
            // comment handling for TMLEditor
            if(editorPart instanceof TMLEditor){
              // remove comments if we are already in a comment section
              if(region.getType().equals(TMLScriptPartitionScanner.MCOMMENT)) {
                removeTMLScriptComment(doc, region);
              }           
              if(region.getType().equals(TMLPartitionScanner.TML_COMMENT)) {             
                removeTMLComment(doc, region);
              }
             
              // create comments depending on current partition
              if(region.getType().equals(TMLScriptPartitionScanner.TMLSCRIPT)){
                createTMLScriptComment(doc, textSelection);
              } else {
                createTMLComment(doc, textSelection);
              }
            }
View Full Code Here

Examples of org.eclipse.jface.text.ITypedRegion

          Method getFileContext = editorClass.getMethod("getFileContext", new Class[]{});
          Object fileContext = getFileContext.invoke(ed);
          if (fileContext != null) {
            Class<? extends Object> fcClass = fileContext.getClass();
            Method getPartition = fcClass.getMethod("getPartitionAtOffset", new Class[]{Integer.TYPE});
            ITypedRegion region = (ITypedRegion) getPartition.invoke(fileContext, new Object[]{editor.getCaretPos()});
            result = guessSyntaxFromString(region.getType());
          }
         
        } catch (Exception e) {  }
      }
    }
View Full Code Here

Examples of org.eclipse.jface.text.ITypedRegion

        @Override
        public ITypedRegion[] computePartitioning(int offset, int length) {
          List<ITypedRegion> regions = new ArrayList<ITypedRegion>();
          editor.reset();
          while (!editor.eof) {
            ITypedRegion current = editor.nextToken();
            int start = current.getOffset();
            int stop = current.getOffset() + current.getLength();
            if (start >= offset && stop <= offset + length) {
              // Region included in the zone
              regions.add(current);
            } else if (start < offset && stop >= offset) {
              // Overlap on the beginning of the zone
              regions.add(new TypedRegion(offset, (stop - offset), current.getType()));
            } else if (start <= offset && stop > offset + length) {
              // XXX this condition actually contains the previous one. problem? --bran
              // Overlap on the end of the zone
              regions.add(new TypedRegion(start, (offset + length - start), current.getType()));
            }
            else if (start > offset + length ) { // bran cut off
              break;
            }
          }
View Full Code Here

Examples of org.eclipse.jface.text.ITypedRegion

      final ISelection selection = editor.getSelectionProvider().getSelection();
      if (!(selection instanceof ITextSelection)) {
        throw new IllegalArgumentException();
      }
      final int offset = ((ITextSelection)selection).getOffset();
      ITypedRegion partition = editor.getDocument().getPartition(offset);
      if (!partition.getType().equals(DOCUMENT_PART)) {
        setBaseEnabled(false);
      } else {
        setBaseEnabled(true);
      }
      return;
View Full Code Here

Examples of org.eclipse.jface.text.ITypedRegion

        if (tokenKind != ErlToken.KIND_ATOM && tokenKind != ErlToken.KIND_STRING
                && tokenKind != ErlToken.KIND_MACRO && tokenKind != ErlToken.KIND_VAR) {
            return null;
        }
        try {
            final ITypedRegion partition = doc.getPartition(offset);
            final ErlRegion region = new ErlRegion(token.getOffset(), token.getLength(),
                    partition.getType());
            if (!IDocument.DEFAULT_CONTENT_TYPE.equals(region.getType())) {
                return null;
            }
            return new IHyperlink[] { new ErlangHyperlink(editor, region) };
        } catch (final BadLocationException e) {
View Full Code Here

Examples of org.eclipse.jface.text.ITypedRegion

         * @param pos
         *            an offset within this document
         * @return true if the offset is within this document's partition
         */
        public boolean inPartition(final int pos) {
            final ITypedRegion partition = getPartition(pos);
            return partition != null && partition.getType().equals(fPartition);
        }
View Full Code Here

Examples of org.eclipse.jface.text.ITypedRegion

         * @param searchForward
         *            the direction of the search
         * @return the next position to query
         */
        public int getNextPosition(final int pos, final boolean searchForward) {
            final ITypedRegion partition = getPartition(pos);
            if (partition == null) {
                return simpleIncrement(pos, searchForward);
            }
            if (fPartition.equals(partition.getType())) {
                return simpleIncrement(pos, searchForward);
            }
            if (searchForward) {
                final int end = partition.getOffset() + partition.getLength();
                if (pos < end) {
                    return end;
                }
            } else {
                final int offset = partition.getOffset();
                if (pos > offset) {
                    return offset - 1;
                }
            }
            return simpleIncrement(pos, searchForward);
View Full Code Here

Examples of org.eclipse.jface.text.ITypedRegion

        int charPos = rightMostNonWhitespaceChar(document, lineStart, lineEnd);
        if (charPos >= lineEnd) {
          continue;
        }
        // check partition - don't remove whitespace inside strings
        ITypedRegion partition = getPartition(document, DEFAULT_PARTITIONING, charPos, false);
        if ("__string".equals(partition.getType())) {
          continue;
        }
        if (rootEdit == null) {
          rootEdit = new MultiTextEdit();
        }
View Full Code Here

Examples of org.eclipse.jface.text.ITypedRegion

   * @return
   * @throws BadLocationException
   */
  private String getRegionType(IDocument d, int offset) throws BadLocationException {
    int p = ((offset == d.getLength()) ? offset - 1 : offset);
    ITypedRegion region = TextUtilities.getPartition(d, fPartitioning, p, true);
    return region.getType();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.