J2K ImportPath: autoconvert
This commit is contained in:
@@ -14,97 +14,77 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jetbrains.kotlin.resolve;
|
package org.jetbrains.kotlin.resolve
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.kotlin.name.FqName
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.name.FqName;
|
import org.jetbrains.kotlin.renderer.*
|
||||||
import org.jetbrains.kotlin.name.Name;
|
|
||||||
import org.jetbrains.kotlin.renderer.RenderingUtilsKt;
|
|
||||||
|
|
||||||
public final class ImportPath {
|
class ImportPath {
|
||||||
private final @NotNull FqName fqName;
|
private val fqName: FqName
|
||||||
private final @Nullable Name alias;
|
val alias: Name?
|
||||||
private final boolean isAllUnder;
|
val isAllUnder: Boolean
|
||||||
|
|
||||||
public ImportPath(@NotNull FqName fqName, boolean isAllUnder) {
|
@JvmOverloads constructor(fqName: FqName, isAllUnder: Boolean, alias: Name? = null) {
|
||||||
this(fqName, isAllUnder, null);
|
this.fqName = fqName
|
||||||
|
this.isAllUnder = isAllUnder
|
||||||
|
this.alias = alias
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImportPath(@NotNull FqName fqName, boolean isAllUnder, @Nullable Name alias) {
|
constructor(pathStr: String) {
|
||||||
this.fqName = fqName;
|
|
||||||
this.isAllUnder = isAllUnder;
|
|
||||||
this.alias = alias;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ImportPath(@NotNull String pathStr) {
|
|
||||||
if (pathStr.endsWith(".*")) {
|
if (pathStr.endsWith(".*")) {
|
||||||
this.isAllUnder = true;
|
this.isAllUnder = true
|
||||||
this.fqName = new FqName(pathStr.substring(0, pathStr.length() - 2));
|
this.fqName = FqName(pathStr.substring(0, pathStr.length - 2))
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.isAllUnder = false;
|
this.isAllUnder = false
|
||||||
this.fqName = new FqName(pathStr);
|
this.fqName = FqName(pathStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
alias = null;
|
alias = null
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPathStr() {
|
val pathStr: String
|
||||||
return RenderingUtilsKt.render(fqName.toUnsafe()) + (isAllUnder ? ".*" : "");
|
get() = fqName.toUnsafe().render() + if (isAllUnder) ".*" else ""
|
||||||
|
|
||||||
|
override fun toString(): String {
|
||||||
|
return pathStr + if (alias != null) " as " + alias.asString() else ""
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
fun fqnPart(): FqName {
|
||||||
public String toString() {
|
return fqName
|
||||||
return getPathStr() + (alias != null ? " as " + alias.asString() : "");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
fun hasAlias(): Boolean {
|
||||||
public FqName fqnPart() {
|
return alias != null
|
||||||
return fqName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
val importedName: Name?
|
||||||
public Name getAlias() {
|
get() {
|
||||||
return alias;
|
if (!isAllUnder) {
|
||||||
}
|
return alias ?: fqName.shortName()
|
||||||
|
}
|
||||||
|
|
||||||
public boolean hasAlias() {
|
return null
|
||||||
return alias != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isAllUnder() {
|
|
||||||
return isAllUnder;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public Name getImportedName() {
|
|
||||||
if (!isAllUnder()) {
|
|
||||||
return alias != null ? alias : fqName.shortName();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
override fun equals(o: Any?): Boolean {
|
||||||
|
if (this === o) return true
|
||||||
|
if (o == null || javaClass != o.javaClass) return false
|
||||||
|
|
||||||
|
val path = o as ImportPath?
|
||||||
|
|
||||||
|
if (isAllUnder != path!!.isAllUnder) return false
|
||||||
|
if (if (alias != null) alias != path.alias else path.alias != null) return false
|
||||||
|
if (fqName != path.fqName) return false
|
||||||
|
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
override fun hashCode(): Int {
|
||||||
public boolean equals(Object o) {
|
var result = fqName.hashCode()
|
||||||
if (this == o) return true;
|
result = 31 * result + (alias?.hashCode() ?: 0)
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
result = 31 * result + if (isAllUnder) 1 else 0
|
||||||
|
return result
|
||||||
ImportPath path = (ImportPath) o;
|
|
||||||
|
|
||||||
if (isAllUnder != path.isAllUnder) return false;
|
|
||||||
if (alias != null ? !alias.equals(path.alias) : path.alias != null) return false;
|
|
||||||
if (!fqName.equals(path.fqName)) return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
int result = fqName.hashCode();
|
|
||||||
result = 31 * result + (alias != null ? alias.hashCode() : 0);
|
|
||||||
result = 31 * result + (isAllUnder ? 1 : 0);
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user