Basic support of the Eclipse Ceylon language (#10096)

Basic support of the Eclipse Ceylon language support, with the following features:
- language description,
- syntax highlighting,
- project creation.

Signed-off-by: David Festal <dfestal@redhat.com>
6.19.x
David Festal 2018-06-21 17:43:01 +02:00 committed by GitHub
parent 919f7712a9
commit ae657b4f53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
28 changed files with 2526 additions and 0 deletions

View File

@ -39,6 +39,10 @@
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-camel-server</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-ceylon-lang-server</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-clangd-lang-server</artifactId>

View File

@ -30,6 +30,11 @@
<artifactId>che-ide-core</artifactId>
<type>gwt-lib</type>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-ceylon-lang-ide</artifactId>
<type>gwt-lib</type>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-composer-ide</artifactId>

View File

@ -0,0 +1,113 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2012-2018 Red Hat, Inc.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v10.html
Contributors:
Red Hat, Inc. - initial API and implementation
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>che-plugin-ceylon-parent</artifactId>
<groupId>org.eclipse.che.plugin</groupId>
<version>6.8.0-SNAPSHOT</version>
</parent>
<artifactId>che-plugin-ceylon-lang-ide</artifactId>
<packaging>gwt-lib</packaging>
<name>Che Plugin :: Ceylon :: IDE</name>
<dependencies>
<dependency>
<groupId>com.google.gwt.inject</groupId>
<artifactId>gin</artifactId>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-languageserver-shared</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-ide-api</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-ide-app</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-ide-ui</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-ceylon-lang-shared</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-ceylon-lang-shared</artifactId>
<classifier>sources</classifier>
</dependency>
<dependency>
<groupId>org.vectomatic</groupId>
<artifactId>lib-gwt-svg</artifactId>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>net.ltgt.gwt.maven</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<moduleName>org.eclipse.che.plugin.ceylon.Ceylon</moduleName>
</configuration>
</plugin>
<plugin>
<groupId>com.mycila</groupId>
<artifactId>license-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>**/ceylon.svg</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>analyze</id>
<configuration>
<ignoredUnusedDeclaredDependencies>
<!-- Ignore *-sources.jar analysis due to the fact that analyzer works at bytecode level
but *-sources.jar is required for including to the GWT source path. -->
<dep>org.eclipse.che.plugin:che-plugin-ceylon-lang-shared</dep>
</ignoredUnusedDeclaredDependencies>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,61 @@
/*
* Copyright (c) 2012-2018 Red Hat, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.plugin.ceylon.ide;
import static org.eclipse.che.ide.api.action.IdeActions.GROUP_FILE_NEW;
import com.google.inject.Inject;
import com.google.inject.name.Named;
import org.eclipse.che.ide.api.action.ActionManager;
import org.eclipse.che.ide.api.action.DefaultActionGroup;
import org.eclipse.che.ide.api.extension.Extension;
import org.eclipse.che.ide.api.filetypes.FileType;
import org.eclipse.che.ide.api.filetypes.FileTypeRegistry;
import org.eclipse.che.ide.api.icon.Icon;
import org.eclipse.che.ide.api.icon.IconRegistry;
import org.eclipse.che.plugin.ceylon.ide.action.CreateCeylonFileAction;
/**
* Python extension entry point.
*
* @author David Festal
*/
@Extension(title = "Ceylon")
public class CeylonExtension {
public static String CEYLON_CATEGORY = "Ceylon";
@Inject
public CeylonExtension(
FileTypeRegistry fileTypeRegistry,
CreateCeylonFileAction createCeylonFileAction,
ActionManager actionManager,
CeylonResources ceylonResources,
IconRegistry iconRegistry,
@Named("CeylonFileType") FileType ceylonFile) {
fileTypeRegistry.registerFileType(ceylonFile);
}
@Inject
private void prepareActions(
CreateCeylonFileAction createCeylonFileAction,
ActionManager actionManager,
CeylonResources resources,
IconRegistry iconRegistry) {
DefaultActionGroup newGroup = (DefaultActionGroup) actionManager.getAction(GROUP_FILE_NEW);
actionManager.registerAction("newCeylonFile", createCeylonFileAction);
newGroup.add(createCeylonFileAction);
iconRegistry.registerIcon(
new Icon(CEYLON_CATEGORY + ".samples.category.icon", resources.category()));
}
}

View File

@ -0,0 +1,33 @@
/*
* Copyright (c) 2012-2018 Red Hat, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.plugin.ceylon.ide;
import static java.util.Arrays.asList;
import javax.inject.Provider;
import org.eclipse.che.api.languageserver.shared.model.LanguageDescription;
import org.eclipse.che.plugin.ceylon.shared.Constants;
public class CeylonLanguageDescriptionProvider implements Provider<LanguageDescription> {
private static final String[] EXTENSIONS = new String[] {Constants.CEYLON_EXT};
private static final String MIME_TYPE = "text/x-ceylon";
@Override
public LanguageDescription get() {
LanguageDescription description = new LanguageDescription();
description.setFileExtensions(asList(EXTENSIONS));
description.setLanguageId(Constants.LANGUAGE_ID);
description.setMimeType(MIME_TYPE);
description.setHighlightingConfiguration(CeylonResources.INSTANCE.syntax().getText());
return description;
}
}

View File

@ -0,0 +1,30 @@
/*
* Copyright (c) 2012-2018 Red Hat, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.plugin.ceylon.ide;
import com.google.gwt.i18n.client.Messages;
import com.google.gwt.i18n.client.Messages.DefaultMessage;
/**
* Localization constants. Interface to represent the constants defined in resource bundle:
* 'CeylonLocalizationConstant.properties'.
*
* @author David Festal
*/
public interface CeylonLocalizationConstant extends Messages {
@Key("ceylon.action.create.file.title")
@DefaultMessage("New Ceylon File")
String createCeylonFileActionTitle();
@Key("ceylon.action.create.file.description")
@DefaultMessage("Create a Ceylon file")
String createCeylonFileActionDescription();
}

View File

@ -0,0 +1,30 @@
/*
* Copyright (c) 2012-2018 Red Hat, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.plugin.ceylon.ide;
import com.google.gwt.core.client.GWT;
import com.google.gwt.resources.client.ClientBundle;
import com.google.gwt.resources.client.TextResource;
import org.vectomatic.dom.svg.ui.SVGResource;
/** @author David Festal */
public interface CeylonResources extends ClientBundle {
CeylonResources INSTANCE = GWT.create(CeylonResources.class);
@Source("svg/ceylon.svg")
SVGResource ceylonFile();
@Source("svg/ceylon.svg")
SVGResource category();
@Source("json/highlighting.json")
TextResource syntax();
}

View File

@ -0,0 +1,72 @@
/*
* Copyright (c) 2012-2018 Red Hat, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.plugin.ceylon.ide.action;
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;
import com.google.web.bindery.event.shared.EventBus;
import org.eclipse.che.ide.CoreLocalizationConstant;
import org.eclipse.che.ide.api.app.AppContext;
import org.eclipse.che.ide.api.editor.EditorAgent;
import org.eclipse.che.ide.api.notification.NotificationManager;
import org.eclipse.che.ide.newresource.AbstractNewResourceAction;
import org.eclipse.che.ide.ui.dialogs.DialogFactory;
import org.eclipse.che.plugin.ceylon.ide.CeylonLocalizationConstant;
import org.eclipse.che.plugin.ceylon.ide.CeylonResources;
import org.eclipse.che.plugin.ceylon.shared.Constants;
/**
* Action to create new Ceylon source file.
*
* @author David Festal
*/
@Singleton
public class CreateCeylonFileAction extends AbstractNewResourceAction {
private static final String DEFAULT_CONTENT =
"\"A Hello World! program in Ceylon.\""
+ "shared void run() {\n"
+ " print(\"Hello World!\");\n"
+ "}";
@Inject
public CreateCeylonFileAction(
CeylonLocalizationConstant localizationConstant,
CeylonResources resources,
DialogFactory dialogFactory,
CoreLocalizationConstant coreLocalizationConstant,
EventBus eventBus,
AppContext appContext,
NotificationManager notificationManager,
Provider<EditorAgent> editorAgentProvider) {
super(
localizationConstant.createCeylonFileActionTitle(),
localizationConstant.createCeylonFileActionDescription(),
resources.ceylonFile(),
dialogFactory,
coreLocalizationConstant,
eventBus,
appContext,
notificationManager,
editorAgentProvider);
}
@Override
protected String getExtension() {
return Constants.CEYLON_EXT;
}
@Override
protected String getDefaultContent() {
return DEFAULT_CONTENT;
}
}

View File

@ -0,0 +1,50 @@
/*
* Copyright (c) 2012-2018 Red Hat, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.plugin.ceylon.ide.inject;
import static com.google.gwt.inject.client.multibindings.GinMultibinder.newSetBinder;
import com.google.gwt.inject.client.AbstractGinModule;
import com.google.inject.Provides;
import com.google.inject.Singleton;
import com.google.inject.name.Named;
import org.eclipse.che.api.languageserver.shared.model.LanguageDescription;
import org.eclipse.che.ide.api.extension.ExtensionGinModule;
import org.eclipse.che.ide.api.filetypes.FileType;
import org.eclipse.che.ide.api.project.type.wizard.ProjectWizardRegistrar;
import org.eclipse.che.plugin.ceylon.ide.CeylonLanguageDescriptionProvider;
import org.eclipse.che.plugin.ceylon.ide.CeylonResources;
import org.eclipse.che.plugin.ceylon.ide.project.CeylonProjectWizardRegistrar;
import org.eclipse.che.plugin.ceylon.shared.Constants;
/** @author David Festal */
@ExtensionGinModule
public class CeylonGinModule extends AbstractGinModule {
/** {@inheritDoc} */
@Override
protected void configure() {
newSetBinder(binder(), ProjectWizardRegistrar.class)
.addBinding()
.to(CeylonProjectWizardRegistrar.class);
newSetBinder(binder(), LanguageDescription.class)
.addBinding()
.toProvider(CeylonLanguageDescriptionProvider.class);
}
@Provides
@Singleton
@Named("CeylonFileType")
protected FileType provideCeylonFile() {
return new FileType(CeylonResources.INSTANCE.ceylonFile(), Constants.CEYLON_EXT);
}
}

View File

@ -0,0 +1,50 @@
/*
* Copyright (c) 2012-2018 Red Hat, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.plugin.ceylon.ide.project;
import com.google.inject.Provider;
import java.util.ArrayList;
import java.util.List;
import javax.validation.constraints.NotNull;
import org.eclipse.che.ide.api.project.MutableProjectConfig;
import org.eclipse.che.ide.api.project.type.wizard.ProjectWizardRegistrar;
import org.eclipse.che.ide.api.wizard.WizardPage;
import org.eclipse.che.plugin.ceylon.ide.CeylonExtension;
import org.eclipse.che.plugin.ceylon.shared.Constants;
/**
* Provides information for registering CEYLON_PROJECT_TYPE_ID project type into project wizard.
*
* @author David festal
*/
public class CeylonProjectWizardRegistrar implements ProjectWizardRegistrar {
private final List<Provider<? extends WizardPage<MutableProjectConfig>>> wizardPages;
public CeylonProjectWizardRegistrar() {
wizardPages = new ArrayList<>();
}
@NotNull
public String getProjectTypeId() {
return Constants.CEYLON_PROJECT_TYPE_ID;
}
@NotNull
public String getCategory() {
return CeylonExtension.CEYLON_CATEGORY;
}
@NotNull
public List<Provider<? extends WizardPage<MutableProjectConfig>>> getWizardPages() {
return wizardPages;
}
}

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2012-2018 Red Hat, Inc.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v10.html
Contributors:
Red Hat, Inc. - initial API and implementation
-->
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.7.0//EN" "http://gwtproject.org/doctype/2.7.0/gwt-module.dtd">
<module>
<inherits name="com.google.gwt.user.User"/>
<inherits name="com.google.gwt.http.HTTP"/>
<inherits name="com.google.gwt.i18n.I18N"/>
<inherits name="com.google.gwt.json.JSON"/>
<inherits name="com.google.gwt.inject.Inject"/>
<inherits name="org.eclipse.che.api.project.Project"/>
<source path="ide"/>
<source path="shared"/>
</module>

View File

@ -0,0 +1,25 @@
[
{ include: "orion.lib#string_singleQuote"},
{ include: "orion.c-like#comment_singleLine"},
{ include: "orion.c-like#comment_block"},
{ include: "orion.lib#brace_open"},
{ include: "orion.lib#brace_close"},
{ include: "orion.lib#bracket_open"},
{ include: "orion.lib#bracket_close"},
{ include: "orion.lib#parenthesis_open"},
{ include: "orion.lib#parenthesis_close"},
{ include: "orion.lib#operator"},
{ match: "^#!/.*$", name: "comment.shebang.ceylon"},
{ match: "\\b(assembly|module|package|import|alias|class|interface|object|given|value|assign|void|function|new|of|extends|satisfies|adapts|abstracts|in|out|return|break|continue|throw|assert|dynamic|if|else|switch|case|for|while|try|catch|finally|then|let|this|outer|super|is|exists|nonempty)\\b", name: "keyword.control.ceylon"},
{ match: "\\b(doc|by|license|see|throws|tagged|shared|abstract|formal|default|actual|variable|late|native|deprecated|final|sealed|annotation|suppressWarnings|static)\\b", name: "keyword.annotations.ceylon" },
{ match: "([A-Z][a-zA-Z0-9_]*|\\\\I[a-zA-Z0-9_]+)", name: "entity.name.class.ceylon" },
{ match: "([a-z][a-zA-Z0-9_]*|\\\\i[a-zA-Z0-9_]+)", name: "variable.other.ceylon"},
{ begin: "\"\"\"", end: "\"\"\"", name: "string.verbatim.ceylon"},
{ begin: "\"", end: "\"|(``)", name: "string.template.head.ceylon", patterns: [{ match: "\\\\.", name: "constant.character.escape.ceylon"}]},
{ begin: "``", end: "\"|``", name: "string.template.midOrtail.ceylon" },
{ match: "`[a-zA-Z][^`]*`", name: "metamodel.ceylon"},
{ match: "\\$(([01]+(_[01]+)+)|[01]+)", name: "constant.numeric.binary.ceylon"},
{ match: "#(([0-9ABCDEF]+(_[0-9ABCDEF]+)+)|[0-9ABCDEF]+)", name: "constant.numeric.hexa.ceylon"},
{ match: "-?(([0-9]+(_[0-9]+)+)|[0-9]+)\\\\.(([0-9]+(_[0-9]+)+)|[0-9]+)(([eE]-?(([0-9]+(_[0-9]+)+)|[0-9]+))|[kmgtpKMGTP])?", name: "constant.numeric.floating.ceylon"},
{ match: "-?(([0-9]+(_[0-9]+)+)|[0-9]+)[kmgtpKMGTP]?", name: "constant.numeric.decimal.ceylon"}
]

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 108 KiB

View File

@ -0,0 +1,79 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2012-2018 Red Hat, Inc.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v10.html
Contributors:
Red Hat, Inc. - initial API and implementation
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>che-plugin-ceylon-parent</artifactId>
<groupId>org.eclipse.che.plugin</groupId>
<version>6.8.0-SNAPSHOT</version>
</parent>
<artifactId>che-plugin-ceylon-lang-server</artifactId>
<name>Che Plugin :: Ceylon :: Extension Server</name>
<properties>
<findbugs.failonerror>false</findbugs.failonerror>
</properties>
<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
</dependency>
<dependency>
<groupId>com.google.inject.extensions</groupId>
<artifactId>guice-multibindings</artifactId>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-core</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-project</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-commons-inject</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-ceylon-lang-shared</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.mycila</groupId>
<artifactId>license-maven-plugin</artifactId>
<configuration>
<excludes>
<!-- The files don't need a license since they will
be added as templates inside the user projects -->
<exclude>src/main/resources/project/**</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,35 @@
/*
* Copyright (c) 2012-2018 Red Hat, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.plugin.ceylon.inject;
import com.google.inject.AbstractModule;
import com.google.inject.multibindings.Multibinder;
import org.eclipse.che.api.project.server.handlers.ProjectHandler;
import org.eclipse.che.api.project.server.type.ProjectTypeDef;
import org.eclipse.che.inject.DynaModule;
import org.eclipse.che.plugin.ceylon.projecttype.CeylonProjectType;
import org.eclipse.che.plugin.ceylon.projecttype.CreateCeylonProjectHandler;
/** @author David Festal */
@DynaModule
public class CeylonModule extends AbstractModule {
@Override
protected void configure() {
Multibinder<ProjectTypeDef> projectTypeMultibinder =
Multibinder.newSetBinder(binder(), ProjectTypeDef.class);
projectTypeMultibinder.addBinding().to(CeylonProjectType.class);
Multibinder<ProjectHandler> projectHandlersMultibinder =
Multibinder.newSetBinder(binder(), ProjectHandler.class);
projectHandlersMultibinder.addBinding().to(CreateCeylonProjectHandler.class);
}
}

View File

@ -0,0 +1,28 @@
/*
* Copyright (c) 2012-2018 Red Hat, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.plugin.ceylon.projecttype;
import com.google.inject.Inject;
import org.eclipse.che.api.project.server.type.ProjectTypeDef;
import org.eclipse.che.plugin.ceylon.shared.Constants;
/**
* Ceylon project type
*
* @author David Festal
*/
public class CeylonProjectType extends ProjectTypeDef {
@Inject
public CeylonProjectType() {
super(Constants.CEYLON_PROJECT_TYPE_ID, "Ceylon", true, false, true);
addConstantDefinition(Constants.LANGUAGE, "language", Constants.CEYLON_LANG);
}
}

View File

@ -0,0 +1,87 @@
/*
* Copyright (c) 2012-2018 Red Hat, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.plugin.ceylon.projecttype;
import static com.google.common.io.Resources.getResource;
import static com.google.common.io.Resources.toByteArray;
import static org.eclipse.che.api.fs.server.WsPathUtils.resolve;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
import javax.inject.Inject;
import org.eclipse.che.api.core.ConflictException;
import org.eclipse.che.api.core.ForbiddenException;
import org.eclipse.che.api.core.NotFoundException;
import org.eclipse.che.api.core.ServerException;
import org.eclipse.che.api.fs.server.FsManager;
import org.eclipse.che.api.project.server.handlers.CreateProjectHandler;
import org.eclipse.che.api.project.server.type.AttributeValue;
import org.eclipse.che.plugin.ceylon.shared.Constants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** @author David Festal */
public class CreateCeylonProjectHandler implements CreateProjectHandler {
private static final Logger LOG = LoggerFactory.getLogger(CreateCeylonProjectHandler.class);
private static final String[] PROJECT_FILES =
new String[] {
"ceylonb",
"ceylonb.bat",
".ceylon/config",
".ceylon/ide-config",
".ceylon/bootstrap/ceylon-bootstrap.jar",
".ceylon/bootstrap/ceylon-bootstrap.properties",
"source/run.ceylon"
};
private final FsManager fsManager;
@Inject
public CreateCeylonProjectHandler(FsManager fsManager) {
this.fsManager = fsManager;
}
@Override
public void onCreateProject(
String projectWsPath, Map<String, AttributeValue> attributes, Map<String, String> options)
throws ForbiddenException, ConflictException, ServerException, NotFoundException {
fsManager.createDir(projectWsPath);
fsManager.createDir(resolve(projectWsPath, "source"));
fsManager.createDir(resolve(projectWsPath, "resource"));
for (String file : PROJECT_FILES) {
InputStream inputStream = new ByteArrayInputStream(getProjectContent("project/" + file));
String wsPath = resolve(projectWsPath, file);
fsManager.createFile(wsPath, inputStream, true, true);
if (file.startsWith("ceylonb")) {
fsManager.toIoFile(wsPath).setExecutable(true);
}
}
}
private byte[] getProjectContent(String file) {
try {
return toByteArray(getResource(file));
} catch (IOException e) {
LOG.warn("File %s not found so its content will be empty.", file);
return new byte[0];
}
}
@Override
public String getProjectType() {
return Constants.CEYLON_PROJECT_TYPE_ID;
}
}

View File

@ -0,0 +1,2 @@
distribution=https\://ceylon-lang.org/download/dist/1_3_3
installation=../../../.ceylon

View File

@ -0,0 +1,11 @@
[compiler]
source=source
resource=resource
[defaults]
encoding=UTF-8
offline=false
flatclasspath=false
autoexportmavendependencies=false
fullyexportmavendependencies=false

View File

@ -0,0 +1,4 @@
[project]
compile-jvm=true
compile-js=false
system-repository=

View File

@ -0,0 +1,81 @@
#!/bin/sh
# resolve links - $0 may be a softlink
PRG="$0"
while [ -h "$PRG" ]; do
ls="$(ls -ld "$PRG")"
link="${ls##*-> }" # remove largest prefix: yields link target (behind ->)
if [ "$link" != "${link#/}" ]; then # remove prefix / if present
# path was absolute
PRG="$link"
else
# was not
PRG="$(dirname "$PRG")/$link"
fi
done
DIR="$(dirname "$PRG")"
# Check if we should use a distribution bootstrap
if [ -f "$DIR/.ceylon/bootstrap/ceylon-bootstrap.properties" ] && [ -f "$DIR/.ceylon/bootstrap/ceylon-bootstrap.jar" ]; then
# Using bootstrap
LIB="$DIR/.ceylon/bootstrap"
else
# Normal execution
CEYLON_HOME="$DIR/.."
LIB="$CEYLON_HOME/lib"
if [ "$1" = "--show-home" ]; then
echo "$CEYLON_HOME"
exit
fi
fi
if [ -z "$JAVA_HOME" ]; then
JAVA="java"
else
JAVA="$JAVA_HOME/bin/java"
fi
# Make sure we have java installed
if ! hash java 2>&-
then
echo >&2 "Java not found, you must install Java in order to compile and run Ceylon programs"
echo >&2 "Go to http://www.java.com/getjava/ to download the latest version of Java"
exit 1
fi
#JAVA_DEBUG_OPTS="-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y"
if [ "$PRESERVE_JAVA_OPTS" != "true" ]; then
PREPEND_JAVA_OPTS="$JAVA_DEBUG_OPTS"
if [ -n "$COLUMNS" ]; then
CEYL_COLS="$COLUMNS"
elif stty size 2>/dev/null >/dev/null; then
CEYL_COLS="$(stty size 2>/dev/null | cut -d' ' -f2)"
else
CEYL_COLS="$(tput 2>/dev/null cols)"
fi
PREPEND_JAVA_OPTS="$PREPEND_JAVA_OPTS -Dcom.redhat.ceylon.common.tool.terminal.width=$CEYL_COLS"
PREPEND_JAVA_OPTS="$PREPEND_JAVA_OPTS -Dcom.redhat.ceylon.common.tool.progname=$(basename "$PRG")"
fi
for arg; do
case $arg in
--java=*) JAVA_OPTS="$JAVA_OPTS ${arg#--java=}";;
[!-]*) break;;
esac
done
JAVA_OPTS="$PREPEND_JAVA_OPTS $JAVA_OPTS"
BOOTSTRAP="$LIB/ceylon-bootstrap.jar"
# Check for cygwin, convert bootstrap path to Windows format
case "`uname`" in
CYGWIN*) [ -n "$LIB" ] && BOOTSTRAP=`cygpath -w "$BOOTSTRAP"`
esac
exec "$JAVA" \
$JAVA_OPTS \
-jar "$BOOTSTRAP" \
"$@"

