Skip to content

Commit

Permalink
Move to comsunsource #1: some definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
Strum355 committed Oct 1, 2020
1 parent 7bb4474 commit 4d9a99e
Show file tree
Hide file tree
Showing 19 changed files with 1,835 additions and 699 deletions.
6 changes: 6 additions & 0 deletions .gitattributes
@@ -0,0 +1,6 @@
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# These are explicitly windows files and should use crlf
*.bat text eol=crlf

1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -8,3 +8,4 @@ target
.gradle
examples/**/dump.lsif
build
bin/*
59 changes: 34 additions & 25 deletions build.gradle
@@ -1,46 +1,55 @@
/*
* This file was generated by the Gradle 'init' task.
*/

plugins {
id 'java'
id 'maven-publish'
id 'application'
}

application {
mainClassName = 'lsifjava.Main'
}

repositories {
jcenter()
mavenLocal()
maven {
url = 'https://repo.maven.apache.org/maven2'
}
}

dependencies {
compile 'com.github.javaparser:javaparser-symbol-solver-core:3.16.1'
compile 'fr.inria.gforge.spoon:spoon-core:8.3.0-beta-8'
compile files("${System.getProperty('java.home')}/../lib/tools.jar")
compile 'com.google.code.gson:gson:2.8.6'
compile 'commons-cli:commons-cli:1.4'
compile 'org.apache.commons:commons-lang3:3.11'
compile 'commons-io:commons-io:2.8.0'
compile group: 'org.apache.commons', name: 'commons-collections4', version: '4.4'
compile 'org.slf4j:slf4j-api:1.7.30'
compile 'org.slf4j:slf4j-nop:1.7.30'
implementation 'org.eclipse.lsp4j:org.eclipse.lsp4j:0.9.0'
implementation 'com.google.guava:guava:29.0-jre'
testImplementation 'junit:junit:4.13'
}

group = 'com.sourcegraph'
version = '1.0-SNAPSHOT'
sourceCompatibility = '1.8'
application {
mainClassName = 'lsifjava.Main'
}

publishing {
model {
tasks.generatePomFileForSourcegraphPublication {
destination = file("$projectDir/pom.xml")
}
}
publications {
sourcegraph(MavenPublication) {
from components.java
}
}
compileJava {
options.compilerArgs += ["--enable-preview"]
options.compilerArgs += [
"--add-exports",
"jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
"--add-exports",
"jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
"--add-exports",
"jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED",
"--add-exports",
"jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED",
"--add-exports",
"jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
"--add-exports",
"jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED",
"--add-exports",
"jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
"--add-exports",
"jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
]
}

group = 'com.sourcegraph'
version = '1.0-SNAPSHOT'
13 changes: 1 addition & 12 deletions examples/small/src/main/java/com/sourcegraph/lsifjava/Main.java
Expand Up @@ -2,19 +2,8 @@

import java.io.File;

import io.opentracing.Span;
import io.opentracing.Tracer;
import io.opentracing.mock.MockTracer;

public class Main {
public abstract class Main {
public static void main(String[] args) {
Sample.nom();
try(Tracer tracer = new MockTracer()) {
Span builder = tracer.buildSpan("test").start();
builder.setTag("hello", "sourcegraph");

File f = new File("lawl");
System.out.println(f);
}
}
}
Expand Up @@ -7,6 +7,7 @@
*/
public class Sample extends Object implements Iterator<String>, Iterable<String> {
public static void nom() {
Sample s = new Sample();
System.out.println("om nom nom");
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
178 changes: 89 additions & 89 deletions gradlew.bat
@@ -1,89 +1,89 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem

@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################

@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:execute
@rem Setup the command line

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar


@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1

:mainEnd
if "%OS%"=="Windows_NT" endlocal

:omega
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem

@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################

@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:execute
@rem Setup the command line

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar


@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1

:mainEnd
if "%OS%"=="Windows_NT" endlocal

:omega
12 changes: 6 additions & 6 deletions src/main/java/lsifjava/ArgumentParser.java
Expand Up @@ -10,9 +10,9 @@ public class ArgumentParser {
public static final String PROTOCOL_VERSION = "0.4.0";

public static Arguments parse(String[] args) {
Options options = createOptions();
CommandLineParser parser = new DefaultParser();
HelpFormatter formatter = new HelpFormatter();
var options = createOptions();
var parser = new DefaultParser();
var formatter = new HelpFormatter();

CommandLine cmd;
try {
Expand Down Expand Up @@ -40,14 +40,14 @@ public static Arguments parse(String[] args) {
} catch(IOException e) {
throw new RuntimeException(String.format("Directory %s could not be found", cmd.getOptionValue("projectRoot", ".")));
}
String outFile = cmd.getOptionValue("out", projectRoot + "/dump.lsif");
boolean verbosity = cmd.hasOption("verbose");
var outFile = cmd.getOptionValue("out", projectRoot + "/dump.lsif");
var verbosity = cmd.hasOption("verbose");

return new Arguments(projectRoot, outFile, verbosity);
}

private static Options createOptions() {
Options options = new Options();
var options = new Options();

options.addOption(new Option(
"help", false,
Expand Down

0 comments on commit 4d9a99e

Please sign in to comment.