Skip to content

Commit 1159dd5

Browse files
committed
Code is formatted
1 parent c7999b1 commit 1159dd5

138 files changed

Lines changed: 1530 additions & 2023 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

samples/wire-grpc-sample/client/src/main/java/com/squareup/wire/whiteboard/MainActivity.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ import kotlinx.coroutines.channels.SendChannel
3333
import kotlinx.coroutines.launch
3434
import kotlinx.coroutines.withContext
3535

36-
class MainActivity : ComponentActivity(), OnBoardEventListener {
36+
class MainActivity :
37+
ComponentActivity(),
38+
OnBoardEventListener {
3739
private lateinit var sendCommandChannel: SendChannel<WhiteboardCommand>
3840
private lateinit var receiveUpdateChannel: ReceiveChannel<WhiteboardUpdate>
3941
private lateinit var whiteboardView: WhiteboardView

samples/wire-grpc-sample/server/src/main/java/com/squareup/wire/whiteboard/WhiteboardGrpcAction.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ import javax.inject.Singleton
2323
import misk.web.actions.WebAction
2424

2525
@Singleton
26-
class WhiteboardGrpcAction : WebAction, WhiteboardWhiteboardBlockingServer {
26+
class WhiteboardGrpcAction :
27+
WebAction,
28+
WhiteboardWhiteboardBlockingServer {
2729
val clients = mutableListOf<Client>()
2830
val points = mutableListOf<Point>()
2931

wire-compiler/src/main/java/com/squareup/wire/WireCompiler.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -329,9 +329,7 @@ class WireCompiler internal constructor(
329329
fileSystem: NioFileSystem,
330330
logger: WireLogger,
331331
vararg args: String,
332-
): WireCompiler {
333-
return forArgs(fileSystem.asOkioFileSystem(), logger, *args)
334-
}
332+
): WireCompiler = forArgs(fileSystem.asOkioFileSystem(), logger, *args)
335333

336334
@Throws(WireException::class)
337335
@JvmOverloads

wire-compiler/src/main/java/com/squareup/wire/schema/Target.kt

Lines changed: 95 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -54,30 +54,26 @@ data class JavaTarget(
5454
/** If true, the constructor of all generated types will be non-public. */
5555
val buildersOnly: Boolean = false,
5656
) : Target() {
57-
override fun newHandler(): SchemaHandler {
58-
return JavaSchemaHandler(
59-
android = android,
60-
androidAnnotations = androidAnnotations,
61-
compact = compact,
62-
emitDeclaredOptions = emitDeclaredOptions,
63-
emitAppliedOptions = emitAppliedOptions,
64-
buildersOnly = buildersOnly,
65-
)
66-
}
57+
override fun newHandler(): SchemaHandler = JavaSchemaHandler(
58+
android = android,
59+
androidAnnotations = androidAnnotations,
60+
compact = compact,
61+
emitDeclaredOptions = emitDeclaredOptions,
62+
emitAppliedOptions = emitAppliedOptions,
63+
buildersOnly = buildersOnly,
64+
)
6765

6866
override fun copyTarget(
6967
includes: List<String>,
7068
excludes: List<String>,
7169
exclusive: Boolean,
7270
outDirectory: String,
73-
): Target {
74-
return copy(
75-
includes = includes,
76-
excludes = excludes,
77-
exclusive = exclusive,
78-
outDirectory = outDirectory,
79-
)
80-
}
71+
): Target = copy(
72+
includes = includes,
73+
excludes = excludes,
74+
exclusive = exclusive,
75+
outDirectory = outDirectory,
76+
)
8177
}
8278

8379
/** Generate `.kt` sources. */
@@ -164,41 +160,37 @@ data class KotlinTarget(
164160
*/
165161
private val makeImmutableCopies: Boolean = true,
166162
) : Target() {
167-
override fun newHandler(): SchemaHandler {
168-
return KotlinSchemaHandler(
169-
outDirectory = outDirectory,
170-
android = android,
171-
javaInterop = javaInterop,
172-
emitDeclaredOptions = emitDeclaredOptions,
173-
emitAppliedOptions = emitAppliedOptions,
174-
rpcCallStyle = rpcCallStyle,
175-
rpcRole = rpcRole,
176-
singleMethodServices = singleMethodServices,
177-
boxOneOfsMinSize = boxOneOfsMinSize,
178-
nameSuffix = nameSuffix,
179-
buildersOnly = buildersOnly,
180-
escapeKotlinKeywords = escapeKotlinKeywords,
181-
enumMode = enumMode,
182-
emitProtoReader32 = emitProtoReader32,
183-
mutableTypes = mutableTypes,
184-
explicitStreamingCalls = explicitStreamingCalls,
185-
makeImmutableCopies = makeImmutableCopies,
186-
)
187-
}
163+
override fun newHandler(): SchemaHandler = KotlinSchemaHandler(
164+
outDirectory = outDirectory,
165+
android = android,
166+
javaInterop = javaInterop,
167+
emitDeclaredOptions = emitDeclaredOptions,
168+
emitAppliedOptions = emitAppliedOptions,
169+
rpcCallStyle = rpcCallStyle,
170+
rpcRole = rpcRole,
171+
singleMethodServices = singleMethodServices,
172+
boxOneOfsMinSize = boxOneOfsMinSize,
173+
nameSuffix = nameSuffix,
174+
buildersOnly = buildersOnly,
175+
escapeKotlinKeywords = escapeKotlinKeywords,
176+
enumMode = enumMode,
177+
emitProtoReader32 = emitProtoReader32,
178+
mutableTypes = mutableTypes,
179+
explicitStreamingCalls = explicitStreamingCalls,
180+
makeImmutableCopies = makeImmutableCopies,
181+
)
188182

189183
override fun copyTarget(
190184
includes: List<String>,
191185
excludes: List<String>,
192186
exclusive: Boolean,
193187
outDirectory: String,
194-
): Target {
195-
return copy(
196-
includes = includes,
197-
excludes = excludes,
198-
exclusive = exclusive,
199-
outDirectory = outDirectory,
200-
)
201-
}
188+
): Target = copy(
189+
includes = includes,
190+
excludes = excludes,
191+
exclusive = exclusive,
192+
outDirectory = outDirectory,
193+
)
202194
}
203195

204196
data class SwiftTarget(
@@ -207,23 +199,19 @@ data class SwiftTarget(
207199
override val exclusive: Boolean = true,
208200
override val outDirectory: String,
209201
) : Target() {
210-
override fun newHandler(): SchemaHandler {
211-
return SwiftSchemaHandler()
212-
}
202+
override fun newHandler(): SchemaHandler = SwiftSchemaHandler()
213203

214204
override fun copyTarget(
215205
includes: List<String>,
216206
excludes: List<String>,
217207
exclusive: Boolean,
218208
outDirectory: String,
219-
): Target {
220-
return copy(
221-
includes = includes,
222-
excludes = excludes,
223-
exclusive = exclusive,
224-
outDirectory = outDirectory,
225-
)
226-
}
209+
): Target = copy(
210+
includes = includes,
211+
excludes = excludes,
212+
exclusive = exclusive,
213+
outDirectory = outDirectory,
214+
)
227215
}
228216

229217
data class ProtoTarget(
@@ -233,58 +221,54 @@ data class ProtoTarget(
233221
override val excludes: List<String> = listOf()
234222
override val exclusive: Boolean = false
235223

236-
override fun newHandler(): SchemaHandler {
237-
return object : SchemaHandler() {
238-
override fun handle(schema: Schema, context: Context) {
239-
context.fileSystem.createDirectories(context.outDirectory)
240-
val outDirectory = context.outDirectory
241-
242-
for (protoFile in schema.protoFiles) {
243-
if (!context.inSourcePath(protoFile) ||
244-
protoFile.isEmpty() ||
245-
// We never emit the `.proto` files we are embedding within Wire.
246-
isWireRuntimeProto(protoFile.location.path)
247-
) {
248-
continue
249-
}
224+
override fun newHandler(): SchemaHandler = object : SchemaHandler() {
225+
override fun handle(schema: Schema, context: Context) {
226+
context.fileSystem.createDirectories(context.outDirectory)
227+
val outDirectory = context.outDirectory
228+
229+
for (protoFile in schema.protoFiles) {
230+
if (!context.inSourcePath(protoFile) ||
231+
protoFile.isEmpty() ||
232+
// We never emit the `.proto` files we are embedding within Wire.
233+
isWireRuntimeProto(protoFile.location.path)
234+
) {
235+
continue
236+
}
237+
238+
val relativePath = protoFile.location.path
239+
.substringBeforeLast("/", missingDelimiterValue = ".")
240+
val outputDirectory = outDirectory / relativePath
241+
val outputFilePath = outputDirectory / "${protoFile.name()}.proto"
242+
context.logger.artifactHandled(outputDirectory, protoFile.location.path, "Proto")
250243

251-
val relativePath = protoFile.location.path
252-
.substringBeforeLast("/", missingDelimiterValue = ".")
253-
val outputDirectory = outDirectory / relativePath
254-
val outputFilePath = outputDirectory / "${protoFile.name()}.proto"
255-
context.logger.artifactHandled(outputDirectory, protoFile.location.path, "Proto")
256-
257-
try {
258-
context.fileSystem.createDirectories(outputFilePath.parent!!)
259-
context.fileSystem.write(outputFilePath) {
260-
writeUtf8(protoFile.toSchema())
261-
}
262-
} catch (e: IOException) {
263-
throw IOException("Error emitting $outputFilePath to $outDirectory", e)
244+
try {
245+
context.fileSystem.createDirectories(outputFilePath.parent!!)
246+
context.fileSystem.write(outputFilePath) {
247+
writeUtf8(protoFile.toSchema())
264248
}
249+
} catch (e: IOException) {
250+
throw IOException("Error emitting $outputFilePath to $outDirectory", e)
265251
}
266252
}
253+
}
267254

268-
private fun ProtoFile.isEmpty() = types.isEmpty() && services.isEmpty() && extendList.isEmpty()
255+
private fun ProtoFile.isEmpty() = types.isEmpty() && services.isEmpty() && extendList.isEmpty()
269256

270-
override fun handle(type: Type, context: Context): Path? = null
257+
override fun handle(type: Type, context: Context): Path? = null
271258

272-
override fun handle(service: Service, context: Context): List<Path> = listOf()
259+
override fun handle(service: Service, context: Context): List<Path> = listOf()
273260

274-
override fun handle(extend: Extend, field: Field, context: Context): Path? = null
275-
}
261+
override fun handle(extend: Extend, field: Field, context: Context): Path? = null
276262
}
277263

278264
override fun copyTarget(
279265
includes: List<String>,
280266
excludes: List<String>,
281267
exclusive: Boolean,
282268
outDirectory: String,
283-
): Target {
284-
return copy(
285-
outDirectory = outDirectory,
286-
)
287-
}
269+
): Target = copy(
270+
outDirectory = outDirectory,
271+
)
288272
}
289273

290274
data class CustomTarget(
@@ -300,24 +284,20 @@ data class CustomTarget(
300284
excludes: List<String>,
301285
exclusive: Boolean,
302286
outDirectory: String,
303-
): Target {
304-
return this.copy(
305-
includes = includes,
306-
excludes = excludes,
307-
exclusive = exclusive,
308-
outDirectory = outDirectory,
309-
)
310-
}
311-
312-
override fun newHandler(): SchemaHandler {
313-
return schemaHandlerFactory.create(
314-
includes = includes,
315-
excludes = excludes,
316-
exclusive = exclusive,
317-
outDirectory = outDirectory,
318-
options = options,
319-
)
320-
}
287+
): Target = this.copy(
288+
includes = includes,
289+
excludes = excludes,
290+
exclusive = exclusive,
291+
outDirectory = outDirectory,
292+
)
293+
294+
override fun newHandler(): SchemaHandler = schemaHandlerFactory.create(
295+
includes = includes,
296+
excludes = excludes,
297+
exclusive = exclusive,
298+
outDirectory = outDirectory,
299+
options = options,
300+
)
321301
}
322302

323303
/**
@@ -326,9 +306,7 @@ data class CustomTarget(
326306
* @param schemaHandlerFactoryClass a fully qualified class name for a class that implements
327307
* [SchemaHandler.Factory]. The class must have a no-arguments public constructor.
328308
*/
329-
fun newSchemaHandler(schemaHandlerFactoryClass: String): SchemaHandler.Factory {
330-
return ClassNameSchemaHandlerFactory(schemaHandlerFactoryClass)
331-
}
309+
fun newSchemaHandler(schemaHandlerFactoryClass: String): SchemaHandler.Factory = ClassNameSchemaHandlerFactory(schemaHandlerFactoryClass)
332310

333311
/**
334312
* This schema handler factory is serializable (so Gradle can cache targets that use it). It works
@@ -368,7 +346,5 @@ private class ClassNameSchemaHandlerFactory(
368346
exclusive: Boolean,
369347
outDirectory: String,
370348
options: Map<String, String>,
371-
): SchemaHandler {
372-
return delegate.create(includes, excludes, exclusive, outDirectory, options)
373-
}
349+
): SchemaHandler = delegate.create(includes, excludes, exclusive, outDirectory, options)
374350
}

wire-compiler/src/test/java/com/squareup/wire/WireCompilerErrorTest.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,7 @@ class WireCompilerErrorTest {
212212
assertThat(readFile("/target/Simple.java")).doesNotContain("package")
213213
}
214214

215-
private fun readFile(path: String): String {
216-
return fileSystem.read(path.toPath()) {
217-
readUtf8()
218-
}
215+
private fun readFile(path: String): String = fileSystem.read(path.toPath()) {
216+
readUtf8()
219217
}
220218
}

wire-compiler/src/test/java/com/squareup/wire/schema/LinkerTest.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -557,8 +557,7 @@ class LinkerTest {
557557
val schemaLoaderFileSystem = when {
558558
reverseSort -> {
559559
object : ForwardingFileSystem(fs) {
560-
override fun listRecursively(dir: Path, followSymlinks: Boolean): Sequence<Path> =
561-
super.listRecursively(dir, followSymlinks).toList().reversed().asSequence()
560+
override fun listRecursively(dir: Path, followSymlinks: Boolean): Sequence<Path> = super.listRecursively(dir, followSymlinks).toList().reversed().asSequence()
562561
}
563562
}
564563
else -> fs

0 commit comments

Comments
 (0)