View File

@ -0,0 +1,132 @@
@echo off
setlocal ENABLEDELAYEDEXPANSION
:: Check if we should use a distribution bootstrap
pushd "%~dp0"
set "DIR=%CD%"
popd
if NOT exist "%DIR%\.ceylon\bootstrap\ceylon-bootstrap.properties" (
goto :normal
)
if NOT exist "%DIR%\.ceylon\bootstrap\ceylon-bootstrap.jar" (
goto :normal
)
:: Using bootstrap
set "LIB=%DIR%\.ceylon\bootstrap"
goto :endbs
:normal
:: Normal execution
:: Find CEYLON_HOME
pushd "%~dp0.."
set "CEYLON_HOME=%CD%"
popd
set "LIB=%CEYLON_HOME%\lib"
if "%~1" == "--show-home" (
@echo %CEYLON_HOME%
exit /b 1
)
:endbs
:: Find Java
:: Only check the registry if JAVA_HOME is not already set
IF NOT "%JAVA_HOME%" == "" (
goto :javaend
)
:: Find Java in the registry
set "KEY_NAME=HKLM\SOFTWARE\JavaSoft\Java Runtime Environment"
set "KEY_NAME2=HKLM\SOFTWARE\Wow6432Node\JavaSoft\Java Runtime Environment"
:: get the current version
FOR /F "usebackq skip=2 tokens=3" %%A IN (`REG QUERY "%KEY_NAME%" /v CurrentVersion 2^>nul`) DO (
set "ValueValue=%%A"
)
if "%ValueValue%" NEQ "" (
set "JAVA_CURRENT=%KEY_NAME%\%ValueValue%"
) else (
rem Try again for 64bit systems
FOR /F "usebackq skip=2 tokens=3" %%A IN (`REG QUERY "%KEY_NAME2%" /v CurrentVersion 2^>nul`) DO (
set "JAVA_CURRENT=%KEY_NAME2%\%%A"
)
)
if "%ValueValue%" NEQ "" (
set "JAVA_CURRENT=%KEY_NAME%\%ValueValue%"
) else (
rem Try again for 64bit systems from a 32-bit process
FOR /F "usebackq skip=2 tokens=3" %%A IN (`REG QUERY "%KEY_NAME%" /v CurrentVersion /reg:64 2^>nul`) DO (
set "JAVA_CURRENT=%KEY_NAME%\%%A"
)
)
if "%JAVA_CURRENT%" == "" (
@echo Java not found, you must install Java in order to compile and run Ceylon programs
@echo Go to http://www.java.com/getjava/ to download the latest version of Java
exit /b 1
)
:: get the javahome
FOR /F "usebackq skip=2 tokens=3*" %%A IN (`REG QUERY "%JAVA_CURRENT%" /v JavaHome 2^>nul`) DO (
set "JAVA_HOME=%%A %%B"
)
if "%JAVA_HOME%" EQU "" (
rem Try again for 64bit systems from a 32-bit process
FOR /F "usebackq skip=2 tokens=3*" %%A IN (`REG QUERY "%JAVA_CURRENT%" /v JavaHome /reg:64 2^>nul`) DO (
set "JAVA_HOME=%%A %%B"
)
)
:javaend
set "JAVA=%JAVA_HOME%\bin\java.exe"
:: Check that Java executable actually exists
if not exist "%JAVA%" (
@echo "Cannot find java.exe at %JAVA%, check that your JAVA_HOME variable is pointing to the right place"
exit /b 1
)
rem set JAVA_DEBUG_OPTS="-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y"
if NOT "%PRESERVE_JAVA_OPTS%" == "true" (
set PREPEND_JAVA_OPTS=%JAVA_DEBUG_OPTS%
rem Other java opts go here
)
rem Find any --java options and add their values to JAVA_OPTS
for %%x in (%*) do (
set ARG=%%~x
if "!ARG:~0,7!" EQU "--java=" (
set OPT=!ARG:~7!
set "JAVA_OPTS=!JAVA_OPTS! !OPT!"
) else if "!ARG!" EQU "--java" (
@echo Error: use --java options with an equal sign and quotes, eg: "--java=-Xmx500m"
exit /b 1
) else if "!ARG:~0,1!" NEQ "-" (
goto :breakloop
)
)
:breakloop
set "JAVA_OPTS=%PREPEND_JAVA_OPTS% %JAVA_OPTS%"
"%JAVA%" ^
%JAVA_OPTS% ^
-jar "%LIB%\ceylon-bootstrap.jar" ^
%*
endlocal
if %errorlevel% neq 0 exit /B %errorlevel%

