Skip to content

Commit f298d04

Browse files
committed
Scala FIT performer: Prevent scalafmt from overriding //?
scalafmt is changing "//?" to "// ?" which then breaks the FIT tagger. The only solution appears to be this: disabling scalafmt around those sections. Change-Id: If392e3e4c54c2bb8ea1422e56f887220499d0eae Reviewed-on: https://review.couchbase.org/c/couchbase-jvm-clients/+/232107 Tested-by: Build Bot <[email protected]> Reviewed-by: David Nault <[email protected]>
1 parent 11483fe commit f298d04

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed

scala-fit-performer/src/main/scala/com/couchbase/client/performer/scala/ScalaPerformer.scala

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ import com.couchbase.client.scala.transactions.internal.TransactionsSupportedExt
3838
import com.couchbase.client.scala.transactions.internal.TransactionsSupportedExtensionsUtil.Supported
3939
// [end]
4040
// [if:<1.7.2]
41+
// format: off
4142
//? import com.couchbase.client.core.transaction.forwards.{Extension, Supported}
43+
// format: on
4244
// [end]
4345
// [end]
4446

@@ -144,6 +146,7 @@ class ScalaPerformer extends CorePerformer {
144146

145147
// [if:1.5.0]
146148
// [if:<1.7.2]
149+
// format: off
147150
//? response.addPerformerCaps(Caps.TRANSACTIONS_SUPPORT_1)
148151
//? val supported = new Supported
149152
//? val protocolVersion = supported.protocolMajor + "." + supported.protocolMinor
@@ -176,6 +179,7 @@ class ScalaPerformer extends CorePerformer {
176179
//? else logger.warn("Could not find FIT extension for " + ext.name)
177180
//? }
178181
//? })
182+
// format: on
179183
// [end]
180184
// [end]
181185
}
@@ -269,7 +273,9 @@ class ScalaPerformer extends CorePerformer {
269273
new ScalaTransactionCommandExecutor(connection, counters, Map.empty)
270274
// [end:1.5.0]
271275
// [if:<1.5.0]
276+
// format: off
272277
//? null
278+
// format: on
273279
// [end]
274280
}
275281

@@ -300,7 +306,7 @@ class ScalaPerformer extends CorePerformer {
300306
val connection: ClusterConnection = getClusterConnection(request.getClusterConnectionId)
301307
logger.info("Starting transaction on cluster connection {}", request.getClusterConnectionId)
302308
val counters = new Counters()
303-
val e = new ScalaTransactionCommandExecutor(connection, counters, Map.empty)
309+
val e = new ScalaTransactionCommandExecutor(connection, counters, Map.empty)
304310
val response = TransactionBlocking.run(connection, request, Some(e), false, Map.empty)
305311
responseObserver.onNext(response)
306312
responseObserver.onCompleted()
@@ -339,7 +345,9 @@ class ScalaPerformer extends CorePerformer {
339345
)
340346
// [end]
341347
// [if:<1.7.2]
342-
//?val cleaner = new TransactionsCleaner(connection.cluster.async.core, cleanupHooks)
348+
// format: off
349+
//? val cleaner = new TransactionsCleaner(connection.cluster.async.core, cleanupHooks)
350+
// format: on
343351
// [end]
344352
val l = new CoreTransactionLogger(null, "")
345353
val merged = new CoreMergedTransactionConfig(config.toCore)

scala-fit-performer/src/main/scala/com/couchbase/client/performer/scala/search/SearchHelper.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,9 @@ object SearchHelper {
220220
// [if:1.4.5]
221221
opts = opts.timeout(Duration(o.getTimeoutMillis, TimeUnit.MILLISECONDS))
222222
// [else]
223+
// format: off
223224
//? throw new UnsupportedOperationException()
225+
// format: on
224226
// [end]
225227
}
226228
if (o.hasParentSpanId) throw new UnsupportedOperationException()
@@ -538,8 +540,10 @@ object SearchHelper {
538540
com.couchbase.client.scala.search.vector.VectorQuery(vq.getVectorFieldName, query)
539541
}
540542
// [else]
543+
// format: off
541544
//? val query: Array[Float] = vq.getVectorQueryList.asScala.toArray.map(v => v.asInstanceOf[Float])
542545
//? var out = com.couchbase.client.scala.search.vector.VectorQuery(vq.getVectorFieldName, query)
546+
// format: on
543547
// [end]
544548
if (vq.hasOptions) {
545549
val opts = vq.getOptions
@@ -757,7 +761,9 @@ object SearchHelper {
757761
result.setElapsedNanos(System.nanoTime - start)
758762
setSuccess(result)
759763
// [else]
764+
// format: off
760765
//? throw new UnsupportedOperationException()
766+
// format: on
761767
// [end]
762768
} else if (command.hasDropIndex) {
763769
val req = command.getDropIndex

scala-fit-performer/src/main/scala/com/couchbase/client/performer/scala/transaction/TransactionBlocking.scala

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,9 @@ class TransactionBlocking(executor: Option[TransactionCommandExecutor])
110110
ptcb.orNull
111111
// [end]
112112
// [if:<3.9.0]
113+
// format: off
113114
//? Option(ptcb.orNull)
115+
// format: on
114116
// [end]
115117
)
116118
if (TransactionMarkerOwner.get.block.isPresent)
@@ -187,12 +189,14 @@ class TransactionBlocking(executor: Option[TransactionCommandExecutor])
187189
}
188190
// [end]
189191
// [if:<1.9.0]
192+
// format: off
190193
//? content match {
191194
//? case ContentString(value) => ctx.insert(collection, request.getDocId.getDocId, value).get
192195
//? case ContentJson(value) => ctx.insert(collection, request.getDocId.getDocId, value).get
193196
//? case ContentByteArray(value) => ctx.insert(collection, request.getDocId.getDocId, value).get
194197
//? case ContentNull(value) => ctx.insert(collection, request.getDocId.getDocId, value).get
195198
//? }
199+
// format: on
196200
// [end]
197201
}
198202
)
@@ -319,6 +323,7 @@ class TransactionBlocking(executor: Option[TransactionCommandExecutor])
319323
}
320324
// [end]
321325
// [if:<1.9.0]
326+
// format: off
322327
//? if (request.getUseStashedResult) {
323328
//? content match {
324329
//? case ContentString(value) => ctx.replace(stashedGet.get, value).get
@@ -353,6 +358,7 @@ class TransactionBlocking(executor: Option[TransactionCommandExecutor])
353358
//? case ContentNull(value) => ctx.replace(r, value).get
354359
//? }
355360
//? }
361+
// format: on
356362
// [end]
357363

