Merge branch 'master' of git.labs.intellij.net:idea/community

This commit is contained in:
Dmitry Jemerov
2010-11-12 14:58:38 +03:00
20 changed files with 560 additions and 470 deletions
@@ -21,6 +21,7 @@ import com.intellij.openapi.components.ProjectComponent;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiFile;
import com.intellij.util.messages.Topic;
import org.jetbrains.annotations.NotNull;
public abstract class DaemonCodeAnalyzer implements ProjectComponent {
@@ -50,4 +51,10 @@ public abstract class DaemonCodeAnalyzer implements ProjectComponent {
public abstract void restart(@NotNull PsiFile file);
public abstract void autoImportReferenceAtCursor(@NotNull Editor editor, @NotNull PsiFile file);
public static final Topic<DaemonListener> DAEMON_EVENT_TOPIC = new Topic<DaemonListener>("DAEMON_EVENT_TOPIC", DaemonListener.class);
public interface DaemonListener {
void daemonFinished();
}
}
@@ -680,7 +680,13 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
myAlarm.cancelAllRequests();
DaemonProgressIndicator progress;
synchronized (DaemonCodeAnalyzerImpl.this) {
progress = new DaemonProgressIndicator();
progress = new DaemonProgressIndicator() {
@Override
public void stopIfRunning() {
super.stopIfRunning();
myProject.getMessageBus().syncPublisher(DAEMON_EVENT_TOPIC).daemonFinished();
}
};
progress.start();
myUpdateProgress = progress;
}
@@ -37,28 +37,28 @@ import java.util.List;
public class Divider {
private static final int STARTING_TREE_HEIGHT = 10;
public static void getInsideAndOutside(@NotNull PsiFile file,
int startOffset,
int endOffset,
@NotNull TextRange range,
@NotNull List<PsiElement> inside,
@NotNull List<PsiElement> outside,
@NotNull HighlightLevelUtil.AnalysisLevel level) {
public static void divideInsideAndOutside(@NotNull PsiFile file,
int startOffset,
int endOffset,
@NotNull TextRange range,
@NotNull List<PsiElement> inside,
@NotNull List<PsiElement> outside,
@NotNull HighlightLevelUtil.AnalysisLevel level) {
final FileViewProvider viewProvider = file.getViewProvider();
for (Language language : viewProvider.getLanguages()) {
final PsiFile psiRoot = viewProvider.getPsi(language);
if (HighlightLevelUtil.shouldAnalyse(psiRoot, level)) {
getInsideAndOutside(psiRoot, startOffset, endOffset, range, inside, outside);
divideInsideAndOutside(psiRoot, startOffset, endOffset, range, inside, outside);
}
}
}
private static void getInsideAndOutside(@NotNull PsiFile root,
int startOffset,
int endOffset,
@NotNull TextRange range,
@NotNull List<PsiElement> inside,
@NotNull List<PsiElement> outside
private static void divideInsideAndOutside(@NotNull PsiFile root,
int startOffset,
int endOffset,
@NotNull TextRange range,
@NotNull List<PsiElement> inside,
@NotNull List<PsiElement> outside
) {
final int currentOffset = root.getTextRange().getStartOffset();
final Condition<PsiElement>[] filters = Extensions.getExtensions(CollectHighlightsUtil.EP_NAME);
@@ -92,6 +92,7 @@ public class GeneralHighlightingPass extends ProgressableTextEditorHighlightingP
}
};
private Runnable myApplyCommand;
private final EditorColorsScheme myGlobalScheme;
public GeneralHighlightingPass(@NotNull Project project,
@NotNull PsiFile file,
@@ -134,6 +135,7 @@ public class GeneralHighlightingPass extends ProgressableTextEditorHighlightingP
// initial guess to show correct progress in the traffic light icon
setProgressLimit(document.getTextLength()/2); // approx number of PSI elements = file length/2
myGlobalScheme = EditorColorsManager.getInstance().getGlobalScheme();
}
private static final Key<AtomicInteger> HIGHLIGHT_VISITOR_INSTANCE_COUNT = new Key<AtomicInteger>("HIGHLIGHT_VISITOR_INSTANCE_COUNT");
@@ -164,7 +166,7 @@ public class GeneralHighlightingPass extends ProgressableTextEditorHighlightingP
}
protected void collectInformationWithProgress(final ProgressIndicator progress) {
final Set<HighlightInfo> result = new THashSet<HighlightInfo>(100);
final Set<HighlightInfo> gotHighlights = new THashSet<HighlightInfo>(100);
final Set<HighlightInfo> outsideResult = new THashSet<HighlightInfo>(100);
DaemonCodeAnalyzer daemonCodeAnalyzer = DaemonCodeAnalyzer.getInstance(myProject);
@@ -174,100 +176,105 @@ public class GeneralHighlightingPass extends ProgressableTextEditorHighlightingP
final List<PsiElement> inside = new ArrayList<PsiElement>();
final List<PsiElement> outside = new ArrayList<PsiElement>();
try {
Divider.getInsideAndOutside(myFile, myStartOffset, myEndOffset, myPriorityRange, inside, outside, HighlightLevelUtil.AnalysisLevel.HIGHLIGHT);
final List<PsiFile> injectedInside = new ArrayList<PsiFile>();
final List<PsiFile> injectedOutside = new ArrayList<PsiFile>();
divideInjectedPsiHighlights(inside, outside, progress, injectedInside, injectedOutside);
Divider.divideInsideAndOutside(myFile, myStartOffset, myEndOffset, myPriorityRange, inside, outside,
HighlightLevelUtil.AnalysisLevel.HIGHLIGHT);
final Set<PsiFile> injected = new THashSet<PsiFile>();
getInjectedPsiFiles(inside, outside, progress, injected);
setProgressLimit((long)(inside.size()+outside.size()) /** filteredVisitors.length*/);
setProgressLimit((long)(inside.size()+outside.size()));
final boolean forceHighlightParents = forceHighlightParents();
if (!isDumbMode()) {
highlightTodos(myFile, myDocument.getCharsSequence(), myStartOffset, myEndOffset, progress, myPriorityRange, result, outsideResult);
highlightTodos(myFile, myDocument.getCharsSequence(), myStartOffset, myEndOffset, progress, myPriorityRange, gotHighlights, outsideResult);
}
collectHighlights(inside, new Runnable() {
@Override
public void run() {
if (!addInjectedPsiHighlights(injectedInside, progress, Collections.synchronizedSet(result))) throw new ProcessCanceledException();
// all infos for the "injected fragment for the host which is inside" are indeed inside
// but some of the infos for the "injected fragment for the host which is outside" can be still inside
THashSet<HighlightInfo> injectedResult = new THashSet<HighlightInfo>();
if (!addInjectedPsiHighlights(injected, progress, Collections.synchronizedSet(injectedResult))) throw new ProcessCanceledException();
if (!outside.isEmpty() || !injectedOutside.isEmpty()) {
if (!inside.isEmpty() || !injectedInside.isEmpty()) { // do not apply when there were no elements to highlight
// clear infos found in visible area to avoid applying them twice
final List<HighlightInfo> toApply = new ArrayList<HighlightInfo>(result.size());
for (HighlightInfo info : result) {
if (myPriorityRange.containsRange(info.getStartOffset(), info.getEndOffset())) {
toApply.add(info);
}
else {
outsideResult.add(info);
}
}
myHighlights.addAll(toApply);
result.clear();
result.addAll(outsideResult);
//if (!addInjectedPsiHighlights(injectedOutside, progress, result)) throw new ProcessCanceledException();
final List<HighlightInfo> toApplyOutside = new ArrayList<HighlightInfo>(gotHighlights.size());
UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override
public void run() {
if (myProject.isDisposed()) return;
MarkupModel markupModel = myDocument.getMarkupModel(myProject);
ProperTextRange range = myPriorityRange.intersection(new TextRange(myStartOffset, myEndOffset));
final EditorColorsScheme colorsScheme = getColorsScheme();
UpdateHighlightersUtil.setHighlightersInRange(myProject, myDocument, range, colorsScheme, toApply,
(MarkupModelEx)markupModel, Pass.UPDATE_ALL);
}
});
UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override
public void run() {
if (myProject.isDisposed() || myEditor == null) return;
new ShowAutoImportPass(myProject, myFile, myEditor).applyInformationToEditor();
}
});
for (HighlightInfo info : injectedResult) {
if (myPriorityRange.containsRange(info.getStartOffset(), info.getEndOffset())) {
gotHighlights.add(info);
}
else {
// nonconditionally apply injected results regardless whether they are in myStartOffset,myEndOffset
toApplyOutside.add(info);
}
}
final List<HighlightInfo> injectedOutsideInfos = Collections.synchronizedList(new ArrayList<HighlightInfo>());
if (!addInjectedPsiHighlights(injectedOutside, progress, injectedOutsideInfos)) throw new ProcessCanceledException();
if (outsideResult.isEmpty() && toApplyOutside.isEmpty()) {
return; // apply only result (by default apply command) and only within inside
}
myApplyCommand = new Runnable() {
final ProperTextRange priorityIntersection = myPriorityRange.intersection(new TextRange(myStartOffset, myEndOffset));
if ((!inside.isEmpty() || !gotHighlights.isEmpty()) && priorityIntersection != null) { // do not apply when there were no elements to highlight
// clear infos found in visible area to avoid applying them twice
final List<HighlightInfo> toApplyInside = new ArrayList<HighlightInfo>(gotHighlights);
myHighlights.addAll(toApplyInside);
gotHighlights.clear();
gotHighlights.addAll(outsideResult);
UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override
public void run() {
final List<HighlightInfo> insideInfos = new ArrayList<HighlightInfo>(result.size());
final List<HighlightInfo> toApply = new ArrayList<HighlightInfo>(result.size());
if (myProject.isDisposed()) return;
MarkupModel markupModel = myDocument.getMarkupModel(myProject);
ProperTextRange range = new ProperTextRange(myStartOffset, myEndOffset);
for (HighlightInfo info : result) {
if (!range.containsRange(info.getStartOffset(), info.getEndOffset())) continue;
if (myPriorityRange.containsRange(info.getStartOffset(), info.getEndOffset())) {
insideInfos.add(info);
}
else {
toApply.add(info);
}
}
toApply.addAll(injectedOutsideInfos);
/*
if (!insideInfos.isEmpty()) {
// some one has reported highlights inside range while running annotators for outside range - bad, bad annotator!
for (HighlightInfo info : insideInfos) {
toApply.add(info);
}
}
*/
UpdateHighlightersUtil.setHighlightersOutsideRange(myProject, myDocument, toApply, getColorsScheme(),
myStartOffset, myEndOffset, myPriorityRange, Pass.UPDATE_ALL);
UpdateHighlightersUtil.setHighlightersInRange(myProject, myDocument, priorityIntersection, getColorsScheme(), toApplyInside,
(MarkupModelEx)markupModel, Pass.UPDATE_ALL);
}
};
});
UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override
public void run() {
if (myProject.isDisposed() || myEditor == null) return;
new ShowAutoImportPass(myProject, myFile, myEditor).applyInformationToEditor();
}
});
}
myApplyCommand = new Runnable() {
@Override
public void run() {
final List<HighlightInfo> insideInfos = new ArrayList<HighlightInfo>(gotHighlights.size());
ProperTextRange range = new ProperTextRange(myStartOffset, myEndOffset);
for (HighlightInfo info : gotHighlights) {
if (!range.containsRange(info.getStartOffset(), info.getEndOffset())) continue;
if (myPriorityRange.containsRange(info.getStartOffset(), info.getEndOffset())) {
insideInfos.add(info);
}
else {
toApplyOutside.add(info);
}
}
//toApply.addAll(injectedOutsideInfos);
/*
if (!insideInfos.isEmpty()) {
// some one has reported highlights inside range while running annotators for outside range - bad, bad annotator!
for (HighlightInfo info : insideInfos) {
toApply.add(info);
}
}
*/
UpdateHighlightersUtil.setHighlightersOutsideRange(myProject, myDocument, toApplyOutside, getColorsScheme(),
myStartOffset, myEndOffset, myPriorityRange, Pass.UPDATE_ALL);
}
};
}
}, outside, progress, filteredVisitors, result, forceHighlightParents);
}, outside, progress, filteredVisitors, gotHighlights, forceHighlightParents);
if (myUpdateAll) {
fileStatusMap.setErrorFoundFlag(myDocument, myErrorFound);
@@ -276,14 +283,13 @@ public class GeneralHighlightingPass extends ProgressableTextEditorHighlightingP
finally {
incVisitorUsageCount(-1);
}
myHighlights.addAll(result);
myHighlights.addAll(gotHighlights);
}
private void divideInjectedPsiHighlights(@NotNull final List<PsiElement> elements1,
@NotNull final List<PsiElement> elements2,
@NotNull final ProgressIndicator progress,
@NotNull List<PsiFile> inside,
@NotNull List<PsiFile> outside) {
private void getInjectedPsiFiles(@NotNull final List<PsiElement> elements1,
@NotNull final List<PsiElement> elements2,
@NotNull final ProgressIndicator progress,
@NotNull final Set<PsiFile> outInjected) {
List<DocumentWindow> injected = InjectedLanguageUtil.getCachedInjectedDocuments(myFile);
Collection<PsiElement> hosts = new THashSet<PsiElement>(elements1.size() + elements2.size() + injected.size());
@@ -305,39 +311,35 @@ public class GeneralHighlightingPass extends ProgressableTextEditorHighlightingP
hosts.addAll(elements1);
hosts.addAll(elements2);
PsiLanguageInjectionHost.InjectedPsiVisitor visitor = new PsiLanguageInjectionHost.InjectedPsiVisitor() {
public void visit(@NotNull PsiFile injectedPsi, @NotNull List<PsiLanguageInjectionHost.Shred> places) {
outInjected.add(injectedPsi);
}
};
for (PsiElement element : hosts) {
progress.checkCanceled();
final List<PsiFile> destination = myPriorityRange.intersects(element.getTextRange()) ? inside : outside;
InjectedLanguageUtil.enumerate(element, myFile, new PsiLanguageInjectionHost.InjectedPsiVisitor() {
public void visit(@NotNull PsiFile injectedPsi, @NotNull List<PsiLanguageInjectionHost.Shred> places) {
destination.add(injectedPsi); // for concatenations there can be many injection hosts with only one injected PSI
}
}, false);
InjectedLanguageUtil.enumerate(element, myFile, visitor, false);
}
}
// returns false if canceled
private boolean addInjectedPsiHighlights(@NotNull final List<PsiFile> injectedFiles,
final ProgressIndicator progress,
final Collection<HighlightInfo> infos) {
EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
final TextAttributes injectedAttributes = scheme.getAttributes(EditorColors.INJECTED_LANGUAGE_FRAGMENT);
private boolean addInjectedPsiHighlights(@NotNull final Set<PsiFile> injectedFiles,
@NotNull final ProgressIndicator progress,
@NotNull final Collection<HighlightInfo> outInfos) {
if (injectedFiles.isEmpty()) return true;
final InjectedLanguageManager injectedLanguageManager = InjectedLanguageManager.getInstance(myProject);
final TextAttributes injectedAttributes = myGlobalScheme.getAttributes(EditorColors.INJECTED_LANGUAGE_FRAGMENT);
return JobUtil.invokeConcurrentlyUnderProgress(new ArrayList<PsiFile>(injectedFiles), new Processor<PsiFile>() {
public boolean process(final PsiFile injectedPsi) {
DocumentWindow documentWindow = (DocumentWindow)PsiDocumentManager.getInstance(myProject).getCachedDocument(injectedPsi);
Place places = InjectedLanguageUtil.getShreds(injectedPsi);
for (PsiLanguageInjectionHost.Shred place : places) {
TextRange textRange = place.getRangeInsideHost().shiftRight(place.host.getTextRange().getStartOffset());
if (textRange.isEmpty()) continue;
String desc = injectedPsi.getLanguage().getDisplayName() + ": " + injectedPsi.getText();
HighlightInfo info =
HighlightInfo.createHighlightInfo(HighlightInfoType.INJECTED_LANGUAGE_FRAGMENT, textRange, null, desc, injectedAttributes);
infos.add(info);
HighlightInfo info = HighlightInfo.createHighlightInfo(HighlightInfoType.INJECTED_LANGUAGE_FRAGMENT, textRange, null, desc, injectedAttributes);
outInfos.add(info);
}
HighlightInfoHolder holder = createInfoHolder(injectedPsi);
@@ -346,7 +348,7 @@ public class GeneralHighlightingPass extends ProgressableTextEditorHighlightingP
HighlightInfo info = holder.get(i);
final int startOffset = documentWindow.injectedToHost(info.startOffset);
final TextRange fixedTextRange = getFixedTextRange(documentWindow, startOffset);
addPatchedInfos(info, injectedPsi, documentWindow, injectedLanguageManager, fixedTextRange, infos);
addPatchedInfos(info, injectedPsi, documentWindow, injectedLanguageManager, fixedTextRange, outInfos);
}
holder.clear();
highlightInjectedSyntax(injectedPsi, holder);
@@ -355,14 +357,14 @@ public class GeneralHighlightingPass extends ProgressableTextEditorHighlightingP
final int startOffset = info.startOffset;
final TextRange fixedTextRange = getFixedTextRange(documentWindow, startOffset);
if (fixedTextRange == null) {
infos.add(info);
outInfos.add(info);
}
else {
HighlightInfo patched =
new HighlightInfo(info.forcedTextAttributes, info.forcedTextAttributesKey, info.type,
fixedTextRange.getStartOffset(), fixedTextRange.getEndOffset(),
info.description, info.toolTip, info.type.getSeverity(null), info.isAfterEndOfLine, null, false);
infos.add(patched);
outInfos.add(patched);
}
}
@@ -370,7 +372,7 @@ public class GeneralHighlightingPass extends ProgressableTextEditorHighlightingP
List<HighlightInfo> todos = new ArrayList<HighlightInfo>();
highlightTodos(injectedPsi, injectedPsi.getText(), 0, injectedPsi.getTextLength(), progress, myPriorityRange, todos, todos);
for (HighlightInfo info : todos) {
addPatchedInfos(info, injectedPsi, documentWindow, injectedLanguageManager, null, infos);
addPatchedInfos(info, injectedPsi, documentWindow, injectedLanguageManager, null, outInfos);
}
}
return true;
@@ -461,15 +463,14 @@ public class GeneralHighlightingPass extends ProgressableTextEditorHighlightingP
}
}
private static void highlightInjectedSyntax(final PsiFile injectedPsi, HighlightInfoHolder holder) {
private void highlightInjectedSyntax(final PsiFile injectedPsi, HighlightInfoHolder holder) {
List<Trinity<IElementType, PsiLanguageInjectionHost, TextRange>> tokens = InjectedLanguageUtil.getHighlightTokens(injectedPsi);
if (tokens == null) return;
final Language injectedLanguage = injectedPsi.getLanguage();
SyntaxHighlighter syntaxHighlighter =
SyntaxHighlighterFactory.getSyntaxHighlighter(injectedLanguage, injectedPsi.getProject(), injectedPsi.getVirtualFile());
EditorColorsScheme globalScheme = EditorColorsManager.getInstance().getGlobalScheme();
final TextAttributes defaultAttrs = globalScheme.getAttributes(HighlighterColors.TEXT);
Project project = injectedPsi.getProject();
SyntaxHighlighter syntaxHighlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(injectedLanguage, project, injectedPsi.getVirtualFile());
final TextAttributes defaultAttrs = myGlobalScheme.getAttributes(HighlighterColors.TEXT);
for (Trinity<IElementType, PsiLanguageInjectionHost, TextRange> token : tokens) {
IElementType tokenType = token.getFirst();
@@ -482,7 +483,7 @@ public class GeneralHighlightingPass extends ProgressableTextEditorHighlightingP
// force attribute colors to override host' ones
TextAttributes attributes = null;
for(TextAttributesKey key:keys) {
TextAttributes attrs2 = globalScheme.getAttributes(key);
TextAttributes attrs2 = myGlobalScheme.getAttributes(key);
if (attrs2 != null) {
attributes = attributes != null ? TextAttributes.merge(attributes, attrs2):attrs2;
}
@@ -492,8 +493,8 @@ public class GeneralHighlightingPass extends ProgressableTextEditorHighlightingP
forcedAttributes = TextAttributes.ERASE_MARKER;
}
else {
Color back = attributes.getBackgroundColor() == null ? globalScheme.getDefaultBackground() : attributes.getBackgroundColor();
Color fore = attributes.getForegroundColor() == null ? globalScheme.getDefaultForeground() : attributes.getForegroundColor();
Color back = attributes.getBackgroundColor() == null ? myGlobalScheme.getDefaultBackground() : attributes.getBackgroundColor();
Color fore = attributes.getForegroundColor() == null ? myGlobalScheme.getDefaultForeground() : attributes.getForegroundColor();
forcedAttributes = new TextAttributes(fore, back, attributes.getEffectColor(), attributes.getEffectType(), attributes.getFontType());
}
@@ -195,7 +195,8 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass
ArrayList<PsiElement> inside = new ArrayList<PsiElement>();
ArrayList<PsiElement> outside = new ArrayList<PsiElement>();
Divider.getInsideAndOutside(myFile, myStartOffset, myEndOffset, myPriorityRange, inside, outside, HighlightLevelUtil.AnalysisLevel.HIGHLIGHT_AND_INSPECT);
Divider.divideInsideAndOutside(myFile, myStartOffset, myEndOffset, myPriorityRange, inside, outside,
HighlightLevelUtil.AnalysisLevel.HIGHLIGHT_AND_INSPECT);
setProgressLimit(1L * tools.size() *2/** (inside.size() + outside.size())*/);
final LocalInspectionToolSession session = new LocalInspectionToolSession(myFile, myStartOffset, myEndOffset);
@@ -222,7 +222,7 @@ public class UpdateHighlightersUtil {
static void setHighlightersOutsideRange(@NotNull final Project project,
@NotNull final Document document,
@NotNull Collection<HighlightInfo> infos,
@Nullable final EditorColorsScheme colorsScheme, // if null global scheme will be used
@Nullable final EditorColorsScheme colorsScheme, // if null global scheme will be used
int startOffset, int endOffset,
@NotNull final ProperTextRange range,
final int group) {
@@ -245,8 +245,8 @@ public class UpdateHighlightersUtil {
RangeHighlighter highlighter = info.highlighter;
int hiStart = highlighter.getStartOffset();
int hiEnd = highlighter.getEndOffset();
boolean willBeRemoved = hiEnd == document.getTextLength() && range.getEndOffset() == document.getTextLength()
|| !range.containsRange(hiStart, hiEnd);
boolean willBeRemoved = !(hiEnd == document.getTextLength() && range.getEndOffset() == document.getTextLength()) &&
!range.containsRange(hiStart, hiEnd);
if (willBeRemoved) {
infosToRemove.recycleHighlighter(highlighter);
info.highlighter = null;
@@ -316,7 +316,7 @@ public class UpdateHighlightersUtil {
int hiStart = highlighter.getStartOffset();
int hiEnd = highlighter.getEndOffset();
boolean willBeRemoved = hiEnd == document.getTextLength() && range.getEndOffset() == document.getTextLength()
|| range.intersectsStrict(hiStart, hiEnd) || range.containsRange(hiStart, hiEnd) || hiStart <= range.getStartOffset() && hiEnd >= range.getEndOffset();
/*|| range.intersectsStrict(hiStart, hiEnd)*/ || range.containsRange(hiStart, hiEnd) /*|| hiStart <= range.getStartOffset() && hiEnd >= range.getEndOffset()*/;
if (willBeRemoved) {
infosToRemove.recycleHighlighter(highlighter);
info.highlighter = null;
@@ -28,6 +28,9 @@ import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Collection;
import java.util.HashSet;
public class GotoClassModel2 extends FilteringGotoByModel<Language> {
public GotoClassModel2(Project project) {
super(project, ChooseByNameRegistry.getInstance().getClassModelContributors());
@@ -38,6 +41,13 @@ public class GotoClassModel2 extends FilteringGotoByModel<Language> {
return item instanceof PsiElement ? ((PsiElement) item).getLanguage() : null;
}
@Override
protected synchronized Collection<Language> getFilterItems() {
final Collection<Language> items = new HashSet<Language>(super.getFilterItems());
items.add(Language.ANY);
return items;
}
@Nullable
public String getPromptText() {
return IdeBundle.message("prompt.gotoclass.enter.class.name");
@@ -94,4 +104,4 @@ public class GotoClassModel2 extends FilteringGotoByModel<Language> {
public String getHelpId() {
return "procedures.navigating.goto.class";
}
}
}
@@ -25,6 +25,9 @@ import com.intellij.psi.PsiElement;
import com.intellij.psi.presentation.java.SymbolPresentationUtil;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
import java.util.HashSet;
public class GotoSymbolModel2 extends FilteringGotoByModel<Language> {
public GotoSymbolModel2(Project project) {
super(project, ChooseByNameRegistry.getInstance().getSymbolModelContributors());
@@ -35,6 +38,13 @@ public class GotoSymbolModel2 extends FilteringGotoByModel<Language> {
return item instanceof PsiElement ? ((PsiElement) item).getLanguage() : null;
}
@Override
protected synchronized Collection<Language> getFilterItems() {
final Collection<Language> items = new HashSet<Language>(super.getFilterItems());
items.add(Language.ANY);
return items;
}
public String getPromptText() {
return IdeBundle.message("prompt.gotosymbol.enter.symbol.name");
}
@@ -436,13 +436,14 @@ public class MultiHostRegistrarImpl implements MultiHostRegistrar {
}
}
// returns lexer elemet types with corresponsing ranges in encoded (injection host based) PSI
private static List<Trinity<IElementType, PsiLanguageInjectionHost, TextRange>> obtainHighlightTokensFromLexer(Language language,
StringBuilder outChars,
List<LiteralTextEscaper<? extends PsiLanguageInjectionHost>> escapers,
Place shreds,
VirtualFileWindow virtualFile,
Project project) {
// returns lexer element types with corresponding ranges in encoded (injection host based) PSI
private static List<Trinity<IElementType, PsiLanguageInjectionHost, TextRange>>
obtainHighlightTokensFromLexer(Language language,
StringBuilder outChars,
List<LiteralTextEscaper<? extends PsiLanguageInjectionHost>> escapers,
Place shreds,
VirtualFileWindow virtualFile,
Project project) {
List<Trinity<IElementType, PsiLanguageInjectionHost, TextRange>> tokens = new ArrayList<Trinity<IElementType, PsiLanguageInjectionHost, TextRange>>(10);
SyntaxHighlighter syntaxHighlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(language, project, (VirtualFile)virtualFile);
Lexer lexer = syntaxHighlighter.getHighlightingLexer();
@@ -25,8 +25,7 @@ import com.intellij.ui.LightColors;
import javax.swing.*;
import javax.swing.plaf.basic.BasicScrollBarUI;
import java.awt.*;
import java.awt.event.AdjustmentEvent;
import java.awt.event.AdjustmentListener;
import java.awt.event.*;
public class ButtonlessScrollBarUI extends BasicScrollBarUI {
public static final Color GRADIENT_LIGHT = new SameColor(0xfb);
@@ -36,21 +35,19 @@ public class ButtonlessScrollBarUI extends BasicScrollBarUI {
public static final Color TRACK_BORDER = new SameColor(230);
private final AdjustmentListener myAdjustmentListener;
private MouseMotionAdapter myMouseMotionListener;
private MouseAdapter myMouseListener;
private final Animator myAnimator;
private int myAnimationColorShift = 0;
private boolean myMouseIsOverThumb = false;
protected ButtonlessScrollBarUI() {
myAdjustmentListener = new AdjustmentListener() {
@Override
public void adjustmentValueChanged(AdjustmentEvent e) {
myAnimator.reset();
if (!scrollbar.getValueIsAdjusting()) {
myAnimator.resume();
}
else {
myAnimationColorShift = 40;
}
resetAnimator();
}
};
@@ -69,6 +66,37 @@ public class ButtonlessScrollBarUI extends BasicScrollBarUI {
}
}
};
myMouseMotionListener = new MouseMotionAdapter() {
@Override
public void mouseMoved(MouseEvent e) {
boolean inside = isOverThumb(e.getPoint());
if (inside != myMouseIsOverThumb) {
myMouseIsOverThumb = inside;
resetAnimator();
}
}
};
myMouseListener = new MouseAdapter() {
@Override
public void mouseExited(MouseEvent e) {
if (myMouseIsOverThumb) {
myMouseIsOverThumb = false;
resetAnimator();
}
}
};
}
private void resetAnimator() {
myAnimator.reset();
if (scrollbar != null && scrollbar.getValueIsAdjusting() || myMouseIsOverThumb) {
myAnimationColorShift = 40;
}
else {
myAnimator.resume();
}
}
public static BasicScrollBarUI createNormal() {
@@ -85,6 +113,13 @@ public class ButtonlessScrollBarUI extends BasicScrollBarUI {
protected void installListeners() {
super.installListeners();
scrollbar.addAdjustmentListener(myAdjustmentListener);
scrollbar.addMouseListener(myMouseListener);
scrollbar.addMouseMotionListener(myMouseMotionListener);
}
private boolean isOverThumb(Point p) {
final Rectangle bounds = getThumbBounds();
return bounds != null && bounds.contains(p);
}
@Override
@@ -151,7 +186,6 @@ public class ButtonlessScrollBarUI extends BasicScrollBarUI {
int vgap = vertical ? 1 : 2;
int w = adjustThumbWidth(thumbBounds.width - hgap * 2);
int h = thumbBounds.height - vgap * 2;
@@ -152,7 +152,6 @@ public class UndoManagerImpl extends UndoManager implements ProjectComponent, Ap
public void commandStarted(CommandEvent event) {
onCommandStarted(event.getProject(), event.getUndoConfirmationPolicy());
if (event.getDocument() != null) addAffectedDocuments(event.getDocument());
}
public void commandFinished(CommandEvent event) {
@@ -29,7 +29,7 @@ public interface Computable <T> {
private final T myValue;
public PredefinedValueComputable(T value) {
this.myValue = value;
myValue = value;
}
@Override
@@ -15,13 +15,13 @@
*/
package com.siyeh.ig.controlflow;
import com.intellij.codeInspection.ui.SingleCheckboxOptionsPanel;
import com.intellij.psi.*;
import com.intellij.psi.tree.IElementType;
import com.siyeh.InspectionGadgetsBundle;
import com.siyeh.ig.BaseInspection;
import com.siyeh.ig.BaseInspectionVisitor;
import com.siyeh.ig.psiutils.EquivalenceChecker;
import com.intellij.codeInspection.ui.SingleCheckboxOptionsPanel;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -35,6 +35,9 @@ public class DuplicateConditionInspection extends BaseInspection {
/** @noinspection PublicField*/
public boolean ignoreMethodCalls = false;
// This is a dirty fix of 'squared' algorithm performance issue.
private static final int LIMIT_DEPTH = 20;
@NotNull
public String getDisplayName() {
return InspectionGadgetsBundle.message(
@@ -73,7 +76,7 @@ public class DuplicateConditionInspection extends BaseInspection {
}
}
final Set<PsiExpression> conditions = new HashSet<PsiExpression>();
collectConditionsForIfStatement(statement, conditions);
collectConditionsForIfStatement(statement, conditions, 0);
final int numConditions = conditions.size();
if (numConditions < 2) {
return;
@@ -113,13 +116,15 @@ public class DuplicateConditionInspection extends BaseInspection {
}
private void collectConditionsForIfStatement(
PsiIfStatement statement, Set<PsiExpression> conditions) {
PsiIfStatement statement, Set<PsiExpression> conditions, int depth) {
if (depth > LIMIT_DEPTH) return;
final PsiExpression condition = statement.getCondition();
collectConditionsForExpression(condition, conditions);
final PsiStatement branch = statement.getElseBranch();
if (branch instanceof PsiIfStatement) {
collectConditionsForIfStatement((PsiIfStatement)branch,
conditions);
conditions, depth + 1);
}
}
@@ -165,4 +170,4 @@ public class DuplicateConditionInspection extends BaseInspection {
return false;
}
}
}
}
@@ -151,7 +151,9 @@ public class IfStatementWithIdenticalBranchesInspection
private static class IfStatementWithIdenticalBranchesVisitor
extends BaseInspectionVisitor{
@Override public void visitIfStatement(
private static final int LIMIT_DEPTH = 20; // Dirty fix for 'squared' algorithm.
@Override public void visitIfStatement(
@NotNull PsiIfStatement ifStatement){
super.visitIfStatement(ifStatement);
final PsiStatement thenBranch = ifStatement.getThenBranch();
@@ -178,7 +180,9 @@ public class IfStatementWithIdenticalBranchesInspection
public static PsiStatement getIdenticalElseIfStatement(
PsiStatement thenBranch, PsiStatement elseBranch) {
int depth = 0;
while (elseBranch instanceof PsiIfStatement) {
if (depth++ > LIMIT_DEPTH) break;
final PsiIfStatement statement =
(PsiIfStatement) elseBranch;
final PsiStatement branch = statement.getThenBranch();
@@ -265,4 +269,4 @@ public class IfStatementWithIdenticalBranchesInspection
return nextStatement;
}
}
}
}
@@ -1,18 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.plugins.github.ui.GithubCloneProjectPane">
<grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="5" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="4" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="500" height="400"/>
<xy x="20" y="20" width="402" height="124"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<vspacer id="5534b">
<constraints>
<grid row="4" column="2" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="47c3a" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
@@ -40,7 +35,8 @@
<component id="8e19a" class="javax.swing.JTextPane" binding="myDetailsTextField" default-binding="true">
<constraints>
<grid row="1" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="100" height="10"/>
<minimum-size width="-1" height="27"/>
<preferred-size width="100" height="27"/>
</grid>
</constraints>
<properties>
@@ -78,9 +78,5 @@ public class GithubSettingsPanel {
public String getPassword() {
return String.valueOf(myPasswordField.getPassword());
}
public JComponent getPreferrableFocusComponent() {
return myLoginTextField;
}
}
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.plugins.github.ui.GithubSharePanel">
<grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="3" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="2" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="500" height="400"/>
<xy x="20" y="20" width="376" height="98"/>
</constraints>
<properties/>
<border type="none"/>
@@ -16,11 +16,6 @@
<text value="New repository name:"/>
</properties>
</component>
<vspacer id="112a6">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="942c9" class="javax.swing.JTextField" binding="myRepositoryTextField">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
@@ -39,7 +39,7 @@ public class MavenAddArchetypeDialog extends DialogWrapper {
init();
DocumentAdapter l =new DocumentAdapter() {
DocumentAdapter l = new DocumentAdapter() {
@Override
protected void textChanged(DocumentEvent e) {
doValidateInput();
@@ -63,6 +63,11 @@ public class MavenAddArchetypeDialog extends DialogWrapper {
return myGroupIdField;
}
@Override
protected String getHelpId() {
return "Add_Archetype_Dialog";
}
private void doValidateInput() {
List<String> errors = new ArrayList<String>();
if (StringUtil.isEmptyOrSpaces(myGroupIdField.getText())) errors.add("GroupId");
@@ -82,9 +87,9 @@ public class MavenAddArchetypeDialog extends DialogWrapper {
public MavenArchetype getArchetype() {
return new MavenArchetype(myGroupIdField.getText(),
myArtifactIdField.getText(),
myVersionField.getText(),
myRepositoryField.getText(),
null);
myArtifactIdField.getText(),
myVersionField.getText(),
myRepositoryField.getText(),
null);
}
}
@@ -1,291 +1,294 @@
aggregator
ajax
anyschema
appender
archivelog
args
arity
asensitive
auth
authid
autocommit
autoextend
autoincrement
barcode
backend
basedir
basicfile
bfile
bigfile
bigint
binlog
bool
btree
calc
capath
captcha
ccflags
cdata
charset
checkbox
checksum
classpath
clazz
clob
closable
cmdline
commandline
config
configs
configurator
controlfile
cron
ctrl
datafile
datafiles
datetime
deallocate
deduplicate
deferrable
desc
dirs
distinctrow
django
dojo
draggable
dumpfile
elseif
elsif
enum
evex
expr
filename
fileset
filesets
filesystem
foreach
formatter
freelist
freelists
freepools
frontend
fulltext
geometrycollection
getters
gdata
google
hardcoded
holdability
hostname
href
hsqldb
html
http
https
impl
inbox
indextype
infile
init
initializer
initrans
inline
innodb
inout
instantiable
intellij
isnull
javadoc
javascript
jetbrains
jquery
json
keepduplicates
ldap
likec
linestring
localhost
localtime
localtimestamp
locator
logfile
login
logoff
logon
logout
longblob
longtext
lookup
lucene
maxdatafiles
maxextents
maximizable
maxinstances
maxlogfiles
maxloghistory
maxlogmembers
maxsize
maxtrans
maxvalue
mediumblob
mediumint
mediumtext
metadata
middleint
minextents
minimizable
minvalue
miny
mlslabel
multilinestring
multipoint
multipolygon
multiset
mutex
mutexes
mysql
namespace
namespaces
nchar
nclob
ndbcluster
noarchivelog
noaudit
nocache
nocompress
nocopy
nocycle
nodegroup
noinspection
noinspections
nologging
nomapping
nomaxvalue
nominvalue
nomonitoring
nonschema
noorder
noparallel
norely
noresetlogs
noreverse
norowdependencies
nosort
notnull
novalidate
nowait
nullif
nvarchar
oauth
oidindex
online
openid
openssl
outfile
param
params
pctfree
pctincrease
pctthreshold
pctused
pctversion
permalink
petersburg
pipelined
playlist
plsql
plugin
plugins
posix
pragma
prebuilt
prepend
preprocessor
processlist
profiler
progressbar
readonly
refactor
refactored
refactoring
reindex
renderer
resetlogs
rlike
rollup
rowdependencies
rtree
rubymine
runtime
savepoint
schemas
securefile
serializable
serializer
servererror
servlet
smallfile
smallint
soname
spellchecker
spellchecking
sqlcode
sqlerror
sqlexception
sqlstate
sqlwarning
startup
stateful
stmt
stylesheet
subpackage
subpartition
subpartitions
substring
sysdate
systimestamp
tablespace
taglib
temptable
timestamp
tinyblob
tinyint
tinytext
todo
tokenize
tokenizer
tooltips
trinary
twitter
uncomment
underwave
undofile
unhandled
uninstall
unpivot
urowid
utf
util
utils
validator
validators
vararg
varbinary
varchar
varcharacter
varray
versa
vertices
webservice
whitespace
wildcard
workflow
wsdl
xmlschema
xmlschemas
xmltype
xpath
xslt
youtube
zend
zerofill
aggregator
ajax
anyschema
appender
archivelog
args
arity
asensitive
auth
authid
autocommit
autoextend
autoincrement
barcode
backend
basedir
basicfile
bfile
bigfile
bigint
binlog
bool
btree
calc
capath
captcha
ccflags
cdata
charset
checkbox
checksum
classpath
clazz
clob
closable
cmdline
commandline
config
configs
configurator
controlfile
cron
ctrl
datafile
datafiles
datetime
deallocate
deduplicate
deferrable
desc
dirs
distinctrow
django
dojo
draggable
dumpfile
elseif
elsif
enum
evex
expr
filename
fileset
filesets
filesystem
foreach
formatter
freelist
freelists
freepools
frontend
fulltext
geometrycollection
getters
gdata
google
hardcoded
holdability
hostname
href
hsqldb
html
http
https
impl
inbox
indextype
infile
init
initializer
initrans
inline
innodb
inout
instantiable
intellij
isnull
javadoc
javascript
jetbrains
jquery
json
keepduplicates
ldap
likec
linestring
localhost
localtime
localtimestamp
locator
logfile
login
logoff
logon
logout
longblob
longtext
lookup
lucene
maxdatafiles
maxextents
maximizable
maxinstances
maxlogfiles
maxloghistory
maxlogmembers
maxsize
maxtrans
maxvalue
mediumblob
mediumint
mediumtext
metadata
middleint
minextents
minimizable
minvalue
miny
mlslabel
multilinestring
multipoint
multipolygon
multiset
mutex
mutexes
mysql
namespace
namespaces
nchar
nclob
ndbcluster
noarchivelog
noaudit
nocache
nocompress
nocopy
nocycle
nodegroup
noinspection
noinspections
nologging
nomapping
nomaxvalue
nominvalue
nomonitoring
nonschema
noorder
noparallel
norely
noresetlogs
noreverse
norowdependencies
nosort
notnull
novalidate
nowait
nullif
nvarchar
oauth
oidindex
online
openid
openssl
outfile
param
params
pctfree
pctincrease
pctthreshold
pctused
pctversion
permalink
petersburg
pipelined
playlist
plsql
plugin
plugins
posix
pragma
prebuilt
prepend
preprocessor
processlist
profiler
progressbar
readonly
refactor
refactored
refactoring
reindex
renderer
resetlogs
rlike
rollup
rowdependencies
rtree
rubymine
runtime
savepoint
schemas
securefile
serializable
serializer
servererror
servlet
smallfile
smallint
soname
spellchecker
spellchecking
sqlcode
sqlerror
sqlexception
sqlstate
sqlwarning
startup
stateful
stmt
stylesheet
subpackage
subpartition
subpartitions
substring
sysdate
systimestamp
tablespace
taglib
temptable
timestamp
tinyblob
tinyint
tinytext
todo
tokenize
tokenizer
tooltips
trinary
twitter
uncomment
underwave
undofile
unhandled
uninstall
unpivot
urowid
utf
util
utils
validator
validators
vararg
varbinary
varchar
varcharacter
varray
versa
vertices
webservice
whitespace
wildcard
workflow
wsdl
xmlschema
xmlschemas
xmltype
xpath
xslt
youtube
zend
zerofill
indices
postfix
Throwable
@@ -24,6 +24,7 @@ import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.impl.FakePsiElement;
import com.intellij.psi.xml.XmlElement;
import com.intellij.util.ArrayUtil;
@@ -160,6 +161,22 @@ public abstract class GoToSymbolProvider implements ChooseByNameContributor {
return myPsiElement.getParent();
}
@NotNull
@Override
public Project getProject() {
return myPsiElement.getProject();
}
@Override
public PsiFile getContainingFile() {
return myPsiElement.getContainingFile();
}
@Override
public boolean isValid() {
return myPsiElement.isValid();
}
public boolean equals(final Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;