Search in sources :

Example 1 with PsiImportStatementBase

use of com.intellij.psi.PsiImportStatementBase in project intellij-community by JetBrains.

the class ImportListElement method addInternal.

@Override
public TreeElement addInternal(TreeElement first, ASTNode last, ASTNode anchor, Boolean before) {
    if (before == null) {
        if (first == last && (first.getElementType() == JavaElementType.IMPORT_STATEMENT || first.getElementType() == JavaElementType.IMPORT_STATIC_STATEMENT)) {
            final PsiImportList list = (PsiImportList) SourceTreeToPsiMap.treeElementToPsi(this);
            final PsiImportStatementBase statement = (PsiImportStatementBase) SourceTreeToPsiMap.treeElementToPsi(first);
            final JavaPsiImplementationHelper instance = JavaPsiImplementationHelper.getInstance(list.getProject());
            if (instance != null) {
                anchor = instance.getDefaultImportAnchor(list, statement);
            }
            before = Boolean.TRUE;
        }
    }
    return super.addInternal(first, last, anchor, before);
}
Also used : JavaPsiImplementationHelper(com.intellij.psi.impl.JavaPsiImplementationHelper) PsiImportStatementBase(com.intellij.psi.PsiImportStatementBase) PsiImportList(com.intellij.psi.PsiImportList)

Aggregations

PsiImportList (com.intellij.psi.PsiImportList)1 PsiImportStatementBase (com.intellij.psi.PsiImportStatementBase)1 JavaPsiImplementationHelper (com.intellij.psi.impl.JavaPsiImplementationHelper)1