update copyright
[fedora-idea.git] / java / java-impl / src / com / intellij / ide / projectView / impl / nodes / PsiMethodNode.java
blob6eae9464edede3dd763fda7c7a3055ebfb797fa1
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.projectView.impl.nodes;
18 import com.intellij.ide.projectView.PresentationData;
19 import com.intellij.ide.projectView.ViewSettings;
20 import com.intellij.ide.util.treeView.AbstractTreeNode;
21 import com.intellij.openapi.project.Project;
22 import com.intellij.psi.PsiClass;
23 import com.intellij.psi.PsiMethod;
24 import com.intellij.psi.PsiSubstitutor;
25 import com.intellij.psi.util.PsiFormatUtil;
27 import java.util.Collection;
29 public class PsiMethodNode extends BasePsiMemberNode<PsiMethod>{
30 public PsiMethodNode(Project project, PsiMethod value, ViewSettings viewSettings) {
31 super(project, value, viewSettings);
34 public Collection<AbstractTreeNode> getChildrenImpl() {
35 return null;
38 public void updateImpl(PresentationData data) {
39 String name = PsiFormatUtil.formatMethod(
40 getValue(),
41 PsiSubstitutor.EMPTY, PsiFormatUtil.SHOW_NAME | PsiFormatUtil.SHOW_TYPE | PsiFormatUtil.TYPE_AFTER | PsiFormatUtil.SHOW_PARAMETERS,
42 PsiFormatUtil.SHOW_TYPE
44 int c = name.indexOf('\n');
45 if (c > -1) {
46 name = name.substring(0, c - 1);
48 data.setPresentableText(name);
51 public boolean isConstructor() {
52 final PsiMethod psiMethod = getValue();
53 return psiMethod != null && psiMethod.isConstructor();
56 public int getWeight() {
57 return isConstructor() ? 40 : 50;
60 @Override
61 public String getTitle() {
62 final PsiMethod method = getValue();
63 if (method != null) {
64 PsiClass aClass = method.getContainingClass();
65 if (aClass != null) {
66 return aClass.getQualifiedName();
68 else {
69 return method.toString();
72 return super.getTitle();