mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-30 02:09:59 +07:00
Java: minor cleanup
GitOrigin-RevId: 3089bdc43162d6c63addd3d6e075bff4830160b2
This commit is contained in:
committed by
intellij-monorepo-bot
parent
1143fea0b7
commit
f3f0542bd9
@@ -18,7 +18,7 @@ public class PsiArrayInitializerExpressionImpl extends ExpressionPsiElement impl
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiExpression @NotNull [] getInitializers(){
|
||||
public PsiExpression @NotNull [] getInitializers() {
|
||||
return getChildrenAsPsiElements(ElementType.EXPRESSION_BIT_SET, PsiExpression.ARRAY_FACTORY);
|
||||
}
|
||||
|
||||
@@ -33,22 +33,22 @@ public class PsiArrayInitializerExpressionImpl extends ExpressionPsiElement impl
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiType getType(){
|
||||
if (getTreeParent() instanceof PsiNewExpression){
|
||||
public PsiType getType() {
|
||||
if (getTreeParent() instanceof PsiNewExpression) {
|
||||
if (getTreeParent().getChildRole(this) == ChildRole.ARRAY_INITIALIZER){
|
||||
return ((PsiNewExpression)getTreeParent()).getType();
|
||||
}
|
||||
}
|
||||
else if (getTreeParent() instanceof PsiVariable){
|
||||
else if (getTreeParent() instanceof PsiVariable) {
|
||||
return ((PsiVariable)getTreeParent()).getType();
|
||||
}
|
||||
else if (getTreeParent() instanceof PsiArrayInitializerExpression){
|
||||
else if (getTreeParent() instanceof PsiArrayInitializerExpression) {
|
||||
PsiType parentType = ((PsiArrayInitializerExpression)getTreeParent()).getType();
|
||||
if (!(parentType instanceof PsiArrayType)) return null;
|
||||
final PsiType componentType = ((PsiArrayType)parentType).getComponentType();
|
||||
return componentType instanceof PsiArrayType ? componentType : null;
|
||||
}
|
||||
else if (getTreeParent() instanceof FieldElement){
|
||||
else if (getTreeParent() instanceof FieldElement) {
|
||||
return ((PsiField)getParent()).getType();
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ public class PsiArrayInitializerExpressionImpl extends ExpressionPsiElement impl
|
||||
@Override
|
||||
public ASTNode findChildByRole(int role) {
|
||||
LOG.assertTrue(ChildRole.isUnique(role));
|
||||
switch(role){
|
||||
switch (role) {
|
||||
case ChildRole.LBRACE:
|
||||
return findChildByType(JavaTokenType.LBRACE);
|
||||
|
||||
@@ -83,12 +83,10 @@ public class PsiArrayInitializerExpressionImpl extends ExpressionPsiElement impl
|
||||
else if (i == JavaTokenType.RBRACE) {
|
||||
return ChildRole.RBRACE;
|
||||
}
|
||||
else {
|
||||
if (ElementType.EXPRESSION_BIT_SET.contains(child.getElementType())) {
|
||||
return ChildRole.EXPRESSION_IN_LIST;
|
||||
}
|
||||
return ChildRoleBase.NONE;
|
||||
else if (ElementType.EXPRESSION_BIT_SET.contains(child.getElementType())) {
|
||||
return ChildRole.EXPRESSION_IN_LIST;
|
||||
}
|
||||
return ChildRoleBase.NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -108,12 +106,12 @@ public class PsiArrayInitializerExpressionImpl extends ExpressionPsiElement impl
|
||||
|
||||
@Override
|
||||
public TreeElement addInternal(TreeElement first, ASTNode last, ASTNode anchor, Boolean before) {
|
||||
if (anchor == null){
|
||||
if (before == null || before.booleanValue()){
|
||||
if (anchor == null) {
|
||||
if (before == null || before.booleanValue()) {
|
||||
anchor = findChildByRole(ChildRole.RBRACE);
|
||||
before = Boolean.TRUE;
|
||||
}
|
||||
else{
|
||||
else {
|
||||
anchor = findChildByRole(ChildRole.LBRACE);
|
||||
before = Boolean.FALSE;
|
||||
}
|
||||
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.psi.impl.source.tree.java;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
@@ -21,12 +7,10 @@ import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.source.tree.*;
|
||||
import com.intellij.psi.tree.ChildRoleBase;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PsiArrayInitializerMemberValueImpl extends CompositePsiElement implements PsiArrayInitializerMemberValue {
|
||||
private static final Logger LOG = Logger.getInstance(PsiArrayInitializerMemberValueImpl.class);
|
||||
private static final TokenSet MEMBER_SET = ElementType.ANNOTATION_MEMBER_VALUE_BIT_SET;
|
||||
|
||||
public PsiArrayInitializerMemberValueImpl() {
|
||||
super(JavaElementType.ANNOTATION_ARRAY_INITIALIZER);
|
||||
@@ -34,7 +18,7 @@ public class PsiArrayInitializerMemberValueImpl extends CompositePsiElement impl
|
||||
|
||||
@Override
|
||||
public PsiAnnotationMemberValue @NotNull [] getInitializers() {
|
||||
return getChildrenAsPsiElements(MEMBER_SET, PsiAnnotationMemberValue.ARRAY_FACTORY);
|
||||
return getChildrenAsPsiElements(ElementType.ANNOTATION_MEMBER_VALUE_BIT_SET, PsiAnnotationMemberValue.ARRAY_FACTORY);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -67,7 +51,7 @@ public class PsiArrayInitializerMemberValueImpl extends CompositePsiElement impl
|
||||
if (i == JavaTokenType.RBRACE) {
|
||||
return ChildRole.RBRACE;
|
||||
}
|
||||
if (MEMBER_SET.contains(child.getElementType())) {
|
||||
if (ElementType.ANNOTATION_MEMBER_VALUE_BIT_SET.contains(child.getElementType())) {
|
||||
return ChildRole.ANNOTATION_VALUE;
|
||||
}
|
||||
return ChildRoleBase.NONE;
|
||||
@@ -75,9 +59,10 @@ public class PsiArrayInitializerMemberValueImpl extends CompositePsiElement impl
|
||||
|
||||
@Override
|
||||
public TreeElement addInternal(TreeElement first, ASTNode last, ASTNode anchor, Boolean before) {
|
||||
if (MEMBER_SET.contains(first.getElementType()) && MEMBER_SET.contains(last.getElementType())) {
|
||||
if (ElementType.ANNOTATION_MEMBER_VALUE_BIT_SET.contains(first.getElementType())
|
||||
&& ElementType.ANNOTATION_MEMBER_VALUE_BIT_SET.contains(last.getElementType())) {
|
||||
TreeElement firstAdded = super.addInternal(first, last, anchor, before);
|
||||
JavaSourceUtil.addSeparatingComma(this, first, MEMBER_SET);
|
||||
JavaSourceUtil.addSeparatingComma(this, first, ElementType.ANNOTATION_MEMBER_VALUE_BIT_SET);
|
||||
return firstAdded;
|
||||
}
|
||||
|
||||
@@ -86,7 +71,7 @@ public class PsiArrayInitializerMemberValueImpl extends CompositePsiElement impl
|
||||
|
||||
@Override
|
||||
public void deleteChildInternal(@NotNull ASTNode child) {
|
||||
if (MEMBER_SET.contains(child.getElementType())) {
|
||||
if (ElementType.ANNOTATION_MEMBER_VALUE_BIT_SET.contains(child.getElementType())) {
|
||||
JavaSourceUtil.deleteSeparatingComma(this, child);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user