コード例 #1
0
ファイル: GlobalTypesStrategy.java プロジェクト: anod/pdt
 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;
 }
コード例 #2
0
  @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());

  }
コード例 #3
0
 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;
 }