Search in sources :

Example 96 with TIntArrayList

use of gnu.trove.TIntArrayList in project intellij-community by JetBrains.

the class JUnitConfigurable method onTypeChanged.

public void onTypeChanged(final int newType) {
    myTypeChooser.setSelectedItem(newType);
    final TIntArrayList enabledFields = ourEnabledFields.get(newType);
    for (int i = 0; i < myTestLocations.length; i++) getTestLocation(i).setEnabled(enabledFields.contains(i));
    /*if (newType == JUnitConfigurationModel.PATTERN) {
      myModule.setEnabled(false);
    } else */
    if (newType != JUnitConfigurationModel.ALL_IN_PACKAGE && newType != JUnitConfigurationModel.PATTERN && newType != JUnitConfigurationModel.CATEGORY) {
        myModule.setEnabled(true);
    } else {
        onScopeChanged();
    }
}
Also used : TIntArrayList(gnu.trove.TIntArrayList)

Example 97 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 98 with TIntArrayList

use of gnu.trove.TIntArrayList in project intellij-community by JetBrains.

the class PyNewStyleStringFormatParser method parseField.

@NotNull
private Field parseField(int startOffset, int recursionDepth) {
    assert myNodeText.charAt(startOffset) == '{';
    int autoFieldNumber = myImplicitlyNumberedFieldsCounter;
    // in the order of appearance inside a field
    final TIntArrayList attrAndLookupBounds = new TIntArrayList();
    int conversionStart = -1;
    int formatSpecStart = -1;
    final List<Field> nestedFields = new ArrayList<>();
    int rightBraceOffset = -1;
    boolean insideItem = false;
    boolean recovering = false;
    final int contentEnd = myNodeContentRange.getEndOffset();
    int offset = startOffset + 1;
    while (offset < contentEnd) {
        final int nextOffset = skipNamedUnicodeEscape(offset);
        if (offset != nextOffset) {
            offset = nextOffset;
            continue;
        }
        final char c = myNodeText.charAt(offset);
        // inside "name" part of the field
        if (conversionStart == -1 && formatSpecStart == -1) {
            // '{' can appear inside a lookup item, but everywhere else it means that field ends
            if (insideItem) {
                // inside lookup item skip everything up to the closing bracket
                if (c == ']') {
                    insideItem = false;
                    // remember the end offset of the lookup now, since later we may enter "recovering" state
                    attrAndLookupBounds.add(offset + 1);
                    // if the next character is neither '.', not '[' stop matching attributes and lookups here
                    recovering = offset + 1 < contentEnd && !isAnyCharOf(myNodeText.charAt(offset + 1), ".[");
                }
            } else if (isAnyCharOf(c, "[.:!}")) {
                insideItem = c == '[';
                if (!recovering) {
                    // avoid duplicate offsets in sequences like "]." or "]["
                    addIfNotLastItem(attrAndLookupBounds, offset);
                    // no name in the field, increment implicitly named fields counter
                    if (attrAndLookupBounds.size() == 1 && attrAndLookupBounds.get(0) == startOffset + 1) {
                        myImplicitlyNumberedFieldsCounter++;
                    }
                }
                if (c == ':') {
                    formatSpecStart = offset;
                } else if (c == '!') {
                    conversionStart = offset;
                } else if (c == '}') {
                    rightBraceOffset = offset;
                    break;
                }
            }
        } else if (c == '}') {
            rightBraceOffset = offset;
            break;
        } else if (conversionStart >= 0) {
            if (c == ':') {
                formatSpecStart = offset;
            }
        } else if (formatSpecStart >= 0) {
            if (c == '{') {
                final Field field = parseField(offset, recursionDepth + 1);
                nestedFields.add(field);
                offset = field.getFieldEnd();
                continue;
            }
        }
        offset++;
    }
    // finish with the trailing attribute or the first name if the field ended unexpectedly
    if (offset >= contentEnd && conversionStart == -1 && formatSpecStart == -1 && !insideItem && !recovering) {
        addIfNotLastItem(attrAndLookupBounds, contentEnd);
    }
    assert !attrAndLookupBounds.isEmpty();
    return new Field(myNodeText, startOffset, attrAndLookupBounds.toNativeArray(), conversionStart, formatSpecStart, nestedFields, rightBraceOffset, rightBraceOffset == -1 ? contentEnd : rightBraceOffset + 1, autoFieldNumber, recursionDepth);
}
Also used : TIntArrayList(gnu.trove.TIntArrayList) ArrayList(java.util.ArrayList) TIntArrayList(gnu.trove.TIntArrayList) NotNull(org.jetbrains.annotations.NotNull)