358364
}
@@ -474,7 +480,9 @@ class TransactionBlocking(executor: Option[TransactionCommandExecutor])
474480
}
475481
// [end]
476482
// [if:<1.9.0]
483+
// format: off
477484
//? val out = ctx.get(collection, request.getDocId.getDocId).get
485+
// format: on
478486
// [end]
479487
val contentAsValidation =
480488
if (request.hasContentAsValidation) Some(request.getContentAsValidation) else None
@@ -501,7 +509,9 @@ class TransactionBlocking(executor: Option[TransactionCommandExecutor])
501509
}
502510
// [end]
503511
// [if:<1.9.0]
512+
// format: off
504513
//? ctx.get(collection, executor.get.getDocId(request.getLocation)).get
514+
// format: on
505515
// [end]
506516
}
507517
)
@@ -531,7 +541,9 @@ class TransactionBlocking(executor: Option[TransactionCommandExecutor])
531541
}
532542
// [end]
533543
// [if:<1.9.0]
544+
// format: off
534545
//? val out = ctx.get(collection, request.getDocId.getDocId)
546+
// format: on
535547
// [end]
536548
val contentAsValidation =
537549
if (request.hasContentAsValidation) Some(request.getContentAsValidation) else None
@@ -562,7 +574,9 @@ class TransactionBlocking(executor: Option[TransactionCommandExecutor])
562574
}
563575
// [end]
564576
// [if:<1.9.0]
577+
// format: off
565578
//? val result = ctx.getReplicaFromPreferredServerGroup(collection, request.getDocId.getDocId).get
579+
// format: on
566580
// [end]
567581
handleGetReplicaFromPreferredServerGroupResult(request, result, connection)
568582
}
@@ -691,7 +705,7 @@ class TransactionBlocking(executor: Option[TransactionCommandExecutor])
691705
ResultValidation.validateQueryResult(request, qr.get)
692706
}
693707
)
694-
// [if:3.9.0]
708+
// [if:3.9.0]
695709
} else if (op.hasGetMulti) {
696710
val request = op.getGetMulti
697711
if (!request.getGetMultiReplicasFromPreferredServerGroup) {

0 commit comments

Comments
 (0)