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 org
.jetbrains
.plugins
.groovy
.codeInsight
;
18 import com
.intellij
.codeHighlighting
.Pass
;
19 import com
.intellij
.codeInsight
.daemon
.DaemonCodeAnalyzerSettings
;
20 import com
.intellij
.codeInsight
.daemon
.LineMarkerInfo
;
21 import com
.intellij
.codeInsight
.daemon
.impl
.JavaLineMarkerProvider
;
22 import com
.intellij
.lang
.ASTNode
;
23 import com
.intellij
.openapi
.editor
.colors
.CodeInsightColors
;
24 import com
.intellij
.openapi
.editor
.colors
.EditorColorsManager
;
25 import com
.intellij
.openapi
.editor
.colors
.EditorColorsScheme
;
26 import com
.intellij
.openapi
.editor
.markup
.GutterIconRenderer
;
27 import com
.intellij
.openapi
.editor
.markup
.SeparatorPlacement
;
28 import com
.intellij
.psi
.*;
29 import com
.intellij
.util
.NullableFunction
;
30 import org
.jetbrains
.plugins
.groovy
.lang
.groovydoc
.psi
.api
.GrDocComment
;
31 import org
.jetbrains
.plugins
.groovy
.lang
.groovydoc
.psi
.api
.GrDocCommentOwner
;
32 import org
.jetbrains
.plugins
.groovy
.lang
.lexer
.TokenSets
;
34 import java
.util
.Collection
;
35 import java
.util
.List
;
39 * Same logic as for Java LMP
41 public class GroovyLineMarkerProvider
extends JavaLineMarkerProvider
{
43 public GroovyLineMarkerProvider(DaemonCodeAnalyzerSettings daemonSettings
, EditorColorsManager colorsManager
) {
44 super(daemonSettings
, colorsManager
);
48 public LineMarkerInfo
getLineMarkerInfo(final PsiElement element
) {
49 final PsiElement parent
= element
.getParent();
50 if (parent
instanceof PsiNameIdentifierOwner
) {
51 final ASTNode node
= element
.getNode();
52 if (node
!= null && TokenSets
.PROPERTY_NAMES
.contains(node
.getElementType())) {
53 return super.getLineMarkerInfo(((PsiNameIdentifierOwner
)parent
).getNameIdentifier());
56 //need to draw method separator above docComment
57 if (myDaemonSettings
.SHOW_METHOD_SEPARATORS
&& element
.getFirstChild() == null) {
58 PsiElement element1
= element
;
59 boolean isMember
= false;
60 while (element1
!= null && !(element1
instanceof PsiFile
) && element1
.getPrevSibling() == null) {
61 element1
= element1
.getParent();
62 if (element1
instanceof PsiMember
) {
67 if (isMember
&& !(element1
instanceof PsiAnonymousClass
|| element1
.getParent() instanceof PsiAnonymousClass
)) {
68 boolean drawSeparator
= false;
69 int category
= getCategory(element1
);
70 for (PsiElement child
= element1
.getPrevSibling(); child
!= null; child
= child
.getPrevSibling()) {
71 int category1
= getCategory(child
);
72 if (category1
== 0) continue;
73 drawSeparator
= category
!= 1 || category1
!= 1;
78 GrDocComment comment
= null;
79 if (element1
instanceof GrDocCommentOwner
) {
80 comment
= ((GrDocCommentOwner
)element1
).getDocComment();
83 new LineMarkerInfo
<PsiElement
>(element
, comment
!= null ? comment
.getTextRange() : element
.getTextRange(), null,
84 Pass
.UPDATE_ALL
, NullableFunction
.NULL
, null,
85 GutterIconRenderer
.Alignment
.RIGHT
);
86 EditorColorsScheme scheme
= myColorsManager
.getGlobalScheme();
87 info
.separatorColor
= scheme
.getColor(CodeInsightColors
.METHOD_SEPARATORS_COLOR
);
88 info
.separatorPlacement
= SeparatorPlacement
.TOP
;
94 return super.getLineMarkerInfo(element
);
98 public void collectSlowLineMarkers(final List
<PsiElement
> elements
, final Collection
<LineMarkerInfo
> result
) {
99 super.collectSlowLineMarkers(elements
, result
);