コード例 #1
0
 private void addOverride() throws IncorrectOperationException {
   IModule module = GosuModuleUtil.findModuleForPsiElement(_method);
   GosuMethodBaseImpl methodDecl =
       (GosuMethodBaseImpl)
           GosuPsiParseUtil.parseDeclaration(
               "override function test() {}", _method.getManager(), module);
   ASTNode[] children = _method.getNode().getChildren(null);
   ASTNode overrideKeyword = methodDecl.getNode().getChildren(null)[0];
   CodeEditUtil.setOldIndentation(
       (TreeElement) overrideKeyword, 0); // this is to avoid a stupid exception
   _method
       .getNode()
       .addChildren(overrideKeyword, overrideKeyword.getTreeNext().getTreeNext(), children[0]);
 }
コード例 #2
0
 @Override
 public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
   return _method.isValid() && _method.getManager().isInProject(_method);
 }