update copyright
[fedora-idea.git] / java / java-impl / src / com / intellij / ide / favoritesTreeView / smartPointerPsiNodes / MethodSmartPointerNode.java
blob9faedd1aa9dc0b193a7c53daba2b06f1364e0713
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.favoritesTreeView.smartPointerPsiNodes;
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.PsiMethod;
23 import com.intellij.psi.PsiSubstitutor;
24 import com.intellij.psi.SmartPointerManager;
25 import com.intellij.psi.SmartPsiElementPointer;
26 import com.intellij.psi.util.PsiFormatUtil;
27 import org.jetbrains.annotations.NotNull;
29 import java.util.Collection;
30 import java.util.Collections;
32 public class MethodSmartPointerNode extends BaseSmartPointerPsiNode<SmartPsiElementPointer>{
33 public MethodSmartPointerNode(Project project, PsiMethod value, ViewSettings viewSettings) {
34 super(project, SmartPointerManager.getInstance(project).createLazyPointer(value), viewSettings);
37 public MethodSmartPointerNode(final Project project, final Object value, final ViewSettings viewSettings) {
38 this(project, (PsiMethod)value, viewSettings);
41 @NotNull
42 public Collection<AbstractTreeNode> getChildrenImpl() {
43 return Collections.emptyList();
46 public void updateImpl(PresentationData data) {
47 String name = PsiFormatUtil.formatMethod(
48 (PsiMethod)getPsiElement(),
49 PsiSubstitutor.EMPTY, PsiFormatUtil.SHOW_NAME | PsiFormatUtil.SHOW_TYPE | PsiFormatUtil.TYPE_AFTER | PsiFormatUtil.SHOW_PARAMETERS,
50 PsiFormatUtil.SHOW_TYPE
52 int c = name.indexOf('\n');
53 if (c > -1) {
54 name = name.substring(0, c - 1);
56 data.setPresentableText(name);
59 public boolean isConstructor() {
60 final PsiMethod psiMethod = (PsiMethod)getPsiElement();
61 return psiMethod != null && psiMethod.isConstructor();