From d79ddf77c3d6b2a53aaba9dc65e74a57b070c763 Mon Sep 17 00:00:00 2001 From: Dmitry Batkovich Date: Thu, 27 Oct 2016 22:08:59 +0300 Subject: [PATCH 01/10] fix test according new functional expression presentation --- .../siyeh/ipp/interfacetoclass/ConvertInterfaceToClassTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/interfacetoclass/ConvertInterfaceToClassTest.java b/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/interfacetoclass/ConvertInterfaceToClassTest.java index b33a66c8fa4c..d6523d9a4a5f 100644 --- a/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/interfacetoclass/ConvertInterfaceToClassTest.java +++ b/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/interfacetoclass/ConvertInterfaceToClassTest.java @@ -31,7 +31,7 @@ public class ConvertInterfaceToClassTest extends IPPTestCase { fail("Conflict not detected"); } catch (BaseRefactoringProcessor.ConflictsInTestsException e) { - assertEquals("Functional expression in Test will not compile after converting class FunctionalExpressions to a class", e.getMessage()); + assertEquals("() -> {...} in Test will not compile after converting class FunctionalExpressions to a class", e.getMessage()); } } From 9c0f50daf7254b9a6bfbbbde6831a9b400c403db Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Thu, 27 Oct 2016 21:13:38 +0200 Subject: [PATCH 02/10] [platform] migrates breakgen build to CMake --- native/breakgen/CMakeLists.txt | 6 + native/breakgen/breakgen.sln | 24 -- native/breakgen/breakgen.vcproj | 337 ----------------------- native/breakgen/breakgen.vcxproj | 157 ----------- native/breakgen/breakgen.vcxproj.filters | 22 -- native/breakgen/build.cmd | 22 ++ 6 files changed, 28 insertions(+), 540 deletions(-) create mode 100644 native/breakgen/CMakeLists.txt delete mode 100644 native/breakgen/breakgen.sln delete mode 100644 native/breakgen/breakgen.vcproj delete mode 100644 native/breakgen/breakgen.vcxproj delete mode 100644 native/breakgen/breakgen.vcxproj.filters create mode 100644 native/breakgen/build.cmd diff --git a/native/breakgen/CMakeLists.txt b/native/breakgen/CMakeLists.txt new file mode 100644 index 000000000000..90aa8a836f09 --- /dev/null +++ b/native/breakgen/CMakeLists.txt @@ -0,0 +1,6 @@ +cmake_minimum_required(VERSION 3.1.0) +project(breakgen) + +include_directories($ENV{JAVA_HOME}/include $ENV{JAVA_HOME}/include/win32) + +add_library(breakgen SHARED AppMain.c) \ No newline at end of file diff --git a/native/breakgen/breakgen.sln b/native/breakgen/breakgen.sln deleted file mode 100644 index c95280945f2d..000000000000 --- a/native/breakgen/breakgen.sln +++ /dev/null @@ -1,24 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "breakgen", "breakgen.vcxproj", "{AE14C87F-E99B-4363-BE34-917FAF98258F}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {AE14C87F-E99B-4363-BE34-917FAF98258F}.Debug|Win32.ActiveCfg = Debug|Win32 - {AE14C87F-E99B-4363-BE34-917FAF98258F}.Debug|Win32.Build.0 = Debug|Win32 - {AE14C87F-E99B-4363-BE34-917FAF98258F}.Debug|x64.ActiveCfg = Debug|x64 - {AE14C87F-E99B-4363-BE34-917FAF98258F}.Release|Win32.ActiveCfg = Release|Win32 - {AE14C87F-E99B-4363-BE34-917FAF98258F}.Release|Win32.Build.0 = Release|Win32 - {AE14C87F-E99B-4363-BE34-917FAF98258F}.Release|x64.ActiveCfg = Release|x64 - {AE14C87F-E99B-4363-BE34-917FAF98258F}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/native/breakgen/breakgen.vcproj b/native/breakgen/breakgen.vcproj deleted file mode 100644 index 4f02b6ace509..000000000000 --- a/native/breakgen/breakgen.vcproj +++ /dev/null @@ -1,337 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/native/breakgen/breakgen.vcxproj b/native/breakgen/breakgen.vcxproj deleted file mode 100644 index 142d26a13fa0..000000000000 --- a/native/breakgen/breakgen.vcxproj +++ /dev/null @@ -1,157 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {AE14C87F-E99B-4363-BE34-917FAF98258F} - breakgen - Win32Proj - - - - DynamicLibrary - - - DynamicLibrary - - - DynamicLibrary - - - DynamicLibrary - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.40219.1 - Debug\ - true - ..\..\bin\win - true - $(Platform)\$(Configuration)\ - true - ..\..\bin\win - true - $(JdkPath)\include;$(IncludePath) - $(JdkPath)\include;$(IncludePath) - $(JdkPath)\include;$(IncludePath) - $(JdkPath)\include;$(IncludePath) - $(ProjectName)64 - - - - Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;BREAKGEN_EXPORTS;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - EditAndContinue - $(JdkPath)\include;$(JdkPath)\include\win32;%(AdditionalIncludeDirectories) - - - true - Windows - MachineX86 - - - - - $(JdkPath)\include;$(JdkPath)\include\win32;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;BREAKGEN_EXPORTS;%(PreprocessorDefinitions) - MultiThreaded - - - Level3 - ProgramDatabase - - - true - Windows - true - true - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;BREAKGEN_EXPORTS;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - ProgramDatabase - $(JdkPath)\include;$(JdkPath)\include\win32;%(AdditionalIncludeDirectories) - - - true - Windows - MachineX64 - - - - - X64 - - - $(JdkPath)\include;$(JdkPath)\include\win32;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;BREAKGEN_EXPORTS;%(PreprocessorDefinitions) - MultiThreaded - - - Level3 - ProgramDatabase - - - true - Windows - true - true - MachineX64 - - - - - - - - - \ No newline at end of file diff --git a/native/breakgen/breakgen.vcxproj.filters b/native/breakgen/breakgen.vcxproj.filters deleted file mode 100644 index 9c4507db840c..000000000000 --- a/native/breakgen/breakgen.vcxproj.filters +++ /dev/null @@ -1,22 +0,0 @@ - - - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - - - Source Files - - - \ No newline at end of file diff --git a/native/breakgen/build.cmd b/native/breakgen/build.cmd new file mode 100644 index 000000000000..d1a6a90b4e92 --- /dev/null +++ b/native/breakgen/build.cmd @@ -0,0 +1,22 @@ +SET CMAKE=%CMAKE_PATH%\bin\cmake + +RMDIR /S /Q build32 +MKDIR build32 +CD build32 +SET JAVA_HOME=%JDK_18% +"%CMAKE%" -G "Visual Studio 12 2013" -T v120_xp .. +IF ERRORLEVEL 1 EXIT 1 +"%CMAKE%" --build . --config Release +IF ERRORLEVEL 1 EXIT 2 +CD .. + +RMDIR /S /Q build64 +MKDIR build64 +CD build64 +SET JAVA_HOME=%JDK_18_x64% +"%CMAKE%" -G "Visual Studio 12 2013" -A x64 -T v120_xp .. +IF ERRORLEVEL 1 EXIT 3 +"%CMAKE%" --build . --config Release +IF ERRORLEVEL 1 EXIT 4 +RENAME Release\breakgen.dll breakgen64.dll +CD .. \ No newline at end of file From 3c24f6bdb36e5b176dee2194283fd33684a1c408 Mon Sep 17 00:00:00 2001 From: Dmitry Batkovich Date: Thu, 27 Oct 2016 22:54:17 +0300 Subject: [PATCH 03/10] javac ast indices: more find usages tests --- .../testCompileTimeConstFindUsages/Bar.java | 7 ++ .../testCompileTimeConstFindUsages/Foo.java | 5 ++ .../testLibClassInJavaDocUsage/Foo.java | 6 ++ .../testLibClassUsage/Foo.java | 7 ++ .../testLibMethodUsage/Foo.java | 9 +++ .../CompilerReferencesFindUsagesTest.java | 73 ++++++++++++++++--- 6 files changed, 98 insertions(+), 9 deletions(-) create mode 100644 java/java-tests/testData/compiler/compilerReferenceFindUsages/testCompileTimeConstFindUsages/Bar.java create mode 100644 java/java-tests/testData/compiler/compilerReferenceFindUsages/testCompileTimeConstFindUsages/Foo.java create mode 100644 java/java-tests/testData/compiler/compilerReferenceFindUsages/testLibClassInJavaDocUsage/Foo.java create mode 100644 java/java-tests/testData/compiler/compilerReferenceFindUsages/testLibClassUsage/Foo.java create mode 100644 java/java-tests/testData/compiler/compilerReferenceFindUsages/testLibMethodUsage/Foo.java diff --git a/java/java-tests/testData/compiler/compilerReferenceFindUsages/testCompileTimeConstFindUsages/Bar.java b/java/java-tests/testData/compiler/compilerReferenceFindUsages/testCompileTimeConstFindUsages/Bar.java new file mode 100644 index 000000000000..20b98c7a7843 --- /dev/null +++ b/java/java-tests/testData/compiler/compilerReferenceFindUsages/testCompileTimeConstFindUsages/Bar.java @@ -0,0 +1,7 @@ +class Bar { + + void m() { + System.out.println(Foo.CONST); + } + +} \ No newline at end of file diff --git a/java/java-tests/testData/compiler/compilerReferenceFindUsages/testCompileTimeConstFindUsages/Foo.java b/java/java-tests/testData/compiler/compilerReferenceFindUsages/testCompileTimeConstFindUsages/Foo.java new file mode 100644 index 000000000000..8c3531003e3b --- /dev/null +++ b/java/java-tests/testData/compiler/compilerReferenceFindUsages/testCompileTimeConstFindUsages/Foo.java @@ -0,0 +1,5 @@ +public class Foo { + + public static final String CONST = "value"; + +} \ No newline at end of file diff --git a/java/java-tests/testData/compiler/compilerReferenceFindUsages/testLibClassInJavaDocUsage/Foo.java b/java/java-tests/testData/compiler/compilerReferenceFindUsages/testLibClassInJavaDocUsage/Foo.java new file mode 100644 index 000000000000..5f97052cb35a --- /dev/null +++ b/java/java-tests/testData/compiler/compilerReferenceFindUsages/testLibClassInJavaDocUsage/Foo.java @@ -0,0 +1,6 @@ +/** + * {@link System} + */ +class Foo { + +} \ No newline at end of file diff --git a/java/java-tests/testData/compiler/compilerReferenceFindUsages/testLibClassUsage/Foo.java b/java/java-tests/testData/compiler/compilerReferenceFindUsages/testLibClassUsage/Foo.java new file mode 100644 index 000000000000..c9cec17836b8 --- /dev/null +++ b/java/java-tests/testData/compiler/compilerReferenceFindUsages/testLibClassUsage/Foo.java @@ -0,0 +1,7 @@ +class Foo { + + void m() { + System.out.println(""); + } + +} \ No newline at end of file diff --git a/java/java-tests/testData/compiler/compilerReferenceFindUsages/testLibMethodUsage/Foo.java b/java/java-tests/testData/compiler/compilerReferenceFindUsages/testLibMethodUsage/Foo.java new file mode 100644 index 000000000000..44aa2d59a7aa --- /dev/null +++ b/java/java-tests/testData/compiler/compilerReferenceFindUsages/testLibMethodUsage/Foo.java @@ -0,0 +1,9 @@ +import java.util.Collections; + +class Foo { + + void m() { + Collections.emptyList(); + } + +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/compiler/CompilerReferencesFindUsagesTest.java b/java/java-tests/testSrc/com/intellij/compiler/CompilerReferencesFindUsagesTest.java index 30f3e7a58df1..ca7a37ffd20a 100644 --- a/java/java-tests/testSrc/com/intellij/compiler/CompilerReferencesFindUsagesTest.java +++ b/java/java-tests/testSrc/com/intellij/compiler/CompilerReferencesFindUsagesTest.java @@ -16,26 +16,81 @@ package com.intellij.compiler; import com.intellij.JavaTestUtil; +import com.intellij.codeInsight.daemon.DaemonAnalyzerTestCase; import com.intellij.lang.injection.InjectedLanguageManager; -import com.intellij.psi.PsiClass; -import com.intellij.psi.PsiReference; +import com.intellij.psi.*; import com.intellij.psi.impl.source.tree.injected.MyTestInjector; -import com.intellij.psi.impl.source.tree.java.PsiReferenceExpressionImpl; +import com.intellij.psi.search.searches.MethodReferencesSearch; import com.intellij.psi.search.searches.ReferencesSearch; +import com.intellij.testFramework.CompilerTester; import com.intellij.testFramework.SkipSlowTestLocally; @SkipSlowTestLocally -public class CompilerReferencesFindUsagesTest extends CompilerReferencesTestBase { +public class CompilerReferencesFindUsagesTest extends DaemonAnalyzerTestCase { + //TODO merge tests + private boolean myDefaultEnableState; + private CompilerTester myCompilerTester; + + @Override + public void setUp() throws Exception { + myDefaultEnableState = CompilerReferenceService.IS_ENABLED_KEY.asBoolean(); + CompilerReferenceService.IS_ENABLED_KEY.setValue(true); + super.setUp(); + myCompilerTester = new CompilerTester(myModule); + } + + @Override + public void tearDown() throws Exception { + try { + CompilerReferenceService.IS_ENABLED_KEY.setValue(myDefaultEnableState); + myCompilerTester.tearDown(); + } + finally { + myCompilerTester = null; + super.tearDown(); + } + } + protected String getTestDataPath() { return JavaTestUtil.getJavaTestDataPath() + "/compiler/compilerReferenceFindUsages/"; } - public void testFindUsagesInInjectedCode() { + public void testLibMethodUsage() throws Exception { + configureByFile(getName() + "/Foo.java"); + myCompilerTester.rebuild(); + PsiMethod methodToSearch = myJavaFacade.findClass(CommonClassNames.JAVA_UTIL_COLLECTIONS).findMethodsByName("emptyList", false)[0]; + assertOneElement(MethodReferencesSearch.search(methodToSearch).findAll()); + } + + public void testLibClassUsage() throws Exception { + configureByFile(getName() + "/Foo.java"); + myCompilerTester.rebuild(); + PsiClass classForSearch = myJavaFacade.findClass("java.lang.System"); + assertOneElement(ReferencesSearch.search(classForSearch).findAll()); + } + + public void testLibClassInJavaDocUsage() throws Exception { + configureByFile(getName() + "/Foo.java"); + myCompilerTester.rebuild(); + PsiClass classForSearch = myJavaFacade.findClass("java.lang.System"); + assertOneElement(ReferencesSearch.search(classForSearch).findAll()); + } + + public void testCompileTimeConstFindUsages() throws Exception { + configureByFiles(getName(), getName() + "/Bar.java", getName() + "/Foo.java"); + PsiField classForSearch = findClass("Foo").findFieldByName("CONST", false); + PsiElement referenceBefore = assertOneElement(ReferencesSearch.search(classForSearch).findAll()).getElement(); + myCompilerTester.rebuild(); + PsiElement referenceAfter = assertOneElement(ReferencesSearch.search(classForSearch).findAll()).getElement(); + assertTrue(referenceBefore == referenceAfter); + } + + public void testFindUsagesInInjectedCode() throws Exception { new MyTestInjector(getPsiManager()).injectAll(getTestRootDisposable()); - myFixture.configureByFile(getName() + "/Foo.java"); - rebuildProject(); - PsiClass classForSearch = myFixture.getJavaFacade().findClass("java.lang.System"); + configureByFile(getName() + "/Foo.java"); + myCompilerTester.rebuild(); + PsiClass classForSearch = myJavaFacade.findClass("java.lang.System"); PsiReference reference = assertOneElement(ReferencesSearch.search(classForSearch).findAll()); - assertTrue(InjectedLanguageManager.getInstance(getProject()).isInjectedFragment(((PsiReferenceExpressionImpl)reference).getContainingFile())); + assertTrue(InjectedLanguageManager.getInstance(getProject()).isInjectedFragment(reference.getElement().getContainingFile())); } } From 7b6ccec41270383d73eb6ae6c961283fe8e11bb0 Mon Sep 17 00:00:00 2001 From: Dmitry Batkovich Date: Thu, 27 Oct 2016 23:06:37 +0300 Subject: [PATCH 04/10] javac ast indices: add diagnostic to detect NPE while hierarchy build process --- .../compiler/backwardRefs/CompilerReferenceReader.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/java/compiler/impl/src/com/intellij/compiler/backwardRefs/CompilerReferenceReader.java b/java/compiler/impl/src/com/intellij/compiler/backwardRefs/CompilerReferenceReader.java index 0f95ec8aed32..0accda716034 100644 --- a/java/compiler/impl/src/com/intellij/compiler/backwardRefs/CompilerReferenceReader.java +++ b/java/compiler/impl/src/com/intellij/compiler/backwardRefs/CompilerReferenceReader.java @@ -197,6 +197,12 @@ class CompilerReferenceReader { if (result.add(curClass)) { if (checkBaseClassAmbiguity || curClass != hierarchyElement) { final Collection definitionFiles = myIndex.getBackwardClassDefinitionMap().get(curClass); + if (definitionFiles == null) { + //diagnostic + String baseHierarchyElement = getNameEnumerator().getName(hierarchyElement.getName()); + String curHierarchyElement = getNameEnumerator().getName(curClass.getName()); + LOG.error("Can't get definition files for :" + curHierarchyElement + " base class: " + baseHierarchyElement); + } if (definitionFiles.size() != 1) { return null; } From ab1a604d97670dc10e0fde6419cc3e99c0afeb7b Mon Sep 17 00:00:00 2001 From: Sergey Ignatov Date: Fri, 28 Oct 2016 00:03:44 +0300 Subject: [PATCH 05/10] show usage popup: merge usages from the same line by default --- .../usageView/src/com/intellij/usages/UsageViewSettings.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/usageView/src/com/intellij/usages/UsageViewSettings.java b/platform/usageView/src/com/intellij/usages/UsageViewSettings.java index ccaf073792aa..280aa29d9e4f 100644 --- a/platform/usageView/src/com/intellij/usages/UsageViewSettings.java +++ b/platform/usageView/src/com/intellij/usages/UsageViewSettings.java @@ -38,7 +38,7 @@ public class UsageViewSettings implements PersistentStateComponent Date: Sun, 16 Oct 2016 22:56:27 +0300 Subject: [PATCH 06/10] [git] better error message for diagnosing EA-90019 --- plugins/git4idea/src/git4idea/history/GitHistoryUtils.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java b/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java index 80b2681391fa..c65399c8e185 100644 --- a/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java +++ b/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java @@ -522,7 +522,8 @@ public class GitHistoryUtils { catch (Throwable t) { if (parseError.isNull()) { parseError.set(t); - LOG.error("Could not parse \" " + builder.toString() + "\"", t); + LOG.error("Could not parse \" " + StringUtil.escapeStringCharacters(builder.toString()) + "\"\n" + + "Command " + handler.printableCommandLine(), t); } } }, 0); From 4a147effb9156a26020006ce66b6087a5d6793b2 Mon Sep 17 00:00:00 2001 From: Julia Beliaeva Date: Mon, 17 Oct 2016 01:58:27 +0300 Subject: [PATCH 07/10] [git] fix parsing commits with \u0001 symbol in commit message In order to separate a commit record, find "record end" symbol first. After this, find the beginning of the next record ("record start" symbol). This helps with commit messages containing "record start" (\u0001 used for that), since "record start" in the message is not treated now as a beginning of a new record. This fixes EA-90019. --- .../src/git4idea/history/GitHistoryUtils.java | 42 +++++++++++++++---- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java b/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java index c65399c8e185..118cc1d54aa8 100644 --- a/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java +++ b/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java @@ -538,23 +538,46 @@ public class GitHistoryUtils { int bufferSize) throws VcsException { final StringBuilder buffer = new StringBuilder(); + final Ref foundRecordEnd = Ref.create(false); final Ref ex = new Ref<>(); final AtomicInteger records = new AtomicInteger(); handler.addLineListener(new GitLineHandlerListener() { @Override public void onLineAvailable(String line, Key outputType) { try { + // format of the record is .*.* + // then next record goes + // (rather inconveniently, after RECORD_END there is a list of modified files) + // so here I'm trying to find text between two RECORD_START symbols + // that simultaneously contains a RECORD_END + // this helps to deal with commits like a929478f6720ac15d949117188cd6798b4a9c286 in linux repo that have RECORD_START symbols in the message + // wont help with RECORD_END symbols in the message however (have not seen those yet) + String tail = null; - int nextRecordStart = line.indexOf(GitLogParser.RECORD_START); - if (nextRecordStart == -1) { - buffer.append(line).append("\n"); + if (!foundRecordEnd.get()) { + int recordEnd = line.indexOf(GitLogParser.RECORD_END); + if (recordEnd != -1) { + foundRecordEnd.set(true); + buffer.append(line.substring(0, recordEnd + 1)); + line = line.substring(recordEnd + 1); + } + else { + buffer.append(line).append("\n"); + } } - else if (nextRecordStart == 0) { - tail = line + "\n"; - } - else { - buffer.append(line.substring(0, nextRecordStart)); - tail = line.substring(nextRecordStart) + "\n"; + + if (foundRecordEnd.get()) { + int nextRecordStart = line.indexOf(GitLogParser.RECORD_START); + if (nextRecordStart == -1) { + buffer.append(line).append("\n"); + } + else if (nextRecordStart == 0) { + tail = line + "\n"; + } + else { + buffer.append(line.substring(0, nextRecordStart)); + tail = line.substring(nextRecordStart) + "\n"; + } } if (tail != null) { @@ -563,6 +586,7 @@ public class GitHistoryUtils { buffer.setLength(0); } buffer.append(tail); + foundRecordEnd.set(false); } } catch (Exception e) { From fdebc0bef5668d37b030ba4997963b9bebd70411 Mon Sep 17 00:00:00 2001 From: Julia Beliaeva Date: Mon, 24 Oct 2016 04:28:37 +0300 Subject: [PATCH 08/10] [git] minor: reformat code --- .../git4idea/history/GitHistoryUtilsTest.java | 29 ++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/plugins/git4idea/tests/git4idea/history/GitHistoryUtilsTest.java b/plugins/git4idea/tests/git4idea/history/GitHistoryUtilsTest.java index d2f44686075c..5affccdc2d99 100644 --- a/plugins/git4idea/tests/git4idea/history/GitHistoryUtilsTest.java +++ b/plugins/git4idea/tests/git4idea/history/GitHistoryUtilsTest.java @@ -134,7 +134,8 @@ public class GitHistoryUtilsTest extends GitSingleRepoTest { String[] parents; if (details.length > 2) { parents = details[2].split(" "); - } else { + } + else { parents = ArrayUtil.EMPTY_STRING_ARRAY; } final GitTestRevision revision = new GitTestRevision(details[0], details[1], parents, commitMessages[i], @@ -290,14 +291,14 @@ public class GitHistoryUtilsTest extends GitSingleRepoTest { @Test public void testGetCurrentRevision() throws Exception { - GitRevisionNumber revisionNumber = (GitRevisionNumber) GitHistoryUtils.getCurrentRevision(myProject, toFilePath(bfile), null); + GitRevisionNumber revisionNumber = (GitRevisionNumber)GitHistoryUtils.getCurrentRevision(myProject, toFilePath(bfile), null); assertEquals(revisionNumber.getRev(), myRevisions.get(0).myHash); assertEquals(revisionNumber.getTimestamp(), myRevisions.get(0).myDate); } @Test public void testGetCurrentRevisionInMasterBranch() throws Exception { - GitRevisionNumber revisionNumber = (GitRevisionNumber) GitHistoryUtils.getCurrentRevision(myProject, toFilePath(bfile), "master"); + GitRevisionNumber revisionNumber = (GitRevisionNumber)GitHistoryUtils.getCurrentRevision(myProject, toFilePath(bfile), "master"); assertEquals(revisionNumber.getRev(), myRevisions.get(0).myHash); assertEquals(revisionNumber.getTimestamp(), myRevisions.get(0).myDate); } @@ -309,7 +310,7 @@ public class GitHistoryUtilsTest extends GitSingleRepoTest { addCommit("new content"); final String[] output = log("master --pretty=%H#%at", "-n1").trim().split("#"); - GitRevisionNumber revisionNumber = (GitRevisionNumber) GitHistoryUtils.getCurrentRevision(myProject, toFilePath(bfile), "master"); + GitRevisionNumber revisionNumber = (GitRevisionNumber)GitHistoryUtils.getCurrentRevision(myProject, toFilePath(bfile), "master"); assertEquals(revisionNumber.getRev(), output[0]); assertEquals(revisionNumber.getTimestamp(), GitTestRevision.gitTimeStampToDate(output[1])); } @@ -323,7 +324,7 @@ public class GitHistoryUtilsTest extends GitSingleRepoTest { public void testGetLastRevisionForExistingFile() throws Exception { final ItemLatestState state = GitHistoryUtils.getLastRevision(myProject, toFilePath(bfile)); assertTrue(state.isItemExists()); - final GitRevisionNumber revisionNumber = (GitRevisionNumber) state.getNumber(); + final GitRevisionNumber revisionNumber = (GitRevisionNumber)state.getNumber(); assertEquals(revisionNumber.getRev(), myRevisions.get(0).myHash); assertEquals(revisionNumber.getTimestamp(), myRevisions.get(0).myDate); } @@ -378,7 +379,7 @@ public class GitHistoryUtilsTest extends GitSingleRepoTest { @Test public void testOnlyHashesHistory() throws Exception { - final List> history = GitHistoryUtils.onlyHashesHistory(myProject, toFilePath(bfile), myProjectRoot); + final List> history = GitHistoryUtils.onlyHashesHistory(myProject, toFilePath(bfile), myProjectRoot); assertEquals(history.size(), myRevisionsAfterRename.size()); Iterator itAfterRename = myRevisionsAfterRename.iterator(); for (Pair pair : history) { @@ -391,7 +392,7 @@ public class GitHistoryUtilsTest extends GitSingleRepoTest { private void assertHistory(@NotNull List actualRevisions) throws IOException, VcsException { assertEquals("Incorrect number of commits in history", myRevisions.size(), actualRevisions.size()); for (int i = 0; i < actualRevisions.size(); i++) { - assertEqualRevisions((GitFileRevision) actualRevisions.get(i), myRevisions.get(i)); + assertEqualRevisions((GitFileRevision)actualRevisions.get(i), myRevisions.get(i)); } } @@ -424,7 +425,16 @@ public class GitHistoryUtilsTest extends GitSingleRepoTest { final byte[] myContent; private String[] myParents; - public GitTestRevision(String hash, String gitTimestamp, String[] parents, String commitMessage, String authorName, String authorEmail, String committerName, String committerEmail, String branch, String content) { + public GitTestRevision(String hash, + String gitTimestamp, + String[] parents, + String commitMessage, + String authorName, + String authorEmail, + String committerName, + String committerEmail, + String branch, + String content) { myHash = hash; myDate = gitTimeStampToDate(gitTimestamp); myParents = parents; @@ -443,8 +453,7 @@ public class GitHistoryUtilsTest extends GitSingleRepoTest { } public static Date gitTimeStampToDate(String gitTimestamp) { - return new Date(Long.parseLong(gitTimestamp)*1000); + return new Date(Long.parseLong(gitTimestamp) * 1000); } } - } From 7ea0e32bcc90a96f822e0f29a539bf16afc0e87e Mon Sep 17 00:00:00 2001 From: Julia Beliaeva Date: Mon, 24 Oct 2016 04:29:49 +0300 Subject: [PATCH 09/10] [git] add test for loading commits with body containing \u0001 character --- .../git4idea/history/GitHistoryUtilsTest.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/plugins/git4idea/tests/git4idea/history/GitHistoryUtilsTest.java b/plugins/git4idea/tests/git4idea/history/GitHistoryUtilsTest.java index 5affccdc2d99..fe9b0c1835a5 100644 --- a/plugins/git4idea/tests/git4idea/history/GitHistoryUtilsTest.java +++ b/plugins/git4idea/tests/git4idea/history/GitHistoryUtilsTest.java @@ -26,6 +26,8 @@ import com.intellij.util.ArrayUtil; import com.intellij.util.Consumer; import com.intellij.util.ExceptionUtil; import com.intellij.util.Function; +import com.intellij.util.containers.ContainerUtil; +import com.intellij.vcs.log.VcsFullCommitDetails; import com.intellij.vcsUtil.VcsUtil; import git4idea.GitFileRevision; import git4idea.GitRevisionNumber; @@ -389,6 +391,21 @@ public class GitHistoryUtilsTest extends GitSingleRepoTest { } } + @Test + public void testLoadingDetailsWithU0001Character() throws Exception { + List details = ContainerUtil.newArrayList(); + + String message = "subject containing \u0001 symbol in it\n\ncommit body containing \u0001 symbol in it"; + touch("file.txt", "content"); + addCommit(message); + + GitHistoryUtils.loadAllDetails(myProject, myRepo.getRoot(), details::add); + + VcsFullCommitDetails lastCommit = ContainerUtil.getFirstItem(details); + assertNotNull(lastCommit); + assertEquals(message, lastCommit.getFullMessage()); + } + private void assertHistory(@NotNull List actualRevisions) throws IOException, VcsException { assertEquals("Incorrect number of commits in history", myRevisions.size(), actualRevisions.size()); for (int i = 0; i < actualRevisions.size(); i++) { From 4ab220dd583f0ce182687378521e954ae4c7cab4 Mon Sep 17 00:00:00 2001 From: Julia Beliaeva Date: Thu, 27 Oct 2016 18:54:59 +0300 Subject: [PATCH 10/10] [vcs-log] minor: remove unused method --- .../intellij/vcs/log/ui/render/GraphCommitCellRenderer.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/GraphCommitCellRenderer.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/GraphCommitCellRenderer.java index cd7c3d61cd8f..a7ca1d6c1cc6 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/GraphCommitCellRenderer.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/GraphCommitCellRenderer.java @@ -310,11 +310,6 @@ public class GraphCommitCellRenderer extends TypeSafeTableCellRenderer