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.
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
;
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>");
41 Set
<String
> names
= new LinkedHashSet
<String
>();
42 for (PsiElement element
: elements
) {
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());
59 @NonNls String sep
= "";
60 for (String name
: names
) {
66 result
.append("</body></html>");
67 return result
.toString();