diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/FixDocCommentAction.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/FixDocCommentAction.java index 7da490ea2364..5d602ea6ea3f 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/FixDocCommentAction.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/FixDocCommentAction.java @@ -1,18 +1,4 @@ -/* - * 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. - */ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.codeInsight.editorActions; import com.intellij.codeInsight.FileModificationService; @@ -25,6 +11,7 @@ import com.intellij.openapi.actionSystem.CommonDataKeys; import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.command.CommandProcessor; +import com.intellij.openapi.editor.Caret; import com.intellij.openapi.editor.CaretModel; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.Editor; @@ -38,6 +25,7 @@ import com.intellij.psi.codeStyle.CodeStyleManager; import com.intellij.util.text.CharArrayUtil; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Creates documentation comment for the current context if it's not created yet (e.g. the caret is inside a method which @@ -60,7 +48,7 @@ public class FixDocCommentAction extends EditorAction { private static final class MyHandler extends EditorActionHandler { @Override - public void execute(@NotNull Editor editor, DataContext dataContext) { + public void doExecute(@NotNull Editor editor, @Nullable Caret caret, DataContext dataContext) { Project project = CommonDataKeys.PROJECT.getData(dataContext); if (project == null) { return; @@ -223,6 +211,7 @@ public class FixDocCommentAction extends EditorAction { if (caretOffsetToSet >= 0) { caretModel.moveToOffset(caretOffsetToSet); + editor.getSelectionModel().removeSelection(); } if (pair == null || pair.second == null) { diff --git a/platform/lang-impl/src/com/intellij/ide/actions/runAnything/RunAnythingAction.java b/platform/lang-impl/src/com/intellij/ide/actions/runAnything/RunAnythingAction.java index 88258f291620..ed250425c7eb 100644 --- a/platform/lang-impl/src/com/intellij/ide/actions/runAnything/RunAnythingAction.java +++ b/platform/lang-impl/src/com/intellij/ide/actions/runAnything/RunAnythingAction.java @@ -394,7 +394,7 @@ public class RunAnythingAction extends AnAction implements CustomComponentAction myCurrentWorker.doWhenProcessed(() -> { myCalcThread = new CalcThread(project, pattern, true); myPopupActualWidth = 0; - RunAnythingUtil.triggerMoreStatistics(group); + RunAnythingUtil.triggerMoreStatistics(project, group); myCurrentWorker = myCalcThread.insert(index, group); }); @@ -416,7 +416,7 @@ public class RunAnythingAction extends AnAction implements CustomComponentAction return; } - RunAnythingUtil.triggerExecCategoryStatistics(index); + RunAnythingUtil.triggerExecCategoryStatistics(project, index); Runnable onDone = null; try { diff --git a/platform/lang-impl/src/com/intellij/ide/actions/runAnything/RunAnythingRunConfigurationItem.java b/platform/lang-impl/src/com/intellij/ide/actions/runAnything/RunAnythingRunConfigurationItem.java index 4052858bb249..01642ddd42bf 100644 --- a/platform/lang-impl/src/com/intellij/ide/actions/runAnything/RunAnythingRunConfigurationItem.java +++ b/platform/lang-impl/src/com/intellij/ide/actions/runAnything/RunAnythingRunConfigurationItem.java @@ -52,8 +52,8 @@ public class RunAnythingRunConfigurationItem extends RunAnythingItem= 0; i--) { String title = RunAnythingGroup.getTitle(i); if (title != null) { - UsageTrigger.trigger(RunAnythingAction.RUN_ANYTHING + " - execution - " + title); + RunAnythingUsageCollector.Companion.trigger(project, RunAnythingAction.RUN_ANYTHING + " - execution - " + title); break; } } } - public static void triggerDebuggerStatistics() { - if (SHIFT_IS_PRESSED.get()) UsageTrigger.trigger(DEBUGGER_FEATURE_USAGE); + public static void triggerDebuggerStatistics(@NotNull DataContext dataContext) { + Project project = Objects.requireNonNull(CommonDataKeys.PROJECT.getData(dataContext)); + Executor executor = Objects.requireNonNull(EXECUTOR_KEY.getData(dataContext)); + + if (ExecutorRegistry.getInstance().getExecutorById(ToolWindowId.DEBUG) == executor) { + RunAnythingUsageCollector.Companion.trigger(project, DEBUGGER_FEATURE_USAGE); + } } - static void triggerMoreStatistics(@NotNull RunAnythingGroup group) { - UsageTrigger.trigger(RunAnythingAction.RUN_ANYTHING + " - more - " + group.getTitle()); + static void triggerMoreStatistics(@NotNull Project project, @NotNull RunAnythingGroup group) { + RunAnythingUsageCollector.Companion.trigger(project, RunAnythingAction.RUN_ANYTHING + " - more - " + group.getTitle()); } @NotNull diff --git a/platform/lang-impl/src/com/intellij/ide/actions/runAnything/items/RunAnythingCommandItem.java b/platform/lang-impl/src/com/intellij/ide/actions/runAnything/items/RunAnythingCommandItem.java index cf904851625c..4270c2e1e95a 100644 --- a/platform/lang-impl/src/com/intellij/ide/actions/runAnything/items/RunAnythingCommandItem.java +++ b/platform/lang-impl/src/com/intellij/ide/actions/runAnything/items/RunAnythingCommandItem.java @@ -106,8 +106,8 @@ public class RunAnythingCommandItem extends RunAnythingItem { } @Override - public void triggerUsage() { - RunAnythingUtil.triggerDebuggerStatistics(); + public void triggerUsage(@NotNull DataContext dataContext) { + RunAnythingUtil.triggerDebuggerStatistics(dataContext); } @NotNull diff --git a/platform/lang-impl/src/com/intellij/ide/actions/runAnything/items/RunAnythingItem.java b/platform/lang-impl/src/com/intellij/ide/actions/runAnything/items/RunAnythingItem.java index 6fbf5960c951..21f5462c32bd 100644 --- a/platform/lang-impl/src/com/intellij/ide/actions/runAnything/items/RunAnythingItem.java +++ b/platform/lang-impl/src/com/intellij/ide/actions/runAnything/items/RunAnythingItem.java @@ -47,8 +47,9 @@ public abstract class RunAnythingItem { /** * Sends statistic if current item action is being executed + * @param dataContext Use {@link DataContext} to extract focus owner component, original action event, working directory, module and project */ - protected void triggerUsage() {} + protected void triggerUsage(@NotNull DataContext dataContext) {} /** * Executes specific action on choosing current item in the list @@ -56,6 +57,6 @@ public abstract class RunAnythingItem { * @param dataContext Use {@link DataContext} to extract focus owner component, original action event, working directory, module and project */ public void run(@NotNull DataContext dataContext) { - triggerUsage(); + triggerUsage(dataContext); } } diff --git a/platform/lang-impl/src/com/intellij/tools/FilterDialog.java b/platform/lang-impl/src/com/intellij/tools/FilterDialog.java deleted file mode 100644 index 7bc00f98f75f..000000000000 --- a/platform/lang-impl/src/com/intellij/tools/FilterDialog.java +++ /dev/null @@ -1,207 +0,0 @@ -/* - * 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.tools; - -import com.intellij.CommonBundle; -import com.intellij.execution.filters.InvalidExpressionException; -import com.intellij.execution.filters.RegexpFilter; -import com.intellij.openapi.ui.DialogWrapper; -import com.intellij.openapi.ui.JBPopupMenu; -import com.intellij.openapi.ui.Messages; -import com.intellij.openapi.wm.IdeFocusManager; -import com.intellij.ui.PopupHandler; -import com.intellij.util.ui.JBUI; - -import javax.swing.*; -import javax.swing.text.BadLocationException; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.regex.PatternSyntaxException; - -class FilterDialog extends DialogWrapper { - private final JTextField myRegexpField = new JTextField(); - private final JTextField myNameField = new JTextField(); - private final JTextField myDescriptionField = new JTextField(); - - private JPopupMenu myPopup; - - private FilterDialog(Component component) { - super(component, true); - init(); - setOKActionEnabled(true); - myRegexpField.setToolTipText(ToolsBundle.message("tools.filters.add.macro.tooltip")); - } - - public static boolean editFilter(FilterInfo filterInfo, JComponent parentComponent, String title) throws InvalidExpressionException { - FilterDialog dialog = new FilterDialog(parentComponent); - dialog.setTitle(title); - dialog.myNameField.setText(filterInfo.getName()); - dialog.myDescriptionField.setText(filterInfo.getDescription()); - dialog.myRegexpField.setText(filterInfo.getRegExp()); - if (!dialog.showAndGet()) { - return false; - } - filterInfo.setName(dialog.myNameField.getText()); - filterInfo.setDescription(dialog.myDescriptionField.getText()); - filterInfo.setRegExp(dialog.myRegexpField.getText()); - return true; - } - - @Override - public JComponent getPreferredFocusedComponent() { - return myRegexpField; - } - - @Override - protected JComponent createCenterPanel() { - JPanel mainPanel = new JPanel(new BorderLayout()); - - JPanel panel = new JPanel(new GridBagLayout()); - - GridBagConstraints constr; - - constr = new GridBagConstraints(); - constr.gridx = 0; - constr.gridy = 0; - constr.anchor = GridBagConstraints.WEST; - constr.weighty = 0; - constr.gridwidth = 1; - constr.insets = new Insets(5, 0, 0, 0); - panel.add(new JLabel(ToolsBundle.message("tools.filters.add.name.label")), constr); - - constr.gridx = 0; - constr.gridy = 1; - constr.weightx = 1; - constr.gridwidth = 3; - constr.fill = GridBagConstraints.HORIZONTAL; - panel.add(myNameField, constr); - - constr.gridx = 0; - constr.gridy = 2; - constr.weightx = 0; - panel.add(new JLabel(ToolsBundle.message("tools.filters.add.description.label")), constr); - - constr.gridx = 0; - constr.gridy = 3; - constr.gridwidth = 2; - constr.weightx = 1; - panel.add(myDescriptionField, constr); - - constr.gridy = 4; - constr.gridx = 0; - constr.gridwidth = 2; - constr.weightx = 0; - panel.add(new JLabel(ToolsBundle.message("tools.filters.add.regex.label")), constr); - - constr.gridx = 0; - constr.gridy = 5; - constr.gridwidth = 3; - panel.add(myRegexpField, constr); - - makePopup(); - - panel.setPreferredSize(JBUI.size(335, 160)); - - mainPanel.add(panel, BorderLayout.NORTH); - - return mainPanel; - } - - private void makePopup() { - myPopup = new JBPopupMenu(); - String[] macrosName = RegexpFilter.getMacrosName(); - JMenuItem[] items = new JMenuItem[macrosName.length]; - for (int i = 0; i < macrosName.length; i++) { - items[i] = myPopup.add(macrosName[i]); - items[i].addActionListener(new MenuItemListener(macrosName[i])); - } - myRegexpField.addMouseListener(new PopupListener()); - } - - @Override - protected void doOKAction() { - String errorMessage = null; - if (noText(myNameField.getText())) { - errorMessage = ToolsBundle.message("tools.filters.add.name.required.error"); - } else if (noText(myRegexpField.getText())) { - errorMessage = ToolsBundle.message("tools.filters.add.regex.required.error"); - } - - if (errorMessage != null) { - Messages.showMessageDialog(getContentPane(), errorMessage, CommonBundle.getErrorTitle(), Messages.getErrorIcon()); - return; - } - - try { - checkRegexp(myRegexpField.getText()); - } - catch (InvalidExpressionException | PatternSyntaxException e) { - Messages.showMessageDialog(getContentPane(), e.getMessage(), ToolsBundle.message("tools.filters.add.regex.invalid.title"), Messages.getErrorIcon()); - return; - } - super.doOKAction(); - } - - private void checkRegexp(String regexpText) { - RegexpFilter.validate(regexpText); - } - - private boolean noText(String text) { - return "".equals(text); - } - - @Override - protected String getDimensionServiceKey(){ - return "#com.intellij.tools.FilterDialog"; - } - - @Override - protected String getHelpId() { - return "reference.settings.ide.settings.external.tools.output.filters.add.filter"; - } - - private class MenuItemListener implements ActionListener { - private final String myMacrosName; - - private MenuItemListener(String macrosName) { - myMacrosName = macrosName; - } - - @Override - public void actionPerformed(ActionEvent e) { - int position = myRegexpField.getCaretPosition(); - try { - if (myRegexpField.getText().indexOf(myMacrosName) == -1) { - myRegexpField.getDocument().insertString(position, myMacrosName, null); - myRegexpField.setCaretPosition(position + myMacrosName.length()); - } - } catch (BadLocationException ex) { - } - IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> { - IdeFocusManager.getGlobalInstance().requestFocus(myRegexpField, true); - }); - } - } - - private class PopupListener extends PopupHandler { - @Override - public void invokePopup(Component comp, int x, int y) { - myPopup.show(comp, x, y); - } - } -} diff --git a/platform/lang-impl/src/com/intellij/tools/OutputFiltersDialog.java b/platform/lang-impl/src/com/intellij/tools/OutputFiltersDialog.java deleted file mode 100644 index f5a15e03fac1..000000000000 --- a/platform/lang-impl/src/com/intellij/tools/OutputFiltersDialog.java +++ /dev/null @@ -1,188 +0,0 @@ -/* - * 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.tools; - -import com.intellij.openapi.help.HelpManager; -import com.intellij.openapi.ui.DialogWrapper; -import com.intellij.openapi.wm.IdeFocusManager; -import com.intellij.ui.*; -import com.intellij.ui.components.JBList; -import org.jetbrains.annotations.NotNull; - -import javax.swing.*; -import java.awt.*; - -public class OutputFiltersDialog extends DialogWrapper { - private final DefaultListModel myFiltersModel = new DefaultListModel(); - private final JList myFiltersList = new JBList(myFiltersModel); - private boolean myModified = false; - private FilterInfo[] myFilters; - - public OutputFiltersDialog(Component parent, FilterInfo[] filters) { - super(parent, true); - myFilters = filters; - - setTitle(ToolsBundle.message("tools.filters.title")); - init(); - initGui(); - } - - @Override - @NotNull - protected Action[] createActions() { - return new Action[]{getOKAction(), getCancelAction(), getHelpAction()}; - } - - @Override - protected void doHelpAction() { - HelpManager.getInstance().invokeHelp("reference.settings.ide.settings.external.tools.output.filters"); - } - - private void initGui() { - myFiltersList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - myFiltersList.setCellRenderer(new ColoredListCellRenderer() { - @Override - protected void customizeCellRenderer(@NotNull JList list, Object value, int index, boolean selected, boolean hasFocus) { - FilterInfo info = (FilterInfo)value; - append(info.getName(), SimpleTextAttributes.REGULAR_ATTRIBUTES); - } - }); - ScrollingUtil.ensureSelectionExists(myFiltersList); - } - - private String suggestFilterName() { - String prefix = ToolsBundle.message("tools.filters.name.template") + " "; - - int number = 1; - for (int i = 0; i < myFiltersModel.getSize(); i++) { - FilterInfo wrapper = (FilterInfo)myFiltersModel.getElementAt(i); - String name = wrapper.getName(); - if (name.startsWith(prefix)) { - try { - int n = Integer.valueOf(name.substring(prefix.length()).trim()).intValue(); - number = Math.max(number, n + 1); - } - catch (NumberFormatException e) { - } - } - } - - return prefix + number; - } - - @Override - protected void doOKAction() { - if (myModified) { - myFilters = new FilterInfo[myFiltersModel.getSize()]; - for (int i = 0; i < myFiltersModel.getSize(); i++) { - myFilters[i] = (FilterInfo)myFiltersModel.get(i); - } - } - super.doOKAction(); - } - - @Override - protected JComponent createCenterPanel() { - for (FilterInfo myFilter : myFilters) { - myFiltersModel.addElement(myFilter.createCopy()); - } - - JPanel panel = ToolbarDecorator.createDecorator(myFiltersList) - .setAddAction(new AnActionButtonRunnable() { - @Override - public void run(AnActionButton button) { - FilterInfo filterInfo = new FilterInfo(); - filterInfo.setName(suggestFilterName()); - boolean wasCreated = FilterDialog.editFilter(filterInfo, myFiltersList, ToolsBundle.message("tools.filters.add.title")); - if (wasCreated) { - myFiltersModel.addElement(filterInfo); - setModified(true); - } - IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> { - IdeFocusManager.getGlobalInstance().requestFocus(myFiltersList, true); - }); - } - }).setEditAction(new AnActionButtonRunnable() { - @Override - public void run(AnActionButton button) { - int index = myFiltersList.getSelectedIndex(); - FilterInfo filterInfo = (FilterInfo)myFiltersModel.getElementAt(index); - boolean wasEdited = FilterDialog.editFilter(filterInfo, myFiltersList, ToolsBundle.message("tools.filters.edit.title")); - if (wasEdited) { - setModified(true); - } - IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> { - IdeFocusManager.getGlobalInstance().requestFocus(myFiltersList, true); - }); - } - }).setRemoveAction(new AnActionButtonRunnable() { - @Override - public void run(AnActionButton button) { - if (myFiltersList.getSelectedIndex() >= 0) { - myFiltersModel.removeElementAt(myFiltersList.getSelectedIndex()); - setModified(true); - } - IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> { - IdeFocusManager.getGlobalInstance().requestFocus(myFiltersList, true); - }); - } - }).setMoveUpAction(new AnActionButtonRunnable() { - @Override - public void run(AnActionButton button) { - int movedCount = ListUtil.moveSelectedItemsUp(myFiltersList); - if (movedCount > 0) { - setModified(true); - } - IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> { - IdeFocusManager.getGlobalInstance().requestFocus(myFiltersList, true); - }); - } - }).setMoveDownAction(new AnActionButtonRunnable() { - @Override - public void run(AnActionButton button) { - int movedCount = ListUtil.moveSelectedItemsDown(myFiltersList); - if (movedCount > 0) { - setModified(true); - } - IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> { - IdeFocusManager.getGlobalInstance().requestFocus(myFiltersList, true); - }); - } - }) - .createPanel(); - - return panel; - } - - @Override - public JComponent getPreferredFocusedComponent() { - return myFiltersList; - } - - private void setModified(boolean modified) { - myModified = modified; - } - - public FilterInfo[] getData() { - return myFilters; - } - - @Override - protected String getDimensionServiceKey() { - return "#com.intellij.tools.OutputFiltersDialog"; - } -} diff --git a/platform/platform-impl/src/com/intellij/diagnostic/IdeErrorsDialog.java b/platform/platform-impl/src/com/intellij/diagnostic/IdeErrorsDialog.java index e6f0b03077bc..b555c335ad6f 100644 --- a/platform/platform-impl/src/com/intellij/diagnostic/IdeErrorsDialog.java +++ b/platform/platform-impl/src/com/intellij/diagnostic/IdeErrorsDialog.java @@ -482,10 +482,10 @@ public class IdeErrorsDialog extends DialogWrapper implements MessagePoolListene myCredentialsLabel.setVisible(true); Credentials credentials = ErrorReportConfigurable.getCredentials(); if (CredentialAttributesKt.isFulfilled(credentials)) { - myCredentialsLabel.setHtmlText(DiagnosticBundle.message("diagnostic.error.report.submit.report.as", credentials.getUserName())); + myCredentialsLabel.setHtmlText(DiagnosticBundle.message("error.dialog.submit.named", credentials.getUserName())); } else { - myCredentialsLabel.setHtmlText(DiagnosticBundle.message("diagnostic.error.report.submit.error.anonymously")); + myCredentialsLabel.setHtmlText(DiagnosticBundle.message("error.dialog.submit.anonymous")); } } else { diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/EditorBasedStatusBarPopup.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/EditorBasedStatusBarPopup.java index 50663e75c6b6..3720dba3de5e 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/EditorBasedStatusBarPopup.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/EditorBasedStatusBarPopup.java @@ -13,7 +13,9 @@ import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.EditorFactory; import com.intellij.openapi.editor.event.DocumentEvent; import com.intellij.openapi.editor.event.DocumentListener; -import com.intellij.openapi.fileEditor.*; +import com.intellij.openapi.fileEditor.FileDocumentManager; +import com.intellij.openapi.fileEditor.FileEditorManager; +import com.intellij.openapi.fileEditor.FileEditorManagerEvent; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.popup.ListPopup; import com.intellij.openapi.util.Disposer; @@ -32,15 +34,11 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.awt.*; import java.awt.event.MouseEvent; -import java.lang.ref.Reference; -import java.lang.ref.WeakReference; public abstract class EditorBasedStatusBarPopup extends EditorBasedWidget implements StatusBarWidget.Multiframe, CustomStatusBarWidget { private final TextPanel.WithIconAndArrows myComponent; private boolean actionEnabled; private final Alarm update; - // store editor here to avoid expensive and EDT-only getSelectedEditor() retrievals - private volatile Reference myEditor = new WeakReference<>(null); public EditorBasedStatusBarPopup(@NotNull Project project) { super(project); @@ -66,22 +64,16 @@ public abstract class EditorBasedStatusBarPopup extends EditorBasedWidget implem @Override public void selectionChanged(@NotNull FileEditorManagerEvent event) { if (ApplicationManager.getApplication().isUnitTestMode()) return; - VirtualFile newFile = event.getNewFile(); - fileChanged(newFile); + fileChanged(); } - private void fileChanged(VirtualFile newFile) { - Project project = getProject(); - assert project != null; - FileEditor fileEditor = newFile == null ? null : FileEditorManager.getInstance(project).getSelectedEditor(newFile); - Editor editor = fileEditor instanceof TextEditor ? ((TextEditor)fileEditor).getEditor() : null; - myEditor = new WeakReference<>(editor); + private void fileChanged() { update(); } @Override public void fileOpened(@NotNull FileEditorManager source, @NotNull VirtualFile file) { - fileChanged(file); + fileChanged(); } @Override @@ -109,7 +101,7 @@ public abstract class EditorBasedStatusBarPopup extends EditorBasedWidget implem } protected void updateForDocument(@Nullable("null means update anyway") Document document) { - Editor selectedEditor = myEditor.get(); + Editor selectedEditor = getEditor(); if (document != null && (selectedEditor == null || selectedEditor.getDocument() != document)) return; update(); } diff --git a/platform/platform-resources-en/src/messages/DiagnosticBundle.properties b/platform/platform-resources-en/src/messages/DiagnosticBundle.properties index 85e0c4aa22a9..833b5cd8707f 100644 --- a/platform/platform-resources-en/src/messages/DiagnosticBundle.properties +++ b/platform/platform-resources-en/src/messages/DiagnosticBundle.properties @@ -33,10 +33,14 @@ error.dialog.foreign.plugin.warning.vendor=This plugin is not a production error.dialog.comment.prompt=Please fill in any details that may be important (steps to reproduce, what were you doing when the exception occurred, etc.): error.dialog.attachments.prompt=To investigate and fix the problem, we need the following files to be attached to the bug report.
\ Note: all the data you send will be kept private. -diagnostic.error.report.submit.error.anonymously=Submit anonymously or use JetBrains Account -diagnostic.error.report.submit.report.as=Submit as {0} or change account +error.dialog.submit.anonymous=Submit anonymously or use JetBrains Account +error.dialog.submit.named=Submit as {0} or change account error.report.to.jetbrains.action=&Report to JetBrains error.dialog.clear.all.action=&Clear all +# suppress inspection "UnusedProperty" +diagnostic.error.report.submit.error.anonymously=Submit anonymously or use JetBrains Account +# suppress inspection "UnusedProperty" +diagnostic.error.report.submit.report.as=Submit as {0} or change account title.submitting.error.report=Submitting Error Report error.report.gratitude=Thank you for your feedback! diff --git a/plugins/devkit/devkit-core/resources/org/jetbrains/idea/devkit/DevKitBundle.properties b/plugins/devkit/devkit-core/resources/org/jetbrains/idea/devkit/DevKitBundle.properties index 93773c949b82..151be56fd24a 100644 --- a/plugins/devkit/devkit-core/resources/org/jetbrains/idea/devkit/DevKitBundle.properties +++ b/plugins/devkit/devkit-core/resources/org/jetbrains/idea/devkit/DevKitBundle.properties @@ -187,7 +187,7 @@ inspections.plugin.xml.invalid.order.attribute=Invalid 'order' attribute value invalid.order.attribute.part=Invalid ''order'' attribute value part: ''{0}'', must be ''first'', ''last'', ''before '' or ''after '' inspections.unstable.api.usage.annotations.list=Unstable API annotations -inspections.unstable.api.usage.description=''{0}'' is unstable +inspections.unstable.api.usage.description=''{0}'' is marked unstable ant.build.jar.comment=Build archive for plugin ''{0}'' ant.build.jar.description=Build plugin archive for module ''{0}'' diff --git a/plugins/devkit/devkit-core/src/inspections/UnstableApiUsageInspection.java b/plugins/devkit/devkit-core/src/inspections/UnstableApiUsageInspection.java index ee7d04417669..c828423e3e43 100644 --- a/plugins/devkit/devkit-core/src/inspections/UnstableApiUsageInspection.java +++ b/plugins/devkit/devkit-core/src/inspections/UnstableApiUsageInspection.java @@ -6,10 +6,12 @@ import com.intellij.codeInspection.ProblemHighlightType; import com.intellij.codeInspection.ProblemsHolder; import com.intellij.codeInspection.util.SpecialAnnotationsUtil; import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.ProjectFileIndex; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.*; +import com.intellij.psi.search.GlobalSearchScope; import com.siyeh.ig.ui.ExternalizableStringSet; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -48,6 +50,10 @@ public class UnstableApiUsageInspection extends LocalInspectionTool { @NotNull @Override public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) { + if (!isApplicable(holder.getProject())) { + return PsiElementVisitor.EMPTY_VISITOR; + } + return new PsiElementVisitor() { @Override public void visitElement(PsiElement element) { @@ -67,13 +73,19 @@ public class UnstableApiUsageInspection extends LocalInspectionTool { } PsiModifierListOwner modifierListOwner = (PsiModifierListOwner)resolvedElement; + boolean problemRegistered = false; for (String annotation : unstableApiAnnotations) { if (modifierListOwner.hasAnnotation(annotation)) { holder.registerProblem(reference, DevKitBundle.message("inspections.unstable.api.usage.description", getReferenceText(reference)), ProblemHighlightType.GENERIC_ERROR_OR_WARNING); + problemRegistered = true; + break; } } + if (problemRegistered) { + break; + } } } }; @@ -106,4 +118,15 @@ public class UnstableApiUsageInspection extends LocalInspectionTool { // references are not PsiQualifiedReference for annotation attributes return StringUtil.getShortName(reference.getCanonicalText()); } + + private boolean isApplicable(@NotNull Project project) { + JavaPsiFacade javaPsiFacade = JavaPsiFacade.getInstance(project); + GlobalSearchScope scope = GlobalSearchScope.allScope(project); + for (String annotation : unstableApiAnnotations) { + if (javaPsiFacade.findClass(annotation, scope) != null) { + return true; + } + } + return false; + } } diff --git a/plugins/devkit/devkit-java-tests/testData/inspections/unstableApiUsage/UnstableElementsTest.java b/plugins/devkit/devkit-java-tests/testData/inspections/unstableApiUsage/UnstableElementsTest.java index c6f5c4801f4d..5f4585752093 100644 --- a/plugins/devkit/devkit-java-tests/testData/inspections/unstableApiUsage/UnstableElementsTest.java +++ b/plugins/devkit/devkit-java-tests/testData/inspections/unstableApiUsage/UnstableElementsTest.java @@ -1,44 +1,44 @@ -import pkg.ExperimentalClass; -import static pkg.ExperimentalClass.NON_EXPERIMENTAL_CONSTANT_IN_EXPERIMENTAL_CLASS; -import static pkg.ExperimentalClass.staticNonExperimentalMethodInExperimentalClass; -import static pkg.ExperimentalClass.EXPERIMENTAL_CONSTANT_IN_EXPERIMENTAL_CLASS; -import static pkg.ExperimentalClass.staticExperimentalMethodInExperimentalClass; +import pkg.ExperimentalClass; +import static pkg.ExperimentalClass.NON_EXPERIMENTAL_CONSTANT_IN_EXPERIMENTAL_CLASS; +import static pkg.ExperimentalClass.staticNonExperimentalMethodInExperimentalClass; +import static pkg.ExperimentalClass.EXPERIMENTAL_CONSTANT_IN_EXPERIMENTAL_CLASS; +import static pkg.ExperimentalClass.staticExperimentalMethodInExperimentalClass; import pkg.NonExperimentalClass; import static pkg.NonExperimentalClass.NON_EXPERIMENTAL_CONSTANT_IN_NON_EXPERIMENTAL_CLASS; import static pkg.NonExperimentalClass.staticNonExperimentalMethodInNonExperimentalClass; -import static pkg.NonExperimentalClass.EXPERIMENTAL_CONSTANT_IN_NON_EXPERIMENTAL_CLASS; -import static pkg.NonExperimentalClass.staticExperimentalMethodInNonExperimentalClass; +import static pkg.NonExperimentalClass.EXPERIMENTAL_CONSTANT_IN_NON_EXPERIMENTAL_CLASS; +import static pkg.NonExperimentalClass.staticExperimentalMethodInNonExperimentalClass; -import pkg.ExperimentalEnum; +import pkg.ExperimentalEnum; import pkg.NonExperimentalEnum; -import static pkg.ExperimentalEnum.NON_EXPERIMENTAL_VALUE_IN_EXPERIMENTAL_ENUM; -import static pkg.ExperimentalEnum.EXPERIMENTAL_VALUE_IN_EXPERIMENTAL_ENUM; +import static pkg.ExperimentalEnum.NON_EXPERIMENTAL_VALUE_IN_EXPERIMENTAL_ENUM; +import static pkg.ExperimentalEnum.EXPERIMENTAL_VALUE_IN_EXPERIMENTAL_ENUM; import static pkg.NonExperimentalEnum.NON_EXPERIMENTAL_VALUE_IN_NON_EXPERIMENTAL_ENUM; -import static pkg.NonExperimentalEnum.EXPERIMENTAL_VALUE_IN_NON_EXPERIMENTAL_ENUM; +import static pkg.NonExperimentalEnum.EXPERIMENTAL_VALUE_IN_NON_EXPERIMENTAL_ENUM; -import pkg.ExperimentalAnnotation; +import pkg.ExperimentalAnnotation; import pkg.NonExperimentalAnnotation; -import unstablePkg.ClassInUnstablePkg; +import unstablePkg.ClassInUnstablePkg; public class UnstableElementsTest { public void test() { - String s = ExperimentalClass.NON_EXPERIMENTAL_CONSTANT_IN_EXPERIMENTAL_CLASS; - ExperimentalClass.staticNonExperimentalMethodInExperimentalClass(); - ExperimentalClass experimentalClassInstanceViaNonExperimentalConstructor = new ExperimentalClass(); + String s = ExperimentalClass.NON_EXPERIMENTAL_CONSTANT_IN_EXPERIMENTAL_CLASS; + ExperimentalClass.staticNonExperimentalMethodInExperimentalClass(); + ExperimentalClass experimentalClassInstanceViaNonExperimentalConstructor = new ExperimentalClass(); s = experimentalClassInstanceViaNonExperimentalConstructor.nonExperimentalFieldInExperimentalClass; experimentalClassInstanceViaNonExperimentalConstructor.nonExperimentalMethodInExperimentalClass(); s = NON_EXPERIMENTAL_CONSTANT_IN_EXPERIMENTAL_CLASS; staticNonExperimentalMethodInExperimentalClass(); - s = ExperimentalClass.EXPERIMENTAL_CONSTANT_IN_EXPERIMENTAL_CLASS; - ExperimentalClass.staticExperimentalMethodInExperimentalClass(); - ExperimentalClass experimentalClassInstanceViaExperimentalConstructor = new ExperimentalClass(""); - s = experimentalClassInstanceViaExperimentalConstructor.experimentalFieldInExperimentalClass; - experimentalClassInstanceViaExperimentalConstructor.experimentalMethodInExperimentalClass(); - s = EXPERIMENTAL_CONSTANT_IN_EXPERIMENTAL_CLASS; - staticExperimentalMethodInExperimentalClass(); + s = ExperimentalClass.EXPERIMENTAL_CONSTANT_IN_EXPERIMENTAL_CLASS; + ExperimentalClass.staticExperimentalMethodInExperimentalClass(); + ExperimentalClass experimentalClassInstanceViaExperimentalConstructor = new ExperimentalClass(""); + s = experimentalClassInstanceViaExperimentalConstructor.experimentalFieldInExperimentalClass; + experimentalClassInstanceViaExperimentalConstructor.experimentalMethodInExperimentalClass(); + s = EXPERIMENTAL_CONSTANT_IN_EXPERIMENTAL_CLASS; + staticExperimentalMethodInExperimentalClass(); // --------------------------------- @@ -50,33 +50,33 @@ public class UnstableElementsTest { s = NON_EXPERIMENTAL_CONSTANT_IN_NON_EXPERIMENTAL_CLASS; staticNonExperimentalMethodInNonExperimentalClass(); - s = NonExperimentalClass.EXPERIMENTAL_CONSTANT_IN_NON_EXPERIMENTAL_CLASS; - NonExperimentalClass.staticExperimentalMethodInNonExperimentalClass(); - NonExperimentalClass nonExperimentalClassInstanceViaExperimentalConstructor = new NonExperimentalClass(""); - s = nonExperimentalClassInstanceViaExperimentalConstructor.experimentalFieldInNonExperimentalClass; - nonExperimentalClassInstanceViaExperimentalConstructor.experimentalMethodInNonExperimentalClass(); - s = EXPERIMENTAL_CONSTANT_IN_NON_EXPERIMENTAL_CLASS; - staticExperimentalMethodInNonExperimentalClass(); + s = NonExperimentalClass.EXPERIMENTAL_CONSTANT_IN_NON_EXPERIMENTAL_CLASS; + NonExperimentalClass.staticExperimentalMethodInNonExperimentalClass(); + NonExperimentalClass nonExperimentalClassInstanceViaExperimentalConstructor = new NonExperimentalClass(""); + s = nonExperimentalClassInstanceViaExperimentalConstructor.experimentalFieldInNonExperimentalClass; + nonExperimentalClassInstanceViaExperimentalConstructor.experimentalMethodInNonExperimentalClass(); + s = EXPERIMENTAL_CONSTANT_IN_NON_EXPERIMENTAL_CLASS; + staticExperimentalMethodInNonExperimentalClass(); // --------------------------------- - ExperimentalEnum nonExperimentalValueInExperimentalEnum = ExperimentalEnum.NON_EXPERIMENTAL_VALUE_IN_EXPERIMENTAL_ENUM; + ExperimentalEnum nonExperimentalValueInExperimentalEnum = ExperimentalEnum.NON_EXPERIMENTAL_VALUE_IN_EXPERIMENTAL_ENUM; nonExperimentalValueInExperimentalEnum = NON_EXPERIMENTAL_VALUE_IN_EXPERIMENTAL_ENUM; - ExperimentalEnum experimentalValueInExperimentalEnum = ExperimentalEnum.EXPERIMENTAL_VALUE_IN_EXPERIMENTAL_ENUM; - experimentalValueInExperimentalEnum = EXPERIMENTAL_VALUE_IN_EXPERIMENTAL_ENUM; + ExperimentalEnum experimentalValueInExperimentalEnum = ExperimentalEnum.EXPERIMENTAL_VALUE_IN_EXPERIMENTAL_ENUM; + experimentalValueInExperimentalEnum = EXPERIMENTAL_VALUE_IN_EXPERIMENTAL_ENUM; NonExperimentalEnum nonExperimentalValueInNonExperimentalEnum = NonExperimentalEnum.NON_EXPERIMENTAL_VALUE_IN_NON_EXPERIMENTAL_ENUM; nonExperimentalValueInNonExperimentalEnum = NON_EXPERIMENTAL_VALUE_IN_NON_EXPERIMENTAL_ENUM; - NonExperimentalEnum experimentalValueInNonExperimentalEnum = NonExperimentalEnum.EXPERIMENTAL_VALUE_IN_NON_EXPERIMENTAL_ENUM; - experimentalValueInNonExperimentalEnum = EXPERIMENTAL_VALUE_IN_NON_EXPERIMENTAL_ENUM; + NonExperimentalEnum experimentalValueInNonExperimentalEnum = NonExperimentalEnum.EXPERIMENTAL_VALUE_IN_NON_EXPERIMENTAL_ENUM; + experimentalValueInNonExperimentalEnum = EXPERIMENTAL_VALUE_IN_NON_EXPERIMENTAL_ENUM; // --------------------------------- - @ExperimentalAnnotation class C1 {} - @ExperimentalAnnotation(nonExperimentalAttributeInExperimentalAnnotation = "123") class C2 {} - @ExperimentalAnnotation(experimentalAttributeInExperimentalAnnotation = "123") class C3 {} + @ExperimentalAnnotation class C1 {} + @ExperimentalAnnotation(nonExperimentalAttributeInExperimentalAnnotation = "123") class C2 {} + @ExperimentalAnnotation(experimentalAttributeInExperimentalAnnotation = "123") class C3 {} @NonExperimentalAnnotation class C4 {} @NonExperimentalAnnotation(nonExperimentalAttributeInNonExperimentalAnnotation = "123") class C5 {} - @NonExperimentalAnnotation(experimentalAttributeInNonExperimentalAnnotation = "123") class C6 {} + @NonExperimentalAnnotation(experimentalAttributeInNonExperimentalAnnotation = "123") class C6 {} } } \ No newline at end of file diff --git a/plugins/devkit/devkit-kotlin-tests/testData/inspections/unstableApiUsage/UnstableElementsTest.kt b/plugins/devkit/devkit-kotlin-tests/testData/inspections/unstableApiUsage/UnstableElementsTest.kt index fa6360fc4083..5ab223f2e58b 100644 --- a/plugins/devkit/devkit-kotlin-tests/testData/inspections/unstableApiUsage/UnstableElementsTest.kt +++ b/plugins/devkit/devkit-kotlin-tests/testData/inspections/unstableApiUsage/UnstableElementsTest.kt @@ -1,45 +1,45 @@ -import pkg.ExperimentalClass -import pkg.ExperimentalClass.NON_EXPERIMENTAL_CONSTANT_IN_EXPERIMENTAL_CLASS -import pkg.ExperimentalClass.staticNonExperimentalMethodInExperimentalClass -import pkg.ExperimentalClass.EXPERIMENTAL_CONSTANT_IN_EXPERIMENTAL_CLASS -import pkg.ExperimentalClass.staticExperimentalMethodInExperimentalClass +import pkg.ExperimentalClass +import pkg.ExperimentalClass.NON_EXPERIMENTAL_CONSTANT_IN_EXPERIMENTAL_CLASS +import pkg.ExperimentalClass.staticNonExperimentalMethodInExperimentalClass +import pkg.ExperimentalClass.EXPERIMENTAL_CONSTANT_IN_EXPERIMENTAL_CLASS +import pkg.ExperimentalClass.staticExperimentalMethodInExperimentalClass import pkg.NonExperimentalClass import pkg.NonExperimentalClass.NON_EXPERIMENTAL_CONSTANT_IN_NON_EXPERIMENTAL_CLASS import pkg.NonExperimentalClass.staticNonExperimentalMethodInNonExperimentalClass -import pkg.NonExperimentalClass.EXPERIMENTAL_CONSTANT_IN_NON_EXPERIMENTAL_CLASS -import pkg.NonExperimentalClass.staticExperimentalMethodInNonExperimentalClass +import pkg.NonExperimentalClass.EXPERIMENTAL_CONSTANT_IN_NON_EXPERIMENTAL_CLASS +import pkg.NonExperimentalClass.staticExperimentalMethodInNonExperimentalClass -import pkg.ExperimentalEnum +import pkg.ExperimentalEnum import pkg.NonExperimentalEnum -import pkg.ExperimentalEnum.NON_EXPERIMENTAL_VALUE_IN_EXPERIMENTAL_ENUM -import pkg.ExperimentalEnum.EXPERIMENTAL_VALUE_IN_EXPERIMENTAL_ENUM +import pkg.ExperimentalEnum.NON_EXPERIMENTAL_VALUE_IN_EXPERIMENTAL_ENUM +import pkg.ExperimentalEnum.EXPERIMENTAL_VALUE_IN_EXPERIMENTAL_ENUM import pkg.NonExperimentalEnum.NON_EXPERIMENTAL_VALUE_IN_NON_EXPERIMENTAL_ENUM -import pkg.NonExperimentalEnum.EXPERIMENTAL_VALUE_IN_NON_EXPERIMENTAL_ENUM +import pkg.NonExperimentalEnum.EXPERIMENTAL_VALUE_IN_NON_EXPERIMENTAL_ENUM -import pkg.ExperimentalAnnotation +import pkg.ExperimentalAnnotation import pkg.NonExperimentalAnnotation -import unstablePkg.ClassInUnstablePkg +import unstablePkg.ClassInUnstablePkg @Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE", "UNUSED_VALUE") class UnstableElementsTest { fun test() { - var s = ExperimentalClass.NON_EXPERIMENTAL_CONSTANT_IN_EXPERIMENTAL_CLASS - ExperimentalClass.staticNonExperimentalMethodInExperimentalClass() - val experimentalClassInstanceViaNonExperimentalConstructor : ExperimentalClass = ExperimentalClass() + var s = ExperimentalClass.NON_EXPERIMENTAL_CONSTANT_IN_EXPERIMENTAL_CLASS + ExperimentalClass.staticNonExperimentalMethodInExperimentalClass() + val experimentalClassInstanceViaNonExperimentalConstructor : ExperimentalClass = ExperimentalClass() s = experimentalClassInstanceViaNonExperimentalConstructor.nonExperimentalFieldInExperimentalClass experimentalClassInstanceViaNonExperimentalConstructor.nonExperimentalMethodInExperimentalClass() s = NON_EXPERIMENTAL_CONSTANT_IN_EXPERIMENTAL_CLASS staticNonExperimentalMethodInExperimentalClass() - s = ExperimentalClass.EXPERIMENTAL_CONSTANT_IN_EXPERIMENTAL_CLASS - ExperimentalClass.staticExperimentalMethodInExperimentalClass() - val experimentalClassInstanceViaExperimentalConstructor : ExperimentalClass = ExperimentalClass("") - s = experimentalClassInstanceViaExperimentalConstructor.experimentalFieldInExperimentalClass - experimentalClassInstanceViaExperimentalConstructor.experimentalMethodInExperimentalClass() - s = EXPERIMENTAL_CONSTANT_IN_EXPERIMENTAL_CLASS - staticExperimentalMethodInExperimentalClass() + s = ExperimentalClass.EXPERIMENTAL_CONSTANT_IN_EXPERIMENTAL_CLASS + ExperimentalClass.staticExperimentalMethodInExperimentalClass() + val experimentalClassInstanceViaExperimentalConstructor : ExperimentalClass = ExperimentalClass("") + s = experimentalClassInstanceViaExperimentalConstructor.experimentalFieldInExperimentalClass + experimentalClassInstanceViaExperimentalConstructor.experimentalMethodInExperimentalClass() + s = EXPERIMENTAL_CONSTANT_IN_EXPERIMENTAL_CLASS + staticExperimentalMethodInExperimentalClass() // --------------------------------- @@ -51,33 +51,33 @@ class UnstableElementsTest { s = NON_EXPERIMENTAL_CONSTANT_IN_NON_EXPERIMENTAL_CLASS staticNonExperimentalMethodInNonExperimentalClass() - s = NonExperimentalClass.EXPERIMENTAL_CONSTANT_IN_NON_EXPERIMENTAL_CLASS - NonExperimentalClass.staticExperimentalMethodInNonExperimentalClass() - val nonExperimentalClassInstanceViaExperimentalConstructor = NonExperimentalClass("") - s = nonExperimentalClassInstanceViaExperimentalConstructor.experimentalFieldInNonExperimentalClass - nonExperimentalClassInstanceViaExperimentalConstructor.experimentalMethodInNonExperimentalClass() - s = EXPERIMENTAL_CONSTANT_IN_NON_EXPERIMENTAL_CLASS - staticExperimentalMethodInNonExperimentalClass() + s = NonExperimentalClass.EXPERIMENTAL_CONSTANT_IN_NON_EXPERIMENTAL_CLASS + NonExperimentalClass.staticExperimentalMethodInNonExperimentalClass() + val nonExperimentalClassInstanceViaExperimentalConstructor = NonExperimentalClass("") + s = nonExperimentalClassInstanceViaExperimentalConstructor.experimentalFieldInNonExperimentalClass + nonExperimentalClassInstanceViaExperimentalConstructor.experimentalMethodInNonExperimentalClass() + s = EXPERIMENTAL_CONSTANT_IN_NON_EXPERIMENTAL_CLASS + staticExperimentalMethodInNonExperimentalClass() // --------------------------------- - var nonExperimentalValueInExperimentalEnum : ExperimentalEnum = ExperimentalEnum.NON_EXPERIMENTAL_VALUE_IN_EXPERIMENTAL_ENUM + var nonExperimentalValueInExperimentalEnum : ExperimentalEnum = ExperimentalEnum.NON_EXPERIMENTAL_VALUE_IN_EXPERIMENTAL_ENUM nonExperimentalValueInExperimentalEnum = NON_EXPERIMENTAL_VALUE_IN_EXPERIMENTAL_ENUM - var experimentalValueInExperimentalEnum : ExperimentalEnum = ExperimentalEnum.EXPERIMENTAL_VALUE_IN_EXPERIMENTAL_ENUM - experimentalValueInExperimentalEnum = EXPERIMENTAL_VALUE_IN_EXPERIMENTAL_ENUM + var experimentalValueInExperimentalEnum : ExperimentalEnum = ExperimentalEnum.EXPERIMENTAL_VALUE_IN_EXPERIMENTAL_ENUM + experimentalValueInExperimentalEnum = EXPERIMENTAL_VALUE_IN_EXPERIMENTAL_ENUM var nonExperimentalValueInNonExperimentalEnum = NonExperimentalEnum.NON_EXPERIMENTAL_VALUE_IN_NON_EXPERIMENTAL_ENUM nonExperimentalValueInNonExperimentalEnum = NON_EXPERIMENTAL_VALUE_IN_NON_EXPERIMENTAL_ENUM - var experimentalValueInNonExperimentalEnum = NonExperimentalEnum.EXPERIMENTAL_VALUE_IN_NON_EXPERIMENTAL_ENUM - experimentalValueInNonExperimentalEnum = EXPERIMENTAL_VALUE_IN_NON_EXPERIMENTAL_ENUM + var experimentalValueInNonExperimentalEnum = NonExperimentalEnum.EXPERIMENTAL_VALUE_IN_NON_EXPERIMENTAL_ENUM + experimentalValueInNonExperimentalEnum = EXPERIMENTAL_VALUE_IN_NON_EXPERIMENTAL_ENUM // --------------------------------- - @ExperimentalAnnotation class C1 - @ExperimentalAnnotation(nonExperimentalAttributeInExperimentalAnnotation = "123") class C2 - @ExperimentalAnnotation(experimentalAttributeInExperimentalAnnotation = "123") class C3 + @ExperimentalAnnotation class C1 + @ExperimentalAnnotation(nonExperimentalAttributeInExperimentalAnnotation = "123") class C2 + @ExperimentalAnnotation(experimentalAttributeInExperimentalAnnotation = "123") class C3 @NonExperimentalAnnotation class C4 @NonExperimentalAnnotation(nonExperimentalAttributeInNonExperimentalAnnotation = "123") class C5 - @NonExperimentalAnnotation(experimentalAttributeInNonExperimentalAnnotation = "123") class C6 + @NonExperimentalAnnotation(experimentalAttributeInNonExperimentalAnnotation = "123") class C6 } } \ No newline at end of file diff --git a/plugins/devkit/devkit-tests-api/src/org/jetbrains/idea/devkit/inspections/UnstableApiUsageInspectionTestBase.kt b/plugins/devkit/devkit-tests-api/src/org/jetbrains/idea/devkit/inspections/UnstableApiUsageInspectionTestBase.kt index 793259a9b869..3cd6ad4c3321 100644 --- a/plugins/devkit/devkit-tests-api/src/org/jetbrains/idea/devkit/inspections/UnstableApiUsageInspectionTestBase.kt +++ b/plugins/devkit/devkit-tests-api/src/org/jetbrains/idea/devkit/inspections/UnstableApiUsageInspectionTestBase.kt @@ -22,80 +22,78 @@ abstract class UnstableApiUsageInspectionTestBase : JavaCodeInsightFixtureTestCa myFixture.enableInspections(UnstableApiUsageInspection::class.java) myFixture.addFileToProject( - "pkg/ExperimentalAnnotation.java", - "package pkg;\n" + - "import org.jetbrains.annotations.ApiStatus;\n" + - "@ApiStatus.Experimental public @interface ExperimentalAnnotation {\n" + - " String nonExperimentalAttributeInExperimentalAnnotation() default \"\";\n" + - " @ApiStatus.Experimental String experimentalAttributeInExperimentalAnnotation() default \"\";\n" + - "}" + "pkg/ExperimentalAnnotation.java", """ + package pkg; + import org.jetbrains.annotations.ApiStatus; + @ApiStatus.Experimental public @interface ExperimentalAnnotation { + String nonExperimentalAttributeInExperimentalAnnotation() default ""; + @ApiStatus.Experimental String experimentalAttributeInExperimentalAnnotation() default ""; + }""" ) myFixture.addFileToProject( - "pkg/ExperimentalEnum.java", - "package pkg;\n" + - "\n" + - "import org.jetbrains.annotations.ApiStatus;\n" + - "\n" + - "@ApiStatus.Experimental public enum ExperimentalEnum {\n" + - " NON_EXPERIMENTAL_VALUE_IN_EXPERIMENTAL_ENUM,\n" + - " @ApiStatus.Experimental EXPERIMENTAL_VALUE_IN_EXPERIMENTAL_ENUM\n" + - "}" + "pkg/ExperimentalEnum.java", """ + package pkg; + import org.jetbrains.annotations.ApiStatus; + @ApiStatus.Experimental public enum ExperimentalEnum { + NON_EXPERIMENTAL_VALUE_IN_EXPERIMENTAL_ENUM, + @ApiStatus.Experimental EXPERIMENTAL_VALUE_IN_EXPERIMENTAL_ENUM + }""" ) myFixture.addFileToProject( - "pkg/ExperimentalClass.java", - "package pkg;\n" + - "import org.jetbrains.annotations.ApiStatus;\n" + - "@ApiStatus.Experimental public class ExperimentalClass {\n" + - " public static final String NON_EXPERIMENTAL_CONSTANT_IN_EXPERIMENTAL_CLASS = \"\";\n" + - " public String nonExperimentalFieldInExperimentalClass = \"\";\n" + - " public ExperimentalClass() {}\n" + - " public static void staticNonExperimentalMethodInExperimentalClass() {}\n" + - " public void nonExperimentalMethodInExperimentalClass() {}\n" + - "\n" + - " @ApiStatus.Experimental public static final String EXPERIMENTAL_CONSTANT_IN_EXPERIMENTAL_CLASS = \"\";\n" + - " @ApiStatus.Experimental public String experimentalFieldInExperimentalClass = \"\";\n" + - " @ApiStatus.Experimental public ExperimentalClass(String s) {}\n" + - " @ApiStatus.Experimental public static void staticExperimentalMethodInExperimentalClass() {}\n" + - " @ApiStatus.Experimental public void experimentalMethodInExperimentalClass() {}\n" + - "}" + "pkg/ExperimentalClass.java", """ + package pkg; + import org.jetbrains.annotations.ApiStatus; + @ApiStatus.Experimental public class ExperimentalClass { + public static final String NON_EXPERIMENTAL_CONSTANT_IN_EXPERIMENTAL_CLASS = ""; + public String nonExperimentalFieldInExperimentalClass = ""; + public ExperimentalClass() {} + public static void staticNonExperimentalMethodInExperimentalClass() {} + public void nonExperimentalMethodInExperimentalClass() {} + + @ApiStatus.Experimental public static final String EXPERIMENTAL_CONSTANT_IN_EXPERIMENTAL_CLASS = ""; + @ApiStatus.Experimental public String experimentalFieldInExperimentalClass = ""; + @ApiStatus.Experimental public ExperimentalClass(String s) {} + @ApiStatus.Experimental public static void staticExperimentalMethodInExperimentalClass() {} + @ApiStatus.Experimental public void experimentalMethodInExperimentalClass() {} + }""" ) myFixture.addFileToProject( - "pkg/NonExperimentalAnnotation.java", - "package pkg;\n" + - "import org.jetbrains.annotations.ApiStatus;\n" + - "public @interface NonExperimentalAnnotation {\n" + - " String nonExperimentalAttributeInNonExperimentalAnnotation() default \"\";\n" + - " @ApiStatus.Experimental String experimentalAttributeInNonExperimentalAnnotation() default \"\";\n" + - "}" + "pkg/NonExperimentalAnnotation.java", """ + package pkg; + import org.jetbrains.annotations.ApiStatus; + public @interface NonExperimentalAnnotation { + String nonExperimentalAttributeInNonExperimentalAnnotation() default ""; + @ApiStatus.Experimental String experimentalAttributeInNonExperimentalAnnotation() default ""; + }""" ) myFixture.addFileToProject( - "pkg/NonExperimentalEnum.java", - "package pkg;\n" + - "import org.jetbrains.annotations.ApiStatus;\n" + - "public enum NonExperimentalEnum {\n" + - " NON_EXPERIMENTAL_VALUE_IN_NON_EXPERIMENTAL_ENUM,\n" + - " @ApiStatus.Experimental EXPERIMENTAL_VALUE_IN_NON_EXPERIMENTAL_ENUM\n" + - "}" + "pkg/NonExperimentalEnum.java", """ + package pkg; + import org.jetbrains.annotations.ApiStatus; + public enum NonExperimentalEnum { + NON_EXPERIMENTAL_VALUE_IN_NON_EXPERIMENTAL_ENUM, + @ApiStatus.Experimental EXPERIMENTAL_VALUE_IN_NON_EXPERIMENTAL_ENUM + }""" ) myFixture.addFileToProject( - "pkg/NonExperimentalClass.java", - "package pkg;\n" + - "import org.jetbrains.annotations.ApiStatus;\n" + - "public class NonExperimentalClass {\n" + - " public static final String NON_EXPERIMENTAL_CONSTANT_IN_NON_EXPERIMENTAL_CLASS = \"\";\n" + - " public String nonExperimentalFieldInNonExperimentalClass = \"\";\n" + - " public NonExperimentalClass() {}\n" + - " public static void staticNonExperimentalMethodInNonExperimentalClass() {}\n" + - " public void nonExperimentalMethodInNonExperimentalClass() {}\n" + - "\n" + - " @ApiStatus.Experimental public static final String EXPERIMENTAL_CONSTANT_IN_NON_EXPERIMENTAL_CLASS = \"\";\n" + - " @ApiStatus.Experimental public String experimentalFieldInNonExperimentalClass = \"\";\n" + - " @ApiStatus.Experimental public NonExperimentalClass(String s) {}\n" + - " @ApiStatus.Experimental public static void staticExperimentalMethodInNonExperimentalClass() {}\n" + - " @ApiStatus.Experimental public void experimentalMethodInNonExperimentalClass() {}\n" + - "}" + "pkg/NonExperimentalClass.java", """ + package pkg; + import org.jetbrains.annotations.ApiStatus; + public class NonExperimentalClass { + public static final String NON_EXPERIMENTAL_CONSTANT_IN_NON_EXPERIMENTAL_CLASS = ""; + public String nonExperimentalFieldInNonExperimentalClass = ""; + public NonExperimentalClass() {} + public static void staticNonExperimentalMethodInNonExperimentalClass() {} + public void nonExperimentalMethodInNonExperimentalClass() {} + + @ApiStatus.Experimental public static final String EXPERIMENTAL_CONSTANT_IN_NON_EXPERIMENTAL_CLASS = ""; + @ApiStatus.Experimental public String experimentalFieldInNonExperimentalClass = ""; + @ApiStatus.Experimental public NonExperimentalClass(String s) {} + @ApiStatus.Experimental public static void staticExperimentalMethodInNonExperimentalClass() {} + @ApiStatus.Experimental public void experimentalMethodInNonExperimentalClass() {} + }""" )