Skip to content
This repository was archived by the owner on Aug 3, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<classpathentry kind="src" path="org.eclim.sdt/test/junit"/>
<classpathentry kind="src" path="org.eclim.vimplugin/java"/>
<classpathentry kind="src" path="org.eclim.wst/java"/>
<classpathentry kind="src" path="org.eclim.wst/test/junit"/>
<classpathentry kind="src" path="org.eclim.wst/test/junit"/>
<classpathentry kind="src" path="org.eclim.kotlin/java"/>
<classpathentry exported="true" kind="src" path="/formic"/>
</classpath>
1 change: 1 addition & 0 deletions ant/build.gant
Original file line number Diff line number Diff line change
Expand Up @@ -991,6 +991,7 @@ def compile(srcdir, destdir, failonerror=true, errorproperty=null, nested){
destdir: destdir,
srcdir: srcdir,
classpathref: 'classpath',
encoding: 'UTF-8',
debug: 'on', optimize: false, deprecation: '${javac.deprecation}',
target: '${javac.target}', source: '${javac.target}',
failonerror: failonerror,
Expand Down
7 changes: 7 additions & 0 deletions org.eclim.installer/build/resources/dependencies.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,11 @@
<site url="http://download.scala-ide.org/sdk/lithium/e46/scala212/stable/site"/>
</dependency>
</feature>

<feature id="kotlin">
<dependency id="org.jetbrains.kotlin.feature" version="0.8.2">
<site url="https://dl.bintray.com/jetbrains/kotlin/eclipse-plugin/0.8.2/"/>
</dependency>
</feature>

</dependencies>
5 changes: 5 additions & 0 deletions org.eclim.installer/build/resources/install.properties
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@
Provides groovy development functionality.<br>\
Requires the <a href="http://groovy.codehaus.org/Eclipse+Plugin">Groovy Eclipse Plugin</a> which will be installed if necessary.

featureList.kotlin=Kotlin Development
featureList.kotlin.html=\
Provides kotlin development functionality.<br>\
Requires the <a href="https://kotlinlang.org/docs/tutorials/getting-started-eclipse.html">Kotlin Eclipse Plugin</a> which will be installed if necessary.

requirements.jdt=Eclipse Java Development Tools (JDT)
requirements.jdt.html=\
Validates that the Eclipse <a href="http://www.eclipse.org/jdt/">java development tools</a> are installed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,7 @@ private static class FeatureNameComparator
NAMES.add("featureList.pydev");
NAMES.add("featureList.sdt210");
NAMES.add("featureList.groovy");
NAMES.add("featureList.kotlin");
}

