Skip to content

Commit

Permalink
Increase checkstyle checks. Javadoc all the things.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mumfrey committed Jan 31, 2017
1 parent 9fd488c commit 791aba7
Show file tree
Hide file tree
Showing 89 changed files with 1,517 additions and 304 deletions.
11 changes: 6 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
}
dependencies {
classpath 'nl.javadude.gradle.plugins:license-gradle-plugin:0.11.0'
classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.0'
classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.3'
}
}

Expand Down Expand Up @@ -199,12 +199,13 @@ license {

checkstyle {
configProperties = [
"name" : project.name,
"organization": project.organization,
"url" : project.url,
"year" : project.inceptionYear
"name" : project.name,
"organization": project.organization,
"url" : project.url,
"year" : project.inceptionYear
]
configFile = file("checkstyle.xml")
toolVersion = '7.5'
}

// Source compiler configuration
Expand Down
51 changes: 51 additions & 0 deletions checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,57 @@
<module name="JavadocType">
<property name="scope" value="package"/>
</module>
<module name="JavadocMethod">
<metadata name="net.sf.eclipsecs.core.comment" value="Package members"/>
<property name="scope" value="package"/>
<property name="allowMissingParamTags" value="true"/>
<property name="allowMissingThrowsTags" value="true"/>
<property name="allowMissingReturnTag" value="true"/>
<property name="allowMissingJavadoc" value="true"/>
<property name="allowMissingPropertyJavadoc" value="true"/>
<property name="suppressLoadErrors" value="true"/>
<property name="tokens" value="METHOD_DEF"/>
</module>
<module name="JavadocTagContinuationIndentation">
<property name="offset" value="5"/>
</module>
<module name="JavadocMethod">
<metadata name="net.sf.eclipsecs.core.comment" value="Public members"/>
<property name="scope" value="public"/>
<property name="excludeScope" value="package"/>
<property name="allowMissingThrowsTags" value="true"/>
<property name="allowMissingReturnTag" value="true"/>
<property name="allowMissingPropertyJavadoc" value="true"/>
<property name="suppressLoadErrors" value="true"/>
<property name="tokens" value="METHOD_DEF"/>
</module>
<module name="NonEmptyAtclauseDescription"/>
<module name="JavadocVariable">
<property name="scope" value="public"/>
<property name="ignoreNamePattern" value="^[A-Z_]+$"/>
<message key="javadoc.missing" value="Missing a Javadoc comment on public field."/>
</module>
<module name="AtclauseOrder"/>
<module name="JavadocParagraph"/>
<module name="JavadocStyle">
<property name="scope" value="public"/>
<property name="checkFirstSentence" value="false"/>
</module>
<module name="IllegalImport">
<property name="illegalPkgs" value="org.objectweb.asm"/>
</module>
<module name="FinalClass"/>
<module name="HideUtilityClassConstructor"/>
<module name="TypecastParenPad">
<property name="tokens" value="RPAREN,TYPECAST"/>
</module>
<module name="ConstantName">
<property name="applyToProtected" value="false"/>
<property name="applyToPackage" value="false"/>
<property name="applyToPrivate" value="false"/>
</module>
<module name="MethodName"/>
<module name="UncommentedMain"/>
</module>
<module name="FileTabCharacter">
<property name="eachLine" value="true"/>
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.11-bin.zip
8 changes: 4 additions & 4 deletions src/agent/java/org/spongepowered/tools/agent/MixinAgent.java
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ public static void init(Instrumentation instrumentation) {
/**
* Initialize the java agent
*
* This will be called automatically if the jar is in a -javaagent java
* command line argument
* <p>This will be called automatically if the jar is in a -javaagent java
* command line argument</p>
*
* @param arg Ignored
* @param instrumentation Instance to use to transform the mixins
Expand All @@ -211,8 +211,8 @@ public static void premain(String arg, Instrumentation instrumentation) {
/**
* Initialize the java agent
*
* This will be called automatically if the java agent is loaded after jvm
* startup
* <p>This will be called automatically if the java agent is loaded after
* JVVM startup</p>
*
* @param arg Ignored
* @param instrumentation Instance to use to re-define the mixins
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,11 @@ public Target getTargetMethod(MethodNode into) {
throw new UnsupportedOperationException("Target not available at compile time");
}

/**
* Register a new accessor
*
* @param elem accessor element
*/
public void registerAccessor(AnnotatedElementAccessor elem) {
if (elem.getAccessorType() == null) {
elem.printMessage(this.ap, Kind.WARNING, "Unsupported accessor type");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ public class AnnotatedMixinElementHandlerSoftImplements extends AnnotatedMixinEl
* in the mixin are then tested for remapability based on the strategy
* defined in the soft-implements decoration
*
* @param implementsAnnotation
* @param implementsAnnotation the &#064;Implements annotation on the
* element
*/
public void process(AnnotationHandle implementsAnnotation) {
if (!this.mixin.remap()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
* Mixin info manager, stores all of the mixin info during processing and also
* manages access to the mappings
*/
class AnnotatedMixins implements IMixinAnnotationProcessor, ITokenProvider, ITypeHandleProvider, IJavadocProvider {
final class AnnotatedMixins implements IMixinAnnotationProcessor, ITokenProvider, ITypeHandleProvider, IJavadocProvider {

private static final String MAPID_SYSTEM_PROPERTY = "mixin.target.mapid";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ public synchronized void init(ProcessingEnvironment processingEnv) {

/**
* Searches and catalogues all annotated mixin classes
*
* @param roundEnv round environment
*/
protected void processMixins(RoundEnvironment roundEnv) {
this.mixins.onPassStarted();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,15 @@
*/
public class ObfuscationData<T> implements Iterable<ObfuscationType> {

/**
* Data points stored in this struct, entries are stored by type
*/
private final Map<ObfuscationType, T> data = new HashMap<ObfuscationType, T>();

/**
* Default obfuscation value to return when an obfuscation entry is
* requested but not present in the map
*/
private final T defaultValue;

public ObfuscationData() {
Expand All @@ -59,24 +66,46 @@ public ObfuscationData(T defaultValue) {
this.defaultValue = defaultValue;
}

/**
* Add an entry to the map
*
* @param type obfuscation type
* @param value new entry
*/
public void add(ObfuscationType type, T value) {
this.data.put(type, value);
}

/**
* Returns true if this store contains no entries
*/
public boolean isEmpty() {
return this.data.isEmpty();
}

/**
* Get the obfuscation entry for the specified obfuscation type, returns the
* default (if present) if no entry is found for the specified type
*
* @param type obfuscation type
* @return obfuscation entry or default value if absent
*/
public T get(ObfuscationType type) {
T value = this.data.get(type);
return value != null ? value : this.defaultValue;
}

/* (non-Javadoc)
* @see java.lang.Iterable#iterator()
*/
@Override
public Iterator<ObfuscationType> iterator() {
return this.data.keySet().iterator();
}

/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return String.format("ObfuscationData[%sDEFAULT=%s]", this.listValues(), this.defaultValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ private boolean initMappings() {

if (this.inFileNames == null) {
this.ap.printMessage(Kind.ERROR, "The " + this.type.getConfig().getInputFileOption()
+ " argument was not supplied, obfuscation processing will not occur");
+ " argument was not supplied, obfuscation processing will not occur");
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,29 @@
*/
public final class ObfuscationType {

/**
* Available obfuscation types indexed by key
*/
private static final Map<String, ObfuscationType> types = new LinkedHashMap<String, ObfuscationType>();

/**
* Key for this type
*/
private final String key;

/**
* Descriptor contains the majority of the metadata for the obfuscation type
*/
private final ObfuscationTypeDescriptor descriptor;

/**
* Annotation Processor
*/
private final IMixinAnnotationProcessor ap;

/**
* Option provider
*/
private final IOptionProvider options;

private ObfuscationType(ObfuscationTypeDescriptor descriptor, IMixinAnnotationProcessor ap) {
Expand All @@ -59,6 +74,9 @@ private ObfuscationType(ObfuscationTypeDescriptor descriptor, IMixinAnnotationPr
this.options = ap;
}

/**
* Create obfuscation environment instance for this obfuscation type
*/
public final ObfuscationEnvironment createEnvironment() {
try {
Class<? extends ObfuscationEnvironment> cls = this.descriptor.getEnvironmentType();
Expand Down Expand Up @@ -88,16 +106,25 @@ public IMixinAnnotationProcessor getAnnotationProcessor() {
return this.ap;
}

/**
* Get whether this is ithe default obfuscation environment
*/
public boolean isDefault() {
String defaultEnv = this.options.getOption(SupportedOptions.DEFAULT_OBFUSCATION_ENV);
return (defaultEnv == null && this.key.equals(ObfuscationServiceMCP.SEARGE))
|| (defaultEnv != null && this.key.equals(defaultEnv.toLowerCase()));
}

/**
* Get whether this obfuscation type has data available
*/
public boolean isSupported() {
return this.getInputFileNames().size() > 0;
}

/**
* Get the input file names specified for this obfuscation type
*/
public List<String> getInputFileNames() {
Builder<String> builder = ImmutableList.<String>builder();

Expand All @@ -116,24 +143,44 @@ public List<String> getInputFileNames() {
return builder.build();
}

/**
* Get the output filenames specified for this obfuscation type
*/
public String getOutputFileName() {
return this.options.getOption(this.descriptor.getOutputFileOption());
}

/**
* All available obfuscation types
*/
public static Iterable<ObfuscationType> types() {
return ObfuscationType.types.values();
}

public static ObfuscationType create(ObfuscationTypeDescriptor config, IMixinAnnotationProcessor ap) {
String key = config.getKey();
/**
* Create a new obfuscation type from the supplied descriptor
*
* @param descriptor obfuscation type metadata
* @param ap annotation processor
* @return new obfuscation type
*/
public static ObfuscationType create(ObfuscationTypeDescriptor descriptor, IMixinAnnotationProcessor ap) {
String key = descriptor.getKey();
if (ObfuscationType.types.containsKey(key)) {
throw new IllegalArgumentException("Obfuscation type with key " + key + " was already registered");
}
ObfuscationType type = new ObfuscationType(config, ap);
ObfuscationType type = new ObfuscationType(descriptor, ap);
ObfuscationType.types.put(key, type);
return type;
}

/**
* Retrieve an obfuscation type by key
*
* @param key obfuscation type key to retrieve
* @return obfuscation type or <tt>null</tt> if no matching type is
* available
*/
public static ObfuscationType get(String key) {
ObfuscationType type = ObfuscationType.types.get(key);
if (type == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public final class SupportedOptions {

private SupportedOptions() {}

/**
* Return all supported options
*/
public static Set<String> getAllOptions() {
Builder<String> options = ImmutableSet.<String>builder();
options.add(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
* Serialisable map of classes to their associated mixins, used so that we can
* pass target information for supermixins from one compiler session to another
*/
public class TargetMap extends HashMap<TypeReference, Set<TypeReference>> {
public final class TargetMap extends HashMap<TypeReference, Set<TypeReference>> {

private static final long serialVersionUID = 1L;

Expand All @@ -68,7 +68,7 @@ private TargetMap() {
/**
* Create a TargetMap with the specified session ID
*
* @param sessionId
* @param sessionId session id
*/
private TargetMap(String sessionId) {
this.sessionId = sessionId;
Expand Down
Loading

0 comments on commit 791aba7

Please sign in to comment.