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();
}
}
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 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);
}
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;
}
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;
}
Aggregations