Giter VIP home page Giter VIP logo

Comments (7)

linux-china avatar linux-china commented on June 20, 2024 1

Got. I will modify the logic and only open one new file by ext name match, and just let developers know that JBang script files have been created successfully.

from jbang-idea.

linux-china avatar linux-china commented on June 20, 2024

Now it's some hard because JBang scripts were created by CLI, and lots of work for IDEA.

  • Start the process
  • Wait for files notification
  • Reload from disk
  • Scan the directory to get file list

My suggestion is to put some JBang templates under fileTemplates/internal directory and bundle into jbang.jar file, then plugin include this jar file, then just call following API, that's all.

 public static PsiFile createFileFromTemplate(@Nullable String name,
                                               @NotNull FileTemplate template,
                                               @NotNull PsiDirectory dir,
                                               @Nullable String defaultTemplateProperty,
                                               boolean openFile) 

We can use CLI to generate the scripts during project/module creation, and that's good. For opened project, we should choose fileTemplates to create JBang scripts, and it's normal way in IDEA.

Now we can have some options:

  • The plugin contains fileTemplates to create some JBang scripts
  • jbang.jar contains fileTemplates and plugin bundles the jar file
  • Use CLI to generate jbang scripts and UX is not good and lots of work.

from jbang-idea.

maxandersen avatar maxandersen commented on June 20, 2024

Not seeing that as a lot of work for the plug-in. It just need to run async via invoke later and we can add better output to jbang if necessary.

What is worse will be if jbang idea now starts having its own set of templates and have to be maintained. That is a lot more work imo.

from jbang-idea.

linux-china avatar linux-china commented on June 20, 2024

Refresh the dest directory synchronously and open all new files now. It may be blocked for a while if dest directory contains lots of files.

VfsUtil.markDirtyAndRefresh(false, true, true, directory)
val fileEditorManager = FileEditorManager.getInstance(project)
//iterate all files and open new files
VfsUtil.iterateChildrenRecursively(
   directory,
   VirtualFileFilter.ALL
) {
    if (!it.isDirectory && !currentFiles.contains(it)) {
        fileEditorManager.openFile(it, true)
   }
 true
}

from jbang-idea.

maxandersen avatar maxandersen commented on June 20, 2024

Opening all new files is not a good approach IMO.

Just search for the file name given to the init; if found open if not select new files but don't open. Then you avoid any blocking operations.

from jbang-idea.

linux-china avatar linux-china commented on June 20, 2024

@maxandersen a question, developers can use JBang template to generate mulit files, and input name just part of file names. For example:

"templates": {
    "Rocketmq": {
      "file-refs": {
        "src/{basename}Consumer.java": "templates/RocketmqConsumer.java.qute",
        "src/{basename}Provider.java": "templates/RocketmqProvider.java.qute",
        "src/application.properties": "templates/rocketmq-application.properties.qute"
      },
      "description": "Basic template for RocketMQ App"
    }
  }

If you input MyApp.java and no real file generated in this case. fileEditorManager.openFile(it, true) is not expensive, and just send a message to IDE and notify IDE to open files asynchronously.

from jbang-idea.

maxandersen avatar maxandersen commented on June 20, 2024

But not expected to have multiple files open. Annoying to users having to close what they don't need open.

from jbang-idea.

Related Issues (20)

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.