Package org.eclipse.jface.text

Examples of org.eclipse.jface.text.IDocument


   *
   * @param lineNo the line number to get
   * @return the text corresponding the the lines requested in the editor
   */
  public String getLine(int lineNo) {
    IDocument doc = this.getDocument();
    try {
      return doc.get(doc.getLineOffset(lineNo), doc.getLineLength(lineNo));
    } catch (BadLocationException e) {
      return null;
    }
  }
View Full Code Here


  public IDocument getDocument() {
    return textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput());
  }

  public int getLineNumber(int offset) throws BadLocationException {
    IDocument doc = this.getDocument();
    return doc.getLineOfOffset(offset);
  }
View Full Code Here

  }

  @Override
  public void verifyKey(VerifyEvent event) {
    try {
      IDocument document = sourceViewer.getDocument();
      Point selection = sourceViewer.getSelectedRange();
      int cursorOffset = selection.x;
      int selectionLength = selection.y;
      char c = event.character;
      char pc = document.getChar(cursorOffset - 1);
      char nc = 0;
      try {
        nc = document.getChar(cursorOffset);
      } catch(Exception e) {
        // Now don't care
      }
      String insert = editor.autoClose(pc, c, nc);
      if(insert != null && insert.equals(Editor.SKIP)) {
        event.doit = false;
        moveCursor(1);
      } else if(insert != null) {
        insert = c + insert;
        document.replace(cursorOffset, selectionLength, insert);
        event.doit = false;
        moveCursor(1);
      }
    } catch(BadLocationException e) {
      // Don't care
View Full Code Here

    @Test @Ignore
    // FIXME
    public void testReadBackwards() throws BadLocationException {
        //setup
        IDocument doc = getDoc();
        int rhsStartOffset = 150;

        AbstractCompletionProcessor proc = new MockCompletionProcessor();
        String backText = proc.readBackwards( rhsStartOffset,
                                              doc );
View Full Code Here

                       "       Class ( )\n" + //
                       "   then\n" + //
                       "       " +//
                       "end\n\n" ;

        IDocument doc = new Document( input );
        IDocumentPartitioner partitioner = new FastPartitioner( new DRLPartionScanner(),
                                                                DRLPartionScanner.LEGAL_CONTENT_TYPES );
        partitioner.connect( doc );
        doc.setDocumentPartitioner( partitioner );
        return doc;
    }
View Full Code Here

  }
 
  public void completeIU_Version(final EObject model, final Assignment assignment, final ContentAssistContext context, final ICompletionProposalAcceptor acceptor) {
    try {
      ITextViewer _viewer = context.getViewer();
      IDocument _document = _viewer.getDocument();
      final String docText = _document.get();
      final int offset = context.getOffset();
      String _xifexpression = null;
      int _length = docText.length();
      boolean _greaterEqualsThan = (_length >= 1);
      if (_greaterEqualsThan) {
View Full Code Here

    }
  }
 
  public void completeLocation_ID(final EObject model, final Assignment assignment, final ContentAssistContext context, final ICompletionProposalAcceptor acceptor) {
    ITextViewer _viewer = context.getViewer();
    IDocument _document = _viewer.getDocument();
    final String docText = _document.get();
    final int offset = context.getOffset();
    String _xifexpression = null;
    int _length = docText.length();
    boolean _greaterEqualsThan = (_length >= 1);
    if (_greaterEqualsThan) {
View Full Code Here

    acceptor.accept(p);
  }
 
  public void completeLocation_Uri(final EObject model, final Assignment assignment, final ContentAssistContext context, final ICompletionProposalAcceptor acceptor) {
    ITextViewer _viewer = context.getViewer();
    IDocument _document = _viewer.getDocument();
    final String docText = _document.get();
    final int offset = context.getOffset();
    String _xifexpression = null;
    int _length = docText.length();
    boolean _greaterEqualsThan = (_length >= 1);
    if (_greaterEqualsThan) {
View Full Code Here

  @Override
  public void apply(ITextViewer viewer, char trigger, int stateMask,
      int offset) {

   
    IDocument document = viewer.getDocument();
    PHPStructuredEditor textEditor = (PHPStructuredEditor) ((PHPStructuredTextViewer) viewer)
        .getTextEditor();

    if (textEditor instanceof PHPStructuredEditor) {
      IModelElement editorElement = ((PHPStructuredEditor) textEditor)
          .getModelElement();
      if (editorElement != null) {

        IModelElement input = EditorUtility.getEditorInputModelElement(textEditor, false);

        if (input instanceof ICodeAssist) {
         
          try {
           
            int repOffset = getReplacementOffset();
            int length = getReplacementLength();
            IDLTKSearchScope scope = SearchEngine.createSearchScope(input.getScriptProject());
            String type = document.get(repOffset, length);
            IType[] types = PhpModelAccess.getDefault().findTypes(null, type, MatchRule.EXACT, 0, 0, scope, new NullProgressMonitor());
           
            if (types.length == 1) {
              this.type = types[0];
              UseStatementInjector injector = new UseStatementInjector(this);
View Full Code Here

  @Override
  public void apply(ITextViewer viewer, char trigger, int stateMask,
      int offset) {

    IDocument document = viewer.getDocument();
    ITextEditor textEditor = ((PHPStructuredTextViewer) viewer)
        .getTextEditor();

    if (textEditor instanceof PHPStructuredEditor) {
      IModelElement editorElement = ((PHPStructuredEditor) textEditor)
          .getModelElement();
      if (editorElement != null) {
       
        ISourceModule sourceModule = ((ModelElement) editorElement)
            .getSourceModule();
               
        try {

          if (sourceModule.getTypes().length != 1) {
            return;
          }
          ModuleDeclaration module = SourceParserUtil.getModuleDeclaration(sourceModule);
          ImplementationValidator validator = new ImplementationValidator(sourceModule);
          String code = "";
          try {
            module.traverse(validator);
          } catch (Exception e) {
            e.getClass();
            e.printStackTrace();
          }
          char indentChar = FormatterUtils
              .getFormatterCommonPrferences().getIndentationChar(document);
          String indent = String.valueOf(indentChar);
         
          for (MissingMethodImplementation miss : validator.getMissing()) {
           
            for (IMethod method : miss.getMisses()) {
              code += MethodStub.getMethodStub(method.getParent().getElementName(), method, method, indent, TextUtilities.getDefaultLineDelimiter(document), true);
            }
                     
            document.replace(miss.getInjectionOffset(), 0, code);
           
            UseStatementInjector injector = new UseStatementInjector(this);
            injector.inject(document, getTextViewer(), offset);
           
            //TODO: format code using new PDT formatter
View Full Code Here

TOP

Related Classes of org.eclipse.jface.text.IDocument

Copyright © 2018 www.massapicom. 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.