Skip to content
/ ctrl-h Public

A VSCode extension for Software Engineering Curriculum Design

License

Notifications You must be signed in to change notification settings

moui0/ctrl-h

Repository files navigation

Ctrl-H

A structural code search and replace VSCode extension.

demo

Application

  • find dead code
  • find similar code snippets
  • code instrumentation
  • code equivalent substitution

For specific examples, see Demo.

Grammar

Query Language

QueryInput ::= Decl | Import | Exp | Stmt
SubQuery ::= (['\\'] QueryInput | '[' INT_VALUE ']' QueryInput)
Decl ::= VarDecl | ClassLikeDecl | MethodDecl
VarDecl ::= {Modifier} [TypeOrVoid] Ident [ '=' Expression ]
Block ::= '{' ((SubQuery {'$' SubQuery} | [SubQuery]) | BlockConstraint) '}'
BlockConstraint ::= '<<null>>' | '<<empty>>'
ClassLikeDecl ::= {Modifier} ClasslikeKeyWord [TypeParameters]
      [EXTENDS TypeList]
      [IMPLEMENTS TypeList]
      [PERMITS TypeList]
			Block
ClasslikeKeyWord ::= 'interface' | 'class' | 'struct'
MethodDecl ::= {Modifier} [TypeOrVoid] Ident '(' [ParamList] ')' [throws Exception] Block 
Stmt ::= IfStmt | Block | ForStmt | TryStmt | SwitchStmt | AssertStmt | WhileStmt | DoWhileStmt
			| ThrowStmt | BreakStmt | ContinueStmt | CaseStmt
Ident ::= '<<>>' | NormalIdent
IfStmt ::= IF ParExp Block [ELSE Block] 
ForStmt ::= FOR '(' ForControl ')' Block
TryStmt ::= TRY Block CATCH (VarDecl)?  [FinalBlock] | FinalBlock
SwitchStmt ::= SWITCH ParExp Block
AssertStmt ::= ASSERT Exp [':' Exp] ';'
WhileStmt ::= WHILE ParExp Block
DoWhileStmt ::= DO Block WHILE ';'
ThrowStmt ::= THROW Exp ';'
BreakStmt ::= BREAK ';'
ContinueStmt ::= CONTINUE ';'
CaseStmt ::= CASE Exp ':' Block
ParExp ::= '('Exp')'
Exp ::= Primary
    | Exp '.'
      (
         Ident
       | MethodCall
       | THIS
       | NEW [NonWildcardTypeArguments] InnerCreator
       | SUPER SuperSuffix
       | ExplicitGenericInvocation
      )
    | Exp '[' Exp ']'
    | MethodCall
    | NEW Creator
    | '(' annotation* typeType {'&' typeType} ')' expression
    | Exp ('++' | '--')
    | ('+'|'-'|'++'|'--') Exp
    | ('~'|'!') Exp
    | Exp ('*'|'/'|'%') Exp
    | Exp ('+'|'-') Exp
    | Exp ('<' '<' | '>' '>' '>' | '>' '>') Exp
    | Exp ('<=' | '>=' | '>' | '<') Exp
    | Exp INSTANCEOF (typeType)
    | Exp ('==' | '!=') Exp
    | Exp '&' Exp
    | Exp '^' Exp
    | Exp '|' Exp
    | Exp '&&' Exp
    | Exp '||' Exp
    | Exp '?' Exp ':' Exp
    | Exp ('=' | '+=' | '-=' | '*=' | '/=' | '&=' | '|=' | '^=' | '>>=' | '>>>=' | '<<=' | '%=') Exp 
Primary
    ::= '(' expression ')'
    | THIS
    | SUPER
    | Literal
    | Identifier
    | TypeTypeOrVoid '.' CLASS
    | NonWildcardTypeArguments (ExplicitGenericInvocationSuffix | THIS Arguments)
ClasslikeKeyWord ::= 'interface' | 'class' | 'struct'
Modifier ::= PUBLIC || PRIVATE ||PROTECTED || STATIC || ABSTRACT || FINAL || VOLATILE || NATIVE

Replace Language

ReplaceInput ::= ReplaceLanguage { }
ReplaceLanguage ::=  [label(,index)?] '=>' (UserString)? '##' [label(,index)?] '##'(UserString)?
UserString ::= '"""'TEXT'"""'

About

A VSCode extension for Software Engineering Curriculum Design

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published