Examples of IDocument


Examples of org.eclipse.jface.text.IDocument

        setSelectionInBytecodeView();
        inputChanged = false;
    }

    private void refreshTextView(DecompiledClass result) {
        IDocument document = new Document(result.getText());
        textViewer.setDocument(document);
        // we are in verify mode but we can't show content because
        // current element is abstract, so we clean table content
        if (modes.get(BCOConstants.F_SHOW_ANALYZER)) {
            setVerifyTableItems(null);
View Full Code Here

Examples of org.eclipse.jface.text.IDocument

            endSourceLine = tmp;
        }

        try {
            if (startSourceLine > 0) {
                IDocument document = javaEditor.getDocumentProvider()
                    .getDocument(javaEditor.getEditorInput());
                try {
                    IRegion lineInfo = document
                        .getLineInformation(startSourceLine - 1);

                    int startOffset = lineInfo.getOffset();
                    int length = lineInfo.getLength();
                    if(endSourceLine > 0){
                        IRegion region = document.getLineInformation(endSourceLine - 1);
                        length = region.getLength() + (region.getOffset() - startOffset);
                    }
                    EclipseUtils.selectInEditor(javaEditor, startOffset, length);
                } catch (BadLocationException e) {
                    // do nothing. This could happens e.g. if editor does not contain
View Full Code Here

Examples of org.eclipse.jface.text.IDocument

     *
     * All other clients of this method shouldn't be affected and should receive always
     * the original document.
     */
    public IDocument getDocument(Object element) {
        IDocument document = super.getDocument(element);
        if (element instanceof IClassFileEditorInput && isDebuggerCall()) {
            IClassFileEditorInput input = (IClassFileEditorInput) element;

            return new DocumentProxy4Debugger(document, input.getClassFile());
        }
View Full Code Here

Examples of org.eclipse.jface.text.IDocument

        }
        return false;
    }

    public IRegion getDecompiledLineInfo(IEditorInput input, int decompiledLine) {
        IDocument document = getDocument(input);
        try {
            return document.getLineInformation(decompiledLine);
        } catch (BadLocationException e) {
            BytecodeOutlinePlugin.log(e, IStatus.ERROR);
        }
        return null;
    }
View Full Code Here

Examples of org.eclipse.jface.text.IDocument

        if (classFile == null) {
            return null;
        }
        IJavaElement result = null;
        if (isDecompiled()) {
            IDocument document = getDocumentProvider().getDocument(
                getEditorInput());
            try {
                // XXX have test if the requested line is from bytecode or sourcecode?!?
                if(document.getLength() > offset){
                    int lineAtOffset = document.getLineOfOffset(offset);
                    // get DecompiledMethod from line, then get JavaElement with same
                    // signature, because we do not have offsets or lines in the class file,
                    // only java elements...
                    result = getSourceMapper().findElement(classFile, lineAtOffset);
                }
View Full Code Here

Examples of org.eclipse.jface.text.IDocument

            newLine = sourceMapper.mapToSource(startLine, getClassFile()) - 1;
        }
        if(newLine < 0) {
            return null;
        }
        IDocument document = getDocumentProvider()
            .getDocument(getEditorInput());
        try {
            int lineOffset = document.getLineOffset(newLine);
            return new TextSelection(lineOffset, 0);
        } catch (BadLocationException e) {
            BytecodeOutlinePlugin.log(e, IStatus.ERROR);
        }
        return null;
View Full Code Here

Examples of org.eclipse.jface.text.IDocument

    }

    public ITextSelection convertLine(int sourceLine) {
        int newLine = sourceMapper.mapToDecompiled(
            sourceLine + 1, getClassFile()) + 1;
        IDocument document = getDocumentProvider()
            .getDocument(getEditorInput());
        try {
            int lineOffset = document.getLineOffset(newLine);
            return new TextSelection(lineOffset, 0);
        } catch (BadLocationException e) {
            BytecodeOutlinePlugin.log(e, IStatus.ERROR);
        }
        return null;
View Full Code Here

Examples of org.eclipse.jface.text.IDocument

* @author <a href="mailto:kris_verlaenen@hotmail.com">kris verlaenen </a>
*/
public class DroolsDocumentProvider extends FileDocumentProvider {

  protected IDocument createDocument(Object element) throws CoreException {
    IDocument document = super.createDocument(element);
    if (document != null) {
      IDocumentPartitioner partitioner =
        new FastPartitioner(
          new DroolsPartitionScanner(),
          new String[] {
            DroolsPartitionScanner.TAG,
            DroolsPartitionScanner.COMMENT });
      partitioner.connect(document);
      document.setDocumentPartitioner(partitioner);
    }
    return document;
  }
View Full Code Here

Examples of org.eclipse.jface.text.IDocument

          int begin= 0;
          int end= 0;
         
          Position position= null;
         
          final IDocument document= getDocument();
         
          for (int index= fCodePositions.size() - 1; index >= 0;) {
           
            position= (Position)fCodePositions.get(index--);
            begin= position.getOffset();
           
            if (index >= 0) {
              position= (Position)fCodePositions.get(index--);
              end= position.getOffset();
            } else {
              /*
               * Handle missing closing tag
               * see: https://bugs.eclipse.org/bugs/show_bug.cgi?id=57011
               */
              position= null;
              end= getOffset() + getLength() - MultiCommentLine.MULTI_COMMENT_END_PREFIX.trim().length();
              while (end > begin && ScannerHelper.isWhitespace(document.getChar(end - 1)))
                end--;
            }
           
            String snippet= document.get(begin, end - begin);
            snippet= preprocessCodeSnippet(snippet);
            snippet= formatCodeSnippet(snippet);
            snippet= postprocessCodeSnippet(snippet, indentation);
           
            logEdit(snippet, begin - getOffset(), end - begin);
View Full Code Here

Examples of org.eclipse.jface.text.IDocument

  /**
   * Format the given Java source file.
   */
  private void formatFile(File file, CodeFormatter codeFormatter) {
    IDocument doc = new Document();
    try {
      // read the file
      if (this.verbose) {
        System.out.println(Messages.bind(Messages.CommandLineFormatting, file.getAbsolutePath()));
      }
      String contents = new String(org.aspectj.org.eclipse.jdt.internal.compiler.util.Util.getFileCharContent(file, null));
      // format the file (the meat and potatoes)
      doc.set(contents);
      TextEdit edit = codeFormatter.format(CodeFormatter.K_COMPILATION_UNIT, contents, 0, contents.length(), 0, null);
      if (edit != null) {
        edit.apply(doc);
      } else {
        System.err.println(Messages.bind(Messages.FormatProblem, file.getAbsolutePath()));
        return;
      }

      // write the file
      final BufferedWriter out = new BufferedWriter(new FileWriter(file));
      try {
        out.write(doc.get());
        out.flush();
      } finally {
        try {
          out.close();
        } catch (IOException e) {
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.