update copyright
[fedora-idea.git] / java / java-impl / src / com / intellij / codeInsight / daemon / impl / analysis / HighlightMessageUtil.java
blob577e2e4ee28de6311a72320823bca9f2d12160b5
2 /*
3 * Copyright 2000-2009 JetBrains s.r.o.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 package com.intellij.codeInsight.daemon.impl.analysis;
19 import com.intellij.lang.LangBundle;
20 import com.intellij.psi.*;
21 import com.intellij.psi.util.PsiFormatUtil;
22 import org.jetbrains.annotations.NotNull;
24 public class HighlightMessageUtil {
25 public static String getSymbolName(@NotNull PsiElement symbol, PsiSubstitutor substitutor) {
26 String symbolName = null;
27 if (symbol instanceof PsiClass) {
28 if (symbol instanceof PsiAnonymousClass){
29 symbolName = LangBundle.message("java.terms.anonymous.class");
31 else{
32 symbolName = ((PsiClass)symbol).getQualifiedName();
33 if (symbolName == null) {
34 symbolName = ((PsiClass)symbol).getName();
38 else if (symbol instanceof PsiMethod) {
39 symbolName = PsiFormatUtil.formatMethod((PsiMethod)symbol,
40 substitutor, PsiFormatUtil.SHOW_NAME | PsiFormatUtil.SHOW_PARAMETERS,
41 PsiFormatUtil.SHOW_TYPE | PsiFormatUtil.SHOW_FQ_CLASS_NAMES
44 else if (symbol instanceof PsiVariable) {
45 symbolName = ((PsiVariable)symbol).getName();
47 else if (symbol instanceof PsiPackage) {
48 symbolName = ((PsiPackage)symbol).getQualifiedName();
50 else if (symbol instanceof PsiJavaFile) {
51 PsiDirectory directory = ((PsiJavaFile) symbol).getContainingDirectory();
52 PsiPackage aPackage = directory == null ? null : JavaDirectoryService.getInstance().getPackage(directory);
53 symbolName = aPackage == null ? null : aPackage.getQualifiedName();
55 else if (symbol instanceof PsiDirectory){
56 symbolName = ((PsiDirectory) symbol).getName();
58 return symbolName;