Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Merge remote-tracking branch 'origin/master' into develar/is
- Loading branch information
Showing
293 changed files
with
2,957 additions
and
1,832 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
java/java-impl/src/com/intellij/codeInsight/daemon/JavaRainbowVisitor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* 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. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.intellij.codeInsight.daemon; | ||
|
||
import com.intellij.codeHighlighting.RainbowHighlighter; | ||
import com.intellij.codeInsight.daemon.impl.HighlightInfo; | ||
import com.intellij.codeInsight.daemon.impl.HighlightVisitor; | ||
import com.intellij.ide.highlighter.JavaHighlightingColors; | ||
import com.intellij.openapi.util.Pair; | ||
import com.intellij.psi.*; | ||
import com.intellij.psi.util.PsiTreeUtil; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class JavaRainbowVisitor extends RainbowVisitor { | ||
@Override | ||
public boolean suitableForFile(@NotNull PsiFile file) { | ||
return file instanceof PsiJavaFile; | ||
} | ||
|
||
@Override | ||
public void visit(@NotNull PsiElement element) { | ||
if (!RainbowHighlighter.isRainbowEnabled()) return; | ||
|
||
if (element instanceof PsiReferenceExpression | ||
|| element instanceof PsiLocalVariable | ||
|| element instanceof PsiParameter) { | ||
PsiElement context = PsiTreeUtil.findFirstParent(element, p -> p instanceof PsiMethod); | ||
if (context != null) { | ||
HighlightInfo attrs = getRainbowSymbolKey( | ||
context, | ||
element instanceof PsiReferenceExpression | ||
? Pair.create(element, ((PsiReferenceExpression)element).resolve()) | ||
: Pair.create(((PsiVariable)element).getNameIdentifier(), element)); | ||
if (attrs != null) { | ||
addInfo(attrs); | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Nullable | ||
private HighlightInfo getRainbowSymbolKey(@NotNull PsiElement context, @NotNull Pair<PsiElement, PsiElement> rainbow) { | ||
if (rainbow.first == null || rainbow.second == null) { | ||
return null; | ||
} | ||
if (rainbow.second instanceof PsiLocalVariable || rainbow.second instanceof PsiParameter) { | ||
String name = ((PsiVariable)rainbow.second).getName(); | ||
if (name != null) { | ||
return getInfo(context, rainbow.first, name, rainbow.second instanceof PsiLocalVariable | ||
? JavaHighlightingColors.LOCAL_VARIABLE_ATTRIBUTES | ||
: JavaHighlightingColors.PARAMETER_ATTRIBUTES); | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
@Override | ||
@NotNull | ||
public HighlightVisitor clone() { | ||
return new JavaRainbowVisitor(); | ||
} | ||
} | ||
|
Oops, something went wrong.