Repository navigation
Shorten fully qualified type names to simple names with imports - #184
Merged
Merged
Conversation
|
I have read the CLA Document and I hereby sign the CLA Tom Tourwe seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. |
This file contains hidden or 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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces type names written out in full in the code by their simple name plus an import, for example
java.util.List<String> list = new java.util.ArrayList<>()becomesList<String> list = new ArrayList<>()with
import java.util.ArrayList;andimport java.util.List;. The change is mechanical, made with an automatedimport refactoring.
The two commits
f56a8f3d7): unused imports are removed, and import blocks that were in no consistent order aresorted. No code line changes.
8ea82b1af): a type name written in full becomes its simple name and the import isadded. A nested type keeps its enclosing type (
java.util.Map.EntrybecomesMap.Entry, importingjava.util.Map); a static member keeps its class (java.util.Collections.emptyList()becomesCollections.emptyList()); no static import is added. Comments, javadoc and string literals are left as they are.A name stays qualified where its simple name would mean another type in that file: another type of that simple
name is imported, declared or written in the file, or two on-demand imports would both provide it.
Verification
./gradlew testpasses, with no failures.Where qualified names are kept
Each link points to a line where a type name is still written in full, because its simple name already means another
type in that file (for example
org.slf4j.Loggerbeside an import ofch.qos.logback.classic.Logger).maddi-aapi-archive: ComGoogleCommonCollect.java, line 302 writesjava.util.Optionalin fullmaddi-aapi-archive: IoVavr.java, line 2887 writesio.vavr.collection.Mapin fullmaddi-aapi-archive: IoVavrCollection.java, line 72 writesjava.util.Listin fullmaddi-aapi-archive: IoVavrConcurrent.java, line 32 writesio.vavr.concurrent.Futurein fullmaddi-analysis-api: module-info.java, line 14 writesuses io.codelaser.maddi.analysis.api.AnalysisEngine;, which stays as it ismaddi-callgraph: CommonTest.java, line 49 writesorg.slf4j.Loggerin fullmaddi-inspection-integration: CommonTest.java, line 52 writesorg.slf4j.Loggerin fullmaddi-inspection-integration: CommonTest2.java, line 45 writesorg.slf4j.Loggerin fullmaddi-inspection-integration: JavaInspectorImpl.java, line 436 writesjava.lang.Runtimein fullmaddi-inspection-integration: TestCompilationProblem.java, line 38 writesorg.slf4j.Loggerin fullmaddi-inspection-integration: TestModuleInfo.java, line 54 writesorg.slf4j.Loggerin fullmaddi-inspection-openjdk: JavaInspectorImpl.java, line 699 writesjava.lang.Runtimein fullmaddi-java-openjdk: ClassSymbolScanner.java, line 2645 writescom.sun.tools.javac.util.Listin fullmaddi-java-openjdk: CommonTest.java, line 162 writesjava.lang.Runtimein fullmaddi-java-openjdk: ScanCompilationUnits.java, line 269 writesjavax.lang.model.element.Elementin fullmaddi-java-parser: CommonParse.java, line 256 writesorg.parsers.java.ast.TypeParameterin fullmaddi-java-parser: ParseBlock.java, line 54 writesio.codelaser.maddi.cst.api.statement.Statementin fullmaddi-java-parser: ParseCompilationUnit.java, line 50 writesio.codelaser.maddi.cst.api.element.CompilationUnitin fullmaddi-java-parser: ParseConstructorCall.java, line 190 writesio.codelaser.maddi.cst.api.expression.ArrayInitializerin fullmaddi-java-parser: ParseExpression.java, line 105 writesorg.parsers.java.ast.Expressionin fullmaddi-java-parser: ParseHelperImpl.java, line 116 writesio.codelaser.maddi.cst.api.statement.ExplicitConstructorInvocationin fullmaddi-java-parser: ParseLambdaExpression.java, line 114 writesorg.parsers.java.ast.Expressionin fullmaddi-java-parser: ParseMethodDeclaration.java, line 168 writesio.codelaser.maddi.cst.api.statement.Statementin fullmaddi-java-parser: ParseRecordPattern.java, line 47 writesorg.parsers.java.ast.RecordPatternin fullmaddi-java-parser: ParseStatement.java, line 73 writesio.codelaser.maddi.cst.api.statement.Statementin fullmaddi-java-parser: ScanCompilationUnit.java, line 56 writesio.codelaser.maddi.cst.api.element.CompilationUnitin fullmaddi-run-kotlin: TestOneEntryPoint.java, line 66 writesio.codelaser.maddi.run.openjdkmain.Mainin fullmaddi-run-main: RunAnalyzer.java, line 112 writesch.qos.logback.classic.Loggerin full