Giter VIP home page Giter VIP logo

Comments (10)

maxandersen avatar maxandersen commented on July 19, 2024

ah - issue is that

if (!(code.contains("///usr/bin/env jbang") || code.contains("//DEPS "))) return false
assumes "//DEPS" can occur anywhere - it should only be if on beginning of a line. regexp match "^//DEPS.*"

from jbang-idea.

linux-china avatar linux-china commented on July 19, 2024

How about following code? IDEA treats line break as \n, no \r in IDEA editor.

  if (!(code.contains("///usr/bin/env jbang")
                    || code.startsWith("//DEPS ")
                    || code.contains("\n//DEPS "))) return false

Regex is not performance well for long text.

from jbang-idea.

maxandersen avatar maxandersen commented on July 19, 2024

I don't think regex of the type just checking start of line is much slower than checking a string contains something.

But anyhow - thinking about this we don't really want the existing ones for java to disappear as it's still very feasible to run/debug the file directly.

Can we just add to list of existing one (run,debug, etc) without removing them ?

from jbang-idea.

linux-china avatar linux-china commented on July 19, 2024

Yes, you can. Now run by JBang is the first option, and you can run it as Normal Java class from More Run/Debug. You should right click outside of class. It's some tricky and maybe it's bug of IntelliJ IDEA. I will submit an issue to jetbrains and confirm it.

Screen Shot 2021-12-24 at 12 34 03 AM

from jbang-idea.

maxandersen avatar maxandersen commented on July 19, 2024

no way to make jbang show up in more run/debug instead of "overtaking" the UI ?

from jbang-idea.

linux-china avatar linux-china commented on July 19, 2024

Another options is to use external tools in IDEA. External tool will not modify anything to Run Configurations and nothing changed to editor popup menu. Just add JBang under External Tools, and of course you can assign shortcut for it.

Screen Shot 2021-12-25 at 7 01 47 PM

But I think external tool is not good idea, hard to add options and arguments. Maybe we should both options to run JBang script.

Run configuration is controlled by IDE, and it's some hard to change. I will take a look at priority available or not for run configuration.

from jbang-idea.

linux-china avatar linux-china commented on July 19, 2024

One more options: if right click in JBang directives, and JBang will be first run option, and native run configuration will be first in other location.

If ///usr/bin/env jbang available, and a run button will be added in the gutter of line to run script by JBang.

from jbang-idea.

linux-china avatar linux-china commented on July 19, 2024

@maxandersen How about new implementation?

Right Click in JBang directives area, then you can choose Run Hello.java by JBang:

Screen Shot 2021-12-29 at 7 26 39 PM

In other area, Run by JBang will be disabled and only run normal Java class available.

Screen Shot 2021-12-29 at 7 26 57 PM

Line marker will add jbang icon to run script when ///usr/bin/env jbang available in script file.

<runLineMarkerContributor language="JAVA" implementationClass="dev.jbang.idea.run.JBangRunLineMarkerContributor"/>

from jbang-idea.

maxandersen avatar maxandersen commented on July 19, 2024

I think that makes sense as it's more the file you run than the class.

Maybe also recognize //DEPS and //JAVA in beginning of line as the /// marker is not a hard requirement?

from jbang-idea.

linux-china avatar linux-china commented on July 19, 2024

line marker adjusted:

  • icon for ///usr/bin/env jbang if available
  • Icon for //JAVA if ///usr/bin/env jbang absent
  • Icon for first //DEPS if ///usr/bin/env jbang and //JAVA absent

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.