Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/org.eclipse.cdt.core.linux.aarch64/META-INF/MANIFEST.MF2
-rw-r--r--core/org.eclipse.cdt.core.linux.aarch64/pom.xml25
-rw-r--r--core/org.eclipse.cdt.core.linux.ppc64le/META-INF/MANIFEST.MF2
-rw-r--r--core/org.eclipse.cdt.core.linux.ppc64le/pom.xml25
-rw-r--r--core/org.eclipse.cdt.core.linux.x86_64/META-INF/MANIFEST.MF2
-rw-r--r--core/org.eclipse.cdt.core.linux.x86_64/pom.xml25
-rw-r--r--core/org.eclipse.cdt.core.linux/pom.xml12
-rw-r--r--core/org.eclipse.cdt.core.macosx/META-INF/MANIFEST.MF2
-rwxr-xr-xcore/org.eclipse.cdt.core.macosx/os/macosx/x86_64/libpty.jnilibbin9788 -> 9792 bytes
-rw-r--r--core/org.eclipse.cdt.core.macosx/pom.xml25
-rw-r--r--core/org.eclipse.cdt.core.native/META-INF/MANIFEST.MF2
-rw-r--r--core/org.eclipse.cdt.core.native/about.properties4
-rw-r--r--core/org.eclipse.cdt.core.native/native_src/Makefile13
-rw-r--r--core/org.eclipse.cdt.core.native/native_src/win/Win32ProcessEx.c65
-rw-r--r--core/org.eclipse.cdt.core.native/native_src/win/iostream.c33
-rw-r--r--core/org.eclipse.cdt.core.native/native_src/win/starter.c7
-rw-r--r--core/org.eclipse.cdt.core.native/native_src/win/util.c36
-rw-r--r--core/org.eclipse.cdt.core.native/native_src/win/util.h3
-rw-r--r--core/org.eclipse.cdt.core.native/pom.xml32
-rw-r--r--core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/spawner/Spawner.java5
-rw-r--r--core/org.eclipse.cdt.core.tests/.settings/.api_filters8
-rw-r--r--core/org.eclipse.cdt.core.tests/META-INF/MANIFEST.MF4
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/GCCErrorParserTests.java18
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scannerinfo/ExtendedScannerInfoSerializerDeserializerTest.java111
-rw-r--r--core/org.eclipse.cdt.core.tests/pom.xml12
-rw-r--r--core/org.eclipse.cdt.core.win32.x86_64/META-INF/MANIFEST.MF2
-rwxr-xr-xcore/org.eclipse.cdt.core.win32.x86_64/os/win32/x86_64/pty.dllbin1037897 -> 1039023 bytes
-rwxr-xr-xcore/org.eclipse.cdt.core.win32.x86_64/os/win32/x86_64/spawner.dllbin334839 -> 335938 bytes
-rwxr-xr-xcore/org.eclipse.cdt.core.win32.x86_64/os/win32/x86_64/starter.exebin402799 -> 402864 bytes
-rw-r--r--core/org.eclipse.cdt.core.win32.x86_64/pom.xml25
-rw-r--r--core/org.eclipse.cdt.core.win32/pom.xml12
-rw-r--r--core/org.eclipse.cdt.core/META-INF/MANIFEST.MF5
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ScannerInfo.java6
-rw-r--r--core/org.eclipse.cdt.core/plugin.properties1
-rw-r--r--core/org.eclipse.cdt.core/plugin.xml8
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java90
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/scannerinfo/ExtendedScannerInfoSerializer.java56
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/scannerinfo/IExtendedScannerInfoDeserializer.java62
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/scannerinfo/ShadowExtendedScannerInfo.java28
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/scannerinfo/ShadowIncludeExportPatterns.java26
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/scannerinfo/ShadowPattern.java31
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/VCErrorParser.java2
-rw-r--r--core/org.eclipse.cdt.ui.tests/pom.xml12
-rw-r--r--core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/codemanipulation/CdtTemplate.java72
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/codemanipulation/StubUtility.java20
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/AnnotationExpansionControl.java8
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/WizardNewFileFromTemplateCreationPage.java172
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractCPropertyTab.java27
-rw-r--r--core/pom.xml12
50 files changed, 979 insertions, 173 deletions
diff --git a/core/org.eclipse.cdt.core.linux.aarch64/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.core.linux.aarch64/META-INF/MANIFEST.MF
index 0a7de03a046..d09e011644e 100644
--- a/core/org.eclipse.cdt.core.linux.aarch64/META-INF/MANIFEST.MF
+++ b/core/org.eclipse.cdt.core.linux.aarch64/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %fragmentName.linux.aarch64
Bundle-SymbolicName: org.eclipse.cdt.core.linux.aarch64;singleton:=true
-Bundle-Version: 6.0.100.qualifier
+Bundle-Version: 6.0.200.qualifier
Bundle-Vendor: %providerName
Fragment-Host: org.eclipse.cdt.core.native;bundle-version="[6.0.0,7.0.0)"
Bundle-Localization: plugin
diff --git a/core/org.eclipse.cdt.core.linux.aarch64/pom.xml b/core/org.eclipse.cdt.core.linux.aarch64/pom.xml
index 70133138625..ff4ea053015 100644
--- a/core/org.eclipse.cdt.core.linux.aarch64/pom.xml
+++ b/core/org.eclipse.cdt.core.linux.aarch64/pom.xml
@@ -1,4 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2020, 2021 Contributors to the Eclipse Foundation
+
+ This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License 2.0
+ which accompanies this distribution, and is available at
+ https://www.eclipse.org/legal/epl-2.0/
+
+ SPDX-License-Identifier: EPL-2.0
+-->
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
@@ -7,11 +17,11 @@
<parent>
<groupId>org.eclipse.cdt</groupId>
<artifactId>cdt-parent</artifactId>
- <version>10.2.0-SNAPSHOT</version>
+ <version>10.3.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
- <version>6.0.100-SNAPSHOT</version>
+ <version>6.0.200-SNAPSHOT</version>
<artifactId>org.eclipse.cdt.core.linux.aarch64</artifactId>
<packaging>eclipse-plugin</packaging>
@@ -48,6 +58,17 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-packaging-plugin</artifactId>
+ <configuration>
+ <!-- When signing binaries, the result is not checked into repo, so the
+ jgit timestamp provider cannot be used. This has the side effect
+ that the version of this bundle needs to be incremented on each
+ CDT release. -->
+ <timestampProvider>default</timestampProvider>
+ </configuration>
+ </plugin>
</plugins>
</build>
</project>
diff --git a/core/org.eclipse.cdt.core.linux.ppc64le/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.core.linux.ppc64le/META-INF/MANIFEST.MF
index ae80f5f3d00..e110dd20940 100644
--- a/core/org.eclipse.cdt.core.linux.ppc64le/META-INF/MANIFEST.MF
+++ b/core/org.eclipse.cdt.core.linux.ppc64le/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@ Bundle-SymbolicName: org.eclipse.cdt.core.linux.ppc64le;singleton:=true
Bundle-ManifestVersion: 2
Bundle-Localization: plugin
Bundle-Name: %fragmentName.linux.ppc64le
-Bundle-Version: 6.0.100.qualifier
+Bundle-Version: 6.0.200.qualifier
Fragment-Host: org.eclipse.cdt.core.native;bundle-version="[6.0.0,7.0.0)"
Bundle-Vendor: %providerName
Eclipse-PlatformFilter: (&(osgi.os=linux)(osgi.arch=ppc64le))
diff --git a/core/org.eclipse.cdt.core.linux.ppc64le/pom.xml b/core/org.eclipse.cdt.core.linux.ppc64le/pom.xml
index 464ea044eaa..f8f8de0ae23 100644
--- a/core/org.eclipse.cdt.core.linux.ppc64le/pom.xml
+++ b/core/org.eclipse.cdt.core.linux.ppc64le/pom.xml
@@ -1,4 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2014, 2021 Contributors to the Eclipse Foundation
+
+ This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License 2.0
+ which accompanies this distribution, and is available at
+ https://www.eclipse.org/legal/epl-2.0/
+
+ SPDX-License-Identifier: EPL-2.0
+-->
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
@@ -7,11 +17,11 @@
<parent>
<groupId>org.eclipse.cdt</groupId>
<artifactId>cdt-parent</artifactId>
- <version>10.2.0-SNAPSHOT</version>
+ <version>10.3.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
- <version>6.0.100-SNAPSHOT</version>
+ <version>6.0.200-SNAPSHOT</version>
<artifactId>org.eclipse.cdt.core.linux.ppc64le</artifactId>
<packaging>eclipse-plugin</packaging>
@@ -48,6 +58,17 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-packaging-plugin</artifactId>
+ <configuration>
+ <!-- When signing binaries, the result is not checked into repo, so the
+ jgit timestamp provider cannot be used. This has the side effect
+ that the version of this bundle needs to be incremented on each
+ CDT release. -->
+ <timestampProvider>default</timestampProvider>
+ </configuration>
+ </plugin>
</plugins>
</build>
</project>
diff --git a/core/org.eclipse.cdt.core.linux.x86_64/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.core.linux.x86_64/META-INF/MANIFEST.MF
index 2a9b6739dd4..d52a8d49ac7 100644
--- a/core/org.eclipse.cdt.core.linux.x86_64/META-INF/MANIFEST.MF
+++ b/core/org.eclipse.cdt.core.linux.x86_64/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %fragmentName.linux.x86_64
Bundle-SymbolicName: org.eclipse.cdt.core.linux.x86_64;singleton:=true
-Bundle-Version: 6.0.100.qualifier
+Bundle-Version: 6.0.200.qualifier
Bundle-Vendor: %providerName
Fragment-Host: org.eclipse.cdt.core.native;bundle-version="[6.0.0,7.0.0)"
Bundle-Localization: plugin
diff --git a/core/org.eclipse.cdt.core.linux.x86_64/pom.xml b/core/org.eclipse.cdt.core.linux.x86_64/pom.xml
index 45a847412e4..37d7285985e 100644
--- a/core/org.eclipse.cdt.core.linux.x86_64/pom.xml
+++ b/core/org.eclipse.cdt.core.linux.x86_64/pom.xml
@@ -1,4 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2011, 2021 Contributors to the Eclipse Foundation
+
+ This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License 2.0
+ which accompanies this distribution, and is available at
+ https://www.eclipse.org/legal/epl-2.0/
+
+ SPDX-License-Identifier: EPL-2.0
+-->
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
@@ -7,11 +17,11 @@
<parent>
<groupId>org.eclipse.cdt</groupId>
<artifactId>cdt-parent</artifactId>
- <version>10.2.0-SNAPSHOT</version>
+ <version>10.3.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
- <version>6.0.100-SNAPSHOT</version>
+ <version>6.0.200-SNAPSHOT</version>
<artifactId>org.eclipse.cdt.core.linux.x86_64</artifactId>
<packaging>eclipse-plugin</packaging>
@@ -48,6 +58,17 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-packaging-plugin</artifactId>
+ <configuration>
+ <!-- When signing binaries, the result is not checked into repo, so the
+ jgit timestamp provider cannot be used. This has the side effect
+ that the version of this bundle needs to be incremented on each
+ CDT release. -->
+ <timestampProvider>default</timestampProvider>
+ </configuration>
+ </plugin>
</plugins>
</build>
</project>
diff --git a/core/org.eclipse.cdt.core.linux/pom.xml b/core/org.eclipse.cdt.core.linux/pom.xml
index 5cf872dd79e..d71fab63836 100644
--- a/core/org.eclipse.cdt.core.linux/pom.xml
+++ b/core/org.eclipse.cdt.core.linux/pom.xml
@@ -1,4 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2017, 2021 Contributors to the Eclipse Foundation
+
+ This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License 2.0
+ which accompanies this distribution, and is available at
+ https://www.eclipse.org/legal/epl-2.0/
+
+ SPDX-License-Identifier: EPL-2.0
+-->
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
@@ -7,7 +17,7 @@
<parent>
<groupId>org.eclipse.cdt</groupId>
<artifactId>cdt-parent</artifactId>
- <version>10.2.0-SNAPSHOT</version>
+ <version>10.3.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
diff --git a/core/org.eclipse.cdt.core.macosx/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.core.macosx/META-INF/MANIFEST.MF
index d1352062481..18e2058249d 100644
--- a/core/org.eclipse.cdt.core.macosx/META-INF/MANIFEST.MF
+++ b/core/org.eclipse.cdt.core.macosx/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %fragmentName.macosx
Bundle-SymbolicName: org.eclipse.cdt.core.macosx; singleton:=true
-Bundle-Version: 6.0.100.qualifier
+Bundle-Version: 6.0.200.qualifier
Bundle-Vendor: %providerName
Fragment-Host: org.eclipse.cdt.core.native;bundle-version="[6.0.0,7.0.0)"
Bundle-Localization: plugin
diff --git a/core/org.eclipse.cdt.core.macosx/os/macosx/x86_64/libpty.jnilib b/core/org.eclipse.cdt.core.macosx/os/macosx/x86_64/libpty.jnilib
index 0283c6b798d..a8203f2dd01 100755
--- a/core/org.eclipse.cdt.core.macosx/os/macosx/x86_64/libpty.jnilib
+++ b/core/org.eclipse.cdt.core.macosx/os/macosx/x86_64/libpty.jnilib
Binary files differ
diff --git a/core/org.eclipse.cdt.core.macosx/pom.xml b/core/org.eclipse.cdt.core.macosx/pom.xml
index 1b9aefa7e97..c9c3002726b 100644
--- a/core/org.eclipse.cdt.core.macosx/pom.xml
+++ b/core/org.eclipse.cdt.core.macosx/pom.xml
@@ -1,4 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2011, 2021 Contributors to the Eclipse Foundation
+
+ This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License 2.0
+ which accompanies this distribution, and is available at
+ https://www.eclipse.org/legal/epl-2.0/
+
+ SPDX-License-Identifier: EPL-2.0
+-->
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
@@ -7,11 +17,11 @@
<parent>
<groupId>org.eclipse.cdt</groupId>
<artifactId>cdt-parent</artifactId>
- <version>10.2.0-SNAPSHOT</version>
+ <version>10.3.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
- <version>6.0.100-SNAPSHOT</version>
+ <version>6.0.200-SNAPSHOT</version>
<artifactId>org.eclipse.cdt.core.macosx</artifactId>
<packaging>eclipse-plugin</packaging>
@@ -33,6 +43,17 @@
</environments>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-packaging-plugin</artifactId>
+ <configuration>
+ <!-- When signing binaries, the result is not checked into repo, so the
+ jgit timestamp provider cannot be used. This has the side effect
+ that the version of this bundle needs to be incremented on each
+ CDT release. -->
+ <timestampProvider>default</timestampProvider>
+ </configuration>
+ </plugin>
</plugins>
</build>
diff --git a/core/org.eclipse.cdt.core.native/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.core.native/META-INF/MANIFEST.MF
index 99abb67a88d..f5e9bc3a33e 100644
--- a/core/org.eclipse.cdt.core.native/META-INF/MANIFEST.MF
+++ b/core/org.eclipse.cdt.core.native/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.cdt.core.native;singleton:=true
-Bundle-Version: 6.1.100.qualifier
+Bundle-Version: 6.1.200.qualifier
Bundle-Activator: org.eclipse.cdt.internal.core.natives.CNativePlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
diff --git a/core/org.eclipse.cdt.core.native/about.properties b/core/org.eclipse.cdt.core.native/about.properties
index f5bd45e9b3d..4ae69567820 100644
--- a/core/org.eclipse.cdt.core.native/about.properties
+++ b/core/org.eclipse.cdt.core.native/about.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2014, 2020 Contributors to the Eclipse Foundation
+# Copyright (c) 2014, 2021 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
@@ -24,7 +24,7 @@ blurb=C/C++ Development Tooling Native Utilities\n\
Version: {featureVersion}\n\
Build id: {0}\n\
\n\
-Copyright (c) 2014, 2020 Contributors to the Eclipse Foundation
+Copyright (c) 2014, 2021 Contributors to the Eclipse Foundation
\n\
See the NOTICE file(s) distributed with this work for additional\n\
information regarding copyright ownership.\n\
diff --git a/core/org.eclipse.cdt.core.native/native_src/Makefile b/core/org.eclipse.cdt.core.native/native_src/Makefile
index 914324a201b..8ba1b06f230 100644
--- a/core/org.eclipse.cdt.core.native/native_src/Makefile
+++ b/core/org.eclipse.cdt.core.native/native_src/Makefile
@@ -66,6 +66,19 @@ clean :
rebuild: clean all
+MAC_TO_SIGN=$(OS_DIR_MACOS_X86_64)/libspawner.jnilib \
+ $(OS_DIR_MACOS_X86_64)/libpty.jnilib \
+ $(OS_DIR_MACOS_X86)/libspawner.jnilib \
+ $(OS_DIR_MACOS_X86)/libpty.jnilib
+WIN_TO_SIGN=$(OS_DIR_WIN32_X86_64)/starter.exe \
+ $(OS_DIR_WIN32_X86_64)/spawner.dll \
+ $(OS_DIR_WIN32_X86_64)/pty.dll
+production: $(MAC_TO_SIGN) $(WIN_TO_SIGN)
+ $(foreach tosign,$(MAC_TO_SIGN) $(WIN_TO_SIGN),mv $(tosign) $(tosign)-unsigned &&) true
+ $(foreach tosign,$(MAC_TO_SIGN),curl -o $(tosign) -F file=@$(tosign)-unsigned https://cbi.eclipse.org/macos/codesign/sign &&) true
+ $(foreach tosign,$(WIN_TO_SIGN),curl -o $(tosign) -F file=@$(tosign)-unsigned https://cbi.eclipse.org/authenticode/sign &&) true
+ $(foreach tosign,$(MAC_TO_SIGN) $(WIN_TO_SIGN),rm $(tosign)-unsigned &&) true
+
# Windows x86_64
# Windows DLLs have a build timestamp in them. This makes it impossible to have reproducible builds.
diff --git a/core/org.eclipse.cdt.core.native/native_src/win/Win32ProcessEx.c b/core/org.eclipse.cdt.core.native/native_src/win/Win32ProcessEx.c
index f0a8b732b7a..12c4baf3008 100644
--- a/core/org.eclipse.cdt.core.native/native_src/win/Win32ProcessEx.c
+++ b/core/org.eclipse.cdt.core.native/native_src/win/Win32ProcessEx.c
@@ -62,7 +62,7 @@ typedef struct _procInfo {
static int procCounter = 0; // Number of running processes
// This is a VM helper
-void ThrowByName(JNIEnv *env, const char *name, const char *msg);
+void ThrowByName(JNIEnv *env, const char *name, const wchar_t *msg);
// Creates _procInfo block for every launched process
pProcInfo_t createProcInfo();
@@ -213,7 +213,7 @@ static bool createCommandLine(JNIEnv *env, jobjectArray cmdarray, wchar_t **cmdL
} else {
// malloc failed, clean up and return
va_end(ap);
- ThrowByName(env, "java/io/IOException", "Not enough memory");
+ ThrowByName(env, "java/io/IOException", L"Not enough memory");
return false;
}
} while (size <= required);
@@ -229,7 +229,7 @@ static bool createCommandLine(JNIEnv *env, jobjectArray cmdarray, wchar_t **cmdL
required = nPos + len + 2; // 2 => space + \0
if (required > 32 * 1024) {
free(buffer);
- ThrowByName(env, "java/io/IOException", "Command line too long");
+ ThrowByName(env, "java/io/IOException", L"Command line too long");
return false;
}
@@ -248,7 +248,7 @@ static bool createCommandLine(JNIEnv *env, jobjectArray cmdarray, wchar_t **cmdL
} else {
// Failed to realloc memory
free(buffer);
- ThrowByName(env, "java/io/IOException", "Not enough memory");
+ ThrowByName(env, "java/io/IOException", L"Not enough memory");
return false;
}
}
@@ -270,7 +270,7 @@ static bool createCommandLine(JNIEnv *env, jobjectArray cmdarray, wchar_t **cmdL
(*env)->ReleaseStringChars(env, item, str);
} else {
free(buffer);
- ThrowByName(env, "java/io/IOException", "Command line contained null string");
+ ThrowByName(env, "java/io/IOException", L"Command line contained null string");
return false;
}
}
@@ -307,7 +307,7 @@ static bool createEnvironmentBlock(JNIEnv *env, jobjectArray envp, wchar_t **blo
} else {
free(buffer);
(*env)->ReleaseStringChars(env, item, str);
- ThrowByName(env, "java/io/IOException", "Not enough memory");
+ ThrowByName(env, "java/io/IOException", L"Not enough memory");
return false;
}
if (isTraceEnabled(CDT_TRACE_SPAWNER)) {
@@ -338,29 +338,29 @@ extern "C"
Java_org_eclipse_cdt_utils_spawner_Spawner_exec0(JNIEnv *env, jobject process, jobjectArray cmdarray,
jobjectArray envp, jstring dir, jobjectArray channels) {
if (!channels) {
- ThrowByName(env, "java/io/IOException", "Channels can't be null");
+ ThrowByName(env, "java/io/IOException", L"Channels can't be null");
return 0;
}
jclass channelClass = (*env)->FindClass(env, "org/eclipse/cdt/utils/spawner/Spawner$WinChannel");
if (!channelClass) {
- ThrowByName(env, "java/io/IOException", "Unable to find channel class");
+ ThrowByName(env, "java/io/IOException", L"Unable to find channel class");
return 0;
}
jmethodID channelConstructor = (*env)->GetMethodID(env, channelClass, "<init>", "(J)V");
if (!channelConstructor) {
- ThrowByName(env, "java/io/IOException", "Unable to find channel constructor");
+ ThrowByName(env, "java/io/IOException", L"Unable to find channel constructor");
return 0;
}
if ((HIBYTE(LOWORD(GetVersion()))) & 0x80) {
- ThrowByName(env, "java/io/IOException", "Does not support Windows 3.1/95/98/Me");
+ ThrowByName(env, "java/io/IOException", L"Does not support Windows 3.1/95/98/Me");
return 0;
}
if (!cmdarray) {
- ThrowByName(env, "java/lang/NullPointerException", "No command line specified");
+ ThrowByName(env, "java/lang/NullPointerException", L"No command line specified");
return 0;
}
@@ -376,14 +376,14 @@ extern "C"
!createStandardNamedPipe(&stdHandles[1], STD_OUTPUT_HANDLE, pid, nLocalCounter) ||
!createStandardNamedPipe(&stdHandles[2], STD_ERROR_HANDLE, pid, nLocalCounter)) {
CLOSE_HANDLES(stdHandles);
- ThrowByName(env, "java/io/IOException", "CreatePipe");
+ ThrowByName(env, "java/io/IOException", L"CreatePipe");
return 0;
}
pProcInfo_t pCurProcInfo = createProcInfo();
if (!pCurProcInfo) {
CLOSE_HANDLES(stdHandles);
- ThrowByName(env, "java/io/IOException", "Too many processes");
+ ThrowByName(env, "java/io/IOException", L"Too many processes");
return 0;
}
@@ -395,7 +395,7 @@ extern "C"
!createNamedEvent(&pCurProcInfo->eventCtrlc, FALSE, L"SACtrlc", pid, nLocalCounter)) {
cleanUpProcBlock(pCurProcInfo);
CLOSE_HANDLES(stdHandles);
- ThrowByName(env, "java/io/IOException", "Cannot create event");
+ ThrowByName(env, "java/io/IOException", L"Cannot create event");
return 0;
}
@@ -463,6 +463,8 @@ extern "C"
&si, /* (in) startup information */
&pi); /* (out) process information */
+ const DWORD error_CreateProcessW = GetLastError();
+
free(cwd);
free(envBlock);
free(cmdLine);
@@ -483,7 +485,7 @@ extern "C"
}
cleanUpProcBlock(pCurProcInfo);
CLOSE_HANDLES(stdHandles);
- ThrowByName(env, "java/io/IOException", "Launching failed");
+ ThrowByName(env, "java/io/IOException", L"Launching failed");
if (isTraceEnabled(CDT_TRACE_SPAWNER)) {
cdtTrace(L"Process failed\n");
}
@@ -508,14 +510,12 @@ extern "C"
}
LeaveCriticalSection(&cs);
} else { // Launching error
- char *lpMsgBuf;
+ wchar_t *lpMsgBuf;
CLOSE_HANDLES(stdHandles);
- FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
- (char *)&lpMsgBuf, 0, NULL);
+ lpMsgBuf = formatWinErrorCode(error_CreateProcessW);
ThrowByName(env, "java/io/IOException", lpMsgBuf);
// Free the buffer.
- LocalFree(lpMsgBuf);
+ free(lpMsgBuf);
cleanUpProcBlock(pCurProcInfo);
ret = -1;
}
@@ -580,6 +580,7 @@ extern "C"
cwd, /* change to the new current directory */
&si, /* (in) startup information */
&pi); /* (out) process information */
+ const DWORD error_CreateProcessW = GetLastError();
free(cwd);
free(cmdLine);
@@ -591,14 +592,10 @@ extern "C"
CloseHandle(pi.hProcess);
ret = (long)pi.dwProcessId; // hProcess;
} else { // error
- char *lpMsgBuf;
-
- FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL,
- GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
- (wchar_t *)&lpMsgBuf, 0, NULL);
+ wchar_t *lpMsgBuf = formatWinErrorCode(error_CreateProcessW);
ThrowByName(env, "java/io/IOException", lpMsgBuf);
// Free the buffer.
- LocalFree(lpMsgBuf);
+ free(lpMsgBuf);
ret = -1;
}
@@ -730,13 +727,23 @@ extern "C"
// Throws Java exception (will be trapped by VM).
// Arguments:
// [in] name - name of exception class
-// [in] message to assign thi event
+// [in] message to assign the event
/////////////////////////////////////////////////////////////////////////////////////
-void ThrowByName(JNIEnv *env, const char *name, const char *msg) {
+void ThrowByName(JNIEnv *env, const char *name, const wchar_t *msg) {
jclass cls = (*env)->FindClass(env, name);
if (cls) { /* Otherwise an exception has already been thrown */
- (*env)->ThrowNew(env, cls, msg);
+ size_t msgLen = wcslen(msg);
+ int nChars = WideCharToMultiByte(CP_UTF8, 0, msg, msgLen, NULL, 0, NULL, NULL);
+ if (nChars == 0) {
+ (*env)->ThrowNew(env, cls, "");
+ } else {
+ // ThrowNew expects message to be encoded in "modified UTF-8"
+ char *buf = (char *)calloc(nChars + 1, sizeof(char));
+ WideCharToMultiByte(CP_UTF8, 0, msg, msgLen, buf, nChars, NULL, NULL);
+ (*env)->ThrowNew(env, cls, buf);
+ free(buf);
+ }
}
/* It's a good practice to clean up the local references. */
diff --git a/core/org.eclipse.cdt.core.native/native_src/win/iostream.c b/core/org.eclipse.cdt.core.native/native_src/win/iostream.c
index dfcfb32efbf..64d63415774 100644
--- a/core/org.eclipse.cdt.core.native/native_src/win/iostream.c
+++ b/core/org.eclipse.cdt.core.native/native_src/win/iostream.c
@@ -25,25 +25,25 @@
#include <org_eclipse_cdt_utils_spawner_Spawner.h>
-void ThrowByName(JNIEnv *env, const char *name, const char *msg);
+void ThrowByName(JNIEnv *env, const char *name, const wchar_t *msg);
#define BUFF_SIZE (1024)
static HANDLE channelToHandle(JNIEnv *env, jobject channel) {
if (!channel) {
- ThrowByName(env, "java/io/IOException", "Invalid channel object");
+ ThrowByName(env, "java/io/IOException", L"Invalid channel object");
return NULL;
}
jclass cls = (*env)->GetObjectClass(env, channel);
if (!cls) {
- ThrowByName(env, "java/io/IOException", "Unable to get channel class");
+ ThrowByName(env, "java/io/IOException", L"Unable to get channel class");
return NULL;
}
jfieldID fid = (*env)->GetFieldID(env, cls, "handle", "J");
if (!fid) {
- ThrowByName(env, "java/io/IOException", "Unable to find handle");
+ ThrowByName(env, "java/io/IOException", L"Unable to find handle");
return NULL;
}
@@ -70,14 +70,10 @@ extern "C"
NULL); // unnamed event object
if (!overlapped.hEvent) {
- char *lpMsgBuf;
- FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL,
- GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
- (wchar_t *)&lpMsgBuf, 0, NULL);
-
+ wchar_t *lpMsgBuf = formatWinErrorCode(GetLastError());
ThrowByName(env, "java/io/IOException", lpMsgBuf);
// Free the buffer.
- LocalFree(lpMsgBuf);
+ free(lpMsgBuf);
}
if (isTraceEnabled(CDT_TRACE_SPAWNER) && isTraceEnabled(CDT_TRACE_SPAWNER_READ_REPORT)) {
@@ -103,19 +99,14 @@ extern "C"
break;
}
if (err != 0) {
- char *lpMsgBuf;
if (isTraceEnabled(CDT_TRACE_SPAWNER)) {
cdtTrace(L"Read failed - %p, error %i\n", handle, err);
}
if (err !=
ERROR_MORE_DATA) { // Otherwise error means just that there are more data than buffer can accept
- FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
- (wchar_t *)&lpMsgBuf, 0, NULL);
-
+ wchar_t *lpMsgBuf = formatWinErrorCode(err);
ThrowByName(env, "java/io/IOException", lpMsgBuf);
- LocalFree(lpMsgBuf);
+ free(lpMsgBuf);
nBuffOffset = 0;
break;
} else {
@@ -200,13 +191,9 @@ extern "C"
DWORD nNumberOfBytesWritten;
(*env)->GetByteArrayRegion(env, buf, nBuffOffset, nNumberOfBytesToWrite, tmpBuf);
if (0 == WriteFile(handle, tmpBuf, nNumberOfBytesToWrite, &nNumberOfBytesWritten, NULL)) {
- char *lpMsgBuf;
- FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
- (wchar_t *)&lpMsgBuf, 0, NULL);
-
+ wchar_t *lpMsgBuf = formatWinErrorCode(GetLastError());
ThrowByName(env, "java/io/IOException", lpMsgBuf);
- LocalFree(lpMsgBuf);
+ free(lpMsgBuf);
return 0;
}
nBuffOffset += nNumberOfBytesWritten;
diff --git a/core/org.eclipse.cdt.core.native/native_src/win/starter.c b/core/org.eclipse.cdt.core.native/native_src/win/starter.c
index 85e58f93f50..0e20b9257d4 100644
--- a/core/org.eclipse.cdt.core.native/native_src/win/starter.c
+++ b/core/org.eclipse.cdt.core.native/native_src/win/starter.c
@@ -479,12 +479,9 @@ int main() {
}
void DisplayErrorMessage() {
- wchar_t *lpMsgBuf;
- FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL,
- GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
- (wchar_t *)&lpMsgBuf, 0, NULL);
+ wchar_t *lpMsgBuf = formatWinErrorCode(GetLastError());
OutputDebugStringW(lpMsgBuf);
// Free the buffer.
- LocalFree(lpMsgBuf);
+ free(lpMsgBuf);
}
//////////////////////////////// End of File //////////////////////////////////
diff --git a/core/org.eclipse.cdt.core.native/native_src/win/util.c b/core/org.eclipse.cdt.core.native/native_src/win/util.c
index 01b1c35521a..13041c39be6 100644
--- a/core/org.eclipse.cdt.core.native/native_src/win/util.c
+++ b/core/org.eclipse.cdt.core.native/native_src/win/util.c
@@ -151,3 +151,39 @@ int copyTo(wchar_t *target, const wchar_t *source, int cpyLength, int availSpace
return j;
}
+
+wchar_t *formatWinErrorCode(DWORD messageId) {
+ const wchar_t *NULL_STR = L"(null)";
+ size_t size = 0;
+ wchar_t *msg = NULL;
+
+ DWORD langId[] = {
+ MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), // US English
+ MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT), // Any English
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // User default language
+ 0 // Let FormatMessage lookup the right language
+ };
+ wchar_t *winBuf = NULL;
+
+ /* Format the message */
+ for (size_t i = 0; i < sizeof(langId) / sizeof(langId[0]); i++) {
+ if (FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL, messageId, langId[i], (wchar_t *)&winBuf, 0, NULL) == 0) {
+ winBuf = NULL;
+ }
+
+ if (winBuf != NULL) {
+ break;
+ }
+ }
+
+ /* Prefix the message */
+ size = 100 + wcslen(winBuf ? winBuf : NULL_STR);
+ msg = (wchar_t *)calloc(size + 1, sizeof(wchar_t));
+ if (msg) {
+ snwprintf(msg, size, L"Code 0x%lx: %s", (unsigned long)messageId, (winBuf ? winBuf : NULL_STR));
+ }
+
+ LocalFree(winBuf);
+ return msg;
+}
diff --git a/core/org.eclipse.cdt.core.native/native_src/win/util.h b/core/org.eclipse.cdt.core.native/native_src/win/util.h
index 89b0604671b..1fa1ffd4ffb 100644
--- a/core/org.eclipse.cdt.core.native/native_src/win/util.h
+++ b/core/org.eclipse.cdt.core.native/native_src/win/util.h
@@ -48,4 +48,7 @@ void cdtTrace(const wchar_t *fmt, ...);
int copyTo(wchar_t *target, const wchar_t *source, int cpyLength, int availSpace);
+// Returned pointer shall be freed with free().
+wchar_t *formatWinErrorCode(DWORD messageId);
+
#endif /* UTIL_H */
diff --git a/core/org.eclipse.cdt.core.native/pom.xml b/core/org.eclipse.cdt.core.native/pom.xml
index f0a212fe5ec..16d05a8d4f6 100644
--- a/core/org.eclipse.cdt.core.native/pom.xml
+++ b/core/org.eclipse.cdt.core.native/pom.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
- Copyright (c) 2018 Red Hat, Inc. and others.
+ Copyright (c) 2014, 2021 Red Hat, Inc. and others.
This program and the accompanying materials
are made available under the terms of the Eclipse Public License 2.0
which accompanies this distribution, and is available at
@@ -19,11 +19,11 @@
<parent>
<groupId>org.eclipse.cdt</groupId>
<artifactId>cdt-parent</artifactId>
- <version>10.2.0-SNAPSHOT</version>
+ <version>10.3.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
- <version>6.1.100-SNAPSHOT</version>
+ <version>6.1.200-SNAPSHOT</version>
<artifactId>org.eclipse.cdt.core.native</artifactId>
<packaging>eclipse-plugin</packaging>
@@ -133,5 +133,31 @@
</plugins>
</build>
</profile>
+ <profile>
+ <id>production</id>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>natives</id>
+ <phase>process-resources</phase>
+ <configuration>
+ <target>
+ <exec executable="make" newenvironment="false" failOnError="true" dir="./native_src">
+ <arg value="production" />
+ </exec>
+ </target>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
</profiles>
</project>
diff --git a/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/spawner/Spawner.java b/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/spawner/Spawner.java
index 27329bb630c..0f49b5eea67 100644
--- a/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/spawner/Spawner.java
+++ b/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/spawner/Spawner.java
@@ -286,6 +286,11 @@ public class Spawner extends Process {
}
}
+ @Override
+ public long pid() {
+ return pid;
+ }
+
/**
* On Windows, interrupt the spawned program by using Cygwin's utility 'kill -SIGINT' if it's a Cgywin
* program, otherwise send it a CTRL-C. If Cygwin's 'kill' command is not available, send a CTRL-C. On
diff --git a/core/org.eclipse.cdt.core.tests/.settings/.api_filters b/core/org.eclipse.cdt.core.tests/.settings/.api_filters
index cc8fdc94773..3015faeefa9 100644
--- a/core/org.eclipse.cdt.core.tests/.settings/.api_filters
+++ b/core/org.eclipse.cdt.core.tests/.settings/.api_filters
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<component id="org.eclipse.cdt.core.tests" version="2">
- <resource path="suite/org/eclipse/cdt/core/testplugin/util/BaseTestCase5.java" type="org.eclipse.cdt.core.testplugin.util.BaseTestCase5$ModelJoiner">
+ <resource path="parser/org/eclipse/cdt/core/parser/tests/scannerinfo/ExtendedScannerInfoSerializerDeserializerTest.java" type="org.eclipse.cdt.core.parser.tests.scannerinfo.ExtendedScannerInfoSerializerDeserializerTest">
<filter comment="This is ok - there is just no way of marking @noreference as having friends." id="640712815">
<message_arguments>
- <message_argument value="CCorePlugin"/>
- <message_argument value="ModelJoiner"/>
- <message_argument value="createStatus(String, Throwable)"/>
+ <message_argument value="ExtendedScannerInfo"/>
+ <message_argument value="ExtendedScannerInfoSerializerDeserializerTest"/>
+ <message_argument value="getIncludeExportPatterns()"/>
</message_arguments>
</filter>
</resource>
diff --git a/core/org.eclipse.cdt.core.tests/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.core.tests/META-INF/MANIFEST.MF
index 3d3b4e2e0b7..d67e449333a 100644
--- a/core/org.eclipse.cdt.core.tests/META-INF/MANIFEST.MF
+++ b/core/org.eclipse.cdt.core.tests/META-INF/MANIFEST.MF
@@ -22,6 +22,7 @@ Export-Package: org.eclipse.cdt.core.cdescriptor.tests,
org.eclipse.cdt.core.parser.tests.rewrite.changegenerator,
org.eclipse.cdt.core.parser.tests.rewrite.comenthandler,
org.eclipse.cdt.core.parser.tests.scanner,
+ org.eclipse.cdt.core.parser.tests.scannerinfo,
org.eclipse.cdt.core.resources.tests,
org.eclipse.cdt.core.settings.model,
org.eclipse.cdt.core.suite,
@@ -42,7 +43,8 @@ Require-Bundle: org.eclipse.core.resources,
org.eclipse.jface.text,
org.eclipse.core.filesystem,
org.eclipse.ltk.core.refactoring;bundle-version="3.4.0",
- org.hamcrest
+ org.hamcrest,
+ com.google.gson;bundle-version="[2.8.6,3.0.0)"
Bundle-ActivationPolicy: lazy
Bundle-Vendor: %providerName
Bundle-RequiredExecutionEnvironment: JavaSE-11
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/GCCErrorParserTests.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/GCCErrorParserTests.java
index 6e581d5c43a..e18f30268f7 100644
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/GCCErrorParserTests.java
+++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/GCCErrorParserTests.java
@@ -218,4 +218,22 @@ public class GCCErrorParserTests extends GenericErrorParserTests {
"required from here", "conversion from 'long int' to 'float' may change value [-Wconversion]" },
new String[] { GCC_ERROR_PARSER_ID });
}
+
+ public void testGccErrorMessages_InConstexprExpansion() throws IOException {
+ runParserTest(
+ new String[] { "../can/CANBus.h: In instantiation of 'constexpr void Test::setupBitrate(T)':",
+ "../can/CANBus.h:113:6: required from 'static auto& Test::getInstance()'",
+ "../can/CAN.cpp:19:27: required from here",
+ "../can/CANBus.h:72:17: in 'constexpr' expansion of 'instance.Test::Test()'",
+ "../can/CANBus.h:173:92: warning: unused parameter 'bitrate' [-Wunused-parameter]",
+ " 173 | constexpr void setupBitrate(T bitrate) noexcept {" },
+ 0, // errors
+ 1, //warnings
+ 3, //infos
+ new String[] { "CAN.cpp", "CANBus.h" },
+ new String[] { "required from 'static auto& Test::getInstance()'", "required from here",
+ "in 'constexpr' expansion of 'instance.Test::Test()'",
+ "unused parameter 'bitrate' [-Wunused-parameter]" },
+ new String[] { GCC_ERROR_PARSER_ID });
+ }
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scannerinfo/ExtendedScannerInfoSerializerDeserializerTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scannerinfo/ExtendedScannerInfoSerializerDeserializerTest.java
new file mode 100644
index 00000000000..9c000a612e3
--- /dev/null
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scannerinfo/ExtendedScannerInfoSerializerDeserializerTest.java
@@ -0,0 +1,111 @@
+/*******************************************************************************
+ * Copyright (c) 2021 Kichwa Coders Canada Inc. and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *******************************************************************************/
+
+package org.eclipse.cdt.core.parser.tests.scannerinfo;
+
+import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+import java.util.Map;
+
+import org.eclipse.cdt.core.parser.ExtendedScannerInfo;
+import org.eclipse.cdt.core.parser.IExtendedScannerInfo;
+import org.eclipse.cdt.internal.core.scannerinfo.ExtendedScannerInfoSerializer;
+import org.eclipse.cdt.internal.core.scannerinfo.IExtendedScannerInfoDeserializer;
+import org.junit.jupiter.api.Test;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+
+public class ExtendedScannerInfoSerializerDeserializerTest {
+
+ private static class Container {
+ IExtendedScannerInfo info;
+ }
+
+ private Gson createGson() {
+ GsonBuilder gsonBuilder = new GsonBuilder();
+ gsonBuilder.registerTypeAdapter(IExtendedScannerInfo.class, new IExtendedScannerInfoDeserializer());
+ gsonBuilder.registerTypeAdapter(ExtendedScannerInfo.class, new ExtendedScannerInfoSerializer());
+ Gson gson = gsonBuilder.create();
+ return gson;
+ }
+
+ @Test
+ public void test() {
+ String input = "" //
+ + "{" //
+ + "\"info\": {\n" //
+ + " \"includeExportPatterns\": {\n" //
+ + " \"includeExportPattern\": {\n" //
+ + " \"pattern\": \"pattern1\"\n" //
+ + " },\n" //
+ + " \"includeBeginExportPattern\": {\n" //
+ + " \"pattern\": \"pattern2\"\n" //
+ + " },\n" //
+ + " \"includeEndExportPattern\": {\n" //
+ + " \"pattern\": \"pattern3\"\n" //
+ + " }\n" //
+ + " },\n" //
+ + " \"definedSymbols\": {\n" //
+ + " \"__STDC__\": \"1\",\n" //
+ + " \"__INT64_MAX__\": \"0x7fffffffffffffffL\"\n" //
+ + " },\n" //
+ + " \"includePaths\": [\n" //
+ + " \"/usr/local/include\",\n" //
+ + " \"/usr/include\"\n" //
+ + " ]\n" //
+ + "}" //
+ + "}";
+
+ Gson createGson = createGson();
+ Container fromJson = createGson.fromJson(input, Container.class);
+ ExtendedScannerInfo info = (ExtendedScannerInfo) fromJson.info;
+ assertEquals(Map.of("__STDC__", "1", "__INT64_MAX__", "0x7fffffffffffffffL"), info.getDefinedSymbols());
+ assertArrayEquals(new String[] { "/usr/local/include", "/usr/include" }, info.getIncludePaths());
+ assertEquals("pattern1", info.getIncludeExportPatterns().getIncludeExportPattern().pattern());
+ assertEquals("pattern2", info.getIncludeExportPatterns().getIncludeBeginExportsPattern().pattern());
+ assertEquals("pattern3", info.getIncludeExportPatterns().getIncludeEndExportsPattern().pattern());
+
+ // default values for the rest
+ assertArrayEquals(new String[0], info.getIncludeFiles());
+ assertArrayEquals(new String[0], info.getLocalIncludePath());
+ assertArrayEquals(new String[0], info.getMacroFiles());
+ assertNotNull(info.getParserSettings());
+
+ Container container = new Container();
+ container.info = info;
+ String json = createGson.toJson(container);
+ assertEquals(input.replaceAll("\\s", ""), json);
+ }
+
+ @Test
+ public void testDefaults() {
+ String input = "{\"info\":{}}";
+
+ Gson createGson = createGson();
+ Container fromJson = createGson.fromJson(input, Container.class);
+ ExtendedScannerInfo info = (ExtendedScannerInfo) fromJson.info;
+
+ // default values
+ assertEquals(Map.of(), info.getDefinedSymbols());
+ assertArrayEquals(new String[0], info.getIncludePaths());
+ assertNull(info.getIncludeExportPatterns());
+
+ assertArrayEquals(new String[0], info.getIncludeFiles());
+ assertArrayEquals(new String[0], info.getLocalIncludePath());
+ assertArrayEquals(new String[0], info.getMacroFiles());
+ assertNotNull(info.getParserSettings());
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core.tests/pom.xml b/core/org.eclipse.cdt.core.tests/pom.xml
index b1f2b709e4c..0e6725a6557 100644
--- a/core/org.eclipse.cdt.core.tests/pom.xml
+++ b/core/org.eclipse.cdt.core.tests/pom.xml
@@ -1,4 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2011, 2021 Contributors to the Eclipse Foundation
+
+ This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License 2.0
+ which accompanies this distribution, and is available at
+ https://www.eclipse.org/legal/epl-2.0/
+
+ SPDX-License-Identifier: EPL-2.0
+-->
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
@@ -7,7 +17,7 @@
<parent>
<groupId>org.eclipse.cdt</groupId>
<artifactId>cdt-parent</artifactId>
- <version>10.2.0-SNAPSHOT</version>
+ <version>10.3.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
diff --git a/core/org.eclipse.cdt.core.win32.x86_64/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.core.win32.x86_64/META-INF/MANIFEST.MF
index bc0e7885833..8a6feffc05b 100644
--- a/core/org.eclipse.cdt.core.win32.x86_64/META-INF/MANIFEST.MF
+++ b/core/org.eclipse.cdt.core.win32.x86_64/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %fragmentName.win32.x86_64
Bundle-SymbolicName: org.eclipse.cdt.core.win32.x86_64;singleton:=true
-Bundle-Version: 6.0.100.qualifier
+Bundle-Version: 6.0.200.qualifier
Fragment-Host: org.eclipse.cdt.core.native;bundle-version="[6.0.0,7.0.0)"
Eclipse-PlatformFilter: (&(osgi.os=win32)(osgi.arch=x86_64))
Bundle-Vendor: %providerName
diff --git a/core/org.eclipse.cdt.core.win32.x86_64/os/win32/x86_64/pty.dll b/core/org.eclipse.cdt.core.win32.x86_64/os/win32/x86_64/pty.dll
index 2dc4174a57d..321c33ca84b 100755
--- a/core/org.eclipse.cdt.core.win32.x86_64/os/win32/x86_64/pty.dll
+++ b/core/org.eclipse.cdt.core.win32.x86_64/os/win32/x86_64/pty.dll
Binary files differ
diff --git a/core/org.eclipse.cdt.core.win32.x86_64/os/win32/x86_64/spawner.dll b/core/org.eclipse.cdt.core.win32.x86_64/os/win32/x86_64/spawner.dll
index df14caadec9..ca657101007 100755
--- a/core/org.eclipse.cdt.core.win32.x86_64/os/win32/x86_64/spawner.dll
+++ b/core/org.eclipse.cdt.core.win32.x86_64/os/win32/x86_64/spawner.dll
Binary files differ
diff --git a/core/org.eclipse.cdt.core.win32.x86_64/os/win32/x86_64/starter.exe b/core/org.eclipse.cdt.core.win32.x86_64/os/win32/x86_64/starter.exe
index 919062dbd93..2add8441589 100755
--- a/core/org.eclipse.cdt.core.win32.x86_64/os/win32/x86_64/starter.exe
+++ b/core/org.eclipse.cdt.core.win32.x86_64/os/win32/x86_64/starter.exe
Binary files differ
diff --git a/core/org.eclipse.cdt.core.win32.x86_64/pom.xml b/core/org.eclipse.cdt.core.win32.x86_64/pom.xml
index 2e660a39a94..31c937d0409 100644
--- a/core/org.eclipse.cdt.core.win32.x86_64/pom.xml
+++ b/core/org.eclipse.cdt.core.win32.x86_64/pom.xml
@@ -1,4 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2011, 2021 Contributors to the Eclipse Foundation
+
+ This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License 2.0
+ which accompanies this distribution, and is available at
+ https://www.eclipse.org/legal/epl-2.0/
+
+ SPDX-License-Identifier: EPL-2.0
+-->
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
@@ -7,11 +17,11 @@
<parent>
<groupId>org.eclipse.cdt</groupId>
<artifactId>cdt-parent</artifactId>
- <version>10.2.0-SNAPSHOT</version>
+ <version>10.3.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
- <version>6.0.100-SNAPSHOT</version>
+ <version>6.0.200-SNAPSHOT</version>
<artifactId>org.eclipse.cdt.core.win32.x86_64</artifactId>
<packaging>eclipse-plugin</packaging>
@@ -48,6 +58,17 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-packaging-plugin</artifactId>
+ <configuration>
+ <!-- When signing binaries, the result is not checked into repo, so the
+ jgit timestamp provider cannot be used. This has the side effect
+ that the version of this bundle needs to be incremented on each
+ CDT release. -->
+ <timestampProvider>default</timestampProvider>
+ </configuration>
+ </plugin>
</plugins>
</build>
</project>
diff --git a/core/org.eclipse.cdt.core.win32/pom.xml b/core/org.eclipse.cdt.core.win32/pom.xml
index 01acea75d05..9a9552012a9 100644
--- a/core/org.eclipse.cdt.core.win32/pom.xml
+++ b/core/org.eclipse.cdt.core.win32/pom.xml
@@ -1,4 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2011, 2021 Contributors to the Eclipse Foundation
+
+ This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License 2.0
+ which accompanies this distribution, and is available at
+ https://www.eclipse.org/legal/epl-2.0/
+
+ SPDX-License-Identifier: EPL-2.0
+-->
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
@@ -7,7 +17,7 @@
<parent>
<groupId>org.eclipse.cdt</groupId>
<artifactId>cdt-parent</artifactId>
- <version>10.2.0-SNAPSHOT</version>
+ <version>10.3.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
diff --git a/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF
index 39a75f09eeb..b40557575b1 100644
--- a/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF
+++ b/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.cdt.core; singleton:=true
-Bundle-Version: 7.2.0.qualifier
+Bundle-Version: 7.2.100.qualifier
Bundle-Activator: org.eclipse.cdt.core.CCorePlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
@@ -98,6 +98,7 @@ Export-Package: org.eclipse.cdt.core,
org.eclipse.cdt.internal.core.pdom.indexer;x-friends:="org.eclipse.cdt.ui",
org.eclipse.cdt.internal.core.pdom.tag;x-internal:=true,
org.eclipse.cdt.internal.core.resources;x-friends:="org.eclipse.cdt.ui,org.eclipse.cdt.make.core,org.eclipse.cdt.codan.ui.cxx",
+ org.eclipse.cdt.internal.core.scannerinfo;x-friends:="org.eclipse.cdt.core.tests",
org.eclipse.cdt.internal.core.settings.model;x-internal:=true,
org.eclipse.cdt.internal.core.util;x-friends:="org.eclipse.cdt.ui",
org.eclipse.cdt.internal.errorparsers;x-friends:="org.eclipse.cdt.codan.checkers.ui",
@@ -132,7 +133,7 @@ Require-Bundle: org.eclipse.cdt.core.native;bundle-version="[6.0.0,7.0.0)";visib
org.eclipse.ltk.core.refactoring;bundle-version="[3.10.200,4.0.0)",
org.eclipse.osgi.services;bundle-version="[3.8.0,4.0.0)",
org.eclipse.text;bundle-version="[3.9.0,4.0.0)",
- com.google.gson,
+ com.google.gson;bundle-version="[2.8.6,3.0.0)",
org.eclipse.jdt.annotation;bundle-version="[2.0.0,3.0.0)";resolution:=optional
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-11
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ScannerInfo.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ScannerInfo.java
index 045ab3540e3..e6cee418b21 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ScannerInfo.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ScannerInfo.java
@@ -33,9 +33,9 @@ public class ScannerInfo implements IScannerInfo {
this(macroDefinitions, null);
}
- public ScannerInfo(Map<String, String> macroDefinitions, String[] includeSearchPath) {
- definedSymbols = macroDefinitions != null ? macroDefinitions : Collections.<String, String>emptyMap();
- includePaths = includeSearchPath != null ? includeSearchPath : new String[] {};
+ public ScannerInfo(Map<String, String> definedSymbols, String[] includePaths) {
+ this.definedSymbols = definedSymbols != null ? definedSymbols : Collections.<String, String>emptyMap();
+ this.includePaths = includePaths != null ? includePaths : new String[] {};
}
@Override
diff --git a/core/org.eclipse.cdt.core/plugin.properties b/core/org.eclipse.cdt.core/plugin.properties
index fbcdc43c132..8cf6be710bb 100644
--- a/core/org.eclipse.cdt.core/plugin.properties
+++ b/core/org.eclipse.cdt.core/plugin.properties
@@ -58,6 +58,7 @@ CDTGNUCErrorParser.regex.ForEachFunctionItAppearsIn=(.*?):(\\d+):(\\d+:)? .*for
CDTGNUCErrorParser.regex.ReportedOnlyOncePerInputFile=(.*?):(\\d+):(\\d+:)? .*this will be reported only once per input file.*
CDTGNUCErrorParser.regex.InstantiatedFromHere=(.*?):(\\d+):(\\d+:)?\\s*(.*((instantiated)|(required)) from .*)
CDTGNUCErrorParser.regex.SkippingInstantiationContexts=(.*?):(\\d+):(\\d+:)?\\s*(\\[\\s*skipping \\d+ instantiation context.*)
+CDTGNUCErrorParser.regex.InConstexprExpansion=(.*?):(\\d+):(\\d+:)?\\s*(in 'constexpr' expansion of.*)
CDTGNUCErrorParser.regex.GenericInfo=(.*?):(\\d+):(\\d+:)?\\s*(([Nn]ote)|(NOTE)|([Ii]nfo)|(INFO)): (.*)
CDTGNUCErrorParser.regex.ParseErrorBefore=(.*?):(\\d+):(\\d+:)? (parse error before.*[`'"](.*)['"].*)
CDTGNUCErrorParser.regex.ErrorUndeclared=(.*?):(\\d+):(\\d+:)? [Ee]rror: ([`'"](.*)['"] undeclared .*)
diff --git a/core/org.eclipse.cdt.core/plugin.xml b/core/org.eclipse.cdt.core/plugin.xml
index d7f02eb4e65..8e1bcb7822c 100644
--- a/core/org.eclipse.cdt.core/plugin.xml
+++ b/core/org.eclipse.cdt.core/plugin.xml
@@ -202,6 +202,14 @@
severity="Info">
</pattern>
<pattern
+ description-expr="$4"
+ eat-processed-line="true"
+ file-expr="$1"
+ line-expr="$2"
+ regex="%CDTGNUCErrorParser.regex.InConstexprExpansion"
+ severity="Info">
+ </pattern>
+ <pattern
description-expr="$7"
eat-processed-line="true"
file-expr="$1"
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java
index d0b6c275aa6..2e4f21c174a 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java
@@ -19,7 +19,6 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintStream;
-import java.lang.reflect.Type;
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.InvalidPathException;
@@ -28,12 +27,11 @@ import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
-import java.util.Properties;
import java.util.Map.Entry;
+import java.util.Properties;
import java.util.Set;
import org.eclipse.cdt.core.CCorePlugin;
@@ -61,12 +59,12 @@ import org.eclipse.cdt.core.parser.ExtendedScannerInfo;
import org.eclipse.cdt.core.parser.IExtendedScannerInfo;
import org.eclipse.cdt.core.parser.IScannerInfo;
import org.eclipse.cdt.core.parser.IScannerInfoChangeListener;
-import org.eclipse.cdt.core.parser.IncludeExportPatterns;
import org.eclipse.cdt.core.resources.IConsole;
import org.eclipse.cdt.internal.core.build.Messages;
import org.eclipse.cdt.internal.core.model.BinaryRunner;
import org.eclipse.cdt.internal.core.model.CModelManager;
-import org.eclipse.cdt.internal.core.parser.ParserSettings2;
+import org.eclipse.cdt.internal.core.scannerinfo.ExtendedScannerInfoSerializer;
+import org.eclipse.cdt.internal.core.scannerinfo.IExtendedScannerInfoDeserializer;
import org.eclipse.cdt.utils.CommandLineUtil;
import org.eclipse.cdt.utils.spawner.EnvironmentReader;
import org.eclipse.core.filesystem.URIUtil;
@@ -92,12 +90,6 @@ import org.osgi.service.prefs.Preferences;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonDeserializationContext;
-import com.google.gson.JsonDeserializer;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParseException;
/**
* Root class for CDT build configurations. Provides access to the build
@@ -639,63 +631,6 @@ public abstract class CBuildConfiguration extends PlatformObject implements ICBu
.append(getProject().getName()).append(name + ".json").toFile(); //$NON-NLS-1$
}
- private static class IExtendedScannerInfoCreator implements JsonDeserializer<IExtendedScannerInfo> {
- @Override
- public IExtendedScannerInfo deserialize(JsonElement element, Type arg1, JsonDeserializationContext arg2)
- throws JsonParseException {
- JsonObject infoObj = element.getAsJsonObject();
-
- Map<String, String> definedSymbols = null;
- if (infoObj.has("definedSymbols")) { //$NON-NLS-1$
- JsonObject definedSymbolsObj = infoObj.get("definedSymbols").getAsJsonObject(); //$NON-NLS-1$
- definedSymbols = new HashMap<>();
- for (Entry<String, JsonElement> entry : definedSymbolsObj.entrySet()) {
- definedSymbols.put(entry.getKey(), entry.getValue().getAsString());
- }
- }
-
- String[] includePaths = null;
- if (infoObj.has("includePaths")) { //$NON-NLS-1$
- JsonArray includePathsArray = infoObj.get("includePaths").getAsJsonArray(); //$NON-NLS-1$
- List<String> includePathsList = new ArrayList<>(includePathsArray.size());
- for (Iterator<JsonElement> i = includePathsArray.iterator(); i.hasNext();) {
- includePathsList.add(i.next().getAsString());
- }
- includePaths = includePathsList.toArray(new String[includePathsList.size()]);
- }
-
- IncludeExportPatterns includeExportPatterns = null;
- if (infoObj.has("includeExportPatterns")) { //$NON-NLS-1$
- JsonObject includeExportPatternsObj = infoObj.get("includeExportPatterns").getAsJsonObject(); //$NON-NLS-1$
- String exportPattern = null;
- if (includeExportPatternsObj.has("includeExportPattern")) { //$NON-NLS-1$
- exportPattern = includeExportPatternsObj.get("includeExportPattern") //$NON-NLS-1$
- .getAsJsonObject().get("pattern").getAsString(); //$NON-NLS-1$
- }
-
- String beginExportsPattern = null;
- if (includeExportPatternsObj.has("includeBeginExportPattern")) { //$NON-NLS-1$
- beginExportsPattern = includeExportPatternsObj.get("includeBeginExportPattern") //$NON-NLS-1$
- .getAsJsonObject().get("pattern").getAsString(); //$NON-NLS-1$
- }
-
- String endExportsPattern = null;
- if (includeExportPatternsObj.has("includeEndExportPattern")) { //$NON-NLS-1$
- endExportsPattern = includeExportPatternsObj.get("includeEndExportPattern") //$NON-NLS-1$
- .getAsJsonObject().get("pattern").getAsString(); //$NON-NLS-1$
- }
-
- includeExportPatterns = new IncludeExportPatterns(exportPattern, beginExportsPattern,
- endExportsPattern);
- }
-
- ExtendedScannerInfo info = new ExtendedScannerInfo(definedSymbols, includePaths);
- info.setIncludeExportPatterns(includeExportPatterns);
- info.setParserSettings(new ParserSettings2());
- return info;
- }
- }
-
/**
* @since 6.1
*/
@@ -705,15 +640,14 @@ public abstract class CBuildConfiguration extends PlatformObject implements ICBu
File cacheFile = getScannerInfoCacheFile();
if (cacheFile.exists()) {
try (FileReader reader = new FileReader(cacheFile)) {
- GsonBuilder gsonBuilder = new GsonBuilder();
- gsonBuilder.registerTypeAdapter(IExtendedScannerInfo.class, new IExtendedScannerInfoCreator());
- Gson gson = gsonBuilder.create();
+ Gson gson = createGson();
scannerInfoCache = gson.fromJson(reader, ScannerInfoCache.class);
} catch (IOException e) {
CCorePlugin.log(e);
- scannerInfoCache = new ScannerInfoCache();
}
- } else {
+ }
+
+ if (scannerInfoCache == null) {
scannerInfoCache = new ScannerInfoCache();
}
scannerInfoCache.initCache();
@@ -721,6 +655,14 @@ public abstract class CBuildConfiguration extends PlatformObject implements ICBu
}
}
+ private Gson createGson() {
+ GsonBuilder gsonBuilder = new GsonBuilder();
+ gsonBuilder.registerTypeAdapter(IExtendedScannerInfo.class, new IExtendedScannerInfoDeserializer());
+ gsonBuilder.registerTypeAdapter(ExtendedScannerInfo.class, new ExtendedScannerInfoSerializer());
+ Gson gson = gsonBuilder.create();
+ return gson;
+ }
+
/**
* @since 6.1
*/
@@ -736,7 +678,7 @@ public abstract class CBuildConfiguration extends PlatformObject implements ICBu
}
try (FileWriter writer = new FileWriter(getScannerInfoCacheFile())) {
- Gson gson = new Gson();
+ Gson gson = createGson();
synchronized (scannerInfoLock) {
gson.toJson(scannerInfoCache, writer);
}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/scannerinfo/ExtendedScannerInfoSerializer.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/scannerinfo/ExtendedScannerInfoSerializer.java
new file mode 100644
index 00000000000..f7e218494d1
--- /dev/null
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/scannerinfo/ExtendedScannerInfoSerializer.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2021 Kichwa Coders Canada Inc. and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.scannerinfo;
+
+import java.lang.reflect.Type;
+
+import org.eclipse.cdt.core.parser.ExtendedScannerInfo;
+import org.eclipse.cdt.core.parser.IncludeExportPatterns;
+
+import com.google.gson.JsonElement;
+import com.google.gson.JsonSerializationContext;
+import com.google.gson.JsonSerializer;
+
+/**
+ * Serializer for {@link ExtendedScannerInfo}
+ *
+ * @see ShadowExtendedScannerInfo
+ * @see ShadowIncludeExportPatterns
+ * @see ShadowPattern
+ */
+public class ExtendedScannerInfoSerializer implements JsonSerializer<ExtendedScannerInfo> {
+ @Override
+ public JsonElement serialize(ExtendedScannerInfo info, Type typeOfInfo, JsonSerializationContext context) {
+ ShadowExtendedScannerInfo shadowInfo = new ShadowExtendedScannerInfo();
+ IncludeExportPatterns includeExportPatterns = info.getIncludeExportPatterns();
+ if (includeExportPatterns != null) {
+ shadowInfo.includeExportPatterns = new ShadowIncludeExportPatterns();
+ if (includeExportPatterns.getIncludeExportPattern() != null) {
+ shadowInfo.includeExportPatterns.includeExportPattern = new ShadowPattern(
+ includeExportPatterns.getIncludeExportPattern().pattern());
+ }
+ if (includeExportPatterns.getIncludeBeginExportsPattern() != null) {
+ shadowInfo.includeExportPatterns.includeBeginExportPattern = new ShadowPattern(
+ includeExportPatterns.getIncludeBeginExportsPattern().pattern());
+ }
+ if (includeExportPatterns.getIncludeEndExportsPattern() != null) {
+ shadowInfo.includeExportPatterns.includeEndExportPattern = new ShadowPattern(
+ includeExportPatterns.getIncludeEndExportsPattern().pattern());
+ }
+
+ }
+
+ shadowInfo.definedSymbols = info.getDefinedSymbols();
+ shadowInfo.includePaths = info.getIncludePaths();
+
+ return context.serialize(shadowInfo);
+ }
+}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/scannerinfo/IExtendedScannerInfoDeserializer.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/scannerinfo/IExtendedScannerInfoDeserializer.java
new file mode 100644
index 00000000000..1a264b4c730
--- /dev/null
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/scannerinfo/IExtendedScannerInfoDeserializer.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2021 Kichwa Coders Canada Inc. and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.scannerinfo;
+
+import java.lang.reflect.Type;
+
+import org.eclipse.cdt.core.parser.ExtendedScannerInfo;
+import org.eclipse.cdt.core.parser.IExtendedScannerInfo;
+import org.eclipse.cdt.core.parser.IncludeExportPatterns;
+import org.eclipse.cdt.internal.core.parser.ParserSettings2;
+
+import com.google.gson.JsonDeserializationContext;
+import com.google.gson.JsonDeserializer;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonParseException;
+
+/**
+ * Deserializer for {@link IExtendedScannerInfo} that deserializes into {@link ExtendedScannerInfo} as the concrete type.
+ *
+ * @see ShadowExtendedScannerInfo
+ * @see ShadowIncludeExportPatterns
+ * @see ShadowPattern
+ */
+public class IExtendedScannerInfoDeserializer implements JsonDeserializer<IExtendedScannerInfo> {
+
+ @Override
+ public IExtendedScannerInfo deserialize(JsonElement element, Type typeOfT, JsonDeserializationContext context)
+ throws JsonParseException {
+ ShadowExtendedScannerInfo shadowInfo = (ShadowExtendedScannerInfo) context.deserialize(element,
+ ShadowExtendedScannerInfo.class);
+
+ ExtendedScannerInfo info = new ExtendedScannerInfo(shadowInfo.definedSymbols, shadowInfo.includePaths);
+ if (shadowInfo.includeExportPatterns != null) {
+ String includeExportPattern = null;
+ String includeBeginExportPattern = null;
+ String includeEndExportPattern = null;
+ if (shadowInfo.includeExportPatterns.includeExportPattern != null) {
+ includeExportPattern = shadowInfo.includeExportPatterns.includeExportPattern.pattern;
+ }
+ if (shadowInfo.includeExportPatterns.includeBeginExportPattern != null) {
+ includeBeginExportPattern = shadowInfo.includeExportPatterns.includeBeginExportPattern.pattern;
+ }
+ if (shadowInfo.includeExportPatterns.includeEndExportPattern != null) {
+ includeEndExportPattern = shadowInfo.includeExportPatterns.includeEndExportPattern.pattern;
+ }
+ IncludeExportPatterns patterns = new IncludeExportPatterns(includeExportPattern, includeBeginExportPattern,
+ includeEndExportPattern);
+ info.setIncludeExportPatterns(patterns);
+ }
+ info.setParserSettings(new ParserSettings2());
+ return info;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/scannerinfo/ShadowExtendedScannerInfo.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/scannerinfo/ShadowExtendedScannerInfo.java
new file mode 100644
index 00000000000..b6c1d71f79f
--- /dev/null
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/scannerinfo/ShadowExtendedScannerInfo.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2021 Kichwa Coders Canada Inc. and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.scannerinfo;
+
+import java.util.Map;
+
+import org.eclipse.cdt.core.parser.ExtendedScannerInfo;
+
+/**
+ * Shadow version of the classes we are trying to serialize that contain only the info we need.
+ *
+ * @see ExtendedScannerInfo
+ * @see IExtendedScannerInfoDeserializer
+ * @see ExtendedScannerInfoSerializer
+ */
+public class ShadowExtendedScannerInfo {
+ ShadowIncludeExportPatterns includeExportPatterns;
+ Map<String, String> definedSymbols;
+ String[] includePaths;
+}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/scannerinfo/ShadowIncludeExportPatterns.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/scannerinfo/ShadowIncludeExportPatterns.java
new file mode 100644
index 00000000000..43eefea5b79
--- /dev/null
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/scannerinfo/ShadowIncludeExportPatterns.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2021 Kichwa Coders Canada Inc. and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.scannerinfo;
+
+import org.eclipse.cdt.core.parser.IncludeExportPatterns;
+
+/**
+ * Shadow version of the classes we are trying to serialize that contain only the info we need.
+ *
+ * @see IncludeExportPatterns
+ * @see IExtendedScannerInfoDeserializer
+ * @see ExtendedScannerInfoSerializer
+ */
+public class ShadowIncludeExportPatterns {
+ ShadowPattern includeExportPattern;
+ ShadowPattern includeBeginExportPattern;
+ ShadowPattern includeEndExportPattern;
+}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/scannerinfo/ShadowPattern.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/scannerinfo/ShadowPattern.java
new file mode 100644
index 00000000000..628f8f1d6ba
--- /dev/null
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/scannerinfo/ShadowPattern.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2021 Kichwa Coders Canada Inc. and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.scannerinfo;
+
+import java.util.regex.Pattern;
+
+/**
+ * Shadow version of the classes we are trying to serialize that contain only the info we need.
+ *
+ * To match original implementation of the serialize/deserialize which used {@link Pattern} directly
+ * we replicate the structure. This is why we don't just use String instead of ShadowPattern
+ *
+ * @see Pattern
+ * @see IExtendedScannerInfoDeserializer
+ * @see ExtendedScannerInfoSerializer
+ */
+public class ShadowPattern {
+ public ShadowPattern(String pattern) {
+ this.pattern = pattern;
+ }
+
+ String pattern;
+}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/VCErrorParser.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/VCErrorParser.java
index 1d07bc5f9d0..c93fd3d74fa 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/VCErrorParser.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/VCErrorParser.java
@@ -22,7 +22,7 @@ import org.eclipse.cdt.core.errorparsers.ErrorPattern;
public class VCErrorParser extends AbstractErrorParser {
private static final ErrorPattern[] patterns = {
- new ErrorPattern("(.+?)(\\(([0-9]+)\\))? : (fatal error|error|warning) (.*)", 1, 3, 5, 0, 0) { //$NON-NLS-1$
+ new ErrorPattern("(.+?)(\\(([0-9]+)\\))?\\s*:\\s*(fatal error|error|warning) (.*)", 1, 3, 5, 0, 0) { //$NON-NLS-1$
@Override
public int getSeverity(Matcher matcher) {
return "warning".equals(matcher.group(4)) //$NON-NLS-1$
diff --git a/core/org.eclipse.cdt.ui.tests/pom.xml b/core/org.eclipse.cdt.ui.tests/pom.xml
index 49841a02e47..208e7589eb0 100644
--- a/core/org.eclipse.cdt.ui.tests/pom.xml
+++ b/core/org.eclipse.cdt.ui.tests/pom.xml
@@ -1,4 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2011, 2021 Contributors to the Eclipse Foundation
+
+ This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License 2.0
+ which accompanies this distribution, and is available at
+ https://www.eclipse.org/legal/epl-2.0/
+
+ SPDX-License-Identifier: EPL-2.0
+-->
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
@@ -7,7 +17,7 @@
<parent>
<groupId>org.eclipse.cdt</groupId>
<artifactId>cdt-parent</artifactId>
- <version>10.2.0-SNAPSHOT</version>
+ <version>10.3.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
diff --git a/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF
index 84741452b5f..90c70d3113f 100644
--- a/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF
+++ b/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.cdt.ui; singleton:=true
-Bundle-Version: 7.1.100.qualifier
+Bundle-Version: 7.2.0.qualifier
Bundle-Activator: org.eclipse.cdt.ui.CUIPlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/codemanipulation/CdtTemplate.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/codemanipulation/CdtTemplate.java
new file mode 100644
index 00000000000..6728b1c96c8
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/codemanipulation/CdtTemplate.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2021 Wind River Systems, Inc. and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Lidia Popescu (Wind River Systems) - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.corext.codemanipulation;
+
+import java.util.Objects;
+
+import org.eclipse.jface.text.templates.Template;
+
+public class CdtTemplate implements Comparable<CdtTemplate> {
+
+ private String id;
+ private Template template;
+ private String key;
+ private String name;
+
+ /**
+ * @param id - should be the id from TemplatePersistenceData
+ * @param template
+ */
+ public CdtTemplate(String id, Template template) {
+ this.id = id;
+ this.template = template;
+ if (id == null) {
+ this.key = ""; //$NON-NLS-1$
+ } else {
+ this.key = id;
+ }
+ if (template == null || template.getName() == null) {
+ this.name = ""; //$NON-NLS-1$
+ } else {
+ this.name = template.getName();
+ }
+ }
+
+ public String getID() {
+ return id;
+ }
+
+ public Template getTemplate() {
+ return template;
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public int compareTo(CdtTemplate cdtTmp) {
+ int value = Objects.compare(key, cdtTmp.key, String::compareTo);
+ if (value == 0) {
+ return Objects.compare(name, cdtTmp.name, String.CASE_INSENSITIVE_ORDER);
+ }
+ return value;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/codemanipulation/StubUtility.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/codemanipulation/StubUtility.java
index d1aa1849f35..af2b0f94e18 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/codemanipulation/StubUtility.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/codemanipulation/StubUtility.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2001, 2016 IBM Corporation and others.
+ * Copyright (c) 2001, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,11 +13,13 @@
* Anton Leherbauer (Wind River Systems)
* Jens Elmenthaler (Verigy) - http://bugs.eclipse.org/235586
* Sergey Prigogin (Google)
+ * Lidia Popescu (Wind River Systems) - http://bugs.eclipse.org/572755
*******************************************************************************/
package org.eclipse.cdt.internal.corext.codemanipulation;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -759,13 +761,27 @@ public class StubUtility {
}
templateDatas = projectStore.getTemplateData();
}
+
List<Template> result = new ArrayList<>();
+ List<CdtTemplate> cdtResult = new ArrayList<>();
for (int j = 0; j < contentTypes.length; j++) {
for (int i = 0; i < templateDatas.length; i++) {
Template template = templateDatas[i].getTemplate();
+ if (template == null)
+ continue;
final String contextTypeId = template.getContextTypeId();
if (FileTemplateContextType.isContextTypeForContentType(contextTypeId, contentTypes[j])) {
- result.add(template);
+ cdtResult.add(new CdtTemplate(templateDatas[i].getId(), templateDatas[i].getTemplate()));
+ }
+ }
+ }
+
+ Collections.sort(cdtResult);
+ for (int j = 0; j < contentTypes.length; j++) {
+ for (CdtTemplate c : cdtResult) {
+ if (FileTemplateContextType.isContextTypeForContentType(c.getTemplate().getContextTypeId(),
+ contentTypes[j])) {
+ result.add(c.getTemplate());
}
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/AnnotationExpansionControl.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/AnnotationExpansionControl.java
index fd075145ab5..5709c9d9a7d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/AnnotationExpansionControl.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/AnnotationExpansionControl.java
@@ -110,6 +110,12 @@ public class AnnotationExpansionControl implements IInformationControl, IInforma
StyleRange[] oldStyles;
public void selected() {
+ if (fSelection != null) {
+ // We can get two selection events back to back because of
+ // code in org.eclipse.cdt.internal.ui.text.c.hover.AnnotationExpansionControl.setVisible(boolean)
+ // which forces a select on first open
+ deselect();
+ }
Display disp = fShell.getDisplay();
canvas.setCursor(getHandCursor(disp));
// TODO: shade - for now: set grey background
@@ -894,7 +900,7 @@ public class AnnotationExpansionControl implements IInformationControl, IInforma
}
private Color getHighlightColor(Display disp) {
- return disp.getSystemColor(SWT.COLOR_GRAY);
+ return disp.getSystemColor(SWT.COLOR_TEXT_DISABLED_BACKGROUND);
}
private Color getSelectionColor(Display disp) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/WizardNewFileFromTemplateCreationPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/WizardNewFileFromTemplateCreationPage.java
index d5d0d5633e8..f70e4f0de37 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/WizardNewFileFromTemplateCreationPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/WizardNewFileFromTemplateCreationPage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
+ * Copyright (c) 2007, 2021 Wind River Systems, Inc. and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -10,21 +10,26 @@
*
* Contributors:
* Anton Leherbauer (Wind River Systems) - initial API and implementation
+ * Lidia Popescu (Wind River Systems) - http://bugs.eclipse.org/573204
*******************************************************************************/
package org.eclipse.cdt.internal.ui.wizards.filewizard;
import java.io.ByteArrayInputStream;
+import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
import org.eclipse.cdt.internal.corext.codemanipulation.StubUtility;
import org.eclipse.cdt.internal.corext.template.c.FileTemplateContextType;
import org.eclipse.cdt.internal.ui.preferences.CodeTemplatePreferencePage;
+import org.eclipse.cdt.internal.ui.viewsupport.ProjectTemplateStore;
+import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -34,6 +39,7 @@ import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.core.runtime.content.IContentTypeManager;
import org.eclipse.core.runtime.content.IContentTypeMatcher;
+import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.preference.PreferenceDialog;
import org.eclipse.jface.text.templates.Template;
import org.eclipse.jface.viewers.IStructuredSelection;
@@ -48,6 +54,7 @@ import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
+import org.eclipse.text.templates.TemplatePersistenceData;
import org.eclipse.ui.dialogs.PreferencesUtil;
import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
@@ -61,6 +68,8 @@ public class WizardNewFileFromTemplateCreationPage extends WizardNewFileCreation
private Combo fTemplatesCombo;
private Template[] fTemplates;
protected boolean fUseTemplate = true;
+ /** Dialog settings key to persist selected template. */
+ private static final String KEY_TEMPLATE = "org.eclipse.cdt.internal.corext.codemanipulation"; //$NON-NLS-1$
/**
* Create a new 'file from template' page.
@@ -148,6 +157,7 @@ public class WizardNewFileFromTemplateCreationPage extends WizardNewFileCreation
String content = StubUtility.getFileContent(template, fileHandle, lineDelimiter);
if (content != null) {
try {
+ saveSelection(getContainterProject(), getFileExtensionFromName(), template);
String charset = fileHandle.getParent().getDefaultCharset();
return new ByteArrayInputStream(content.getBytes(charset));
} catch (UnsupportedEncodingException exc) {
@@ -182,6 +192,10 @@ public class WizardNewFileFromTemplateCreationPage extends WizardNewFileCreation
idx = i;
}
}
+ Optional<Integer> idxo = getSelection(getContainterProject(), getFileExtensionFromName(), fTemplates);
+ if (idxo.isPresent()) {
+ idx = idxo.get();
+ }
if (fTemplatesCombo != null) {
if (names.length == 0) {
names = new String[] { NewFileWizardMessages.WizardNewFileFromTemplateCreationPage_noTemplate_name };
@@ -277,4 +291,160 @@ public class WizardNewFileFromTemplateCreationPage extends WizardNewFileCreation
return result.toArray(new String[result.size()]);
}
+ /**
+ * @return
+ */
+ private String getFileExtensionFromName() {
+ String fName = getFileName();
+ if (fName == null || fName.isEmpty() || !fName.contains(".")) { //$NON-NLS-1$
+ return null;
+ }
+ return fName.substring(fName.lastIndexOf("."), fName.length()); //$NON-NLS-1$
+ }
+
+ /**
+ * Returns the specific section from dialog based on provided key
+ *
+ * @param fileExtension
+ * @return
+ */
+ protected static IDialogSettings getDialogSettings(String fileExtension) {
+ if (fileExtension == null) {
+ return null;
+ }
+ IDialogSettings settings = CUIPlugin.getDefault().getDialogSettings().getSection(KEY_TEMPLATE);
+ if (settings == null) {
+ settings = CUIPlugin.getDefault().getDialogSettings().addNewSection(KEY_TEMPLATE);
+ }
+ IDialogSettings eSettings = settings.getSection(fileExtension);
+ if (eSettings == null) {
+ eSettings = settings.addNewSection(fileExtension);
+ }
+ return eSettings;
+ }
+
+ /**
+ * Saves the template that has been used for a specific file extension.
+ *
+ * @param project
+ * @param fExtension
+ * @param template
+ */
+ private static void saveSelection(IProject project, String fExtension, Template template) {
+ if (fExtension == null || fExtension.isEmpty() || template == null) {
+ return;
+ }
+ IDialogSettings settings = getDialogSettings(fExtension);
+ if (settings != null) {
+ TemplatePersistenceData[] data = getTemplatePersistentData(project);
+ String templateID = getTemplateId(template, data);
+ settings.put("id", templateID == null ? "" : templateID); //$NON-NLS-1$ //$NON-NLS-2$
+ settings.put("name", template.getName()); //$NON-NLS-1$
+ settings.put("contextId", template.getContextTypeId()); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * @param template
+ * @param data
+ * @return
+ */
+ private static String getTemplateId(Template template, TemplatePersistenceData[] data) {
+ if (template == null || data == null)
+ return null;
+ for (int i = 0; i < data.length; i++) {
+ TemplatePersistenceData tData = data[i];
+ if (tData.getTemplate().equals(template)) {
+ return tData.getId();
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @param project
+ * @return
+ */
+ private static TemplatePersistenceData[] getTemplatePersistentData(IProject project) {
+ TemplatePersistenceData[] templateDatas;
+ if (project == null) {
+ templateDatas = CUIPlugin.getDefault().getCodeTemplateStore().getTemplateData(true);
+ } else {
+ ProjectTemplateStore projectStore = new ProjectTemplateStore(project.getProject());
+ try {
+ projectStore.load();
+ } catch (IOException e) {
+ CUIPlugin.log(e);
+ }
+ templateDatas = projectStore.getTemplateData();
+ }
+ return templateDatas;
+ }
+
+ /**
+ * @param project
+ * @param fExtension
+ * @param fTemplates
+ * @return the position of found template in the list for combobox selection inside Optional
+ */
+ private static Optional<Integer> getSelection(IProject project, String fExtension, Template[] fTemplates) {
+ if (fExtension == null || fTemplates == null) {
+ return Optional.empty();
+ }
+ if (fExtension.isEmpty() || fTemplates.length == 0) {
+ return Optional.empty();
+ }
+ IDialogSettings settings = CUIPlugin.getDefault().getDialogSettings().getSection(KEY_TEMPLATE);
+ if (settings == null) {
+ return Optional.empty();
+ }
+ IDialogSettings eSettings = settings.getSection(fExtension);
+ if (eSettings == null) {
+ return Optional.empty();
+ }
+ String tId = eSettings.get("id"); //$NON-NLS-1$
+ String tName = eSettings.get("name"); //$NON-NLS-1$
+ String tContextId = eSettings.get("contextId"); //$NON-NLS-1$
+ Template template = getTemplateFromId(project, tId);
+
+ if (template != null) {
+ for (int i = 0; i < fTemplates.length; i++) {
+ if (fTemplates[i].equals(template)) {
+ return Optional.of(i);
+ }
+ }
+ }
+ for (int i = 0; i < fTemplates.length; i++) {
+ if (fTemplates[i].getContextTypeId().equals(tContextId) && fTemplates[i].getName().equals(tName)) {
+ return Optional.of(i);
+ }
+ }
+ return Optional.empty();
+ }
+
+ /**
+ * Templates provided thought extension point may have id, but user manually created templates will not have ids.
+ *
+ * The method finds template object from provided template id stored in DialogSettings.
+ * If the plugin that provided the template has been uninstalled, it may not found the template.
+ *
+ * @param project
+ * @param tId
+ * @return
+ */
+ private static Template getTemplateFromId(IProject project, String tId) {
+ if (tId == null || tId.isEmpty()) {
+ return null;
+ }
+ TemplatePersistenceData[] data = getTemplatePersistentData(project);
+ if (data == null) {
+ return null;
+ }
+ for (int i = 0; i < data.length; i++) {
+ if (tId.equals(data[i].getId())) {
+ return data[i].getTemplate();
+ }
+ }
+ return null;
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractCPropertyTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractCPropertyTab.java
index 380a73cf3de..47fb72c7b4f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractCPropertyTab.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractCPropertyTab.java
@@ -378,6 +378,16 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab {
return g;
}
+ /**
+ * @since 7.2
+ */
+ protected Composite setupComposite(Composite c, int cols, int mode) {
+ Composite c1 = new Composite(c, SWT.NONE);
+ c1.setLayout(new GridLayout(cols, false));
+ setupControl(c1, 1, mode);
+ return c1;
+ }
+
protected Button setupCheck(Composite c, String name, int span, int mode) {
Button b = new Button(c, SWT.CHECK);
b.setText(name);
@@ -393,6 +403,23 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab {
}
/**
+ * @since 7.2
+ */
+ protected Button setupRadio(Composite c, String name, int span, int mode) {
+ Button b = new Button(c, SWT.RADIO);
+ b.setText(name);
+ setupControl(b, span, mode);
+ b.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent event) {
+ ((Button) event.widget).setGrayed(false);
+ checkPressed(event);
+ }
+ });
+ return b;
+ }
+
+ /**
* Selection handler for checkbox created
* by methods "setupCheck()" or "setupTri()"
* Descendants should override this method
diff --git a/core/pom.xml b/core/pom.xml
index 7a31c6d04c3..3b6a9dc2308 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -1,4 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2011, 2021 Contributors to the Eclipse Foundation
+
+ This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License 2.0
+ which accompanies this distribution, and is available at
+ https://www.eclipse.org/legal/epl-2.0/
+
+ SPDX-License-Identifier: EPL-2.0
+-->
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
@@ -7,7 +17,7 @@
<parent>
<groupId>org.eclipse.cdt</groupId>
<artifactId>cdt-parent</artifactId>
- <version>10.2.0-SNAPSHOT</version>
+ <version>10.3.0-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.cdt-parent</artifactId>

Back to the top