update copyright
[fedora-idea.git] / java / java-impl / src / com / intellij / codeInsight / daemon / impl / GutterIconTooltipHelper.java
blobfd4d1c69ae9f4baab81099f48013a309488224f0
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.
18 * @author max
20 package com.intellij.codeInsight.daemon.impl;
22 import com.intellij.psi.PsiClass;
23 import com.intellij.psi.PsiElement;
24 import com.intellij.psi.PsiFile;
25 import com.intellij.psi.PsiMethod;
26 import com.intellij.psi.presentation.java.ClassPresentationUtil;
27 import org.jetbrains.annotations.NonNls;
29 import java.text.MessageFormat;
30 import java.util.LinkedHashSet;
31 import java.util.Set;
33 public class GutterIconTooltipHelper {
34 private GutterIconTooltipHelper() {
37 public static String composeText(PsiElement[] elements, String start, final String pattern) {
38 @NonNls StringBuilder result = new StringBuilder();
39 result.append("<html><body>");
40 result.append(start);
41 Set<String> names = new LinkedHashSet<String>();
42 for (PsiElement element : elements) {
43 String descr = "";
44 if (element instanceof PsiClass) {
45 String className = ClassPresentationUtil.getNameForClass((PsiClass)element, true);
46 descr = MessageFormat.format(pattern, className);
48 else if (element instanceof PsiMethod) {
49 String methodName = ((PsiMethod)element).getName();
50 String className = ClassPresentationUtil.getNameForClass(((PsiMethod)element).getContainingClass(), true);
51 descr = MessageFormat.format(pattern, methodName, className);
53 else if (element instanceof PsiFile) {
54 descr = MessageFormat.format(pattern, ((PsiFile)element).getName());
56 names.add(descr);
59 @NonNls String sep = "";
60 for (String name : names) {
61 result.append(sep);
62 sep = "<br>";
63 result.append(name);
66 result.append("</body></html>");
67 return result.toString();