Search in sources :

Example 1 with IntArrayList

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();
    }
}
Also used : RadComponent(com.intellij.designer.model.RadComponent) IntArrayList(com.intellij.util.containers.IntArrayList) ArrayList(java.util.ArrayList) IntArrayList(com.intellij.util.containers.IntArrayList)

Example 2 with IntArrayList

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;
}
Also used : IntArrayList(com.intellij.util.containers.IntArrayList)

Example 3 with IntArrayList

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);
}
Also used : IntArrayList(com.intellij.util.containers.IntArrayList) ArrayList(java.util.ArrayList) IntArrayList(com.intellij.util.containers.IntArrayList)

Example 4 with IntArrayList

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);
}
Also used : IntArrayList(com.intellij.util.containers.IntArrayList) ArrayList(java.util.ArrayList) IntArrayList(com.intellij.util.containers.IntArrayList)

Example 5 with IntArrayList

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));
    }
}
Also used : IntArrayList(com.intellij.util.containers.IntArrayList) ArrayList(java.util.ArrayList) PsiFile(com.intellij.psi.PsiFile) IntArrayList(com.intellij.util.containers.IntArrayList)

Aggregations

IntArrayList (com.intellij.util.containers.IntArrayList)31 ArrayList (java.util.ArrayList)5 PsiFile (com.intellij.psi.PsiFile)3 NotNull (org.jetbrains.annotations.NotNull)3 TextRange (com.intellij.openapi.util.TextRange)2 Nullable (org.jetbrains.annotations.Nullable)2 ExceptionUtil (com.intellij.codeInsight.ExceptionUtil)1 RadComponent (com.intellij.designer.model.RadComponent)1 LighterASTNode (com.intellij.lang.LighterASTNode)1 Logger (com.intellij.openapi.diagnostic.Logger)1 RangeMarker (com.intellij.openapi.editor.RangeMarker)1 Project (com.intellij.openapi.project.Project)1 com.intellij.psi (com.intellij.psi)1 PsiCodeBlock (com.intellij.psi.PsiCodeBlock)1 PsiElement (com.intellij.psi.PsiElement)1 PsiJavaFile (com.intellij.psi.PsiJavaFile)1 DummyHolder (com.intellij.psi.impl.source.DummyHolder)1 MethodSignature (com.intellij.psi.util.MethodSignature)1 PsiTreeUtil (com.intellij.psi.util.PsiTreeUtil)1 PsiUtil (com.intellij.psi.util.PsiUtil)1