Git Product home page Git Product logo

intellij-crystal-lang's People

Contributors

asedunov 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

Watchers

 avatar  avatar  avatar  avatar

intellij-crystal-lang's Issues

Add type-related diagnostics reported by top-level visitor of original compiler

Paths:

  • Nested types may only be declared inside modules/classes/structs

Reopening:

  • Class may only be reopened as class
  • Struct may only be reopened as struct
  • Module may only be reopened as module
  • Enum may only be reopened as enum
  • Annotation may only be reopened as annotation
  • Lib may only be reopened as lib
  • If reopened class/struct/module is generic, original declaration must also be generic and have the same set of type variables
  • An alias/typedef/C-struct/C-union may not be reopened at all

Inheritance:

  • If superclass/superstruct or included/extended module is generic, it must be supplied with type arguments
  • A class/struct may not inherit directly from Enum
  • A class may not inherit from from non-class
  • A struct may not inherit from non-struct
  • If a class/struct reopening specifies explicit supertype, it must be the same as original one
  • A struct may not inherit from non-abstract struct
  • Inclusion/extension target must be a module

Enums:

  • Enum base type must be an integer type
  • Enum must have at least one member
  • Enum reopening can't add more constants
  • Values of enum members may not overflow its base type
  • Flags enum can't redefine None member to non-zero
  • Flags enum can't redefine All member
  • If enum base type is Int32, all its values must also be of Int32 kind
  • Enum members must have distinct names

Annotation (general):

  • Annotation expression must refer to an annotation type
  • Annotation expression must not have duplicated named arguments

Extern annotation (structs):

  • annotation on non-generic struct must have a single named argument union with boolean literal as it value

Link annotation (libraries):

  • The only allowed arguments are lib (a string literal), ldflags (a string literal), static (a boolean literal), framework (a string literal) and pkg_config (a string literal). They may be passed as positional in the specified order (except pkg_config which must be named), named or using mixed notation
  • At least one argument must be specified
  • The same argument may not be specified more than once
  • Annotation with static attribute is deprecated
  • Annotation with positional arguments is deprecated

CallConvention annotation (libraries):

  • At most one annotation may be specified for a given library
  • Annotation must have a single positional argument, a string literal corresponding to one of LLVM::CallConvention values

Reference:
https://github.com/crystal-lang/crystal/blob/master/src/compiler/crystal/semantic/semantic_visitor.cr
https://github.com/crystal-lang/crystal/blob/master/src/compiler/crystal/semantic/top_level_visitor.cr

Implement Crystal injection inside macro bodies

Currently macro bodies are represented as opaque strings. The goal is to parse their content and inject into the original literal to enable highlighting, resolve and all available code insight features

what should I set as the standard library path?

just getting started with Crystal, installed it via homebrew, trying to create a project but can't find a folder which this plugin will accept but none seems to fit :/

os: Monterey 13.3.1 (Apple Silicon)
crystal: 1.8.0
shards: 0.17.3
plugin: 0.7-2023.1

output of /opt/homebrew/opt/crystal/bin/crystal env:

CRYSTAL_CACHE_DIR=/Users/user/.cache/crystal
CRYSTAL_PATH=lib:/opt/homebrew/Cellar/crystal/1.8.0/libexec/../share/crystal/src
CRYSTAL_VERSION=1.8.0
CRYSTAL_LIBRARY_PATH=/opt/homebrew/Cellar/crystal/1.8.0/libexec/../../../../lib
CRYSTAL_OPTS=''

running the project with empty path gives:

/opt/homebrew/Cellar/crystal/1.8.0/bin/crystal run --progress /Users/user/dev/tmp/crtest/src/p3415crtest.cr
Showing last frame. Use --error-trace for full trace.

In Users/user/dev/tmp/crtest/src/p3415crtest.cr:1:1

 1 | # TODO: Write documentation for `P3415crtest`
     ^
Error: can't find file 'prelude'

Differentiate syntax highlighting for the first part of a chained function call

Didn't know how better to phrase this one, but seeing as you're working so quickly I figured I throw this small issue at you. Right now there's one major issue I've noticed in the syntax highlighting, and that's that chained function calls have each part of the chain highlighted with the same color, which doesn't look great.

Screenshot from 2023-03-18 11-23-20

With the Ruby syntax highlighting in RubyMine, and the Crystal syntax highlighting in VS Code it looks like this which breaks up the monotony a bit and makes things easier to read.

Screenshot from 2023-03-18 11-23-47

Support syntax changes in Crystal 1.7

How to create a build/run configuration which creates a binary?

Noob question 2: how do I add the "build" configuration?
Just naively adding "build" to compiler parameters gets me

/opt/homebrew/Cellar/crystal/1.8.0/bin/crystal run --progress build /Users/user/dev/tmp/crtest/src/p3415crtest.cr

which predictably results in

Error: file 'build' does not exist

upd: for posterity

os: Monterey 13.3.1 (Apple Silicon)
crystal: 1.8.0
shards: 0.17.3
plugin: 0.7-2023.1

Add quick fix for removing parameters and arguments at improper positions

Cases to support:

  • Calls:
    • Multiple block arguments
    • Splat argument after double splat argument
    • Out argument after double splat argument
    • Ordinary (named/positional) argument after double splat
  • Blocks:
    • Multiple splat parameters
  • Generics:
    • Multiple splat type parameters
  • Methods/Functions/Macros:
    • Multiple splat parameters
    • Non-block parameters after double splat parameter
    • Any parameters after block parameter
    • More than one parameter in setter method

Exception when I try to open the structure window

