mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'master' of git.labs.intellij.net:idea/community
This commit is contained in:
@@ -18,8 +18,10 @@ package com.intellij.codeInspection;
|
||||
import com.intellij.codeInsight.AnnotationUtil;
|
||||
import com.intellij.codeInsight.FileModificationService;
|
||||
import com.intellij.codeInsight.intention.AddAnnotationPsiFix;
|
||||
import com.intellij.openapi.application.ReadAction;
|
||||
import com.intellij.openapi.command.undo.UndoUtil;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
@@ -38,7 +40,7 @@ import java.util.List;
|
||||
public class AnnotateMethodFix implements LocalQuickFix {
|
||||
private static final Logger LOG = Logger.getInstance(AnnotateMethodFix.class);
|
||||
|
||||
protected final String myAnnotation;
|
||||
private final String myAnnotation;
|
||||
private final String[] myAnnotationsToRemove;
|
||||
|
||||
public AnnotateMethodFix(@NotNull String fqn, @NotNull String... annotationsToRemove) {
|
||||
@@ -87,15 +89,21 @@ public class AnnotateMethodFix implements LocalQuickFix {
|
||||
if (annotateSelf()) {
|
||||
toAnnotate.add(method);
|
||||
}
|
||||
if (annotateOverriddenMethods()) {
|
||||
|
||||
if (annotateOverriddenMethods() && !ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> {
|
||||
PsiMethod[] methods = OverridingMethodsSearch.search(method).toArray(PsiMethod.EMPTY_ARRAY);
|
||||
for (PsiMethod psiMethod : methods) {
|
||||
if (AnnotationUtil.isAnnotatingApplicable(psiMethod, myAnnotation) &&
|
||||
!AnnotationUtil.isAnnotated(psiMethod, myAnnotation, false, false, true) &&
|
||||
psiMethod.getManager().isInProject(psiMethod)) {
|
||||
toAnnotate.add(psiMethod);
|
||||
}
|
||||
ReadAction.run(() -> {
|
||||
if (psiMethod.isPhysical() &&
|
||||
psiMethod.getManager().isInProject(psiMethod) &&
|
||||
AnnotationUtil.isAnnotatingApplicable(psiMethod, myAnnotation) &&
|
||||
!AnnotationUtil.isAnnotated(psiMethod, myAnnotation, false, false, true)) {
|
||||
toAnnotate.add(psiMethod);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, "Searching for Overriding Methods", true, project)) {
|
||||
return;
|
||||
}
|
||||
|
||||
FileModificationService.getInstance().preparePsiElementsForWrite(toAnnotate);
|
||||
|
||||
@@ -165,8 +165,14 @@ public abstract class ArchiveHandler {
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
myEntries.clear();
|
||||
myChildrenEntries.clear();
|
||||
clearCaches();
|
||||
}
|
||||
|
||||
protected void clearCaches() {
|
||||
synchronized (myLock) {
|
||||
myEntries.clear();
|
||||
myChildrenEntries.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -139,6 +139,7 @@ public class ZipHandler extends ArchiveHandler {
|
||||
|
||||
private void removeZipHandlerFromCache() {
|
||||
ourZipFileFileAccessorCache.remove(this);
|
||||
clearCaches();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+66
-17
@@ -18,10 +18,12 @@ package com.intellij.application.options.colors.fileStatus;
|
||||
import com.intellij.openapi.application.ApplicationBundle;
|
||||
import com.intellij.openapi.ui.JBMenuItem;
|
||||
import com.intellij.openapi.ui.JBPopupMenu;
|
||||
import com.intellij.ui.*;
|
||||
import com.intellij.ui.ClickListener;
|
||||
import com.intellij.ui.ColorPicker;
|
||||
import com.intellij.ui.Gray;
|
||||
import com.intellij.ui.table.JBTable;
|
||||
import com.intellij.util.ui.ColorIcon;
|
||||
import com.intellij.util.ui.EmptyIcon;
|
||||
import com.intellij.util.ui.JBEmptyBorder;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -46,16 +48,18 @@ public class FileStatusColorsTable extends JBTable {
|
||||
getColumnModel().setColumnSelectionAllowed(false);
|
||||
setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
setDefaultRenderer(Color.class, new MyColorCellRenderer(defaultColor));
|
||||
setTableHeader(null);
|
||||
registerKeyboardAction(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
setColor();
|
||||
}
|
||||
}, KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, false), JComponent.WHEN_FOCUSED);
|
||||
new DoubleClickListener() {
|
||||
new ClickListener() {
|
||||
@Override
|
||||
protected boolean onDoubleClick(MouseEvent event) {
|
||||
return setColor();
|
||||
public boolean onClick(@NotNull MouseEvent event, int clickCount) {
|
||||
int col = FileStatusColorsTable.this.columnAtPoint(event.getPoint());
|
||||
return isColorColumn(col) && setColor();
|
||||
}
|
||||
}.installOn(this);
|
||||
initPopup();
|
||||
@@ -64,13 +68,13 @@ public class FileStatusColorsTable extends JBTable {
|
||||
private void initPopup() {
|
||||
mySetColorMenu = new JBPopupMenu();
|
||||
mySetColorMenu.add(new JBMenuItem(new ChooseColorAction()));
|
||||
mySetColorMenu.add(new JBMenuItem(new ResetToDefaultAction()));
|
||||
mySetColorMenu.add(new JBMenuItem(new DropColorAction()));
|
||||
mySetColorMenu.add(new JBMenuItem(new ResetToDefaultAction()));
|
||||
}
|
||||
|
||||
private class ChooseColorAction extends AbstractAction {
|
||||
public ChooseColorAction() {
|
||||
super("Choose Color...");
|
||||
super(ApplicationBundle.message("file.status.color.menu.choose.color"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -81,7 +85,7 @@ public class FileStatusColorsTable extends JBTable {
|
||||
|
||||
private class DropColorAction extends AbstractAction {
|
||||
public DropColorAction() {
|
||||
super("Set to Normal Text");
|
||||
super(ApplicationBundle.message("file.status.color.menu.normal.text"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -95,7 +99,7 @@ public class FileStatusColorsTable extends JBTable {
|
||||
|
||||
private class ResetToDefaultAction extends AbstractAction {
|
||||
public ResetToDefaultAction() {
|
||||
super("Reset to Default");
|
||||
super(ApplicationBundle.message("file.status.color.menu.reset.to.default"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -121,7 +125,7 @@ public class FileStatusColorsTable extends JBTable {
|
||||
private Point getPopupLocation() {
|
||||
int row = getSelectedRow();
|
||||
if (row >= 0) {
|
||||
Rectangle cellRect = getCellRect(row, 1, false);
|
||||
Rectangle cellRect = getCellRect(row, 0, false);
|
||||
return cellRect.getLocation();
|
||||
}
|
||||
return null;
|
||||
@@ -130,17 +134,18 @@ public class FileStatusColorsTable extends JBTable {
|
||||
private void editColor() {
|
||||
int row = getSelectedRow();
|
||||
if (row >= 0) {
|
||||
Color currentColor = (Color)getModel().getValueAt(row, 1);
|
||||
int colorColumn = getColumn(Color.class);
|
||||
Color currentColor = (Color)getModel().getValueAt(row, colorColumn);
|
||||
Color color = ColorPicker.showDialog(this, ApplicationBundle.message("title.file.status.color"), currentColor, true, null, false);
|
||||
if (color != null) {
|
||||
getModel().setValueAt(color, row, 1);
|
||||
getModel().setValueAt(color, row, colorColumn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void adjustColumnWidths() {
|
||||
for (int col = 0; col < getColumnCount(); col++) {
|
||||
int rightGap = col > 0 ? JBUI.size(10,1).width : 0;
|
||||
int rightGap = isColorColumn(col) ? JBUI.size(10, 1).width : 0;
|
||||
DefaultTableColumnModel colModel = (DefaultTableColumnModel) getColumnModel();
|
||||
TableColumn column = colModel.getColumn(col);
|
||||
int width = 0;
|
||||
@@ -154,14 +159,26 @@ public class FileStatusColorsTable extends JBTable {
|
||||
}
|
||||
width += rightGap;
|
||||
column.setPreferredWidth(width);
|
||||
if (col > 0) {
|
||||
if (isColorColumn(col)) {
|
||||
column.setMinWidth(width);
|
||||
column.setMaxWidth(width);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isColorColumn(int col) {
|
||||
return getModel().getColumnClass(col).equals(Color.class);
|
||||
}
|
||||
|
||||
private int getColumn(@NotNull Class columnClass) {
|
||||
for (int i = 0; i < getModel().getColumnCount(); i ++) {
|
||||
if (getModel().getColumnClass(i).equals(columnClass)) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
private static class MyColorCellRenderer implements TableCellRenderer {
|
||||
public static final int RIGHT_GAP = 10;
|
||||
private Color myDefaultColor;
|
||||
|
||||
public MyColorCellRenderer(@NotNull Color defaultColor) {
|
||||
@@ -172,9 +189,10 @@ public class FileStatusColorsTable extends JBTable {
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||
JLabel colorLabel = new JLabel();
|
||||
Color c = getDisplayColor(value);
|
||||
colorLabel.setBorder(new JBEmptyBorder(0, RIGHT_GAP, 0, 0));
|
||||
colorLabel.setIcon(getIcon(c));
|
||||
//noinspection StringToUpperCaseOrToLowerCaseWithoutLocale
|
||||
colorLabel.setText(value != null ? ColorUtil.toHex(c).toUpperCase() : ApplicationBundle.message("file.status.color.none"));
|
||||
colorLabel.setText(value != null ? "" : ApplicationBundle.message("file.status.color.none"));
|
||||
colorLabel.setForeground(c);
|
||||
if (isSelected) {
|
||||
colorLabel.setOpaque(true);
|
||||
@@ -184,12 +202,43 @@ public class FileStatusColorsTable extends JBTable {
|
||||
return colorLabel;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Color getDisplayColor(@Nullable Object value) {
|
||||
return value instanceof Color ? (Color)value : myDefaultColor;
|
||||
}
|
||||
|
||||
private static Icon getIcon(Color color) {
|
||||
return color == null ? EmptyIcon.ICON_16 : JBUI.scale(new ColorIcon(16, 13, color, true));
|
||||
private Icon getIcon(@NotNull Color color) {
|
||||
return color != myDefaultColor ? JBUI.scale(new MyColorIcon(color)) : null;
|
||||
}
|
||||
}
|
||||
|
||||
private static class MyColorIcon extends EmptyIcon {
|
||||
|
||||
public static final int COLOR_HEIGHT = 14;
|
||||
public static final int ICON_HEIGHT = 16;
|
||||
public static final int ICON_WIDTH = 32;
|
||||
private Color myColor;
|
||||
|
||||
public MyColorIcon(@NotNull Color color) {
|
||||
//noinspection deprecation
|
||||
super(ICON_WIDTH, ICON_HEIGHT);
|
||||
myColor = color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintIcon(final Component component, final Graphics g, final int i, final int j) {
|
||||
final int iconHeight = getIconHeight();
|
||||
final int iconWidth = getIconWidth();
|
||||
g.setColor(myColor);
|
||||
|
||||
final int size = scaleVal(COLOR_HEIGHT);
|
||||
final int y = j + (iconHeight - size) / 2;
|
||||
|
||||
g.fillRect(i, y, iconWidth, size);
|
||||
|
||||
g.setColor(Gray.x00.withAlpha(40));
|
||||
g.drawRect(i, y, iconWidth, size);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -37,9 +37,9 @@ public class FileStatusColorsTableModel extends AbstractTableModel {
|
||||
|
||||
private final static ColumnInfo[] COLUMNS_INFO = {
|
||||
new ColumnInfo(
|
||||
String.class, ApplicationBundle.message("file.status.colors.header.status"), descriptor -> descriptor.getStatus().getText()),
|
||||
Color.class, ApplicationBundle.message("file.status.colors.header.color"), descriptor -> descriptor.getColor()),
|
||||
new ColumnInfo(
|
||||
Color.class, ApplicationBundle.message("file.status.colors.header.color"), descriptor -> descriptor.getColor())
|
||||
String.class, ApplicationBundle.message("file.status.colors.header.status"), descriptor -> descriptor.getStatus().getText())
|
||||
};
|
||||
|
||||
private static class ColumnInfo {
|
||||
|
||||
@@ -571,7 +571,7 @@ public class InspectionResultsView extends JPanel implements Disposable, DataPro
|
||||
}
|
||||
}
|
||||
if (previewEditor != null) {
|
||||
new ProblemPreviewEditorPresentation(previewEditor, this);
|
||||
ProblemPreviewEditorPresentation.setupFoldingsForNonProblemRanges(previewEditor, this);
|
||||
}
|
||||
mySplitter.setSecondComponent(editorPanel);
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -106,7 +106,7 @@ class InspectionViewPsiTreeChangeAdapter extends PsiTreeChangeAdapter {
|
||||
}
|
||||
return true;
|
||||
});
|
||||
if (needUpdateUI[0]) {
|
||||
if (needUpdateUI[0] && !myAlarm.isDisposed()) {
|
||||
myAlarm.cancelAllRequests();
|
||||
myAlarm.addRequest(() -> myView.resetTree(), 100, ModalityState.NON_MODAL);
|
||||
}
|
||||
|
||||
+52
-56
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -15,13 +15,13 @@
|
||||
*/
|
||||
package com.intellij.codeInspection.ui;
|
||||
|
||||
import com.intellij.codeInspection.CommonProblemDescriptor;
|
||||
import com.intellij.codeInspection.ProblemDescriptorBase;
|
||||
import com.intellij.diff.tools.util.FoldingModelSupport;
|
||||
import com.intellij.diff.util.DiffDrawUtil;
|
||||
import com.intellij.openapi.application.WriteAction;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.FoldRegion;
|
||||
import com.intellij.openapi.editor.ScrollType;
|
||||
import com.intellij.openapi.editor.ex.DocumentEx;
|
||||
import com.intellij.openapi.editor.ex.EditorEx;
|
||||
import com.intellij.openapi.editor.markup.HighlighterLayer;
|
||||
import com.intellij.openapi.util.Segment;
|
||||
@@ -30,35 +30,23 @@ import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.usageView.UsageInfo;
|
||||
import com.intellij.usages.impl.UsagePreviewPanel;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author Dmitry Batkovich
|
||||
*/
|
||||
public class ProblemPreviewEditorPresentation {
|
||||
class ProblemPreviewEditorPresentation {
|
||||
private final static int VIEW_ADDITIONAL_OFFSET = 4;
|
||||
|
||||
private final EditorEx myEditor;
|
||||
private final InspectionResultsView myView;
|
||||
private final SortedSet<PreviewEditorFoldingRegion> myFoldedRegions = new TreeSet<>(Comparator.comparing(x -> x.startLine));
|
||||
private final DocumentEx myDocument;
|
||||
|
||||
public ProblemPreviewEditorPresentation(EditorEx editor, InspectionResultsView view) {
|
||||
myEditor = editor;
|
||||
myView = view;
|
||||
myDocument = editor.getDocument();
|
||||
myFoldedRegions.add(new PreviewEditorFoldingRegion(0, myDocument.getLineCount()));
|
||||
appendFoldings(view.getTree().getAllValidSelectedDescriptors());
|
||||
}
|
||||
|
||||
private static boolean inRegion(int position, PreviewEditorFoldingRegion range) {
|
||||
return range.startLine <= position && range.endLine > position;
|
||||
}
|
||||
|
||||
private void appendFoldings(CommonProblemDescriptor[] descriptors) {
|
||||
List<UsageInfo> usages = Arrays.stream(descriptors)
|
||||
static void setupFoldingsForNonProblemRanges(@NotNull EditorEx editor, @NotNull InspectionResultsView view) {
|
||||
final Document doc = editor.getDocument();
|
||||
PsiDocumentManager documentManager = PsiDocumentManager.getInstance(view.getProject());
|
||||
if (documentManager.isUncommited(doc)) {
|
||||
WriteAction.run(() -> documentManager.commitDocument(doc));
|
||||
}
|
||||
final SortedSet<PreviewEditorFoldingRegion> foldingRegions = new TreeSet<>(Comparator.comparing(x -> x.startLine));
|
||||
foldingRegions.add(new PreviewEditorFoldingRegion(0, doc.getLineCount()));
|
||||
List<UsageInfo> usages = Arrays.stream(view.getTree().getAllValidSelectedDescriptors())
|
||||
.filter(ProblemDescriptorBase.class::isInstance)
|
||||
.map(ProblemDescriptorBase.class::cast)
|
||||
.map(d -> {
|
||||
@@ -76,47 +64,55 @@ public class ProblemPreviewEditorPresentation {
|
||||
if (usage == null) {
|
||||
return;
|
||||
}
|
||||
isUpdated |= appendFoldings(usage.getSegment());
|
||||
isUpdated |= makeVisible(foldingRegions, usage.getSegment(), doc);
|
||||
}
|
||||
if (isUpdated) {
|
||||
updateFoldings();
|
||||
setupFoldings(editor, foldingRegions);
|
||||
}
|
||||
|
||||
highlightProblems(editor, view, usages);
|
||||
}
|
||||
|
||||
private static void highlightProblems(EditorEx editor, InspectionResultsView view, List<UsageInfo> usages) {
|
||||
List<UsageInfo> validUsages = usages.stream().filter(Objects::nonNull).collect(Collectors.toList());
|
||||
PsiDocumentManager.getInstance(myView.getProject()).performLaterWhenAllCommitted(() -> {
|
||||
if (!myEditor.isDisposed()) {
|
||||
myView.invalidate();
|
||||
myView.validate();
|
||||
UsagePreviewPanel.highlight(validUsages, myEditor, myView.getProject(), false, HighlighterLayer.SELECTION);
|
||||
PsiDocumentManager.getInstance(view.getProject()).performLaterWhenAllCommitted(() -> {
|
||||
if (!editor.isDisposed()) {
|
||||
view.invalidate();
|
||||
view.validate();
|
||||
UsagePreviewPanel.highlight(validUsages, editor, view.getProject(), false, HighlighterLayer.SELECTION);
|
||||
if (validUsages.size() == 1) {
|
||||
final PsiElement element = validUsages.get(0).getElement();
|
||||
if (element != null) {
|
||||
final DocumentEx document = myEditor.getDocument();
|
||||
final Document document = editor.getDocument();
|
||||
final int offset = Math.min(element.getTextRange().getEndOffset() + VIEW_ADDITIONAL_OFFSET,
|
||||
document.getLineEndOffset(document.getLineNumber(element.getTextRange().getEndOffset())));
|
||||
myEditor.getScrollingModel().scrollTo(myEditor.offsetToLogicalPosition(offset), ScrollType.CENTER);
|
||||
editor.getScrollingModel().scrollTo(editor.offsetToLogicalPosition(offset), ScrollType.CENTER);
|
||||
return;
|
||||
}
|
||||
}
|
||||
myEditor.getScrollingModel().scrollTo(myEditor.offsetToLogicalPosition(0), ScrollType.CENTER_UP);
|
||||
editor.getScrollingModel().scrollTo(editor.offsetToLogicalPosition(0), ScrollType.CENTER_UP);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void updateFoldings() {
|
||||
myEditor.getFoldingModel().runBatchFoldingOperation(() -> {
|
||||
myEditor.getFoldingModel().clearFoldRegions();
|
||||
myEditor.getMarkupModel().removeAllHighlighters();
|
||||
for (PreviewEditorFoldingRegion region : myFoldedRegions) {
|
||||
private static boolean inRegion(int position, PreviewEditorFoldingRegion range) {
|
||||
return range.startLine <= position && range.endLine > position;
|
||||
}
|
||||
|
||||
private static void setupFoldings(EditorEx editor, SortedSet<PreviewEditorFoldingRegion> foldedRegions) {
|
||||
editor.getFoldingModel().runBatchFoldingOperation(() -> {
|
||||
editor.getFoldingModel().clearFoldRegions();
|
||||
editor.getMarkupModel().removeAllHighlighters();
|
||||
for (PreviewEditorFoldingRegion region : foldedRegions) {
|
||||
if (region.endLine - region.startLine > 1) {
|
||||
FoldRegion currentRegion = FoldingModelSupport.addFolding(myEditor,
|
||||
FoldRegion currentRegion = FoldingModelSupport.addFolding(editor,
|
||||
region.startLine,
|
||||
region.endLine,
|
||||
false);
|
||||
if (currentRegion != null) {
|
||||
DiffDrawUtil.createLineSeparatorHighlighter(myEditor,
|
||||
myDocument.getLineStartOffset(region.startLine),
|
||||
myDocument.getLineEndOffset(region.endLine - 1),
|
||||
DiffDrawUtil.createLineSeparatorHighlighter(editor,
|
||||
editor.getDocument().getLineStartOffset(region.startLine),
|
||||
editor.getDocument().getLineEndOffset(region.endLine - 1),
|
||||
() -> currentRegion.isValid() && !currentRegion.isExpanded());
|
||||
}
|
||||
}
|
||||
@@ -124,35 +120,35 @@ public class ProblemPreviewEditorPresentation {
|
||||
});
|
||||
}
|
||||
|
||||
private boolean appendFoldings(Segment toShowRange) {
|
||||
private static boolean makeVisible(SortedSet<PreviewEditorFoldingRegion> foldingRegions, Segment toShowRange, Document document) {
|
||||
if (toShowRange == null) return false;
|
||||
boolean isUpdated = false;
|
||||
final int startLine = Math.max(0, myDocument.getLineNumber(toShowRange.getStartOffset()) - 1);
|
||||
final int endLine = Math.min(myDocument.getLineCount(), myDocument.getLineNumber(toShowRange.getEndOffset()) + 2);
|
||||
for (PreviewEditorFoldingRegion range : new ArrayList<>(myFoldedRegions)) {
|
||||
final int startLine = Math.max(0, document.getLineNumber(toShowRange.getStartOffset()) - 1);
|
||||
final int endLine = Math.min(document.getLineCount(), document.getLineNumber(toShowRange.getEndOffset()) + 2);
|
||||
for (PreviewEditorFoldingRegion range : new ArrayList<>(foldingRegions)) {
|
||||
final boolean startInRegion = inRegion(startLine, range);
|
||||
final boolean endInRegion = inRegion(endLine, range);
|
||||
if (startInRegion && endInRegion) {
|
||||
myFoldedRegions.remove(range);
|
||||
foldingRegions.remove(range);
|
||||
if (range.startLine != startLine) {
|
||||
myFoldedRegions.add(new PreviewEditorFoldingRegion(range.startLine, startLine));
|
||||
foldingRegions.add(new PreviewEditorFoldingRegion(range.startLine, startLine));
|
||||
}
|
||||
if (endLine != range.endLine) {
|
||||
myFoldedRegions.add(new PreviewEditorFoldingRegion(endLine, range.endLine));
|
||||
foldingRegions.add(new PreviewEditorFoldingRegion(endLine, range.endLine));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (startInRegion) {
|
||||
myFoldedRegions.remove(range);
|
||||
foldingRegions.remove(range);
|
||||
if (range.startLine != startLine) {
|
||||
myFoldedRegions.add(new PreviewEditorFoldingRegion(range.startLine, startLine));
|
||||
foldingRegions.add(new PreviewEditorFoldingRegion(range.startLine, startLine));
|
||||
}
|
||||
isUpdated = true;
|
||||
}
|
||||
if (endInRegion) {
|
||||
myFoldedRegions.remove(range);
|
||||
foldingRegions.remove(range);
|
||||
if (endLine != range.endLine) {
|
||||
myFoldedRegions.add(new PreviewEditorFoldingRegion(endLine, range.endLine));
|
||||
foldingRegions.add(new PreviewEditorFoldingRegion(endLine, range.endLine));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -140,7 +140,6 @@ public class LanguageConsoleImpl extends ConsoleViewImpl implements LanguageCons
|
||||
myHistoryViewer = (EditorEx)editorFactory.createViewer(historyDocument, getProject(), EditorKind.CONSOLE);
|
||||
myHistoryViewer.getDocument().addDocumentListener(myDocumentAdapter);
|
||||
|
||||
myScrollBar.setOpaque(false);
|
||||
myScrollBar.setModel(new MyModel(myScrollBar, myHistoryViewer, myConsoleEditor));
|
||||
myScrollBar.putClientProperty(Alignment.class, Alignment.BOTTOM);
|
||||
|
||||
|
||||
+42
-51
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -16,81 +16,72 @@
|
||||
package com.intellij.openapi.wm.impl;
|
||||
|
||||
import com.intellij.ProjectTopics;
|
||||
import com.intellij.openapi.components.AbstractProjectComponent;
|
||||
import com.intellij.openapi.application.Application;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ModuleRootEvent;
|
||||
import com.intellij.openapi.roots.ModuleRootListener;
|
||||
import com.intellij.openapi.startup.StartupManager;
|
||||
import com.intellij.openapi.startup.StartupActivity;
|
||||
import com.intellij.openapi.wm.ToolWindow;
|
||||
import com.intellij.openapi.wm.ex.ToolWindowManagerEx;
|
||||
import com.intellij.openapi.wm.ext.LibraryDependentToolWindow;
|
||||
import com.intellij.util.messages.MessageBusConnection;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class LibraryDependentToolWindowManager extends AbstractProjectComponent {
|
||||
private final ToolWindowManagerEx myToolWindowManager;
|
||||
|
||||
protected LibraryDependentToolWindowManager(Project project, ToolWindowManagerEx toolWindowManager) {
|
||||
super(project);
|
||||
myToolWindowManager = toolWindowManager;
|
||||
}
|
||||
public class LibraryDependentToolWindowManager implements StartupActivity {
|
||||
|
||||
@Override
|
||||
public void projectOpened() {
|
||||
public void runActivity(@NotNull Project project) {
|
||||
final Application application = ApplicationManager.getApplication();
|
||||
if (application.isUnitTestMode() ||
|
||||
application.isHeadlessEnvironment()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final ModuleRootListener rootListener = new ModuleRootListener() {
|
||||
@Override
|
||||
public void rootsChanged(ModuleRootEvent event) {
|
||||
if (!myProject.isDisposed()) {
|
||||
checkToolWindowStatuses(myProject);
|
||||
}
|
||||
checkToolWindowStatuses(project);
|
||||
}
|
||||
};
|
||||
|
||||
StartupManager.getInstance(myProject).runWhenProjectIsInitialized(() -> {
|
||||
if (!myProject.isDisposed()) {
|
||||
checkToolWindowStatuses(myProject);
|
||||
final MessageBusConnection connection = myProject.getMessageBus().connect(myProject);
|
||||
connection.subscribe(ProjectTopics.PROJECT_ROOTS, rootListener);
|
||||
}
|
||||
checkToolWindowStatuses(project);
|
||||
|
||||
final MessageBusConnection connection = project.getMessageBus().connect(project);
|
||||
connection.subscribe(ProjectTopics.PROJECT_ROOTS, rootListener);
|
||||
}
|
||||
|
||||
private static void checkToolWindowStatuses(@NotNull final Project project) {
|
||||
ApplicationManager.getApplication().executeOnPooledThread(() -> {
|
||||
if (project.isDisposed()) return;
|
||||
|
||||
doCheckToolWindowStatuses(project);
|
||||
});
|
||||
}
|
||||
|
||||
private void checkToolWindowStatuses(@NotNull final Project project) {
|
||||
assert !project.isDisposed();
|
||||
private static void doCheckToolWindowStatuses(@NotNull final Project project) {
|
||||
final ToolWindowManagerEx toolWindowManagerEx = ToolWindowManagerEx.getInstanceEx(project);
|
||||
|
||||
DumbService.getInstance(project).smartInvokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (LibraryDependentToolWindow libraryToolWindow : Extensions.getExtensions(LibraryDependentToolWindow.EXTENSION_POINT_NAME)) {
|
||||
boolean exists;
|
||||
try {
|
||||
exists = libraryToolWindow.getLibrarySearchHelper().isLibraryExists(project);
|
||||
}
|
||||
catch (ProcessCanceledException e) {
|
||||
exists = false;
|
||||
DumbService.getInstance(project).smartInvokeLater(this);
|
||||
}
|
||||
if (exists) {
|
||||
ensureToolWindowExists(libraryToolWindow);
|
||||
}
|
||||
else {
|
||||
ToolWindow toolWindow = myToolWindowManager.getToolWindow(libraryToolWindow.id);
|
||||
if (toolWindow != null) {
|
||||
myToolWindowManager.unregisterToolWindow(libraryToolWindow.id);
|
||||
}
|
||||
for (LibraryDependentToolWindow libraryToolWindow : Extensions.getExtensions(LibraryDependentToolWindow.EXTENSION_POINT_NAME)) {
|
||||
boolean exists = DumbService.getInstance(project)
|
||||
.runReadActionInSmartMode(() -> libraryToolWindow.getLibrarySearchHelper().isLibraryExists(project));
|
||||
|
||||
ApplicationManager.getApplication().invokeLater(() -> {
|
||||
ToolWindow toolWindow = toolWindowManagerEx.getToolWindow(libraryToolWindow.id);
|
||||
|
||||
if (exists) {
|
||||
if (toolWindow == null) {
|
||||
toolWindowManagerEx.initToolWindow(libraryToolWindow);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void ensureToolWindowExists(LibraryDependentToolWindow extension) {
|
||||
ToolWindow toolWindow = myToolWindowManager.getToolWindow(extension.id);
|
||||
if (toolWindow == null) {
|
||||
myToolWindowManager.initToolWindow(extension);
|
||||
else {
|
||||
if (toolWindow != null) {
|
||||
toolWindowManagerEx.unregisterToolWindow(libraryToolWindow.id);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -579,7 +579,10 @@ title.file.status.colors=File Status Colors
|
||||
title.file.status.color=File Status Color
|
||||
file.status.colors.header.status=File Status
|
||||
file.status.colors.header.color=Color
|
||||
file.status.color.none=Normal text
|
||||
file.status.color.none=Default
|
||||
file.status.color.menu.choose.color=Choose Color...
|
||||
file.status.color.menu.normal.text=Set to Default UI Font Color
|
||||
file.status.color.menu.reset.to.default=Restore Default
|
||||
title.scope.based=By Scope
|
||||
title.colors.and.fonts=Color Scheme
|
||||
progress.analysing.font=Analysing font: {0}
|
||||
|
||||
@@ -22,10 +22,9 @@
|
||||
<implementation-class>com.intellij.openapi.wm.impl.WindowDressing</implementation-class>
|
||||
<skipForDefaultProject/>
|
||||
</component>
|
||||
<component>
|
||||
<implementation-class>com.intellij.openapi.wm.impl.LibraryDependentToolWindowManager</implementation-class>
|
||||
<headless-implementation-class/>
|
||||
<skipForDefaultProject/>
|
||||
</component>
|
||||
</project-components>
|
||||
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
<postStartupActivity implementation="com.intellij.openapi.wm.impl.LibraryDependentToolWindowManager"/>
|
||||
</extensions>
|
||||
</idea-plugin>
|
||||
@@ -36,7 +36,7 @@ abstract class VmConnection<T : Vm> : Disposable {
|
||||
|
||||
private val stateRef = AtomicReference(ConnectionState(ConnectionStatus.NOT_CONNECTED))
|
||||
|
||||
private val dispatcher = EventDispatcher.create(DebugEventListener::class.java)
|
||||
open protected val dispatcher: EventDispatcher<DebugEventListener> = EventDispatcher.create(DebugEventListener::class.java)
|
||||
private val connectionDispatcher = ContainerUtil.createLockFreeCopyOnWriteList<(ConnectionState) -> Unit>()
|
||||
|
||||
@Volatile var vm: T? = null
|
||||
|
||||
@@ -29,8 +29,6 @@ import java.lang.management.ManagementFactory;
|
||||
import java.lang.management.MemoryNotificationInfo;
|
||||
import java.lang.management.MemoryPoolMXBean;
|
||||
import java.lang.management.MemoryType;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Future;
|
||||
@@ -65,7 +63,6 @@ public class LowMemoryWatcherManager implements Disposable {
|
||||
long threshold = Math.min((long) (max * getOccupiedMemoryThreshold()), max - MEM_THRESHOLD);
|
||||
if (threshold > 0) {
|
||||
bean.setUsageThreshold(threshold);
|
||||
bean.setCollectionUsageThreshold(threshold);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -80,12 +77,7 @@ public class LowMemoryWatcherManager implements Disposable {
|
||||
private final NotificationListener myLowMemoryListener = new NotificationListener() {
|
||||
@Override
|
||||
public void handleNotification(Notification notification, Object __) {
|
||||
if (MemoryNotificationInfo.MEMORY_THRESHOLD_EXCEEDED.equals(notification.getType()) ||
|
||||
MemoryNotificationInfo.MEMORY_COLLECTION_THRESHOLD_EXCEEDED.equals(notification.getType())) {
|
||||
|
||||
if (Runtime.getRuntime().freeMemory() >= Runtime.getRuntime().maxMemory() * (1 - getOccupiedMemoryThreshold())) {
|
||||
return;
|
||||
}
|
||||
if (MemoryNotificationInfo.MEMORY_THRESHOLD_EXCEEDED.equals(notification.getType())) {
|
||||
|
||||
if (Registry.is("low.memory.watcher.sync", true)) {
|
||||
handleEventImmediately();
|
||||
|
||||
@@ -21,7 +21,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public abstract class FileAccessorCache<K, T> implements com.intellij.util.containers.hash.EqualityPolicy<K> {
|
||||
/*@GuardedBy("myCacheLock")*/ private final SLRUMap<K, Handle<T>> myCache;
|
||||
@@ -53,22 +52,11 @@ public abstract class FileAccessorCache<K, T> implements com.intellij.util.conta
|
||||
}
|
||||
}
|
||||
|
||||
//private static final int FACTOR = 0xF;
|
||||
//private static final AtomicLong myCreateTime = new AtomicLong();
|
||||
//private static final AtomicInteger myCreateRequests = new AtomicInteger();
|
||||
//private static final AtomicInteger myCloseRequests = new AtomicInteger();
|
||||
//private static final AtomicLong myCloseTime = new AtomicLong();
|
||||
@NotNull
|
||||
private Handle<T> createHandle(K key) {
|
||||
Handle<T> cached;
|
||||
try {
|
||||
//long started = System.nanoTime();
|
||||
cached = new Handle<T>(createAccessor(key), this);
|
||||
//myCreateTime.addAndGet(System.nanoTime() - started);
|
||||
//int l = myCreateRequests.incrementAndGet();
|
||||
//if ((l & FACTOR) == 0) {
|
||||
// System.out.println("Opened for:" + this + ", " + l + " for " + (myCreateTime.get() / 1000000));
|
||||
//}
|
||||
cached.allocate();
|
||||
|
||||
synchronized (myCacheLock) {
|
||||
@@ -90,9 +78,6 @@ public abstract class FileAccessorCache<K, T> implements com.intellij.util.conta
|
||||
myElementsToBeDisposed.clear();
|
||||
}
|
||||
|
||||
//assert Thread.holdsLock(myUpdateLock);
|
||||
|
||||
//long started = System.nanoTime();
|
||||
for (T t : fileAccessorsToBeDisposed) {
|
||||
try {
|
||||
disposeAccessor(t);
|
||||
@@ -101,12 +86,6 @@ public abstract class FileAccessorCache<K, T> implements com.intellij.util.conta
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
//myCloseTime.addAndGet(System.nanoTime() - started);
|
||||
//int l = myCloseRequests.addAndGet(fileAccessorsToBeDisposed.size());
|
||||
//if ((l & FACTOR) == 0) {
|
||||
// System.out.println("Closed for:" + this + ", " + l + " for " + (myCloseTime.get() / 1000000));
|
||||
//}
|
||||
}
|
||||
|
||||
public Handle<T> getIfCached(K key) {
|
||||
@@ -155,30 +134,19 @@ public abstract class FileAccessorCache<K, T> implements com.intellij.util.conta
|
||||
return val1.equals(val2);
|
||||
}
|
||||
|
||||
public static final class Handle<T> {
|
||||
public static final class Handle<T> extends ResourceHandle<T> {
|
||||
private final FileAccessorCache<?, T> myOwner;
|
||||
private final T myFileAccessor;
|
||||
private final AtomicInteger myRefCount = new AtomicInteger(1);
|
||||
|
||||
|
||||
public Handle(T fileAccessor, FileAccessorCache<?, T> owner) {
|
||||
myFileAccessor = fileAccessor;
|
||||
super(fileAccessor);
|
||||
myOwner = owner;
|
||||
}
|
||||
|
||||
private void allocate() {
|
||||
myRefCount.incrementAndGet();
|
||||
}
|
||||
|
||||
public final void release() {
|
||||
if (myRefCount.decrementAndGet() == 0) {
|
||||
synchronized (myOwner.myCacheLock) {
|
||||
myOwner.myElementsToBeDisposed.add(myFileAccessor);
|
||||
}
|
||||
@Override
|
||||
protected void disposeResource() {
|
||||
synchronized (myOwner.myCacheLock) {
|
||||
myOwner.myElementsToBeDisposed.add(get());
|
||||
}
|
||||
}
|
||||
|
||||
public T get() {
|
||||
return myFileAccessor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright 2000-2017 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.util.io;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public abstract class ResourceHandle<T> implements Closeable {
|
||||
private final T myResource;
|
||||
private final AtomicInteger myRefCount = new AtomicInteger(1);
|
||||
|
||||
public ResourceHandle(T resource) {
|
||||
myResource = resource;
|
||||
}
|
||||
|
||||
public void allocate() {
|
||||
myRefCount.incrementAndGet();
|
||||
}
|
||||
|
||||
public final void release() {
|
||||
if (myRefCount.decrementAndGet() == 0) {
|
||||
disposeResource();
|
||||
}
|
||||
}
|
||||
|
||||
public T get() {
|
||||
return myResource;
|
||||
}
|
||||
|
||||
public int getRefCount() {
|
||||
return myRefCount.get();
|
||||
}
|
||||
|
||||
protected abstract void disposeResource();
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
release();
|
||||
}
|
||||
}
|
||||
-1080
File diff suppressed because it is too large
Load Diff
+1284
File diff suppressed because it is too large
Load Diff
+40
-11
@@ -18,7 +18,9 @@ package org.jetbrains.idea.maven.execution;
|
||||
import com.intellij.execution.JUnitPatcher;
|
||||
import com.intellij.execution.configurations.JavaParameters;
|
||||
import com.intellij.execution.configurations.ParametersList;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jdom.Element;
|
||||
@@ -33,6 +35,7 @@ import org.jetbrains.idea.maven.project.MavenProjectsManager;
|
||||
import org.jetbrains.idea.maven.project.MavenTestRunningSettings;
|
||||
import org.jetbrains.idea.maven.utils.MavenJDOMUtil;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
@@ -43,6 +46,7 @@ import java.util.regex.Pattern;
|
||||
*/
|
||||
public class MavenJUnitPatcher extends JUnitPatcher {
|
||||
public static final Pattern PROPERTY_PATTERN = Pattern.compile("\\$\\{(.+?)\\}");
|
||||
private static final Logger LOG = Logger.getInstance(MavenJUnitPatcher.class);
|
||||
|
||||
@Override
|
||||
public void patchJavaParameters(@Nullable Module module, JavaParameters javaParameters) {
|
||||
@@ -78,17 +82,42 @@ public class MavenJUnitPatcher extends JUnitPatcher {
|
||||
}
|
||||
}
|
||||
|
||||
if (testRunningSettings.isPassSystemProperties() && isEnabled(plugin, "systemPropertyVariables")) {
|
||||
Element systemPropertyVariables = config.getChild("systemPropertyVariables");
|
||||
if (systemPropertyVariables != null) {
|
||||
for (Element element : systemPropertyVariables.getChildren()) {
|
||||
String propertyName = element.getName();
|
||||
|
||||
if (!javaParameters.getVMParametersList().hasProperty(propertyName)) {
|
||||
String value = resolvePluginProperties(plugin, element.getValue(), domModel);
|
||||
value = resolveVmProperties(javaParameters.getVMParametersList(), value);
|
||||
if (isResolved(plugin, value)) {
|
||||
javaParameters.getVMParametersList().addProperty(propertyName, value);
|
||||
if (testRunningSettings.isPassSystemProperties()) {
|
||||
if (isEnabled(plugin, "systemPropertyVariables")) {
|
||||
Element systemPropertyVariables = config.getChild("systemPropertyVariables");
|
||||
if (systemPropertyVariables != null) {
|
||||
for (Element element : systemPropertyVariables.getChildren()) {
|
||||
String propertyName = element.getName();
|
||||
if (!javaParameters.getVMParametersList().hasProperty(propertyName)) {
|
||||
String value = resolvePluginProperties(plugin, element.getValue(), domModel);
|
||||
value = resolveVmProperties(javaParameters.getVMParametersList(), value);
|
||||
if (isResolved(plugin, value)) {
|
||||
javaParameters.getVMParametersList().addProperty(propertyName, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isEnabled(plugin, "systemPropertiesFile")) {
|
||||
Element systemPropertiesFile = config.getChild("systemPropertiesFile");
|
||||
if (systemPropertiesFile != null) {
|
||||
String systemPropertiesFilePath = systemPropertiesFile.getTextTrim();
|
||||
if (StringUtil.isNotEmpty(systemPropertiesFilePath) && !FileUtil.isAbsolute(systemPropertiesFilePath)) {
|
||||
systemPropertiesFilePath = mavenProject.getDirectory() + '/' + systemPropertiesFilePath;
|
||||
}
|
||||
if (StringUtil.isNotEmpty(systemPropertiesFilePath) && new File(systemPropertiesFilePath).exists()) {
|
||||
try {
|
||||
Reader fis = new BufferedReader(new FileReader(systemPropertiesFilePath));
|
||||
try {
|
||||
Map<String, String> properties = FileUtil.loadProperties(fis);
|
||||
properties.forEach((pName, pValue) -> javaParameters.getVMParametersList().addProperty(pName, pValue));
|
||||
}
|
||||
finally {
|
||||
fis.close();
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.warn("Can't read property file '" + systemPropertiesFilePath + "': " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-8
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -41,7 +41,6 @@ import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
@@ -80,12 +79,7 @@ public class UnusedPropertyInspection extends PropertiesInspectionBase implement
|
||||
}
|
||||
if (modules.isEmpty()) return null;
|
||||
|
||||
List<Module> list = ContainerUtil.newArrayList(modules);
|
||||
GlobalSearchScope result = GlobalSearchScope.moduleWithDependentsScope(list.get(0));
|
||||
for (int i = 1; i < list.size(); i++) {
|
||||
result = result.uniteWith(GlobalSearchScope.moduleWithDependentsScope(list.get(i)));
|
||||
}
|
||||
return result;
|
||||
return GlobalSearchScope.union(modules.stream().map(Module::getModuleWithDependentsScope).toArray(GlobalSearchScope[]::new));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -43,7 +43,7 @@ public enum LanguageLevel {
|
||||
public static List<LanguageLevel> ALL_LEVELS = ImmutableList.copyOf(values());
|
||||
|
||||
private static final LanguageLevel DEFAULT2 = PYTHON27;
|
||||
private static final LanguageLevel DEFAULT3 = PYTHON35;
|
||||
private static final LanguageLevel DEFAULT3 = PYTHON36;
|
||||
|
||||
public static LanguageLevel FORCE_LANGUAGE_LEVEL = null;
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.intellij.lang.WhitespacesBinders;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.jetbrains.python.PyElementTypes;
|
||||
import com.jetbrains.python.PyTokenTypes;
|
||||
import com.jetbrains.python.psi.LanguageLevel;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static com.jetbrains.python.PyBundle.message;
|
||||
@@ -163,7 +164,7 @@ public class FunctionParsing extends Parsing {
|
||||
}
|
||||
boolean isStarParameter = atAnyOfTokens(PyTokenTypes.MULT, PyTokenTypes.EXP);
|
||||
if (!parseParameter(endToken, isLambda)) {
|
||||
if (afterStarParameter) {
|
||||
if (afterStarParameter && myContext.getLanguageLevel().isOlderThan(LanguageLevel.PYTHON36)) {
|
||||
myBuilder.error("expression expected");
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
def f1(*, x,):
|
||||
pass
|
||||
|
||||
|
||||
def f2(*args,):
|
||||
pass
|
||||
|
||||
|
||||
def f3(**kwargs,):
|
||||
pass
|
||||
|
||||
|
||||
lambda *, x,: 42
|
||||
lambda *args,: 42
|
||||
lambda *kwargs,: 42
|
||||
@@ -0,0 +1,99 @@
|
||||
PyFile:CommaAfterStarArgAllowedInPython36.py
|
||||
PyFunction('f1')
|
||||
PsiElement(Py:DEF_KEYWORD)('def')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:IDENTIFIER)('f1')
|
||||
PyParameterList
|
||||
PsiElement(Py:LPAR)('(')
|
||||
PySingleStarParameter
|
||||
PsiElement(Py:MULT)('*')
|
||||
PsiElement(Py:COMMA)(',')
|
||||
PsiWhiteSpace(' ')
|
||||
PyNamedParameter('x')
|
||||
PsiElement(Py:IDENTIFIER)('x')
|
||||
PsiElement(Py:COMMA)(',')
|
||||
PsiElement(Py:RPAR)(')')
|
||||
PsiElement(Py:COLON)(':')
|
||||
PsiWhiteSpace('\n ')
|
||||
PyStatementList
|
||||
PyPassStatement
|
||||
PsiElement(Py:PASS_KEYWORD)('pass')
|
||||
PsiWhiteSpace('\n\n\n')
|
||||
PyFunction('f2')
|
||||
PsiElement(Py:DEF_KEYWORD)('def')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:IDENTIFIER)('f2')
|
||||
PyParameterList
|
||||
PsiElement(Py:LPAR)('(')
|
||||
PyNamedParameter('args')
|
||||
PsiElement(Py:MULT)('*')
|
||||
PsiElement(Py:IDENTIFIER)('args')
|
||||
PsiElement(Py:COMMA)(',')
|
||||
PsiElement(Py:RPAR)(')')
|
||||
PsiElement(Py:COLON)(':')
|
||||
PsiWhiteSpace('\n ')
|
||||
PyStatementList
|
||||
PyPassStatement
|
||||
PsiElement(Py:PASS_KEYWORD)('pass')
|
||||
PsiWhiteSpace('\n\n\n')
|
||||
PyFunction('f3')
|
||||
PsiElement(Py:DEF_KEYWORD)('def')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:IDENTIFIER)('f3')
|
||||
PyParameterList
|
||||
PsiElement(Py:LPAR)('(')
|
||||
PyNamedParameter('kwargs')
|
||||
PsiElement(Py:EXP)('**')
|
||||
PsiElement(Py:IDENTIFIER)('kwargs')
|
||||
PsiElement(Py:COMMA)(',')
|
||||
PsiElement(Py:RPAR)(')')
|
||||
PsiElement(Py:COLON)(':')
|
||||
PsiWhiteSpace('\n ')
|
||||
PyStatementList
|
||||
PyPassStatement
|
||||
PsiElement(Py:PASS_KEYWORD)('pass')
|
||||
PsiWhiteSpace('\n\n\n')
|
||||
PyExpressionStatement
|
||||
PyLambdaExpression
|
||||
PsiElement(Py:LAMBDA_KEYWORD)('lambda')
|
||||
PsiWhiteSpace(' ')
|
||||
PyParameterList
|
||||
PySingleStarParameter
|
||||
PsiElement(Py:MULT)('*')
|
||||
PsiElement(Py:COMMA)(',')
|
||||
PsiWhiteSpace(' ')
|
||||
PyNamedParameter('x')
|
||||
PsiElement(Py:IDENTIFIER)('x')
|
||||
PsiElement(Py:COMMA)(',')
|
||||
PsiElement(Py:COLON)(':')
|
||||
PsiWhiteSpace(' ')
|
||||
PyNumericLiteralExpression
|
||||
PsiElement(Py:INTEGER_LITERAL)('42')
|
||||
PsiWhiteSpace('\n')
|
||||
PyExpressionStatement
|
||||
PyLambdaExpression
|
||||
PsiElement(Py:LAMBDA_KEYWORD)('lambda')
|
||||
PsiWhiteSpace(' ')
|
||||
PyParameterList
|
||||
PyNamedParameter('args')
|
||||
PsiElement(Py:MULT)('*')
|
||||
PsiElement(Py:IDENTIFIER)('args')
|
||||
PsiElement(Py:COMMA)(',')
|
||||
PsiElement(Py:COLON)(':')
|
||||
PsiWhiteSpace(' ')
|
||||
PyNumericLiteralExpression
|
||||
PsiElement(Py:INTEGER_LITERAL)('42')
|
||||
PsiWhiteSpace('\n')
|
||||
PyExpressionStatement
|
||||
PyLambdaExpression
|
||||
PsiElement(Py:LAMBDA_KEYWORD)('lambda')
|
||||
PsiWhiteSpace(' ')
|
||||
PyParameterList
|
||||
PyNamedParameter('kwargs')
|
||||
PsiElement(Py:MULT)('*')
|
||||
PsiElement(Py:IDENTIFIER)('kwargs')
|
||||
PsiElement(Py:COMMA)(',')
|
||||
PsiElement(Py:COLON)(':')
|
||||
PsiWhiteSpace(' ')
|
||||
PyNumericLiteralExpression
|
||||
PsiElement(Py:INTEGER_LITERAL)('42')
|
||||
@@ -335,6 +335,11 @@ public class PythonParsingTest extends ParsingTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-24389
|
||||
public void testCommaAfterStarArgAllowedInPython36() {
|
||||
doTest(LanguageLevel.PYTHON36);
|
||||
}
|
||||
|
||||
public void testRangeAsLHS() { // PY-6468
|
||||
doTest();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user