Ejemplo n.º 1
0
 public SourceRange getReplacementRange(ICompletionContext context) throws BadLocationException {
   SourceRange replacementRange = super.getReplacementRange(context);
   boolean insertMode = isInsertMode();
   if (replacementRange.getLength() > 0 && insertMode) {
     return new SourceRange(replacementRange.getOffset(), replacementRange.getLength() - 1);
   }
   return replacementRange;
 }
  @Override
  public void apply(ICompletionReporter reporter) throws Exception {

    InControllerContext ctx = null;
    if (getContext() instanceof InControllerContext) {
      ctx = (InControllerContext) getContext();
    }

    final String prefix = ctx.getPrefix();

    CompletionRequestor requstor = ctx.getCompletionRequestor();

    ctx.getSourceModule().getElementAt(ctx.getOffset());

    /*-
    ASTParser parser = ASTParser.newParser(PHPVersion.PHP5_4, ctx.getSourceModule());
    Program p = parser.createAST(null);
    ASTNode node = p.getElementAt(ctx.getOffset());
     */

    IMethod method = ctx.getSourceModule().getMethod(prefix);
    SourceMethod sm = (SourceMethod) method;

    ctx.getOffset();

    SourceRange replacementRange = this.getReplacementRange(ctx);

    int offset = replacementRange.getOffset();
    int length = replacementRange.getLength();

    SourceRange r = new SourceRange(offset - prefix.length(), length + prefix.length());

    //		reporter.reportKeyword("Create "+prefix+" method", "(){$this->render('" + prefix + "',
    // array());}", r);

    // reporter.reportMethod(method, "(){$this->render('" + prefix + "');\n}", replacementRange, new
    // Object());

  }
 protected IModelElement[] getSelection(String data) throws Exception {
   SourceRange range = createFile(data);
   ISourceModule sourceModule = DLTKCore.createSourceModuleFrom(testFile);
   IModelElement[] elements = sourceModule.codeSelect(range.getOffset(), range.getLength());
   return elements;
 }