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() {
38 public void updateImpl(PresentationData data
) {
39 String name
= PsiFormatUtil
.formatMethod(
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');
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;
61 public String
getTitle() {
62 final PsiMethod method
= getValue();
64 PsiClass aClass
= method
.getContainingClass();
66 return aClass
.getQualifiedName();
69 return method
.toString();
72 return super.getTitle();