use of gnu.trove.TIntArrayList in project intellij-community by JetBrains.
the class BuildNumber method fromString.
public static BuildNumber fromString(String version, @Nullable String name) {
if (StringUtil.isEmptyOrSpaces(version))
return null;
if (BUILD_NUMBER.equals(version) || SNAPSHOT.equals(version)) {
final String productCode = name != null ? name : "";
return new BuildNumber(productCode, currentVersion().myComponents);
}
String code = version;
int productSeparator = code.indexOf('-');
final String productCode;
if (productSeparator > 0) {
productCode = code.substring(0, productSeparator);
code = code.substring(productSeparator + 1);
} else {
productCode = "";
}
int baselineVersionSeparator = code.indexOf('.');
int baselineVersion;
int buildNumber;
if (baselineVersionSeparator > 0) {
String baselineVersionString = code.substring(0, baselineVersionSeparator);
if (baselineVersionString.trim().isEmpty())
return null;
List<String> stringComponents = StringUtil.split(code, ".");
TIntArrayList intComponentsList = new TIntArrayList();
for (String stringComponent : stringComponents) {
int comp = parseBuildNumber(version, stringComponent, name);
intComponentsList.add(comp);
if (comp == SNAPSHOT_VALUE)
break;
}
int[] intComponents = intComponentsList.toNativeArray();
return new BuildNumber(productCode, intComponents);
} else {
buildNumber = parseBuildNumber(version, code, name);
if (buildNumber <= 2000) {
// it's probably a baseline, not a build number
return new BuildNumber(productCode, buildNumber, 0);
}
baselineVersion = getBaseLineForHistoricBuilds(buildNumber);
return new BuildNumber(productCode, baselineVersion, buildNumber);
}
}
use of gnu.trove.TIntArrayList in project intellij-community by JetBrains.
the class CtrlMouseHandler method calculateWidthIncrease.
/**
* It's possible that we need to expand quick doc control's width in order to provide better visual representation
* (see https://youtrack.jetbrains.com/issue/IDEA-101425). This method calculates that width expand.
*
* @param buttonWidth icon button's width
* @param updatedText text which will be should at the quick doc control
* @return width increase to apply to the target quick doc control (zero if no additional width increase is required)
*/
private static int calculateWidthIncrease(int buttonWidth, String updatedText) {
int maxLineWidth = 0;
TIntArrayList lineWidths = new TIntArrayList();
for (String lineText : StringUtil.split(updatedText, "<br/>")) {
String html = HintUtil.prepareHintText(lineText, HintUtil.getInformationHint());
int width = new JLabel(html).getPreferredSize().width;
maxLineWidth = Math.max(maxLineWidth, width);
lineWidths.add(width);
}
if (!lineWidths.isEmpty()) {
int firstLineAvailableTrailingWidth = maxLineWidth - lineWidths.get(0);
if (firstLineAvailableTrailingWidth >= buttonWidth) {
return 0;
} else {
return buttonWidth - firstLineAvailableTrailingWidth;
}
}
return 0;
}
use of gnu.trove.TIntArrayList in project intellij-community by JetBrains.
the class JavaMethodsConflictResolver method checkParametersNumber.
public boolean checkParametersNumber(@NotNull List<CandidateInfo> conflicts, final int argumentsCount, FactoryMap<MethodCandidateInfo, PsiSubstitutor> map, boolean ignoreIfStaticsProblem) {
boolean atLeastOneMatch = false;
TIntArrayList unmatchedIndices = null;
for (int i = 0; i < conflicts.size(); i++) {
ProgressManager.checkCanceled();
CandidateInfo info = conflicts.get(i);
if (ignoreIfStaticsProblem && !info.isStaticsScopeCorrect())
return true;
if (!(info instanceof MethodCandidateInfo))
continue;
PsiMethod method = ((MethodCandidateInfo) info).getElement();
final int parametersCount = method.getParameterList().getParametersCount();
boolean isVarargs = (myLanguageLevel.isAtLeast(LanguageLevel.JDK_1_8) ? ((MethodCandidateInfo) info).isVarargs() : method.isVarArgs()) && parametersCount - 1 <= argumentsCount;
if (isVarargs || parametersCount == argumentsCount) {
// remove all unmatched before
if (unmatchedIndices != null) {
for (int u = unmatchedIndices.size() - 1; u >= 0; u--) {
int index = unmatchedIndices.get(u);
//ensure super method with varargs won't win over non-vararg override
if (ignoreIfStaticsProblem && isVarargs) {
MethodCandidateInfo candidateInfo = (MethodCandidateInfo) conflicts.get(index);
PsiMethod candidateToRemove = candidateInfo.getElement();
if (candidateToRemove != method) {
PsiSubstitutor candidateToRemoveSubst = map.get(candidateInfo);
PsiSubstitutor substitutor = map.get(info);
if (MethodSignatureUtil.isSubsignature(candidateToRemove.getSignature(candidateToRemoveSubst), method.getSignature(substitutor))) {
continue;
}
}
}
conflicts.remove(index);
i--;
}
unmatchedIndices = null;
}
atLeastOneMatch = true;
} else if (atLeastOneMatch) {
conflicts.remove(i);
i--;
} else {
if (unmatchedIndices == null)
unmatchedIndices = new TIntArrayList(conflicts.size() - i);
unmatchedIndices.add(i);
}
}
return atLeastOneMatch;
}
use of gnu.trove.TIntArrayList in project intellij-community by JetBrains.
the class GrInplaceParameterIntroducer method getInitialSettingsForInplace.
@Nullable
@Override
protected GrIntroduceParameterSettings getInitialSettingsForInplace(@NotNull GrIntroduceContext context, @NotNull OccurrencesChooser.ReplaceChoice choice, String[] names) {
GrExpression expression = context.getExpression();
GrVariable var = context.getVar();
PsiType type = var != null ? var.getDeclaredType() : expression != null ? expression.getType() : null;
return new GrIntroduceExpressionSettingsImpl(myInfo, names[0], false, new TIntArrayList(), false, IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, expression, var, type, false, false, false);
}
use of gnu.trove.TIntArrayList in project intellij-community by JetBrains.
the class CutCopyPasteSupport method deserializeComponents.
@Nullable
private static ArrayList<RadComponent> deserializeComponents(final GuiEditor editor, final String serializedComponents) {
ArrayList<RadComponent> components = new ArrayList<>();
TIntArrayList xs = new TIntArrayList();
TIntArrayList ys = new TIntArrayList();
if (!loadComponentsToPaste(editor, serializedComponents, xs, ys, components)) {
return null;
}
return components;
}
Aggregations