diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/annotator/GrKeywordAndDeclarationHighlighter.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/annotator/GrKeywordAndDeclarationHighlighter.java
index 477d7065a1d1..0d991dc6fd64 100644
--- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/annotator/GrKeywordAndDeclarationHighlighter.java
+++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/annotator/GrKeywordAndDeclarationHighlighter.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2015 JetBrains s.r.o.
+ * Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -99,8 +99,8 @@ public class GrKeywordAndDeclarationHighlighter extends TextEditorHighlightingPa
if (parent instanceof GrArgumentLabel) return false; //don't highlight: print (void:'foo')
if (PsiTreeUtil.getParentOfType(element, GrCodeReferenceElement.class) != null) {
- if (token == GroovyTokenTypes.kDEF || token == GroovyTokenTypes.kIN || token == GroovyTokenTypes.kAS) {
- return false; //It is allowed to name packages 'as', 'in' or 'def'
+ if (TokenSets.CODE_REFERENCE_ELEMENT_NAME_TOKENS.contains(token)) {
+ return false; //It is allowed to name packages 'as', 'in', 'def' or 'trait'
}
}
else if (token == GroovyTokenTypes.kDEF && element.getParent() instanceof GrAnnotationNameValuePair) {
diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/lexer/TokenSets.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/lexer/TokenSets.java
index 6391a469680a..75f49e2d5882 100644
--- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/lexer/TokenSets.java
+++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/lexer/TokenSets.java
@@ -280,7 +280,8 @@ public abstract class TokenSets {
GroovyElementTypes.COMPOSITE_RSHIFT_SIGN,
GroovyElementTypes.COMPOSITE_TRIPLE_SHIFT_SIGN);
public static final TokenSet CODE_REFERENCE_ELEMENT_NAME_TOKENS = TokenSet.create(GroovyTokenTypes.mIDENT, GroovyTokenTypes.kDEF,
- GroovyTokenTypes.kIN, GroovyTokenTypes.kAS);
+ GroovyTokenTypes.kIN, GroovyTokenTypes.kAS,
+ GroovyTokenTypes.kTRAIT);
public static final TokenSet BLOCK_SET = TokenSet.create(GroovyElementTypes.CLOSABLE_BLOCK, GroovyElementTypes.BLOCK_STATEMENT,
GroovyElementTypes.CONSTRUCTOR_BODY, GroovyElementTypes.OPEN_BLOCK,
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GroovyHighlightingTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GroovyHighlightingTest.groovy
index 2099b57154d0..b3cc1ed2fffe 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GroovyHighlightingTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GroovyHighlightingTest.groovy
@@ -2011,4 +2011,14 @@ def foo = new Rrrrrrrr()
void testLocalVariableModifiers() { doTest() }
void testFieldModifiers() { doTest() }
+
+ void "test allow and do not highlight 'trait', 'as', 'def', 'in' within package"() {
+ myFixture.addClass '''\
+package a.b.c.trait.d.as.e.def.f.in.g;
+public class Foo {}
+'''
+ testHighlighting '''\
+import a.b.c.trait.d.as.e.def.f.in.g.*
+''', false, true
+ }
}