From b7bfb1a8789e110b9135ac71ebc34c382ba77b75 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Tue, 9 Nov 2010 13:18:38 +0300 Subject: [PATCH 01/45] prepopulate choose by name with selected text in editor (IDEA-57250) --- .../src/com/intellij/ide/actions/GotoActionBase.java | 11 +++++++++++ .../src/com/intellij/ide/actions/GotoClassAction.java | 3 ++- .../src/com/intellij/ide/actions/GotoFileAction.java | 3 ++- .../com/intellij/ide/actions/GotoSymbolAction.java | 3 ++- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/ide/actions/GotoActionBase.java b/platform/lang-impl/src/com/intellij/ide/actions/GotoActionBase.java index 0fda5957f06e..4c69b3a20065 100644 --- a/platform/lang-impl/src/com/intellij/ide/actions/GotoActionBase.java +++ b/platform/lang-impl/src/com/intellij/ide/actions/GotoActionBase.java @@ -34,6 +34,17 @@ public abstract class GotoActionBase extends AnAction { protected static Class myInAction = null; + public static String getInitialText(Editor editor) { + if (editor == null) { + return ""; + } + final String selectedText = editor.getSelectionModel().getSelectedText(); + if (selectedText != null && selectedText.indexOf("\n") < 0) { + return selectedText; + } + return ""; + } + public final void actionPerformed(AnActionEvent e) { LOG.assertTrue (!getClass ().equals (myInAction)); try { diff --git a/platform/lang-impl/src/com/intellij/ide/actions/GotoClassAction.java b/platform/lang-impl/src/com/intellij/ide/actions/GotoClassAction.java index 6842dec2b59f..7dd49cbbf3c5 100644 --- a/platform/lang-impl/src/com/intellij/ide/actions/GotoClassAction.java +++ b/platform/lang-impl/src/com/intellij/ide/actions/GotoClassAction.java @@ -47,7 +47,8 @@ public class GotoClassAction extends GotoActionBase implements DumbAware { PsiDocumentManager.getInstance(project).commitAllDocuments(); final GotoClassModel2 model = new GotoClassModel2(project); - final ChooseByNamePopup popup = ChooseByNamePopup.createPopup(project, model, getPsiContext(e)); + final ChooseByNamePopup popup = ChooseByNamePopup.createPopup(project, model, getPsiContext(e), + getInitialText(e.getData(PlatformDataKeys.EDITOR))); final ChooseByNameFilter filterUI = new ChooseByNameLanguageFilter(popup, model, GotoClassSymbolConfiguration.getInstance(project), project); popup.invoke(new ChooseByNamePopupComponent.Callback() { diff --git a/platform/lang-impl/src/com/intellij/ide/actions/GotoFileAction.java b/platform/lang-impl/src/com/intellij/ide/actions/GotoFileAction.java index a1c64f86dcc4..823b1e8a7b72 100644 --- a/platform/lang-impl/src/com/intellij/ide/actions/GotoFileAction.java +++ b/platform/lang-impl/src/com/intellij/ide/actions/GotoFileAction.java @@ -52,7 +52,8 @@ public class GotoFileAction extends GotoActionBase implements DumbAware { FeatureUsageTracker.getInstance().triggerFeatureUsed("navigation.popup.file"); final Project project = e.getData(PlatformDataKeys.PROJECT); final GotoFileModel gotoFileModel = new GotoFileModel(project); - final ChooseByNamePopup popup = ChooseByNamePopup.createPopup(project, gotoFileModel, getPsiContext(e)); + final ChooseByNamePopup popup = ChooseByNamePopup.createPopup(project, gotoFileModel, getPsiContext(e), + getInitialText(e.getData(PlatformDataKeys.EDITOR))); final ChooseByNameFilter filterUI = new GotoFileFilter(popup, gotoFileModel, project); popup.invoke(new ChooseByNamePopupComponent.Callback() { public void onClose() { diff --git a/platform/lang-impl/src/com/intellij/ide/actions/GotoSymbolAction.java b/platform/lang-impl/src/com/intellij/ide/actions/GotoSymbolAction.java index 26a68ae23cb3..ef2d7197d441 100644 --- a/platform/lang-impl/src/com/intellij/ide/actions/GotoSymbolAction.java +++ b/platform/lang-impl/src/com/intellij/ide/actions/GotoSymbolAction.java @@ -36,7 +36,8 @@ public class GotoSymbolAction extends GotoActionBase { PsiDocumentManager.getInstance(project).commitAllDocuments(); final GotoSymbolModel2 model = new GotoSymbolModel2(project); - final ChooseByNamePopup popup = ChooseByNamePopup.createPopup(project, model, getPsiContext(e)); + final ChooseByNamePopup popup = ChooseByNamePopup.createPopup(project, model, getPsiContext(e), + getInitialText(e.getData(PlatformDataKeys.EDITOR))); final ChooseByNameFilter filterUI = new ChooseByNameLanguageFilter(popup, model, GotoClassSymbolConfiguration.getInstance(project), project); popup.invoke(new ChooseByNamePopupComponent.Callback() { From 5a2c1d2ab47b494e7f0cce7c0b959015542edc01 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Tue, 9 Nov 2010 13:23:33 +0300 Subject: [PATCH 02/45] Import settings dialog: don't gray out deselected items (IDEA-60940) --- .../com/intellij/ide/actions/ChooseComponentsToExportDialog.java | 1 + 1 file changed, 1 insertion(+) diff --git a/platform/platform-impl/src/com/intellij/ide/actions/ChooseComponentsToExportDialog.java b/platform/platform-impl/src/com/intellij/ide/actions/ChooseComponentsToExportDialog.java index cb6e09877419..7874189358ca 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/ChooseComponentsToExportDialog.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/ChooseComponentsToExportDialog.java @@ -68,6 +68,7 @@ public class ChooseComponentsToExportDialog extends DialogWrapper { } final Set componentElementProperties = new LinkedHashSet(componentToContainingListElement.values()); myChooser = new ElementsChooser(true); + myChooser.setColorUnmarkedElements(false); for (final ComponentElementProperties componentElementProperty : componentElementProperties) { myChooser.addElement(componentElementProperty, true, componentElementProperty); } From e5cca9cde569f364c632a5f534576ee5c7ae7461 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Tue, 9 Nov 2010 13:46:33 +0300 Subject: [PATCH 03/45] provide "delete to line end" action, use it in Eclipse keymap (IDEA-56243) --- .../editor/actions/CutLineEndAction.java | 14 +++++++--- .../editor/actions/DeleteToLineEndAction.java | 27 +++++++++++++++++++ .../src/idea/Keymap_Eclipse.xml | 2 +- .../src/idea/PlatformActions.xml | 1 + 4 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 platform/platform-impl/src/com/intellij/openapi/editor/actions/DeleteToLineEndAction.java diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/actions/CutLineEndAction.java b/platform/platform-impl/src/com/intellij/openapi/editor/actions/CutLineEndAction.java index d42ec92ad09f..154423330c7c 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/actions/CutLineEndAction.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/actions/CutLineEndAction.java @@ -40,10 +40,16 @@ import java.awt.datatransfer.StringSelection; public class CutLineEndAction extends EditorAction { public CutLineEndAction() { - super(new Handler()); + super(new Handler(true)); } - private static class Handler extends EditorWriteActionHandler { + static class Handler extends EditorWriteActionHandler { + private final boolean myCopyToClipboard; + + Handler(boolean copyToClipboard) { + myCopyToClipboard = copyToClipboard; + } + public void executeWriteAction(Editor editor, DataContext dataContext) { final Document doc = editor.getDocument(); if (doc.getLineCount() == 0) return; @@ -56,7 +62,9 @@ public class CutLineEndAction extends EditorAction { return; } - copyToClipboard(doc, caretOffset, lineEndOffset, dataContext, editor); + if (myCopyToClipboard) { + copyToClipboard(doc, caretOffset, lineEndOffset, dataContext, editor); + } final int lineStartOffset = doc.getLineStartOffset(lineNumber); if (StringUtil.isEmptyOrSpaces(doc.getCharsSequence().subSequence(lineStartOffset, lineEndOffset).toString())) { diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/actions/DeleteToLineEndAction.java b/platform/platform-impl/src/com/intellij/openapi/editor/actions/DeleteToLineEndAction.java new file mode 100644 index 000000000000..b178ba89728c --- /dev/null +++ b/platform/platform-impl/src/com/intellij/openapi/editor/actions/DeleteToLineEndAction.java @@ -0,0 +1,27 @@ +/* + * Copyright 2000-2010 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.actions; + +import com.intellij.openapi.editor.actionSystem.EditorAction; + +/** + * @author yole + */ +public class DeleteToLineEndAction extends EditorAction { + public DeleteToLineEndAction() { + super(new CutLineEndAction.Handler(false)); + } +} diff --git a/platform/platform-resources/src/idea/Keymap_Eclipse.xml b/platform/platform-resources/src/idea/Keymap_Eclipse.xml index 7198e1f92409..6f749a03b42b 100644 --- a/platform/platform-resources/src/idea/Keymap_Eclipse.xml +++ b/platform/platform-resources/src/idea/Keymap_Eclipse.xml @@ -59,7 +59,7 @@ - + diff --git a/platform/platform-resources/src/idea/PlatformActions.xml b/platform/platform-resources/src/idea/PlatformActions.xml index 55c40538ce57..d571195faca2 100644 --- a/platform/platform-resources/src/idea/PlatformActions.xml +++ b/platform/platform-resources/src/idea/PlatformActions.xml @@ -57,6 +57,7 @@ + From d1164f1c361c729c231d9db2a9e82ea9d1f0d0cb Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Tue, 9 Nov 2010 14:10:04 +0300 Subject: [PATCH 04/45] allow specifying custom name for "jump to source" action (IDEA-59460) --- .../impl/nodes/NamedLibraryElementNode.java | 8 ++++++- .../com/intellij/pom/NavigatableWithText.java | 23 +++++++++++++++++++ .../actions/BaseNavigateToSourceAction.java | 18 +++++++++++---- 3 files changed, 43 insertions(+), 6 deletions(-) create mode 100644 platform/platform-api/src/com/intellij/pom/NavigatableWithText.java diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/NamedLibraryElementNode.java b/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/NamedLibraryElementNode.java index 0ab7de8454bd..0014de0dd56c 100644 --- a/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/NamedLibraryElementNode.java +++ b/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/NamedLibraryElementNode.java @@ -33,6 +33,7 @@ import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.pom.NavigatableWithText; import org.jetbrains.annotations.NotNull; import javax.swing.*; @@ -40,7 +41,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; -public class NamedLibraryElementNode extends ProjectViewNode{ +public class NamedLibraryElementNode extends ProjectViewNode implements NavigatableWithText { private static final Icon GENERIC_JDK_ICON = IconLoader.getIcon("/general/jdk.png"); private static final Icon LIB_ICON_OPEN = IconLoader.getIcon("/nodes/ppLibOpen.png"); private static final Icon LIB_ICON_CLOSED = IconLoader.getIcon("/nodes/ppLibClosed.png"); @@ -123,4 +124,9 @@ public class NamedLibraryElementNode extends ProjectViewNode Date: Tue, 9 Nov 2010 16:55:19 +0300 Subject: [PATCH 05/45] fix passing selected tab from ProjectSettingsService --- .../openapi/roots/ui/configuration/ModuleEditor.java | 5 +++-- .../roots/ui/configuration/ProjectStructureConfigurable.java | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ModuleEditor.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ModuleEditor.java index 8af238b834d5..59e25af14f35 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ModuleEditor.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ModuleEditor.java @@ -60,6 +60,7 @@ import java.util.List; @SuppressWarnings({"AssignmentToStaticFieldFromInstanceMethod"}) public abstract class ModuleEditor implements Place.Navigator, Disposable { + public static final String MODULE_TAB = "moduleTab"; private final Project myProject; private JPanel myGenericSettingsPanel; private ModifiableRootModel myModifiableRootModel; // important: in order to correctly update OrderEntries UI use corresponding proxy for the model @@ -246,12 +247,12 @@ public abstract class ModuleEditor implements Place.Navigator, Disposable { } public ActionCallback navigateTo(@Nullable final Place place, final boolean requestFocus) { - myTabbedPane.setSelectedTitle((String)place.getPath("moduleTab")); + myTabbedPane.setSelectedTitle((String)place.getPath(MODULE_TAB)); return new ActionCallback.Done(); } public void queryPlace(@NotNull final Place place) { - place.putPath("moduleTab", ourSelectedTabName); + place.putPath(MODULE_TAB, ourSelectedTabName); } public static String getSelectedTab(){ diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ProjectStructureConfigurable.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ProjectStructureConfigurable.java index fac45969b2a7..63132c974ee3 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ProjectStructureConfigurable.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ProjectStructureConfigurable.java @@ -359,7 +359,7 @@ public class ProjectStructureConfigurable extends BaseConfigurable implements Se if (moduleToSelect != null) { final Module module = ModuleManager.getInstance(myProject).findModuleByName(moduleToSelect); assert module != null; - place = place.putPath(ModuleStructureConfigurable.TREE_OBJECT, module); + place = place.putPath(ModuleStructureConfigurable.TREE_OBJECT, module).putPath(ModuleEditor.MODULE_TAB, tab); } return navigateTo(place, requestFocus); } From 8c2746638e98f4aba031984c4480ccca9ff99037 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Tue, 9 Nov 2010 17:15:55 +0300 Subject: [PATCH 06/45] provide name for "navigate to source" action on PsiDirectoryNode --- .../impl/nodes/PsiDirectoryNode.java | 28 +++++++++++++++++-- .../com/intellij/pom/NavigatableWithText.java | 3 ++ .../actions/BaseNavigateToSourceAction.java | 9 +++++- 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/PsiDirectoryNode.java b/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/PsiDirectoryNode.java index 047e12c09453..df2e3249a93e 100644 --- a/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/PsiDirectoryNode.java +++ b/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/PsiDirectoryNode.java @@ -35,6 +35,7 @@ import com.intellij.openapi.util.Iconable; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.pom.NavigatableWithText; import com.intellij.psi.PsiDirectory; import com.intellij.psi.impl.file.PsiDirectoryFactory; import com.intellij.ui.LayeredIcon; @@ -47,7 +48,7 @@ import org.jetbrains.annotations.NotNull; import javax.swing.*; import java.util.Collection; -public class PsiDirectoryNode extends BasePsiNode { +public class PsiDirectoryNode extends BasePsiNode implements NavigatableWithText { public PsiDirectoryNode(Project project, PsiDirectory value, ViewSettings viewSettings) { super(project, value, viewSettings); } @@ -190,15 +191,38 @@ public class PsiDirectoryNode extends BasePsiNode { public void navigate(final boolean requestFocus) { Module module = ModuleUtil.findModuleForPsiElement(getValue()); if (module != null) { - if (ProjectRootsUtil.isModuleContentRoot(getVirtualFile(), getProject())) { + final VirtualFile file = getVirtualFile(); + final Project project = getProject(); + if (ProjectRootsUtil.isModuleContentRoot(file, project)) { ProjectSettingsService.getInstance(myProject).openModuleSettings(module); } + else if (ProjectRootsUtil.isLibraryRoot(file, project)) { + ProjectSettingsService.getInstance(myProject).openModuleLibrarySettings(module); + } else { ProjectSettingsService.getInstance(myProject).openContentEntriesSettings(module); } } } + @Override + public String getNavigateActionText(boolean focusEditor) { + VirtualFile file = getVirtualFile(); + Project project = getProject(); + + if (file != null) { + if (ProjectRootsUtil.isModuleContentRoot(file, project) || + ProjectRootsUtil.isSourceOrTestRoot(file, project)) { + return "Open Module Settings"; + } + if (ProjectRootsUtil.isLibraryRoot(file, project)) { + return "Open Library Settings"; + } + } + + return null; + } + public int getWeight() { return isFQNameShown() ? 70 : 0; } diff --git a/platform/platform-api/src/com/intellij/pom/NavigatableWithText.java b/platform/platform-api/src/com/intellij/pom/NavigatableWithText.java index 57669c1159f7..a9968e592fef 100644 --- a/platform/platform-api/src/com/intellij/pom/NavigatableWithText.java +++ b/platform/platform-api/src/com/intellij/pom/NavigatableWithText.java @@ -15,9 +15,12 @@ */ package com.intellij.pom; +import org.jetbrains.annotations.Nullable; + /** * @author yole */ public interface NavigatableWithText extends Navigatable { + @Nullable String getNavigateActionText(boolean focusEditor); } diff --git a/platform/platform-impl/src/com/intellij/ide/actions/BaseNavigateToSourceAction.java b/platform/platform-impl/src/com/intellij/ide/actions/BaseNavigateToSourceAction.java index 4c85e9465071..14ba0980674e 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/BaseNavigateToSourceAction.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/BaseNavigateToSourceAction.java @@ -46,13 +46,20 @@ public abstract class BaseNavigateToSourceAction extends AnAction implements Dum event.getPresentation().setEnabled(enabled); } if (target != null && target instanceof NavigatableWithText) { - event.getPresentation().setText(((NavigatableWithText)target).getNavigateActionText(myFocusEditor)); + final String navigateActionText = ((NavigatableWithText)target).getNavigateActionText(myFocusEditor); + if (navigateActionText != null) { + event.getPresentation().setText(navigateActionText); + } + else { + event.getPresentation().setText(getTemplatePresentation().getText()); + } } else { event.getPresentation().setText(getTemplatePresentation().getText()); } } + @Nullable private Navigatable getTarget(final DataContext dataContext) { Navigatable[] navigatables = getNavigatables(dataContext); if (navigatables != null) { From aa6f787a8d8c185f75a11aa9978f367a8c7263b1 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Tue, 9 Nov 2010 17:22:40 +0300 Subject: [PATCH 07/45] no need to have two separate module settings actions in the context menu --- .../ide/projectView/impl/nodes/AbstractModuleNode.java | 8 +++++++- resources/src/idea/IdeaActions.xml | 4 ---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/AbstractModuleNode.java b/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/AbstractModuleNode.java index 3cad5dedf975..2009d454eb16 100644 --- a/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/AbstractModuleNode.java +++ b/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/AbstractModuleNode.java @@ -25,10 +25,11 @@ import com.intellij.openapi.roots.ui.configuration.ProjectSettingsService; import com.intellij.openapi.vfs.JarFileSystem; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.pom.NavigatableWithText; import com.intellij.ui.SimpleTextAttributes; import org.jetbrains.annotations.NotNull; -public abstract class AbstractModuleNode extends ProjectViewNode { +public abstract class AbstractModuleNode extends ProjectViewNode implements NavigatableWithText { protected AbstractModuleNode(Project project, Module module, ViewSettings viewSettings) { super(project, module, viewSettings); } @@ -84,6 +85,11 @@ public abstract class AbstractModuleNode extends ProjectViewNode { ProjectSettingsService.getInstance(myProject).openModuleSettings(getValue()); } + @Override + public String getNavigateActionText(boolean focusEditor) { + return "Open Module Settings"; + } + public boolean canNavigate() { return true; } diff --git a/resources/src/idea/IdeaActions.xml b/resources/src/idea/IdeaActions.xml index 05130fbc564d..5617e7f3af70 100644 --- a/resources/src/idea/IdeaActions.xml +++ b/resources/src/idea/IdeaActions.xml @@ -382,10 +382,6 @@ - - - - From 9d0e24d7f3e07c72718bbb2b49b0635b9f035d67 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Tue, 9 Nov 2010 17:27:44 +0300 Subject: [PATCH 08/45] EA-23238 - SIOOBE: TemplateResource.getMethodBody --- .../tostring/template/TemplateResource.java | 426 +++++++++--------- 1 file changed, 215 insertions(+), 211 deletions(-) diff --git a/plugins/generate-tostring/src/org/jetbrains/generate/tostring/template/TemplateResource.java b/plugins/generate-tostring/src/org/jetbrains/generate/tostring/template/TemplateResource.java index 4ffd7b8ae7f8..d0ff33a96e7a 100644 --- a/plugins/generate-tostring/src/org/jetbrains/generate/tostring/template/TemplateResource.java +++ b/plugins/generate-tostring/src/org/jetbrains/generate/tostring/template/TemplateResource.java @@ -27,246 +27,250 @@ import java.io.Serializable; * the text is stored. */ public class TemplateResource implements Serializable { - private final boolean isDefault; - private String fileName = ""; - private String template = ""; + private final boolean isDefault; + private String fileName = ""; + private String template = ""; - /** - * Constructor. - * - * @param fileName a template filename - * @param template the template velocity body content - */ - public TemplateResource(String fileName, String template) { - this(fileName, template, false); + /** + * Constructor. + * + * @param fileName a template filename + * @param template the template velocity body content + */ + public TemplateResource(String fileName, String template) { + this(fileName, template, false); + } + + public TemplateResource(String fileName, String template, boolean aDefault) { + isDefault = aDefault; + this.fileName = fileName; + this.template = template; + } + + /** + * Bean constructor + */ + public TemplateResource() { + isDefault = false; + } + + public String getTemplate() { + return template; + } + + public void setTemplate(String template) { + this.template = template; + } + + public String getFileName() { + return fileName; + } + + public void setFileName(String fileName) { + this.fileName = fileName; + } + + public boolean isDefault() { + return isDefault; + } + + /** + * Get's the javadoc, if any. + * + * @return the javadoc, null if no javadoc. + */ + @Nullable + public String getJavaDoc() { + int i = template.indexOf("*/"); + if (i == -1) { + return null; } - public TemplateResource(String fileName, String template, boolean aDefault) { - isDefault = aDefault; - this.fileName = fileName; - this.template = template; + return template.substring(0, i + 2); + } + + /** + * Get's the method body. + * + * @return the method body. + */ + public String getMethodBody() { + return getMethodBody(template); + } + + @Nullable + private static String getMethodBody(String template) { + String signature = getMethodSignature(template); + String s = StringUtil.after(template, signature); + + if (s == null) { + return null; } - /** - * Bean constructor - */ - public TemplateResource() { - isDefault = false; + // skip the starting and ending { } + final String trimmed = s.trim(); + return trimmed.substring(1, s.length() - 1); + } + + /** + * Gets the method signature + *

+ * public String toString() + */ + public String getMethodSignature() { + return getMethodSignature(template); + } + + private static String getMethodSignature(String template) { + String s = StringUtil.after(template, "*/").trim(); + + StringBuffer signature = new StringBuffer(); + + String[] lines = s.split("\n"); + for (String line : lines) { + line = line.trim(); + if (line.startsWith("@")) { + continue; + } + signature.append(line); + if (line.indexOf("{") > -1) { + break; + } } - public String getTemplate() { - return template; + // remove last { + String result = signature.toString(); + return result.substring(0, result.lastIndexOf("{")); + } + + /** + * Get's the method that this template is for (toString) + */ + public String getTargetMethodName() { + String s = getMethodSignature(); + s = StringUtil.before(s, "("); + int i = s.lastIndexOf(" "); + return s.substring(i).trim(); + } + + /** + * Validates this template to see if its valid for plugin v3.10 or higher. + * + * @return true if valid, false if not + */ + public boolean isValidTemplate() { + return isValidTemplate(template); + } + + /** + * Validates the provided template. + * + * @param template the template to validate. + * @return true if valid, false if not. + */ + public static boolean isValidTemplate(String template) { + template = template.trim(); + + if (template.indexOf("{") == -1) { + return false; } - public void setTemplate(String template) { - this.template = template; + // ending } must be the last character + String s = template.trim(); + if (s.lastIndexOf("}") != s.length() - 1) { + return false; } - public String getFileName() { - return fileName; + if (getMethodSignature(template) == null) { + return false; } - public void setFileName(String fileName) { - this.fileName = fileName; + if (getMethodBody(template) == null) { + return false; } - public boolean isDefault() { - return isDefault; + return true; + } + + /** + * Does the template use annotations? + * + * @return true if so, false if not. + */ + public boolean hasAnnotations() { + return getAnnotations() != null; + } + + /** + * Get's the annotations + * + * @return the annotation, null if does not have. + */ + public String[] getAnnotations() { + String signature = getMethodSignature(); + String javadoc = getJavaDoc(); + String annotations; + if (javadoc != null) { + annotations = StringUtil.middle(template, javadoc, signature); + } + else { + annotations = StringUtil.before(template, signature); } - /** - * Get's the javadoc, if any. - * - * @return the javadoc, null if no javadoc. - */ - @Nullable - public String getJavaDoc() { - int i = template.indexOf("*/"); - if (i == -1) - return null; - - return template.substring(0, i + 2); + if (StringUtil.isEmpty(annotations)) { + return null; } - /** - * Get's the method body. - * - * @return the method body. - */ - public String getMethodBody() { - return getMethodBody(template); + if (annotations.indexOf("@") == -1) { + return null; } - @Nullable - private static String getMethodBody(String template) { - String signature = getMethodSignature(template); - String s = StringUtil.after(template, signature); - - if (s == null) - return null; - - // skip the starting and ending { } - return s.trim().substring(1, s.length() - 1); + // remove first and last \n + annotations = annotations.trim(); + if (annotations.startsWith("\n")) { + annotations = annotations.substring(1); + } + if (annotations.endsWith("\n")) { + annotations = annotations.substring(0, annotations.length() - 1); } - /** - * Gets the method signature - *

- * public String toString() - */ - public String getMethodSignature() { - return getMethodSignature(template); - } + return annotations.split("\n"); + } - private static String getMethodSignature(String template) { - String s = StringUtil.after(template, "*/").trim(); + /** + * Important to return filename only as it is the displayname in the UI. + * + * @return filename for UI. + */ + public String toString() { + return fileName != null ? fileName : template; + } - StringBuffer signature = new StringBuffer(); + public String getName() { + return fileName; + } - String[] lines = s.split("\n"); - for (String line : lines) { - line = line.trim(); - if (line.startsWith("@")) { - continue; - } - signature.append(line); - if (line.indexOf("{") > -1) { - break; - } - } + public void copyFrom(TemplateResource templateResource) { + fileName = templateResource.getFileName(); + template = templateResource.getTemplate(); + } - // remove last { - String result = signature.toString(); - return result.substring(0, result.lastIndexOf("{")); - } + public void setName(String name) { + fileName = name; + } - /** - * Get's the method that this template is for (toString) - */ - public String getTargetMethodName() { - String s = getMethodSignature(); - s = StringUtil.before(s, "("); - int i = s.lastIndexOf(" "); - return s.substring(i).trim(); - } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof TemplateResource)) return false; - /** - * Validates this template to see if its valid for plugin v3.10 or higher. - * - * @return true if valid, false if not - */ - public boolean isValidTemplate() { - return isValidTemplate(template); - } + TemplateResource that = (TemplateResource)o; - /** - * Validates the provided template. - * - * @param template the template to validate. - * @return true if valid, false if not. - */ - public static boolean isValidTemplate(String template) { - template = template.trim(); + return fileName.equals(that.fileName) && template.equals(that.template); + } - if (template.indexOf("{") == -1) { - return false; - } - - // ending } must be the last character - String s = template.trim(); - if (s.lastIndexOf("}") != s.length() - 1) { - return false; - } - - if (getMethodSignature(template) == null) { - return false; - } - - if (getMethodBody(template) == null) { - return false; - } - - return true; - } - - /** - * Does the template use annotations? - * - * @return true if so, false if not. - */ - public boolean hasAnnotations() { - return getAnnotations() != null; - } - - /** - * Get's the annotations - * - * @return the annotation, null if does not have. - */ - public String[] getAnnotations() { - String signature = getMethodSignature(); - String javadoc = getJavaDoc(); - String annotations; - if (javadoc != null) { - annotations = StringUtil.middle(template, javadoc, signature); - } else { - annotations = StringUtil.before(template, signature); - } - - if (StringUtil.isEmpty(annotations)) { - return null; - } - - if (annotations.indexOf("@") == -1) { - return null; - } - - // remove first and last \n - annotations = annotations.trim(); - if (annotations.startsWith("\n")) { - annotations = annotations.substring(1); - } - if (annotations.endsWith("\n")) { - annotations = annotations.substring(0, annotations.length()-1); - } - - return annotations.split("\n"); - } - - /** - * Important to return filename only as it is the displayname in the UI. - * @return filename for UI. - */ - public String toString() { - return fileName != null ? fileName : template; - } - - public String getName() { - return fileName; - } - - public void copyFrom(TemplateResource templateResource) { - fileName = templateResource.getFileName(); - template = templateResource.getTemplate(); - } - - public void setName(String name) { - fileName = name; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof TemplateResource)) return false; - - TemplateResource that = (TemplateResource) o; - - return fileName.equals(that.fileName) && template.equals(that.template); - - } - - @Override - public int hashCode() { - return 31 * fileName.hashCode() + template.hashCode(); - } + @Override + public int hashCode() { + return 31 * fileName.hashCode() + template.hashCode(); + } } From a336f1bbc48aea6b33a37a1edf8dae8ad4bb2637 Mon Sep 17 00:00:00 2001 From: anna Date: Tue, 9 Nov 2010 16:29:52 +0300 Subject: [PATCH 09/45] collect statistics for type selected --- .../introduceVariable/IntroduceVariableBase.java | 7 +++++-- .../introduceVariable/ReassignVariableUtil.java | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableBase.java b/java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableBase.java index b5dc13ba4f83..c8c42e8440f0 100644 --- a/java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableBase.java +++ b/java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableBase.java @@ -462,8 +462,9 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase impleme final IntroduceVariableSettings settings = getSettings(project, editor, expr, occurrences, typeSelectorManager, inFinalContext, hasWriteAccess, validator, choice); if (!settings.isOK()) return; + typeSelectorManager.setAllOccurences(choice != OccurrencesChooser.ReplaceChoice.NO); final RangeMarker exprMarker = editor.getDocument().createRangeMarker(expr.getTextRange()); - final SuggestedNameInfo suggestedName = getSuggestedName(typeSelectorManager.getDefaultType(), expr); + final SuggestedNameInfo suggestedName = getSuggestedName(settings.getSelectedType(), expr); final Runnable runnable = introduce(project, expr, editor, anchorStatement, tempContainer, occurrences, anchorStatementIfAll, settings, variable); CommandProcessor.getInstance().executeCommand( @@ -501,6 +502,7 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase impleme editor.getCaretModel().moveToOffset(startOffset); } editor.putUserData(ReassignVariableUtil.DECLARATION_KEY, null); + typeSelectorManager.typeSelected(ReassignVariableUtil.getVariableType(declarationStatement)); exprMarker.dispose(); } }); @@ -816,7 +818,8 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase impleme @Override public PsiType getSelectedType() { - return typeSelectorManager.getDefaultType(); + final PsiType selectedType = typeSelectorManager.getTypeSelector().getSelectedType(); + return selectedType != null ? selectedType : typeSelectorManager.getDefaultType(); } @Override diff --git a/java/java-impl/src/com/intellij/refactoring/introduceVariable/ReassignVariableUtil.java b/java/java-impl/src/com/intellij/refactoring/introduceVariable/ReassignVariableUtil.java index 9e76662587ed..8f7141df44a7 100644 --- a/java/java-impl/src/com/intellij/refactoring/introduceVariable/ReassignVariableUtil.java +++ b/java/java-impl/src/com/intellij/refactoring/introduceVariable/ReassignVariableUtil.java @@ -97,7 +97,7 @@ public class ReassignVariableUtil { } @Nullable - private static PsiType getVariableType(@Nullable PsiDeclarationStatement declaration) { + static PsiType getVariableType(@Nullable PsiDeclarationStatement declaration) { if (declaration != null) { final PsiElement[] declaredElements = declaration.getDeclaredElements(); if (declaredElements.length > 0 && declaredElements[0] instanceof PsiVariable) { From 4cd12ba0b26f865d89ff2442ec12330ab9ee1e23 Mon Sep 17 00:00:00 2001 From: anna Date: Tue, 9 Nov 2010 17:17:57 +0300 Subject: [PATCH 10/45] import selected type on insertion --- .../refactoring/introduceVariable/ReassignVariableUtil.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/java/java-impl/src/com/intellij/refactoring/introduceVariable/ReassignVariableUtil.java b/java/java-impl/src/com/intellij/refactoring/introduceVariable/ReassignVariableUtil.java index 8f7141df44a7..aab01479d103 100644 --- a/java/java-impl/src/com/intellij/refactoring/introduceVariable/ReassignVariableUtil.java +++ b/java/java-impl/src/com/intellij/refactoring/introduceVariable/ReassignVariableUtil.java @@ -14,6 +14,7 @@ package com.intellij.refactoring.introduceVariable; import com.intellij.codeInsight.lookup.LookupElement; import com.intellij.codeInsight.lookup.LookupElementBuilder; +import com.intellij.codeInsight.lookup.PsiTypeLookupItem; import com.intellij.codeInsight.template.Expression; import com.intellij.codeInsight.template.ExpressionContext; import com.intellij.codeInsight.template.TextResult; @@ -167,7 +168,7 @@ public class ReassignVariableUtil { public LookupElement[] calculateLookupItems(ExpressionContext context) { LookupElement[] result = new LookupElement[types.length]; for (int i = 0, typesLength = types.length; i < typesLength; i++) { - result[i] = LookupElementBuilder.create(types[i], types[i].getPresentableText()); + result[i] = PsiTypeLookupItem.createLookupItem(types[i], null); } return result; } From 31551a9aa5c09d7cc1eecdd99bc5a051d67136a9 Mon Sep 17 00:00:00 2001 From: Alexey Pegov Date: Tue, 9 Nov 2010 17:46:10 +0300 Subject: [PATCH 11/45] IDEA-52423 Bring back option for Run/Debug to pop up configurations --- .../RunnerAndConfigurationSettings.java | 4 +++ .../intellij/execution/ProgramRunnerUtil.java | 2 +- .../com/intellij/execution/RunManagerEx.java | 2 ++ .../ConfigurationSettingsEditorWrapper.java | 31 +++++++++++++------ .../execution/impl/RunManagerImpl.java | 9 ++++++ .../RunnerAndConfigurationSettingsImpl.java | 18 ++++++++++- .../src/messages/ExecutionBundle.properties | 1 + 7 files changed, 56 insertions(+), 11 deletions(-) diff --git a/platform/lang-api/src/com/intellij/execution/RunnerAndConfigurationSettings.java b/platform/lang-api/src/com/intellij/execution/RunnerAndConfigurationSettings.java index 572f7ead1c0d..26a0944f9267 100644 --- a/platform/lang-api/src/com/intellij/execution/RunnerAndConfigurationSettings.java +++ b/platform/lang-api/src/com/intellij/execution/RunnerAndConfigurationSettings.java @@ -52,4 +52,8 @@ public interface RunnerAndConfigurationSettings { void setTemporary(boolean temporary); Factory createFactory(); + + void setEditBeforeRun(boolean b); + + boolean isEditBeforeRun(); } diff --git a/platform/lang-impl/src/com/intellij/execution/ProgramRunnerUtil.java b/platform/lang-impl/src/com/intellij/execution/ProgramRunnerUtil.java index 9b34532b148f..f974986590be 100644 --- a/platform/lang-impl/src/com/intellij/execution/ProgramRunnerUtil.java +++ b/platform/lang-impl/src/com/intellij/execution/ProgramRunnerUtil.java @@ -58,7 +58,7 @@ public class ProgramRunnerUtil { return; } - if (!RunManagerImpl.canRunConfiguration(configuration, executor)) { + if (!RunManagerImpl.canRunConfiguration(configuration, executor) || RunManagerImpl.isEditBeforeRun(configuration)) { final boolean result = RunDialog.editConfiguration(project, configuration, "Edit configuration", executor.getActionName(), executor.getIcon()); if (!result) { return; diff --git a/platform/lang-impl/src/com/intellij/execution/RunManagerEx.java b/platform/lang-impl/src/com/intellij/execution/RunManagerEx.java index fc6b6a24cce6..c2a9d032ae6d 100644 --- a/platform/lang-impl/src/com/intellij/execution/RunManagerEx.java +++ b/platform/lang-impl/src/com/intellij/execution/RunManagerEx.java @@ -48,6 +48,8 @@ public abstract class RunManagerEx extends RunManager { public abstract void setTemporaryConfiguration(RunnerAndConfigurationSettings tempConfiguration); + public abstract void setEditBeforeRun(RunConfiguration settings, boolean edit); + public abstract RunManagerConfig getConfig(); @NotNull diff --git a/platform/lang-impl/src/com/intellij/execution/impl/ConfigurationSettingsEditorWrapper.java b/platform/lang-impl/src/com/intellij/execution/impl/ConfigurationSettingsEditorWrapper.java index 53de302b4f2a..efcbd9ef4ea0 100644 --- a/platform/lang-impl/src/com/intellij/execution/impl/ConfigurationSettingsEditorWrapper.java +++ b/platform/lang-impl/src/com/intellij/execution/impl/ConfigurationSettingsEditorWrapper.java @@ -18,6 +18,7 @@ package com.intellij.execution.impl; import com.intellij.execution.BeforeRunTask; import com.intellij.execution.BeforeRunTaskProvider; +import com.intellij.execution.ExecutionBundle; import com.intellij.execution.RunnerAndConfigurationSettings; import com.intellij.execution.configurations.RunConfiguration; import com.intellij.execution.configurations.UnknownRunConfiguration; @@ -55,10 +56,12 @@ public class ConfigurationSettingsEditorWrapper extends SettingsEditor, BeforeRunTask> myStepsBeforeLaunch; private final Map, StepBeforeLaunchRow> myStepBeforeLaunchRows = new THashMap, StepBeforeLaunchRow>(); private boolean myStoreProjectConfiguration; + private boolean myEditBeforeRun; private final ConfigurationSettingsEditor myEditor; @@ -78,7 +81,7 @@ public class ConfigurationSettingsEditorWrapper extends SettingsEditor[] providers = Extensions.getExtensions(BeforeRunTaskProvider.EXTENSION_POINT_NAME, runConfiguration.getProject()); myStepsPanel.removeAll(); - if (providers.length == 0 || runConfiguration instanceof UnknownRunConfiguration) { + if (runConfiguration instanceof UnknownRunConfiguration) { myStepsPanel.setVisible(false); } else { @@ -92,17 +95,25 @@ public class ConfigurationSettingsEditorWrapper extends SettingsEditor, BeforeRunTask> getStepsBeforeLaunch() { diff --git a/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java b/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java index 30f57223b6d9..329392e2ed1e 100644 --- a/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java @@ -619,6 +619,15 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable, setActiveConfiguration(tempConfiguration); } + public static boolean isEditBeforeRun(@NotNull final RunnerAndConfigurationSettings configuration) { + return configuration.isEditBeforeRun(); + } + + public void setEditBeforeRun(@NotNull final RunConfiguration configuration, final boolean edit) { + final RunnerAndConfigurationSettings settings = getSettings(configuration); + if (settings != null) settings.setEditBeforeRun(edit); + } + public void setActiveConfiguration(final RunnerAndConfigurationSettings configuration) { setSelectedConfiguration(configuration); } diff --git a/platform/lang-impl/src/com/intellij/execution/impl/RunnerAndConfigurationSettingsImpl.java b/platform/lang-impl/src/com/intellij/execution/impl/RunnerAndConfigurationSettingsImpl.java index 94de17906a01..18730145d1f3 100644 --- a/platform/lang-impl/src/com/intellij/execution/impl/RunnerAndConfigurationSettingsImpl.java +++ b/platform/lang-impl/src/com/intellij/execution/impl/RunnerAndConfigurationSettingsImpl.java @@ -57,6 +57,9 @@ public class RunnerAndConfigurationSettingsImpl implements JDOMExternalizable, C protected static final String DUMMY_ELEMENT_NANE = "dummy"; @NonNls private static final String TEMPORARY_ATTRIBUTE = "temporary"; + @NonNls + private static final String EDIT_BEFORE_RUN = "editBeforeRun"; + /** for compatibility */ @NonNls @@ -73,6 +76,7 @@ public class RunnerAndConfigurationSettingsImpl implements JDOMExternalizable, C private List myUnloadedConfigurationPerRunnerSettings = null; private boolean myTemporary; + private boolean myEditBeforeRun; public RunnerAndConfigurationSettingsImpl(RunManagerImpl manager) { myManager = manager; @@ -122,6 +126,16 @@ public class RunnerAndConfigurationSettingsImpl implements JDOMExternalizable, C return myConfiguration.getName(); } + @Override + public void setEditBeforeRun(boolean b) { + myEditBeforeRun = b; + } + + @Override + public boolean isEditBeforeRun() { + return myEditBeforeRun; + } + @Nullable private ConfigurationFactory getFactory(final Element element) { final String typeName = element.getAttributeValue(CONFIGURATION_TYPE_ATTRIBUTE); @@ -130,9 +144,9 @@ public class RunnerAndConfigurationSettingsImpl implements JDOMExternalizable, C } public void readExternal(Element element) throws InvalidDataException { - myIsTemplate = Boolean.valueOf(element.getAttributeValue(TEMPLATE_FLAG_ATTRIBUTE)).booleanValue(); myTemporary = Boolean.valueOf(element.getAttributeValue(TEMPORARY_ATTRIBUTE)).booleanValue() || TEMP_CONFIGURATION.equals(element.getName()); + myEditBeforeRun = Boolean.valueOf(element.getAttributeValue(EDIT_BEFORE_RUN)).booleanValue(); final ConfigurationFactory factory = getFactory(element); if (factory == null) return; @@ -192,6 +206,8 @@ public class RunnerAndConfigurationSettingsImpl implements JDOMExternalizable, C } element.setAttribute(CONFIGURATION_TYPE_ATTRIBUTE, factory.getType().getId()); element.setAttribute(FACTORY_NAME_ATTRIBUTE, factory.getName()); + + if (isEditBeforeRun()) element.setAttribute(EDIT_BEFORE_RUN, String.valueOf(true)); if (myTemporary) { element.setAttribute(TEMPORARY_ATTRIBUTE, Boolean.toString(myTemporary)); } diff --git a/platform/platform-resources-en/src/messages/ExecutionBundle.properties b/platform/platform-resources-en/src/messages/ExecutionBundle.properties index 31c03b502121..cc8ae5dda7d5 100644 --- a/platform/platform-resources-en/src/messages/ExecutionBundle.properties +++ b/platform/platform-resources-en/src/messages/ExecutionBundle.properties @@ -301,3 +301,4 @@ export.test.results.open.browser=O&pen exported file in browser export.test.results.dialog.title=Export Test Results export.test.results.output.path.empty=Output path is empty export.test.results.output.filename.empty=Output file name is empty +configuration.edit.before.run=Show settings From d9c128e9bd75284f89f498de304148ad76bfd5fd Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Tue, 9 Nov 2010 18:03:18 +0300 Subject: [PATCH 12/45] IDEA-60591 (use correct yjpagent on 64-bit Linux in IDEA) --- bin/nix/idea.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 bin/nix/idea.sh diff --git a/bin/nix/idea.sh b/bin/nix/idea.sh old mode 100644 new mode 100755 index 941b392455aa..6b19f0819c4e --- a/bin/nix/idea.sh +++ b/bin/nix/idea.sh @@ -84,7 +84,7 @@ fi REQUIRED_JVM_ARGS="-Xbootclasspath/a:../lib/boot.jar $IDEA_PROPERTIES_PROPERTY $REQUIRED_JVM_ARGS" JVM_ARGS=`tr '\n' ' ' < "$IDEA_VM_OPTIONS"` -JVM_ARGS="$JVM_ARGS $REQUIRED_JVM_ARGS" +JVM_ARGS=`eval echo $JVM_ARGS $REQUIRED_JVM_ARGS` CLASSPATH=../lib/bootstrap.jar CLASSPATH=$CLASSPATH:../lib/util.jar From c6e8dece2de038fd7ef5fbc37f639414d42e7293 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Tue, 9 Nov 2010 18:23:20 +0300 Subject: [PATCH 13/45] Exit application startup scripts if no JDK was found (Unix) --- bin/nix/idea.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bin/nix/idea.sh b/bin/nix/idea.sh index 6b19f0819c4e..cf3b52de4e7e 100755 --- a/bin/nix/idea.sh +++ b/bin/nix/idea.sh @@ -26,7 +26,11 @@ if [ -z "$IDEA_JDK" ]; then fi if [ -z "$IDEA_JDK" ]; then echo ERROR: cannot start IntelliJ IDEA. - echo No JDK found to run IDEA. Please validate either IDEA_JDK or JDK_HOME points to valid JDK installation + echo No JDK found to run IDEA. Please validate either IDEA_JDK, JDK_HOME or JAVA_HOME points to valid JDK installation. + echo + echo Press Enter to continue. + read IGNORE + exit 1 fi fi @@ -36,7 +40,7 @@ grep 'OpenJDK' $VERSION_LOG OPEN_JDK=$? grep '64-Bit' $VERSION_LOG BITS=$? -rm /tmp/java.version.log +rm $VERSION_LOG if [ $OPEN_JDK -eq 0 ]; then echo WARNING: You are launching IDE using OpenJDK Java runtime echo From 626aa548ba6d48cd7fdeb77a1b63e46ac233caca Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Tue, 9 Nov 2010 19:06:08 +0300 Subject: [PATCH 14/45] count on Show Colors option on the start --- .../intellij/openapi/vcs/actions/AnnotationFieldGutter.java | 2 +- .../openapi/vcs/actions/ShowAnnotationColorsAction.java | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/AnnotationFieldGutter.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/AnnotationFieldGutter.java index 6f3f99d9e8b7..55a54738ec39 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/AnnotationFieldGutter.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/AnnotationFieldGutter.java @@ -47,7 +47,7 @@ class AnnotationFieldGutter implements ActiveAnnotationGutter { private final AnnotationListener myListener; private final boolean myIsGutterAction; private Map myColorScheme; - private boolean myShowBg = true; + private boolean myShowBg = ShowAnnotationColorsAction.isColorsEnabled(); private boolean myShowAdditionalInfo = false; AnnotationFieldGutter(FileAnnotation annotation, Editor editor, LineAnnotationAspect aspect, final TextAnnotationPresentation presentation, Map colorScheme) { diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/ShowAnnotationColorsAction.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/ShowAnnotationColorsAction.java index 5001368ac0f8..d222d9499e4f 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/ShowAnnotationColorsAction.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/ShowAnnotationColorsAction.java @@ -35,7 +35,7 @@ public class ShowAnnotationColorsAction extends ToggleAction { @Override public boolean isSelected(AnActionEvent e) { - return PropertiesComponent.getInstance().getBoolean(KEY, true); + return isColorsEnabled(); } @Override @@ -46,4 +46,8 @@ public class ShowAnnotationColorsAction extends ToggleAction { } myGutter.revalidateMarkup(); } + + public static boolean isColorsEnabled() { + return PropertiesComponent.getInstance().getBoolean(KEY, true); + } } From 3183bbbc81b9bb9e21d9fb8b9b43fa699d26f905 Mon Sep 17 00:00:00 2001 From: Denis Zhdanov Date: Tue, 9 Nov 2010 19:27:29 +0300 Subject: [PATCH 15/45] IDEA-60781 After formatting cursor jumps from indented position to beginning of the line. Caret location is restored according to its position before formatting instead of indent offset --- .../codeStyle/CodeStyleManagerImpl.java | 37 +++++-------------- 1 file changed, 9 insertions(+), 28 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeStyleManagerImpl.java b/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeStyleManagerImpl.java index 90c00162f75e..dcdc78135e83 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeStyleManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeStyleManagerImpl.java @@ -154,7 +154,8 @@ public class CodeStyleManagerImpl extends CodeStyleManager { // } // Formatter removes such white spaces, i.e. keeps only line feed symbol. But we want to preserve caret position then. // So, we check if it should be preserved and restore it after formatting if necessary - boolean fixCaretPosition = false; + int visualColumnToRestore = -1; + if (editor != null) { Document document = editor.getDocument(); int caretOffset = editor.getCaretModel().getOffset(); @@ -162,7 +163,7 @@ public class CodeStyleManagerImpl extends CodeStyleManager { CharSequence text = document.getCharsSequence(); int caretLine = document.getLineNumber(caretOffset); int lineStartOffset = document.getLineStartOffset(caretLine); - fixCaretPosition = true; + boolean fixCaretPosition = true; for (int i = caretOffset; i>= lineStartOffset; i--) { char c = text.charAt(i); if (c != ' ' && c != '\t' && c != '\n') { @@ -170,6 +171,9 @@ public class CodeStyleManagerImpl extends CodeStyleManager { break; } } + if (fixCaretPosition) { + visualColumnToRestore = editor.getCaretModel().getVisualPosition().column; + } } @@ -190,38 +194,15 @@ public class CodeStyleManagerImpl extends CodeStyleManager { formatToEnd ? file.getTextLength() : endElement.getTextRange().getEndOffset())); } - if (!fixCaretPosition) { + if (visualColumnToRestore < 0) { return; } CaretModel caretModel = editor.getCaretModel(); - String indent = getLineIndent(file, caretModel.getOffset()); - if (indent == null) { - return; - } - int tabSize = getSettings().getTabSize(file.getFileType()); - int indentColumn = indentInVisualColumns(indent, tabSize); VisualPosition position = caretModel.getVisualPosition(); - if (indentColumn != position.column) { - caretModel.moveToVisualPosition(new VisualPosition(position.line, indentColumn)); + if (visualColumnToRestore != position.column) { + caretModel.moveToVisualPosition(new VisualPosition(position.line, visualColumnToRestore)); } } - - private static int indentInVisualColumns(String indent, int tabSize) { - if (tabSize <= 1) { - return indent.length(); - } - int result = 0; - for (int i = 0; i < indent.length(); i++) { - char c = indent.charAt(i); - if (c == '\t') { - result += tabSize - result % tabSize; - } - else { - result++; - } - } - return result; - } private PsiElement reformatRangeImpl(final PsiElement element, final int startOffset, From 2fde612208228f5d25cde3e0ddc1f0f77a6cd66b Mon Sep 17 00:00:00 2001 From: "Rustam.Vishnyakov" Date: Tue, 9 Nov 2010 19:05:00 +0300 Subject: [PATCH 16/45] Add JavaScript files to the library from a specified directory, file type (source/compact) autodetection --- .../LangScriptingContextProvider.java | 5 ++- .../ui/EditLibraryDialog.form | 28 ++++++++----- .../ui/EditLibraryDialog.java | 42 +++++++++++++++---- 3 files changed, 55 insertions(+), 20 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/ide/scriptingContext/LangScriptingContextProvider.java b/platform/lang-impl/src/com/intellij/ide/scriptingContext/LangScriptingContextProvider.java index d7f7c9d9c4ff..957ea71c02ad 100644 --- a/platform/lang-impl/src/com/intellij/ide/scriptingContext/LangScriptingContextProvider.java +++ b/platform/lang-impl/src/com/intellij/ide/scriptingContext/LangScriptingContextProvider.java @@ -16,10 +16,9 @@ package com.intellij.ide.scriptingContext; import com.intellij.lang.Language; -import com.intellij.openapi.extensions.ExtensionPointName; -import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.libraries.LibraryType; +import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; /** @@ -36,4 +35,6 @@ public abstract class LangScriptingContextProvider { public abstract ScriptingLibraryMappings getLibraryMappings(Project project); + public abstract boolean isCompact(VirtualFile file); + } diff --git a/platform/lang-impl/src/com/intellij/ide/scriptingContext/ui/EditLibraryDialog.form b/platform/lang-impl/src/com/intellij/ide/scriptingContext/ui/EditLibraryDialog.form index c1186386820d..803ac485f05e 100644 --- a/platform/lang-impl/src/com/intellij/ide/scriptingContext/ui/EditLibraryDialog.form +++ b/platform/lang-impl/src/com/intellij/ide/scriptingContext/ui/EditLibraryDialog.form @@ -3,7 +3,7 @@ - + @@ -47,7 +47,7 @@ - + @@ -70,19 +70,27 @@ - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/platform/lang-impl/src/com/intellij/ide/scriptingContext/ui/EditLibraryDialog.java b/platform/lang-impl/src/com/intellij/ide/scriptingContext/ui/EditLibraryDialog.java index 018a01e4637d..f83dc4dfef9e 100644 --- a/platform/lang-impl/src/com/intellij/ide/scriptingContext/ui/EditLibraryDialog.java +++ b/platform/lang-impl/src/com/intellij/ide/scriptingContext/ui/EditLibraryDialog.java @@ -50,6 +50,7 @@ public class EditLibraryDialog extends DialogWrapper { private JButton myAddFileButton; private JButton myRemoveFileButton; private JBTable myFileTable; + private JButton myAttachFromButton; private Project myProject; private FileTableModel myFileTableModel; private VirtualFile mySelectedFile; @@ -65,6 +66,14 @@ public class EditLibraryDialog extends DialogWrapper { addFiles(); } }); + + myAttachFromButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + attachFromDirectory(); + } + }); + myFileTableModel = new FileTableModel(); myFileTable.setModel(myFileTableModel); @@ -135,14 +144,31 @@ public class EditLibraryDialog extends DialogWrapper { FileChooserDescriptor chooserDescriptor = new LibFileChooserDescriptor(); VirtualFile[] files = FileChooser.chooseFiles(myProject, chooserDescriptor); if (files.length == 1 && files[0] != null) { - myFileTableModel.addFile(files[0], false); + myFileTableModel.addFile(files[0]); + } + } + + private void attachFromDirectory() { + FileChooserDescriptor chooserDescriptor = new FileChooserDescriptor(false, true, false, false, false, false); + chooserDescriptor.setTitle("Select a directory to attach files from"); //TODO Move to resources + VirtualFile[] files = FileChooser.chooseFiles(myProject, chooserDescriptor); + if (files.length == 1 && files[0] != null) { + VirtualFile chosenDir = files[0]; + if (chosenDir.isDirectory() && chosenDir.isValid()) { + if (myLibName.getText().isEmpty()) myLibName.setText(chosenDir.getName()); + for (VirtualFile file : chosenDir.getChildren()) { + if (file.isValid() && !file.isDirectory() && myProvider.acceptsExtension(file.getExtension())) { + myFileTableModel.addFile(file); + } + } + } } } private class LibFileChooserDescriptor extends FileChooserDescriptor { public LibFileChooserDescriptor() { super (true, false, false, true, false, false); - setTitle("Select library file"); + setTitle("Select library file"); //TODO Move to resources } @Override @@ -158,14 +184,14 @@ public class EditLibraryDialog extends DialogWrapper { } } - private static class FileTableModel extends AbstractTableModel { + private class FileTableModel extends AbstractTableModel { @Override public String getColumnName(int column) { switch(column) { case FILE_LOCATION_COL: - return "Location"; - case FILE_TYPE_COL: + return "Location"; //TODO Move to resources + case FILE_TYPE_COL: //TODO Move to resources return "Type"; } return ""; @@ -182,9 +208,9 @@ public class EditLibraryDialog extends DialogWrapper { private ArrayList myFiles = new ArrayList(); private HashSet myCompactFiles = new HashSet(); - public void addFile(VirtualFile file, boolean isCompact) { + public void addFile(VirtualFile file) { myFiles.add(file); - if (isCompact) { + if (myProvider.isCompact(file)) { myCompactFiles.add(file); } fireTableDataChanged(); @@ -286,7 +312,7 @@ public class EditLibraryDialog extends DialogWrapper { @Override protected void doOKAction() { if (!isLibNameValid(myLibName.getText())) { - Messages.showErrorDialog(myProject, "Invalid library name", "Error"); + Messages.showErrorDialog(myProject, "Invalid library name", "Error"); //TODO Move to resources return; } super.doOKAction(); From 696f4dfd9b4e6c2ed5fd36558e52f30fba764d12 Mon Sep 17 00:00:00 2001 From: Eugene Kudelevsky Date: Tue, 9 Nov 2010 22:22:43 +0300 Subject: [PATCH 17/45] IDEA-25623 validate mandatory attributes in the layout definition --- .../android/dom/AndroidDomExtender.java | 111 +++++++++++++----- plugins/android/testData/dom/layout/hl.xml | 4 +- plugins/android/testData/dom/layout/idh.xml | 13 +- .../testData/dom/layout/layoutAttrs.xml | 10 ++ .../testData/dom/layout/primValues.xml | 7 +- .../android/testData/dom/layout/systemRes.xml | 11 +- plugins/android/testData/dom/layout/vcr1.xml | 3 +- .../android/dom/Android11LayoutDomTest.java | 2 +- .../android/dom/AndroidLayoutDomTest.java | 4 + 9 files changed, 118 insertions(+), 47 deletions(-) create mode 100644 plugins/android/testData/dom/layout/layoutAttrs.xml diff --git a/plugins/android/src/org/jetbrains/android/dom/AndroidDomExtender.java b/plugins/android/src/org/jetbrains/android/dom/AndroidDomExtender.java index 83b796d834c1..b59163d81938 100644 --- a/plugins/android/src/org/jetbrains/android/dom/AndroidDomExtender.java +++ b/plugins/android/src/org/jetbrains/android/dom/AndroidDomExtender.java @@ -25,10 +25,7 @@ import com.intellij.psi.xml.XmlAttribute; import com.intellij.psi.xml.XmlTag; import com.intellij.util.ArrayUtil; import com.intellij.util.Processor; -import com.intellij.util.xml.Converter; -import com.intellij.util.xml.DomElement; -import com.intellij.util.xml.GenericAttributeValue; -import com.intellij.util.xml.XmlName; +import com.intellij.util.xml.*; import com.intellij.util.xml.reflect.DomExtender; import com.intellij.util.xml.reflect.DomExtension; import com.intellij.util.xml.reflect.DomExtensionsRegistrar; @@ -60,6 +57,7 @@ import org.jetbrains.android.util.AndroidUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.lang.annotation.Annotation; import java.lang.reflect.Type; import java.util.*; @@ -93,6 +91,7 @@ public class AndroidDomExtender extends DomExtender { @NotNull StyleableDefinition[] styleables, @Nullable String namespace, DomExtensionsRegistrar registrar, + MyAttributeProcessor processor, String... skipNames) { Set skippedAttrSet = new HashSet(); Collections.addAll(skippedAttrSet, skipNames); @@ -107,7 +106,7 @@ public class AndroidDomExtender extends DomExtender { String attrName = attrDef.getName(); if (!skippedAttrSet.contains(attrName)) { skippedAttrSet.add(attrName); - registerAttribute(attrDef, namespace, registrar); + registerAttribute(attrDef, namespace, registrar, processor, element); } } } @@ -120,7 +119,15 @@ public class AndroidDomExtender extends DomExtender { return formats.size() > 1; } - private static void registerAttribute(@NotNull AttributeDefinition attrDef, String namespaceKey, DomExtensionsRegistrar registrar) { + private interface MyAttributeProcessor { + void process(@NotNull XmlName attrName, @NotNull DomExtension extension, @NotNull DomElement element); + } + + private static void registerAttribute(@NotNull AttributeDefinition attrDef, + String namespaceKey, + DomExtensionsRegistrar registrar, + @Nullable MyAttributeProcessor processor, + @NotNull DomElement element) { XmlName xmlName = new XmlName(attrDef.getName(), namespaceKey); Set formats = attrDef.getFormats(); Class valueClass = formats.size() == 1 ? getValueClass(formats.iterator().next()) : String.class; @@ -130,14 +137,18 @@ public class AndroidDomExtender extends DomExtender { if (converter != null) { extension.setConverter(converter, mustBeSoft(converter, attrDef.getFormats())); } + if (processor != null) { + processor.process(xmlName, extension, element); + } } protected static void registerAttributes(AndroidFacet facet, DomElement element, @NotNull String[] styleableNames, - DomExtensionsRegistrar registrar) { - registerAttributes(facet, element, styleableNames, null, registrar); - registerAttributes(facet, element, styleableNames, SYSTEM_RESOURCE_PACKAGE, registrar); + DomExtensionsRegistrar registrar, + MyAttributeProcessor processor) { + registerAttributes(facet, element, styleableNames, null, registrar, processor); + registerAttributes(facet, element, styleableNames, SYSTEM_RESOURCE_PACKAGE, registrar, processor); } private static StyleableDefinition[] getStyleables(@NotNull AttributeDefinitions definitions, @NotNull String[] names) { @@ -157,7 +168,7 @@ public class AndroidDomExtender extends DomExtender { @Nullable String resPackage, DomExtensionsRegistrar registrar, String... skipNames) { - registerAttributes(facet, element, new String[]{styleableName}, resPackage, registrar, skipNames); + registerAttributes(facet, element, new String[]{styleableName}, resPackage, registrar, null, skipNames); } protected static void registerAttributes(AndroidFacet facet, @@ -165,6 +176,7 @@ public class AndroidDomExtender extends DomExtender { @NotNull String[] styleableNames, @Nullable String resPackage, DomExtensionsRegistrar registrar, + MyAttributeProcessor processor, String... skipNames) { ResourceManager manager = facet.getResourceManager(resPackage); if (manager == null) return; @@ -172,7 +184,7 @@ public class AndroidDomExtender extends DomExtender { if (attrDefs == null) return; StyleableDefinition[] styleables = getStyleables(attrDefs, styleableNames); String namespace = getNamespaceKeyByResourcePackage(facet, resPackage); - registerStyleableAttributes(element, styleables, namespace, registrar, skipNames); + registerStyleableAttributes(element, styleables, namespace, registrar, processor, skipNames); } @NotNull @@ -195,11 +207,12 @@ public class AndroidDomExtender extends DomExtender { protected static void registerAttributesForClassAndSuperclasses(AndroidFacet facet, DomElement element, PsiClass c, - DomExtensionsRegistrar registrar) { + DomExtensionsRegistrar registrar, + MyAttributeProcessor processor) { while (c != null) { String styleableName = c.getName(); if (styleableName != null) { - registerAttributes(facet, element, new String[]{styleableName}, registrar); + registerAttributes(facet, element, new String[]{styleableName}, registrar, processor); } c = getSuperclass(c); } @@ -241,7 +254,7 @@ public class AndroidDomExtender extends DomExtender { PsiClass c = prefClassMap.get(prefClassName); // register attributes by preference class - registerAttributesForClassAndSuperclasses(facet, element, c, registrar); + registerAttributesForClassAndSuperclasses(facet, element, c, registrar, null); //register attributes by widget String suffix = "Preference"; @@ -249,7 +262,7 @@ public class AndroidDomExtender extends DomExtender { String widgetClassName = prefClassName.substring(0, prefClassName.length() - suffix.length()); Map viewClassMap = getViewClassMap(facet); PsiClass widgetClass = viewClassMap.get(widgetClassName); - registerAttributesForClassAndSuperclasses(facet, element, widgetClass, registrar); + registerAttributesForClassAndSuperclasses(facet, element, widgetClass, registrar, null); } if (c != null && isPreference(prefClassMap, c)) { @@ -277,7 +290,7 @@ public class AndroidDomExtender extends DomExtender { final String styleableName = AndroidAnimationUtils.getStyleableNameByTagName(tagName); PsiClass c = facet.findClass(AndroidUtils.ANIMATION_PACKAGE + '.' + styleableName); if (c != null) { - registerAttributesForClassAndSuperclasses(facet, element, c, registrar); + registerAttributesForClassAndSuperclasses(facet, element, c, registrar, null); } else { registerAttributes(facet, element, styleableName, SYSTEM_RESOURCE_PACKAGE, registrar); @@ -303,33 +316,70 @@ public class AndroidDomExtender extends DomExtender { return ArrayUtil.toStringArray(names); } - private static void registerLayoutAttributes(AndroidFacet facet, DomElement element, XmlTag tag, DomExtensionsRegistrar registrar) { + private static void registerLayoutAttributes(AndroidFacet facet, + DomElement element, + XmlTag tag, + DomExtensionsRegistrar registrar, + MyAttributeProcessor processor) { XmlTag parentTag = tag.getParentTag(); Map map = getViewClassMap(facet); if (parentTag != null) { PsiClass c = map.get(parentTag.getName()); while (c != null) { - registerLayoutAttributes(facet, element, c, registrar); + registerLayoutAttributes(facet, element, c, registrar, processor); c = getSuperclass(c); } } else { for (String className : map.keySet()) { PsiClass c = map.get(className); - registerLayoutAttributes(facet, element, c, registrar); + registerLayoutAttributes(facet, element, c, registrar, processor); } } } - private static void registerLayoutAttributes(AndroidFacet facet, DomElement element, PsiClass c, DomExtensionsRegistrar registrar) { + private static void registerLayoutAttributes(AndroidFacet facet, + DomElement element, + PsiClass c, + DomExtensionsRegistrar registrar, + MyAttributeProcessor processor) { String styleableName = c.getName(); if (styleableName != null) { for (String suf : LAYOUT_ATTRIBUTES_SUFS) { - registerAttributes(facet, element, new String[]{styleableName + suf}, registrar); + registerAttributes(facet, element, new String[]{styleableName + suf}, registrar, processor); } } } + private static final MyAttributeProcessor ourLayoutAttrsProcessor = new MyAttributeProcessor() { + @Override + public void process(@NotNull XmlName attrName, @NotNull DomExtension extension, @NotNull DomElement element) { + if (element instanceof LayoutViewElement && + SdkConstants.NS_RESOURCES.equals(attrName.getNamespaceKey()) && + ("layout_width".equals(attrName.getLocalName()) || "layout_height".equals(attrName.getLocalName()))) { + extension.addCustomAnnotation(new MyRequired()); + } + } + }; + + private static class MyRequired implements Required { + public boolean value() { + return true; + } + + public boolean nonEmpty() { + return true; + } + + public boolean identifier() { + return false; + } + + public Class annotationType() { + return Required.class; + } + } + public static void registerExtensionsForLayout(AndroidFacet facet, XmlTag tag, LayoutElement element, @@ -339,20 +389,20 @@ public class AndroidDomExtender extends DomExtender { if (element instanceof Include) { for (String className : map.keySet()) { PsiClass c = map.get(className); - registerLayoutAttributes(facet, element, c, registrar); + registerLayoutAttributes(facet, element, c, registrar, ourLayoutAttrsProcessor); } return; } String tagName = tag.getName(); if (!tagName.equals("view")) { PsiClass c = map.get(tagName); - registerAttributesForClassAndSuperclasses(facet, element, c, registrar); + registerAttributesForClassAndSuperclasses(facet, element, c, registrar, ourLayoutAttrsProcessor); } else { String[] styleableNames = getClassNames(map.values()); - registerAttributes(facet, element, styleableNames, registrar); + registerAttributes(facet, element, styleableNames, registrar, ourLayoutAttrsProcessor); } - registerLayoutAttributes(facet, element, tag, registrar); + registerLayoutAttributes(facet, element, tag, registrar, ourLayoutAttrsProcessor); for (String viewClassName : map.keySet()) { PsiClass viewClass = map.get(viewClassName); @@ -376,7 +426,7 @@ public class AndroidDomExtender extends DomExtender { if (attrDefs == null) return; StyleableDefinition styleable = attrDefs.getStyleableByName(styleableName); if (styleable == null) return; - registerStyleableAttributes(element, new StyleableDefinition[]{styleable}, SdkConstants.NS_RESOURCES, registrar, skipNames); + registerStyleableAttributes(element, new StyleableDefinition[]{styleable}, SdkConstants.NS_RESOURCES, registrar, null, skipNames); Set subtagSet = new HashSet(); Collections.addAll(subtagSet, AndroidManifestUtils.getStaticallyDefinedSubtags(element)); @@ -395,7 +445,7 @@ public class AndroidDomExtender extends DomExtender { AndroidFacet facet = AndroidFacet.getInstance(element); if (facet == null) return; XmlTag tag = element.getXmlTag(); - registerExistingAttributes(facet, tag, registrar); + registerExistingAttributes(facet, tag, registrar, element); String tagName = tag.getName(); Set registeredSubtags = new HashSet(); if (element instanceof ManifestElement) { @@ -449,7 +499,10 @@ public class AndroidDomExtender extends DomExtender { } } - private static void registerExistingAttributes(AndroidFacet facet, XmlTag tag, DomExtensionsRegistrar registrar) { + private static void registerExistingAttributes(AndroidFacet facet, + XmlTag tag, + DomExtensionsRegistrar registrar, + AndroidDomElement element) { XmlAttribute[] attrs = tag.getAttributes(); for (XmlAttribute attr : attrs) { String localName = attr.getLocalName(); @@ -460,7 +513,7 @@ public class AndroidDomExtender extends DomExtender { attrDef = new AttributeDefinition(localName); } String namespace = attr.getNamespace(); - registerAttribute(attrDef, namespace.length() > 0 ? namespace : null, registrar); + registerAttribute(attrDef, namespace.length() > 0 ? namespace : null, registrar, null, element); } } } diff --git a/plugins/android/testData/dom/layout/hl.xml b/plugins/android/testData/dom/layout/hl.xml index bd8e619920e4..eee46b437863 100644 --- a/plugins/android/testData/dom/layout/hl.xml +++ b/plugins/android/testData/dom/layout/hl.xml @@ -18,8 +18,8 @@ android:text="@string/animation_1_instructions" /> - - + + diff --git a/plugins/android/testData/dom/layout/idh.xml b/plugins/android/testData/dom/layout/idh.xml index 4883d1f0df7e..734c01197d87 100644 --- a/plugins/android/testData/dom/layout/idh.xml +++ b/plugins/android/testData/dom/layout/idh.xml @@ -1,7 +1,8 @@ - -