From 9803887eb7f404d0783b3f8b7a9254ba237cab1d Mon Sep 17 00:00:00 2001 From: Dmitry Batrak Date: Thu, 20 Aug 2015 15:46:32 +0300 Subject: [PATCH 1/5] IDEA-142975 Smart home action doesn't work on a folded method --- .../openapi/editor/actions/EditorActionUtil.java | 9 ++++++--- .../openapi/editor/actions/EditorActionTest.java | 8 ++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/actions/EditorActionUtil.java b/platform/platform-impl/src/com/intellij/openapi/editor/actions/EditorActionUtil.java index 1cce0b895469..1c0565c14b17 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/actions/EditorActionUtil.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/actions/EditorActionUtil.java @@ -369,10 +369,13 @@ public class EditorActionUtil { } else { int line = logLineEndVis.line; - if (currentVisCaret.column == 0 && editorSettings.isSmartHome()) { - findSmartIndentColumn(editor, line); - } int column = 0; + if (currentVisCaret.column > 0) { + int firstNonSpaceColumnOnTheLine = findFirstNonSpaceColumnOnTheLine(editor, currentVisCaret.line); + if (firstNonSpaceColumnOnTheLine < currentVisCaret.column) { + column = firstNonSpaceColumnOnTheLine; + } + } caretModel.moveToVisualPosition(new VisualPosition(line, column)); } } diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/editor/actions/EditorActionTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/editor/actions/EditorActionTest.java index 38110d6c95c9..5fa819a55615 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/editor/actions/EditorActionTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/editor/actions/EditorActionTest.java @@ -214,4 +214,12 @@ public class EditorActionTest extends AbstractEditorTest { executeAction(IdeActions.ACTION_EDITOR_DUPLICATE_LINES); checkResultByText("a\nb\nb\nc"); } + + public void testSmartHomeAfterFoldedRegion() throws IOException { + initText(" text with [multiline\nfold region]"); + foldOccurrences("(?s)\\[.*\\]", "..."); + myEditor.getSettings().setSmartHome(true); + home(); + checkResultByText(" text with [multiline\nfold region]"); + } } \ No newline at end of file From 402bfccf845725de39e4063622e55af1aa6f95c6 Mon Sep 17 00:00:00 2001 From: nik Date: Thu, 20 Aug 2015 16:00:34 +0300 Subject: [PATCH 2/5] added license description for spantable library --- build/scripts/libLicenses.gant | 1 + 1 file changed, 1 insertion(+) diff --git a/build/scripts/libLicenses.gant b/build/scripts/libLicenses.gant index a175d5ced874..721e00dab165 100644 --- a/build/scripts/libLicenses.gant +++ b/build/scripts/libLicenses.gant @@ -290,6 +290,7 @@ libraryLicense(name: "EditorConfig Java Core", libraryName: "editorconfig-core-j libraryLicense(name: "Fest", libraryName: "fest", version: "", license: "Apache 2.0", licenseUrl: "http://www.apache.org/licenses/LICENSE-2.0.txt", url: "https://code.google.com/p/fest/") libraryLicense(name: "Gherkin", libraryName: "Gherkin", version: "2.12.2", license: "MIT", licenseUrl: "http://www.apache.org/licenses/LICENSE-2.0.txt", url: "https://github.com/cucumber/gherkin") libraryLicense(name: "imgscalr", libraryName: "imgscalr", version: "4.2", license: "Apache 2.0", licenseUrl: "http://www.apache.org/licenses/LICENSE-2.0.txt", url: "https://github.com/thebuzzmedia/imgscalr") +libraryLicense(name: "Spantable", libraryName: "spantable.jar", version: "unknown", license: "LGPL 2.1", licenseUrl: "http://www.gnu.org/licenses/lgpl.html", url: "http://code.google.com/p/spantable/") libraryLicense(name: "JGit", libraryName: "jgit", version: "4.0", license: "Eclipse Distribution License 1.0", licenseUrl: "http://www.eclipse.org/org/documents/edl-v10.php", url: "https://eclipse.org/jgit/") libraryLicense(name: "JGit", libraryName: "jackson", version: "2.5.1", license: "Apache 2.0", licenseUrl: "http://www.eclipse.org/org/documents/edl-v10.php", url: "https://github.com/FasterXML/jackson") jetbrainsLibrary("Coverage") From b406f88a94ce901b61c55eb9f0c0468fbd0fdf26 Mon Sep 17 00:00:00 2001 From: Sergey Ignatov Date: Thu, 20 Aug 2015 16:01:44 +0300 Subject: [PATCH 3/5] unify change dialect action and quick fix, DBE-1097 [^savenko] --- .../ide/scratch/ScratchFileActions.java | 31 +++++++++---------- .../intellij/ide/scratch/ScratchRootType.java | 7 ++++- .../src/com/jetbrains/python/psi/PyUtil.java | 16 +++------- 3 files changed, 26 insertions(+), 28 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/ide/scratch/ScratchFileActions.java b/platform/lang-impl/src/com/intellij/ide/scratch/ScratchFileActions.java index ec98e32a11ee..d98e04219e8b 100644 --- a/platform/lang-impl/src/com/intellij/ide/scratch/ScratchFileActions.java +++ b/platform/lang-impl/src/com/intellij/ide/scratch/ScratchFileActions.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,7 +45,8 @@ import org.jetbrains.annotations.Nullable; import java.util.Set; -import static com.intellij.openapi.util.Conditions.*; +import static com.intellij.openapi.util.Conditions.not; +import static com.intellij.openapi.util.Conditions.notNull; /** * @author ignatov @@ -143,16 +144,6 @@ public class ScratchFileActions { return file.getLanguage(); } - @NotNull - private static Function ROOT_TYPE(final ScratchFileService service) { - return new Function() { - @Override - public RootType fun(VirtualFile virtualFile) { - return service.getRootType(virtualFile); - } - }; - } - @NotNull private static Function SCRATCH_LANG(final ScratchFileService service, final Project project) { return new Function() { @@ -167,6 +158,16 @@ public class ScratchFileActions { }; } + @NotNull + private static Condition isScratch() { + return new Condition() { + @Override + public boolean value(@NotNull VirtualFile file) { + return ScratchRootType.getInstance().isScratchFile(file); + } + }; + } + public static class LanguageAction extends DumbAwareAction { @Override public void update(AnActionEvent e) { @@ -178,7 +179,7 @@ public class ScratchFileActions { } ScratchFileService fileService = ScratchFileService.getInstance(); - Condition isScratch = compose(ROOT_TYPE(fileService), instanceOf(ScratchRootType.class)); + Condition isScratch = isScratch(); if (!files.filter(not(isScratch)).isEmpty()) { e.getPresentation().setEnabledAndVisible(false); return; @@ -194,12 +195,10 @@ public class ScratchFileActions { public void actionPerformed(AnActionEvent e) { Project project = e.getProject(); ScratchFileService fileService = ScratchFileService.getInstance(); - JBIterable files = JBIterable.of(e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY)). - filter(compose(ROOT_TYPE(fileService), instanceOf(ScratchRootType.class))); + JBIterable files = JBIterable.of(e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY)).filter(isScratch()); if (project == null || files.isEmpty()) return; PerFileMappings mapping = fileService.getScratchesMapping(); LRUPopupBuilder.forFileLanguages(project, files, mapping).showInBestPositionFor(e.getDataContext()); } } - } \ No newline at end of file diff --git a/platform/lang-impl/src/com/intellij/ide/scratch/ScratchRootType.java b/platform/lang-impl/src/com/intellij/ide/scratch/ScratchRootType.java index 634858a6c6da..39cd85a43264 100644 --- a/platform/lang-impl/src/com/intellij/ide/scratch/ScratchRootType.java +++ b/platform/lang-impl/src/com/intellij/ide/scratch/ScratchRootType.java @@ -37,7 +37,6 @@ import javax.swing.*; * @author gregsh */ public final class ScratchRootType extends RootType { - @NotNull public static ScratchRootType getInstance() { return findByClass(ScratchRootType.class); @@ -47,6 +46,12 @@ public final class ScratchRootType extends RootType { super("scratches", "Scratches"); } + public boolean isScratchFile(@Nullable VirtualFile file) { + if (file == null) return false; + ScratchFileService service = ScratchFileService.getInstance(); + return service != null && service.getRootType(file) == this; + } + @Override public Language substituteLanguage(@NotNull Project project, @NotNull VirtualFile file) { Language language = ScratchFileService.getInstance().getScratchesMapping().getMapping(file); diff --git a/python/src/com/jetbrains/python/psi/PyUtil.java b/python/src/com/jetbrains/python/psi/PyUtil.java index bb343fe2024b..03124d7410de 100644 --- a/python/src/com/jetbrains/python/psi/PyUtil.java +++ b/python/src/com/jetbrains/python/psi/PyUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,7 @@ import com.intellij.codeInsight.lookup.LookupElement; import com.intellij.codeInsight.lookup.LookupElementBuilder; import com.intellij.ide.fileTemplates.FileTemplate; import com.intellij.ide.fileTemplates.FileTemplateManager; -import com.intellij.ide.scratch.ScratchFileService; +import com.intellij.ide.scratch.ScratchRootType; import com.intellij.injected.editor.VirtualFileWindow; import com.intellij.lang.ASTFactory; import com.intellij.lang.ASTNode; @@ -933,11 +933,11 @@ public class PyUtil { /** * If directory is a PsiDirectory, that is also a valid Python package, return PsiFile that points to __init__.py, * if such file exists, or directory itself (i.e. namespace package). Otherwise, return {@code null}. - * Unlike {@link #turnDirIntoInit(com.intellij.psi.PsiElement)} this function handles namespace packages and + * Unlike {@link #turnDirIntoInit(PsiElement)} this function handles namespace packages and * accepts only PsiDirectories as target. * * @param directory directory to check - * @param anchor optional PSI element to determine language level as for {@link #isPackage(com.intellij.psi.PsiDirectory, com.intellij.psi.PsiElement)} + * @param anchor optional PSI element to determine language level as for {@link #isPackage(PsiDirectory, PsiElement)} * @return PsiFile or PsiDirectory, if target is a Python package and {@code null} null otherwise */ @Nullable @@ -1782,13 +1782,7 @@ public class PyUtil { } public static boolean isInScratchFile(@NotNull PsiElement element) { - final ScratchFileService service = ScratchFileService.getInstance(); - final PsiFile file = element.getContainingFile(); - if (file != null) { - final VirtualFile virtualFile = file.getVirtualFile(); - return service != null && virtualFile != null && service.getRootType(virtualFile) != null; - } - return false; + return ScratchRootType.getInstance().isScratchFile(element.getContainingFile().getVirtualFile()); } /** From fa9c41f4f15021307741c2e04bef247fa5161dc3 Mon Sep 17 00:00:00 2001 From: Sergey Ignatov Date: Thu, 20 Aug 2015 16:03:11 +0300 Subject: [PATCH 4/5] cleanup --- python/src/com/jetbrains/python/psi/PyUtil.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/python/src/com/jetbrains/python/psi/PyUtil.java b/python/src/com/jetbrains/python/psi/PyUtil.java index 03124d7410de..ef3f28350ef7 100644 --- a/python/src/com/jetbrains/python/psi/PyUtil.java +++ b/python/src/com/jetbrains/python/psi/PyUtil.java @@ -1688,7 +1688,7 @@ public class PyUtil { } /** - * Filters out {@link com.jetbrains.python.refactoring.classes.membersManager.PyMemberInfo} + * Filters out {@link PyMemberInfo} * that should not be displayed in this refactoring (like object) * * @param pyMemberInfos collection to sort @@ -1756,10 +1756,10 @@ public class PyUtil { /** * Checks that given class is the root of class hierarchy, i.e. it's either {@code object} or - * special {@link com.jetbrains.python.PyNames#FAKE_OLD_BASE} class for old-style classes. + * special {@link PyNames#FAKE_OLD_BASE} class for old-style classes. * * @param cls Python class to check - * @see com.jetbrains.python.psi.impl.PyBuiltinCache + * @see PyBuiltinCache * @see PyNames#FAKE_OLD_BASE */ public static boolean isObjectClass(@NotNull PyClass cls) { @@ -1769,11 +1769,11 @@ public class PyUtil { /** * Checks that given type is the root of type hierarchy, i.e. it's type of either {@code object} or special - * {@link com.jetbrains.python.PyNames#FAKE_OLD_BASE} class for old-style classes. + * {@link PyNames#FAKE_OLD_BASE} class for old-style classes. * * @param type Python class to check * @param anchor arbitrary PSI element to find appropriate SDK - * @see com.jetbrains.python.psi.impl.PyBuiltinCache + * @see PyBuiltinCache * @see PyNames#FAKE_OLD_BASE */ public static boolean isObjectType(@NotNull PyType type, @NotNull PsiElement anchor) { From 516ee5bad706123cf283e01313ba1d7051a098fb Mon Sep 17 00:00:00 2001 From: Dmitry Semeniouta Date: Thu, 20 Aug 2015 16:06:09 +0300 Subject: [PATCH 5/5] AC/C++: CPP-898 No Intellisense for large files, idea.max.intellisense.filesize ignored --- platform/util/resources/misc/registry.properties | 3 +++ 1 file changed, 3 insertions(+) diff --git a/platform/util/resources/misc/registry.properties b/platform/util/resources/misc/registry.properties index 69b3883c8861..8668ac87c6f0 100644 --- a/platform/util/resources/misc/registry.properties +++ b/platform/util/resources/misc/registry.properties @@ -608,6 +608,9 @@ cidr.cygwin.cmakePermissionsFix=true cidr.cygwin.cmakePermissionsFix.description=Update permissions for the bin/ folder inside the installed IDE so that the bundled CMake could run cidr.lldb.enableXcodeLLDB=false cidr.lldb.enableXcodeLLDB.description=Enable LLDB from Xcode +cidr.max.intellisense.filesize=512 +cidr.max.intellisense.filesize.description=Maximum size of C/C++ file (in kilobytes) IDE should provide code assistance for. + ide.win.frame.decoration=false ide.win.frame.decoration.description=Enables Frame and Dialog decorations for IntelliJ and Darcula LaFs on Windows darcula.fix.native.flickering=false