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:
@@ -21,6 +21,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.light.LightElement;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.search.LocalSearchScope;
|
||||
import com.intellij.psi.search.SearchScope;
|
||||
@@ -134,10 +135,11 @@ public class RenameJavaClassProcessor extends RenamePsiElementProcessor {
|
||||
final PsiElement prototype = ((PsiMirrorElement)constructor).getPrototype();
|
||||
if (prototype instanceof PsiNamedElement) {
|
||||
allRenames.put(prototype, newName);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
allRenames.put(constructor, newName);
|
||||
else if (!(constructor instanceof LightElement)) {
|
||||
allRenames.put(constructor, newName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -69,6 +69,7 @@ import java.util.List;
|
||||
|
||||
public class CreateTestDialog extends DialogWrapper {
|
||||
private static final String RECENTS_KEY = "CreateTestDialog.RecentsKey";
|
||||
private static final String RECENT_SUPERS_KEY = "CreateTestDialog.Recents.Supers";
|
||||
private static final String DEFAULT_LIBRARY_NAME_PROPERTY = CreateTestDialog.class.getName() + ".defaultLibrary";
|
||||
private static final String SHOW_INHERITED_MEMBERS_PROPERTY = CreateTestDialog.class.getName() + ".includeInheritedMembers";
|
||||
|
||||
@@ -81,7 +82,7 @@ public class CreateTestDialog extends DialogWrapper {
|
||||
|
||||
private final List<JRadioButton> myLibraryButtons = new ArrayList<JRadioButton>();
|
||||
private EditorTextField myTargetClassNameField;
|
||||
private ReferenceEditorWithBrowseButton mySuperClassField;
|
||||
private ReferenceEditorComboWithBrowseButton mySuperClassField;
|
||||
private ReferenceEditorComboWithBrowseButton myTargetPackageField;
|
||||
private JCheckBox myGenerateBeforeBox;
|
||||
private JCheckBox myGenerateAfterBox;
|
||||
@@ -176,7 +177,8 @@ public class CreateTestDialog extends DialogWrapper {
|
||||
}
|
||||
});
|
||||
|
||||
mySuperClassField = JavaReferenceEditorUtil.createReferenceEditorWithBrowseButton(new MyChooseSuperClassAction(), "", myProject, true);
|
||||
mySuperClassField = new ReferenceEditorComboWithBrowseButton(new MyChooseSuperClassAction(), null, myProject, true,
|
||||
JavaCodeFragment.VisibilityChecker.EVERYTHING_VISIBLE, RECENT_SUPERS_KEY);
|
||||
mySuperClassField.setMinimumSize(mySuperClassField.getPreferredSize());
|
||||
|
||||
String targetPackageName = targetPackage != null ? targetPackage.getQualifiedName() : "";
|
||||
@@ -209,7 +211,7 @@ public class CreateTestDialog extends DialogWrapper {
|
||||
myFixLibraryPanel.setVisible(!descriptor.isLibraryAttached(myTargetModule));
|
||||
|
||||
String superClass = descriptor.getDefaultSuperClass();
|
||||
mySuperClassField.setText(superClass == null ? "" : superClass);
|
||||
mySuperClassField.appendItem(superClass == null ? "" : superClass);
|
||||
mySelectedFramework = descriptor;
|
||||
}
|
||||
|
||||
@@ -416,6 +418,7 @@ public class CreateTestDialog extends DialogWrapper {
|
||||
|
||||
protected void doOKAction() {
|
||||
RecentsManager.getInstance(myProject).registerRecentEntry(RECENTS_KEY, myTargetPackageField.getText());
|
||||
RecentsManager.getInstance(myProject).registerRecentEntry(RECENT_SUPERS_KEY, mySuperClassField.getText());
|
||||
|
||||
String errorMessage;
|
||||
try {
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.fileTypes.StdFileTypes;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.ComponentWithBrowseButton;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -42,7 +43,7 @@ public class ReferenceEditorComboWithBrowseButton extends ComponentWithBrowseBut
|
||||
@NotNull final Project project,
|
||||
boolean toAcceptClasses,
|
||||
final JavaCodeFragment.VisibilityChecker visibilityChecker, final String recentsKey) {
|
||||
super(new EditorComboBox(createDocument(text, project, toAcceptClasses, visibilityChecker), project, StdFileTypes.JAVA),
|
||||
super(new EditorComboBox(createDocument(StringUtil.isEmpty(text) ? "" : text, project, toAcceptClasses, visibilityChecker), project, StdFileTypes.JAVA),
|
||||
browseActionListener);
|
||||
final List<String> recentEntries = RecentsManager.getInstance(project).getRecentEntries(recentsKey);
|
||||
if (recentEntries != null) {
|
||||
@@ -82,4 +83,8 @@ public class ReferenceEditorComboWithBrowseButton extends ComponentWithBrowseBut
|
||||
public void prependItem(String item) {
|
||||
getChildComponent().prependItem(item);
|
||||
}
|
||||
|
||||
public void appendItem(String item) {
|
||||
getChildComponent().appendItem(item);
|
||||
}
|
||||
}
|
||||
|
||||
+10
-5
@@ -19,18 +19,23 @@ import com.intellij.lang.Language;
|
||||
import com.intellij.psi.FileViewProvider;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiErrorElement;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author Dennis.Ushakov
|
||||
*/
|
||||
public abstract class TemplateLanguageErrorFilter extends HighlightErrorFilter {
|
||||
private final IElementType myTemplateExpressionStart;
|
||||
@NotNull
|
||||
private final TokenSet myTemplateExpressionStartTokens;
|
||||
@NotNull
|
||||
private final Class myTemplateFileViewProviderClass;
|
||||
|
||||
protected TemplateLanguageErrorFilter(IElementType templateExpressionStart, Class templateFileViewProviderClass) {
|
||||
myTemplateExpressionStart = templateExpressionStart;
|
||||
protected TemplateLanguageErrorFilter(
|
||||
final @NotNull TokenSet templateExpressionStartTokens,
|
||||
final @NotNull Class templateFileViewProviderClass)
|
||||
{
|
||||
myTemplateExpressionStartTokens = TokenSet.create(templateExpressionStartTokens.getTypes());
|
||||
myTemplateFileViewProviderClass = templateFileViewProviderClass;
|
||||
}
|
||||
|
||||
@@ -45,7 +50,7 @@ public abstract class TemplateLanguageErrorFilter extends HighlightErrorFilter {
|
||||
final Language css = Language.findLanguageByID("CSS");
|
||||
if (javaScript != null && parentLanguage.is(javaScript) || css != null && parentLanguage.is(css)) {
|
||||
final PsiElement next = viewProvider.findElementAt(element.getTextOffset() + 1, viewProvider.getBaseLanguage());
|
||||
if (next != null && next.getNode().getElementType() == myTemplateExpressionStart) {
|
||||
if (next != null && myTemplateExpressionStartTokens.contains(next.getNode().getElementType())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,6 +176,7 @@ public abstract class GotoTargetHandler implements CodeInsightActionHandler {
|
||||
return true;
|
||||
}
|
||||
}).
|
||||
setAdText(getAdText(gotoData.source, targets.length)).
|
||||
createPopup();
|
||||
if (gotoData.listUpdaterTask != null) {
|
||||
gotoData.listUpdaterTask.init((AbstractPopup)popup, list);
|
||||
@@ -237,6 +238,10 @@ public abstract class GotoTargetHandler implements CodeInsightActionHandler {
|
||||
protected abstract String getChooserTitle(PsiElement sourceElement, String name, int length);
|
||||
|
||||
protected abstract String getNotFoundMessage(Project project, Editor editor, PsiFile file);
|
||||
@Nullable
|
||||
protected String getAdText(PsiElement source, int length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public interface AdditionalAction {
|
||||
String getText();
|
||||
|
||||
@@ -79,7 +79,6 @@ import gnu.trove.TIntObjectHashMap;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
@@ -130,11 +129,14 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo
|
||||
private final Runnable myFinishProgress;
|
||||
private boolean myAllowHeavyFilters = false;
|
||||
|
||||
@TestOnly
|
||||
public Editor getEditor() {
|
||||
return myEditor;
|
||||
}
|
||||
|
||||
public EditorHyperlinkSupport getHyperlinks() {
|
||||
return myHyperlinks;
|
||||
}
|
||||
|
||||
public void scrollToEnd() {
|
||||
if (myEditor == null) return;
|
||||
myEditor.getCaretModel().moveToOffset(myEditor.getDocument().getTextLength());
|
||||
|
||||
@@ -17,8 +17,12 @@
|
||||
package com.intellij.ide.ui.search;
|
||||
|
||||
import com.intellij.application.options.OptionsContainingConfigurable;
|
||||
import com.intellij.ide.fileTemplates.FileTemplate;
|
||||
import com.intellij.ide.fileTemplates.FileTemplateManager;
|
||||
import com.intellij.ide.fileTemplates.impl.AllFileTemplatesConfigurable;
|
||||
import com.intellij.ide.plugins.AvailablePluginsManagerMain;
|
||||
import com.intellij.ide.plugins.PluginManagerConfigurable;
|
||||
import com.intellij.internal.ImageDuplicateResultsDialog;
|
||||
import com.intellij.openapi.actionSystem.ActionManager;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.impl.ActionManagerImpl;
|
||||
@@ -90,9 +94,7 @@ public class TraverseUIStarter implements ApplicationStarter {
|
||||
configurableElement.setAttribute(ID, id);
|
||||
configurableElement.setAttribute(CONFIGURABLE_NAME, configurable.getDisplayName());
|
||||
final TreeSet<OptionDescription> sortedOptions = options.get(configurable);
|
||||
for (OptionDescription option : sortedOptions) {
|
||||
append(option.getPath(), option.getHit(), option.getOption(), configurableElement);
|
||||
}
|
||||
writeOptions(configurableElement, sortedOptions);
|
||||
if (configurable instanceof KeymapPanel){
|
||||
processKeymap(configurableElement);
|
||||
} else if (configurable instanceof OptionsContainingConfigurable){
|
||||
@@ -102,6 +104,8 @@ public class TraverseUIStarter implements ApplicationStarter {
|
||||
for (OptionDescription description : descriptions) {
|
||||
append(null, AvailablePluginsManagerMain.MANAGE_REPOSITORIES, description.getOption(), configurableElement);
|
||||
}
|
||||
} else if (configurable instanceof AllFileTemplatesConfigurable) {
|
||||
processFileTemplates(configurableElement);
|
||||
}
|
||||
root.addContent(configurableElement);
|
||||
configurable.disposeUIResources();
|
||||
@@ -118,13 +122,39 @@ public class TraverseUIStarter implements ApplicationStarter {
|
||||
((ApplicationEx)ApplicationManager.getApplication()).exit(true);
|
||||
}
|
||||
|
||||
private static void processFileTemplates(Element configurableElement) {
|
||||
final SearchableOptionsRegistrar optionsRegistrar = SearchableOptionsRegistrar.getInstance();
|
||||
TreeSet<OptionDescription> options = new TreeSet<OptionDescription>();
|
||||
|
||||
processTemplates(optionsRegistrar, options, FileTemplateManager.getInstance().getAllTemplates());
|
||||
processTemplates(optionsRegistrar, options, FileTemplateManager.getInstance().getAllPatterns());
|
||||
processTemplates(optionsRegistrar, options, FileTemplateManager.getInstance().getAllCodeTemplates());
|
||||
processTemplates(optionsRegistrar, options, FileTemplateManager.getInstance().getAllJ2eeTemplates());
|
||||
|
||||
writeOptions(configurableElement, options);
|
||||
}
|
||||
|
||||
private static void processTemplates(SearchableOptionsRegistrar optionsRegistrar,
|
||||
TreeSet<OptionDescription> options,
|
||||
FileTemplate[] templates) {
|
||||
for (FileTemplate template : templates) {
|
||||
collectOptions(optionsRegistrar, options, template.getName());
|
||||
//collectOptions(optionsRegistrar, options, template.getDescription());
|
||||
}
|
||||
}
|
||||
|
||||
private static void collectOptions(SearchableOptionsRegistrar optionsRegistrar, TreeSet<OptionDescription> options, String text) {
|
||||
final Set<String> strings = optionsRegistrar.getProcessedWordsWithoutStemming(text);
|
||||
for (String word : strings) {
|
||||
options.add(new OptionDescription(word, text, null));
|
||||
}
|
||||
}
|
||||
|
||||
private static void processOptionsContainingConfigurable(final OptionsContainingConfigurable configurable,
|
||||
final Element configurableElement) {
|
||||
final Set<String> optionsPath = configurable.processListOptions();
|
||||
final TreeSet<OptionDescription> result = wordsToOptionDescriptors(optionsPath);
|
||||
for (OptionDescription option : result) {
|
||||
append(option.getPath(), option.getHit(), option.getOption(), configurableElement);
|
||||
}
|
||||
writeOptions(configurableElement, result);
|
||||
}
|
||||
|
||||
private static TreeSet<OptionDescription> wordsToOptionDescriptors(Set<String> optionsPath) {
|
||||
@@ -150,24 +180,22 @@ public class TraverseUIStarter implements ApplicationStarter {
|
||||
final AnAction anAction = actionManager.getAction(id);
|
||||
final String text = anAction.getTemplatePresentation().getText();
|
||||
if (text != null) {
|
||||
final Set<String> strings = searchableOptionsRegistrar.getProcessedWordsWithoutStemming(text);
|
||||
for (String word : strings) {
|
||||
options.add(new OptionDescription(word, text, null));
|
||||
}
|
||||
collectOptions(searchableOptionsRegistrar, options, text);
|
||||
}
|
||||
final String description = anAction.getTemplatePresentation().getDescription();
|
||||
if (description != null) {
|
||||
final Set<String> strings = searchableOptionsRegistrar.getProcessedWordsWithoutStemming(description);
|
||||
for (String word : strings) {
|
||||
options.add(new OptionDescription(word, description, null));
|
||||
}
|
||||
collectOptions(searchableOptionsRegistrar, options, description);
|
||||
}
|
||||
}
|
||||
writeOptions(configurableElement, options);
|
||||
}
|
||||
|
||||
private static void writeOptions(Element configurableElement, TreeSet<OptionDescription> options) {
|
||||
for (OptionDescription opt : options) {
|
||||
append(opt.getPath(), opt.getHit(), opt.getOption(), configurableElement);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void append(String path, String hit, final String word, final Element configurableElement) {
|
||||
Element optionElement = new Element(OPTION);
|
||||
optionElement.setAttribute(NAME, word);
|
||||
|
||||
+33
-13
@@ -27,7 +27,6 @@ import com.intellij.codeInsight.daemon.impl.SeverityRegistrar;
|
||||
import com.intellij.codeInspection.ModifiableModel;
|
||||
import com.intellij.codeInspection.ex.InspectionProfileImpl;
|
||||
import com.intellij.codeInspection.ex.InspectionToolRegistrar;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.ui.ListCellRendererWrapper;
|
||||
import com.intellij.lang.annotation.HighlightSeverity;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
@@ -173,7 +172,7 @@ public abstract class InspectionToolsConfigurable extends BaseConfigurable imple
|
||||
profile.setLocal(true);
|
||||
profile.initInspectionTools(null);
|
||||
profile.setModified(true);
|
||||
if (myPanels.get(profile.getName()) != null) {
|
||||
if (getProfilePanel(profile) != null) {
|
||||
if (Messages.showOkCancelDialog(myWholePanel, "Profile with name \'" + profile.getName() + "\' already exists. Do you want to overwrite it?", "Warning", Messages.getInformationIcon()) != DialogWrapper.OK_EXIT_CODE) return;
|
||||
}
|
||||
addProfile((InspectionProfileImpl)profile.getModifiableModel());
|
||||
@@ -247,7 +246,7 @@ public abstract class InspectionToolsConfigurable extends BaseConfigurable imple
|
||||
if (!myPanels.containsKey(modelName)) {
|
||||
((DefaultComboBoxModel)myProfiles.getModel()).addElement(model);
|
||||
}
|
||||
myPanels.put(modelName, panel);
|
||||
putProfile(model, panel);
|
||||
myProfiles.setSelectedItem(model);
|
||||
}
|
||||
|
||||
@@ -281,7 +280,7 @@ public abstract class InspectionToolsConfigurable extends BaseConfigurable imple
|
||||
public void customize(final JList list, final Profile value, final int index, final boolean selected, final boolean hasFocus) {
|
||||
final String profileName = value.getName();
|
||||
setText(profileName);
|
||||
final SingleInspectionProfilePanel panel = myPanels.get(profileName);
|
||||
final SingleInspectionProfilePanel panel = getProfilePanel(value);
|
||||
setIcon(panel != null && panel.isProfileShared() ? Profile.PROJECT_PROFILE : Profile.LOCAL_PROFILE);
|
||||
}
|
||||
});
|
||||
@@ -320,15 +319,36 @@ public abstract class InspectionToolsConfigurable extends BaseConfigurable imple
|
||||
}
|
||||
|
||||
public void apply() throws ConfigurationException {
|
||||
for (final Iterator<String> it = myPanels.keySet().iterator(); it.hasNext();) {
|
||||
final String name = it.next();
|
||||
final Map<String, SingleInspectionProfilePanel> panels = new LinkedHashMap<String, SingleInspectionProfilePanel>();
|
||||
for (final String name : myPanels.keySet()) {
|
||||
if (myDeletedProfiles.remove(name)) {
|
||||
deleteProfile(name);
|
||||
it.remove();
|
||||
} else {
|
||||
myPanels.get(name).apply();
|
||||
}
|
||||
else {
|
||||
final SingleInspectionProfilePanel panel = getProfilePanel(name);
|
||||
panel.apply();
|
||||
final ModifiableModel profile = panel.getSelectedProfile();
|
||||
panels.put(getProfilePrefix(profile) + profile.getName(), panel);
|
||||
}
|
||||
}
|
||||
myPanels.clear();
|
||||
myPanels.putAll(panels);
|
||||
}
|
||||
|
||||
private SingleInspectionProfilePanel getProfilePanel(String name) {
|
||||
return myPanels.get(name);
|
||||
}
|
||||
|
||||
private SingleInspectionProfilePanel getProfilePanel(Profile inspectionProfile) {
|
||||
return getProfilePanel(getProfilePrefix(inspectionProfile) + inspectionProfile.getName());
|
||||
}
|
||||
|
||||
private void putProfile(Profile profile, SingleInspectionProfilePanel panel) {
|
||||
myPanels.put(getProfilePrefix(profile) + profile.getName(), panel);
|
||||
}
|
||||
|
||||
private static String getProfilePrefix(Profile profile) {
|
||||
return (profile.isLocal() ? "L" : "S");
|
||||
}
|
||||
|
||||
protected void deleteProfile(String name) {
|
||||
@@ -349,7 +369,7 @@ public abstract class InspectionToolsConfigurable extends BaseConfigurable imple
|
||||
model.addElement(profile);
|
||||
final String profileName = profile.getName();
|
||||
final SingleInspectionProfilePanel panel = new SingleInspectionProfilePanel(myProjectProfileManager, profileName, ((InspectionProfileImpl)profile).getModifiableModel());
|
||||
myPanels.put(profileName, panel);
|
||||
putProfile(profile, panel);
|
||||
myPanel.add(profileName, panel);
|
||||
}
|
||||
final InspectionProfileImpl inspectionProfile = getCurrentProfile();
|
||||
@@ -426,7 +446,7 @@ public abstract class InspectionToolsConfigurable extends BaseConfigurable imple
|
||||
public void selectInspectionTool(String selectedToolShortName) {
|
||||
final InspectionProfileImpl inspectionProfile = getSelectedObject();
|
||||
assert inspectionProfile != null : configuredProfiles();
|
||||
final SingleInspectionProfilePanel panel = myPanels.get(inspectionProfile.getName());
|
||||
final SingleInspectionProfilePanel panel = getProfilePanel(inspectionProfile);
|
||||
LOG.assertTrue(panel != null, "No settings panel for: " + inspectionProfile.getName() + "; " + configuredProfiles());
|
||||
panel.selectInspectionTool(selectedToolShortName);
|
||||
}
|
||||
@@ -434,7 +454,7 @@ public abstract class InspectionToolsConfigurable extends BaseConfigurable imple
|
||||
protected SingleInspectionProfilePanel getSelectedPanel() {
|
||||
final InspectionProfileImpl inspectionProfile = getSelectedObject();
|
||||
assert inspectionProfile != null : configuredProfiles();
|
||||
return myPanels.get(inspectionProfile.getName());
|
||||
return getProfilePanel(inspectionProfile);
|
||||
}
|
||||
|
||||
private String configuredProfiles() {
|
||||
@@ -453,6 +473,6 @@ public abstract class InspectionToolsConfigurable extends BaseConfigurable imple
|
||||
public JComponent getPreferredFocusedComponent() {
|
||||
final InspectionProfileImpl inspectionProfile = getSelectedObject();
|
||||
assert inspectionProfile != null : configuredProfiles();
|
||||
return myPanels.get(inspectionProfile.getName()).getTree();
|
||||
return getProfilePanel(inspectionProfile).getTree();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,12 @@ import com.intellij.codeInsight.CodeInsightBundle;
|
||||
import com.intellij.codeInsight.navigation.GotoTargetHandler;
|
||||
import com.intellij.codeInsight.navigation.NavigationUtil;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.actionSystem.IdeActions;
|
||||
import com.intellij.openapi.actionSystem.Shortcut;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.keymap.Keymap;
|
||||
import com.intellij.openapi.keymap.KeymapManager;
|
||||
import com.intellij.openapi.keymap.KeymapUtil;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.pom.Navigatable;
|
||||
import com.intellij.psi.PsiElement;
|
||||
@@ -75,7 +80,7 @@ public class GotoTestOrCodeHandler extends GotoTargetHandler {
|
||||
}
|
||||
}
|
||||
|
||||
return new GotoData(sourceElement, PsiUtilBase.toPsiElementArray(candidates), actions);
|
||||
return new GotoData(sourceElement, PsiUtilCore.toPsiElementArray(candidates), actions);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -102,6 +107,19 @@ public class GotoTestOrCodeHandler extends GotoTargetHandler {
|
||||
return CodeInsightBundle.message("goto.test.notFound");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected String getAdText(PsiElement source, int length) {
|
||||
if (length > 0 && !TestFinderHelper.isTest(source)) {
|
||||
final Keymap keymap = KeymapManager.getInstance().getActiveKeymap();
|
||||
final Shortcut[] shortcuts = keymap.getShortcuts(IdeActions.ACTION_DEFAULT_RUNNER);
|
||||
if (shortcuts.length > 0) {
|
||||
return ("Press " + KeymapUtil.getShortcutText(shortcuts[0]) + " to run selected tests");
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void navigateToElement(Navigatable element) {
|
||||
if (element instanceof PsiElement) {
|
||||
|
||||
@@ -19,9 +19,8 @@ package com.intellij.unscramble;
|
||||
import com.intellij.execution.ExecutionManager;
|
||||
import com.intellij.execution.Executor;
|
||||
import com.intellij.execution.executors.DefaultRunExecutor;
|
||||
import com.intellij.execution.filters.Filter;
|
||||
import com.intellij.execution.filters.TextConsoleBuilder;
|
||||
import com.intellij.execution.filters.TextConsoleBuilderFactory;
|
||||
import com.intellij.execution.filters.*;
|
||||
import com.intellij.execution.impl.ConsoleViewImpl;
|
||||
import com.intellij.execution.ui.ConsoleView;
|
||||
import com.intellij.execution.ui.ConsoleViewContentType;
|
||||
import com.intellij.execution.ui.ExecutionConsole;
|
||||
@@ -95,8 +94,8 @@ public class AnalyzeStacktraceUtil {
|
||||
for(Filter filter: Extensions.getExtensions(EP_NAME, project)) {
|
||||
builder.addFilter(filter);
|
||||
}
|
||||
|
||||
final ConsoleView consoleView = builder.getConsole();
|
||||
|
||||
final DefaultActionGroup toolbarActions = new DefaultActionGroup();
|
||||
JComponent consoleComponent = consoleFactory != null
|
||||
? consoleFactory.createConsoleComponent(consoleView, toolbarActions)
|
||||
@@ -109,10 +108,11 @@ public class AnalyzeStacktraceUtil {
|
||||
};
|
||||
|
||||
final Executor executor = DefaultRunExecutor.getRunExecutorInstance();
|
||||
toolbarActions.add(new CloseAction(executor, descriptor, project));
|
||||
for (AnAction action: consoleView.createConsoleActions()) {
|
||||
toolbarActions.add(action);
|
||||
}
|
||||
toolbarActions.add(new AnnotateStackTraceAction((ConsoleViewImpl)consoleView));
|
||||
toolbarActions.add(new CloseAction(executor, descriptor, project));
|
||||
ExecutionManager.getInstance(project).getContentManager().showRunContent(executor, descriptor);
|
||||
consoleView.allowHeavyFilters();
|
||||
printStacktrace(consoleView, text);
|
||||
|
||||
@@ -0,0 +1,232 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.unscramble;
|
||||
|
||||
import com.intellij.execution.filters.FileHyperlinkInfo;
|
||||
import com.intellij.execution.filters.HyperlinkInfo;
|
||||
import com.intellij.execution.impl.ConsoleViewImpl;
|
||||
import com.intellij.execution.impl.EditorHyperlinkSupport;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.colors.ColorKey;
|
||||
import com.intellij.openapi.editor.colors.EditorColors;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsManager;
|
||||
import com.intellij.openapi.editor.colors.EditorFontType;
|
||||
import com.intellij.openapi.editor.ex.EditorGutterComponentEx;
|
||||
import com.intellij.openapi.editor.markup.RangeHighlighter;
|
||||
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
|
||||
import com.intellij.openapi.progress.PerformInBackgroundOption;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.progress.Task;
|
||||
import com.intellij.openapi.vcs.AbstractVcs;
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.actions.ActiveAnnotationGutter;
|
||||
import com.intellij.openapi.vcs.actions.VcsContextFactory;
|
||||
import com.intellij.openapi.vcs.annotate.AnnotationSource;
|
||||
import com.intellij.openapi.vcs.history.VcsFileRevision;
|
||||
import com.intellij.openapi.vcs.history.VcsHistoryProvider;
|
||||
import com.intellij.openapi.vcs.history.VcsHistorySession;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.text.DateFormatUtil;
|
||||
import com.intellij.vcsUtil.VcsUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
class AnnotateStackTraceAction extends AnAction {
|
||||
private final EditorHyperlinkSupport myHyperlinks;
|
||||
private Map<Integer, VcsFileRevision> cache;
|
||||
private int newestLine = -1;
|
||||
private int maxDateLength = 0;
|
||||
private final Editor myEditor;
|
||||
|
||||
AnnotateStackTraceAction(ConsoleViewImpl consoleView) {
|
||||
super("Annotate", null, AllIcons.Actions.Annotate);
|
||||
myHyperlinks = consoleView.getHyperlinks();
|
||||
myEditor = consoleView.getEditor();
|
||||
myEditor.getColorsScheme().setColor(
|
||||
EditorColors.CARET_ROW_COLOR, EditorColorsManager.getInstance().getGlobalScheme().getColor(EditorColors.CARET_ROW_COLOR));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
cache = new HashMap<Integer, VcsFileRevision>();
|
||||
|
||||
ProgressManager.getInstance().run(
|
||||
new Task.Backgroundable(myEditor.getProject(), "Getting file history", true, PerformInBackgroundOption.ALWAYS_BACKGROUND) {
|
||||
@Override
|
||||
public boolean shouldStartInBackground() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
}
|
||||
|
||||
private void showGutter() {
|
||||
myEditor.getGutter().registerTextAnnotation(new ActiveAnnotationGutter() {
|
||||
@Override
|
||||
public void doAction(int lineNum) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cursor getCursor(int lineNum) {
|
||||
return Cursor.getDefaultCursor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLineText(int line, Editor editor) {
|
||||
final VcsFileRevision revision = cache.get(line);
|
||||
if (revision != null) {
|
||||
return String.format("%"+maxDateLength+"s", DateFormatUtil.formatPrettyDate(revision.getRevisionDate())) + " " + revision.getAuthor();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getToolTip(int line, Editor editor) {
|
||||
final VcsFileRevision revision = cache.get(line);
|
||||
if (revision != null) {
|
||||
return "<html>" +
|
||||
revision.getAuthor() +
|
||||
" " +
|
||||
DateFormatUtil.formatDateTime(revision.getRevisionDate()) +
|
||||
"<br/>" +
|
||||
revision.getCommitMessage() +
|
||||
"</html>";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EditorFontType getStyle(int line, Editor editor) {
|
||||
return line == newestLine ? EditorFontType.BOLD : EditorFontType.PLAIN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ColorKey getColor(int line, Editor editor) {
|
||||
return AnnotationSource.LOCAL.getColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getBgColor(int line, Editor editor) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AnAction> getPopupActions(int line, Editor editor) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void gutterClosed() {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(@NotNull ProgressIndicator indicator) {
|
||||
Date newestDate = null;
|
||||
HashMap<VirtualFile, List<Integer>> files2lines = new HashMap<VirtualFile, List<Integer>>();
|
||||
List<VirtualFile> files = new ArrayList<VirtualFile>();
|
||||
for (int line = 0; line < myEditor.getDocument().getLineCount(); line++) {
|
||||
indicator.checkCanceled();
|
||||
final List<RangeHighlighter> links = myHyperlinks.findAllHyperlinksOnLine(line);
|
||||
if (links.size() > 0) {
|
||||
final HyperlinkInfo info = myHyperlinks.getHyperlinks().get(links.get(links.size() - 1));
|
||||
if (info instanceof FileHyperlinkInfo) {
|
||||
final OpenFileDescriptor fileDescriptor = ((FileHyperlinkInfo)info).getDescriptor();
|
||||
if (fileDescriptor != null) {
|
||||
final VirtualFile file = fileDescriptor.getFile();
|
||||
if (files2lines.containsKey(file)) {
|
||||
files2lines.get(file).add(line);
|
||||
} else {
|
||||
final ArrayList<Integer> lines = new ArrayList<Integer>();
|
||||
lines.add(line);
|
||||
files2lines.put(file, lines);
|
||||
files.add(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (VirtualFile file : files) {
|
||||
indicator.checkCanceled();
|
||||
final AbstractVcs vcs = VcsUtil.getVcsFor(myEditor.getProject(), file);
|
||||
FilePath filePath = VcsContextFactory.SERVICE.getInstance().createFilePathOn(file);
|
||||
if (vcs != null) {
|
||||
try {
|
||||
final VcsHistoryProvider provider = vcs.getVcsHistoryProvider();
|
||||
final VcsHistorySession session;
|
||||
if (provider != null) {
|
||||
session = provider.createSessionFor(filePath);
|
||||
final List<VcsFileRevision> list;
|
||||
if (session != null) {
|
||||
list = session.getRevisionList();
|
||||
final List<Integer> lines = files2lines.get(file);
|
||||
if (list != null && !list.isEmpty()) {
|
||||
final VcsFileRevision revision = list.get(0);
|
||||
final Date date = revision.getRevisionDate();
|
||||
if (newestDate == null || date.after(newestDate)) {
|
||||
newestDate = date;
|
||||
newestLine = lines.get(0);
|
||||
}
|
||||
final int length = DateFormatUtil.formatPrettyDate(date).length();
|
||||
if (length > maxDateLength) {
|
||||
maxDateLength = length;
|
||||
}
|
||||
for (Integer line : lines) {
|
||||
cache.put(line, revision);
|
||||
}
|
||||
ApplicationManager.getApplication().invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
if (cache.keySet().size() == 1) {
|
||||
showGutter();
|
||||
} else {
|
||||
((EditorGutterComponentEx)myEditor.getGutter()).revalidateMarkup();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (VcsException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
e.getPresentation().setEnabled(cache == null);
|
||||
}
|
||||
}
|
||||
@@ -215,6 +215,20 @@ public class EditorComboBox extends JComboBox implements DocumentListener {
|
||||
setModel(new DefaultComboBoxModel(ArrayUtil.toObjectArray(objects)));
|
||||
}
|
||||
|
||||
public void appendItem(String item) {
|
||||
ArrayList<Object> objects = new ArrayList<Object>();
|
||||
|
||||
int count = getItemCount();
|
||||
for (int i = 0; i < count; i++) {
|
||||
objects.add(getItemAt(i));
|
||||
}
|
||||
|
||||
if (!objects.contains(item)) {
|
||||
objects.add(item);
|
||||
}
|
||||
setModel(new DefaultComboBoxModel(ArrayUtil.toObjectArray(objects)));
|
||||
}
|
||||
|
||||
private class MyEditor implements ComboBoxEditor {
|
||||
public void addActionListener(ActionListener l) {
|
||||
}
|
||||
|
||||
+21
-30
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -31,6 +31,7 @@ import com.siyeh.ig.InspectionGadgetsFix;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -74,8 +75,7 @@ public class TryFinallyCanBeTryWithResourcesInspection extends BaseInspection {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doFix(Project project, ProblemDescriptor descriptor)
|
||||
throws IncorrectOperationException {
|
||||
protected void doFix(Project project, ProblemDescriptor descriptor) throws IncorrectOperationException {
|
||||
final PsiElement element = descriptor.getPsiElement();
|
||||
final PsiElement parent = element.getParent();
|
||||
if (!(parent instanceof PsiTryStatement)) {
|
||||
@@ -93,10 +93,8 @@ public class TryFinallyCanBeTryWithResourcesInspection extends BaseInspection {
|
||||
variables.add(variable);
|
||||
}
|
||||
}
|
||||
final PsiElementFactory factory =
|
||||
JavaPsiFacade.getElementFactory(project);
|
||||
@NonNls final StringBuilder newTryStatementText =
|
||||
new StringBuilder("try (");
|
||||
final PsiElementFactory factory = JavaPsiFacade.getElementFactory(project);
|
||||
@NonNls final StringBuilder newTryStatementText = new StringBuilder("try (");
|
||||
final Set<Integer> unwantedChildren = new HashSet(2);
|
||||
boolean separator = false;
|
||||
for (PsiLocalVariable variable : variables) {
|
||||
@@ -120,19 +118,17 @@ public class TryFinallyCanBeTryWithResourcesInspection extends BaseInspection {
|
||||
newTryStatementText.append(initializer.getText());
|
||||
}
|
||||
else {
|
||||
final int index = findInitialization(tryBlockChildren,
|
||||
variable, hasInitializer);
|
||||
final int index = findInitialization(tryBlockChildren, variable, hasInitializer);
|
||||
if (index < 0) {
|
||||
return;
|
||||
}
|
||||
unwantedChildren.add(Integer.valueOf(index));
|
||||
final PsiExpressionStatement expressionStatement =
|
||||
(PsiExpressionStatement)tryBlockChildren[index];
|
||||
final PsiAssignmentExpression assignmentExpression =
|
||||
(PsiAssignmentExpression)
|
||||
expressionStatement.getExpression();
|
||||
final PsiExpression rhs =
|
||||
assignmentExpression.getRExpression();
|
||||
final PsiExpressionStatement expressionStatement = (PsiExpressionStatement)tryBlockChildren[index];
|
||||
if (expressionStatement.getNextSibling() instanceof PsiWhiteSpace) {
|
||||
unwantedChildren.add(Integer.valueOf(index + 1));
|
||||
}
|
||||
final PsiAssignmentExpression assignmentExpression = (PsiAssignmentExpression)expressionStatement.getExpression();
|
||||
final PsiExpression rhs = assignmentExpression.getRExpression();
|
||||
if (rhs == null) {
|
||||
return;
|
||||
}
|
||||
@@ -145,16 +141,12 @@ public class TryFinallyCanBeTryWithResourcesInspection extends BaseInspection {
|
||||
for (int i = 1; i < tryBlockStatementsLength; i++) {
|
||||
final PsiElement child = tryBlockChildren[i];
|
||||
if (unwantedChildren.contains(Integer.valueOf(i))) {
|
||||
if (child.getNextSibling() instanceof PsiWhiteSpace) {
|
||||
i++;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
newTryStatementText.append(child.getText());
|
||||
}
|
||||
newTryStatementText.append('}');
|
||||
final PsiCatchSection[] catchSections =
|
||||
tryStatement.getCatchSections();
|
||||
final PsiCatchSection[] catchSections = tryStatement.getCatchSections();
|
||||
for (PsiCatchSection catchSection : catchSections) {
|
||||
newTryStatementText.append(catchSection.getText());
|
||||
}
|
||||
@@ -167,17 +159,17 @@ public class TryFinallyCanBeTryWithResourcesInspection extends BaseInspection {
|
||||
for (int i = 1; i < finallyChildrenLength; i++) {
|
||||
final PsiElement child = finallyChildren[i];
|
||||
if (isCloseStatement(child, variables)) {
|
||||
if (child.getNextSibling() instanceof PsiWhiteSpace) {
|
||||
i++;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (!appended) {
|
||||
if (child instanceof PsiWhiteSpace ||
|
||||
child instanceof PsiComment) {
|
||||
if (child instanceof PsiComment) {
|
||||
final PsiElement prevSibling = child.getPrevSibling();
|
||||
if (prevSibling instanceof PsiWhiteSpace) {
|
||||
savedComments.add(prevSibling);
|
||||
}
|
||||
savedComments.add(child);
|
||||
}
|
||||
else {
|
||||
else if (!(child instanceof PsiWhiteSpace)) {
|
||||
newTryStatementText.append(" finally {");
|
||||
for (PsiElement savedComment : savedComments) {
|
||||
newTryStatementText.append(savedComment.getText());
|
||||
@@ -204,9 +196,7 @@ public class TryFinallyCanBeTryWithResourcesInspection extends BaseInspection {
|
||||
parent1.addAfter(savedComment, tryStatement);
|
||||
}
|
||||
}
|
||||
final PsiStatement newTryStatement =
|
||||
factory.createStatementFromText(
|
||||
newTryStatementText.toString(), element);
|
||||
final PsiStatement newTryStatement = factory.createStatementFromText(newTryStatementText.toString(), element);
|
||||
tryStatement.replace(newTryStatement);
|
||||
}
|
||||
|
||||
@@ -404,6 +394,7 @@ public class TryFinallyCanBeTryWithResourcesInspection extends BaseInspection {
|
||||
return variables;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
static PsiLocalVariable findAutoCloseableVariable(
|
||||
PsiStatement statement) {
|
||||
if (statement instanceof PsiIfStatement) {
|
||||
|
||||
@@ -52,6 +52,7 @@ public class AndroidDxRunner {
|
||||
private static Field myJarOutputField;
|
||||
private static Field myFileNamesField;
|
||||
private static Field myStrictNameCheckField;
|
||||
private static Field myOptimizeField;
|
||||
|
||||
private static Field myConsoleOut;
|
||||
private static Field myConsoleErr;
|
||||
@@ -82,6 +83,8 @@ public class AndroidDxRunner {
|
||||
myVerboseField = argClass.getField("verbose");
|
||||
myStrictNameCheckField = argClass.getField("strictNameCheck");
|
||||
|
||||
myOptimizeField = getFieldIfPossible(argClass);
|
||||
|
||||
myConsoleOut = consoleClass.getField("out");
|
||||
myConsoleErr = consoleClass.getField("err");
|
||||
}
|
||||
@@ -102,7 +105,17 @@ public class AndroidDxRunner {
|
||||
}
|
||||
}
|
||||
|
||||
private static int runDex(String dxPath, String outFilePath, String[] fileNames) {
|
||||
@Nullable
|
||||
private static Field getFieldIfPossible(Class<?> argClass) {
|
||||
try {
|
||||
return argClass.getField("optimize");
|
||||
}
|
||||
catch (NoSuchFieldException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static int runDex(String dxPath, String outFilePath, String[] fileNames, boolean optimize) {
|
||||
loadDex(dxPath);
|
||||
|
||||
try {
|
||||
@@ -116,6 +129,13 @@ public class AndroidDxRunner {
|
||||
myVerboseField.set(args, false);
|
||||
myStrictNameCheckField.set(args, false);
|
||||
|
||||
if (myOptimizeField != null) {
|
||||
myOptimizeField.set(args, optimize);
|
||||
}
|
||||
else {
|
||||
reportWarning("Cannot find 'optimize' field. The option won't be passed to DEX");
|
||||
}
|
||||
|
||||
Object res = myMethod.invoke(null, args);
|
||||
|
||||
if (res instanceof Integer) {
|
||||
@@ -203,8 +223,20 @@ public class AndroidDxRunner {
|
||||
Set<String> files = new HashSet<String>();
|
||||
HashSet<String> visited = new HashSet<String>();
|
||||
HashSet<String> qNames = new HashSet<String>();
|
||||
boolean optimize = true;
|
||||
|
||||
int i = 2;
|
||||
|
||||
while (i < args.length && args[i].startsWith("--")) {
|
||||
if ("--optimize".equals(args[i])) {
|
||||
i++;
|
||||
if (i < args.length) {
|
||||
optimize = Boolean.parseBoolean(args[i]);
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
while (i < args.length) {
|
||||
String arg = args[i];
|
||||
if ("--exclude".equals(arg)) {
|
||||
@@ -226,7 +258,7 @@ public class AndroidDxRunner {
|
||||
files.removeAll(Arrays.asList(excludedFiles));
|
||||
String[] filesArray = files.toArray(new String[files.size()]);
|
||||
//System.out.println("file names: " + concat(filesArray));
|
||||
runDex(dxPath, outFilePath, filesArray);
|
||||
runDex(dxPath, outFilePath, filesArray, optimize);
|
||||
}
|
||||
|
||||
private static String concat(String[] ar) {
|
||||
|
||||
@@ -41,6 +41,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
@@ -78,7 +79,7 @@ public class AndroidDexCompiler implements ClassPostProcessingCompiler {
|
||||
}
|
||||
|
||||
public ValidityState createValidityState(DataInput in) throws IOException {
|
||||
return new ClassesAndJarsValidityState(in);
|
||||
return new MyValidityState(in);
|
||||
}
|
||||
|
||||
public static VirtualFile getOutputDirectoryForDex(@NotNull Module module) {
|
||||
@@ -114,6 +115,9 @@ public class AndroidDexCompiler implements ClassPostProcessingCompiler {
|
||||
}
|
||||
|
||||
public ProcessingItem[] compute() {
|
||||
final AndroidDexCompilerConfiguration dexConfig =
|
||||
AndroidDexCompilerConfiguration.getInstance(myContext.getProject());
|
||||
|
||||
Module[] modules = ModuleManager.getInstance(myContext.getProject()).getModules();
|
||||
List<ProcessingItem> items = new ArrayList<ProcessingItem>();
|
||||
for (Module module : modules) {
|
||||
@@ -181,7 +185,8 @@ public class AndroidDexCompiler implements ClassPostProcessingCompiler {
|
||||
continue;
|
||||
}
|
||||
|
||||
items.add(new DexItem(module, dexOutputDir, platform.getTarget(), files));
|
||||
items.add(new DexItem(module, dexOutputDir, platform.getTarget(), files, dexConfig.VM_OPTIONS, dexConfig.MAX_HEAP_SIZE,
|
||||
dexConfig.OPTIMIZE));
|
||||
}
|
||||
}
|
||||
return items.toArray(new ProcessingItem[items.size()]);
|
||||
@@ -214,8 +219,9 @@ public class AndroidDexCompiler implements ClassPostProcessingCompiler {
|
||||
files[i++] = FileUtil.toSystemDependentName(file.getPath());
|
||||
}
|
||||
|
||||
Map<CompilerMessageCategory, List<String>> messages = AndroidCompileUtil.toCompilerMessageCategoryKeys(
|
||||
AndroidDxWrapper.execute(dexItem.myModule, dexItem.myAndroidTarget, outputDirPath, files));
|
||||
Map<CompilerMessageCategory, List<String>> messages = AndroidCompileUtil.toCompilerMessageCategoryKeys(AndroidDxWrapper.execute(
|
||||
dexItem.myModule, dexItem.myAndroidTarget, outputDirPath, files, dexItem.myAdditionalVmParams, dexItem.myMaxHeapSize,
|
||||
dexItem.myOptimize));
|
||||
|
||||
addMessages(messages, dexItem.myModule);
|
||||
if (messages.get(CompilerMessageCategory.ERROR).isEmpty()) {
|
||||
@@ -241,15 +247,24 @@ public class AndroidDexCompiler implements ClassPostProcessingCompiler {
|
||||
final VirtualFile myClassDir;
|
||||
final IAndroidTarget myAndroidTarget;
|
||||
final Collection<VirtualFile> myFiles;
|
||||
final String myAdditionalVmParams;
|
||||
final int myMaxHeapSize;
|
||||
final boolean myOptimize;
|
||||
|
||||
public DexItem(@NotNull Module module,
|
||||
@NotNull VirtualFile classDir,
|
||||
@NotNull IAndroidTarget target,
|
||||
Collection<VirtualFile> files) {
|
||||
Collection<VirtualFile> files,
|
||||
@NotNull String additionalVmParams,
|
||||
int maxHeapSize,
|
||||
boolean optimize) {
|
||||
myModule = module;
|
||||
myClassDir = classDir;
|
||||
myAndroidTarget = target;
|
||||
myFiles = files;
|
||||
myAdditionalVmParams = additionalVmParams;
|
||||
myMaxHeapSize = maxHeapSize;
|
||||
myOptimize = optimize;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -259,7 +274,49 @@ public class AndroidDexCompiler implements ClassPostProcessingCompiler {
|
||||
|
||||
@Nullable
|
||||
public ValidityState getValidityState() {
|
||||
return new ClassesAndJarsValidityState(myFiles);
|
||||
return new MyValidityState(myFiles, myAdditionalVmParams, myMaxHeapSize, myOptimize);
|
||||
}
|
||||
}
|
||||
|
||||
private static class MyValidityState extends ClassesAndJarsValidityState {
|
||||
private final String myAdditionalVmParams;
|
||||
private final int myMaxHeapSize;
|
||||
private final boolean myOptimize;
|
||||
|
||||
public MyValidityState(@NotNull Collection<VirtualFile> files, @NotNull String additionalVmParams, int maxHeapSize, boolean optimize) {
|
||||
super(files);
|
||||
myAdditionalVmParams = additionalVmParams;
|
||||
myMaxHeapSize = maxHeapSize;
|
||||
myOptimize = optimize;
|
||||
}
|
||||
|
||||
public MyValidityState(@NotNull DataInput in) throws IOException {
|
||||
super(in);
|
||||
myAdditionalVmParams = in.readUTF();
|
||||
myMaxHeapSize = in.readInt();
|
||||
myOptimize = in.readBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(DataOutput out) throws IOException {
|
||||
super.save(out);
|
||||
out.writeUTF(myAdditionalVmParams);
|
||||
out.writeInt(myMaxHeapSize);
|
||||
out.writeBoolean(myOptimize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equalsTo(ValidityState otherState) {
|
||||
if (!super.equalsTo(otherState)) {
|
||||
return false;
|
||||
}
|
||||
if (!(otherState instanceof MyValidityState)) {
|
||||
return false;
|
||||
}
|
||||
final MyValidityState state = (MyValidityState)otherState;
|
||||
return state.myAdditionalVmParams.equals(myAdditionalVmParams) &&
|
||||
state.myMaxHeapSize == myMaxHeapSize &&
|
||||
state.myOptimize == myOptimize;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -32,6 +32,7 @@ import com.intellij.util.xmlb.XmlSerializerUtil;
|
||||
public class AndroidDexCompilerConfiguration implements PersistentStateComponent<AndroidDexCompilerConfiguration> {
|
||||
public String VM_OPTIONS = "";
|
||||
public int MAX_HEAP_SIZE = 1024;
|
||||
public boolean OPTIMIZE = true;
|
||||
|
||||
@Override
|
||||
public AndroidDexCompilerConfiguration getState() {
|
||||
|
||||
+10
-2
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.android.compiler.AndroidDexCompilerSettingsFactory.AndroidDexCompilerSettingsConfigurable">
|
||||
<grid id="27dc6" binding="myContentPanel" layout-manager="GridLayoutManager" row-count="3" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="27dc6" binding="myContentPanel" layout-manager="GridLayoutManager" row-count="4" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="378" height="400"/>
|
||||
@@ -24,7 +24,7 @@
|
||||
</hspacer>
|
||||
<vspacer id="e6619">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<component id="5c5d1" class="javax.swing.JLabel" binding="myVmOptionsLabel">
|
||||
@@ -49,6 +49,14 @@
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="a1a71" class="com.intellij.ui.components.JBCheckBox" binding="myOptimizeCheckBox">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="&Optimize"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
|
||||
+7
-4
@@ -21,6 +21,7 @@ import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.options.SearchableConfigurable;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.ui.RawCommandLineEditor;
|
||||
import com.intellij.ui.components.JBCheckBox;
|
||||
import org.jetbrains.android.util.AndroidBundle;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -42,6 +43,7 @@ public class AndroidDexCompilerSettingsFactory implements CompilerSettingsFactor
|
||||
private JSpinner myHeapSizeSpinner;
|
||||
private JLabel myVmOptionsLabel;
|
||||
private RawCommandLineEditor myVmOptionsEditor;
|
||||
private JBCheckBox myOptimizeCheckBox;
|
||||
|
||||
public AndroidDexCompilerSettingsConfigurable(Project project) {
|
||||
myConfig = AndroidDexCompilerConfiguration.getInstance(project);
|
||||
@@ -68,22 +70,23 @@ public class AndroidDexCompilerSettingsFactory implements CompilerSettingsFactor
|
||||
@Override
|
||||
public boolean isModified() {
|
||||
int maxHeapSize = ((Integer)myHeapSizeSpinner.getValue()).intValue();
|
||||
if (maxHeapSize != myConfig.MAX_HEAP_SIZE) {
|
||||
return true;
|
||||
}
|
||||
return !myVmOptionsEditor.getText().equals(myConfig.VM_OPTIONS);
|
||||
return maxHeapSize != myConfig.MAX_HEAP_SIZE ||
|
||||
!myVmOptionsEditor.getText().equals(myConfig.VM_OPTIONS) ||
|
||||
myOptimizeCheckBox.isSelected() != myConfig.OPTIMIZE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() throws ConfigurationException {
|
||||
myConfig.MAX_HEAP_SIZE = ((Integer)myHeapSizeSpinner.getValue()).intValue();
|
||||
myConfig.VM_OPTIONS = myVmOptionsEditor.getText();
|
||||
myConfig.OPTIMIZE = myOptimizeCheckBox.isSelected();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
myHeapSizeSpinner.setModel(new SpinnerNumberModel(myConfig.MAX_HEAP_SIZE, 1, 10000000, 1));
|
||||
myVmOptionsEditor.setText(myConfig.VM_OPTIONS);
|
||||
myOptimizeCheckBox.setSelected(myConfig.OPTIMIZE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -29,7 +29,6 @@ import com.intellij.openapi.util.io.FileUtilRt;
|
||||
import com.intellij.util.PathUtil;
|
||||
import com.intellij.util.PathsList;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import org.jetbrains.android.compiler.AndroidDexCompilerConfiguration;
|
||||
import org.jetbrains.android.util.AndroidBundle;
|
||||
import org.jetbrains.android.util.AndroidCommonUtils;
|
||||
import org.jetbrains.android.util.AndroidCompilerMessageKind;
|
||||
@@ -51,9 +50,12 @@ public class AndroidDxWrapper {
|
||||
|
||||
@SuppressWarnings({"IOResourceOpenedButNotSafelyClosed"})
|
||||
public static Map<AndroidCompilerMessageKind, List<String>> execute(@NotNull Module module,
|
||||
@NotNull IAndroidTarget target,
|
||||
@NotNull String outputDir,
|
||||
@NotNull String[] compileTargets) {
|
||||
@NotNull IAndroidTarget target,
|
||||
@NotNull String outputDir,
|
||||
@NotNull String[] compileTargets,
|
||||
@NotNull String additionalVmParams,
|
||||
int maxHeapSize,
|
||||
boolean optimize) {
|
||||
String outFile = outputDir + File.separatorChar + AndroidCommonUtils.CLASSES_FILE_NAME;
|
||||
|
||||
final Map<AndroidCompilerMessageKind, List<String>> messages = new HashMap<AndroidCompilerMessageKind, List<String>>(2);
|
||||
@@ -82,18 +84,17 @@ public class AndroidDxWrapper {
|
||||
ParametersList programParamList = parameters.getProgramParametersList();
|
||||
programParamList.add(dxJarPath);
|
||||
programParamList.add(outFile);
|
||||
programParamList.add("--optimize", Boolean.toString(optimize));
|
||||
programParamList.addAll(compileTargets);
|
||||
programParamList.add("--exclude");
|
||||
|
||||
ParametersList vmParamList = parameters.getVMParametersList();
|
||||
|
||||
AndroidDexCompilerConfiguration configuration = AndroidDexCompilerConfiguration.getInstance(module.getProject());
|
||||
String additionalVmParams = configuration.VM_OPTIONS;
|
||||
if (additionalVmParams.length() > 0) {
|
||||
vmParamList.addParametersString(additionalVmParams);
|
||||
}
|
||||
if (!hasXmxParam(vmParamList)) {
|
||||
vmParamList.add("-Xmx" + configuration.MAX_HEAP_SIZE + "M");
|
||||
vmParamList.add("-Xmx" + maxHeapSize + "M");
|
||||
}
|
||||
final PathsList classPath = parameters.getClassPath();
|
||||
classPath.add(PathUtil.getJarPathForClass(AndroidDxRunner.class));
|
||||
|
||||
@@ -45,6 +45,7 @@ import git4idea.repo.GitRepository;
|
||||
import git4idea.util.UntrackedFilesNotifier;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.HyperlinkEvent;
|
||||
@@ -462,17 +463,17 @@ public class GitCherryPicker {
|
||||
@NotNull private final Project myProject;
|
||||
@NotNull private final PlatformFacade myPlatformFacade;
|
||||
@NotNull private final List<Change> myChanges;
|
||||
@NotNull private final String myCommitMessage;
|
||||
@NotNull private final String myOriginalCommitMessage;
|
||||
private boolean myCommitFailed;
|
||||
|
||||
private CherryPickCommitExecutor.CherryPickCommitSession myCommitSession;
|
||||
@Nullable private CherryPickCommitExecutor.CherryPickCommitSession myCommitSession;
|
||||
|
||||
CherryPickCommitExecutor(@NotNull Project project, @NotNull PlatformFacade platformFacade,
|
||||
@NotNull List<Change> changes, @NotNull String commitMessage) {
|
||||
@NotNull List<Change> changes, @NotNull String originalCommitMessage) {
|
||||
myProject = project;
|
||||
myPlatformFacade = platformFacade;
|
||||
myChanges = changes;
|
||||
myCommitMessage = commitMessage;
|
||||
myOriginalCommitMessage = originalCommitMessage;
|
||||
}
|
||||
|
||||
@Nls
|
||||
@@ -494,7 +495,7 @@ public class GitCherryPicker {
|
||||
|
||||
@NotNull
|
||||
public String getActualCommitMessage() {
|
||||
return myCommitSession.getActualCommitMessage();
|
||||
return myCommitSession == null ? myOriginalCommitMessage : myCommitSession.getActualCommitMessage();
|
||||
}
|
||||
|
||||
private class CherryPickCommitSession implements CommitSession {
|
||||
|
||||
@@ -573,4 +573,23 @@ class Java {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void testTupleConstructor() {
|
||||
myFixture.with {
|
||||
configureByText('a.groovy', '''\
|
||||
import groovy.transform.TupleConstructor
|
||||
|
||||
@TupleConstructor
|
||||
class X<caret>x {}
|
||||
''')
|
||||
|
||||
renameElementAtCaret('Yy')
|
||||
checkResult("""\
|
||||
import groovy.transform.TupleConstructor
|
||||
|
||||
@TupleConstructor
|
||||
class Y<caret>y {}
|
||||
""")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user