Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enables plugin to analyze kotlin projects #378

Open
wants to merge 15 commits into
base: develop
Choose a base branch
from
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
579 changes: 277 additions & 302 deletions plugins/de.cognicrypt.core/src/de/cognicrypt/utils/Utils.java

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions plugins/de.cognicrypt.staticanalyzer.kotlin/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src/"/>
<classpathentry exported="true" kind="lib" path="lib" sourcepath="lib"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
34 changes: 34 additions & 0 deletions plugins/de.cognicrypt.staticanalyzer.kotlin/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>de.cognicrypt.staticanalyzer.kotlin</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
17 changes: 17 additions & 0 deletions plugins/de.cognicrypt.staticanalyzer.kotlin/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: CogniCrypt Static Analyzer for Kotlin
Bundle-SymbolicName: de.cognicrypt.staticanalyzer.kotlin;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: de.cognicrypt.staticanalyzer.kotlin.Activator
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Automatic-Module-Name: de.cognicrypt.staticanalyzer.kotlin
Bundle-ClassPath: .,
lib/
Require-Bundle: org.eclipse.jdt.core,
org.eclipse.m2e.maven.runtime,
org.eclipse.core.runtime,
org.eclipse.core.resources,
org.eclipse.ui,
org.jetbrains.kotlin.core;bundle-version="0.8.19";resolution:=optional,
de.cognicrypt.staticanalyzer;bundle-version="1.0.0"
7 changes: 7 additions & 0 deletions plugins/de.cognicrypt.staticanalyzer.kotlin/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
src/,\
lib/
source.. = src/
Binary file not shown.
10 changes: 10 additions & 0 deletions plugins/de.cognicrypt.staticanalyzer.kotlin/plugin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="de.cognicrypt.staticanalyzer.listeners">
<listener
class="de.cognicrypt.staticanalyzer.kotlin.KotlinListener"/>
</extension>

</plugin>
152 changes: 152 additions & 0 deletions plugins/de.cognicrypt.staticanalyzer.kotlin/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
<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>
<groupId>de.cognicrypt</groupId>
<artifactId>de.cognicrypt.staticanalyzer.kotlin</artifactId>
<packaging>eclipse-plugin</packaging>
<parent>
<groupId>de.cognicrypt</groupId>
<artifactId>de.cognicrypt.parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<version>${tycho-version}</version>
<extensions>true</extensions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<configuration>
<reportsDirectory>../../shippable/testresults</reportsDirectory>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit4</artifactId>
<version>2.17</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
</dependencies>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>compiletests</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>

<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.eclipse.tycho</groupId>
<artifactId>
tycho-packaging-plugin
</artifactId>
<versionRange>
[0.26.0,)
</versionRange>
<goals>
<goal>build-qualifier</goal>
<goal>validate-id</goal>
<goal>validate-version</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.eclipse.tycho</groupId>
<artifactId>
tycho-compiler-plugin
</artifactId>
<versionRange>
[0.26.0,)
</versionRange>
<goals>
<goal>compile</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<versionRange>
[0.26.0,)
</versionRange>
<goals>
<goal>test-compile</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<versionRange>
[0.26.0,)
</versionRange>
<goals>
<goal>test</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package de.cognicrypt.staticanalyzer.kotlin;

import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;

/**
* The activator class controls the plug-in life cycle
*/
public class Activator extends AbstractUIPlugin {

// The plug-in ID
public static final String PLUGIN_ID = "de.cognicrypt.staticanalyzer.kotlin"; //$NON-NLS-1$

// The shared instance
private static Activator plugin;

/**
* The constructor
*/
public Activator() {
}

@Override
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
}

@Override
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}

/**
* Returns the shared instance
*
* @return the shared instance
*/
public static Activator getDefault() {
return plugin;
}

private void log(final int severity, final String message, final Exception ex) {
getLog().log(new Status(severity, Activator.PLUGIN_ID, message, ex));
}

public void logError(final Exception ex) {
logError(ex, ex.getMessage());
}

public void logError(final Exception ex, final String message) {
log(IStatus.ERROR, message, ex);
}

public void logError(final String message) {
log(IStatus.ERROR, message, null);
}

public void logInfo(final String message) {
log(IStatus.INFO, message, null);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package de.cognicrypt.staticanalyzer.kotlin;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.jdt.core.JavaModelException;

import de.cognicrypt.staticanalyzer.IListener;
import de.cognicrypt.staticanalyzer.kotlin.utilities.KotlinUtils;

public class KotlinListener implements IListener {

@Override
public void listen1(IProject ip) {
KotlinUtils.compileKotlinFiles(ip);
}

@Override
public IResource listen2(String name, IProject ip) throws JavaModelException, ClassNotFoundException {
return KotlinUtils.findKotlinClassByName(name, ip);
}
}
Loading