mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-09 08:09:39 +07:00
InstalledPackage refactoring: explicit nullability; PackageManagementService#getInstalledPackage variance added
GitOrigin-RevId: 1bfb0969da77bde8809855f9c80da3878e7569e5
This commit is contained in:
committed by
intellij-monorepo-bot
parent
a3328983c3
commit
c07e578e7d
@@ -1,20 +1,21 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.jetbrains.python.packaging;
|
||||
|
||||
import com.intellij.openapi.util.NlsSafe;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.webcore.packaging.InstalledPackage;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author vlan
|
||||
*/
|
||||
public final class PyPackage extends InstalledPackage {
|
||||
private final String myLocation;
|
||||
private final List<PyRequirement> myRequirements;
|
||||
private final @Nullable String myLocation;
|
||||
private final @NotNull List<PyRequirement> myRequirements;
|
||||
|
||||
public PyPackage(@NotNull String name, @NotNull String version, @Nullable String location, @NotNull List<PyRequirement> requirements) {
|
||||
super(name, version);
|
||||
@@ -22,11 +23,22 @@ public final class PyPackage extends InstalledPackage {
|
||||
myRequirements = requirements;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<PyRequirement> getRequirements() {
|
||||
return myRequirements;
|
||||
public PyPackage(@NotNull String name, @NotNull String version, @Nullable String location) {
|
||||
this(name, version, location, List.of());
|
||||
}
|
||||
|
||||
public PyPackage(@NotNull String name, @NotNull String version) {
|
||||
this(name, version, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NlsSafe @NotNull String getVersion() {
|
||||
return Objects.requireNonNull(super.getVersion());
|
||||
}
|
||||
|
||||
public @NotNull List<PyRequirement> getRequirements() {
|
||||
return myRequirements;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if package meets requirement, described in [PEP-0386] format using {@link PyRequirement}
|
||||
@@ -35,11 +47,10 @@ public final class PyPackage extends InstalledPackage {
|
||||
* @return true if matches.
|
||||
*/
|
||||
public boolean matches(@NotNull PyRequirement requirement) {
|
||||
return requirement.match(Collections.singletonList(this)) != null;
|
||||
return requirement.match(List.of(this)) != null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getLocation() {
|
||||
public @Nullable String getLocation() {
|
||||
return myLocation;
|
||||
}
|
||||
|
||||
@@ -47,9 +58,8 @@ public final class PyPackage extends InstalledPackage {
|
||||
return myLocation != null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getTooltipText() {
|
||||
public @Nullable String getTooltipText() {
|
||||
return FileUtil.getLocationRelativeToUserHome(myLocation);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user