Coder Social home page Coder Social logo

semantic-refactor's Introduction

What is Semantic Refactor?

Semantic Refactor is a C/C++ refactoring tool based on Semantic parser framework.

Semantic is a package that provides a framework for writing parsers. Parsing is a process of analyzing source code based on programming language syntax. relies on Semantic for analyzing source code and uses its results to perform smart code refactoring that based on code structure of the analyzed language, instead of plain text structure.

NOTE: semantic-refactor only supports Emacs 24.4 or above at the moment.

Features

C/C++:

  • Context-sensitive menu offers appropriate refactoring actions

  • Generate class implementation (also handles nested class and class template)

  • Generate class getters and setters

  • Generate function implementation (also handles function template)

  • Generate function prototype

  • Convert function to function pointer

  • Convert function to function parameter

  • Move semantic units (class, function, variable)

  • Extract function with proper type information

  • Precise local variable rename

More info and demos

Lisp:

  • Format whole buffer

  • Format a defun

  • Convert a sexpression into one line precisely

  • Convert a sexpression into multiple lines precisely

More info and demos

Installation

This package can be obtained from MELPA:

  • M-x list-packages
  • Move to srefactor and press i.
  • Press x to install.
  • Then, place this configuration in ~/.emacs.d/init.el or ~/.emacs:
    (require 'srefactor)
    (require 'srefactor-lisp)
    
    ;; OPTIONAL: ADD IT ONLY IF YOU USE C/C++. 
    (semantic-mode 1) ;; -> this is optional for Lisp
    
    (define-key c-mode-map (kbd "M-RET") 'srefactor-refactor-at-point)
    (define-key c++-mode-map (kbd "M-RET") 'srefactor-refactor-at-point)
    (global-set-key (kbd "M-RET o") 'srefactor-lisp-one-line)
    (global-set-key (kbd "M-RET m") 'srefactor-lisp-format-sexp)
    (global-set-key (kbd "M-RET d") 'srefactor-lisp-format-defun)
    (global-set-key (kbd "M-RET b") 'srefactor-lisp-format-buffer)

NOTICE: If you only use Lisp formatting, you don't have to enable semantic-mode.

Usage

To use this package, a user only needs to use this single command: srefactor-refactor-at-point and semantic-mode activated. Based on the context at point, appropriate menu items are offered. When the menu opens up, the top line contains the tag at point, which is the context for offering appropriate refactor actions.

Key bindings of contextual menu:

  • 1..9 to quickly execute an action.
  • o to switch to next option, O to switch to previous option.
  • n to go to the next line, p to got to previous line.
  • q or C-g to quit.

You can hide the help message in the menu with by customizing srefactor-ui-menu-show-help and set it to nil.

(setq srefactor-ui-menu-show-help nil)

semantic-refactor's People

Contributors

mosic avatar rational-curiosity avatar tuhdo avatar whatacold avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.