1

今天我在我的 macbook 上安装了 intelliJ ceylon IDE。编译我的项目时,我收到以下消息

/Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk/Contents/Home/bin/java "-Dceylon.system.repo=/Users/Laust/Library/ApplicationSupport/IdeaIC2016.3/CeylonIDEA/classes/embeddedDist/repo" -Didea.launcher.port=7533 "-Didea.launcher.bin.path=/Applications/IntelliJ IDEA CE.app/Contents/bin" -Dfile.encoding=UTF-8 -classpath "/Users/Laust/Library/Application Support/IdeaIC2016.3/CeylonIDEA/classes/embeddedDist/lib/ceylon-bootstrap.jar:/Applications/IntelliJ IDEA CE.app/Contents/lib/idea_rt.jar" com.intellij.rt.execution.application.AppMain com.redhat.ceylon.launcher.Bootstrap run --run main default/unversioned
ceylon run: Module default/unversioned not found in the following repositories:
 /Users/Laust/Library/Application Support/IdeaIC2016.
3/CeylonIDEA/classes/embeddedDist/repo
 /Users/Laust/.ceylon/cache
 https://modules.ceylon-lang.org/repo/1
 [Maven] Aether
 [NPM] npm

Process finished with exit code 1

该代码在我的另一台计算机(Windows 7)上执行良好。

文件夹“模块”包含以下内容:

default
    default.car
    default.car.sha1
    default.src
    default.src.sha1

我的构建配置如下所示

这是我的代码(在文件 source/main.ceylon 中)

shared void main() {
    print("Generating pretty sweet g-code:");

    {Gcommand+} myGcommands = {
        G00( Vector3(0.0, 0.0, 0.0) ),
        G00( Vector3(9.0, 0.0, 0.0) ),
        G00( Vector3(9.0, 9.0, 0.0) ),
        G00( Vector3(0.0, 9.0, 0.0) ),
        G00( Vector3(0.0, 0.0, 0.0) )
    };

    GcodeProgram myGcodeProgram = GcodeProgram( *myGcommands );

    print(myGcodeProgram.toString());
}

"A carthesian coordinate class"
alias X => Float;
alias Y => Float;
alias Z => Float;
class Vector3(shared X x, shared Y y, shared Z z) {
}

"An abstract spec class for all G-code command classes"
abstract class Gcommand() {
    shared formal String toString();
}

"G-code command for moving in a straight line at rapid speed"
class G00( Vector3 endPoint ) extends Gcommand() {
    toString() => "G0 " + "X" + endPoint.x.string
                        + "Y" + endPoint.y.string
                        + "Z" + endPoint.z.string + "\n";
}

class GcodeProgram( Gcommand+ gcommands ) {

    variable String stringifiedGcodeProgram = "";

    shared String toString() {
        for (gcommand in gcommands) {
            stringifiedGcodeProgram = stringifiedGcodeProgram + gcommand.toString();
        }
    return stringifiedGcodeProgram;
    }
}
4

4 回答 4

3

您提供的屏幕截图显示运行配置不基于任何 IntelliJ 模块(Use classpath of module设置为[none])。这意味着配置不会在目录所在的项目文件夹中运行modules。该目录包含已编译的代码,并且ceylon run会在您要求它运行default模块时查找该目录。

一般来说,您应该避免手动创建运行配置。通过单击可运行函数名称旁边的绿色箭头,Ceylon IDE 将自动创建并配置正确的运行配置。

运行锡兰函数

要修复您现有的运行配置,只需在标记为 的字段中选择包含您的代码的 IntelliJ 模块Use classpath of module

另请参阅入门指南,了解有关如何开始使用 Ceylon IDE for IntelliJ 的更多信息。

于 2017-02-04T15:49:02.770 回答
0

这可能是 IntelliJ 插件无法正确处理“默认”模块的错误。我们倾向于不使用默认模块,因为它们比常规模块更受限制。

尝试创建一个模块并将您的代码移动到它。这很可能会解决问题。如果是这样,您可以打开一个问题以在此处修复此错误:https ://github.com/ceylon/ceylon-ide-intellij/issues/new

于 2017-02-04T11:31:05.053 回答
0

这里的项目设置似乎有些混乱。请注意正在搜索的存储库列表:

Module default/unversioned not found in the following repositories:
 /Users/Laust/Library/Application Support/IdeaIC2016.3/CeylonIDEA/classes/embeddedDist/repo
 /Users/Laust/.ceylon/cache
 https://modules.ceylon-lang.org/repo/1
 [Maven] Aether
 [NPM] npm

我希望看到一个 repoyour-project-dir/modules作为该列表中的第二个条目,但它不存在。

也就是说,ceylon run不是在modules编译所在的目录中查找.car。所以问题是为什么列表中缺少该回购。

您在 Project Structure > Modules > Ceylon > Repositories 中看到了什么?

于 2017-02-04T14:13:02.450 回答
0

这个问题中,第一个(也是唯一一个)答案告诉我们如何创建一个新模块。

我对这个答案有几点评论:

  • 在开始一个新项目时,您可能不需要为您的模块使用复杂的嵌套命名层次结构。如果您在模块名称中使用句点(例如my.ceylon.example),您会明白这一点,所以我建议您坚持使用简单的名称,例如main.
  • 创建新模块时,您将(除其他外)被要求指定一个“可运行单元名称”。该字段的目的是告诉 IntelliJ 在启动程序时应该执行哪些模块类。换句话说,这将成为您程序的入口点。一个合适的名称可以(也)是main.
  • Ceylon 项目分为模块,模块分为包,包分为类和顶层函数。创建模块时,会在该模块下自动创建一个包。此模块下的代码文件的路径将是“source/moduleName/packageName”。创建新模块时,您无需指定模块中第一个包的名称。相反,包的名称与您的模块名称相同。因此,名为“main”的模块将具有此路径:source/main/main作为其代码文件的路径。
  • 在您的新模块文件夹(例如source/main/main)中,将创建三个新文件。找到以您之前选择的“可运行单元名称”命名的文件。您的代码应该进入这个文件。此外,您的代码应该有一个与您选择作为“可运行单元名称”的名称完全相同的类
  • 答案使用了花哨的术语“可运行单元”,他只是指包含锡兰代码的文件。
  • 在尝试运行新模块之前,请记住删除包含旧“默认”模块的文件。
  • 模块名称不能以大写字母开头。
  • modules/是编译代码所在的输出目录。它是在source/构建项目时从代码中自动重新创建的。
于 2017-02-04T13:37:12.790 回答