Example 99 with TIntArrayList

use of gnu.trove.TIntArrayList in project intellij-community by JetBrains.

the class XmlTextImpl method getValue.

@Override
public String getValue() {
    String displayText = myDisplayText;
    if (displayText != null)
        return displayText;
    StringBuilder buffer = new StringBuilder();
    ASTNode child = getFirstChildNode();
    final TIntArrayList gapsStarts = new TIntArrayList();
    final TIntArrayList gapsShifts = new TIntArrayList();
    while (child != null) {
        final int start = buffer.length();
        IElementType elementType = child.getElementType();
        if (elementType == XmlElementType.XML_CDATA) {
            final ASTNode cdata = child;
            child = cdata.getFirstChildNode();
        } else if (elementType == XmlTokenType.XML_CHAR_ENTITY_REF) {
            String text = child.getText();
            LOG.assertTrue(text != null, child);
            buffer.append(XmlUtil.getCharFromEntityRef(text));
        } else if (elementType == XmlTokenType.XML_WHITE_SPACE || elementType == XmlTokenType.XML_DATA_CHARACTERS || elementType == XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN) {
            buffer.append(child.getText());
        } else if (elementType == TokenType.ERROR_ELEMENT || elementType == TokenType.NEW_LINE_INDENT) {
            buffer.append(child.getText());
        }
        int end = buffer.length();
        int originalLength = child.getTextLength();
        if (end - start != originalLength) {
            gapsStarts.add(end);
            gapsShifts.add(originalLength - (end - start));
        }
        final ASTNode next = child.getTreeNext();
        if (next == null && child.getTreeParent().getElementType() == XmlElementType.XML_CDATA) {
            child = child.getTreeParent().getTreeNext();
        } else {
            child = next;
        }
    }
    int[] gapDisplayStarts = ArrayUtil.newIntArray(gapsShifts.size());
    int[] gapPhysicalStarts = ArrayUtil.newIntArray(gapsShifts.size());
    int currentGapsSum = 0;
    for (int i = 0; i < gapDisplayStarts.length; i++) {
        currentGapsSum += gapsShifts.get(i);
        gapDisplayStarts[i] = gapsStarts.get(i);
        gapPhysicalStarts[i] = gapDisplayStarts[i] + currentGapsSum;
    }
    myGapDisplayStarts = gapDisplayStarts;
    myGapPhysicalStarts = gapPhysicalStarts;
    String text = buffer.toString();
    myDisplayText = text;
    return text;
}
Also used : IElementType(com.intellij.psi.tree.IElementType) ASTNode(com.intellij.lang.ASTNode) TIntArrayList(gnu.trove.TIntArrayList)

Example 100 with TIntArrayList

use of gnu.trove.TIntArrayList in project android by JetBrains.

the class BaseAxisFormatter method getInterval.

/**
   * Determines the interval value for a particular range given the number of ticks that should be used.
   */
public long getInterval(double range, int numTicks) {
    int index = getMultiplierIndex(range, mSwitchThreshold);
    int base = getUnitBase(index);
    int minInterval = getUnitMinimalInterval(index);
    TIntArrayList factors = getUnitBaseFactors(index);
    return getInterval(range / mMultiplier, numTicks, base, minInterval, factors) * mMultiplier;
}
Also used : TIntArrayList(gnu.trove.TIntArrayList)

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