Giter Club home page Giter Club logo

intellij-template-plugin's Introduction

Intellij Code Template

Structure

src
└── main
    ├── kotlin
    │   └── com
    │       └── richone
    │           └── fluttertemplate
    │               ├── action
    │               │   ├── GenerateDialog.kt
    │               │   └── PresentationAction.kt
    │               └── generator
    │                   ├── PresentationLayerGenerator.kt
    │                   ├── PresentationLayerGeneratorFactory.kt
    │                   └── components
    │                       ├── BlocEventGenerator.kt
    │                       ├── BlocGenerator.kt
    │                       ├── BlocStateGenerator.kt
    │                       ├── BuilderGenerator.kt
    │                       ├── ModelMapperGenerator.kt
    │                       ├── WidgetGenerator.kt
    │                       └── WidgetModelGenerator.kt
    └── resources
        ├── META-INF
        │   ├── plugin.xml
        │   └── pluginIcon.svg
        └── templates
            └── presentation_layer
                ├── bloc
                │   ├── bloc.dart.template
                │   ├── bloc_event.dart.template
                │   └── bloc_state.dart.template
                ├── builder.dart.template
                ├── model_mapper.dart.template
                ├── widget.dart.template
                └── widget_model.dart.template

How to use

  1. templates 폴더에 template 파일 정의

  2. template 파일과 1:1로 대응하는 Generator 파일 components 파일에 정의

  3. PresentationLayerGenerator의 init 부분에서 탐색할 파일 경로와 확장자 설정

    init {
            templateValues = mutableMapOf(
                    TEMPLATE_PASCAL_CASE to pascalCase(),
                    TEMPLATE_SNAKE_CASE to snakeCase()
            )
            try {
                val templateFolder = /*** 템플릿 파일 폴더 이름 ***/
                val resource = "/templates/$templateFolder/$templateName.{확장자 이름}.template"
                val resourceAsStream = PresentationLayerGenerator::class.java.getResourceAsStream(resource)
                templateString = CharStreams.toString(InputStreamReader(resourceAsStream, Charsets.UTF_8))
            } catch (e: Exception) {
                throw RuntimeException(e)
            }
        }
  4. PresentationLayerGeneratorFactory에 제너레이터 등록

fun getBlocGenerators(name: String): List<PresentationLayerGenerator> {
	val generator = Generator(name)
	return listOf(generator...)
}
  1. PresentationLayerGeneratorFactory의 팩토리 메서드에 맞춰 onGenerateClicked 메서드 generate 메서드 수정

## Build Config

스크린샷 2022-09-06 오후 7 55 36

스크린샷 2022-09-06 오후 7 56 27

  1. Run

    스크린샷 2022-09-06 오후 7 56 49

  2. Archive

    스크린샷 2022-09-06 오후 7 57 33

Apply

Android Studio - Preferences - Plugin

스크린샷 2022-09-06 오후 8 00 19

Plugin - build - distributions - zip file

스크린샷 2022-09-06 오후 8 00 58

Restart IDE

스크린샷 2022-09-06 오후 8 02 14

New - TestAction 실행

스크린샷 2022-09-06 오후 8 03 00

intellij-template-plugin's People

Contributors

canlab-leechiwon avatar lwbvv 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.