Git Product home page Git Product logo

zio-intellij's Introduction

ZIO companion plugin for IntelliJ IDEA

Project stage

Provides inspections, refactorings, and other improvements to the ZIO library ecosystem users in IntelliJ IDEA.

Installation

The plugin is now available on the JetBrains Plugin Marketplace.

Supported versions

A note about support: this plugin is maintained for the last two IntelliJ IDEA versions. When a new IDEA is released, the oldest supported version will stop getting new features (except critical bug fixes).

To continue enjoying new features, please upgrade to the latest available IntellJ version!

Features

The plugin has several powerful features for ZIO:

Test runner support

You can run individual ZIO tests or the whole specs from IDEA:

And view the results in the integrated runner:

Refactorings and inspections

Don't want to type out the full type signature? Choose a more specific one:

specific-type

Suggestions to simplify complex expressions using built-in ZIO combinators:

And many more features!

Contributing

Like what you see? Help improve this plugin by submitting issues and ideas!

Have questions? We're waiting for you at #zio-intellij on the ZIO Discord!

Acknowledgments

This project is using the YourKit Java Profiler to bring you bug-free and performant experience!

YourKit supports open source projects with innovative and intelligent tools for monitoring and profiling Java and .NET applications. YourKit is the creator of YourKit Java Profiler, YourKit .NET Profiler, and YourKit YouMonitor.

zio-intellij's People

Contributors

adamgfraser avatar alexvanolst avatar alterationx10 avatar darl avatar dmytroorlov-flixbus avatar ghostdogpr avatar grigoriiberezin avatar hmemcpy avatar leszekgruchala avatar m-kalai avatar mitsutaka-takeda avatar myazinn avatar nightscape avatar palanga avatar poslegm avatar reibitto avatar senia-psm avatar timaliberdov avatar ybogomolov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zio-intellij's Issues

Use IntelliJ's integrated test runner.

IntelliJ doesn't have good extensibility for plugging in new test runner supports without hard work. The functionality of the test runner is now implemented as a separate project https://github.com/zio/zio-test-intellij, allowing the plugin to be completely decoupled for a specific ZIO version.

This means that the user must manually add

"zio.dev" %%% "zio-test-intellij" % zioVersion % test

to their build.sbt in order for the runner to exist on the classpath, and IntelliJ to use it.

Consider alternative ways, such as downloading a matching runner in the background (similar to how IntelliJ downloads scalafmt)

Idea 2020.1 support

I see that there's a PR for idea 2020.1 support #32,
can we publish a new version to the marketplace?

image

Rewrite `*>` chain expressions to `for`

x *> 
y *> 
z

to

for {
  _ <- x
  _ <- y
  r <- z
} yield r

Oftentimes a chain starts small, with one or two actions chained with *>. When such a chain grows larger it becomes more suitable to write it as a for-comprehension.

Have both testrunners for 2.12 and 2.13 share the sources

The testrunner library is used by the test runner. It needs to add the correct version to the classpath in order to run the tests.
Right now, it's just a duplicate project, with duplicated sources.
Ideally, they should share the sources and just use a different scala versions (and zio versions) to compile.

Any help is appreciated!

Wrong suggestion fromOption

Given:

val a: Task[Option[Int]] = ZIO(Option(1))

it suggests ZIO.fromOption which is obviously wrong since the fromOption will return an IO[Unit,...] and initial code is IO[Throwable,...]

Suggest io.delay

clock.sleep(duration) *> io can be simplified to io.delay(duration)

scalaJS targets are not supported by the test runner

Exception in thread "main" java.lang.ExceptionInInitializerError
  at org.portablescala.reflect.Reflect$.lookupLoadableModuleClass(Reflect.scala:23)
  at org.portablescala.reflect.Reflect$.lookupLoadableModuleClass(Reflect.scala:41)
  at zio.intellij.testsupport.runner.ZTestRunner$.createSpec(ZTestRunner.scala:26)
  at zio.intellij.testsupport.runner.ZTestRunner$.run(ZTestRunner.scala:35)
  at zio.intellij.testsupport.runner.ZTestRunnerHost.main(ZTestRunnerHost.java:5)
Caused by: java.lang.ClassCastException: scala.scalajs.js.Object cannot be cast to scala.scalajs.js.Dictionary
  at scala.scalajs.js.Dictionary$.empty(Dictionary.scala:83)
  at scala.scalajs.reflect.Reflect$.<init>(Reflect.scala:72)
  at scala.scalajs.reflect.Reflect$.<clinit>(Reflect.scala)
  ... 5 more

warn about nested or unused ZIO

The common pitfall we see is when ZIO is nested in other ZIO. And therefore is not executed.
This problem can have many forms. Thanks to developers and blogs this is already documented and has following forms:

The idea would be to write an inspection that can recognize such lone ZIOs and at least warn about the issue.

"Replace with .unit" replacing too much code

Sometimes the .unit suggestion is replacing too much code. Here's a minimal example:

UIO(println("a")) *> UIO(println("b")).unit

