use of com.intellij.util.containers.IntArrayList in project intellij-community by JetBrains.
the class CaptionPanel method update.
public void update() {
List<RadComponent> selection = myMainArea.getSelection();
if (selection.size() != 1) {
if (myCaption != null) {
myCaption = null;
myRootComponent.setLayout(null);
myRootChildren = Collections.emptyList();
myArea.deselectAll();
revalidate();
repaint();
}
return;
}
boolean update = !myRootChildren.isEmpty();
IntArrayList oldSelection = null;
if (myCaption != null) {
oldSelection = new IntArrayList();
for (RadComponent component : myArea.getSelection()) {
oldSelection.add(myRootChildren.indexOf(component));
}
}
myArea.deselectAll();
myRootComponent.setLayout(null);
ICaption caption = null;
RadComponent component = selection.get(0);
RadComponent parent = component.getParent();
if (parent != null) {
caption = parent.getLayout().getCaption(component);
}
if (caption == null) {
caption = component.getCaption();
}
if (caption == null) {
myRootChildren = Collections.emptyList();
} else {
myRootComponent.setLayout(caption.getCaptionLayout(myMainArea, myHorizontal));
myRootChildren = caption.getCaptionChildren(myMainArea, myHorizontal);
for (RadComponent child : myRootChildren) {
child.setParent(myRootComponent);
}
if (myCaption == caption) {
List<RadComponent> newSelection = new ArrayList<>();
int componentSize = myRootChildren.size();
int selectionSize = oldSelection.size();
for (int i = 0; i < selectionSize; i++) {
int index = oldSelection.get(i);
if (0 <= index && index < componentSize) {
newSelection.add(myRootChildren.get(index));
}
}
if (!newSelection.isEmpty()) {
myArea.setSelection(newSelection);
}
}
update |= !myRootChildren.isEmpty();
}
myCaption = caption;
if (update) {
revalidate();
repaint();
}
}
use of com.intellij.util.containers.IntArrayList in project intellij-community by JetBrains.
the class DesignerEditorPanel method getSelectionState.
protected static int[][] getSelectionState(List<RadComponent> selection) {
int[][] selectionState = new int[selection.size()][];
for (int i = 0; i < selectionState.length; i++) {
IntArrayList path = new IntArrayList();
componentToPath(selection.get(i), path);
selectionState[i] = path.toArray();
}
return selectionState;
}
use of com.intellij.util.containers.IntArrayList in project intellij-community by JetBrains.
the class FindUsagesTest method testOverloadConstructors.
public void testOverloadConstructors() throws Exception {
PsiClass aClass = myJavaFacade.findClass("B", GlobalSearchScope.allScope(myProject));
PsiMethod constructor = aClass.findMethodsByName("B", false)[0];
PsiMethodCallExpression superCall = (PsiMethodCallExpression) constructor.getBody().getStatements()[0].getFirstChild();
PsiReferenceExpression superExpr = superCall.getMethodExpression();
String[] fileNames = { "B.java", "A.java", "A.java", "B.java" };
int[] starts = {};
int[] ends = {};
final ArrayList<PsiFile> filesList = new ArrayList<>();
final IntArrayList startsList = new IntArrayList();
final IntArrayList endsList = new IntArrayList();
PsiReference[] refs = MethodReferencesSearch.search((PsiMethod) superExpr.resolve(), GlobalSearchScope.projectScope(myProject), false).toArray(PsiReference.EMPTY_ARRAY);
for (PsiReference ref : refs) {
addReference(ref, filesList, startsList, endsList);
}
checkResult(fileNames, filesList, starts, startsList, ends, endsList);
}
use of com.intellij.util.containers.IntArrayList in project intellij-community by JetBrains.
the class FindUsagesTest method doTest.
public static void doTest(PsiElement element, String[] fileNames, int[] starts, int[] ends) throws Exception {
final ArrayList<PsiFile> filesList = new ArrayList<>();
final IntArrayList startsList = new IntArrayList();
final IntArrayList endsList = new IntArrayList();
ReferencesSearch.search(element, GlobalSearchScope.projectScope(element.getProject()), false).forEach(new PsiReferenceProcessorAdapter(new PsiReferenceProcessor() {
@Override
public boolean execute(PsiReference ref) {
addReference(ref, filesList, startsList, endsList);
return true;
}
}));
checkResult(fileNames, filesList, starts, startsList, ends, endsList);
}
use of com.intellij.util.containers.IntArrayList in project intellij-community by JetBrains.
the class PlainTextUsagesTest method doTest.
private void doTest(String qNameToSearch, final PsiElement originalElement, String[] fileNames, int[] starts, int[] ends) throws Exception {
PsiSearchHelper helper = PsiSearchHelper.SERVICE.getInstance(myProject);
final List<PsiFile> filesList = new ArrayList<>();
final IntArrayList startsList = new IntArrayList();
final IntArrayList endsList = new IntArrayList();
helper.processUsagesInNonJavaFiles(originalElement, qNameToSearch, new PsiNonJavaFileReferenceProcessor() {
@Override
public boolean process(PsiFile file, int startOffset, int endOffset) {
filesList.add(file);
startsList.add(startOffset);
endsList.add(endOffset);
return true;
}
}, GlobalSearchScope.projectScope(myProject));
assertEquals("usages count", fileNames.length, filesList.size());
for (int i = 0; i < fileNames.length; i++) {
assertEquals("files[" + i + "]", fileNames[i], filesList.get(i).getName());
}
for (int i = 0; i < starts.length; i++) {
assertEquals("starts[" + i + "]", starts[i], startsList.get(i));
}
for (int i = 0; i < ends.length; i++) {
assertEquals("ends[" + i + "]", ends[i], endsList.get(i));
}
}
Aggregations