View File

@ -0,0 +1,5 @@
"A Hello World! program in Ceylon"
shared void run() {
print("Hello World!");
}

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2012-2018 Red Hat, Inc.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v10.html
Contributors:
Red Hat, Inc. - initial API and implementation
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>che-plugin-ceylon-parent</artifactId>
<groupId>org.eclipse.che.plugin</groupId>
<version>6.8.0-SNAPSHOT</version>
</parent>
<artifactId>che-plugin-ceylon-lang-shared</artifactId>
<name>Che Plugin :: Ceylon :: Shared</name>
<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,31 @@
/*
* Copyright (c) 2012-2018 Red Hat, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.plugin.ceylon.shared;
/** @author David Festal */
public final class Constants {
/** Language attribute name */
public static final String LANGUAGE = "language";
/** Ceylon Project Type ID */
public static final String CEYLON_PROJECT_TYPE_ID = "ceylon";
/** Ceylon Language */
public static final String CEYLON_LANG = "ceylon_lang";
/** Default extension for Ceylon files */
public static final String CEYLON_EXT = "ceylon";
public static final String LANGUAGE_ID = "ceylon";
private Constants() {}
}

View File

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2012-2018 Red Hat, Inc.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v10.html
Contributors:
Red Hat, Inc. - initial API and implementation
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>che-plugin-parent</artifactId>
<groupId>org.eclipse.che.plugin</groupId>
<version>6.8.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>che-plugin-ceylon-parent</artifactId>
<packaging>pom</packaging>
<name>Che Plugin :: Ceylon :: Parent</name>
<modules>
<module>che-plugin-ceylon-lang-ide</module>
<module>che-plugin-ceylon-lang-shared</module>
<module>che-plugin-ceylon-lang-server</module>
</modules>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-dto-maven-plugin</artifactId>
<version>${project.version}</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>

View File

@ -58,6 +58,7 @@
<module>plugin-pullrequest-parent</module>
<module>plugin-yaml</module>
<module>plugin-camel</module>
<module>plugin-ceylon</module>
<module>plugin-clangd</module>
<module>plugin-golang</module>
</modules>

22
pom.xml
View File

@ -1087,6 +1087,28 @@
<artifactId>che-plugin-camel-server</artifactId>
<version>${che.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-ceylon-lang-ide</artifactId>
<version>${che.version}</version>
<type>gwt-lib</type>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-ceylon-lang-server</artifactId>
<version>${che.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-ceylon-lang-shared</artifactId>
<version>${che.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-ceylon-lang-shared</artifactId>
<version>${che.version}</version>
<classifier>sources</classifier>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-clangd-lang-server</artifactId>