It gets replaced with:

UIO(println("a")).unit

This is with 2020.1.0.5.

Convert gradle to sbt

There's a sbt-idea-plugin whose goal is to allow building and packaging IntelliJ plugins from sbt. It would be great to convert the current gradle build to this sbt one!

Implement @mockable support

ZIO guidelines suggest using zio-macros to generate helper methods for service mocking.
It would be great to add hints in Intellij Idea for the generated code.

Problem running tests from IntelliJ in RC18

In RC17 I was able to run the tests from within IntelliJ. I think in RC18 s.th. broke.

I get this error from the ZTestRunner.

Exception in thread "main" java.lang.NoSuchMethodError: zio.test.TestRunner.unsafeRun$default$2()Lzio/test/TestLogger;
	at zio.intellij.testsupport.runner.ZTestRunner$.run(ZTestRunner.scala:37)
	at zio.intellij.testsupport.runner.ZTestRunnerHost.main(ZTestRunnerHost.java:5)

As discussed with @adamgfraser in zio/zio#3014 it seems to be an issue with the IDEA plugin.

Add tests for inspections

This requires porting over massive amounts of base test fixtures from the scala plugin, because they are currently not published in the jar.

Suggest tap

.flatMap(a => f(a).as(a)) => .tap(f)
.flatMap(a => b.as(a)) => .tap(_ => b)

Similarly, tapError and tapBoth.

Support zio-macros @accessible

When using the module pattern (described here: https://zio.dev/docs/howto/howto_use_module_pattern) one can use the @accessible annotation from zio-macros to generate helper methods to access services.

Right now intellij is unable to pick up the macro expansion, so going with this recommended approach leaves you with red underlines and no code completion.

It is possible to "fake" macro expansion in intellij by injecting synthetic members with a plugin: https://blog.jetbrains.com/scala/2015/10/14/intellij-api-to-build-scala-macros-support/

I am working to test out adding support for @accessible. Once this is done it would be worth considering adding the other annotations the same way.

Suggest bimap

.map(a).mapError(b) => .bimap(b, a)
.mapError(a).map(b) => .bimap(a, b)

Wrong autofix for `.when` method

Example

def list: List[Int] = ???
def toZio: Int => UIO[Int] = ???

for {
  _ <- if (true) ZIO.foreach_(list)(toZio) else ZIO.unit
} yield ???

Plugin correctly suggests using the .when method, but incorrectly transforms for comprehension into

for {
  _ <- ZIO.foreach_(ZIO.foreach_(list)(toZio)).when(true)
} yield ???

MatchError in test run line marker

During querying provider Run line marker (class com.intellij.execution.lineMarker.RunLineMarkerProvider)

scala.MatchError: Some(ReferenceExpression: test) (of class scala.Some)
	at zio.intellij.testsupport.ZTestRunLineMarkerProvider.buildUrl(ZTestRunLineMarkerProvider.scala:38)
	at zio.intellij.testsupport.ZTestRunLineMarkerProvider.buildInfo$1(ZTestRunLineMarkerProvider.scala:27)
	at zio.intellij.testsupport.ZTestRunLineMarkerProvider.getInfo(ZTestRunLineMarkerProvider.scala:30)
	at com.intellij.execution.lineMarker.RunLineMarkerProvider.getLineMarkerInfo(RunLineMarkerProvider.java:53)
	at com.intellij.codeInsight.daemon.impl.LineMarkersPass.queryProviders(LineMarkersPass.java:171)
	at com.intellij.codeInsight.daemon.impl.LineMarkersPass.lambda$doCollectInformation$3(LineMarkersPass.java:96)
	at com.intellij.codeInsight.daemon.impl.Divider.divideInsideAndOutsideInOneRoot(Divider.java:79)
	at com.intellij.codeInsight.daemon.impl.LineMarkersPass.doCollectInformation(LineMarkersPass.java:91)
	at com.intellij.codeHighlighting.TextEditorHighlightingPass.collectInformation(TextEditorHighlightingPass.java:52)
	at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$null$1(PassExecutorService.java:434)
	at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1106)
	at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$doRun$2(PassExecutorService.java:427)
	at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:625)
	at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:570)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:61)
	at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.doRun(PassExecutorService.java:426)
	at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$run$0(PassExecutorService.java:402)
	at com.intellij.openapi.application.impl.ReadMostlyRWLock.executeByImpatientReader(ReadMostlyRWLock.java:168)
	at com.intellij.openapi.application.impl.ApplicationImpl.executeByImpatientReader(ApplicationImpl.java:168)
	at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.run(PassExecutorService.java:400)
	at com.intellij.concurrency.JobLauncherImpl$VoidForkJoinTask$1.exec(JobLauncherImpl.java:171)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)

Test runner doesn't work on JVM 1.8

java.lang.UnsupportedClassVersionError: zio/intellij/testsupport/runner/ZTestRunnerHost has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0

The test runner was compiled against JDK11... I guess java doesn't like it.

sigh ๐Ÿ˜•

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.