Comments (7)
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.
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.
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.
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.
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.
@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.
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)
- Support IDEA 2022.2 EAP HOT 1
- use private artifactory to sync deps to module HOT 3
- Plugin doesn't aknowledge JBANG_HOME
- Running JBang as a Scratch file will not set the Script file attribute properly HOT 3
- cannot create jbang script in intellij idea HOT 10
- Unable to create a JBang script from Intellij HOT 3
- Sync 'JBang DEPS to Module' fails with 'Could not execute [/Users/cer/.jbang/bin/jbang' HOT 2
- JBang not listed in project generators HOT 3
- NPE running "New/JBangScript" in IntelliJ 2022.3.3 HOT 1
- jbang edit --open=idea Test.kt doesn't work with IntelliJ 2022.3.3 HOT 5
- IDEA does not see jbang installed with scoop HOT 2
- Use `hello = Basic Hello World template` as the default option when creating a new JBang Script HOT 1
- Plugin doesn't work with latest IDEA HOT 1
- Exception when synching deps with 2023.2.1
- JBang Scripts Inside a Maven Project HOT 2
- Exception on IntelliJ 2023.2.3
- Support IDE build 233.x HOT 3
- Code completion does not work with native edit HOT 5
- Improve the Jbang experience in IntelliJ HOT 3
- `ActionUpdateThread.OLD_EDT` is deprecated and going to be removed soon.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jbang-idea.