public int compare(String ob1, String ob2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,22 @@ public class FeatureProvider
public static final String[] FEATURES = {
"jdt", "adt", "wst", "cdt",
"dltk", "dltkruby", "pdt",
"pydev", "sdt", "groovy"
"pydev", "sdt", "groovy",
"kotlin"
};

private static final String[][] FEATURES_DEPENDS = {
null, {"jdt", "wst"}, null, null,
null, {"dltk"}, {"dltk", "wst"},
null, {"jdt"}, {"jdt"}
null, {"jdt"}, {"jdt"},
{"jdt"}
};

private static final String[][] FEATURES_EXCLUSIVE = {
null, null, null, null,
null, null, null,
null, null, null
null, null, null,
null
};

@Override
Expand Down
22 changes: 22 additions & 0 deletions org.eclim.kotlin/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Vendor: eclim.org
Bundle-SymbolicName: org.eclim.kotlin;singleton:=true
Bundle-Version: ${eclim.version}
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-Localization: plugin
Bundle-ActivationPolicy: lazy
Bundle-Activator: org.eclim.plugin.Plugin
Bundle-ClassPath: .,
eclim.kotlin.jar
Require-Bundle: org.eclim,
org.eclim.core,
org.eclim.jdt,
org.eclipse.core.resources,
org.eclipse.core.runtime,
org.eclipse.jface.text,
org.eclipse.jdt,
org.eclipse.jdt.core,
org.jetbrains.kotlin.ui,
org.eclipse.ui,
org.eclipse.ui.ide
7 changes: 7 additions & 0 deletions org.eclim.kotlin/about.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<body>
See <a href="../org.eclim_${eclim.version}">org.eclim_${eclim.version}</a>.
</body>
</html>
29 changes: 29 additions & 0 deletions org.eclim.kotlin/build_kotlin.gant
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
feature_kotlin = 'org.jetbrains.kotlin.feature'

target(name: 'org.eclim.kotlin.classpath') {
pluginClasspath {
include(name: 'dropins/**/plugins/*kotlin*.jar')
include(name: 'plugins/*kotlin*.jar')
}
}

target(name: 'org.eclim.kotlin.plugin.compile') {

mkdir(dir: '${build.classes}/org.eclim.kotlin')
javac(
srcdir: 'org.eclim.kotlin/java',
destdir: '${build.classes}/org.eclim.kotlin',
classpathref: 'classpath',
deprecation: true)
{
include(name: '**/*.java')
classpath{fileset(dir: '${build.classes}/org.eclim.kotlin', includes: 'org.eclim/**')}
classpath {
pathelement(path: '${build.classes}/org.eclim.kotlin')
fileset(dir: '${build.plugins}', includes: 'org.eclim*/eclim*.jar')
}
}
copy(todir: '${build.classes}/org.eclim.kotlin'){
fileset(dir: "org.eclim.kotlin/java", includes: "eclim/**", excludes: '**/*.java')
}
}
33 changes: 33 additions & 0 deletions org.eclim.kotlin/java/org/eclim/plugin/kotlin/PluginResources.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package org.eclim.plugin.kotlin;

import org.eclim.plugin.AbstractPluginResources;
import org.eclim.plugin.core.project.ProjectManagement;
import org.eclim.plugin.core.project.ProjectNatureFactory;
import org.eclipse.jdt.core.JavaCore;
import org.jetbrains.kotlin.core.model.KotlinNature;
import org.eclim.plugin.kotlin.project.KotlinProjectManager;

public final class PluginResources extends AbstractPluginResources
{
public static final String BUNDLE_BASENAME = "org/eclim/plugin/kotlin/messages";
public static final String NATURE = KotlinNature.KOTLIN_NATURE;

@Override
public void initialize(final String name)
{
super.initialize(name);

ProjectNatureFactory.addNature("kotlin", new String[] {
NATURE,
JavaCore.NATURE_ID
});
ProjectManagement.addProjectManager(NATURE, new KotlinProjectManager());
}

@Override
protected String getBundleBaseName()
{
return BUNDLE_BASENAME;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package org.eclim.plugin.kotlin.command.complete;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.eclim.annotation.Command;
import org.eclim.command.CommandLine;
import org.eclim.plugin.core.command.complete.CodeCompleteResult;
import org.eclim.plugin.core.util.ProjectUtils;
import org.eclipse.core.resources.IFile;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.texteditor.ITextEditor;
import org.jetbrains.kotlin.ui.builder.AspectsUtils;
import org.jetbrains.kotlin.ui.editors.KotlinFileEditor;
import org.jetbrains.kotlin.ui.editors.codeassist.KotlinCompletionProcessor;


@Command(name = "kotlin_complete",
options = "REQUIRED p project ARG,"
+ "REQUIRED f file ARG,"
+ "REQUIRED o offset ARG,"
+ "REQUIRED e encoding ARG,"
+ "REQUIRED l layout ARG,"
+ "OPTIONAL j javaDoc NOARG")
public final class CodeCompleteCommand
extends org.eclim.plugin.jdt.command.complete.CodeCompleteCommand
{

@Override
protected Object getResponse(final List<CodeCompleteResult> results)
{
return results;
}

@Override
protected List<CodeCompleteResult> getCompletionResults(
final CommandLine commandLine, final String project, final String file,
final int offset) throws Exception
{
final IFile ifile = ProjectUtils
.getFile(ProjectUtils.getProject(project, true), file);

if (!AspectsUtils.isKotlinFile(ifile))
return Collections.emptyList();

final IWorkbenchPage page = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getActivePage();
final IEditorPart editorPart = IDE.openEditor(page, ifile, false);
final KotlinFileEditor ktEditor = (KotlinFileEditor) editorPart;
final ISourceViewer viewer = ktEditor.getViewer();

final KotlinCompletionProcessor completer = new KotlinCompletionProcessor(
ktEditor, null, true);
final ICompletionProposal[] proposals = completer
.computeCompletionProposals(viewer, offset);

((ITextEditor) ktEditor).close(false);

if (proposals == null)
return Collections.emptyList();

final List<CodeCompleteResult> results = new ArrayList<CodeCompleteResult>(
proposals.length);

for(ICompletionProposal proposal : proposals){
final String moreInfo = proposal.getAdditionalProposalInfo();
final String shortDesc = proposal.getDisplayString();
final String desc = proposal.getDisplayString();
final String completion = proposal.getDisplayString();
final String completionText = (moreInfo != null) ? moreInfo : completion;

results.add(new CodeCompleteResult(completionText, shortDesc, desc));
}

return results;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package org.eclim.plugin.kotlin.command.src;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang.StringUtils;
import org.eclim.annotation.Command;
import org.eclim.command.CommandLine;
import org.eclim.command.Error;
import org.eclim.command.Options;
import org.eclim.plugin.core.command.AbstractCommand;
import org.eclim.plugin.core.util.ProjectUtils;
import org.eclim.plugin.jdt.util.JavaUtils;
import org.eclim.util.file.FileOffsets;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.compiler.IProblem;

@Command(
name = "kotlin_src_update",
options = "REQUIRED p project ARG,"
+ "REQUIRED f file ARG,"
+ "OPTIONAL v validate NOARG,"
+ "OPTIONAL b build NOARG"
)
public final class SrcUpdateCommand extends AbstractCommand
{

@Override
public Object execute(final CommandLine commandLine) throws Exception
{
final String file = commandLine.getValue(Options.FILE_OPTION);
final String projectName = commandLine.getValue(Options.PROJECT_OPTION);
final IProject project = ProjectUtils.getProject(projectName, true);
final IFile ifile = ProjectUtils.getFile(project, file);

// validate the src file.
if(commandLine.hasOption(Options.VALIDATE_OPTION)){
final ICompilationUnit src = JavaCore.createCompilationUnitFrom(ifile);
final IProblem[] problems = JavaUtils.getProblems(src);
final List<Error> errors = new ArrayList<Error>(problems.length);
final String filename = src.getResource().getLocation().toOSString()
.replace('\\', '/');
final FileOffsets offsets = FileOffsets.compile(filename);

for(IProblem problem : problems){
if(problem.getID() == IProblem.Task){
continue;
}

final int[] lineColumn = offsets
.offsetToLineColumn(problem.getSourceStart());
errors.add(new Error(problem.getMessage(), filename, lineColumn[0],
lineColumn[1], problem.isWarning()));
}

if(commandLine.hasOption(Options.BUILD_OPTION)){
project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD,
new NullProgressMonitor());
}

return errors;
}

return StringUtils.EMPTY;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.eclim.plugin.kotlin.project;

import org.eclim.command.CommandLine;
import org.eclim.plugin.jdt.project.JavaProjectManager;
import org.eclipse.core.resources.IProject;
import org.jetbrains.kotlin.core.model.KotlinNature;

public final class KotlinProjectManager extends JavaProjectManager
{

@Override
protected void create(final IProject project, final String depends)
throws Exception
{
super.create(project, depends);
KotlinNature.addNature(project);
}

}
1 change: 1 addition & 0 deletions org.eclim.kotlin/plugin.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
eclim.plugin.resources=org.eclim.plugin.kotlin.PluginResources
34 changes: 34 additions & 0 deletions org.eclim.kotlin/vim/eclim/autoload/eclim/kotlin/complete.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
" Author: Eric Van Dewoestine
"
" License: {{{
"
" Copyright (C) 2014 Eric Van Dewoestine
"
" This program is free software: you can redistribute it and/or modify
" it under the terms of the GNU General Public License as published by
" the Free Software Foundation, either version 3 of the License, or
" (at your option) any later version.
"
" This program is distributed in the hope that it will be useful,
" but WITHOUT ANY WARRANTY; without even the implied warranty of
" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
" GNU General Public License for more details.
"
" You should have received a copy of the GNU General Public License
" along with this program. If not, see <http://www.gnu.org/licenses/>.
"
" }}}

" Script Varables {{{
let s:complete_command =
\ '-command kotlin_complete -p "<project>" -f "<file>" ' .
\ '-o <offset> -e <encoding> -l <layout>'
" }}}

function! eclim#kotlin#complete#CodeComplete(findstart, base) " {{{
return eclim#lang#CodeComplete(
\ s:complete_command, a:findstart, a:base,
\ {'temp': 0, 'layout': g:EclimKotlinCompleteLayout})
endfunction " }}}

" vim:ft=vim:fdm=marker
Loading