mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
+5
@@ -0,0 +1,5 @@
|
||||
class Foo {
|
||||
public int main() {
|
||||
r<caret>
|
||||
}
|
||||
}
|
||||
+7
@@ -22,6 +22,7 @@ import com.intellij.codeInsight.CodeInsightSettings
|
||||
import com.intellij.codeInsight.lookup.LookupElement
|
||||
import com.intellij.codeInsight.lookup.LookupElementPresentation
|
||||
import com.intellij.codeInsight.lookup.impl.LookupImpl
|
||||
import com.intellij.codeInsight.template.impl.LiveTemplateCompletionContributor
|
||||
import com.intellij.ide.ui.UISettings
|
||||
import com.intellij.psi.PsiClass
|
||||
import com.intellij.psi.PsiField
|
||||
@@ -670,4 +671,10 @@ interface TxANotAnno {}
|
||||
assertPreferredItems 0, 'get'
|
||||
}
|
||||
|
||||
public void testLiveTemplateOrdering() {
|
||||
LiveTemplateCompletionContributor.setShowTemplatesInTests(true, getTestRootDisposable())
|
||||
checkPreferredItems(0, 'return')
|
||||
assert lookup.items[-1].lookupString == 'ritar'
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+3
-1
@@ -91,7 +91,9 @@ public class LiveTemplateCompletionContributor extends CompletionContributor {
|
||||
@Override
|
||||
public void consume(CompletionResult completionResult) {
|
||||
finalResult.passResult(completionResult);
|
||||
ensureTemplatesShown(templatesShown, templates, parameters, finalResult);
|
||||
if (completionResult.isStartMatch()) {
|
||||
ensureTemplatesShown(templatesShown, templates, parameters, finalResult);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright 2000-2015 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.openapi.keymap;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.components.*;
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* @author Denis Fokin
|
||||
*/
|
||||
|
||||
@State(
|
||||
name = "KeyboardSettings",
|
||||
storages = {@Storage(file = StoragePathMacros.APP_CONFIG + "/keyboard.xml")}
|
||||
)
|
||||
public class KeyboardSettingsExternalizable implements PersistentStateComponent<KeyboardSettingsExternalizable.OptionSet> {
|
||||
|
||||
private static final String [] supportedNonEnglishLanguages = {"de", "fr", "it"};
|
||||
|
||||
public static boolean isSupportedKeyboardLayout(@NotNull Component component) {
|
||||
String keyboardLayoutLanguage = getLanguageForComponent(component);
|
||||
for (String language : supportedNonEnglishLanguages) {
|
||||
if (language.equals(keyboardLayoutLanguage)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static String getLanguageForComponent(@NotNull Component component) {
|
||||
return component.getInputContext().getLocale().getLanguage();
|
||||
}
|
||||
|
||||
public static String getDisplayLanguageNameForComponent(@NotNull Component component) {
|
||||
return component.getInputContext().getLocale().getDisplayLanguage();
|
||||
}
|
||||
|
||||
public static final class OptionSet {
|
||||
public boolean USE_NON_ENGLISH_KEYBOARD = false;
|
||||
}
|
||||
|
||||
private OptionSet myOptions = new OptionSet();
|
||||
|
||||
public static KeyboardSettingsExternalizable getInstance() {
|
||||
if (ApplicationManager.getApplication().isDisposed()) {
|
||||
return new KeyboardSettingsExternalizable();
|
||||
}
|
||||
else {
|
||||
return ServiceManager.getService(KeyboardSettingsExternalizable.class);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public OptionSet getState() {
|
||||
return myOptions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadState(OptionSet state) {
|
||||
myOptions = state;
|
||||
}
|
||||
|
||||
public boolean isNonEnglishKeyboardSupportEnabled () {
|
||||
return myOptions.USE_NON_ENGLISH_KEYBOARD;
|
||||
}
|
||||
|
||||
public void setNonEnglishKeyboardSupportEnabled (boolean enabled) {
|
||||
myOptions.USE_NON_ENGLISH_KEYBOARD = enabled;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -29,17 +29,16 @@ import com.intellij.openapi.application.impl.ApplicationImpl;
|
||||
import com.intellij.openapi.application.impl.LaterInvocator;
|
||||
import com.intellij.openapi.diagnostic.FrequentEventDetector;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.keymap.KeyboardSettingsExternalizable;
|
||||
import com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher;
|
||||
import com.intellij.openapi.keymap.impl.IdeMouseEventDispatcher;
|
||||
import com.intellij.openapi.keymap.impl.KeyState;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.ExpirableRunnable;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.wm.IdeFocusManager;
|
||||
import com.intellij.openapi.wm.WindowManager;
|
||||
import com.intellij.openapi.wm.ex.WindowManagerEx;
|
||||
import com.intellij.util.Alarm;
|
||||
import com.intellij.util.ReflectionUtil;
|
||||
@@ -411,7 +410,7 @@ public class IdeEventQueue extends EventQueue {
|
||||
//private static boolean altGrIsPressed = false;
|
||||
|
||||
private static AWTEvent fixNonEnglishKeyboardLayouts(AWTEvent e) {
|
||||
if (!Registry.is("ide.non.english.keyboard.layout.fix")) return e;
|
||||
if (!KeyboardSettingsExternalizable.getInstance().isNonEnglishKeyboardSupportEnabled()) return e;
|
||||
|
||||
if (e instanceof KeyEvent) {
|
||||
KeyEvent ke = (KeyEvent)e;
|
||||
|
||||
@@ -204,7 +204,7 @@ public class PluginGroups {
|
||||
}
|
||||
|
||||
protected static void addVimPlugin(Map<String, String> featuredPlugins) {
|
||||
featuredPlugins.put("IdeaVIM", "Editor:Emulates Vim editor:" + IDEA_VIM_PLUGIN_ID);
|
||||
featuredPlugins.put("IdeaVim", "Editor:Emulates Vim editor:" + IDEA_VIM_PLUGIN_ID);
|
||||
}
|
||||
|
||||
protected static void addLuaPlugin(Map<String, String> featuredPlugins) {
|
||||
|
||||
+2
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -18,9 +18,7 @@ package com.intellij.openapi.editor.actions;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorWriteActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Stands for emacs 'reverse-kill-line' action, i.e.
|
||||
@@ -30,7 +28,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
* @author Denis Zhdanov
|
||||
* @since 4/18/11 1:22 PM
|
||||
*/
|
||||
public class CutLineBackwardAction extends EditorAction {
|
||||
public class CutLineBackwardAction extends TextComponentEditorAction {
|
||||
|
||||
public CutLineBackwardAction() {
|
||||
super(new Handler());
|
||||
|
||||
+2
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -24,9 +24,7 @@
|
||||
*/
|
||||
package com.intellij.openapi.editor.actions;
|
||||
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
|
||||
public class CutLineEndAction extends EditorAction {
|
||||
public class CutLineEndAction extends TextComponentEditorAction {
|
||||
public CutLineEndAction() {
|
||||
super(new CutLineActionHandler(false, true, true));
|
||||
}
|
||||
|
||||
@@ -875,6 +875,8 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean firstCharTyped = true;
|
||||
|
||||
private void initComponent() {
|
||||
myPanel.setLayout(new BorderLayout());
|
||||
|
||||
@@ -930,6 +932,14 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
}
|
||||
|
||||
myEditorComponent.addKeyListener(new KeyListener() {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
if (e.getKeyCode() >= KeyEvent.VK_A && e.getKeyCode() <= KeyEvent.VK_Z) {
|
||||
myCharKeyPressed = true;
|
||||
}
|
||||
KeyboardInternationalizationNotificationManager.showNotification();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(@NotNull KeyEvent event) {
|
||||
myNeedToSelectPreviousChar = false;
|
||||
@@ -941,13 +951,6 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
if (e.getKeyCode() >= KeyEvent.VK_A && e.getKeyCode() <= KeyEvent.VK_Z) {
|
||||
myCharKeyPressed = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
myCharKeyPressed = false;
|
||||
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Copyright 2000-2015 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.openapi.editor.impl;
|
||||
|
||||
import com.intellij.notification.*;
|
||||
import com.intellij.openapi.application.ApplicationNamesInfo;
|
||||
import com.intellij.openapi.keymap.KeyboardSettingsExternalizable;
|
||||
import com.intellij.openapi.keymap.impl.ui.KeymapPanel;
|
||||
import com.intellij.openapi.options.ShowSettingsUtil;
|
||||
import com.intellij.openapi.wm.IdeFrame;
|
||||
import com.intellij.openapi.wm.ex.WindowManagerEx;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.event.HyperlinkEvent;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* @author Denis Fokin
|
||||
*/
|
||||
public class KeyboardInternationalizationNotificationManager {
|
||||
public static final String LOCALIZATION_GROUP_DISPLAY_ID = "Localization and Internationalization";
|
||||
public static boolean notificationHasBeenShown;
|
||||
|
||||
private KeyboardInternationalizationNotificationManager() {
|
||||
}
|
||||
|
||||
public static void showNotification() {
|
||||
|
||||
if (notificationHasBeenShown || !KeyboardSettingsExternalizable.isSupportedKeyboardLayout(WindowManagerEx.getInstanceEx().getMostRecentFocusedWindow())) return;
|
||||
|
||||
MyNotificationListener listener =
|
||||
new MyNotificationListener();
|
||||
|
||||
Notifications.Bus.notify(createNotification(LOCALIZATION_GROUP_DISPLAY_ID, listener));
|
||||
notificationHasBeenShown = true;
|
||||
}
|
||||
|
||||
public static Notification createNotification(@NotNull final String groupDisplayId, @Nullable NotificationListener listener) {
|
||||
|
||||
final String productName = ApplicationNamesInfo.getInstance().getProductName();
|
||||
|
||||
Window recentFocusedWindow = WindowManagerEx.getInstanceEx().getMostRecentFocusedWindow();
|
||||
|
||||
String text =
|
||||
"<html>We have found out that you are using a non-english keyboard layout. You can <a href='enable'>enable</a> smart layout support for " +
|
||||
KeyboardSettingsExternalizable.getDisplayLanguageNameForComponent(recentFocusedWindow) + " language." +
|
||||
"You can change this option in the settings of " + productName + " <a href='settings'>more...</a></html>";
|
||||
|
||||
String title = "Enable smart keyboard internalization for " + productName + ".";
|
||||
|
||||
return new Notification(groupDisplayId, title,
|
||||
text,
|
||||
NotificationType.INFORMATION,
|
||||
listener);
|
||||
}
|
||||
|
||||
private static class MyNotificationListener implements NotificationListener {
|
||||
|
||||
public MyNotificationListener() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
|
||||
if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
|
||||
final String description = event.getDescription();
|
||||
if ("enable".equals(description)) {
|
||||
KeyboardSettingsExternalizable.getInstance().setNonEnglishKeyboardSupportEnabled(true);
|
||||
}
|
||||
else if ("settings".equals(description)) {
|
||||
final ShowSettingsUtil util = ShowSettingsUtil.getInstance();
|
||||
IdeFrame ideFrame = WindowManagerEx.getInstanceEx().findFrameFor(null);
|
||||
//util.editConfigurable((JFrame)ideFrame, new StatisticsConfigurable(true));
|
||||
util.showSettingsDialog(ideFrame.getProject(), KeymapPanel.class);
|
||||
}
|
||||
|
||||
NotificationsConfiguration.getNotificationsConfiguration().changeSettings(LOCALIZATION_GROUP_DISPLAY_ID, NotificationDisplayType.NONE, false, false);
|
||||
notification.expire();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -456,7 +456,7 @@ public abstract class EditorComposite implements Disposable {
|
||||
myFocusWatcher.deinstall(myFocusWatcher.getTopComponent());
|
||||
}
|
||||
|
||||
void addEditor(FileEditor editor) {
|
||||
void addEditor(@NotNull FileEditor editor) {
|
||||
ApplicationManager.getApplication().assertIsDispatchThread();
|
||||
FileEditor[] editors = ArrayUtil.append(myEditors, editor);
|
||||
if (myTabbedPaneWrapper == null) {
|
||||
|
||||
+1
-1
@@ -91,7 +91,7 @@ public class EditorWithProviderComposite extends EditorComposite {
|
||||
return new HistoryEntry(getFile(), providers, states, providers[selectedProviderIndex]);
|
||||
}
|
||||
|
||||
public void addEditor(FileEditor editor, FileEditorProvider provider) {
|
||||
public void addEditor(@NotNull FileEditor editor, FileEditorProvider provider) {
|
||||
addEditor(editor);
|
||||
myProviders = ArrayUtil.append(myProviders, provider);
|
||||
}
|
||||
|
||||
@@ -26,10 +26,7 @@ import com.intellij.openapi.actionSystem.ex.QuickList;
|
||||
import com.intellij.openapi.actionSystem.ex.QuickListsManager;
|
||||
import com.intellij.openapi.actionSystem.impl.ActionToolbarImpl;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.keymap.KeyMapBundle;
|
||||
import com.intellij.openapi.keymap.Keymap;
|
||||
import com.intellij.openapi.keymap.KeymapManager;
|
||||
import com.intellij.openapi.keymap.KeymapUtil;
|
||||
import com.intellij.openapi.keymap.*;
|
||||
import com.intellij.openapi.keymap.ex.KeymapManagerEx;
|
||||
import com.intellij.openapi.keymap.impl.ActionShortcutRestrictions;
|
||||
import com.intellij.openapi.keymap.impl.KeymapImpl;
|
||||
@@ -52,6 +49,9 @@ import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.wm.IdeFocusManager;
|
||||
import com.intellij.openapi.wm.IdeFrame;
|
||||
import com.intellij.openapi.wm.impl.IdeFocusManagerImpl;
|
||||
import com.intellij.packageDependencies.ui.TreeExpansionMonitor;
|
||||
import com.intellij.ui.DocumentAdapter;
|
||||
import com.intellij.ui.DoubleClickListener;
|
||||
@@ -91,6 +91,7 @@ public class KeymapPanel extends JPanel implements SearchableConfigurable, Confi
|
||||
private JButton myCopyButton;
|
||||
private JButton myDeleteButton;
|
||||
private JButton myResetToDefault;
|
||||
private JCheckBox myNonEnglishKeyboardSupportOption;
|
||||
|
||||
private JLabel myBaseKeymapLabel;
|
||||
|
||||
@@ -233,7 +234,12 @@ public class KeymapPanel extends JPanel implements SearchableConfigurable, Confi
|
||||
final JPanel panel = new JPanel();
|
||||
panel.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 0));
|
||||
panel.setLayout(new GridBagLayout());
|
||||
myCopyButton = new JButton(KeyMapBundle.message("copy.keymap.button"));
|
||||
myCopyButton = new JButton(new AbstractAction(KeyMapBundle.message("copy.keymap.button")) {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
copyKeymap();
|
||||
}
|
||||
});
|
||||
Insets insets = new Insets(2, 2, 2, 2);
|
||||
myCopyButton.setMargin(insets);
|
||||
final GridBagConstraints gc = new GridBagConstraints(GridBagConstraints.RELATIVE, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 0), 0, 0);
|
||||
@@ -241,19 +247,28 @@ public class KeymapPanel extends JPanel implements SearchableConfigurable, Confi
|
||||
myResetToDefault = new JButton(CommonBundle.message("button.reset"));
|
||||
myResetToDefault.setMargin(insets);
|
||||
panel.add(myResetToDefault, gc);
|
||||
myDeleteButton = new JButton(KeyMapBundle.message("delete.keymap.button"));
|
||||
myDeleteButton = new JButton(new AbstractAction(KeyMapBundle.message("delete.keymap.button")) {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
deleteKeymap();
|
||||
}
|
||||
});
|
||||
myDeleteButton.setMargin(insets);
|
||||
gc.weightx = 1;
|
||||
panel.add(myDeleteButton, gc);
|
||||
|
||||
myCopyButton.addActionListener(
|
||||
new ActionListener() {
|
||||
IdeFrame ideFrame = IdeFocusManager.getGlobalInstance().getLastFocusedFrame();
|
||||
if (ideFrame != null && KeyboardSettingsExternalizable.isSupportedKeyboardLayout( ideFrame.getComponent()))
|
||||
{
|
||||
String displayLanguage = ideFrame.getComponent().getInputContext().getLocale().getDisplayLanguage();
|
||||
myNonEnglishKeyboardSupportOption = new JCheckBox(new AbstractAction(displayLanguage + " " + KeyMapBundle.message("use.non.english.keyboard.layout.support")) {
|
||||
@Override
|
||||
public void actionPerformed(@NotNull ActionEvent e) {
|
||||
copyKeymap();
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
KeyboardSettingsExternalizable.getInstance().setNonEnglishKeyboardSupportEnabled(myNonEnglishKeyboardSupportOption.isSelected());
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
myNonEnglishKeyboardSupportOption.setSelected(KeyboardSettingsExternalizable.getInstance().isNonEnglishKeyboardSupportEnabled());
|
||||
panel.add(myNonEnglishKeyboardSupportOption, gc);
|
||||
}
|
||||
|
||||
myResetToDefault.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
@@ -262,16 +277,6 @@ public class KeymapPanel extends JPanel implements SearchableConfigurable, Confi
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
myDeleteButton.addActionListener(
|
||||
new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(@NotNull ActionEvent e) {
|
||||
deleteKeymap();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
return panel;
|
||||
}
|
||||
|
||||
@@ -790,6 +795,12 @@ public class KeymapPanel extends JPanel implements SearchableConfigurable, Confi
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
|
||||
if (myNonEnglishKeyboardSupportOption != null) {
|
||||
KeyboardSettingsExternalizable.getInstance().setNonEnglishKeyboardSupportEnabled(false);
|
||||
myNonEnglishKeyboardSupportOption.setSelected(KeyboardSettingsExternalizable.getInstance().isNonEnglishKeyboardSupportEnabled());
|
||||
}
|
||||
|
||||
myKeymapListModel.removeAllElements();
|
||||
KeymapManagerEx keymapManager = KeymapManagerEx.getInstanceEx();
|
||||
Keymap[] keymaps = keymapManager.getAllKeymaps();
|
||||
|
||||
@@ -46,6 +46,7 @@ remove.keymap.label=Remo&ve
|
||||
unnamed.list.display.name=unnamed
|
||||
copy.keymap.button=&Copy
|
||||
delete.keymap.button=De&lete
|
||||
use.non.english.keyboard.layout.support=la&yout support
|
||||
|
||||
parent.keymap.label=Parent keymap:
|
||||
disable.mnemonic.in.menu.check.box=Disable mnemonics in &menu
|
||||
|
||||
@@ -292,6 +292,7 @@
|
||||
serviceImplementation="com.intellij.openapi.actionSystem.impl.AbbreviationManagerImpl"/>
|
||||
|
||||
<applicationService serviceImplementation="com.intellij.openapi.editor.ex.EditorSettingsExternalizable"/>
|
||||
<applicationService serviceImplementation="com.intellij.openapi.keymap.KeyboardSettingsExternalizable"/>
|
||||
<applicationService serviceImplementation="com.intellij.openapi.editor.SpellCheckingEditorCustomizationProvider"/>
|
||||
|
||||
<scopeParserExtension implementation="com.intellij.psi.search.scope.packageSet.FilePackageSetParserExtension"/>
|
||||
|
||||
@@ -860,6 +860,9 @@
|
||||
level="WARNING" implementationClass="com.siyeh.ig.encapsulation.UseOfAnotherObjectsPrivateFieldInspection"/>
|
||||
|
||||
<!--group.names.error.handling-->
|
||||
<localInspection groupPath="Java" language="JAVA" shortName="ExtendsThrowable" bundle="com.siyeh.InspectionGadgetsBundle"
|
||||
key="extends.throwable.display.name" groupBundle="messages.InspectionsBundle" groupKey="group.names.error.handling"
|
||||
enabledByDefault="false" level="WARNING" implementationClass="com.siyeh.ig.errorhandling.ExtendsThrowableInspection"/>
|
||||
<localInspection groupPath="Java" language="JAVA" suppressId="ProhibitedExceptionCaught" shortName="BadExceptionCaught" bundle="com.siyeh.InspectionGadgetsBundle"
|
||||
key="bad.exception.caught.display.name" groupBundle="messages.InspectionsBundle" groupKey="group.names.error.handling"
|
||||
enabledByDefault="false" level="WARNING"
|
||||
|
||||
+12
-12
@@ -192,14 +192,6 @@ non.constant.logger.display.name=Non-constant logger
|
||||
non.constant.logger.problem.descriptor=Non-constant logger field <code>#ref</code> #loc
|
||||
public.method.without.logging.display.name='public' method without logging
|
||||
public.method.without.logging.problem.descriptor='public' method <code>#ref()</code> has no logging call #loc
|
||||
action.reset.telemetry.description=Reset telemetry data
|
||||
|
||||
telemetry.table.column.inspection.name=Inspection
|
||||
telemetry.table.column.total.time=Total Run Time (ms)
|
||||
telemetry.table.column.average.time=Average Run Time (ms)
|
||||
telemetry.table.column.run.count=Run Count
|
||||
telemetry.toolwindow.title=IG Telemetry
|
||||
action.telemetry.refresh.description=Refresh telemetry display
|
||||
finalize.doesnt.call.super.display.name='finalize()' does not call 'super.finalize()'
|
||||
finalize.doesnt.call.super.ignore.option=Ignore for direct subclasses of 'java.lang.Object'
|
||||
ignore.trivial.finalizers.option=Ignore for trivial 'finalize()' implementations
|
||||
@@ -655,7 +647,7 @@ unsecure.random.number.generation.display.name=Insecure random number generation
|
||||
parameters.per.method.display.name=Method with too many parameters
|
||||
parameters.per.constructor.display.name=Constructor with too many parameters
|
||||
unnecessary.unboxing.display.name=Unnecessary unboxing
|
||||
extends.thread.display.name=Class explicitly extends 'java.lang.Thread'
|
||||
extends.thread.display.name=Class directly extends 'java.lang.Thread'
|
||||
misspelled.tear.down.display.name='teardown()' instead of 'tearDown()'
|
||||
test.case.with.constructor.display.name=JUnit TestCase with non-trivial constructors
|
||||
parameter.name.differs.from.overridden.parameter.display.name=Parameter name differs from parameter in overridden method
|
||||
@@ -1005,8 +997,8 @@ call.to.native.method.while.locked.problem.descriptor=Call to native method <cod
|
||||
object.notify.problem.descriptor=<code>#ref</code> should probably be replaced with 'notifyAll()' #loc
|
||||
condition.signal.problem.descriptor=<code>#ref</code> should probably be replaced with 'signalAll()' #loc
|
||||
thread.with.default.run.method.problem.descriptor=Instantiating a <code>#ref</code> with default 'run()' method #loc
|
||||
extends.thread.problem.descriptor=Class <code>#ref</code> explicitly extends 'java.lang.Thread' #loc
|
||||
anonymous.extends.thread.problem.descriptor=Anonymous class explicitly extends 'java.lang.Thread' #loc
|
||||
extends.thread.problem.descriptor=Class <code>#ref</code> directly extends 'java.lang.Thread' #loc
|
||||
anonymous.extends.thread.problem.descriptor=Anonymous class directly extends 'java.lang.Thread' #loc
|
||||
naked.notify.problem.descriptor=Call to <code>#ref()</code> without corresponding state change #loc
|
||||
unconditional.wait.problem.descriptor=Unconditional call to <code>#ref()</code> #loc
|
||||
system.run.finalizers.on.exit.problem.descriptor=Call to <code>System.#ref()</code> #loc
|
||||
@@ -2157,4 +2149,12 @@ equals.replaceable.by.objects.call.problem.descriptor=<code>#ref</code> replacea
|
||||
equals.replaceable.by.objects.call.quickfix=Replace with 'Objects.equals()' expression
|
||||
array.objects.equals.display.name='Objects.equals()' called on arrays
|
||||
array.objects.equals.problem.descriptor=<code>Objects.#ref()</code> on arrays should probably be 'Arrays.equals()' #loc
|
||||
array.objects.deep.equals.problem.descriptor=<code>Objects.#ref()</code> on arrays should probably be 'Arrays.deepEquals()' #loc
|
||||
array.objects.deep.equals.problem.descriptor=<code>Objects.#ref()</code> on arrays should probably be 'Arrays.deepEquals()' #loc
|
||||
extends.throwable.display.name=Class directly extends 'java.lang.Throwable'
|
||||
anonymous.extends.throwable.problem.descriptor=Anonymous class directly extends 'java.lang.Throwable' #loc
|
||||
extends.throwable.problem.descriptor=class <code>#ref</code> directly extends 'java.lang.Throwable' #loc
|
||||
lambda.parameter.naming.convention.display.name=Lambda parameter naming convention
|
||||
lambda.parameter.naming.convention.problem.descriptor.short=Lambda parameter name <code>#ref</code> is too short #loc
|
||||
lambda.parameter.naming.convention.problem.descriptor.long=Lambda parameter name <code>#ref</code> is too long #loc
|
||||
lambda.parameter.naming.convention.problem.descriptor.regex.mismatch=Lambda parameter name <code>#ref</code> doesn''t match regex ''{0}'' #loc
|
||||
|
||||
|
||||
+5
-7
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2011 Dave Griffith, Bas Leijdekkers
|
||||
* Copyright 2003-2015 Dave Griffith, Bas Leijdekkers
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -44,16 +44,14 @@ public class CheckedExceptionClassInspection extends BaseInspection {
|
||||
return new CheckedExceptionClassVisitor();
|
||||
}
|
||||
|
||||
private static class CheckedExceptionClassVisitor
|
||||
extends BaseInspectionVisitor {
|
||||
private static class CheckedExceptionClassVisitor extends BaseInspectionVisitor {
|
||||
|
||||
@Override
|
||||
public void visitClass(@NotNull PsiClass aClass) {
|
||||
if (!InheritanceUtil.isInheritor(aClass,
|
||||
CommonClassNames.JAVA_LANG_THROWABLE)) {
|
||||
if (!InheritanceUtil.isInheritor(aClass, CommonClassNames.JAVA_LANG_EXCEPTION)) {
|
||||
return;
|
||||
}
|
||||
if (InheritanceUtil.isInheritor(aClass,
|
||||
CommonClassNames.JAVA_LANG_RUNTIME_EXCEPTION)) {
|
||||
if (InheritanceUtil.isInheritor(aClass, CommonClassNames.JAVA_LANG_RUNTIME_EXCEPTION)) {
|
||||
return;
|
||||
}
|
||||
registerClassError(aClass);
|
||||
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright 2000-2015 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.siyeh.ig.errorhandling;
|
||||
|
||||
import com.intellij.psi.CommonClassNames;
|
||||
import com.intellij.psi.PsiAnonymousClass;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.siyeh.InspectionGadgetsBundle;
|
||||
import com.siyeh.ig.BaseInspection;
|
||||
import com.siyeh.ig.BaseInspectionVisitor;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author Bas Leijdekkers
|
||||
*/
|
||||
public class ExtendsThrowableInspection extends BaseInspection {
|
||||
|
||||
@Nls
|
||||
@NotNull
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return InspectionGadgetsBundle.message("extends.throwable.display.name");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected String buildErrorString(Object... infos) {
|
||||
final PsiClass aClass = (PsiClass)infos[0];
|
||||
if (aClass instanceof PsiAnonymousClass) {
|
||||
return InspectionGadgetsBundle.message("anonymous.extends.throwable.problem.descriptor");
|
||||
} else {
|
||||
return InspectionGadgetsBundle.message("extends.throwable.problem.descriptor");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseInspectionVisitor buildVisitor() {
|
||||
return new ExtendsThrowableVisitor();
|
||||
}
|
||||
|
||||
private static class ExtendsThrowableVisitor extends BaseInspectionVisitor {
|
||||
|
||||
@Override
|
||||
public void visitClass(@NotNull PsiClass aClass) {
|
||||
if (aClass.isInterface() || aClass.isAnnotationType() || aClass.isEnum()) {
|
||||
return;
|
||||
}
|
||||
final PsiClass superClass = aClass.getSuperClass();
|
||||
if (superClass == null) {
|
||||
return;
|
||||
}
|
||||
final String superclassName = superClass.getQualifiedName();
|
||||
if (!CommonClassNames.JAVA_LANG_THROWABLE.equals(superclassName)) {
|
||||
return;
|
||||
}
|
||||
registerClassError(aClass, aClass);
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-11
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2011 Dave Griffith, Bas Leijdekkers
|
||||
* Copyright 2003-2015 Dave Griffith, Bas Leijdekkers
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -44,19 +44,11 @@ public class UncheckedExceptionClassInspection extends BaseInspection {
|
||||
return new UncheckedExceptionClassVisitor();
|
||||
}
|
||||
|
||||
private static class UncheckedExceptionClassVisitor
|
||||
extends BaseInspectionVisitor {
|
||||
private static class UncheckedExceptionClassVisitor extends BaseInspectionVisitor {
|
||||
|
||||
@Override
|
||||
public void visitClass(@NotNull PsiClass aClass) {
|
||||
if (!InheritanceUtil.isInheritor(aClass,
|
||||
CommonClassNames.JAVA_LANG_THROWABLE)) {
|
||||
return;
|
||||
}
|
||||
if (InheritanceUtil.isInheritor(aClass,
|
||||
CommonClassNames.JAVA_LANG_EXCEPTION) &&
|
||||
!InheritanceUtil.isInheritor(aClass,
|
||||
CommonClassNames.JAVA_LANG_RUNTIME_EXCEPTION)) {
|
||||
if (!InheritanceUtil.isInheritor(aClass, CommonClassNames.JAVA_LANG_RUNTIME_EXCEPTION)) {
|
||||
return;
|
||||
}
|
||||
registerClassError(aClass);
|
||||
|
||||
+98
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Copyright 2000-2015 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.siyeh.ig.naming;
|
||||
|
||||
import com.intellij.psi.*;
|
||||
import com.siyeh.InspectionGadgetsBundle;
|
||||
import com.siyeh.ig.BaseInspectionVisitor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author Bas Leijdekkers
|
||||
*/
|
||||
public class LambdaParameterNamingConventionInspectionBase extends ConventionInspection {
|
||||
|
||||
private static final int DEFAULT_MIN_LENGTH = 1;
|
||||
private static final int DEFAULT_MAX_LENGTH = 20;
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getID() {
|
||||
return "LambdaParameterNamingConvention";
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getDisplayName() {
|
||||
return InspectionGadgetsBundle.message("lambda.parameter.naming.convention.display.name");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean buildQuickFixesOnlyForOnTheFlyErrors() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String buildErrorString(Object... infos) {
|
||||
final String parameterName = (String)infos[0];
|
||||
if (parameterName.length() < getMinLength()) {
|
||||
return InspectionGadgetsBundle.message("lambda.parameter.naming.convention.problem.descriptor.short");
|
||||
}
|
||||
else if (parameterName.length() > getMaxLength()) {
|
||||
return InspectionGadgetsBundle.message("lambda.parameter.naming.convention.problem.descriptor.long");
|
||||
}
|
||||
else {
|
||||
return InspectionGadgetsBundle.message("lambda.parameter.naming.convention.problem.descriptor.regex.mismatch", getRegex());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDefaultRegex() {
|
||||
return "[a-z][A-Za-z\\d]*";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getDefaultMinLength() {
|
||||
return DEFAULT_MIN_LENGTH;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getDefaultMaxLength() {
|
||||
return DEFAULT_MAX_LENGTH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseInspectionVisitor buildVisitor() {
|
||||
return new NamingConventionsVisitor();
|
||||
}
|
||||
|
||||
private class NamingConventionsVisitor extends BaseInspectionVisitor {
|
||||
|
||||
@Override
|
||||
public void visitParameter(@NotNull PsiParameter variable) {
|
||||
final PsiElement scope = variable.getDeclarationScope();
|
||||
if (!(scope instanceof PsiLambdaExpression)) {
|
||||
return;
|
||||
}
|
||||
final String name = variable.getName();
|
||||
if (name == null || isValid(name)) {
|
||||
return;
|
||||
}
|
||||
registerVariableError(variable, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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,10 +15,7 @@
|
||||
*/
|
||||
package com.siyeh.ig.naming;
|
||||
|
||||
import com.intellij.psi.PsiCatchSection;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiForeachStatement;
|
||||
import com.intellij.psi.PsiParameter;
|
||||
import com.intellij.psi.*;
|
||||
import com.siyeh.InspectionGadgetsBundle;
|
||||
import com.siyeh.ig.BaseInspectionVisitor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -90,7 +87,8 @@ public class ParameterNamingConventionInspectionBase extends ConventionInspectio
|
||||
public void visitParameter(@NotNull PsiParameter variable) {
|
||||
final PsiElement scope = variable.getDeclarationScope();
|
||||
if (scope instanceof PsiCatchSection ||
|
||||
scope instanceof PsiForeachStatement) {
|
||||
scope instanceof PsiForeachStatement ||
|
||||
scope instanceof PsiLambdaExpression) {
|
||||
return;
|
||||
}
|
||||
final String name = variable.getName();
|
||||
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright 2003-2015 Dave Griffith, Bas Leijdekkers
|
||||
*
|
||||
* 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.siyeh.ig.naming;
|
||||
|
||||
import com.siyeh.ig.InspectionGadgetsFix;
|
||||
import com.siyeh.ig.fixes.RenameFix;
|
||||
|
||||
/**
|
||||
* @author Bas Leijdekkers
|
||||
*/
|
||||
public class LambdaParameterNamingConventionInspection extends LambdaParameterNamingConventionInspectionBase {
|
||||
|
||||
@Override
|
||||
protected InspectionGadgetsFix buildFix(Object... infos) {
|
||||
return new RenameFix();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<html>
|
||||
<body>
|
||||
Reports any clases which extend <b>java.lang.Thread</b>.
|
||||
Reports any classes which directly extend <b>java.lang.Thread</b>.
|
||||
It is usually thought better practice to delegate to rather than extend
|
||||
<b>java.lang.Thread</b>, so that a thread creator may exert better
|
||||
control over the thread's behavior, and to better localize all concurrency related operations.
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<html>
|
||||
<body>
|
||||
Reports any classes which directly extend <b>java.lang.Throwable</b>.
|
||||
It is generally considered bad practice to extend <b>java.lang.Throwable</b> directly and
|
||||
it is usually enough to extend either <b>java.lang.RuntimeException</b> or <b>java.lang.Exception</b> or in special
|
||||
cases <b>java.lang.Error</b>.
|
||||
<!-- tooltip end -->
|
||||
<p>
|
||||
<small>New in 15</small>
|
||||
<p>
|
||||
</body>
|
||||
</html>
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
<html>
|
||||
<body>
|
||||
Reports lambda parameters whose names are either too short, too long, or do not follow
|
||||
the specified regular expression pattern.
|
||||
<!-- tooltip end -->
|
||||
<p>
|
||||
Use the fields below to specify minimum length, maximum length and regular expression expected for method parameter names.
|
||||
Specify <b>0</b> to not check the length of names. Regular expressions are in standard <b>java.util.regex</b> format.
|
||||
<p>
|
||||
<small>New in 15</small>
|
||||
<p>
|
||||
</body>
|
||||
</html>
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
public class <warning descr="Checked exception class 'CheckedExceptionClass'">CheckedExceptionClass</warning> extends Exception {
|
||||
|
||||
}
|
||||
class E1 extends RuntimeException {}
|
||||
class E2 extends Throwable {}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
public class <warning descr="class 'ExtendsThrowable' directly extends 'java.lang.Throwable'">ExtendsThrowable</warning> extends Throwable {
|
||||
|
||||
void f() {
|
||||
new <warning descr="Anonymous class directly extends 'java.lang.Throwable'">Throwable</warning>() {
|
||||
void b() {}
|
||||
};
|
||||
}
|
||||
}
|
||||
class E1 extends Exception {}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
public class <warning descr="Unchecked exception class 'UncheckedExceptionClass'">UncheckedExceptionClass</warning> extends RuntimeException {
|
||||
|
||||
}
|
||||
class E1 extends Throwable {}
|
||||
class E2 extends Exception {}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
public class LambdaParameterNamingConvention {
|
||||
|
||||
void m(int a) {}
|
||||
void n(int abcd) {
|
||||
F f = (<warning descr="Lambda parameter name 'i' is too short">i</warning>) -> 10;
|
||||
F g = abc -> 12;
|
||||
}
|
||||
|
||||
interface F {
|
||||
int a(int i);
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package com.siyeh.igtest.naming.parameter_naming_convention;
|
||||
|
||||
public class ParameterNamingConvention {
|
||||
|
||||
void m(int <warning descr="Parameter name 'a' is too short">a</warning>) {}
|
||||
void n(int abcd) {
|
||||
F f = (i) -> 10;
|
||||
}
|
||||
|
||||
interface F {
|
||||
int a(int <warning descr="Parameter name 'i' is too short">i</warning>);
|
||||
}
|
||||
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2000-2015 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.siyeh.ig.errorhandling;
|
||||
|
||||
import com.intellij.codeInspection.InspectionProfileEntry;
|
||||
import com.siyeh.ig.LightInspectionTestCase;
|
||||
import junit.framework.TestCase;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author Bas Leijdekkers
|
||||
*/
|
||||
public class CheckedExceptionClassInspectionTest extends LightInspectionTestCase {
|
||||
|
||||
public void testCheckedExceptionClass() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected InspectionProfileEntry getInspection() {
|
||||
return new CheckedExceptionClassInspection();
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2000-2015 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.siyeh.ig.errorhandling;
|
||||
|
||||
import com.intellij.codeInspection.InspectionProfileEntry;
|
||||
import com.siyeh.ig.LightInspectionTestCase;
|
||||
import junit.framework.TestCase;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author Bas Leijdekkers
|
||||
*/
|
||||
public class ExtendsThrowableInspectionTest extends LightInspectionTestCase {
|
||||
|
||||
public void testExtendsThrowable() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected InspectionProfileEntry getInspection() {
|
||||
return new ExtendsThrowableInspection();
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2000-2015 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.siyeh.ig.errorhandling;
|
||||
|
||||
import com.intellij.codeInspection.InspectionProfileEntry;
|
||||
import com.siyeh.ig.LightInspectionTestCase;
|
||||
import junit.framework.TestCase;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author Bas Leijdekkers
|
||||
*/
|
||||
public class UncheckedExceptionClassInspectionTest extends LightInspectionTestCase {
|
||||
|
||||
public void testUncheckedExceptionClass() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected InspectionProfileEntry getInspection() {
|
||||
return new UncheckedExceptionClassInspection();
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright 2000-2015 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.siyeh.ig.naming;
|
||||
|
||||
import com.intellij.codeInspection.InspectionProfileEntry;
|
||||
import com.siyeh.ig.LightInspectionTestCase;
|
||||
import junit.framework.TestCase;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author Bas Leijdekkers
|
||||
*/
|
||||
public class LambdaParameterNamingConventionInspectionTest extends LightInspectionTestCase {
|
||||
|
||||
public void testLambdaParameterNamingConvention() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected InspectionProfileEntry getInspection() {
|
||||
final LambdaParameterNamingConventionInspection inspection = new LambdaParameterNamingConventionInspection();
|
||||
inspection.m_minLength = 2;
|
||||
return inspection;
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright 2000-2015 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.siyeh.ig.naming;
|
||||
|
||||
import com.intellij.codeInspection.InspectionProfileEntry;
|
||||
import com.siyeh.ig.LightInspectionTestCase;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author Bas Leijdekkers
|
||||
*/
|
||||
public class ParameterNamingConventionInspectionTest extends LightInspectionTestCase {
|
||||
|
||||
public void testParameterNamingConvention() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected InspectionProfileEntry getInspection() {
|
||||
final ParameterNamingConventionInspection inspection = new ParameterNamingConventionInspection();
|
||||
inspection.m_minLength = 3;
|
||||
inspection.m_maxLength = 5;
|
||||
return inspection;
|
||||
}
|
||||
}
|
||||
+47
-1
@@ -25,18 +25,25 @@ import com.intellij.openapi.externalSystem.settings.ExternalProjectSettings;
|
||||
import com.intellij.openapi.externalSystem.settings.ExternalSystemSettingsListenerAdapter;
|
||||
import com.intellij.openapi.externalSystem.test.ExternalSystemImportingTestCase;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
|
||||
import com.intellij.openapi.projectRoots.JavaSdk;
|
||||
import com.intellij.openapi.projectRoots.JdkUtil;
|
||||
import com.intellij.openapi.projectRoots.ProjectJdkTable;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.impl.SdkConfigurationUtil;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.ui.TestDialog;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.PathUtil;
|
||||
import com.intellij.util.SystemProperties;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.gradle.util.GradleVersion;
|
||||
import org.gradle.wrapper.GradleWrapperMain;
|
||||
import org.intellij.lang.annotations.Language;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.gradle.VersionMatcherRule;
|
||||
import org.jetbrains.plugins.gradle.settings.DistributionType;
|
||||
import org.jetbrains.plugins.gradle.settings.GradleProjectSettings;
|
||||
@@ -60,6 +67,7 @@ import java.util.Properties;
|
||||
import static org.jetbrains.plugins.gradle.tooling.builder.AbstractModelBuilderTest.DistributionLocator;
|
||||
import static org.jetbrains.plugins.gradle.tooling.builder.AbstractModelBuilderTest.SUPPORTED_GRADLE_VERSIONS;
|
||||
import static org.junit.Assume.assumeThat;
|
||||
import static org.junit.Assume.assumeTrue;
|
||||
|
||||
/**
|
||||
* @author Vladislav.Soroka
|
||||
@@ -77,20 +85,58 @@ public abstract class GradleImportingTestCase extends ExternalSystemImportingTes
|
||||
@org.junit.runners.Parameterized.Parameter(0)
|
||||
public String gradleVersion;
|
||||
private GradleProjectSettings myProjectSettings;
|
||||
private String myGradleJdkName;
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
assumeThat(gradleVersion, versionMatcherRule.getMatcher());
|
||||
final String jdkHome = getJdkHome();
|
||||
if (jdkHome != null) {
|
||||
myGradleJdkName = "Gradle JDK";
|
||||
assertNull("JDK " + myGradleJdkName + " already exists", ProjectJdkTable.getInstance().findJdk(myGradleJdkName));
|
||||
new WriteAction() {
|
||||
@Override
|
||||
protected void run(@NotNull Result result) throws Throwable {
|
||||
VirtualFile jdkHomeDir = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(new File(jdkHome));
|
||||
Sdk jdk = SdkConfigurationUtil.setupSdk(new Sdk[0], jdkHomeDir, JavaSdk.getInstance(), true, null, myGradleJdkName);
|
||||
assertNotNull("Cannot create JDK for " + jdkHome, jdk);
|
||||
SdkConfigurationUtil.addSdk(jdk);
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
myProjectSettings = new GradleProjectSettings();
|
||||
GradleSettings.getInstance(myProject).setGradleVmOptions("-Xmx64m -XX:MaxPermSize=64m");
|
||||
System.setProperty(ExternalSystemExecutionSettings.REMOTE_PROCESS_IDLE_TTL_IN_MS_KEY, String.valueOf(GRADLE_DAEMON_TTL_MS));
|
||||
configureWrapper();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String getJdkHome() {
|
||||
String javaHome = SystemProperties.getJavaHome();
|
||||
List<String> paths =
|
||||
ContainerUtil.packNullables(javaHome, new File(javaHome).getParent(), System.getenv("JDK_16_x64"), System.getenv("JDK_16"));
|
||||
for (String path : paths) {
|
||||
if (JdkUtil.checkForJdk(new File(path))) {
|
||||
return path;
|
||||
}
|
||||
}
|
||||
assumeTrue("Cannot find JDK, checked paths: " + paths, false);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tearDown() throws Exception {
|
||||
try {
|
||||
new WriteAction() {
|
||||
@Override
|
||||
protected void run(@NotNull Result result) throws Throwable {
|
||||
Sdk old = ProjectJdkTable.getInstance().findJdk(myGradleJdkName);
|
||||
if (old != null) {
|
||||
SdkConfigurationUtil.removeSdk(old);
|
||||
}
|
||||
}
|
||||
}.execute();
|
||||
Messages.setTestDialog(TestDialog.DEFAULT);
|
||||
FileUtil.delete(BuildManager.getInstance().getBuildSystemDirectory());
|
||||
}
|
||||
@@ -136,7 +182,7 @@ public abstract class GradleImportingTestCase extends ExternalSystemImportingTes
|
||||
public void onProjectsLinked(@NotNull Collection settings) {
|
||||
final Object item = ContainerUtil.getFirstItem(settings);
|
||||
if (item instanceof GradleProjectSettings) {
|
||||
((GradleProjectSettings)item).setGradleJvm(null);
|
||||
((GradleProjectSettings)item).setGradleJvm(myGradleJdkName);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
+5
@@ -31,6 +31,7 @@ import org.gradle.tooling.model.idea.IdeaModule;
|
||||
import org.gradle.util.GradleVersion;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.gradle.VersionMatcherRule;
|
||||
import org.jetbrains.plugins.gradle.importing.GradleImportingTestCase;
|
||||
import org.jetbrains.plugins.gradle.model.BuildScriptClasspathModel;
|
||||
import org.jetbrains.plugins.gradle.model.ClasspathEntryModel;
|
||||
import org.jetbrains.plugins.gradle.model.ProjectImportAction;
|
||||
@@ -135,6 +136,10 @@ public abstract class AbstractModelBuilderTest {
|
||||
BuildActionExecuter<ProjectImportAction.AllModels> buildActionExecutor = connection.action(projectImportAction);
|
||||
File initScript = GradleExecutionHelper.generateInitScript(false, getToolingExtensionClasses());
|
||||
assertNotNull(initScript);
|
||||
String jdkHome = GradleImportingTestCase.getJdkHome();
|
||||
if (jdkHome != null) {
|
||||
buildActionExecutor.setJavaHome(new File(jdkHome));
|
||||
}
|
||||
buildActionExecutor.setJvmArguments("-Xmx64m", "-XX:MaxPermSize=64m");
|
||||
buildActionExecutor.withArguments("--info", "--recompile-scripts", GradleConstants.INIT_SCRIPT_CMD_OPTION, initScript.getAbsolutePath());
|
||||
allModels = buildActionExecutor.run();
|
||||
|
||||
Reference in New Issue
Block a user