Skip to content
Merged
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
5 changes: 1 addition & 4 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,7 @@ lazy val scip = project
moduleName := "scip-semanticdb",
javaOnlySettings,
libraryDependencies ++=
Seq(
"org.scip-code" % "scip-java-bindings" % V.scipBindings,
"com.google.protobuf" % "protobuf-java-util" % V.protobuf
),
Seq("org.scip-code" % "scip-java-bindings" % V.scipBindings),
(Compile / PB.targets) :=
Seq(PB.gens.java(V.protobuf) -> (Compile / sourceManaged).value),
Compile / PB.protocOptions := Seq("--experimental_allow_proto3_optional")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import com.sourcegraph.io.AbsolutePath
import com.sourcegraph.scip_java.BuildInfo
import com.sourcegraph.scip_java.buildtools.ClasspathEntry
import com.sourcegraph.scip_semanticdb.ConsoleScipSemanticdbReporter
import com.sourcegraph.scip_semanticdb.ScipOutputFormat
import com.sourcegraph.scip_semanticdb.ScipSemanticdb
import com.sourcegraph.scip_semanticdb.ScipSemanticdbOptions
import moped.annotations._
Expand Down Expand Up @@ -72,15 +71,6 @@ final case class IndexSemanticdbCommand(

def run(): Int = {
val reporter = new ConsoleScipSemanticdbReporter(app)
val outputFilename = output.getFileName.toString
val format = ScipOutputFormat.fromFilename(outputFilename)
if (format == ScipOutputFormat.UNKNOWN) {
app.error(
s"unknown output format for filename '$outputFilename'. " +
s"Supported file extensions are `*.scip` and `*.scip.ndjson`"
)
return 1
}
val packages =
absoluteTargetroots
.iterator
Expand All @@ -100,7 +90,6 @@ final case class IndexSemanticdbCommand(
.setName("scip-java")
.setVersion(BuildInfo.version)
.build(),
format,
parallel,
packages.map(_.toPackageInformation).asJava,
emitInverseRelationships,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ public boolean hasErrors() {
options.sourceroot,
reporter,
ToolInfo.newBuilder().setName("scip-java").setVersion("HEAD").build(),
ScipOutputFormat.TYPED_PROTOBUF,
options.parallel,
mavenPackages,
/* emitInverseRelationships */ true,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,16 @@

import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.ConcurrentLinkedDeque;
import java.util.concurrent.atomic.AtomicBoolean;

/** Low-level methods to write raw SCIP bytes into the output stream. */
public class ScipOutputStream {
private final ScipOutputFormat format;
private final OutputStream out;
private final ConcurrentLinkedDeque<byte[]> buffer;
private final AtomicBoolean isFlushing;
private static final byte[] NEWLINE = "\n".getBytes(StandardCharsets.UTF_8);

public ScipOutputStream(ScipOutputFormat format, OutputStream out) {
this.format = format;
public ScipOutputStream(OutputStream out) {
this.out = out;
this.buffer = new ConcurrentLinkedDeque<>();
this.isFlushing = new AtomicBoolean(false);
Expand All @@ -31,9 +27,6 @@ public void flush() throws IOException {
byte[] bytes = buffer.poll();
while (bytes != null) {
out.write(bytes);
if (format.isNewlineDelimitedJSON()) {
out.write(NEWLINE);
}
bytes = buffer.poll();
}
out.flush();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ public class ScipSemanticdbOptions {
public final Path sourceroot;
public final ScipSemanticdbReporter reporter;
public final ToolInfo toolInfo;
public final ScipOutputFormat format;
public final boolean parallel;
public final List<MavenPackage> packages;
public final boolean emitInverseRelationships;
Expand All @@ -25,7 +24,6 @@ public ScipSemanticdbOptions(
Path sourceroot,
ScipSemanticdbReporter reporter,
ToolInfo toolInfo,
ScipOutputFormat format,
boolean parallel,
List<MavenPackage> packages,
boolean emitInverseRelationships,
Expand All @@ -36,7 +34,6 @@ public ScipSemanticdbOptions(
this.sourceroot = sourceroot;
this.reporter = reporter;
this.toolInfo = toolInfo;
this.format = format;
this.parallel = parallel;
this.packages = packages;
this.emitInverseRelationships = emitInverseRelationships;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package com.sourcegraph.scip_semanticdb;

import com.google.protobuf.util.JsonFormat;
import org.scip_code.scip.Index;

import java.io.BufferedOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
Expand All @@ -17,7 +15,6 @@ public class ScipWriter implements AutoCloseable {
private final Path tmp;
private final ScipOutputStream output;
private final ScipSemanticdbOptions options;
private final JsonFormat.Printer jsonPrinter;

public ScipWriter(ScipSemanticdbOptions options) throws IOException {
if (OperatingSystem.isWindows()) {
Expand All @@ -29,22 +26,12 @@ public ScipWriter(ScipSemanticdbOptions options) throws IOException {
"index.scip",
PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rw-r--r--")));
}
this.output =
new ScipOutputStream(options.format, new BufferedOutputStream(Files.newOutputStream(tmp)));
this.output = new ScipOutputStream(new BufferedOutputStream(Files.newOutputStream(tmp)));
this.options = options;
this.jsonPrinter = JsonFormat.printer().omittingInsignificantWhitespace();
}

public void emitTyped(Index index) {
try {
if (options.format.isNewlineDelimitedJSON()) {
this.output.write(jsonPrinter.print(index).getBytes(StandardCharsets.UTF_8));
} else {
this.output.write(index.toByteArray());
}
} catch (IOException e) {
options.reporter.error(e);
}
this.output.write(index.toByteArray());
}

public void build() throws IOException {
Expand Down
Loading