mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
js: add typescript mappings to PackageJsonData WEB-42898
GitOrigin-RevId: 001958ed89e8a0f285445a740b7e8df63de62dd6
This commit is contained in:
committed by
intellij-monorepo-bot
parent
3584af8f19
commit
112044d06a
@@ -189,24 +189,46 @@ public final class SemVer implements Comparable<SemVer> {
|
||||
|
||||
@Nullable
|
||||
public static SemVer parseFromText(@Nullable String text) {
|
||||
if (text != null) {
|
||||
int majorEndIdx = text.indexOf('.');
|
||||
if (majorEndIdx >= 0) {
|
||||
int minorEndIdx = text.indexOf('.', majorEndIdx + 1);
|
||||
if (minorEndIdx >= 0) {
|
||||
int preReleaseIdx = text.indexOf('-', minorEndIdx + 1);
|
||||
int patchEndIdx = preReleaseIdx >= 0 ? preReleaseIdx : text.length();
|
||||
return parseFromText(text, false);
|
||||
}
|
||||
|
||||
int major = StringUtil.parseInt(text.substring(0, majorEndIdx), -1);
|
||||
int minor = StringUtil.parseInt(text.substring(majorEndIdx + 1, minorEndIdx), -1);
|
||||
int patch = StringUtil.parseInt(text.substring(minorEndIdx + 1, patchEndIdx), -1);
|
||||
String preRelease = preReleaseIdx >= 0 ? text.substring(preReleaseIdx + 1) : null;
|
||||
/**
|
||||
* @param text string presentation of the version
|
||||
* @param incomplete if the flag is true the method will accept shorten paths e.g. 3.5 instead of 3.5.0
|
||||
* @return parsed version or null
|
||||
*/
|
||||
@Nullable
|
||||
public static SemVer parseFromText(@Nullable String text, boolean incomplete) {
|
||||
if (text == null) return null;
|
||||
int majorEndIdx = text.indexOf('.');
|
||||
if (majorEndIdx >= 0) {
|
||||
int minorEndIdx = text.indexOf('.', majorEndIdx + 1);
|
||||
if (minorEndIdx >= 0) {
|
||||
int preReleaseIdx = text.indexOf('-', minorEndIdx + 1);
|
||||
int patchEndIdx = preReleaseIdx >= 0 ? preReleaseIdx : text.length();
|
||||
|
||||
if (major >= 0 && minor >= 0 && patch >= 0) {
|
||||
return new SemVer(text, major, minor, patch, preRelease);
|
||||
}
|
||||
int major = StringUtil.parseInt(text.substring(0, majorEndIdx), -1);
|
||||
int minor = StringUtil.parseInt(text.substring(majorEndIdx + 1, minorEndIdx), -1);
|
||||
int patch = StringUtil.parseInt(text.substring(minorEndIdx + 1, patchEndIdx), -1);
|
||||
String preRelease = preReleaseIdx >= 0 ? text.substring(preReleaseIdx + 1) : null;
|
||||
|
||||
if (major >= 0 && minor >= 0 && patch >= 0) {
|
||||
return new SemVer(text, major, minor, patch, preRelease);
|
||||
}
|
||||
}
|
||||
else if (incomplete) {
|
||||
int major = StringUtil.parseInt(text.substring(0, majorEndIdx), -1);
|
||||
int minor = StringUtil.parseInt(text.substring(majorEndIdx + 1), -1);
|
||||
if (major >= 0 && minor >= 0) {
|
||||
return new SemVer(text, major, minor, 0, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (incomplete) {
|
||||
int major = StringUtil.parseInt(text, -1);
|
||||
if (major >= 0) {
|
||||
return new SemVer(text, major, 0, 0, null);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user