-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
2,708 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
src/main/java/com/github/checkstyle/regression/data/ModuleExtractInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
//////////////////////////////////////////////////////////////////////////////// | ||
// checkstyle: Checks Java source code for adherence to a set of rules. | ||
// Copyright (C) 2001-2017 the original author or authors. | ||
// | ||
// This library is free software; you can redistribute it and/or | ||
// modify it under the terms of the GNU Lesser General Public | ||
// License as published by the Free Software Foundation; either | ||
// version 2.1 of the License, or (at your option) any later version. | ||
// | ||
// This library is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
// Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public | ||
// License along with this library; if not, write to the Free Software | ||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
//////////////////////////////////////////////////////////////////////////////// | ||
|
||
package com.github.checkstyle.regression.data; | ||
|
||
import org.immutables.gson.Gson; | ||
import org.immutables.value.Value; | ||
|
||
/** | ||
* Represents the extract information of a checkstyle module. | ||
* @author LuoLiangchen | ||
*/ | ||
@Gson.TypeAdapters | ||
@Value.Immutable | ||
public abstract class ModuleExtractInfo { | ||
/** | ||
* The package name of this module. | ||
* @return the package name of this module | ||
*/ | ||
public abstract String packageName(); | ||
|
||
/** | ||
* The name of this module. | ||
* @return the name of this module. | ||
*/ | ||
public abstract String name(); | ||
|
||
/** | ||
* The parent of this module. | ||
* The value should be either "TreeWalker" or "Checker". | ||
* @return the parent of this module. | ||
*/ | ||
public abstract String parent(); | ||
|
||
/** | ||
* The full qualified name of this module. | ||
* @return the full qualified name of this module | ||
*/ | ||
public String fullName() { | ||
return packageName() + "." + name(); | ||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
src/main/java/com/github/checkstyle/regression/data/ModuleInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
//////////////////////////////////////////////////////////////////////////////// | ||
// checkstyle: Checks Java source code for adherence to a set of rules. | ||
// Copyright (C) 2001-2017 the original author or authors. | ||
// | ||
// This library is free software; you can redistribute it and/or | ||
// modify it under the terms of the GNU Lesser General Public | ||
// License as published by the Free Software Foundation; either | ||
// version 2.1 of the License, or (at your option) any later version. | ||
// | ||
// This library is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
// Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public | ||
// License along with this library; if not, write to the Free Software | ||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
//////////////////////////////////////////////////////////////////////////////// | ||
|
||
package com.github.checkstyle.regression.data; | ||
|
||
import java.util.List; | ||
|
||
import org.immutables.value.Value; | ||
|
||
/** | ||
* Represents the related information of a checkstyle module. | ||
* Including the extract module information, change of the module class, change | ||
* of the corresponding test and changed of the utility classes that the module | ||
* depends on. | ||
* @author LuoLiangchen | ||
*/ | ||
@Value.Immutable | ||
@Value.Modifiable | ||
public abstract class ModuleInfo { | ||
/** | ||
* The extract information of the module. | ||
* @return the extract information of the module | ||
*/ | ||
public abstract ModuleExtractInfo moduleExtractInfo(); | ||
|
||
/** | ||
* The properties of the module. | ||
* @return the properties of the module | ||
*/ | ||
public abstract List<Property> properties(); | ||
|
||
/** | ||
* The name of the module. | ||
* @return the name of the module | ||
*/ | ||
public String name() { | ||
return moduleExtractInfo().name(); | ||
} | ||
|
||
/** | ||
* Represents the property and its settings of a module. | ||
*/ | ||
@Value.Immutable | ||
public interface Property { | ||
/** | ||
* The name of the property. | ||
* @return the name of the property | ||
*/ | ||
String name(); | ||
|
||
/** | ||
* The value of the property. | ||
* @return the value of the property | ||
*/ | ||
String value(); | ||
} | ||
} |
86 changes: 86 additions & 0 deletions
86
src/main/java/com/github/checkstyle/regression/extract/ExtractInfoProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
//////////////////////////////////////////////////////////////////////////////// | ||
// checkstyle: Checks Java source code for adherence to a set of rules. | ||
// Copyright (C) 2001-2017 the original author or authors. | ||
// | ||
// This library is free software; you can redistribute it and/or | ||
// modify it under the terms of the GNU Lesser General Public | ||
// License as published by the Free Software Foundation; either | ||
// version 2.1 of the License, or (at your option) any later version. | ||
// | ||
// This library is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
// Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public | ||
// License along with this library; if not, write to the Free Software | ||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
//////////////////////////////////////////////////////////////////////////////// | ||
|
||
package com.github.checkstyle.regression.extract; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.InputStreamReader; | ||
import java.nio.charset.Charset; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.stream.Collectors; | ||
|
||
import com.github.checkstyle.regression.data.ModuleExtractInfo; | ||
import com.google.gson.Gson; | ||
import com.google.gson.GsonBuilder; | ||
import com.google.gson.TypeAdapterFactory; | ||
import com.google.gson.reflect.TypeToken; | ||
import com.sun.tools.javac.util.ServiceLoader; | ||
|
||
/** | ||
* Processes the module extract info grabbed from checkstyle project. | ||
* @author LuoLiangchen | ||
*/ | ||
public final class ExtractInfoProcessor { | ||
/** The {@link Gson} instance. */ | ||
private static final Gson GSON; | ||
|
||
/** Prevents instantiation. */ | ||
private ExtractInfoProcessor() { | ||
} | ||
|
||
static { | ||
final GsonBuilder gsonBuilder = new GsonBuilder(); | ||
for (TypeAdapterFactory factory : ServiceLoader.load(TypeAdapterFactory.class)) { | ||
gsonBuilder.registerTypeAdapterFactory(factory); | ||
} | ||
GSON = gsonBuilder.create(); | ||
} | ||
|
||
/** | ||
* Gets the full qualified name to module extract info map from the given input stream. | ||
* @param stream the given input stream | ||
* @return the full qualified name to module extract info map | ||
*/ | ||
public static Map<String, ModuleExtractInfo> getNameToModuleExtractInfoFromInputStream( | ||
InputStream stream) { | ||
final List<ModuleExtractInfo> modules; | ||
|
||
try { | ||
final InputStreamReader reader = | ||
new InputStreamReader(stream, Charset.forName("UTF-8")); | ||
|
||
try { | ||
modules = GSON.fromJson(reader, new TypeToken<List<ModuleExtractInfo>>() { | ||
}.getType()); | ||
} | ||
finally { | ||
reader.close(); | ||
} | ||
} | ||
catch (IOException ex) { | ||
throw new IllegalStateException( | ||
"Failed when loaing hardcoded checkstyle module information", ex); | ||
} | ||
|
||
return modules.stream().collect(Collectors.toMap( | ||
ModuleExtractInfo::fullName, extractInfo -> extractInfo)); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/com/github/checkstyle/regression/extract/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
//////////////////////////////////////////////////////////////////////////////// | ||
// checkstyle: Checks Java source code for adherence to a set of rules. | ||
// Copyright (C) 2001-2017 the original author or authors. | ||
// | ||
// This library is free software; you can redistribute it and/or | ||
// modify it under the terms of the GNU Lesser General Public | ||
// License as published by the Free Software Foundation; either | ||
// version 2.1 of the License, or (at your option) any later version. | ||
// | ||
// This library is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
// Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public | ||
// License along with this library; if not, write to the Free Software | ||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
//////////////////////////////////////////////////////////////////////////////// | ||
|
||
/** | ||
* Contains checkstyle maven command executing codes and extract file processor. | ||
* @author LuoLiangchen | ||
*/ | ||
package com.github.checkstyle.regression.extract; |
Oops, something went wrong.