update copyright
[fedora-idea.git] / java / java-impl / src / com / intellij / ide / structureView / impl / java / ClassInitializerTreeElement.java
blobccf7c6a30dc27ce1aead62ab15df2d1af02fb99c
1 /*
2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com.intellij.ide.structureView.impl.java;
18 import com.intellij.codeInsight.CodeInsightBundle;
19 import com.intellij.ide.structureView.StructureViewTreeElement;
20 import com.intellij.ide.structureView.impl.common.PsiTreeElementBase;
21 import com.intellij.openapi.util.text.StringUtil;
22 import com.intellij.psi.*;
23 import com.intellij.psi.util.PsiUtil;
24 import org.jetbrains.annotations.NotNull;
26 import java.util.Collection;
27 import java.util.Collections;
29 public class ClassInitializerTreeElement extends PsiTreeElementBase<PsiClassInitializer> implements AccessLevelProvider{
30 public ClassInitializerTreeElement(PsiClassInitializer initializer) {
31 super(initializer);
34 public String getPresentableText() {
35 PsiClassInitializer initializer = getElement();
36 assert initializer != null;
37 String isStatic = initializer.hasModifierProperty(PsiModifier.STATIC) ? PsiModifier.STATIC + " " : "";
38 return CodeInsightBundle.message("static.class.initializer", isStatic);
41 public String getLocationString() {
42 PsiClassInitializer initializer = getElement();
43 assert initializer != null;
44 PsiCodeBlock body = initializer.getBody();
45 PsiElement first = body.getFirstBodyElement();
46 if (first instanceof PsiWhiteSpace) first = first.getNextSibling();
47 if (first == body.getRBrace()) first = null;
48 if (first != null) {
49 return StringUtil.first(first.getText(), 20, true);
51 return null;
54 @NotNull
55 public Collection<StructureViewTreeElement> getChildrenBase() {
56 return Collections.emptyList();
59 public int getAccessLevel() {
60 return PsiUtil.ACCESS_LEVEL_PRIVATE;
63 public int getSubLevel() {
64 return 0;