When I try to see the structure of this file this file: https://github.com/MarioAriasC/monyet/blob/main/src/parser.cr

java.lang.NullPointerException
	at org.crystal.intellij.psi.CrProcType.getInputList(CrProcType.kt:20)
	at org.crystal.intellij.presentation.CrystalDefinitionPresentationBase.appendType(CrystalDefinitionPresentationBase.kt:91)
	at org.crystal.intellij.presentation.CrystalDefinitionPresentationBase.appendRHS(CrystalDefinitionPresentationBase.kt:66)
	at org.crystal.intellij.presentation.CrystalDefinitionPresentationBase.getPresentableText(CrystalDefinitionPresentationBase.kt:20)
	at org.crystal.intellij.presentation.CrystalDefinitionPresentationBase.getPresentableText(CrystalDefinitionPresentationBase.kt:15)
	at com.intellij.ide.projectView.PresentationData.updateFrom(PresentationData.java:168)
	at com.intellij.ide.util.treeView.smartTree.TreeElementWrapper.update(TreeElementWrapper.java:42)
	at com.intellij.ide.util.treeView.PresentableNodeDescriptor.getUpdatedPresentation(PresentableNodeDescriptor.java:78)
	at com.intellij.ide.util.treeView.PresentableNodeDescriptor.update(PresentableNodeDescriptor.java:30)
	at com.intellij.ui.tree.StructureTreeModel$Node.update(StructureTreeModel.java:455)
	at com.intellij.ui.tree.StructureTreeModel$Node.<init>(StructureTreeModel.java:436)
	at com.intellij.ui.tree.StructureTreeModel$Node.<init>(StructureTreeModel.java:429)
	at com.intellij.ui.tree.StructureTreeModel.getValidChildren(StructureTreeModel.java:390)
	at com.intellij.ui.tree.StructureTreeModel.validateChildren(StructureTreeModel.java:299)
	at com.intellij.ui.tree.StructureTreeModel$Node.isLeaf(StructureTreeModel.java:559)
	at com.intellij.ui.tree.StructureTreeModel.isLeaf(StructureTreeModel.java:335)
	at com.intellij.ui.tree.LeafState.get(LeafState.java:64)
	at com.intellij.ui.tree.AsyncTreeModel$CmdGetChildren.load(AsyncTreeModel.java:574)
	at com.intellij.ui.tree.AsyncTreeModel$CmdGetChildren.getNode(AsyncTreeModel.java:547)
	at com.intellij.ui.tree.AsyncTreeModel$Command.get(AsyncTreeModel.java:440)
	at com.intellij.ui.tree.AsyncTreeModel$Command.get(AsyncTreeModel.java:406)
	at com.intellij.util.concurrency.Invoker$Task.run(Invoker.java:316)
	at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1084)
	at com.intellij.openapi.progress.util.ProgressIndicatorUtils.lambda$runInReadActionWithWriteActionPriority$0(ProgressIndicatorUtils.java:75)
	at com.intellij.openapi.progress.util.ProgressIndicatorUtils.runActionAndCancelBeforeWrite(ProgressIndicatorUtils.java:158)
	at com.intellij.openapi.progress.util.ProgressIndicatorUtils.lambda$runWithWriteActionPriority$1(ProgressIndicatorUtils.java:115)
	at com.intellij.openapi.progress.ProgressManager.lambda$runProcess$0(ProgressManager.java:57)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:188)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$12(CoreProgressManager.java:624)
	at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:698)
	at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:646)
	at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:623)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:66)
	at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:175)
	at com.intellij.openapi.progress.ProgressManager.runProcess(ProgressManager.java:57)
	at com.intellij.openapi.progress.util.ProgressIndicatorUtils.runWithWriteActionPriority(ProgressIndicatorUtils.java:112)
	at com.intellij.openapi.progress.util.ProgressIndicatorUtils.runInReadActionWithWriteActionPriority(ProgressIndicatorUtils.java:75)
	at com.intellij.util.concurrency.Invoker.invokeSafely(Invoker.java:205)
	at com.intellij.util.concurrency.Invoker.lambda$offerSafely$0(Invoker.java:183)
	at com.intellij.util.concurrency.Invoker$Background.lambda$offer$0(Invoker.java:486)
	at com.intellij.util.concurrency.BoundedTaskExecutor.doRun(BoundedTaskExecutor.java:246)
	at com.intellij.util.concurrency.BoundedTaskExecutor.access$200(BoundedTaskExecutor.java:32)
	at com.intellij.util.concurrency.BoundedTaskExecutor$1.execute(BoundedTaskExecutor.java:225)
	at com.intellij.util.ConcurrencyUtil.runUnderThreadName(ConcurrencyUtil.java:213)
	at com.intellij.util.concurrency.BoundedTaskExecutor$1.run(BoundedTaskExecutor.java:214)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:668)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:665)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:665)
	at java.base/java.lang.Thread.run(Thread.java:829)

Some 1.3/1.4 syntax specifics are not reflected in parser

Support constant definitions

  • Implement constant reference resolve
  • Report constant redefinitions
  • Show constants in File Structure tool window
  • Allow searching constants via "Go To Symbol..."

Check branch duplication in case-expressions

Crystal compiler reports error when case-expressions contains duplicate conditions in when/in. For example the code above should be highlighted as red:

case x; when {1, 2}; 2; when {1, 2}; end

Report wrongly used expression splats

As of 1.3 expression splat can only be used as:

  • call argument
  • argument of a qualified assignment of the form a.b = (*c) which is semantically is also a call of b= method

In 1.4 it's also allowed to use splats as assignment left-hand side (e.g. *a = b, c). This case is covered by #11

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.