Skip to content

Commit

Permalink
Style: apply checkstyle
Browse files Browse the repository at this point in the history
  • Loading branch information
dieyidezui committed Jan 8, 2019
1 parent 9bb50d9 commit 26a07d1
Show file tree
Hide file tree
Showing 29 changed files with 250 additions and 47 deletions.
26 changes: 26 additions & 0 deletions .tarvis.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
anguage: java

jdk:
- oraclejdk8
# - openjdk11

notifications:
email: false

sudo: false


script: ./gradlew check

after_success:
- .buildscript/deploy_snapshot.sh

env:
global:
- secure: "S0BTJVrF4fUCwhTdmoQY6LYr5r1wgXZ/p8lc5bIgUUsc1Ckalwt7s/GDwPuLJ4702sI5t56Eye2iEIMUjeFJKqebZRsX1C5oYsYFxGi3BGlepstYpmj0gLXuSWqCLniS9zmHXCxLhLkC6KxPVjhDlbq76XQx0o3K1J8oEIj/PCE="
- secure: "awV7yLXURjlPbTOladsNDZk74KYCNXoiZpAP0gQFfK4Sc0fc7+kg8z/yhdWXeTxjsIZ6m0dVDHTqnH8ytnydwXpBam8JdQJ+EAWA6R3Svq1BR1bzl/PcZUoz+Xn8lMXdU3yA1p4qtQlUhMxwsE3MOVe24HSDJPAu4XeWFj1j3qo="

branches:
except:
- gh-pages

2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ subprojects {
jcenter()
mavenCentral()
}

apply plugin: 'checkstyle'
}

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void beforeCreate(T capt) {
}

