IDEA-57505 Support collection members

This commit is contained in:
Maxim Medvedev
2010-09-10 15:48:13 +04:00
parent e5ed4d7c57
commit 16fad73d84
7 changed files with 184 additions and 7 deletions
@@ -0,0 +1,85 @@
/*
* Copyright 2000-2010 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.
*/
package com.intellij.psi.impl.light;
import com.intellij.psi.*;
import com.intellij.psi.javadoc.PsiDocComment;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* @author Maxim.Medvedev
*/
public class LightFieldBuilder extends LightVariableBuilder<LightFieldBuilder> implements PsiField {
PsiClass myContainingClass = null;
PsiExpression myInitializer = null;
private PsiDocComment myDocComment = null;
private boolean myIsDeprecated = false;
public LightFieldBuilder(@NotNull String name, @NotNull String type, @NotNull PsiElement navigationElement) {
super(name, JavaPsiFacade.getElementFactory(navigationElement.getProject()).createTypeFromText(type, navigationElement),
navigationElement);
}
public LightFieldBuilder(@NotNull String name, @NotNull PsiType type, @NotNull PsiElement navigationElement) {
super(name, type, navigationElement);
}
public LightFieldBuilder(PsiManager manager, @NotNull String name, @NotNull PsiType type) {
super(manager, name, type);
}
public LightFieldBuilder setContainingClass(PsiClass psiClass) {
myContainingClass = psiClass;
return this;
}
@Override
public void setInitializer(@Nullable PsiExpression initializer) throws IncorrectOperationException {
myInitializer = initializer;
}
@Override
public PsiExpression getInitializer() {
return myInitializer;
}
@Override
public PsiDocComment getDocComment() {
return myDocComment;
}
public LightFieldBuilder setDocComment(PsiDocComment docComment) {
myDocComment = docComment;
return this;
}
@Override
public boolean isDeprecated() {
return myIsDeprecated;
}
public LightFieldBuilder setIsDeprecated(boolean isDeprecated) {
myIsDeprecated = isDeprecated;
return this;
}
@Override
public PsiClass getContainingClass() {
return myContainingClass;
}
}
@@ -14,7 +14,7 @@ import javax.swing.*;
/**
* @author peter
*/
public class LightVariableBuilder extends LightElement implements PsiVariable {
public class LightVariableBuilder<T extends LightVariableBuilder> extends LightElement implements PsiVariable {
private final String myName;
private final PsiType myType;
private volatile LightModifierList myModifierList;
@@ -53,9 +53,9 @@ public class LightVariableBuilder extends LightElement implements PsiVariable {
return myModifierList;
}
public LightVariableBuilder setModifiers(String... modifiers) {
public T setModifiers(String... modifiers) {
myModifierList = new LightModifierList(getManager(), getLanguage(), modifiers);
return this;
return (T)this;
}
@Override
@@ -112,10 +112,8 @@ public class LightVariableBuilder extends LightElement implements PsiVariable {
return ElementPresentationUtil.addVisibilityIcon(this, flags, baseIcon);
}
public LightVariableBuilder setBaseIcon(Icon baseIcon) {
public T setBaseIcon(Icon baseIcon) {
myBaseIcon = baseIcon;
return this;
return (T)this;
}
}