GithubHelp home page GithubHelp logo

isabella232 / intellij-structural-search-for-kotlin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jetbrains/intellij-structural-search-for-kotlin

0.0 0.0 0.0 798 KB

Structural Search support for Kotlin

License: Apache License 2.0

Kotlin 100.00%

intellij-structural-search-for-kotlin's Introduction

Structural Search for Kotlin IntelliJ IDEA plugin (legacy)

Plugin that implements structural search support for the Kotlin language in IntelliJ IDEA. It is compatible with IDEA 2020.1 and 2020.2.

Kotlin Structural Search support is provided by the Kotlin plugin from IDEA 2020.3.

Getting started

Reporting issues

Issues can be reported in YouTrack.

Matching Behaviour

Blocks

Series of instructions are matched strictly. The following template:

fun x() {
    val foo = 1
}

will not match the following piece of code:

fun x() {
    val foo = 1
    val bar = 2
}

Loose matching can be achieved using variables with a [0,∞] count filter to match surrounding instructions:

fun x() {
    $before$
    val foo = 1
    $after$
}

Variable declarations

The val and var keywords aren’t taken into account by default. Type reference and initializer are optional. The following template:

val $x$: Int

will match the following piece of code:

var myVariable = 6

It is possible to match variables with custom getters or setters. The Kotlin — Property with explicit getter/setter file type must be selected.

Type filters should be applied on name identifiers:

val $name$

Strings

Strings in Kotlin are made of successive entries. These entries can be:

"bug"       // literals
"\n"        // escapes
"$name"     // simple names
"${ name }" // blocks

In order to be able to match strings containing one of these entries, simple names with a variable match any entry. The following template will match any string with only one entry (any of the previous four examples for instance):

“$$$name$”

The following template will match any string containing a block with one instruction (with, again, [0,∞] count filters on $before$ and $after$):

“$$$before$${ $instruction$ }$$$after$”

Functions

In function calls, named value arguments are matched in any order. Unnamed value arguments and type arguments are matched if the arguments are placed in the same order.

In function declarations, expressions bodies (fun x() = 1) are matched with block bodies containing a return expression (fun x() { return 1 }).

Object declarations

Object searches match both companion objects and normal object declarations.

Binary expressions

Binary operations are matched with their functional counterparts. The following template:

x + y

will match this piece of code:

x.plus(y)

Augmented assignments are matched with their binary and functional counterparts. The following template:

x += y

will match these two lines of code:

x = x + y
x.plusEquals(y)

intellij-structural-search-for-kotlin's People

Contributors

bartvhelvert avatar basleijdekkers avatar yopox 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.