/**
* Do your time-consuming tasks in this function
* Do your time-consuming tasks in this function.
*
* @param capt Plugin context
* @throws IOException io
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ final void link(ClassVisitor next) {
if (cv instanceof CaptClassVisitor) {
((CaptClassVisitor) cv).link(next);
} else {
throw new IllegalStateException("Require CaptClassVisitor or subclass, but is " + cv.getClass().getName());
throw new IllegalStateException("Require CaptClassVisitor or subclass, but is "
+ cv.getClass().getName());
}
} else {
cv = next;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import java.util.List;

/**
* REMOVED and NOT_EXISTS are not in graph
* REMOVED and NOT_EXISTS are not in graph.
*/
public interface ClassInfo {

Expand All @@ -16,14 +16,14 @@ public interface ClassInfo {
Status status();

/**
* Alias for: status != REMOVED and status != NOT_EXISTS
* Alias for: status != REMOVED and status != NOT_EXISTS.
*
* @return true if exists in APK.
*/
boolean exists();

/**
* class access with deprecated flag, see Opcodes.ACC_DEPRECATED
* class access with deprecated flag, see Opcodes.ACC_DEPRECATED.
*
* @return class access.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
public interface MethodInfo {

/**
* method access with deprecated flag, see Opcodes.ACC_DEPRECATED
* method access with deprecated flag, see Opcodes.ACC_DEPRECATED.
*
* @return method access
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.lang.annotation.*;

/**
* Notify function on which thread type
* Notify function on which thread type.
*/
@Documented
@Retention(RetentionPolicy.SOURCE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import javax.annotation.Nullable;

/**
* Only class contains plugin interested annotations will pass to AnnotationProcessor
* Only class contains plugin interested annotations will pass to AnnotationProcessor.
*/
public class AnnotationProcessor {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public Scope scope() {
}

/**
* Regardless of scope(), extra specified classes
* Regardless of scope(), extra specified classes.
*
* @return extra specified classes
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.objectweb.asm.ClassVisitor;

/**
* Context during single class transform.
* TODO: more API
*/
public interface TransformContext {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public Set<? super QualifiedContent.Scope> getScopes() {
}

/**
* Needs other scopes to compute frame
* Needs other scopes to compute frame.
*/
@Override
public Set<? super QualifiedContent.Scope> getReferencedScopes() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ public void throwIfDuplicated(boolean throwIfDuplicated) {
public boolean getThrowIfDuplicated() {
return throwIfDuplicated;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

public class LoggerFactory {

private LoggerFactory() {
}

public static Logger getLogger(Class<?> clazz) {
return new LoggerImpl(Logging.getLogger(clazz));
}
Expand All @@ -15,7 +18,7 @@ static class LoggerImpl implements Logger {

private final org.gradle.api.logging.Logger logger;

public LoggerImpl(org.gradle.api.logging.Logger logger) {
LoggerImpl(org.gradle.api.logging.Logger logger) {
this.logger = logger;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

public class InternalCache {

private static Logger LOGGER = LoggerFactory.getLogger(InternalCache.class);
private static final Logger LOGGER = LoggerFactory.getLogger(InternalCache.class);

private final GlobalResource global;
private final RelativeDirectoryProvider provider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class OutputProviderImpl implements OutputProvider {

private final String id;

public OutputProviderImpl(String id) {
OutputProviderImpl(String id) {
this.id = id;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class ApkClassInfo implements ClassInfo {
public ClassBean clazz;

/**
* null means removed or not exists
* null means removed or not exists.
*/
@Nullable
public ApkClassInfo parent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import javax.annotation.Nullable;

/**
* Ignore exceptions, too large
* Ignore exceptions, too large.
*/
public class MethodBean implements MethodInfo {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package coffeepartner.capt.plugin.process;

import com.android.build.api.transform.TransformException;
import com.android.build.api.transform.TransformInvocation;
import coffeepartner.capt.plugin.GradleCaptExtension;
import coffeepartner.capt.plugin.api.Plugin;
import coffeepartner.capt.plugin.api.graph.Status;
import coffeepartner.capt.plugin.dsl.CaptPluginExtension;
import coffeepartner.capt.plugin.GradleCaptExtension;
import coffeepartner.capt.plugin.graph.ApkClassGraph;
import coffeepartner.capt.plugin.graph.ApkClassInfo;
import coffeepartner.capt.plugin.process.plugin.GlobalCapt;
Expand All @@ -16,6 +14,8 @@
import coffeepartner.capt.plugin.resource.VariantResource;
import coffeepartner.capt.plugin.util.Constants;
import coffeepartner.capt.plugin.util.WaitableTasks;
import com.android.build.api.transform.TransformException;
import com.android.build.api.transform.TransformInvocation;
import com.google.common.io.Closeables;
import okio.BufferedSource;
import okio.Okio;
Expand Down Expand Up @@ -135,7 +135,7 @@ public Stream<ApkClassInfo> collectRemovedPluginsAffectedClasses(ApkClassGraph g
.map(graph::get)
.filter(Objects::nonNull)
.filter(c -> c.status() == Status.NOT_CHANGED)
: Stream.empty();// others are already called.
: Stream.empty(); // others are already called.
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package coffeepartner.capt.plugin.process.visitors;

import com.android.build.api.transform.TransformException;
import coffeepartner.capt.plugin.api.graph.Status;
import coffeepartner.capt.plugin.api.process.AnnotationProcessor;
import coffeepartner.capt.plugin.api.process.ClassConsumer;
Expand All @@ -11,6 +10,7 @@
import coffeepartner.capt.plugin.util.Util;
import coffeepartner.capt.plugin.util.WaitableTasks;
import coffeepartner.capt.plugin.util.asm.AnnotationSniffer;
import com.android.build.api.transform.TransformException;
import com.google.common.io.ByteStreams;
import org.gradle.api.logging.Logger;
import org.gradle.api.logging.Logging;
Expand Down Expand Up @@ -77,7 +77,8 @@ public MatchedClasses(Map<String, Set<String>> classes) {
}


public void dispatch(boolean recompute, boolean incremental, ApkClassGraph graph, VariantResource resource, AnnotationProcessorFactory factory) throws InterruptedException, TransformException, IOException {
public void dispatch(boolean recompute, boolean incremental, ApkClassGraph graph, VariantResource resource, AnnotationProcessorFactory factory)
throws InterruptedException, TransformException, IOException {
PerClassDispatcher inner = new PerClassDispatcher(factory);
ForkJoinPool pool = global.computation();
WaitableTasks tasks = WaitableTasks.get(global.io());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package coffeepartner.capt.plugin.process.visitors;

import com.android.build.api.transform.JarInput;
import com.android.build.api.transform.Status;
import com.android.build.api.transform.TransformException;
import coffeepartner.capt.plugin.graph.ApkClassGraph;
import coffeepartner.capt.plugin.graph.ClassBean;
import coffeepartner.capt.plugin.graph.MethodBean;
import coffeepartner.capt.plugin.util.ClassWalker;
import coffeepartner.capt.plugin.util.asm.AnnotationSniffer;
import com.android.build.api.transform.JarInput;
import com.android.build.api.transform.Status;
import com.android.build.api.transform.TransformException;
import org.gradle.api.logging.Logger;
import org.gradle.api.logging.Logging;
import org.objectweb.asm.ClassReader;
Expand All @@ -30,7 +30,7 @@ public FirstRound(ApkClassGraph graph) {
}

public void accept(ClassWalker walker, boolean incremental, AnnotationCollector collector) throws IOException, InterruptedException, TransformException {
if(!incremental) {
if (!incremental) {
graph.clear();
}
walker.visit(false, incremental, false, asFactory(collector));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package coffeepartner.capt.plugin.process.visitors;

import com.android.build.api.transform.*;
import coffeepartner.capt.plugin.api.asm.ClassVisitorManager;
import coffeepartner.capt.plugin.api.asm.CaptClassVisitor;
import coffeepartner.capt.plugin.api.asm.ClassVisitorManager;
import coffeepartner.capt.plugin.api.transform.ClassRequest;
import coffeepartner.capt.plugin.api.transform.ClassTransformer;
import coffeepartner.capt.plugin.api.transform.TransformContext;
Expand All @@ -13,6 +12,10 @@
import coffeepartner.capt.plugin.util.ClassWalker;
import coffeepartner.capt.plugin.util.Util;
import coffeepartner.capt.plugin.util.WaitableTasks;
import com.android.build.api.transform.QualifiedContent;
import com.android.build.api.transform.Status;
import com.android.build.api.transform.TransformException;
import com.android.build.api.transform.TransformInvocation;
import org.gradle.api.logging.Logger;
import org.gradle.api.logging.Logging;
import org.objectweb.asm.ClassReader;
Expand All @@ -29,9 +32,6 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
* toRemove is higher than ClassTransformer
*/
public class ThirdRound {
private static final Logger LOGGER = Logging.getLogger(ThirdRound.class);
private final VariantResource variantResource;
Expand All @@ -46,7 +46,8 @@ public ThirdRound(VariantResource variantResource, GlobalResource global, ApkCla
this.graph = graph;
}

public void accept(boolean incremental, ClassWalker walker, TransformProviderFactory manager, TransformInvocation invocation) throws IOException, InterruptedException, TransformException {
public void accept(boolean incremental, ClassWalker walker, TransformProviderFactory manager, TransformInvocation invocation)
throws IOException, InterruptedException, TransformException {
List<PluginTransform> transforms = manager.create().map(PluginTransform::new).collect(Collectors.toList());

// 1. call beforeTransform to collect class request
Expand Down Expand Up @@ -244,16 +245,16 @@ public ClassVisitor getLastWriter() {
}
}

private static class ComputeFrameClassWriter extends ClassWriter {
static class ComputeFrameClassWriter extends ClassWriter {

private final URLClassLoader classLoader;

public ComputeFrameClassWriter(int flags, URLClassLoader classLoader) {
ComputeFrameClassWriter(int flags, URLClassLoader classLoader) {
super(flags);
this.classLoader = classLoader;
}

public ComputeFrameClassWriter(ClassReader classReader, int flags, URLClassLoader classLoader) {
ComputeFrameClassWriter(ClassReader classReader, int flags, URLClassLoader classLoader) {
super(classReader, flags);
this.classLoader = classLoader;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ public class GlobalResource {
private final GradleCaptExtension gradleCaptExtension;
private final BaseExtension extension;

public GlobalResource(Project project, File root, ForkJoinPool computation, ExecutorService executor, Gson gson, GradleCaptExtension gradleCaptExtension, BaseExtension extension) {
public GlobalResource(Project project,
File root,
ForkJoinPool computation,
ExecutorService executor,
Gson gson,
GradleCaptExtension gradleCaptExtension,
BaseExtension extension) {
this.project = project;
this.root = root;
this.computation = computation;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package coffeepartner.capt.plugin.resource;

import com.android.build.api.transform.QualifiedContent;
import com.android.build.api.transform.TransformInvocation;
import coffeepartner.capt.plugin.api.OutputProvider;
import coffeepartner.capt.plugin.api.Plugin;
import coffeepartner.capt.plugin.cache.FileManager;
import coffeepartner.capt.plugin.cache.OutputProviderFactory;
import coffeepartner.capt.plugin.util.Constants;
import com.android.build.api.transform.QualifiedContent;
import com.android.build.api.transform.TransformInvocation;
import com.google.common.collect.Streams;
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.logging.Logger;
Expand Down Expand Up @@ -49,7 +49,7 @@ public void init(TransformInvocation invocation, List<File> bootClasspath, Confi

public void setIncremental(boolean incremental) throws IOException {
this.incremental = incremental;
if(!incremental) {
if (!incremental) {
files.clearForFullMode();
}
}
Expand Down
Loading

0 comments on commit 26a07d1

Please sign in to comment.