From 44c275c66c3ab7c188cd31a86ab3e7dedee03038 Mon Sep 17 00:00:00 2001 From: Anton Sviridov Date: Mon, 20 May 2024 14:26:40 +0100 Subject: [PATCH] Fix snapshot tests --- .../sourcegraph/scip_java/ScipPrinters.scala | 14 ++++---- .../scala/tests/SnapshotCommandSuite.scala | 33 +++++++++++++++---- 2 files changed, 35 insertions(+), 12 deletions(-) diff --git a/scip-java/src/main/scala/com/sourcegraph/scip_java/ScipPrinters.scala b/scip-java/src/main/scala/com/sourcegraph/scip_java/ScipPrinters.scala index 53fafcb18..af78536ab 100644 --- a/scip-java/src/main/scala/com/sourcegraph/scip_java/ScipPrinters.scala +++ b/scip-java/src/main/scala/com/sourcegraph/scip_java/ScipPrinters.scala @@ -183,7 +183,13 @@ object ScipPrinters { .append("signature_documentation ") .append(info.getSignatureDocumentation.getLanguage) .append(" ") - .append(info.getSignatureDocumentation.getText.replace("\n", "\\n").replace("\t", "\\t")) + .append( + info + .getSignatureDocumentation + .getText + .replace("\n", "\\n") + .replace("\t", "\\t") + ) .append("\n") } if (!info.getEnclosingSymbol.isEmpty) { @@ -194,11 +200,7 @@ object ScipPrinters { .append("\n") } if (info.getKind != Scip.SymbolInformation.Kind.UnspecifiedKind) { - out - .append(prefix) - .append("kind ") - .append(info.getKind) - .append("\n") + out.append(prefix).append("kind ").append(info.getKind).append("\n") } 0.until(info.getDocumentationCount) .foreach { n => diff --git a/tests/unit/src/test/scala/tests/SnapshotCommandSuite.scala b/tests/unit/src/test/scala/tests/SnapshotCommandSuite.scala index 7fc0eeb91..061841ed5 100644 --- a/tests/unit/src/test/scala/tests/SnapshotCommandSuite.scala +++ b/tests/unit/src/test/scala/tests/SnapshotCommandSuite.scala @@ -13,8 +13,13 @@ class SnapshotCommandSuite extends MopedSuite(ScipJava.app) { FileLayout.fromString( """/main/Sample.java |package main; - | + | /** + | * Sample class + | */ |public class Sample { + | /** + | * Main application entry point + | */ | public static void main(String[] asdf) {} |} |""".stripMargin, @@ -37,6 +42,7 @@ class SnapshotCommandSuite extends MopedSuite(ScipJava.app) { targetroot.toString ) ) + assertEquals(indexExit, 0, clues(app.capturedOutput)) val snapshotExit = app().run( @@ -47,18 +53,33 @@ class SnapshotCommandSuite extends MopedSuite(ScipJava.app) { FileLayout.asString(generatedpath), """|/main/Sample.java |package main; - | + | /** + | * Sample class + | */ |public class Sample { |// ^^^^^^ definition semanticdb maven . . main/Sample# - |// documentation ```java\npublic class Sample\n``` + |// display_name Sample + |// signature_documentation java public class Sample + |// kind Class + |// documentation Sample class\n |// ^^^^^^ definition semanticdb maven . . main/Sample#``(). - |// documentation ```java\npublic Sample()\n``` + |// display_name + |// signature_documentation java public Sample() + |// kind Constructor + | /** + | * Main application entry point + | */ | public static void main(String[] asdf) {} |// ^^^^ definition semanticdb maven . . main/Sample#main(). - |// documentation ```java\npublic static void main(String[] asdf)\n``` + |// display_name main + |// signature_documentation java public static void main(String[] asdf) + |// kind StaticMethod + |// documentation Main application entry point\n |// ^^^^^^ reference semanticdb maven jdk 11 java/lang/String# |// ^^^^ definition local 0 - |// documentation ```java\nString[] asdf\n``` + |// display_name asdf + |// signature_documentation java String[] asdf + |// enclosing_symbol semanticdb maven . . main/Sample#main(). |} |""".stripMargin )