Search in sources :

Example 81 with TIntArrayList

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);
    }
}
Also used : TIntArrayList(gnu.trove.TIntArrayList)

Example 82 with TIntArrayList

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;
}
Also used : LightweightHint(com.intellij.ui.LightweightHint) TIntArrayList(gnu.trove.TIntArrayList)

Example 83 with TIntArrayList

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;
}
Also used : MethodCandidateInfo(com.intellij.psi.infos.MethodCandidateInfo) CandidateInfo(com.intellij.psi.infos.CandidateInfo) MethodCandidateInfo(com.intellij.psi.infos.MethodCandidateInfo) TIntArrayList(gnu.trove.TIntArrayList)

Example 84 with TIntArrayList

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);
}
Also used : GrVariable(org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable) GrExpression(org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression) TIntArrayList(gnu.trove.TIntArrayList) PsiType(com.intellij.psi.PsiType) Nullable(org.jetbrains.annotations.Nullable)

Example 85 with TIntArrayList

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;
}
Also used : ArrayList(java.util.ArrayList) TIntArrayList(gnu.trove.TIntArrayList) RadComponent(com.intellij.uiDesigner.radComponents.RadComponent) TIntArrayList(gnu.trove.TIntArrayList) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

TIntArrayList (gnu.trove.TIntArrayList)104 NotNull (org.jetbrains.annotations.NotNull)34 ArrayList (java.util.ArrayList)9 List (java.util.List)7 Nullable (org.jetbrains.annotations.Nullable)7 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 ArrangementMatchingRulesControl (com.intellij.application.options.codeStyle.arrangement.match.ArrangementMatchingRulesControl)3 StringSearcher (com.intellij.util.text.StringSearcher)3 TIntHashSet (gnu.trove.TIntHashSet)3 TIntProcedure (gnu.trove.TIntProcedure)3 IOException (java.io.IOException)3 IDevice (com.android.ddmlib.IDevice)2 ArrangementMatchingRulesModel (com.intellij.application.options.codeStyle.arrangement.match.ArrangementMatchingRulesModel)2 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)2 Project (com.intellij.openapi.project.Project)2 TextRange (com.intellij.openapi.util.TextRange)2 ElementToWorkOn (com.intellij.refactoring.introduceField.ElementToWorkOn)2 IntroduceParameterProcessor (com.intellij.refactoring.introduceParameter.IntroduceParameterProcessor)2 RelativePoint (com.intellij.ui.awt.RelativePoint)2 RadComponent (com.intellij.uiDesigner.radComponents.RadComponent)2