diff options
Diffstat (limited to 'core')
690 files changed, 15127 insertions, 10881 deletions
diff --git a/core/org.eclipse.cdt.core.linux.aarch64/.project b/core/org.eclipse.cdt.core.linux.aarch64/.project new file mode 100644 index 00000000000..c0e42ebeb4a --- /dev/null +++ b/core/org.eclipse.cdt.core.linux.aarch64/.project @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.cdt.core.linux.aarch64</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + </natures> +</projectDescription> diff --git a/core/org.eclipse.cdt.core.linux.aarch64/.settings/org.eclipse.core.resources.prefs b/core/org.eclipse.cdt.core.linux.aarch64/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 00000000000..99f26c0203a --- /dev/null +++ b/core/org.eclipse.cdt.core.linux.aarch64/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/<project>=UTF-8 diff --git a/core/org.eclipse.cdt.core.linux.aarch64/.settings/org.eclipse.pde.api.tools.prefs b/core/org.eclipse.cdt.core.linux.aarch64/.settings/org.eclipse.pde.api.tools.prefs new file mode 100644 index 00000000000..ec9fbf321d0 --- /dev/null +++ b/core/org.eclipse.cdt.core.linux.aarch64/.settings/org.eclipse.pde.api.tools.prefs @@ -0,0 +1,184 @@ +ANNOTATION_ELEMENT_TYPE_ADDED_CLASS_BOUND=Error +ANNOTATION_ELEMENT_TYPE_ADDED_FIELD=Error +ANNOTATION_ELEMENT_TYPE_ADDED_INTERFACE_BOUND=Error +ANNOTATION_ELEMENT_TYPE_ADDED_INTERFACE_BOUNDS=Error +ANNOTATION_ELEMENT_TYPE_ADDED_METHOD=Error +ANNOTATION_ELEMENT_TYPE_ADDED_METHOD_WITHOUT_DEFAULT_VALUE=Error +ANNOTATION_ELEMENT_TYPE_ADDED_TYPE_MEMBER=Error +ANNOTATION_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error +ANNOTATION_ELEMENT_TYPE_CHANGED_CLASS_BOUND=Error +ANNOTATION_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERINTERFACES_SET=Error +ANNOTATION_ELEMENT_TYPE_CHANGED_INTERFACE_BOUND=Error +ANNOTATION_ELEMENT_TYPE_CHANGED_INTERFACE_BOUNDS=Error +ANNOTATION_ELEMENT_TYPE_CHANGED_RESTRICTIONS=Error +ANNOTATION_ELEMENT_TYPE_CHANGED_TO_CLASS=Error +ANNOTATION_ELEMENT_TYPE_CHANGED_TO_ENUM=Error +ANNOTATION_ELEMENT_TYPE_CHANGED_TO_INTERFACE=Error +ANNOTATION_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error +ANNOTATION_ELEMENT_TYPE_REMOVED_CLASS_BOUND=Error +ANNOTATION_ELEMENT_TYPE_REMOVED_FIELD=Error +ANNOTATION_ELEMENT_TYPE_REMOVED_INTERFACE_BOUND=Error +ANNOTATION_ELEMENT_TYPE_REMOVED_METHOD=Error +ANNOTATION_ELEMENT_TYPE_REMOVED_METHOD_WITHOUT_DEFAULT_VALUE=Error +ANNOTATION_ELEMENT_TYPE_REMOVED_METHOD_WITH_DEFAULT_VALUE=Error +ANNOTATION_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error +ANNOTATION_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error +ANNOTATION_ELEMENT_TYPE_REMOVED_TYPE_PARAMETERS=Error +API_COMPONENT_ELEMENT_TYPE_REMOVED_API_TYPE=Error +API_COMPONENT_ELEMENT_TYPE_REMOVED_REEXPORTED_API_TYPE=Error +API_COMPONENT_ELEMENT_TYPE_REMOVED_REEXPORTED_TYPE=Error +API_COMPONENT_ELEMENT_TYPE_REMOVED_TYPE=Error +API_USE_SCAN_FIELD_SEVERITY=Error +API_USE_SCAN_METHOD_SEVERITY=Error +API_USE_SCAN_TYPE_SEVERITY=Error +CLASS_ELEMENT_TYPE_ADDED_CLASS_BOUND=Error +CLASS_ELEMENT_TYPE_ADDED_FIELD=Error +CLASS_ELEMENT_TYPE_ADDED_INTERFACE_BOUND=Error +CLASS_ELEMENT_TYPE_ADDED_INTERFACE_BOUNDS=Error +CLASS_ELEMENT_TYPE_ADDED_METHOD=Error +CLASS_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error +CLASS_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error +CLASS_ELEMENT_TYPE_CHANGED_CLASS_BOUND=Error +CLASS_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERCLASS_SET=Error +CLASS_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERINTERFACES_SET=Error +CLASS_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error +CLASS_ELEMENT_TYPE_CHANGED_INTERFACE_BOUND=Error +CLASS_ELEMENT_TYPE_CHANGED_NON_ABSTRACT_TO_ABSTRACT=Error +CLASS_ELEMENT_TYPE_CHANGED_NON_FINAL_TO_FINAL=Error +CLASS_ELEMENT_TYPE_CHANGED_RESTRICTIONS=Error +CLASS_ELEMENT_TYPE_CHANGED_SUPERCLASS=Error +CLASS_ELEMENT_TYPE_CHANGED_TO_ANNOTATION=Error +CLASS_ELEMENT_TYPE_CHANGED_TO_ENUM=Error +CLASS_ELEMENT_TYPE_CHANGED_TO_INTERFACE=Error +CLASS_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error +CLASS_ELEMENT_TYPE_REMOVED_CLASS_BOUND=Error +CLASS_ELEMENT_TYPE_REMOVED_CONSTRUCTOR=Error +CLASS_ELEMENT_TYPE_REMOVED_FIELD=Error +CLASS_ELEMENT_TYPE_REMOVED_INTERFACE_BOUND=Error +CLASS_ELEMENT_TYPE_REMOVED_INTERFACE_BOUNDS=Error +CLASS_ELEMENT_TYPE_REMOVED_METHOD=Error +CLASS_ELEMENT_TYPE_REMOVED_SUPERCLASS=Error +CLASS_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error +CLASS_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error +CLASS_ELEMENT_TYPE_REMOVED_TYPE_PARAMETERS=Error +CONSTRUCTOR_ELEMENT_TYPE_ADDED_CLASS_BOUND=Error +CONSTRUCTOR_ELEMENT_TYPE_ADDED_INTERFACE_BOUND=Error +CONSTRUCTOR_ELEMENT_TYPE_ADDED_INTERFACE_BOUNDS=Error +CONSTRUCTOR_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error +CONSTRUCTOR_ELEMENT_TYPE_CHANGED_CLASS_BOUND=Error +CONSTRUCTOR_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error +CONSTRUCTOR_ELEMENT_TYPE_CHANGED_INTERFACE_BOUND=Error +CONSTRUCTOR_ELEMENT_TYPE_CHANGED_NON_ABSTRACT_TO_ABSTRACT=Error +CONSTRUCTOR_ELEMENT_TYPE_CHANGED_NON_FINAL_TO_FINAL=Error +CONSTRUCTOR_ELEMENT_TYPE_CHANGED_NON_STATIC_TO_STATIC=Error +CONSTRUCTOR_ELEMENT_TYPE_CHANGED_STATIC_TO_NON_STATIC=Error +CONSTRUCTOR_ELEMENT_TYPE_CHANGED_TYPE_PARAMETER=Error +CONSTRUCTOR_ELEMENT_TYPE_CHANGED_VARARGS_TO_ARRAY=Error +CONSTRUCTOR_ELEMENT_TYPE_REMOVED_ANNOTATION_DEFAULT_VALUE=Error +CONSTRUCTOR_ELEMENT_TYPE_REMOVED_CLASS_BOUND=Error +CONSTRUCTOR_ELEMENT_TYPE_REMOVED_INTERFACE_BOUND=Error +CONSTRUCTOR_ELEMENT_TYPE_REMOVED_INTERFACE_BOUNDS=Error +CONSTRUCTOR_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error +CONSTRUCTOR_ELEMENT_TYPE_REMOVED_TYPE_PARAMETERS=Error +ENUM_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERINTERFACES_SET=Error +ENUM_ELEMENT_TYPE_CHANGED_RESTRICTIONS=Error +ENUM_ELEMENT_TYPE_CHANGED_TO_ANNOTATION=Error +ENUM_ELEMENT_TYPE_CHANGED_TO_CLASS=Error +ENUM_ELEMENT_TYPE_CHANGED_TO_INTERFACE=Error +ENUM_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error +ENUM_ELEMENT_TYPE_REMOVED_ENUM_CONSTANT=Error +ENUM_ELEMENT_TYPE_REMOVED_FIELD=Error +ENUM_ELEMENT_TYPE_REMOVED_METHOD=Error +ENUM_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error +FIELD_ELEMENT_TYPE_ADDED_VALUE=Error +FIELD_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error +FIELD_ELEMENT_TYPE_CHANGED_FINAL_TO_NON_FINAL_STATIC_CONSTANT=Error +FIELD_ELEMENT_TYPE_CHANGED_NON_FINAL_TO_FINAL=Error +FIELD_ELEMENT_TYPE_CHANGED_NON_STATIC_TO_STATIC=Error +FIELD_ELEMENT_TYPE_CHANGED_STATIC_TO_NON_STATIC=Error +FIELD_ELEMENT_TYPE_CHANGED_TYPE=Error +FIELD_ELEMENT_TYPE_CHANGED_VALUE=Error +FIELD_ELEMENT_TYPE_REMOVED_TYPE_ARGUMENT=Error +FIELD_ELEMENT_TYPE_REMOVED_TYPE_ARGUMENTS=Error +FIELD_ELEMENT_TYPE_REMOVED_VALUE=Error +ILLEGAL_EXTEND=Warning +ILLEGAL_IMPLEMENT=Warning +ILLEGAL_INSTANTIATE=Warning +ILLEGAL_OVERRIDE=Warning +ILLEGAL_REFERENCE=Warning +INTERFACE_ELEMENT_TYPE_ADDED_CLASS_BOUND=Error +INTERFACE_ELEMENT_TYPE_ADDED_DEFAULT_METHOD=Error +INTERFACE_ELEMENT_TYPE_ADDED_FIELD=Error +INTERFACE_ELEMENT_TYPE_ADDED_INTERFACE_BOUND=Error +INTERFACE_ELEMENT_TYPE_ADDED_INTERFACE_BOUNDS=Error +INTERFACE_ELEMENT_TYPE_ADDED_METHOD=Error +INTERFACE_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error +INTERFACE_ELEMENT_TYPE_ADDED_SUPER_INTERFACE_WITH_METHODS=Error +INTERFACE_ELEMENT_TYPE_ADDED_TYPE_MEMBER=Error +INTERFACE_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error +INTERFACE_ELEMENT_TYPE_ADDED_TYPE_PARAMETERS=Error +INTERFACE_ELEMENT_TYPE_CHANGED_CLASS_BOUND=Error +INTERFACE_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERINTERFACES_SET=Error +INTERFACE_ELEMENT_TYPE_CHANGED_INTERFACE_BOUND=Error +INTERFACE_ELEMENT_TYPE_CHANGED_INTERFACE_BOUNDS=Error +INTERFACE_ELEMENT_TYPE_CHANGED_RESTRICTIONS=Error +INTERFACE_ELEMENT_TYPE_CHANGED_TO_ANNOTATION=Error +INTERFACE_ELEMENT_TYPE_CHANGED_TO_CLASS=Error +INTERFACE_ELEMENT_TYPE_CHANGED_TO_ENUM=Error +INTERFACE_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error +INTERFACE_ELEMENT_TYPE_REMOVED_CLASS_BOUND=Error +INTERFACE_ELEMENT_TYPE_REMOVED_FIELD=Error +INTERFACE_ELEMENT_TYPE_REMOVED_INTERFACE_BOUND=Error +INTERFACE_ELEMENT_TYPE_REMOVED_INTERFACE_BOUNDS=Error +INTERFACE_ELEMENT_TYPE_REMOVED_METHOD=Error +INTERFACE_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error +INTERFACE_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error +INVALID_ANNOTATION=Ignore +INVALID_JAVADOC_TAG=Error +INVALID_REFERENCE_IN_SYSTEM_LIBRARIES=Warning +LEAK_EXTEND=Warning +LEAK_FIELD_DECL=Warning +LEAK_IMPLEMENT=Warning +LEAK_METHOD_PARAM=Warning +LEAK_METHOD_RETURN_TYPE=Warning +METHOD_ELEMENT_TYPE_ADDED_CLASS_BOUND=Error +METHOD_ELEMENT_TYPE_ADDED_INTERFACE_BOUND=Error +METHOD_ELEMENT_TYPE_ADDED_INTERFACE_BOUNDS=Error +METHOD_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error +METHOD_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error +METHOD_ELEMENT_TYPE_CHANGED_CLASS_BOUND=Error +METHOD_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error +METHOD_ELEMENT_TYPE_CHANGED_INTERFACE_BOUND=Error +METHOD_ELEMENT_TYPE_CHANGED_NON_ABSTRACT_TO_ABSTRACT=Error +METHOD_ELEMENT_TYPE_CHANGED_NON_FINAL_TO_FINAL=Error +METHOD_ELEMENT_TYPE_CHANGED_NON_STATIC_TO_STATIC=Error +METHOD_ELEMENT_TYPE_CHANGED_STATIC_TO_NON_STATIC=Error +METHOD_ELEMENT_TYPE_CHANGED_TYPE_PARAMETER=Error +METHOD_ELEMENT_TYPE_CHANGED_VARARGS_TO_ARRAY=Error +METHOD_ELEMENT_TYPE_REMOVED_ANNOTATION_DEFAULT_VALUE=Error +METHOD_ELEMENT_TYPE_REMOVED_CLASS_BOUND=Error +METHOD_ELEMENT_TYPE_REMOVED_INTERFACE_BOUND=Error +METHOD_ELEMENT_TYPE_REMOVED_INTERFACE_BOUNDS=Error +METHOD_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error +METHOD_ELEMENT_TYPE_REMOVED_TYPE_PARAMETERS=Error +MISSING_EE_DESCRIPTIONS=Warning +TYPE_PARAMETER_ELEMENT_TYPE_ADDED_CLASS_BOUND=Error +TYPE_PARAMETER_ELEMENT_TYPE_ADDED_INTERFACE_BOUND=Error +TYPE_PARAMETER_ELEMENT_TYPE_CHANGED_CLASS_BOUND=Error +TYPE_PARAMETER_ELEMENT_TYPE_CHANGED_INTERFACE_BOUND=Error +TYPE_PARAMETER_ELEMENT_TYPE_REMOVED_CLASS_BOUND=Error +TYPE_PARAMETER_ELEMENT_TYPE_REMOVED_INTERFACE_BOUND=Error +UNUSED_PROBLEM_FILTERS=Warning +automatically_removed_unused_problem_filters=false +changed_execution_env=Error +eclipse.preferences.version=1 +incompatible_api_component_version=Error +incompatible_api_component_version_include_major_without_breaking_change=Disabled +incompatible_api_component_version_include_minor_without_api_change=Disabled +incompatible_api_component_version_report_major_without_breaking_change=Warning +incompatible_api_component_version_report_minor_without_api_change=Warning +invalid_since_tag_version=Error +malformed_since_tag=Error +missing_since_tag=Error +report_api_breakage_when_major_version_incremented=Disabled +report_resolution_errors_api_component=Warning diff --git a/core/org.eclipse.cdt.core.linux.aarch64/.settings/org.eclipse.pde.prefs b/core/org.eclipse.cdt.core.linux.aarch64/.settings/org.eclipse.pde.prefs new file mode 100644 index 00000000000..d2dc703ba9e --- /dev/null +++ b/core/org.eclipse.cdt.core.linux.aarch64/.settings/org.eclipse.pde.prefs @@ -0,0 +1,35 @@ +compilers.f.unresolved-features=1 +compilers.f.unresolved-plugins=1 +compilers.incompatible-environment=1 +compilers.p.build=1 +compilers.p.build.bin.includes=1 +compilers.p.build.encodings=2 +compilers.p.build.java.compiler=2 +compilers.p.build.java.compliance=1 +compilers.p.build.missing.output=2 +compilers.p.build.output.library=1 +compilers.p.build.source.library=1 +compilers.p.build.src.includes=1 +compilers.p.deprecated=1 +compilers.p.discouraged-class=1 +compilers.p.internal=1 +compilers.p.missing-packages=2 +compilers.p.missing-version-export-package=2 +compilers.p.missing-version-import-package=2 +compilers.p.missing-version-require-bundle=2 +compilers.p.no-required-att=0 +compilers.p.no.automatic.module=1 +compilers.p.not-externalized-att=1 +compilers.p.service.component.without.lazyactivation=1 +compilers.p.unknown-attribute=1 +compilers.p.unknown-class=1 +compilers.p.unknown-element=1 +compilers.p.unknown-identifier=1 +compilers.p.unknown-resource=1 +compilers.p.unresolved-ex-points=0 +compilers.p.unresolved-import=0 +compilers.s.create-docs=false +compilers.s.doc-folder=doc +compilers.s.open-tags=1 +compilers.use-project=true +eclipse.preferences.version=1 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 new file mode 100644 index 00000000000..ea7bfc7d50a --- /dev/null +++ b/core/org.eclipse.cdt.core.linux.aarch64/META-INF/MANIFEST.MF @@ -0,0 +1,9 @@ +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.600.qualifier +Bundle-Vendor: %providerName +Fragment-Host: org.eclipse.cdt.core.native;bundle-version="[6.0.0,7.0.0)" +Bundle-Localization: plugin +Eclipse-PlatformFilter: (&(osgi.os=linux)(osgi.arch=aarch64)) diff --git a/core/org.eclipse.cdt.core.linux.aarch64/about.html b/core/org.eclipse.cdt.core.linux.aarch64/about.html new file mode 100644 index 00000000000..b3134865230 --- /dev/null +++ b/core/org.eclipse.cdt.core.linux.aarch64/about.html @@ -0,0 +1,38 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> + +<head> + <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> + <title>About</title> +</head> + +<body lang="EN-US"> + <h2>About This Content</h2> + + <p>November 30, 2017</p> + <h3>License</h3> + + <p> + The Eclipse Foundation makes available all content in this plug-in + ("Content"). Unless otherwise indicated below, the Content + is provided to you under the terms and conditions of the Eclipse + Public License Version 2.0 ("EPL"). A copy of the EPL is + available at <a href="https://www.eclipse.org/legal/epl-2.0">https://www.eclipse.org/legal/epl-2.0</a>. + For purposes of the EPL, "Program" will mean the Content. + </p> + + <p> + If you did not receive this Content directly from the Eclipse + Foundation, the Content is being redistributed by another party + ("Redistributor") and different terms and conditions may + apply to your use of any object code in the Content. Check the + Redistributor's license that was provided with the Content. If no such + license exists, contact the Redistributor. Unless otherwise indicated + below, the terms and conditions of the EPL still apply to any source + code in the Content and such source code may be obtained at <a + href="https://www.eclipse.org/">https://www.eclipse.org</a>. + </p> + +</body> + +</html>
\ No newline at end of file diff --git a/core/org.eclipse.cdt.core.linux.aarch64/build.properties b/core/org.eclipse.cdt.core.linux.aarch64/build.properties new file mode 100644 index 00000000000..d5cafe61924 --- /dev/null +++ b/core/org.eclipse.cdt.core.linux.aarch64/build.properties @@ -0,0 +1,18 @@ +############################################################################### +# Copyright (c) 2005, 2009 IBM Corporation 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: +# IBM Corporation - initial API and implementation +############################################################################### +bin.includes = os/,\ + about.html,\ + META-INF/,\ + plugin.properties +src.includes = about.html diff --git a/core/org.eclipse.cdt.core.linux.aarch64/os/linux/aarch64/libpty.so b/core/org.eclipse.cdt.core.linux.aarch64/os/linux/aarch64/libpty.so Binary files differnew file mode 100755 index 00000000000..3c2ec1047da --- /dev/null +++ b/core/org.eclipse.cdt.core.linux.aarch64/os/linux/aarch64/libpty.so diff --git a/core/org.eclipse.cdt.core.linux.aarch64/os/linux/aarch64/libspawner.so b/core/org.eclipse.cdt.core.linux.aarch64/os/linux/aarch64/libspawner.so Binary files differnew file mode 100755 index 00000000000..a9919b4ca52 --- /dev/null +++ b/core/org.eclipse.cdt.core.linux.aarch64/os/linux/aarch64/libspawner.so diff --git a/core/org.eclipse.cdt.core.linux.aarch64/plugin.properties b/core/org.eclipse.cdt.core.linux.aarch64/plugin.properties new file mode 100644 index 00000000000..9737accb85d --- /dev/null +++ b/core/org.eclipse.cdt.core.linux.aarch64/plugin.properties @@ -0,0 +1,2 @@ +fragmentName.linux.aarch64=C/C++ Development Tools Core for Linux Aarch64 +providerName=Eclipse CDT diff --git a/core/org.eclipse.cdt.core.linux.aarch64/pom.xml b/core/org.eclipse.cdt.core.linux.aarch64/pom.xml new file mode 100644 index 00000000000..fa2d447bccf --- /dev/null +++ b/core/org.eclipse.cdt.core.linux.aarch64/pom.xml @@ -0,0 +1,74 @@ +<?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"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.eclipse.cdt</groupId> + <artifactId>cdt-parent</artifactId> + <version>10.7.0-SNAPSHOT</version> + <relativePath>../../pom.xml</relativePath> + </parent> + + <version>6.0.600-SNAPSHOT</version> + <artifactId>org.eclipse.cdt.core.linux.aarch64</artifactId> + <packaging>eclipse-plugin</packaging> + + <build> + <plugins> + <plugin> + <groupId>org.eclipse.tycho</groupId> + <artifactId>target-platform-configuration</artifactId> + <version>${tycho-version}</version> + <configuration> + <resolver>p2</resolver> + <pomDependencies>consider</pomDependencies> + <environments> + <environment> + <os>linux</os> + <ws>gtk</ws> + <arch>aarch64</arch> + </environment> + </environments> + </configuration> + </plugin> + <plugin> + <groupId>org.eclipse.tycho</groupId> + <artifactId>tycho-source-plugin</artifactId> + <version>${tycho-version}</version> + <executions> + <execution> + <id>plugin-source</id> + <phase>none</phase> + </execution> + <execution> + <id>attach-source</id> + <phase>none</phase> + </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/.settings/org.eclipse.core.resources.prefs b/core/org.eclipse.cdt.core.linux.ppc64le/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 00000000000..99f26c0203a --- /dev/null +++ b/core/org.eclipse.cdt.core.linux.ppc64le/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/<project>=UTF-8 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 7586bdce61d..f8488d7e43d 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.0.qualifier +Bundle-Version: 6.0.600.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/about.html b/core/org.eclipse.cdt.core.linux.ppc64le/about.html index 164f781a8fd..b3134865230 100644 --- a/core/org.eclipse.cdt.core.linux.ppc64le/about.html +++ b/core/org.eclipse.cdt.core.linux.ppc64le/about.html @@ -1,10 +1,11 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> + <head> -<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> -<title>About</title> + <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> + <title>About</title> </head> + <body lang="EN-US"> <h2>About This Content</h2> @@ -16,7 +17,7 @@ ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 ("EPL"). A copy of the EPL is - available at <a href="http://www.eclipse.org/legal/epl-2.0">http://www.eclipse.org/legal/epl-2.0</a>. + available at <a href="https://www.eclipse.org/legal/epl-2.0">https://www.eclipse.org/legal/epl-2.0</a>. For purposes of the EPL, "Program" will mean the Content. </p> @@ -29,8 +30,9 @@ license exists, contact the Redistributor. Unless otherwise indicated below, the terms and conditions of the EPL still apply to any source code in the Content and such source code may be obtained at <a - href="http://www.eclipse.org/">http://www.eclipse.org</a>. + href="https://www.eclipse.org/">https://www.eclipse.org</a>. </p> </body> + </html>
\ No newline at end of file diff --git a/core/org.eclipse.cdt.core.linux.ppc64le/build.properties b/core/org.eclipse.cdt.core.linux.ppc64le/build.properties index ab271c792ff..345f7ca9fb0 100644 --- a/core/org.eclipse.cdt.core.linux.ppc64le/build.properties +++ b/core/org.eclipse.cdt.core.linux.ppc64le/build.properties @@ -13,6 +13,6 @@ ############################################################################### bin.includes = os/,\ about.html,\ - META-INF/\, + META-INF/,\ plugin.properties src.includes = about.html diff --git a/core/org.eclipse.cdt.core.linux.ppc64le/os/linux/ppc64le/libpty.so b/core/org.eclipse.cdt.core.linux.ppc64le/os/linux/ppc64le/libpty.so Binary files differindex 1d73a55cb16..d59d51b7452 100755 --- a/core/org.eclipse.cdt.core.linux.ppc64le/os/linux/ppc64le/libpty.so +++ b/core/org.eclipse.cdt.core.linux.ppc64le/os/linux/ppc64le/libpty.so diff --git a/core/org.eclipse.cdt.core.linux.ppc64le/os/linux/ppc64le/libspawner.so b/core/org.eclipse.cdt.core.linux.ppc64le/os/linux/ppc64le/libspawner.so Binary files differindex 524114fa73a..cddfefcb258 100755 --- a/core/org.eclipse.cdt.core.linux.ppc64le/os/linux/ppc64le/libspawner.so +++ b/core/org.eclipse.cdt.core.linux.ppc64le/os/linux/ppc64le/libspawner.so diff --git a/core/org.eclipse.cdt.core.linux.ppc64le/pom.xml b/core/org.eclipse.cdt.core.linux.ppc64le/pom.xml index d0732049018..ed762c94e10 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.0.0-SNAPSHOT</version> + <version>10.7.0-SNAPSHOT</version> <relativePath>../../pom.xml</relativePath> </parent> - <version>6.0.0-SNAPSHOT</version> + <version>6.0.600-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/.settings/org.eclipse.core.resources.prefs b/core/org.eclipse.cdt.core.linux.x86_64/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 00000000000..99f26c0203a --- /dev/null +++ b/core/org.eclipse.cdt.core.linux.x86_64/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/<project>=UTF-8 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 14eabee4ac0..1f09d4b0134 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.0.qualifier +Bundle-Version: 6.0.600.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/about.html b/core/org.eclipse.cdt.core.linux.x86_64/about.html index 164f781a8fd..b3134865230 100644 --- a/core/org.eclipse.cdt.core.linux.x86_64/about.html +++ b/core/org.eclipse.cdt.core.linux.x86_64/about.html @@ -1,10 +1,11 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> + <head> -<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> -<title>About</title> + <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> + <title>About</title> </head> + <body lang="EN-US"> <h2>About This Content</h2> @@ -16,7 +17,7 @@ ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 ("EPL"). A copy of the EPL is - available at <a href="http://www.eclipse.org/legal/epl-2.0">http://www.eclipse.org/legal/epl-2.0</a>. + available at <a href="https://www.eclipse.org/legal/epl-2.0">https://www.eclipse.org/legal/epl-2.0</a>. For purposes of the EPL, "Program" will mean the Content. </p> @@ -29,8 +30,9 @@ license exists, contact the Redistributor. Unless otherwise indicated below, the terms and conditions of the EPL still apply to any source code in the Content and such source code may be obtained at <a - href="http://www.eclipse.org/">http://www.eclipse.org</a>. + href="https://www.eclipse.org/">https://www.eclipse.org</a>. </p> </body> + </html>
\ No newline at end of file diff --git a/core/org.eclipse.cdt.core.linux.x86_64/build.properties b/core/org.eclipse.cdt.core.linux.x86_64/build.properties index 1ad6c2e0ed7..d5cafe61924 100644 --- a/core/org.eclipse.cdt.core.linux.x86_64/build.properties +++ b/core/org.eclipse.cdt.core.linux.x86_64/build.properties @@ -13,6 +13,6 @@ ############################################################################### bin.includes = os/,\ about.html,\ - META-INF/\, + META-INF/,\ plugin.properties src.includes = about.html diff --git a/core/org.eclipse.cdt.core.linux.x86_64/os/linux/x86_64/libpty.so b/core/org.eclipse.cdt.core.linux.x86_64/os/linux/x86_64/libpty.so Binary files differindex 587fa695259..cfd41f315e8 100644..100755 --- a/core/org.eclipse.cdt.core.linux.x86_64/os/linux/x86_64/libpty.so +++ b/core/org.eclipse.cdt.core.linux.x86_64/os/linux/x86_64/libpty.so diff --git a/core/org.eclipse.cdt.core.linux.x86_64/os/linux/x86_64/libspawner.so b/core/org.eclipse.cdt.core.linux.x86_64/os/linux/x86_64/libspawner.so Binary files differindex 18736e10a2c..476ea56bdc0 100644..100755 --- a/core/org.eclipse.cdt.core.linux.x86_64/os/linux/x86_64/libspawner.so +++ b/core/org.eclipse.cdt.core.linux.x86_64/os/linux/x86_64/libspawner.so 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 f525efb4fff..0afb2ce29c6 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.0.0-SNAPSHOT</version> + <version>10.7.0-SNAPSHOT</version> <relativePath>../../pom.xml</relativePath> </parent> - <version>6.0.0-SNAPSHOT</version> + <version>6.0.600-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/.classpath b/core/org.eclipse.cdt.core.linux/.classpath index 01836c4842f..e801ebfb468 100644 --- a/core/org.eclipse.cdt.core.linux/.classpath +++ b/core/org.eclipse.cdt.core.linux/.classpath @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> - <classpathentry kind="src" path="src"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> + <classpathentry kind="src" path="src"/> <classpathentry kind="output" path="bin"/> </classpath> diff --git a/core/org.eclipse.cdt.core.linux/.project b/core/org.eclipse.cdt.core.linux/.project index 8e8b3560544..eeec452f97b 100644 --- a/core/org.eclipse.cdt.core.linux/.project +++ b/core/org.eclipse.cdt.core.linux/.project @@ -20,9 +20,15 @@ <arguments> </arguments> </buildCommand> + <buildCommand> + <name>org.eclipse.pde.api.tools.apiAnalysisBuilder</name> + <arguments> + </arguments> + </buildCommand> </buildSpec> <natures> <nature>org.eclipse.jdt.core.javanature</nature> <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature> </natures> </projectDescription> diff --git a/core/org.eclipse.cdt.core.linux/.settings/org.eclipse.core.resources.prefs b/core/org.eclipse.cdt.core.linux/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 00000000000..99f26c0203a --- /dev/null +++ b/core/org.eclipse.cdt.core.linux/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/<project>=UTF-8 diff --git a/core/org.eclipse.cdt.core.linux/.settings/org.eclipse.jdt.core.prefs b/core/org.eclipse.cdt.core.linux/.settings/org.eclipse.jdt.core.prefs index 2b6ecff8a01..e3a8104f9ca 100644 --- a/core/org.eclipse.cdt.core.linux/.settings/org.eclipse.jdt.core.prefs +++ b/core/org.eclipse.cdt.core.linux/.settings/org.eclipse.jdt.core.prefs @@ -30,9 +30,9 @@ org.eclipse.jdt.core.compiler.annotation.nullable.secondary= org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.methodParameters=generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.compliance=11 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -49,6 +49,7 @@ org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled org.eclipse.jdt.core.compiler.problem.discouragedReference=warning org.eclipse.jdt.core.compiler.problem.emptyStatement=warning +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning @@ -107,6 +108,7 @@ org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=igno org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled @@ -144,13 +146,14 @@ org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.release=disabled -org.eclipse.jdt.core.compiler.source=1.8 +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=11 org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns=false org.eclipse.jdt.core.formatter.align_with_spaces=false +org.eclipse.jdt.core.formatter.alignment_for_additive_operator=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 @@ -158,21 +161,24 @@ org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_c org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_assignment=0 -org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_bitwise_operator=16 org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 org.eclipse.jdt.core.formatter.alignment_for_compact_loops=16 org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 org.eclipse.jdt.core.formatter.alignment_for_enum_constants=16 org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0 +org.eclipse.jdt.core.formatter.alignment_for_logical_operator=16 org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 org.eclipse.jdt.core.formatter.alignment_for_module_statements=16 org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_multiplicative_operator=16 org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_string_concatenation=16 org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 @@ -264,11 +270,12 @@ org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_after_additive_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_bitwise_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert @@ -299,6 +306,8 @@ org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_after_logical_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_multiplicative_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert @@ -323,13 +332,17 @@ org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_relational_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert +org.eclipse.jdt.core.formatter.insert_space_after_shift_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_string_concatenation=insert org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_additive_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_bitwise_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert @@ -377,6 +390,8 @@ org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do no org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_before_logical_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_multiplicative_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert @@ -413,9 +428,12 @@ org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not inser org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_relational_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_shift_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_string_concatenation=insert org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert @@ -454,10 +472,14 @@ org.eclipse.jdt.core.formatter.tabulation.char=tab org.eclipse.jdt.core.formatter.tabulation.size=4 org.eclipse.jdt.core.formatter.use_on_off_tags=true org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false +org.eclipse.jdt.core.formatter.wrap_before_additive_operator=true org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false -org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true +org.eclipse.jdt.core.formatter.wrap_before_bitwise_operator=true org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true +org.eclipse.jdt.core.formatter.wrap_before_logical_operator=true +org.eclipse.jdt.core.formatter.wrap_before_multiplicative_operator=true org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true +org.eclipse.jdt.core.formatter.wrap_before_string_concatenation=true org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true org.eclipse.jdt.core.incompatibleJDKLevel=ignore org.eclipse.jdt.core.incompleteClasspath=error diff --git a/core/org.eclipse.cdt.core.linux/.settings/org.eclipse.jdt.ui.prefs b/core/org.eclipse.cdt.core.linux/.settings/org.eclipse.jdt.ui.prefs index e44576346c4..d35ba9b5231 100644 --- a/core/org.eclipse.cdt.core.linux/.settings/org.eclipse.jdt.ui.prefs +++ b/core/org.eclipse.cdt.core.linux/.settings/org.eclipse.jdt.ui.prefs @@ -1,3 +1,4 @@ +cleanup.add_all=false cleanup.add_default_serial_version_id=true cleanup.add_generated_serial_version_id=false cleanup.add_missing_annotations=true @@ -11,25 +12,72 @@ cleanup.always_use_blocks=true cleanup.always_use_parentheses_in_expressions=false cleanup.always_use_this_for_non_static_field_access=false cleanup.always_use_this_for_non_static_method_access=false +cleanup.array_with_curly=false +cleanup.arrays_fill=false +cleanup.bitwise_conditional_expression=false +cleanup.boolean_literal=false +cleanup.boolean_value_rather_than_comparison=false +cleanup.break_loop=false +cleanup.collection_cloning=false +cleanup.comparing_on_criteria=false +cleanup.comparison_statement=false +cleanup.controlflow_merge=false cleanup.convert_functional_interfaces=false cleanup.convert_to_enhanced_for_loop=false +cleanup.convert_to_enhanced_for_loop_if_loop_var_used=true +cleanup.convert_to_switch_expressions=false cleanup.correct_indentation=false +cleanup.do_while_rather_than_while=true +cleanup.double_negation=false +cleanup.else_if=false +cleanup.embedded_if=false +cleanup.evaluate_nullable=false +cleanup.extract_increment=false cleanup.format_source_code=true cleanup.format_source_code_changes_only=false +cleanup.hash=false +cleanup.if_condition=false cleanup.insert_inferred_type_arguments=false +cleanup.instanceof=false +cleanup.instanceof_keyword=false +cleanup.invert_equals=false +cleanup.join=false +cleanup.lazy_logical_operator=false cleanup.make_local_variable_final=true cleanup.make_parameters_final=false cleanup.make_private_fields_final=true cleanup.make_type_abstract_if_missing_method=false cleanup.make_variable_declarations_final=false +cleanup.map_cloning=false +cleanup.merge_conditional_blocks=false +cleanup.multi_catch=false cleanup.never_use_blocks=false cleanup.never_use_parentheses_in_expressions=true +cleanup.no_string_creation=false +cleanup.no_super=false +cleanup.number_suffix=false +cleanup.objects_equals=false +cleanup.one_if_rather_than_duplicate_blocks_that_fall_through=false +cleanup.operand_factorization=false cleanup.organize_imports=true +cleanup.overridden_assignment=false +cleanup.plain_replacement=false +cleanup.precompile_regex=false +cleanup.primitive_comparison=false +cleanup.primitive_parsing=false +cleanup.primitive_rather_than_wrapper=false +cleanup.primitive_serialization=false +cleanup.pull_out_if_from_if_else=false +cleanup.pull_up_assignment=false +cleanup.push_down_negation=false cleanup.qualify_static_field_accesses_with_declaring_class=false cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true cleanup.qualify_static_member_accesses_with_declaring_class=false cleanup.qualify_static_method_accesses_with_declaring_class=false +cleanup.reduce_indentation=false +cleanup.redundant_comparator=false +cleanup.redundant_falling_through_block_end=false cleanup.remove_private_constructors=true cleanup.remove_redundant_modifiers=false cleanup.remove_redundant_semicolons=true @@ -37,25 +85,57 @@ cleanup.remove_redundant_type_arguments=true cleanup.remove_trailing_whitespaces=true cleanup.remove_trailing_whitespaces_all=true cleanup.remove_trailing_whitespaces_ignore_empty=false +cleanup.remove_unnecessary_array_creation=false cleanup.remove_unnecessary_casts=true cleanup.remove_unnecessary_nls_tags=false cleanup.remove_unused_imports=true cleanup.remove_unused_local_variables=false +cleanup.remove_unused_method_parameters=false cleanup.remove_unused_private_fields=true cleanup.remove_unused_private_members=false cleanup.remove_unused_private_methods=true cleanup.remove_unused_private_types=true +cleanup.return_expression=false +cleanup.simplify_lambda_expression_and_method_ref=false +cleanup.single_used_field=false cleanup.sort_members=false cleanup.sort_members_all=false +cleanup.standard_comparison=false +cleanup.static_inner_class=false +cleanup.strictly_equal_or_different=false +cleanup.stringbuffer_to_stringbuilder=false +cleanup.stringbuilder=false +cleanup.stringbuilder_for_local_vars=true +cleanup.stringconcat_to_textblock=false +cleanup.substring=false +cleanup.switch=false +cleanup.system_property=false +cleanup.system_property_boolean=false +cleanup.system_property_file_encoding=false +cleanup.system_property_file_separator=false +cleanup.system_property_line_separator=false +cleanup.system_property_path_separator=false +cleanup.ternary_operator=false +cleanup.try_with_resource=false +cleanup.unlooped_while=false +cleanup.unreachable_block=false cleanup.use_anonymous_class_creation=false +cleanup.use_autoboxing=false cleanup.use_blocks=false cleanup.use_blocks_only_for_return_and_throw=false +cleanup.use_directly_map_method=false cleanup.use_lambda=true cleanup.use_parentheses_in_expressions=false +cleanup.use_string_is_blank=false cleanup.use_this_for_non_static_field_access=false cleanup.use_this_for_non_static_field_access_only_if_necessary=true cleanup.use_this_for_non_static_method_access=false cleanup.use_this_for_non_static_method_access_only_if_necessary=true +cleanup.use_unboxing=false +cleanup.use_var=false +cleanup.useless_continue=false +cleanup.useless_return=false +cleanup.valueof_rather_than_instantiation=false cleanup_profile=_CDT cleanup_settings_version=2 eclipse.preferences.version=1 diff --git a/core/org.eclipse.cdt.core.linux/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.core.linux/META-INF/MANIFEST.MF index c7f4b92d61e..c5eb9f3d7e4 100644 --- a/core/org.eclipse.cdt.core.linux/META-INF/MANIFEST.MF +++ b/core/org.eclipse.cdt.core.linux/META-INF/MANIFEST.MF @@ -2,10 +2,10 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %fragmentName.linux Bundle-SymbolicName: org.eclipse.cdt.core.linux; singleton:=true -Bundle-Version: 6.0.0.qualifier +Bundle-Version: 6.0.100.qualifier Bundle-Vendor: %providerName Fragment-Host: org.eclipse.cdt.core.native;bundle-version="[6.0.0,7.0.0)" Bundle-Localization: plugin -Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Bundle-RequiredExecutionEnvironment: JavaSE-11 Eclipse-PlatformFilter: (osgi.os=linux) Automatic-Module-Name: org.eclipse.cdt.core.linux diff --git a/core/org.eclipse.cdt.core.linux/about.html b/core/org.eclipse.cdt.core.linux/about.html index 164f781a8fd..b3134865230 100644 --- a/core/org.eclipse.cdt.core.linux/about.html +++ b/core/org.eclipse.cdt.core.linux/about.html @@ -1,10 +1,11 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> + <head> -<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> -<title>About</title> + <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> + <title>About</title> </head> + <body lang="EN-US"> <h2>About This Content</h2> @@ -16,7 +17,7 @@ ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 ("EPL"). A copy of the EPL is - available at <a href="http://www.eclipse.org/legal/epl-2.0">http://www.eclipse.org/legal/epl-2.0</a>. + available at <a href="https://www.eclipse.org/legal/epl-2.0">https://www.eclipse.org/legal/epl-2.0</a>. For purposes of the EPL, "Program" will mean the Content. </p> @@ -29,8 +30,9 @@ license exists, contact the Redistributor. Unless otherwise indicated below, the terms and conditions of the EPL still apply to any source code in the Content and such source code may be obtained at <a - href="http://www.eclipse.org/">http://www.eclipse.org</a>. + href="https://www.eclipse.org/">https://www.eclipse.org</a>. </p> </body> + </html>
\ No newline at end of file diff --git a/core/org.eclipse.cdt.core.linux/build.properties b/core/org.eclipse.cdt.core.linux/build.properties index 587895eb060..833b5a7e6f6 100644 --- a/core/org.eclipse.cdt.core.linux/build.properties +++ b/core/org.eclipse.cdt.core.linux/build.properties @@ -16,6 +16,5 @@ bin.includes = fragment.xml,\ .,\ META-INF/,\ plugin.properties -src.includes = about.html,\ - library/ +src.includes = about.html source.. = src/ diff --git a/core/org.eclipse.cdt.core.linux/library/Makefile b/core/org.eclipse.cdt.core.linux/library/Makefile deleted file mode 100644 index 508cb455a41..00000000000 --- a/core/org.eclipse.cdt.core.linux/library/Makefile +++ /dev/null @@ -1,44 +0,0 @@ -# makefile for libspawner.so - -ifeq ($(JAVA_HOME),) -$(warning JAVA_HOME not set in environment) -endif - -# Defaults which can be overridden. -OS = linux -ARCH = x86_64 - -JDK_INCLUDES= $(JAVA_HOME)/include -JDK_OS_INCLUDES= $(JAVA_HOME)/include/$(OS) - -CC=gcc -CPPFLAGS = -I. -I$(JDK_INCLUDES) -I$(JDK_OS_INCLUDES) -CFLAGS +=-fpic -D_REENTRANT -D_GNU_SOURCE - -INSTALL_DIR = ../../org.eclipse.cdt.core.linux.$(ARCH)/os/$(OS)/$(ARCH) - -LIB_NAME_SPAWNER = libspawner.so -LIB_NAME_FULL_SPAWNER = $(INSTALL_DIR)/libspawner.so -OBJS_SPAWNER=spawner.o io.o exec_unix.o exec_pty.o pfind.o openpty.o - -LIB_NAME_PTY = libpty.so -LIB_NAME_FULL_PTY = $(INSTALL_DIR)/libpty.so -OBJS_PTY= openpty.o pty.o ptyio.o - -OBJS = $(OBJS_SPAWNER) $(OBJS_PTY) - -all: $(LIB_NAME_FULL_SPAWNER) $(LIB_NAME_FULL_PTY) - -rebuild: clean all - -$(LIB_NAME_FULL_SPAWNER) : $(OBJS_SPAWNER) - mkdir -p $(INSTALL_DIR) - $(CC) -g -shared -Wl,-soname,$(LIB_NAME_SPAWNER) $(LDFLAGS) -o $(LIB_NAME_FULL_SPAWNER) $(OBJS_SPAWNER) -lc - -$(LIB_NAME_FULL_PTY): $(OBJS_PTY) - mkdir -p $(INSTALL_DIR) - $(CC) -g -shared -Wl,-soname,$(LIB_NAME_PTY) $(LDFLAGS) -o $(LIB_NAME_FULL_PTY) $(OBJS_PTY) - -clean : - $(RM) $(OBJS_SPAWNER) $(LIB_NAME_FULL_SPAWNER) - $(RM) $(OBJS_PTY) $(LIB_NAME_FULL_PTY) diff --git a/core/org.eclipse.cdt.core.linux/library/PTY.h b/core/org.eclipse.cdt.core.linux/library/PTY.h deleted file mode 100644 index f717942a01d..00000000000 --- a/core/org.eclipse.cdt.core.linux/library/PTY.h +++ /dev/null @@ -1,29 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include <jni.h> -/* Header for class org_eclipse_cdt_utils_pty_PTY */ - -#ifndef _Included_org_eclipse_cdt_utils_pty_PTY -#define _Included_org_eclipse_cdt_utils_pty_PTY -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: org_eclipse_cdt_utils_pty_PTY - * Method: openMaster - * Signature: (Z)Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL Java_org_eclipse_cdt_utils_pty_PTY_openMaster - (JNIEnv *, jobject, jboolean); - -/* - * Class: org_eclipse_cdt_utils_pty_PTY - * Method: change_window_size - * Signature: (III)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTY_change_1window_1size - (JNIEnv *, jobject, jint, jint, jint); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/core/org.eclipse.cdt.core.linux/library/PTYInputStream.h b/core/org.eclipse.cdt.core.linux/library/PTYInputStream.h deleted file mode 100644 index e7349272b56..00000000000 --- a/core/org.eclipse.cdt.core.linux/library/PTYInputStream.h +++ /dev/null @@ -1,32 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include <jni.h> -/* Header for class org_eclipse_cdt_utils_pty_PTYInputStream */ - -#ifndef _Included_org_eclipse_cdt_utils_pty_PTYInputStream -#define _Included_org_eclipse_cdt_utils_pty_PTYInputStream -#ifdef __cplusplus -extern "C" { -#endif -#undef org_eclipse_cdt_utils_pty_PTYInputStream_SKIP_BUFFER_SIZE -#define org_eclipse_cdt_utils_pty_PTYInputStream_SKIP_BUFFER_SIZE 2048L -/* Inaccessible static: skipBuffer */ -/* - * Class: org_eclipse_cdt_utils_pty_PTYInputStream - * Method: read0 - * Signature: (I[BI)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTYInputStream_read0 - (JNIEnv *, jobject, jint, jbyteArray, jint); - -/* - * Class: org_eclipse_cdt_utils_pty_PTYInputStream - * Method: close0 - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTYInputStream_close0 - (JNIEnv *, jobject, jint); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/core/org.eclipse.cdt.core.linux/library/PTYOutputStream.h b/core/org.eclipse.cdt.core.linux/library/PTYOutputStream.h deleted file mode 100644 index fb28491060e..00000000000 --- a/core/org.eclipse.cdt.core.linux/library/PTYOutputStream.h +++ /dev/null @@ -1,29 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include <jni.h> -/* Header for class org_eclipse_cdt_utils_pty_PTYOutputStream */ - -#ifndef _Included_org_eclipse_cdt_utils_pty_PTYOutputStream -#define _Included_org_eclipse_cdt_utils_pty_PTYOutputStream -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: org_eclipse_cdt_utils_pty_PTYOutputStream - * Method: write0 - * Signature: (I[BI)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTYOutputStream_write0 - (JNIEnv *, jobject, jint, jbyteArray, jint); - -/* - * Class: org_eclipse_cdt_utils_pty_PTYOutputStream - * Method: close0 - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTYOutputStream_close0 - (JNIEnv *, jobject, jint); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/core/org.eclipse.cdt.core.linux/library/Spawner.h b/core/org.eclipse.cdt.core.linux/library/Spawner.h deleted file mode 100644 index 02727f98a88..00000000000 --- a/core/org.eclipse.cdt.core.linux/library/Spawner.h +++ /dev/null @@ -1,53 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include <jni.h> -/* Header for class org_eclipse_cdt_utils_spawner_Spawner */ - -#ifndef _Included_org_eclipse_cdt_utils_spawner_Spawner -#define _Included_org_eclipse_cdt_utils_spawner_Spawner -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: org_eclipse_cdt_utils_spawner_Spawner - * Method: exec0 - * Signature: ([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[I)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec0 - (JNIEnv *, jobject, jobjectArray, jobjectArray, jstring, jintArray); - -/* - * Class: org_eclipse_cdt_utils_spawner_Spawner - * Method: exec1 - * Signature: ([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec1 - (JNIEnv *, jobject, jobjectArray, jobjectArray, jstring); - -/* - * Class: org_eclipse_cdt_utils_spawner_Spawner - * Method: exec2 - * Signature: ([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[ILjava/lang/String;IZ)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec2 - (JNIEnv *, jobject, jobjectArray, jobjectArray, jstring, jintArray, jstring, jint, jboolean); - -/* - * Class: org_eclipse_cdt_utils_spawner_Spawner - * Method: raise - * Signature: (II)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_raise - (JNIEnv *, jobject, jint, jint); - -/* - * Class: org_eclipse_cdt_utils_spawner_Spawner - * Method: waitFor - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_waitFor - (JNIEnv *, jobject, jint); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/core/org.eclipse.cdt.core.linux/library/SpawnerInputStream.h b/core/org.eclipse.cdt.core.linux/library/SpawnerInputStream.h deleted file mode 100644 index ecf8f8c6a78..00000000000 --- a/core/org.eclipse.cdt.core.linux/library/SpawnerInputStream.h +++ /dev/null @@ -1,32 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include <jni.h> -/* Header for class com_qnx_tools_utils_spawner_SpawnerInputStream */ - -#ifndef _Included_com_qnx_tools_utils_spawner_SpawnerInputStream -#define _Included_com_qnx_tools_utils_spawner_SpawnerInputStream -#ifdef __cplusplus -extern "C" { -#endif -#undef com_qnx_tools_utils_spawner_SpawnerInputStream_SKIP_BUFFER_SIZE -#define com_qnx_tools_utils_spawner_SpawnerInputStream_SKIP_BUFFER_SIZE 2048L -/* Inaccessible static: skipBuffer */ -/* - * Class: org_elipse_cdt_utils_spawner_SpawnerInputStream - * Method: read0 - * Signature: (I[BI)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_read0 - (JNIEnv *, jobject, jint, jbyteArray, jint); - -/* - * Class: org_eclipse_cdt_utils_spawner_SpawnerInputStream - * Method: close0 - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_close0 - (JNIEnv *, jobject, jint); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/core/org.eclipse.cdt.core.linux/library/SpawnerOutputStream.h b/core/org.eclipse.cdt.core.linux/library/SpawnerOutputStream.h deleted file mode 100644 index 444d71c698c..00000000000 --- a/core/org.eclipse.cdt.core.linux/library/SpawnerOutputStream.h +++ /dev/null @@ -1,29 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include <jni.h> -/* Header for class com_qnx_tools_utils_spawner_SpawnerOutputStream */ - -#ifndef _Included_com_qnx_tools_utils_spawner_SpawnerOutputStream -#define _Included_com_qnx_tools_utils_spawner_SpawnerOutputStream -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: org_eclipse_cdt_utils_spawner_SpawnerOutputStream - * Method: write0 - * Signature: (I[BI)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerOutputStream_write0 - (JNIEnv *, jobject, jint, jbyteArray, jint); - -/* - * Class: org_eclipse_cdt_utils_spawner_SpawnerOutputStream - * Method: close0 - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerOutputStream_close0 - (JNIEnv *, jobject, jint); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/core/org.eclipse.cdt.core.linux/library/exec_pty.c b/core/org.eclipse.cdt.core.linux/library/exec_pty.c deleted file mode 100644 index e020053db41..00000000000 --- a/core/org.eclipse.cdt.core.linux/library/exec_pty.c +++ /dev/null @@ -1,189 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2010 QNX Software Systems 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: - * QNX Software Systems - initial API and implementation - * Wind River Systems, Inc. - * Mikhail Zabaluev (Nokia) - bug 82744 - * Mikhail Sennikovsky - bug 145737 - *******************************************************************************/ -#include "exec0.h" -#include "openpty.h" -#include <unistd.h> -#include <stdlib.h> -#include <stdio.h> -#include <errno.h> -#include <string.h> -#include <libgen.h> -#include <stdlib.h> -#include <termios.h> - -/* from pfind.c */ -extern char *pfind(const char *name, char * const envp[]); - -pid_t -exec_pty(const char *path, char *const argv[], char *const envp[], - const char *dirpath, int channels[3], const char *pts_name, int fdm, int console) -{ - int pipe2[2]; - pid_t childpid; - char *full_path; - - /* - * We use pfind() to check that the program exists and is an executable. - * If not pass the error up. Also execve() wants a full path. - */ - full_path = pfind(path, envp); - if (full_path == NULL) { - fprintf(stderr, "Unable to find full path for \"%s\"\n", (path) ? path : ""); - return -1; - } - - /* - * Make sure we can create our pipes before forking. - */ - if (channels != NULL && console) { - if (pipe(pipe2) < 0) { - fprintf(stderr, "%s(%d): returning due to error: %s\n", __FUNCTION__, __LINE__, strerror(errno)); - free(full_path); - return -1; - } - } - - childpid = fork(); - - if (childpid < 0) { - fprintf(stderr, "%s(%d): returning due to error: %s\n", __FUNCTION__, __LINE__, strerror(errno)); - free(full_path); - return -1; - } else if (childpid == 0) { /* child */ - - chdir(dirpath); - - if (channels != NULL) { - int fds; - - if (!console && setsid() < 0) { - perror("setsid()"); - return -1; - } - - fds = ptys_open(fdm, pts_name); - if (fds < 0) { - fprintf(stderr, "%s(%d): returning due to error: %s\n", __FUNCTION__, __LINE__, strerror(errno)); - return -1; - } - - /* Close the read end of pipe2 */ - if (console && close(pipe2[0]) == -1) { - perror("close(pipe2[0]))"); - } - - /* close the master, no need in the child */ - close(fdm); - - if (console) { - set_noecho(fds); - if (setpgid(getpid(), getpid()) < 0) { - perror("setpgid()"); - return -1; - } - } - - /* redirections */ - dup2(fds, STDIN_FILENO); /* dup stdin */ - dup2(fds, STDOUT_FILENO); /* dup stdout */ - if (console) { - dup2(pipe2[1], STDERR_FILENO); /* dup stderr */ - } else { - dup2(fds, STDERR_FILENO); /* dup stderr */ - } - close(fds); /* done with fds. */ - } - - /* Close all the fd's in the child */ - { - int fdlimit = sysconf(_SC_OPEN_MAX); - int fd = 3; - - while (fd < fdlimit) - close(fd++); - } - - if (envp[0] == NULL) { - execv(full_path, argv); - } else { - execve(full_path, argv, envp); - } - - _exit(127); - - } else if (childpid != 0) { /* parent */ - if (console) { - set_noecho(fdm); - } - if (channels != NULL) { - channels[0] = fdm; /* Input Stream. */ - channels[1] = fdm; /* Output Stream. */ - if (console) { - /* close the write end of pipe1 */ - if (close(pipe2[1]) == -1) - perror("close(pipe2[1])"); - channels[2] = pipe2[0]; /* stderr Stream. */ - } else { - channels[2] = fdm; /* Error Stream. */ - } - } - - free(full_path); - return childpid; - } - - free(full_path); - return -1; /*NOT REACHED */ -} -#ifdef __STAND_ALONE__ -int main(int argc, char **argv, char **envp) { - const char *path = "./bufferring_test"; - int channels[3] = { -1, -1, -1}; - int status; - FILE *app_stdin; - FILE *app_stdout; - FILE *app_stderr; - char pts_name[32]; - int fdm; - char buffer[32]; - - fdm = ptym_open(pts_name); - status = exec_pty(path, argv, envp, ".", channels, pts_name, fdm); - if (status >= 0) { - app_stdin = fdopen(channels[0], "w"); - app_stdout = fdopen(channels[1], "r"); - app_stderr = fdopen(channels[2], "r"); - if (app_stdout == NULL || app_stderr == NULL || app_stdin == NULL) { - fprintf(stderr, "PROBLEMS\n"); - } else { - fputs("foo\n", app_stdin); - fputs("bar\n", app_stdin); - while(fgets(buffer, sizeof buffer, app_stdout) != NULL) { - fprintf(stdout, "STDOUT: %s\n", buffer); - } - while(fgets(buffer, sizeof buffer, app_stderr) != NULL) { - fprintf(stdout, "STDERR: %s\n", buffer); - } - } - } - fputs("bye\n", stdout); - close(channels[0]); - close(channels[1]); - close(channels[2]); - return 0; -} -#endif diff --git a/core/org.eclipse.cdt.core.linux/library/exec_unix.c b/core/org.eclipse.cdt.core.linux/library/exec_unix.c deleted file mode 100644 index 4feb805f15d..00000000000 --- a/core/org.eclipse.cdt.core.linux/library/exec_unix.c +++ /dev/null @@ -1,161 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2010 QNX Software Systems 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: - * QNX Software Systems - initial API and implementation - * Wind River Systems, Inc. - * Mikhail Sennikovsky - bug 145737 - *******************************************************************************/ -#include "exec0.h" -#include <unistd.h> -#include <stdlib.h> -#include <stdio.h> -#include <errno.h> -#include <string.h> -#include <libgen.h> -#include <stdlib.h> - -/* from pfind.c */ -extern char *pfind(const char *name, char * const envp[]); - -pid_t -exec0(const char *path, char *const argv[], char *const envp[], - const char *dirpath, int channels[3]) -{ - int pipe0[2], pipe1[2], pipe2[2]; - pid_t childpid; - char *full_path; - - /* - * We use pfind() to check that the program exists and is an executable. - * If not pass the error up. Also execve() wants a full path. - */ - full_path = pfind(path, envp); - if (full_path == NULL) { - fprintf(stderr, "Unable to find full path for \"%s\"\n", (path) ? path : ""); - return -1; - } - - /* - * Make sure we can create our pipes before forking. - */ - if (channels != NULL) { - if (pipe(pipe0) < 0 || pipe(pipe1) < 0 || pipe(pipe2) < 0) { - fprintf(stderr, "%s(%d): returning due to error.\n", - __FUNCTION__, __LINE__); - free(full_path); - return -1; - } - } - - childpid = fork(); - - if (childpid < 0) { - fprintf(stderr, "%s(%d): returning due to error: %s\n", - __FUNCTION__, __LINE__, strerror(errno)); - free(full_path); - return -1; - } else if (childpid == 0) { /* child */ - char *ptr; - - chdir(dirpath); - - if (channels != NULL) { - /* Close the write end of pipe0 */ - if (close(pipe0[1]) == -1) - perror("close(pipe0[1])"); - - /* Close the read end of pipe1 */ - if (close(pipe1[0]) == -1) - perror("close(pipe1[0])"); - - /* Close the read end of pipe2 */ - if (close(pipe2[0]) == -1) - perror("close(pipe2[0]))"); - - /* redirections */ - dup2(pipe0[0], STDIN_FILENO); /* dup stdin */ - dup2(pipe1[1], STDOUT_FILENO); /* dup stdout */ - dup2(pipe2[1], STDERR_FILENO); /* dup stderr */ - } - - /* Close all the fd's in the child */ - { - int fdlimit = sysconf(_SC_OPEN_MAX); - int fd = 3; - - while (fd < fdlimit) - close(fd++); - } - - setpgid(getpid(), getpid()); - - if (envp[0] == NULL) { - execv(full_path, argv); - } else { - execve(full_path, argv, envp); - } - - _exit(127); - - } else if (childpid != 0) { /* parent */ - - char b; - - if (channels != NULL) { - /* close the read end of pipe1 */ - if (close(pipe0[0]) == -1) - perror("close(pipe0[0])"); - - /* close the write end of pipe2 */ - if (close(pipe1[1]) == -1) - perror("close(pipe1[1])"); - - /* close the write end of pipe2 */ - if (close(pipe2[1]) == -1) - perror("close(pipe2[1])"); - - channels[0] = pipe0[1]; /* Output Stream. */ - channels[1] = pipe1[0]; /* Input Stream. */ - channels[2] = pipe2[0]; /* Input Stream. */ - } - - free(full_path); - return childpid; - } - - free(full_path); - return -1; /*NOT REACHED */ -} - - -int wait0(pid_t pid) -{ - int status; - int val = -1; - - if (pid < 0) - return -1; - - for (;;) { - if (waitpid(pid, &status, 0) < 0) { - if (errno == EINTR) { - // interrupted system call - retry - continue; - } - } - break; - } - if (WIFEXITED(status)) { - val = WEXITSTATUS(status); - } - - return val; -} diff --git a/core/org.eclipse.cdt.core.linux/library/io.c b/core/org.eclipse.cdt.core.linux/library/io.c deleted file mode 100644 index 94f03d63935..00000000000 --- a/core/org.eclipse.cdt.core.linux/library/io.c +++ /dev/null @@ -1,117 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2006 QNX Software Systems 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: - * QNX Software Systems - initial API and implementation - * Wind River Systems, Inc. - *******************************************************************************/ -#include <jni.h> -#include <stdio.h> -#include <SpawnerInputStream.h> -#include <SpawnerOutputStream.h> -#include <unistd.h> - -/* Header for class _org_eclipse_cdt_utils_spawner_SpawnerInputStream */ -/* Header for class _org_eclipse_cdt_utils_spawner_SpawnerOutputStream */ - -/* - * Class: org_eclipse_cdt_utils_spawner_SpawnerInputStream - * Method: read0 - * Signature: (I)I - */ -JNIEXPORT jint JNICALL -Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_read0(JNIEnv * env, - jobject jobj, - jint jfd, - jbyteArray buf, - jint buf_len) -{ - int fd; - int status; - jbyte *data; - int data_len; - - data = (*env)->GetByteArrayElements(env, buf, 0); - data_len = buf_len; - fd = jfd; - - status = read( fd, data, data_len ); - (*env)->ReleaseByteArrayElements(env, buf, data, 0); - - if (status == 0) { - /* EOF. */ - status = -1; - } else if (status == -1) { - /* Error, toss an exception */ - jclass exception = (*env)->FindClass(env, "java/io/IOException"); - if (exception == NULL) { - /* Give up. */ - return -1; - } - (*env)->ThrowNew(env, exception, "read error"); - } - - return status; -} - - -/* - * Class: org_eclipse_cdt_utils_spawner_SpawnerInputStream - * Method: close0 - * Signature: (I)I - */ -JNIEXPORT jint JNICALL -Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_close0(JNIEnv * env, - jobject jobj, - jint fd) -{ - return close(fd); -} - -/* - * Class: org_eclipse_cdt_utils_spawner_SpawnerOutputStream - * Method: write0 - * Signature: (II)I - */ -JNIEXPORT jint JNICALL -Java_org_eclipse_cdt_utils_spawner_SpawnerOutputStream_write0(JNIEnv * env, - jobject jobj, - jint jfd, - jbyteArray buf, - jint buf_len) -{ - int status; - int fd; - jbyte *data; - int data_len; - - data = (*env)->GetByteArrayElements(env, buf, 0); - data_len = buf_len; - fd = jfd; - - status = write(fd, data, data_len); - (*env)->ReleaseByteArrayElements(env, buf, data, 0); - - return status; -} - - -/* - * Class: org_eclipse_cdt_utils_spawner_SpawnerOutputStream - * Method: close0 - * Signature: (I)I - */ -JNIEXPORT jint JNICALL -Java_org_eclipse_cdt_utils_spawner_SpawnerOutputStream_close0(JNIEnv * env, - jobject jobj, - jint fd) -{ - return close(fd); -} diff --git a/core/org.eclipse.cdt.core.linux/library/openpty.c b/core/org.eclipse.cdt.core.linux/library/openpty.c deleted file mode 100644 index cae7dd5684a..00000000000 --- a/core/org.eclipse.cdt.core.linux/library/openpty.c +++ /dev/null @@ -1,133 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2010 QNX Software Systems 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: - * QNX Software Systems - initial API and implementation - * Wind River Systems, Inc. - * Mikhail Zabaluev (Nokia) - bug 82744 - * Corey Ashford (IBM) - bug 272370, bug 272372 - *******************************************************************************/ - -/* _XOPEN_SOURCE is needed to bring in the header for ptsname */ -#define _XOPEN_SOURCE -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/ioctl.h> -#include <fcntl.h> -#include <termios.h> -#include <errno.h> -#include <unistd.h> -#include <stdio.h> -#include <string.h> -#include <grp.h> - -#include <stdlib.h> - -/** - * This is taken from R. W. Stevens book. - * Alain Magloire. - */ - -int ptym_open (char *pts_name); -int ptys_open (int fdm, const char * pts_name); -void set_noecho(int fd); - -int -openpty(int *amaster, int *aslave, char *name, struct termios *termp, struct winsize *winp) -{ - char line[20]; - line[0]=0; - *amaster = ptym_open(line); - if (*amaster < 0) - return -1; - *aslave = ptys_open(*amaster, line); - if (*aslave < 0) { - close(*amaster); - return -1; - } - - if (name) - strcpy(name, line); -#ifndef TCSAFLUSH -#define TCSAFLUSH TCSETAF -#endif - if (termp) - (void) tcsetattr(*aslave, TCSAFLUSH, termp); -#ifdef TIOCSWINSZ - if (winp) - (void) ioctl(*aslave, TIOCSWINSZ, (char *)winp); -#endif - return 0; -} - -void -set_noecho(int fd) -{ - struct termios stermios; - if (tcgetattr(fd, &stermios) < 0) { - return ; - } - - /* turn off echo */ - stermios.c_lflag &= ~(ECHO | ECHOE | ECHOK | ECHONL); - /* Turn off the NL to CR/NL mapping ou output. */ - /*stermios.c_oflag &= ~(ONLCR);*/ - - stermios.c_iflag |= (IGNCR); - - tcsetattr(fd, TCSANOW, &stermios); -} - -int -ptym_open(char * pts_name) -{ - int fdm; - char *ptr; - - strcpy(pts_name, "/dev/ptmx"); - fdm = getpt(); - if (fdm < 0) - return -1; - if (grantpt(fdm) < 0) { /* grant access to slave */ - close(fdm); - return -2; - } - if (unlockpt(fdm) < 0) { /* clear slave's lock flag */ - close(fdm); - return -3; - } - ptr = ptsname(fdm); - if (ptr == NULL) { /* get slave's name */ - close (fdm); - return -4; - } - strcpy(pts_name, ptr); /* return name of slave */ - return fdm; /* return fd of master */ -} - -int -ptys_open(int fdm, const char * pts_name) -{ - int fds; - /* following should allocate controlling terminal */ - fds = open(pts_name, O_RDWR); - if (fds < 0) { - close(fdm); - return -5; - } - -#if defined(TIOCSCTTY) - /* TIOCSCTTY is the BSD way to acquire a controlling terminal. */ - if (ioctl(fds, TIOCSCTTY, (char *)0) < 0) { - // ignore error: this is expected in console-mode - } -#endif - return fds; -} diff --git a/core/org.eclipse.cdt.core.linux/library/pfind.c b/core/org.eclipse.cdt.core.linux/library/pfind.c deleted file mode 100644 index dd7abddf2f6..00000000000 --- a/core/org.eclipse.cdt.core.linux/library/pfind.c +++ /dev/null @@ -1,112 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2010 QNX Software Systems 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: - * QNX Software Systems - initial API and implementation - * Wind River Systems, Inc. - * Mikhail Sennikovsky - bug 145737 - * Everton Rufino Constantino (IBM) - bug 237611 - *******************************************************************************/ -/* - * pfind.c - Search for a binary in $PATH. - */ - -#include <stdio.h> -#include <unistd.h> -#include <stdlib.h> -#include <string.h> -#include <limits.h> - -#ifndef PATH_MAX -#define PATH_MAX 1024 -#endif - -#define PATH_DEF "PATH=" -const int path_def_len = 5; /* strlen(PATH_DEF); */ - -char * path_val(char * const envp[]) -{ - int i; - if (envp == NULL || envp[0] == NULL) - return getenv("PATH" ); - - for(i = 0; envp[i] != NULL; i++){ - char* p = envp[i]; - if(!strncmp(PATH_DEF, p, path_def_len)){ - return p + path_def_len; - } - } - - return NULL; -} - -char * pfind(const char *name, char * const envp[]) -{ - char *tok; - char *sp; - char *path; - char fullpath[PATH_MAX+1]; - - /* Sanity check. */ - if (name == NULL) { - fprintf(stderr, "pfind(): Null argument.\n"); - return NULL; - } - - /* For absolute name or name with a path, check if it is an executable. */ - if (name[0] == '/' || name[0] == '.') { - if (access(name, X_OK) == 0) { - return strdup(name); - } - return NULL; - } - - /* Search in the PATH environment. */ - path = path_val( envp ); - - if (path == NULL || strlen(path) <= 0) { - fprintf(stderr, "Unable to get $PATH.\n"); - return NULL; - } - - /* The value return by getenv() is readonly */ - path = strdup(path); - - tok = strtok_r(path, ":", &sp); - while (tok != NULL) { - snprintf(fullpath, sizeof(fullpath) - 1, "%s/%s", tok, name); - - if (access(fullpath, X_OK) == 0) { - free(path); - return strdup(fullpath); - } - - tok = strtok_r( NULL, ":", &sp ); - } - - free(path); - return NULL; -} - -#ifdef BUILD_WITH_MAIN -int main(int argc, char **argv) -{ - int i; - char *fullpath; - - for (i=1; i<argc; i++) { - fullpath = pfind(argv[i], NULL); - if (fullpath == NULL) - printf("Unable to find %s in $PATH.\n", argv[i]); - else - printf("Found %s @ %s.\n", argv[i], fullpath); - } -} -#endif diff --git a/core/org.eclipse.cdt.core.linux/library/pty.c b/core/org.eclipse.cdt.core.linux/library/pty.c deleted file mode 100644 index ce25c965919..00000000000 --- a/core/org.eclipse.cdt.core.linux/library/pty.c +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2010 QNX Software Systems 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: - * QNX Software Systems - initial API and implementation - * Wind River Systems, Inc. - *******************************************************************************/ -#include <sys/ioctl.h> -#include "PTY.h" -#include "openpty.h" - -/* - * Class: org_eclipse_cdt_utils_pty_PTY - * Method: forkpty - * Signature: ()I - */ -JNIEXPORT jstring JNICALL -Java_org_eclipse_cdt_utils_pty_PTY_openMaster (JNIEnv *env, jobject jobj, jboolean console) { - jfieldID fid; /* Store the field ID */ - jstring jstr = NULL; - int master = -1; - char line[1024]; /* FIXME: Should be enough */ - jclass cls; - - line[0] = '\0'; - - master = ptym_open(line); - if (master >= 0) { - // turn off echo - if (console) { - set_noecho(master); - } - - /* Get a reference to the obj's class */ - cls = (*env)->GetObjectClass(env, jobj); - - /* Set the master fd. */ - fid = (*env)->GetFieldID(env, cls, "master", "I"); - if (fid == NULL) { - return NULL; - } - (*env)->SetIntField(env, jobj, fid, (jint)master); - - /* Create a new String for the slave. */ - jstr = (*env)->NewStringUTF(env, line); - } - return jstr; -} - -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTY_change_1window_1size - (JNIEnv *env, jobject jobj, jint fdm, jint width, jint height) -{ -#ifdef TIOCGWINSZ - struct winsize win; - - win.ws_col = width; - win.ws_row = height; - win.ws_xpixel = 0; - win.ws_ypixel = 0; - - return ioctl(fdm, TIOCSWINSZ, &win); -#else - return 0; -#endif -} - diff --git a/core/org.eclipse.cdt.core.linux/library/ptyio.c b/core/org.eclipse.cdt.core.linux/library/ptyio.c deleted file mode 100644 index e022db11f99..00000000000 --- a/core/org.eclipse.cdt.core.linux/library/ptyio.c +++ /dev/null @@ -1,120 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002 - 2005 QNX Software Systems 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: - * QNX Software Systems - initial API and implementation - *******************************************************************************/ -#include <jni.h> -#include <stdio.h> -#include <PTYInputStream.h> -#include <PTYOutputStream.h> -#include <unistd.h> - -/* Header for class _org_eclipse_cdt_utils_pty_PTYInputStream */ -/* Header for class _org_eclipse_cdt_utils_pty_PTYOutputStream */ - -/* - * Class: org_eclipse_cdt_utils_pty_PTYInputStream - * Method: read0 - * Signature: (I)I - */ -JNIEXPORT jint JNICALL -Java_org_eclipse_cdt_utils_pty_PTYInputStream_read0(JNIEnv * env, - jobject jobj, - jint jfd, - jbyteArray buf, - jint buf_len) -{ - int fd; - int status; - jbyte *data; - int data_len; - - data = (*env)->GetByteArrayElements(env, buf, 0); - data_len = buf_len; - fd = jfd; - - status = read( fd, data, data_len ); - (*env)->ReleaseByteArrayElements(env, buf, data, 0); - - if (status == 0) { - /* EOF. */ - status = -1; - } else if (status == -1) { - /* Error, toss an exception */ - /* Ignore the error for now, the debugger will attempt - * to close this multiple time. */ -#if 0 - jclass exception = (*env)->FindClass(env, "java/io/IOException"); - if (exception == NULL) { - /* Give up. */ - return -1; - } - (*env)->ThrowNew(env, exception, "read error"); -#endif - } - - return status; -} - - -/* - * Class: org_eclipse_cdt_utils_pty_PTYInputStream - * Method: close0 - * Signature: (I)I - */ -JNIEXPORT jint JNICALL -Java_org_eclipse_cdt_utils_pty_PTYInputStream_close0(JNIEnv * env, - jobject jobj, - jint fd) -{ - return close(fd); -} - -/* - * Class: org_eclipse_cdt_utils_pty_PTYOutputStream - * Method: write0 - * Signature: (II)I - */ -JNIEXPORT jint JNICALL -Java_org_eclipse_cdt_utils_pty_PTYOutputStream_write0(JNIEnv * env, - jobject jobj, - jint jfd, - jbyteArray buf, - jint buf_len) -{ - int status; - int fd; - jbyte *data; - int data_len; - - data = (*env)->GetByteArrayElements(env, buf, 0); - data_len = buf_len; - fd = jfd; - - status = write(fd, data, data_len); - (*env)->ReleaseByteArrayElements(env, buf, data, 0); - - return status; -} - - -/* - * Class: org_eclipse_cdt_utils_pty_PTYOutputStream - * Method: close0 - * Signature: (I)I - */ -JNIEXPORT jint JNICALL -Java_org_eclipse_cdt_utils_pty_PTYOutputStream_close0(JNIEnv * env, - jobject jobj, - jint fd) -{ - return close(fd); -} diff --git a/core/org.eclipse.cdt.core.linux/library/spawner.c b/core/org.eclipse.cdt.core.linux/library/spawner.c deleted file mode 100644 index 623b1382cf8..00000000000 --- a/core/org.eclipse.cdt.core.linux/library/spawner.c +++ /dev/null @@ -1,305 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2010 QNX Software Systems 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: - * QNX Software Systems - initial API and implementation - * Wind River Systems, Inc. - * Mikhail Zabaluev (Nokia) - bug 82744 - *******************************************************************************/ -#include <unistd.h> -#include <stdlib.h> -#include <stdio.h> -#include <signal.h> -#include <string.h> -#include <jni.h> - -#include "exec0.h" -#include <Spawner.h> - - -#define DEBUGIT 0 - - -/* - * Header for class org_eclipse_cdt_utils_spawner_Spawner - */ - - -#if DEBUGIT -static void print_array(char **c_array) -{ - if (c_array) { - char **p = c_array; - for (; *p; p++) { - if (*p) { - fprintf(stderr, " %s", *p); - } - } - } else { - fprintf(stderr, "null"); - } - fprintf(stderr, "\n"); -} -#endif - - -static char **alloc_c_array(JNIEnv * env, jobjectArray j_array) -{ - int i; - jint c_array_size = (*env)->GetArrayLength(env, j_array); - char **c_array = calloc(c_array_size + 1, sizeof(*c_array)); - - if (c_array == NULL) - return NULL; - - for (i = 0; i < c_array_size; i++) { - jstring j_str = - (jstring) (*env)->GetObjectArrayElement(env, j_array, i); - const char *c_str = (*env)->GetStringUTFChars(env, j_str, NULL); - c_array[i] = (char *) strdup(c_str); - (*env)->ReleaseStringUTFChars(env, j_str, c_str); - (*env)->DeleteLocalRef(env, j_str); - } - - return c_array; -} - - -static void free_c_array(char **c_array) -{ - if (c_array) { - char **p = c_array; - for (; *p; p++) { - if (*p) { - free(*p); - } - } - free(c_array); - } -} - - -/* - * Class: org_eclipse_cdt_utils_spawner_Spawner - * Method: exec2 - * Signature: ([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[ILorg/eclipse/cdt/utils/pty/PTY;)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec2 - (JNIEnv *env, jobject jobj, jobjectArray jcmd, jobjectArray jenv, jstring jdir, jintArray jchannels, - jstring jslaveName, jint masterFD, jboolean console) -{ - jint *channels = (*env)->GetIntArrayElements(env, jchannels, 0); - const char *dirpath = (*env)->GetStringUTFChars(env, jdir, NULL); - const char *pts_name = (*env)->GetStringUTFChars(env, jslaveName, NULL); - char **cmd = NULL; - char **envp = NULL; - int fd[3]; - pid_t pid = -1; - - if (channels == NULL) - goto bail_out; - - cmd = alloc_c_array(env, jcmd); - if (cmd == NULL) - goto bail_out; - - envp = alloc_c_array(env, jenv); - if (envp == NULL) - goto bail_out; - -#if DEBUGIT - fprintf(stderr, "command:"); - print_array(cmd); - fprintf(stderr, "Envp:"); - print_array(envp); - fprintf(stderr, "dirpath: %s\n", dirpath); - fprintf(stderr, "pts_name: %s\n", pts_name); -#endif - - pid = exec_pty(cmd[0], cmd, envp, dirpath, fd, pts_name, masterFD, console); - if (pid < 0) - goto bail_out; - - channels[0] = fd[0]; - channels[1] = fd[1]; - channels[2] = fd[2]; - - bail_out: - (*env)->ReleaseIntArrayElements(env, jchannels, channels, 0); - (*env)->ReleaseStringUTFChars(env, jdir, dirpath); - (*env)->ReleaseStringUTFChars(env, jslaveName, pts_name); - if (cmd) - free_c_array(cmd); - if (envp) - free_c_array(envp); - return pid; -} - - -JNIEXPORT jint JNICALL -Java_org_eclipse_cdt_utils_spawner_Spawner_exec1(JNIEnv * env, jobject jobj, - jobjectArray jcmd, - jobjectArray jenv, - jstring jdir) -{ - const char *dirpath = (*env)->GetStringUTFChars(env, jdir, NULL); - char **cmd = NULL; - char **envp = NULL; - pid_t pid = -1; - - cmd = alloc_c_array(env, jcmd); - if (cmd == NULL) - goto bail_out; - - envp = alloc_c_array(env, jenv); - if (envp == NULL) - goto bail_out; - -#if DEBUGIT - fprintf(stderr, "command:"); - print_array(cmd); - fprintf(stderr, "Envp:"); - print_array(envp); - fprintf(stderr, "dirpath: %s\n", dirpath); -#endif - - pid = exec0(cmd[0], cmd, envp, dirpath, NULL); - if (pid < 0) - goto bail_out; - - bail_out: - (*env)->ReleaseStringUTFChars(env, jdir, dirpath); - if (cmd) - free_c_array(cmd); - if (envp) - free_c_array(envp); - return pid; -} - -/* - * Class: org_eclipse_cdt_utils_spawner_Spawner - * Method: exec0 - * Signature: ([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[I)I - */ -JNIEXPORT jint JNICALL -Java_org_eclipse_cdt_utils_spawner_Spawner_exec0(JNIEnv * env, jobject jobj, - jobjectArray jcmd, - jobjectArray jenv, - jstring jdir, - jintArray jchannels) -{ - jint *channels = (*env)->GetIntArrayElements(env, jchannels, 0); - const char *dirpath = (*env)->GetStringUTFChars(env, jdir, NULL); - char **cmd = NULL; - char **envp = NULL; - int fd[3]; - pid_t pid = -1; - - if (channels == NULL) - goto bail_out; - - cmd = alloc_c_array(env, jcmd); - if (cmd == NULL) - goto bail_out; - - envp = alloc_c_array(env, jenv); - if (envp == NULL) - goto bail_out; - -#if DEBUGIT - fprintf(stderr, "command:"); - print_array(cmd); - fprintf(stderr, "Envp:"); - print_array(envp); - fprintf(stderr, "dirpath: %s\n", dirpath); -#endif - - pid = exec0(cmd[0], cmd, envp, dirpath, fd); - if (pid < 0) - goto bail_out; - - channels[0] = fd[0]; - channels[1] = fd[1]; - channels[2] = fd[2]; - - bail_out: - (*env)->ReleaseIntArrayElements(env, jchannels, channels, 0); - (*env)->ReleaseStringUTFChars(env, jdir, dirpath); - if (cmd) - free_c_array(cmd); - if (envp) - free_c_array(envp); - return pid; -} - -/* - * Class: org_eclipse_cdt_utils_spawner_Spawner - * Method: raise - * Signature: (II)I - */ -JNIEXPORT jint JNICALL -Java_org_eclipse_cdt_utils_spawner_Spawner_raise(JNIEnv * env, jobject jobj, - jint pid, jint sig) -{ - int status = -1; - - switch (sig) { - case 0: /* NOOP */ - status = killpg(pid, 0); - if(status == -1) { - status = kill(pid, 0); - } - break; - - case 2: /* INTERRUPT */ - status = killpg(pid, SIGINT); - if(status == -1) { - status = kill(pid, SIGINT); - } - break; - - case 9: /* KILL */ - status = killpg(pid, SIGKILL); - if(status == -1) { - status = kill(pid, SIGKILL); - } - break; - - case 15: /* TERM */ - status = killpg(pid, SIGTERM); - if(status == -1) { - status = kill(pid, SIGTERM); - } - break; - - default: - status = killpg(pid, sig); /* WHAT ?? */ - if(status == -1) { - status = kill(pid, sig); /* WHAT ?? */ - } - break; - } - - return status; -} - - - -/* - * Class: org_eclipse_cdt_utils_spawner_Spawner - * Method: waitFor - * Signature: (I)I - */ -JNIEXPORT jint JNICALL -Java_org_eclipse_cdt_utils_spawner_Spawner_waitFor(JNIEnv * env, - jobject jobj, jint pid) -{ - return wait0(pid); -} diff --git a/core/org.eclipse.cdt.core.linux/pom.xml b/core/org.eclipse.cdt.core.linux/pom.xml index eacc249a446..437c92c60dd 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,111 +17,14 @@ <parent> <groupId>org.eclipse.cdt</groupId> <artifactId>cdt-parent</artifactId> - <version>10.0.0-SNAPSHOT</version> + <version>10.7.0-SNAPSHOT</version> <relativePath>../../pom.xml</relativePath> </parent> - <version>6.0.0-SNAPSHOT</version> + <version>6.0.100-SNAPSHOT</version> <artifactId>org.eclipse.cdt.core.linux</artifactId> <packaging>eclipse-plugin</packaging> - <profiles> - <profile> - <id>build-native.linux.x86_64</id> - <activation> - <property> - <name>native</name> - <value>linux.x86_64</value> - </property> - </activation> - <build> - <plugins> - <plugin> - <artifactId>maven-antrun-plugin</artifactId> - <executions> - <execution> - <id>natives</id> - <phase>process-resources</phase> - <configuration> - <target> - <exec executable="make" newenvironment="false" dir="./library"> - <arg value="ARCH=x86_64" /> - </exec> - </target> - </configuration> - <goals> - <goal>run</goal> - </goals> - </execution> - <execution> - <id>clean-natives</id> - <phase>clean</phase> - <configuration> - <target> - <exec executable="make" newenvironment="false" dir="./library"> - <arg value="ARCH=x86_64" /> - <arg value="clean" /> - </exec> - </target> - </configuration> - <goals> - <goal>run</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> - </profile> - <profile> - <id>build-native.linux.ppc64le</id> - <activation> - <property> - <name>native</name> - <value>linux.ppc64le</value> - </property> - </activation> - <build> - <plugins> - <plugin> - <artifactId>maven-antrun-plugin</artifactId> - <executions> - <execution> - <id>natives</id> - <phase>process-resources</phase> - <configuration> - <target> - <exec executable="make" newenvironment="false" dir="./library"> - <arg value="ARCH=ppc64le" /> - </exec> - </target> - </configuration> - <goals> - <goal>run</goal> - </goals> - </execution> - <execution> - <id>clean-natives</id> - <phase>clean</phase> - <configuration> - <target> - <exec executable="make" newenvironment="false" dir="./library"> - <arg value="ARCH=ppc64le" /> - <arg value="clean" /> - </exec> - </target> - </configuration> - <goals> - <goal>run</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> - </profile> - </profiles> - <build> <plugins> <plugin> @@ -130,6 +43,11 @@ <environment> <os>linux</os> <ws>gtk</ws> + <arch>aarch64</arch> + </environment> + <environment> + <os>linux</os> + <ws>gtk</ws> <arch>ppc64le</arch> </environment> </environments> diff --git a/core/org.eclipse.cdt.core.macosx/.classpath b/core/org.eclipse.cdt.core.macosx/.classpath index 01836c4842f..e801ebfb468 100644 --- a/core/org.eclipse.cdt.core.macosx/.classpath +++ b/core/org.eclipse.cdt.core.macosx/.classpath @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> - <classpathentry kind="src" path="src"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> + <classpathentry kind="src" path="src"/> <classpathentry kind="output" path="bin"/> </classpath> diff --git a/core/org.eclipse.cdt.core.macosx/.project b/core/org.eclipse.cdt.core.macosx/.project index d56d04e05eb..da4e1b0ada8 100644 --- a/core/org.eclipse.cdt.core.macosx/.project +++ b/core/org.eclipse.cdt.core.macosx/.project @@ -20,9 +20,15 @@ <arguments> </arguments> </buildCommand> + <buildCommand> + <name>org.eclipse.pde.api.tools.apiAnalysisBuilder</name> + <arguments> + </arguments> + </buildCommand> </buildSpec> <natures> <nature>org.eclipse.jdt.core.javanature</nature> <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature> </natures> </projectDescription> diff --git a/core/org.eclipse.cdt.core.macosx/.settings/org.eclipse.core.resources.prefs b/core/org.eclipse.cdt.core.macosx/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 00000000000..99f26c0203a --- /dev/null +++ b/core/org.eclipse.cdt.core.macosx/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/<project>=UTF-8 diff --git a/core/org.eclipse.cdt.core.macosx/.settings/org.eclipse.jdt.core.prefs b/core/org.eclipse.cdt.core.macosx/.settings/org.eclipse.jdt.core.prefs index 2b6ecff8a01..e3a8104f9ca 100644 --- a/core/org.eclipse.cdt.core.macosx/.settings/org.eclipse.jdt.core.prefs +++ b/core/org.eclipse.cdt.core.macosx/.settings/org.eclipse.jdt.core.prefs @@ -30,9 +30,9 @@ org.eclipse.jdt.core.compiler.annotation.nullable.secondary= org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.methodParameters=generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.compliance=11 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -49,6 +49,7 @@ org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled org.eclipse.jdt.core.compiler.problem.discouragedReference=warning org.eclipse.jdt.core.compiler.problem.emptyStatement=warning +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning @@ -107,6 +108,7 @@ org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=igno org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled @@ -144,13 +146,14 @@ org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.release=disabled -org.eclipse.jdt.core.compiler.source=1.8 +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=11 org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns=false org.eclipse.jdt.core.formatter.align_with_spaces=false +org.eclipse.jdt.core.formatter.alignment_for_additive_operator=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 @@ -158,21 +161,24 @@ org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_c org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_assignment=0 -org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_bitwise_operator=16 org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 org.eclipse.jdt.core.formatter.alignment_for_compact_loops=16 org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 org.eclipse.jdt.core.formatter.alignment_for_enum_constants=16 org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0 +org.eclipse.jdt.core.formatter.alignment_for_logical_operator=16 org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 org.eclipse.jdt.core.formatter.alignment_for_module_statements=16 org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_multiplicative_operator=16 org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_string_concatenation=16 org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 @@ -264,11 +270,12 @@ org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_after_additive_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_bitwise_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert @@ -299,6 +306,8 @@ org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_after_logical_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_multiplicative_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert @@ -323,13 +332,17 @@ org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_relational_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert +org.eclipse.jdt.core.formatter.insert_space_after_shift_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_string_concatenation=insert org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_additive_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_bitwise_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert @@ -377,6 +390,8 @@ org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do no org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_before_logical_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_multiplicative_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert @@ -413,9 +428,12 @@ org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not inser org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_relational_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_shift_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_string_concatenation=insert org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert @@ -454,10 +472,14 @@ org.eclipse.jdt.core.formatter.tabulation.char=tab org.eclipse.jdt.core.formatter.tabulation.size=4 org.eclipse.jdt.core.formatter.use_on_off_tags=true org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false +org.eclipse.jdt.core.formatter.wrap_before_additive_operator=true org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false -org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true +org.eclipse.jdt.core.formatter.wrap_before_bitwise_operator=true org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true +org.eclipse.jdt.core.formatter.wrap_before_logical_operator=true +org.eclipse.jdt.core.formatter.wrap_before_multiplicative_operator=true org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true +org.eclipse.jdt.core.formatter.wrap_before_string_concatenation=true org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true org.eclipse.jdt.core.incompatibleJDKLevel=ignore org.eclipse.jdt.core.incompleteClasspath=error diff --git a/core/org.eclipse.cdt.core.macosx/.settings/org.eclipse.jdt.ui.prefs b/core/org.eclipse.cdt.core.macosx/.settings/org.eclipse.jdt.ui.prefs index e44576346c4..d35ba9b5231 100644 --- a/core/org.eclipse.cdt.core.macosx/.settings/org.eclipse.jdt.ui.prefs +++ b/core/org.eclipse.cdt.core.macosx/.settings/org.eclipse.jdt.ui.prefs @@ -1,3 +1,4 @@ +cleanup.add_all=false cleanup.add_default_serial_version_id=true cleanup.add_generated_serial_version_id=false cleanup.add_missing_annotations=true @@ -11,25 +12,72 @@ cleanup.always_use_blocks=true cleanup.always_use_parentheses_in_expressions=false cleanup.always_use_this_for_non_static_field_access=false cleanup.always_use_this_for_non_static_method_access=false +cleanup.array_with_curly=false +cleanup.arrays_fill=false +cleanup.bitwise_conditional_expression=false +cleanup.boolean_literal=false +cleanup.boolean_value_rather_than_comparison=false +cleanup.break_loop=false +cleanup.collection_cloning=false +cleanup.comparing_on_criteria=false +cleanup.comparison_statement=false +cleanup.controlflow_merge=false cleanup.convert_functional_interfaces=false cleanup.convert_to_enhanced_for_loop=false +cleanup.convert_to_enhanced_for_loop_if_loop_var_used=true +cleanup.convert_to_switch_expressions=false cleanup.correct_indentation=false +cleanup.do_while_rather_than_while=true +cleanup.double_negation=false +cleanup.else_if=false +cleanup.embedded_if=false +cleanup.evaluate_nullable=false +cleanup.extract_increment=false cleanup.format_source_code=true cleanup.format_source_code_changes_only=false +cleanup.hash=false +cleanup.if_condition=false cleanup.insert_inferred_type_arguments=false +cleanup.instanceof=false +cleanup.instanceof_keyword=false +cleanup.invert_equals=false +cleanup.join=false +cleanup.lazy_logical_operator=false cleanup.make_local_variable_final=true cleanup.make_parameters_final=false cleanup.make_private_fields_final=true cleanup.make_type_abstract_if_missing_method=false cleanup.make_variable_declarations_final=false +cleanup.map_cloning=false +cleanup.merge_conditional_blocks=false +cleanup.multi_catch=false cleanup.never_use_blocks=false cleanup.never_use_parentheses_in_expressions=true +cleanup.no_string_creation=false +cleanup.no_super=false +cleanup.number_suffix=false +cleanup.objects_equals=false +cleanup.one_if_rather_than_duplicate_blocks_that_fall_through=false +cleanup.operand_factorization=false cleanup.organize_imports=true +cleanup.overridden_assignment=false +cleanup.plain_replacement=false +cleanup.precompile_regex=false +cleanup.primitive_comparison=false +cleanup.primitive_parsing=false +cleanup.primitive_rather_than_wrapper=false +cleanup.primitive_serialization=false +cleanup.pull_out_if_from_if_else=false +cleanup.pull_up_assignment=false +cleanup.push_down_negation=false cleanup.qualify_static_field_accesses_with_declaring_class=false cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true cleanup.qualify_static_member_accesses_with_declaring_class=false cleanup.qualify_static_method_accesses_with_declaring_class=false +cleanup.reduce_indentation=false +cleanup.redundant_comparator=false +cleanup.redundant_falling_through_block_end=false cleanup.remove_private_constructors=true cleanup.remove_redundant_modifiers=false cleanup.remove_redundant_semicolons=true @@ -37,25 +85,57 @@ cleanup.remove_redundant_type_arguments=true cleanup.remove_trailing_whitespaces=true cleanup.remove_trailing_whitespaces_all=true cleanup.remove_trailing_whitespaces_ignore_empty=false +cleanup.remove_unnecessary_array_creation=false cleanup.remove_unnecessary_casts=true cleanup.remove_unnecessary_nls_tags=false cleanup.remove_unused_imports=true cleanup.remove_unused_local_variables=false +cleanup.remove_unused_method_parameters=false cleanup.remove_unused_private_fields=true cleanup.remove_unused_private_members=false cleanup.remove_unused_private_methods=true cleanup.remove_unused_private_types=true +cleanup.return_expression=false +cleanup.simplify_lambda_expression_and_method_ref=false +cleanup.single_used_field=false cleanup.sort_members=false cleanup.sort_members_all=false +cleanup.standard_comparison=false +cleanup.static_inner_class=false +cleanup.strictly_equal_or_different=false +cleanup.stringbuffer_to_stringbuilder=false +cleanup.stringbuilder=false +cleanup.stringbuilder_for_local_vars=true +cleanup.stringconcat_to_textblock=false +cleanup.substring=false +cleanup.switch=false +cleanup.system_property=false +cleanup.system_property_boolean=false +cleanup.system_property_file_encoding=false +cleanup.system_property_file_separator=false +cleanup.system_property_line_separator=false +cleanup.system_property_path_separator=false +cleanup.ternary_operator=false +cleanup.try_with_resource=false +cleanup.unlooped_while=false +cleanup.unreachable_block=false cleanup.use_anonymous_class_creation=false +cleanup.use_autoboxing=false cleanup.use_blocks=false cleanup.use_blocks_only_for_return_and_throw=false +cleanup.use_directly_map_method=false cleanup.use_lambda=true cleanup.use_parentheses_in_expressions=false +cleanup.use_string_is_blank=false cleanup.use_this_for_non_static_field_access=false cleanup.use_this_for_non_static_field_access_only_if_necessary=true cleanup.use_this_for_non_static_method_access=false cleanup.use_this_for_non_static_method_access_only_if_necessary=true +cleanup.use_unboxing=false +cleanup.use_var=false +cleanup.useless_continue=false +cleanup.useless_return=false +cleanup.valueof_rather_than_instantiation=false cleanup_profile=_CDT cleanup_settings_version=2 eclipse.preferences.version=1 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 83f776ca07f..8f49113c8bd 100644 --- a/core/org.eclipse.cdt.core.macosx/META-INF/MANIFEST.MF +++ b/core/org.eclipse.cdt.core.macosx/META-INF/MANIFEST.MF @@ -2,10 +2,10 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %fragmentName.macosx Bundle-SymbolicName: org.eclipse.cdt.core.macosx; singleton:=true -Bundle-Version: 6.0.0.qualifier +Bundle-Version: 6.0.600.qualifier Bundle-Vendor: %providerName Fragment-Host: org.eclipse.cdt.core.native;bundle-version="[6.0.0,7.0.0)" Bundle-Localization: plugin -Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Bundle-RequiredExecutionEnvironment: JavaSE-11 Eclipse-PlatformFilter: (osgi.os=macosx) Automatic-Module-Name: org.eclipse.cdt.core.macosx diff --git a/core/org.eclipse.cdt.core.macosx/about.html b/core/org.eclipse.cdt.core.macosx/about.html index 164f781a8fd..b3134865230 100644 --- a/core/org.eclipse.cdt.core.macosx/about.html +++ b/core/org.eclipse.cdt.core.macosx/about.html @@ -1,10 +1,11 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> + <head> -<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> -<title>About</title> + <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> + <title>About</title> </head> + <body lang="EN-US"> <h2>About This Content</h2> @@ -16,7 +17,7 @@ ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 ("EPL"). A copy of the EPL is - available at <a href="http://www.eclipse.org/legal/epl-2.0">http://www.eclipse.org/legal/epl-2.0</a>. + available at <a href="https://www.eclipse.org/legal/epl-2.0">https://www.eclipse.org/legal/epl-2.0</a>. For purposes of the EPL, "Program" will mean the Content. </p> @@ -29,8 +30,9 @@ license exists, contact the Redistributor. Unless otherwise indicated below, the terms and conditions of the EPL still apply to any source code in the Content and such source code may be obtained at <a - href="http://www.eclipse.org/">http://www.eclipse.org</a>. + href="https://www.eclipse.org/">https://www.eclipse.org</a>. </p> </body> + </html>
\ No newline at end of file diff --git a/core/org.eclipse.cdt.core.macosx/build.properties b/core/org.eclipse.cdt.core.macosx/build.properties index 424f3017722..3630460b11f 100644 --- a/core/org.eclipse.cdt.core.macosx/build.properties +++ b/core/org.eclipse.cdt.core.macosx/build.properties @@ -17,6 +17,5 @@ bin.includes = fragment.xml,\ os/,\ META-INF/,\ plugin.properties -src.includes = about.html,\ - library/ +src.includes = about.html source.. = src/ diff --git a/core/org.eclipse.cdt.core.macosx/library/.gitignore b/core/org.eclipse.cdt.core.macosx/library/.gitignore deleted file mode 100644 index f9e528a2229..00000000000 --- a/core/org.eclipse.cdt.core.macosx/library/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*.o -/ltmain.sh diff --git a/core/org.eclipse.cdt.core.macosx/library/Makefile b/core/org.eclipse.cdt.core.macosx/library/Makefile deleted file mode 100644 index 62eeec8cdb3..00000000000 --- a/core/org.eclipse.cdt.core.macosx/library/Makefile +++ /dev/null @@ -1,135 +0,0 @@ -#******************************************************************************* -# Copyright (c) 2002, 2015 QNX Software Systems 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: -# QNX Software Systems - initial API and implementation -# Alex Blewitt - MacOSX with a 64-bit vm -# Martin Oberhuber (Wind River) - Bug 476709 - Fix change_window_size() -#*******************************************************************************/ - -# makefile for libspawner.so -# See http://developer.apple.com/documentation/Java/Conceptual/Java141Development/Core_APIs/chapter_6_section_4.html - -JAVA_HOME = $(shell echo /Library/Java/JavaVirtualMachines/jdk1.[78].0_*.jdk/Contents/Home) - -# Defaults which can be overridden. -OS = macosx -ARCH_X86 = x86 -ARCH_X86_64 = x86_64 - -CC=gcc -LD=libtool -CPPFLAGS = -I. -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/darwin -CFLAGS +=-fPIC -D_REENTRANT - -ARCH_FLAG_X86 = -arch i386 -ARCH_FLAG_X86_64 = -arch x86_64 - -INSTALL_DIR_X86 = ../os/$(OS)/$(ARCH_X86) -INSTALL_DIR_X86_64 = ../os/$(OS)/$(ARCH_X86_64) - -LIB_NAME_FULL_SPAWNER_X86 = $(INSTALL_DIR_X86)/libspawner.jnilib -LIB_NAME_FULL_SPAWNER_X86_64 = $(INSTALL_DIR_X86_64)/libspawner.jnilib -OBJS_SPAWNER_X86 = spawner_$(ARCH_X86).o \ - io_$(ARCH_X86).o \ - exec_unix_$(ARCH_X86).o \ - exec_pty_$(ARCH_X86).o \ - openpty_$(ARCH_X86).o \ - pfind_$(ARCH_X86).o -OBJS_SPAWNER_X86_64 = spawner_$(ARCH_X86_64).o \ - io_$(ARCH_X86_64).o \ - exec_unix_$(ARCH_X86_64).o \ - exec_pty_$(ARCH_X86_64).o \ - openpty_$(ARCH_X86_64).o \ - pfind_$(ARCH_X86_64).o - -LIB_NAME_FULL_PTY_X86 = $(INSTALL_DIR_X86)/libpty.jnilib -LIB_NAME_FULL_PTY_X86_64 = $(INSTALL_DIR_X86_64)/libpty.jnilib -OBJS_PTY_X86 = openpty_$(ARCH_X86).o pty_$(ARCH_X86).o ptyio_$(ARCH_X86).o -OBJS_PTY_X86_64 = openpty_$(ARCH_X86_64).o pty_$(ARCH_X86_64).o ptyio_$(ARCH_X86_64).o - -OBJS_X86 = $(OBJS_SPAWNER_X86) $(OBJS_PTY_X86) $(OBJS_SERIAL_X86) -OBJS_X86_64 = $(OBJS_SPAWNER_X86_64) $(OBJS_PTY_X86_64) $(OBJS_SERIAL_X86_64) - -all: x86 x86_64 - -x86: $(LIB_NAME_FULL_SPAWNER_X86) $(LIB_NAME_FULL_PTY_X86) - -x86_64: $(LIB_NAME_FULL_SPAWNER_X86_64) $(LIB_NAME_FULL_PTY_X86_64) - -rebuild: clean all - -$(LIB_NAME_FULL_SPAWNER_X86) : $(OBJS_SPAWNER_X86) - mkdir -p $(INSTALL_DIR_X86) - $(CC) -dynamiclib $(ARCH_FLAG_X86) -o $(LIB_NAME_FULL_SPAWNER_X86) $(OBJS_SPAWNER_X86) -lc -framework JavaVM - -$(LIB_NAME_FULL_SPAWNER_X86_64) : $(OBJS_SPAWNER_X86_64) - mkdir -p $(INSTALL_DIR_X86_64) - $(CC) -dynamiclib $(ARCH_FLAG_X86_64) -o $(LIB_NAME_FULL_SPAWNER_X86_64) $(OBJS_SPAWNER_X86_64) -lc -framework JavaVM - -$(LIB_NAME_FULL_PTY_X86): $(OBJS_PTY_X86) - mkdir -p $(INSTALL_DIR_X86) - $(CC) -dynamiclib $(ARCH_FLAG_X86) -o $(LIB_NAME_FULL_PTY_X86) $(OBJS_PTY_X86) -lc -framework JavaVM - -$(LIB_NAME_FULL_PTY_X86_64): $(OBJS_PTY_X86_64) - mkdir -p $(INSTALL_DIR_X86_64) - $(CC) -dynamiclib $(ARCH_FLAG_X86_64) -o $(LIB_NAME_FULL_PTY_X86_64) $(OBJS_PTY_X86_64) -lc -framework JavaVM - -spawner_$(ARCH_X86).o: spawner.c - $(CC) $(CFLAGS) $(ARCH_FLAG_X86) $(CPPFLAGS) -c -o $@ spawner.c - -io_$(ARCH_X86).o: io.c - $(CC) $(CFLAGS) $(ARCH_FLAG_X86) $(CPPFLAGS) -c -o $@ io.c - -exec_unix_$(ARCH_X86).o: exec_unix.c - $(CC) $(CFLAGS) $(ARCH_FLAG_X86) $(CPPFLAGS) -c -o $@ exec_unix.c - -exec_pty_$(ARCH_X86).o: exec_pty.c - $(CC) $(CFLAGS) $(ARCH_FLAG_X86) $(CPPFLAGS) -c -o $@ exec_pty.c - -openpty_$(ARCH_X86).o: openpty.c - $(CC) $(CFLAGS) $(ARCH_FLAG_X86) $(CPPFLAGS) -c -o $@ openpty.c - -pfind_$(ARCH_X86).o: pfind.c - $(CC) $(CFLAGS) $(ARCH_FLAG_X86) $(CPPFLAGS) -c -o $@ pfind.c - -pty_$(ARCH_X86).o: pty.c - $(CC) $(CFLAGS) $(ARCH_FLAG_X86) $(CPPFLAGS) -c -o $@ pty.c - -ptyio_$(ARCH_X86).o: ptyio.c - $(CC) $(CFLAGS) $(ARCH_FLAG_X86) $(CPPFLAGS) -c -o $@ ptyio.c - -spawner_$(ARCH_X86_64).o: spawner.c - $(CC) $(CFLAGS) $(ARCH_FLAG_X86_64) $(CPPFLAGS) -c -o $@ spawner.c - -io_$(ARCH_X86_64).o: io.c - $(CC) $(CFLAGS) $(ARCH_FLAG_X86_64) $(CPPFLAGS) -c -o $@ io.c - -exec_unix_$(ARCH_X86_64).o: exec_unix.c - $(CC) $(CFLAGS) $(ARCH_FLAG_X86_64) $(CPPFLAGS) -c -o $@ exec_unix.c - -exec_pty_$(ARCH_X86_64).o: exec_pty.c - $(CC) $(CFLAGS) $(ARCH_FLAG_X86_64) $(CPPFLAGS) -c -o $@ exec_pty.c - -openpty_$(ARCH_X86_64).o: openpty.c - $(CC) $(CFLAGS) $(ARCH_FLAG_X86_64) $(CPPFLAGS) -c -o $@ openpty.c - -pfind_$(ARCH_X86_64).o: pfind.c - $(CC) $(CFLAGS) $(ARCH_FLAG_X86_64) $(CPPFLAGS) -c -o $@ pfind.c - -pty_$(ARCH_X86_64).o: pty.c - $(CC) $(CFLAGS) $(ARCH_FLAG_X86_64) $(CPPFLAGS) -c -o $@ pty.c - -ptyio_$(ARCH_X86_64).o: ptyio.c - $(CC) $(CFLAGS) $(ARCH_FLAG_X86_64) $(CPPFLAGS) -c -o $@ ptyio.c - -clean : - $(RM) $(OBJS_X86) $(LIB_NAME_FULL_SPAWNER_X86) $(LIB_NAME_FULL_PTY_X86) - $(RM) $(OBJS_X86_64) $(LIB_NAME_FULL_SPAWNER_X86_64) $(LIB_NAME_FULL_PTY_X86_64) diff --git a/core/org.eclipse.cdt.core.macosx/library/PTY.h b/core/org.eclipse.cdt.core.macosx/library/PTY.h deleted file mode 100644 index f717942a01d..00000000000 --- a/core/org.eclipse.cdt.core.macosx/library/PTY.h +++ /dev/null @@ -1,29 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include <jni.h> -/* Header for class org_eclipse_cdt_utils_pty_PTY */ - -#ifndef _Included_org_eclipse_cdt_utils_pty_PTY -#define _Included_org_eclipse_cdt_utils_pty_PTY -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: org_eclipse_cdt_utils_pty_PTY - * Method: openMaster - * Signature: (Z)Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL Java_org_eclipse_cdt_utils_pty_PTY_openMaster - (JNIEnv *, jobject, jboolean); - -/* - * Class: org_eclipse_cdt_utils_pty_PTY - * Method: change_window_size - * Signature: (III)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTY_change_1window_1size - (JNIEnv *, jobject, jint, jint, jint); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/core/org.eclipse.cdt.core.macosx/library/PTYInputStream.h b/core/org.eclipse.cdt.core.macosx/library/PTYInputStream.h deleted file mode 100644 index e7349272b56..00000000000 --- a/core/org.eclipse.cdt.core.macosx/library/PTYInputStream.h +++ /dev/null @@ -1,32 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include <jni.h> -/* Header for class org_eclipse_cdt_utils_pty_PTYInputStream */ - -#ifndef _Included_org_eclipse_cdt_utils_pty_PTYInputStream -#define _Included_org_eclipse_cdt_utils_pty_PTYInputStream -#ifdef __cplusplus -extern "C" { -#endif -#undef org_eclipse_cdt_utils_pty_PTYInputStream_SKIP_BUFFER_SIZE -#define org_eclipse_cdt_utils_pty_PTYInputStream_SKIP_BUFFER_SIZE 2048L -/* Inaccessible static: skipBuffer */ -/* - * Class: org_eclipse_cdt_utils_pty_PTYInputStream - * Method: read0 - * Signature: (I[BI)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTYInputStream_read0 - (JNIEnv *, jobject, jint, jbyteArray, jint); - -/* - * Class: org_eclipse_cdt_utils_pty_PTYInputStream - * Method: close0 - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTYInputStream_close0 - (JNIEnv *, jobject, jint); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/core/org.eclipse.cdt.core.macosx/library/Spawner.h b/core/org.eclipse.cdt.core.macosx/library/Spawner.h deleted file mode 100644 index 02727f98a88..00000000000 --- a/core/org.eclipse.cdt.core.macosx/library/Spawner.h +++ /dev/null @@ -1,53 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include <jni.h> -/* Header for class org_eclipse_cdt_utils_spawner_Spawner */ - -#ifndef _Included_org_eclipse_cdt_utils_spawner_Spawner -#define _Included_org_eclipse_cdt_utils_spawner_Spawner -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: org_eclipse_cdt_utils_spawner_Spawner - * Method: exec0 - * Signature: ([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[I)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec0 - (JNIEnv *, jobject, jobjectArray, jobjectArray, jstring, jintArray); - -/* - * Class: org_eclipse_cdt_utils_spawner_Spawner - * Method: exec1 - * Signature: ([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec1 - (JNIEnv *, jobject, jobjectArray, jobjectArray, jstring); - -/* - * Class: org_eclipse_cdt_utils_spawner_Spawner - * Method: exec2 - * Signature: ([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[ILjava/lang/String;IZ)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec2 - (JNIEnv *, jobject, jobjectArray, jobjectArray, jstring, jintArray, jstring, jint, jboolean); - -/* - * Class: org_eclipse_cdt_utils_spawner_Spawner - * Method: raise - * Signature: (II)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_raise - (JNIEnv *, jobject, jint, jint); - -/* - * Class: org_eclipse_cdt_utils_spawner_Spawner - * Method: waitFor - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_waitFor - (JNIEnv *, jobject, jint); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/core/org.eclipse.cdt.core.macosx/library/SpawnerInputStream.h b/core/org.eclipse.cdt.core.macosx/library/SpawnerInputStream.h deleted file mode 100644 index ecf8f8c6a78..00000000000 --- a/core/org.eclipse.cdt.core.macosx/library/SpawnerInputStream.h +++ /dev/null @@ -1,32 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include <jni.h> -/* Header for class com_qnx_tools_utils_spawner_SpawnerInputStream */ - -#ifndef _Included_com_qnx_tools_utils_spawner_SpawnerInputStream -#define _Included_com_qnx_tools_utils_spawner_SpawnerInputStream -#ifdef __cplusplus -extern "C" { -#endif -#undef com_qnx_tools_utils_spawner_SpawnerInputStream_SKIP_BUFFER_SIZE -#define com_qnx_tools_utils_spawner_SpawnerInputStream_SKIP_BUFFER_SIZE 2048L -/* Inaccessible static: skipBuffer */ -/* - * Class: org_elipse_cdt_utils_spawner_SpawnerInputStream - * Method: read0 - * Signature: (I[BI)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_read0 - (JNIEnv *, jobject, jint, jbyteArray, jint); - -/* - * Class: org_eclipse_cdt_utils_spawner_SpawnerInputStream - * Method: close0 - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_close0 - (JNIEnv *, jobject, jint); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/core/org.eclipse.cdt.core.macosx/library/SpawnerOutputStream.h b/core/org.eclipse.cdt.core.macosx/library/SpawnerOutputStream.h deleted file mode 100644 index 444d71c698c..00000000000 --- a/core/org.eclipse.cdt.core.macosx/library/SpawnerOutputStream.h +++ /dev/null @@ -1,29 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include <jni.h> -/* Header for class com_qnx_tools_utils_spawner_SpawnerOutputStream */ - -#ifndef _Included_com_qnx_tools_utils_spawner_SpawnerOutputStream -#define _Included_com_qnx_tools_utils_spawner_SpawnerOutputStream -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: org_eclipse_cdt_utils_spawner_SpawnerOutputStream - * Method: write0 - * Signature: (I[BI)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerOutputStream_write0 - (JNIEnv *, jobject, jint, jbyteArray, jint); - -/* - * Class: org_eclipse_cdt_utils_spawner_SpawnerOutputStream - * Method: close0 - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerOutputStream_close0 - (JNIEnv *, jobject, jint); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/core/org.eclipse.cdt.core.macosx/library/exec0.h b/core/org.eclipse.cdt.core.macosx/library/exec0.h deleted file mode 100644 index b1e24c44fd6..00000000000 --- a/core/org.eclipse.cdt.core.macosx/library/exec0.h +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2010 QNX Software Systems 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: - * QNX Software Systems - initial API and implementation - *******************************************************************************/ -#include <unistd.h> -#include <sys/wait.h> -#include <sys/types.h> -#include <signal.h> -#include <errno.h> - -extern pid_t exec0(const char *path, char *const argv[], - char *const envp[], const char *dirpath, - int channels[3] ); - -extern pid_t exec_pty(const char *path, char *const argv[], - char *const envp[], const char *dirpath, - int channels[3], const char *pts_name, int fdm, - int console); - -extern int wait0(pid_t pid); diff --git a/core/org.eclipse.cdt.core.macosx/library/exec_pty.c b/core/org.eclipse.cdt.core.macosx/library/exec_pty.c deleted file mode 100644 index e020053db41..00000000000 --- a/core/org.eclipse.cdt.core.macosx/library/exec_pty.c +++ /dev/null @@ -1,189 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2010 QNX Software Systems 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: - * QNX Software Systems - initial API and implementation - * Wind River Systems, Inc. - * Mikhail Zabaluev (Nokia) - bug 82744 - * Mikhail Sennikovsky - bug 145737 - *******************************************************************************/ -#include "exec0.h" -#include "openpty.h" -#include <unistd.h> -#include <stdlib.h> -#include <stdio.h> -#include <errno.h> -#include <string.h> -#include <libgen.h> -#include <stdlib.h> -#include <termios.h> - -/* from pfind.c */ -extern char *pfind(const char *name, char * const envp[]); - -pid_t -exec_pty(const char *path, char *const argv[], char *const envp[], - const char *dirpath, int channels[3], const char *pts_name, int fdm, int console) -{ - int pipe2[2]; - pid_t childpid; - char *full_path; - - /* - * We use pfind() to check that the program exists and is an executable. - * If not pass the error up. Also execve() wants a full path. - */ - full_path = pfind(path, envp); - if (full_path == NULL) { - fprintf(stderr, "Unable to find full path for \"%s\"\n", (path) ? path : ""); - return -1; - } - - /* - * Make sure we can create our pipes before forking. - */ - if (channels != NULL && console) { - if (pipe(pipe2) < 0) { - fprintf(stderr, "%s(%d): returning due to error: %s\n", __FUNCTION__, __LINE__, strerror(errno)); - free(full_path); - return -1; - } - } - - childpid = fork(); - - if (childpid < 0) { - fprintf(stderr, "%s(%d): returning due to error: %s\n", __FUNCTION__, __LINE__, strerror(errno)); - free(full_path); - return -1; - } else if (childpid == 0) { /* child */ - - chdir(dirpath); - - if (channels != NULL) { - int fds; - - if (!console && setsid() < 0) { - perror("setsid()"); - return -1; - } - - fds = ptys_open(fdm, pts_name); - if (fds < 0) { - fprintf(stderr, "%s(%d): returning due to error: %s\n", __FUNCTION__, __LINE__, strerror(errno)); - return -1; - } - - /* Close the read end of pipe2 */ - if (console && close(pipe2[0]) == -1) { - perror("close(pipe2[0]))"); - } - - /* close the master, no need in the child */ - close(fdm); - - if (console) { - set_noecho(fds); - if (setpgid(getpid(), getpid()) < 0) { - perror("setpgid()"); - return -1; - } - } - - /* redirections */ - dup2(fds, STDIN_FILENO); /* dup stdin */ - dup2(fds, STDOUT_FILENO); /* dup stdout */ - if (console) { - dup2(pipe2[1], STDERR_FILENO); /* dup stderr */ - } else { - dup2(fds, STDERR_FILENO); /* dup stderr */ - } - close(fds); /* done with fds. */ - } - - /* Close all the fd's in the child */ - { - int fdlimit = sysconf(_SC_OPEN_MAX); - int fd = 3; - - while (fd < fdlimit) - close(fd++); - } - - if (envp[0] == NULL) { - execv(full_path, argv); - } else { - execve(full_path, argv, envp); - } - - _exit(127); - - } else if (childpid != 0) { /* parent */ - if (console) { - set_noecho(fdm); - } - if (channels != NULL) { - channels[0] = fdm; /* Input Stream. */ - channels[1] = fdm; /* Output Stream. */ - if (console) { - /* close the write end of pipe1 */ - if (close(pipe2[1]) == -1) - perror("close(pipe2[1])"); - channels[2] = pipe2[0]; /* stderr Stream. */ - } else { - channels[2] = fdm; /* Error Stream. */ - } - } - - free(full_path); - return childpid; - } - - free(full_path); - return -1; /*NOT REACHED */ -} -#ifdef __STAND_ALONE__ -int main(int argc, char **argv, char **envp) { - const char *path = "./bufferring_test"; - int channels[3] = { -1, -1, -1}; - int status; - FILE *app_stdin; - FILE *app_stdout; - FILE *app_stderr; - char pts_name[32]; - int fdm; - char buffer[32]; - - fdm = ptym_open(pts_name); - status = exec_pty(path, argv, envp, ".", channels, pts_name, fdm); - if (status >= 0) { - app_stdin = fdopen(channels[0], "w"); - app_stdout = fdopen(channels[1], "r"); - app_stderr = fdopen(channels[2], "r"); - if (app_stdout == NULL || app_stderr == NULL || app_stdin == NULL) { - fprintf(stderr, "PROBLEMS\n"); - } else { - fputs("foo\n", app_stdin); - fputs("bar\n", app_stdin); - while(fgets(buffer, sizeof buffer, app_stdout) != NULL) { - fprintf(stdout, "STDOUT: %s\n", buffer); - } - while(fgets(buffer, sizeof buffer, app_stderr) != NULL) { - fprintf(stdout, "STDERR: %s\n", buffer); - } - } - } - fputs("bye\n", stdout); - close(channels[0]); - close(channels[1]); - close(channels[2]); - return 0; -} -#endif diff --git a/core/org.eclipse.cdt.core.macosx/library/exec_unix.c b/core/org.eclipse.cdt.core.macosx/library/exec_unix.c deleted file mode 100644 index 4feb805f15d..00000000000 --- a/core/org.eclipse.cdt.core.macosx/library/exec_unix.c +++ /dev/null @@ -1,161 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2010 QNX Software Systems 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: - * QNX Software Systems - initial API and implementation - * Wind River Systems, Inc. - * Mikhail Sennikovsky - bug 145737 - *******************************************************************************/ -#include "exec0.h" -#include <unistd.h> -#include <stdlib.h> -#include <stdio.h> -#include <errno.h> -#include <string.h> -#include <libgen.h> -#include <stdlib.h> - -/* from pfind.c */ -extern char *pfind(const char *name, char * const envp[]); - -pid_t -exec0(const char *path, char *const argv[], char *const envp[], - const char *dirpath, int channels[3]) -{ - int pipe0[2], pipe1[2], pipe2[2]; - pid_t childpid; - char *full_path; - - /* - * We use pfind() to check that the program exists and is an executable. - * If not pass the error up. Also execve() wants a full path. - */ - full_path = pfind(path, envp); - if (full_path == NULL) { - fprintf(stderr, "Unable to find full path for \"%s\"\n", (path) ? path : ""); - return -1; - } - - /* - * Make sure we can create our pipes before forking. - */ - if (channels != NULL) { - if (pipe(pipe0) < 0 || pipe(pipe1) < 0 || pipe(pipe2) < 0) { - fprintf(stderr, "%s(%d): returning due to error.\n", - __FUNCTION__, __LINE__); - free(full_path); - return -1; - } - } - - childpid = fork(); - - if (childpid < 0) { - fprintf(stderr, "%s(%d): returning due to error: %s\n", - __FUNCTION__, __LINE__, strerror(errno)); - free(full_path); - return -1; - } else if (childpid == 0) { /* child */ - char *ptr; - - chdir(dirpath); - - if (channels != NULL) { - /* Close the write end of pipe0 */ - if (close(pipe0[1]) == -1) - perror("close(pipe0[1])"); - - /* Close the read end of pipe1 */ - if (close(pipe1[0]) == -1) - perror("close(pipe1[0])"); - - /* Close the read end of pipe2 */ - if (close(pipe2[0]) == -1) - perror("close(pipe2[0]))"); - - /* redirections */ - dup2(pipe0[0], STDIN_FILENO); /* dup stdin */ - dup2(pipe1[1], STDOUT_FILENO); /* dup stdout */ - dup2(pipe2[1], STDERR_FILENO); /* dup stderr */ - } - - /* Close all the fd's in the child */ - { - int fdlimit = sysconf(_SC_OPEN_MAX); - int fd = 3; - - while (fd < fdlimit) - close(fd++); - } - - setpgid(getpid(), getpid()); - - if (envp[0] == NULL) { - execv(full_path, argv); - } else { - execve(full_path, argv, envp); - } - - _exit(127); - - } else if (childpid != 0) { /* parent */ - - char b; - - if (channels != NULL) { - /* close the read end of pipe1 */ - if (close(pipe0[0]) == -1) - perror("close(pipe0[0])"); - - /* close the write end of pipe2 */ - if (close(pipe1[1]) == -1) - perror("close(pipe1[1])"); - - /* close the write end of pipe2 */ - if (close(pipe2[1]) == -1) - perror("close(pipe2[1])"); - - channels[0] = pipe0[1]; /* Output Stream. */ - channels[1] = pipe1[0]; /* Input Stream. */ - channels[2] = pipe2[0]; /* Input Stream. */ - } - - free(full_path); - return childpid; - } - - free(full_path); - return -1; /*NOT REACHED */ -} - - -int wait0(pid_t pid) -{ - int status; - int val = -1; - - if (pid < 0) - return -1; - - for (;;) { - if (waitpid(pid, &status, 0) < 0) { - if (errno == EINTR) { - // interrupted system call - retry - continue; - } - } - break; - } - if (WIFEXITED(status)) { - val = WEXITSTATUS(status); - } - - return val; -} diff --git a/core/org.eclipse.cdt.core.macosx/library/io.c b/core/org.eclipse.cdt.core.macosx/library/io.c deleted file mode 100644 index 17d12ae639d..00000000000 --- a/core/org.eclipse.cdt.core.macosx/library/io.c +++ /dev/null @@ -1,116 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002 - 2005 QNX Software Systems 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: - * QNX Software Systems - initial API and implementation - *******************************************************************************/ -#include <jni.h> -#include <stdio.h> -#include <SpawnerInputStream.h> -#include <SpawnerOutputStream.h> -#include <unistd.h> - -/* Header for class _org_eclipse_cdt_utils_spawner_SpawnerInputStream */ -/* Header for class _org_eclipse_cdt_utils_spawner_SpawnerOutputStream */ - -/* - * Class: org_eclipse_cdt_utils_spawner_SpawnerInputStream - * Method: read0 - * Signature: (I)I - */ -JNIEXPORT jint JNICALL -Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_read0(JNIEnv * env, - jobject jobj, - jint jfd, - jbyteArray buf, - jint buf_len) -{ - int fd; - int status; - jbyte *data; - int data_len; - - data = (*env)->GetByteArrayElements(env, buf, 0); - data_len = buf_len; - fd = jfd; - - status = read( fd, data, data_len ); - (*env)->ReleaseByteArrayElements(env, buf, data, 0); - - if (status == 0) { - /* EOF. */ - status = -1; - } else if (status == -1) { - /* Error, toss an exception */ - jclass exception = (*env)->FindClass(env, "java/io/IOException"); - if (exception == NULL) { - /* Give up. */ - return -1; - } - (*env)->ThrowNew(env, exception, "read error"); - } - - return status; -} - - -/* - * Class: org_eclipse_cdt_utils_spawner_SpawnerInputStream - * Method: close0 - * Signature: (I)I - */ -JNIEXPORT jint JNICALL -Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_close0(JNIEnv * env, - jobject jobj, - jint fd) -{ - return close(fd); -} - -/* - * Class: org_eclipse_cdt_utils_spawner_SpawnerOutputStream - * Method: write0 - * Signature: (II)I - */ -JNIEXPORT jint JNICALL -Java_org_eclipse_cdt_utils_spawner_SpawnerOutputStream_write0(JNIEnv * env, - jobject jobj, - jint jfd, - jbyteArray buf, - jint buf_len) -{ - int status; - int fd; - jbyte *data; - int data_len; - - data = (*env)->GetByteArrayElements(env, buf, 0); - data_len = buf_len; - fd = jfd; - - status = write(fd, data, data_len); - (*env)->ReleaseByteArrayElements(env, buf, data, 0); - - return status; -} - - -/* - * Class: org_eclipse_cdt_utils_spawner_SpawnerOutputStream - * Method: close0 - * Signature: (I)I - */ -JNIEXPORT jint JNICALL -Java_org_eclipse_cdt_utils_spawner_SpawnerOutputStream_close0(JNIEnv * env, - jobject jobj, - jint fd) -{ - return close(fd); -} diff --git a/core/org.eclipse.cdt.core.macosx/library/openpty.c b/core/org.eclipse.cdt.core.macosx/library/openpty.c deleted file mode 100644 index 933349220f9..00000000000 --- a/core/org.eclipse.cdt.core.macosx/library/openpty.c +++ /dev/null @@ -1,134 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2017 QNX Software Systems 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: - * QNX Software Systems - initial API and implementation - * Wind River Systems, Inc. - * Mikhail Zabaluev (Nokia) - bug 82744 - * Corey Ashford (IBM) - bug 272370, bug 272372 - * Martin Oberhuber - [519886] align w/ Linux, support OSX 10.13 - *******************************************************************************/ - -/* _XOPEN_SOURCE is needed to bring in the header for ptsname */ -#define _XOPEN_SOURCE -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/ioctl.h> -#include <fcntl.h> -#include <termios.h> -#include <errno.h> -#include <unistd.h> -#include <stdio.h> -#include <string.h> -#include <grp.h> - -#include <stdlib.h> - -/** - * This is taken from R. W. Stevens book. - * Alain Magloire. - */ - -int ptym_open (char *pts_name); -int ptys_open (int fdm, const char * pts_name); -void set_noecho(int fd); - -int -openpty(int *amaster, int *aslave, char *name, struct termios *termp, struct winsize *winp) -{ - char line[20]; - line[0]=0; - *amaster = ptym_open(line); - if (*amaster < 0) - return -1; - *aslave = ptys_open(*amaster, line); - if (*aslave < 0) { - close(*amaster); - return -1; - } - - if (name) - strcpy(name, line); -#ifndef TCSAFLUSH -#define TCSAFLUSH TCSETAF -#endif - if (termp) - (void) tcsetattr(*aslave, TCSAFLUSH, termp); -#ifdef TIOCSWINSZ - if (winp) - (void) ioctl(*aslave, TIOCSWINSZ, (char *)winp); -#endif - return 0; -} - -void -set_noecho(int fd) -{ - struct termios stermios; - if (tcgetattr(fd, &stermios) < 0) { - return ; - } - - /* turn off echo */ - stermios.c_lflag &= ~(ECHO | ECHOE | ECHOK | ECHONL); - /* Turn off the NL to CR/NL mapping ou output. */ - /*stermios.c_oflag &= ~(ONLCR);*/ - - stermios.c_iflag |= (IGNCR); - - tcsetattr(fd, TCSANOW, &stermios); -} - -int -ptym_open(char * pts_name) -{ - int fdm; - char *ptr; - - strcpy(pts_name, "/dev/ptmx"); - fdm = posix_openpt(O_RDWR|O_NOCTTY); - if (fdm < 0) - return -1; - if (grantpt(fdm) < 0) { /* grant access to slave */ - close(fdm); - return -2; - } - if (unlockpt(fdm) < 0) { /* clear slave's lock flag */ - close(fdm); - return -3; - } - ptr = ptsname(fdm); - if (ptr == NULL) { /* get slave's name */ - close (fdm); - return -4; - } - strcpy(pts_name, ptr); /* return name of slave */ - return fdm; /* return fd of master */ -} - -int -ptys_open(int fdm, const char * pts_name) -{ - int fds; - /* following should allocate controlling terminal */ - fds = open(pts_name, O_RDWR); - if (fds < 0) { - close(fdm); - return -5; - } - -#if defined(TIOCSCTTY) - /* TIOCSCTTY is the BSD way to acquire a controlling terminal. */ - if (ioctl(fds, TIOCSCTTY, (char *)0) < 0) { - // ignore error: this is expected in console-mode - } -#endif - return fds; -} diff --git a/core/org.eclipse.cdt.core.macosx/library/openpty.h b/core/org.eclipse.cdt.core.macosx/library/openpty.h deleted file mode 100644 index 43d2b8bcb97..00000000000 --- a/core/org.eclipse.cdt.core.macosx/library/openpty.h +++ /dev/null @@ -1,19 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2010 QNX Software Systems 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: - * QNX Software Systems - initial API and implementation - *******************************************************************************/ -#ifndef _OPENPTY_H -#define _OPENPTY_H -int ptym_open (char *pts_name); -int ptys_open (int fdm, const char * pts_name); -void set_noecho(int fd); -#endif diff --git a/core/org.eclipse.cdt.core.macosx/library/pfind.c b/core/org.eclipse.cdt.core.macosx/library/pfind.c deleted file mode 100644 index 01b9e5cc054..00000000000 --- a/core/org.eclipse.cdt.core.macosx/library/pfind.c +++ /dev/null @@ -1,112 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2011 QNX Software Systems 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: - * QNX Software Systems - initial API and implementation - * Wind River Systems, Inc. - * Mikhail Sennikovsky - bug 145737 - * Everton Rufino Constantino (IBM) - bug 237611 - *******************************************************************************/ -/* - * pfind.c - Search for a binary in $PATH. - */ - -#include <stdio.h> -#include <unistd.h> -#include <stdlib.h> -#include <string.h> -#include <limits.h> - -#ifndef PATH_MAX -#define PATH_MAX 1024 -#endif - -#define PATH_DEF "PATH=" -const int path_def_len = 5; /* strlen(PATH_DEF); */ - -char * path_val(char * const envp[]) -{ - int i; - if (envp == NULL || envp[0] == NULL) - return getenv("PATH" ); - - for(i = 0; envp[i] != NULL; i++){ - char* p = envp[i]; - if(!strncmp(PATH_DEF, p, path_def_len)){ - return p + path_def_len; - } - } - - return NULL; -} - -char * pfind(const char *name, char * const envp[]) -{ - char *tok; - char *sp; - char *path; - char fullpath[PATH_MAX+1]; - - /* Sanity check. */ - if (name == NULL) { - fprintf(stderr, "pfind(): Null argument.\n"); - return NULL; - } - - /* For absolute name or name with a path, check if it is an executable. */ - if (name[0] == '/' || name[0] == '.') { - if (access(name, X_OK) == 0) { - return strdup(name); - } - return NULL; - } - - /* Search in the PATH environment. */ - path = path_val( envp ); - - if (path == NULL || strlen(path) <= 0) { - fprintf(stderr, "Unable to get $PATH.\n"); - return NULL; - } - - /* The value return by getenv() is readonly */ - path = strdup(path); - - tok = strtok_r(path, ":", &sp); - while (tok != NULL) { - snprintf(fullpath, sizeof(fullpath) - 1, "%s/%s", tok, name); - - if (access(fullpath, X_OK) == 0) { - free(path); - return strdup(fullpath); - } - - tok = strtok_r( NULL, ":", &sp ); - } - - free(path); - return NULL; -} - -#ifdef BUILD_WITH_MAIN -int main(int argc, char **argv) -{ - int i; - char *fullpath; - - for (i=1; i<argc; i++) { - fullpath = pfind(argv[i], NULL); - if (fullpath == NULL) - printf("Unable to find %s in $PATH.\n", argv[i]); - else - printf("Found %s @ %s.\n", argv[i], fullpath); - } -} -#endif diff --git a/core/org.eclipse.cdt.core.macosx/library/pty.c b/core/org.eclipse.cdt.core.macosx/library/pty.c deleted file mode 100644 index e6ebd9015a2..00000000000 --- a/core/org.eclipse.cdt.core.macosx/library/pty.c +++ /dev/null @@ -1,74 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2015 QNX Software Systems 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: - * QNX Software Systems - initial API and implementation - * Martin Oberhuber (Wind River) - Bug 476709 - Fix change_window_size() - *******************************************************************************/ -#include "PTY.h" -#include "openpty.h" - -#include <sys/ioctl.h> - -/* - * Class: org_eclipse_cdt_utils_pty_PTY - * Method: forkpty - * Signature: ()I - */ -JNIEXPORT jstring JNICALL -Java_org_eclipse_cdt_utils_pty_PTY_openMaster (JNIEnv *env, jobject jobj, jboolean console) { - jfieldID fid; /* Store the field ID */ - jstring jstr = NULL; - int master = -1; - char line[1024]; /* FIXME: Should be enough */ - jclass cls; - - line[0] = '\0'; - - master = ptym_open(line); - if (master >= 0) { - if (console) { - // turn off echo - set_noecho(master); - } - - /* Get a reference to the obj's class */ - cls = (*env)->GetObjectClass(env, jobj); - - /* Set the master fd. */ - fid = (*env)->GetFieldID(env, cls, "master", "I"); - if (fid == NULL) { - return NULL; - } - (*env)->SetIntField(env, jobj, fid, (jint)master); - - /* Create a new String for the slave. */ - jstr = (*env)->NewStringUTF(env, line); - } - return jstr; -} - -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTY_change_1window_1size - (JNIEnv *env, jobject jobj, jint fdm, jint width, jint height) -{ -#ifdef TIOCSWINSZ - struct winsize win; - - win.ws_col = width; - win.ws_row = height; - win.ws_xpixel = 0; - win.ws_ypixel = 0; - - return ioctl(fdm, TIOCSWINSZ, &win); -#else -#error no TIOCSWINSZ - return 0; -#endif -} diff --git a/core/org.eclipse.cdt.core.macosx/library/spawner.c b/core/org.eclipse.cdt.core.macosx/library/spawner.c deleted file mode 100644 index 623b1382cf8..00000000000 --- a/core/org.eclipse.cdt.core.macosx/library/spawner.c +++ /dev/null @@ -1,305 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2010 QNX Software Systems 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: - * QNX Software Systems - initial API and implementation - * Wind River Systems, Inc. - * Mikhail Zabaluev (Nokia) - bug 82744 - *******************************************************************************/ -#include <unistd.h> -#include <stdlib.h> -#include <stdio.h> -#include <signal.h> -#include <string.h> -#include <jni.h> - -#include "exec0.h" -#include <Spawner.h> - - -#define DEBUGIT 0 - - -/* - * Header for class org_eclipse_cdt_utils_spawner_Spawner - */ - - -#if DEBUGIT -static void print_array(char **c_array) -{ - if (c_array) { - char **p = c_array; - for (; *p; p++) { - if (*p) { - fprintf(stderr, " %s", *p); - } - } - } else { - fprintf(stderr, "null"); - } - fprintf(stderr, "\n"); -} -#endif - - -static char **alloc_c_array(JNIEnv * env, jobjectArray j_array) -{ - int i; - jint c_array_size = (*env)->GetArrayLength(env, j_array); - char **c_array = calloc(c_array_size + 1, sizeof(*c_array)); - - if (c_array == NULL) - return NULL; - - for (i = 0; i < c_array_size; i++) { - jstring j_str = - (jstring) (*env)->GetObjectArrayElement(env, j_array, i); - const char *c_str = (*env)->GetStringUTFChars(env, j_str, NULL); - c_array[i] = (char *) strdup(c_str); - (*env)->ReleaseStringUTFChars(env, j_str, c_str); - (*env)->DeleteLocalRef(env, j_str); - } - - return c_array; -} - - -static void free_c_array(char **c_array) -{ - if (c_array) { - char **p = c_array; - for (; *p; p++) { - if (*p) { - free(*p); - } - } - free(c_array); - } -} - - -/* - * Class: org_eclipse_cdt_utils_spawner_Spawner - * Method: exec2 - * Signature: ([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[ILorg/eclipse/cdt/utils/pty/PTY;)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec2 - (JNIEnv *env, jobject jobj, jobjectArray jcmd, jobjectArray jenv, jstring jdir, jintArray jchannels, - jstring jslaveName, jint masterFD, jboolean console) -{ - jint *channels = (*env)->GetIntArrayElements(env, jchannels, 0); - const char *dirpath = (*env)->GetStringUTFChars(env, jdir, NULL); - const char *pts_name = (*env)->GetStringUTFChars(env, jslaveName, NULL); - char **cmd = NULL; - char **envp = NULL; - int fd[3]; - pid_t pid = -1; - - if (channels == NULL) - goto bail_out; - - cmd = alloc_c_array(env, jcmd); - if (cmd == NULL) - goto bail_out; - - envp = alloc_c_array(env, jenv); - if (envp == NULL) - goto bail_out; - -#if DEBUGIT - fprintf(stderr, "command:"); - print_array(cmd); - fprintf(stderr, "Envp:"); - print_array(envp); - fprintf(stderr, "dirpath: %s\n", dirpath); - fprintf(stderr, "pts_name: %s\n", pts_name); -#endif - - pid = exec_pty(cmd[0], cmd, envp, dirpath, fd, pts_name, masterFD, console); - if (pid < 0) - goto bail_out; - - channels[0] = fd[0]; - channels[1] = fd[1]; - channels[2] = fd[2]; - - bail_out: - (*env)->ReleaseIntArrayElements(env, jchannels, channels, 0); - (*env)->ReleaseStringUTFChars(env, jdir, dirpath); - (*env)->ReleaseStringUTFChars(env, jslaveName, pts_name); - if (cmd) - free_c_array(cmd); - if (envp) - free_c_array(envp); - return pid; -} - - -JNIEXPORT jint JNICALL -Java_org_eclipse_cdt_utils_spawner_Spawner_exec1(JNIEnv * env, jobject jobj, - jobjectArray jcmd, - jobjectArray jenv, - jstring jdir) -{ - const char *dirpath = (*env)->GetStringUTFChars(env, jdir, NULL); - char **cmd = NULL; - char **envp = NULL; - pid_t pid = -1; - - cmd = alloc_c_array(env, jcmd); - if (cmd == NULL) - goto bail_out; - - envp = alloc_c_array(env, jenv); - if (envp == NULL) - goto bail_out; - -#if DEBUGIT - fprintf(stderr, "command:"); - print_array(cmd); - fprintf(stderr, "Envp:"); - print_array(envp); - fprintf(stderr, "dirpath: %s\n", dirpath); -#endif - - pid = exec0(cmd[0], cmd, envp, dirpath, NULL); - if (pid < 0) - goto bail_out; - - bail_out: - (*env)->ReleaseStringUTFChars(env, jdir, dirpath); - if (cmd) - free_c_array(cmd); - if (envp) - free_c_array(envp); - return pid; -} - -/* - * Class: org_eclipse_cdt_utils_spawner_Spawner - * Method: exec0 - * Signature: ([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[I)I - */ -JNIEXPORT jint JNICALL -Java_org_eclipse_cdt_utils_spawner_Spawner_exec0(JNIEnv * env, jobject jobj, - jobjectArray jcmd, - jobjectArray jenv, - jstring jdir, - jintArray jchannels) -{ - jint *channels = (*env)->GetIntArrayElements(env, jchannels, 0); - const char *dirpath = (*env)->GetStringUTFChars(env, jdir, NULL); - char **cmd = NULL; - char **envp = NULL; - int fd[3]; - pid_t pid = -1; - - if (channels == NULL) - goto bail_out; - - cmd = alloc_c_array(env, jcmd); - if (cmd == NULL) - goto bail_out; - - envp = alloc_c_array(env, jenv); - if (envp == NULL) - goto bail_out; - -#if DEBUGIT - fprintf(stderr, "command:"); - print_array(cmd); - fprintf(stderr, "Envp:"); - print_array(envp); - fprintf(stderr, "dirpath: %s\n", dirpath); -#endif - - pid = exec0(cmd[0], cmd, envp, dirpath, fd); - if (pid < 0) - goto bail_out; - - channels[0] = fd[0]; - channels[1] = fd[1]; - channels[2] = fd[2]; - - bail_out: - (*env)->ReleaseIntArrayElements(env, jchannels, channels, 0); - (*env)->ReleaseStringUTFChars(env, jdir, dirpath); - if (cmd) - free_c_array(cmd); - if (envp) - free_c_array(envp); - return pid; -} - -/* - * Class: org_eclipse_cdt_utils_spawner_Spawner - * Method: raise - * Signature: (II)I - */ -JNIEXPORT jint JNICALL -Java_org_eclipse_cdt_utils_spawner_Spawner_raise(JNIEnv * env, jobject jobj, - jint pid, jint sig) -{ - int status = -1; - - switch (sig) { - case 0: /* NOOP */ - status = killpg(pid, 0); - if(status == -1) { - status = kill(pid, 0); - } - break; - - case 2: /* INTERRUPT */ - status = killpg(pid, SIGINT); - if(status == -1) { - status = kill(pid, SIGINT); - } - break; - - case 9: /* KILL */ - status = killpg(pid, SIGKILL); - if(status == -1) { - status = kill(pid, SIGKILL); - } - break; - - case 15: /* TERM */ - status = killpg(pid, SIGTERM); - if(status == -1) { - status = kill(pid, SIGTERM); - } - break; - - default: - status = killpg(pid, sig); /* WHAT ?? */ - if(status == -1) { - status = kill(pid, sig); /* WHAT ?? */ - } - break; - } - - return status; -} - - - -/* - * Class: org_eclipse_cdt_utils_spawner_Spawner - * Method: waitFor - * Signature: (I)I - */ -JNIEXPORT jint JNICALL -Java_org_eclipse_cdt_utils_spawner_Spawner_waitFor(JNIEnv * env, - jobject jobj, jint pid) -{ - return wait0(pid); -} diff --git a/core/org.eclipse.cdt.core.macosx/os/macosx/aarch64/libpty.jnilib b/core/org.eclipse.cdt.core.macosx/os/macosx/aarch64/libpty.jnilib Binary files differnew file mode 100755 index 00000000000..a8028f753b0 --- /dev/null +++ b/core/org.eclipse.cdt.core.macosx/os/macosx/aarch64/libpty.jnilib diff --git a/core/org.eclipse.cdt.core.macosx/os/macosx/aarch64/libspawner.jnilib b/core/org.eclipse.cdt.core.macosx/os/macosx/aarch64/libspawner.jnilib Binary files differnew file mode 100755 index 00000000000..1b2ebe73c12 --- /dev/null +++ b/core/org.eclipse.cdt.core.macosx/os/macosx/aarch64/libspawner.jnilib diff --git a/core/org.eclipse.cdt.core.macosx/os/macosx/x86/libpty.jnilib b/core/org.eclipse.cdt.core.macosx/os/macosx/x86/libpty.jnilib Binary files differdeleted file mode 100755 index 50ba6991d48..00000000000 --- a/core/org.eclipse.cdt.core.macosx/os/macosx/x86/libpty.jnilib +++ /dev/null diff --git a/core/org.eclipse.cdt.core.macosx/os/macosx/x86/libspawner.jnilib b/core/org.eclipse.cdt.core.macosx/os/macosx/x86/libspawner.jnilib Binary files differdeleted file mode 100755 index bde561aed62..00000000000 --- a/core/org.eclipse.cdt.core.macosx/os/macosx/x86/libspawner.jnilib +++ /dev/null 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 Binary files differindex b18de5e480c..f3827e81292 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 diff --git a/core/org.eclipse.cdt.core.macosx/os/macosx/x86_64/libspawner.jnilib b/core/org.eclipse.cdt.core.macosx/os/macosx/x86_64/libspawner.jnilib Binary files differindex 8d8c80bac6e..f5fc0ca37d4 100755 --- a/core/org.eclipse.cdt.core.macosx/os/macosx/x86_64/libspawner.jnilib +++ b/core/org.eclipse.cdt.core.macosx/os/macosx/x86_64/libspawner.jnilib diff --git a/core/org.eclipse.cdt.core.macosx/plugin.properties b/core/org.eclipse.cdt.core.macosx/plugin.properties index 3ea2577f208..fb9494360d3 100644 --- a/core/org.eclipse.cdt.core.macosx/plugin.properties +++ b/core/org.eclipse.cdt.core.macosx/plugin.properties @@ -1,2 +1,2 @@ -fragmentName.linux=C/C++ Development Tools Core for Mac OS X +fragmentName.macosx=C/C++ Development Tools Core for Mac OS X providerName=Eclipse CDT diff --git a/core/org.eclipse.cdt.core.macosx/pom.xml b/core/org.eclipse.cdt.core.macosx/pom.xml index 2814786462c..faa08aa814f 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.0.0-SNAPSHOT</version> + <version>10.7.0-SNAPSHOT</version> <relativePath>../../pom.xml</relativePath> </parent> - <version>6.0.0-SNAPSHOT</version> + <version>6.0.600-SNAPSHOT</version> <artifactId>org.eclipse.cdt.core.macosx</artifactId> <packaging>eclipse-plugin</packaging> @@ -30,9 +40,25 @@ <ws>cocoa</ws> <arch>x86_64</arch> </environment> + <environment> + <os>macosx</os> + <ws>cocoa</ws> + <arch>aarch64</arch> + </environment> </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/.classpath b/core/org.eclipse.cdt.core.native/.classpath index eca7bdba8f0..e801ebfb468 100644 --- a/core/org.eclipse.cdt.core.native/.classpath +++ b/core/org.eclipse.cdt.core.native/.classpath @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="src" path="src"/> <classpathentry kind="output" path="bin"/> diff --git a/core/org.eclipse.cdt.core.native/.options b/core/org.eclipse.cdt.core.native/.options new file mode 100644 index 00000000000..fe17ebc0cbf --- /dev/null +++ b/core/org.eclipse.cdt.core.native/.options @@ -0,0 +1,9 @@ +org.eclipse.cdt.core.native/debug=false + +org.eclipse.cdt.core.native/debug/spawner=false +org.eclipse.cdt.core.native/debug/spawner/details=false +org.eclipse.cdt.core.native/debug/spawner/starter=false +org.eclipse.cdt.core.native/debug/spawner/read_report=false + +# Used by org.eclipse.cdt.core.win32 fragment +org.eclipse.cdt.core.native/debug/win32/registry=false diff --git a/core/org.eclipse.cdt.core.native/.project b/core/org.eclipse.cdt.core.native/.project index 16748cc2a7f..7b153603502 100644 --- a/core/org.eclipse.cdt.core.native/.project +++ b/core/org.eclipse.cdt.core.native/.project @@ -30,5 +30,6 @@ <nature>org.eclipse.jdt.core.javanature</nature> <nature>org.eclipse.pde.PluginNature</nature> <nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature> + <nature>org.eclipse.cdt.core.cnature</nature> </natures> </projectDescription> diff --git a/core/org.eclipse.cdt.core.native/.settings/org.eclipse.core.resources.prefs b/core/org.eclipse.cdt.core.native/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 00000000000..99f26c0203a --- /dev/null +++ b/core/org.eclipse.cdt.core.native/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/<project>=UTF-8 diff --git a/core/org.eclipse.cdt.core.native/.settings/org.eclipse.jdt.core.prefs b/core/org.eclipse.cdt.core.native/.settings/org.eclipse.jdt.core.prefs index 2b6ecff8a01..e3a8104f9ca 100644 --- a/core/org.eclipse.cdt.core.native/.settings/org.eclipse.jdt.core.prefs +++ b/core/org.eclipse.cdt.core.native/.settings/org.eclipse.jdt.core.prefs @@ -30,9 +30,9 @@ org.eclipse.jdt.core.compiler.annotation.nullable.secondary= org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.methodParameters=generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.compliance=11 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -49,6 +49,7 @@ org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled org.eclipse.jdt.core.compiler.problem.discouragedReference=warning org.eclipse.jdt.core.compiler.problem.emptyStatement=warning +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning @@ -107,6 +108,7 @@ org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=igno org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled @@ -144,13 +146,14 @@ org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.release=disabled -org.eclipse.jdt.core.compiler.source=1.8 +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=11 org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns=false org.eclipse.jdt.core.formatter.align_with_spaces=false +org.eclipse.jdt.core.formatter.alignment_for_additive_operator=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 @@ -158,21 +161,24 @@ org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_c org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_assignment=0 -org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_bitwise_operator=16 org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 org.eclipse.jdt.core.formatter.alignment_for_compact_loops=16 org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 org.eclipse.jdt.core.formatter.alignment_for_enum_constants=16 org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0 +org.eclipse.jdt.core.formatter.alignment_for_logical_operator=16 org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 org.eclipse.jdt.core.formatter.alignment_for_module_statements=16 org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_multiplicative_operator=16 org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_string_concatenation=16 org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 @@ -264,11 +270,12 @@ org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_after_additive_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_bitwise_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert @@ -299,6 +306,8 @@ org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_after_logical_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_multiplicative_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert @@ -323,13 +332,17 @@ org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_relational_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert +org.eclipse.jdt.core.formatter.insert_space_after_shift_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_string_concatenation=insert org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_additive_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_bitwise_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert @@ -377,6 +390,8 @@ org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do no org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_before_logical_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_multiplicative_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert @@ -413,9 +428,12 @@ org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not inser org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_relational_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_shift_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_string_concatenation=insert org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert @@ -454,10 +472,14 @@ org.eclipse.jdt.core.formatter.tabulation.char=tab org.eclipse.jdt.core.formatter.tabulation.size=4 org.eclipse.jdt.core.formatter.use_on_off_tags=true org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false +org.eclipse.jdt.core.formatter.wrap_before_additive_operator=true org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false -org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true +org.eclipse.jdt.core.formatter.wrap_before_bitwise_operator=true org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true +org.eclipse.jdt.core.formatter.wrap_before_logical_operator=true +org.eclipse.jdt.core.formatter.wrap_before_multiplicative_operator=true org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true +org.eclipse.jdt.core.formatter.wrap_before_string_concatenation=true org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true org.eclipse.jdt.core.incompatibleJDKLevel=ignore org.eclipse.jdt.core.incompleteClasspath=error diff --git a/core/org.eclipse.cdt.core.native/.settings/org.eclipse.jdt.ui.prefs b/core/org.eclipse.cdt.core.native/.settings/org.eclipse.jdt.ui.prefs index e44576346c4..d35ba9b5231 100644 --- a/core/org.eclipse.cdt.core.native/.settings/org.eclipse.jdt.ui.prefs +++ b/core/org.eclipse.cdt.core.native/.settings/org.eclipse.jdt.ui.prefs @@ -1,3 +1,4 @@ +cleanup.add_all=false cleanup.add_default_serial_version_id=true cleanup.add_generated_serial_version_id=false cleanup.add_missing_annotations=true @@ -11,25 +12,72 @@ cleanup.always_use_blocks=true cleanup.always_use_parentheses_in_expressions=false cleanup.always_use_this_for_non_static_field_access=false cleanup.always_use_this_for_non_static_method_access=false +cleanup.array_with_curly=false +cleanup.arrays_fill=false +cleanup.bitwise_conditional_expression=false +cleanup.boolean_literal=false +cleanup.boolean_value_rather_than_comparison=false +cleanup.break_loop=false +cleanup.collection_cloning=false +cleanup.comparing_on_criteria=false +cleanup.comparison_statement=false +cleanup.controlflow_merge=false cleanup.convert_functional_interfaces=false cleanup.convert_to_enhanced_for_loop=false +cleanup.convert_to_enhanced_for_loop_if_loop_var_used=true +cleanup.convert_to_switch_expressions=false cleanup.correct_indentation=false +cleanup.do_while_rather_than_while=true +cleanup.double_negation=false +cleanup.else_if=false +cleanup.embedded_if=false +cleanup.evaluate_nullable=false +cleanup.extract_increment=false cleanup.format_source_code=true cleanup.format_source_code_changes_only=false +cleanup.hash=false +cleanup.if_condition=false cleanup.insert_inferred_type_arguments=false +cleanup.instanceof=false +cleanup.instanceof_keyword=false +cleanup.invert_equals=false +cleanup.join=false +cleanup.lazy_logical_operator=false cleanup.make_local_variable_final=true cleanup.make_parameters_final=false cleanup.make_private_fields_final=true cleanup.make_type_abstract_if_missing_method=false cleanup.make_variable_declarations_final=false +cleanup.map_cloning=false +cleanup.merge_conditional_blocks=false +cleanup.multi_catch=false cleanup.never_use_blocks=false cleanup.never_use_parentheses_in_expressions=true +cleanup.no_string_creation=false +cleanup.no_super=false +cleanup.number_suffix=false +cleanup.objects_equals=false +cleanup.one_if_rather_than_duplicate_blocks_that_fall_through=false +cleanup.operand_factorization=false cleanup.organize_imports=true +cleanup.overridden_assignment=false +cleanup.plain_replacement=false +cleanup.precompile_regex=false +cleanup.primitive_comparison=false +cleanup.primitive_parsing=false +cleanup.primitive_rather_than_wrapper=false +cleanup.primitive_serialization=false +cleanup.pull_out_if_from_if_else=false +cleanup.pull_up_assignment=false +cleanup.push_down_negation=false cleanup.qualify_static_field_accesses_with_declaring_class=false cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true cleanup.qualify_static_member_accesses_with_declaring_class=false cleanup.qualify_static_method_accesses_with_declaring_class=false +cleanup.reduce_indentation=false +cleanup.redundant_comparator=false +cleanup.redundant_falling_through_block_end=false cleanup.remove_private_constructors=true cleanup.remove_redundant_modifiers=false cleanup.remove_redundant_semicolons=true @@ -37,25 +85,57 @@ cleanup.remove_redundant_type_arguments=true cleanup.remove_trailing_whitespaces=true cleanup.remove_trailing_whitespaces_all=true cleanup.remove_trailing_whitespaces_ignore_empty=false +cleanup.remove_unnecessary_array_creation=false cleanup.remove_unnecessary_casts=true cleanup.remove_unnecessary_nls_tags=false cleanup.remove_unused_imports=true cleanup.remove_unused_local_variables=false +cleanup.remove_unused_method_parameters=false cleanup.remove_unused_private_fields=true cleanup.remove_unused_private_members=false cleanup.remove_unused_private_methods=true cleanup.remove_unused_private_types=true +cleanup.return_expression=false +cleanup.simplify_lambda_expression_and_method_ref=false +cleanup.single_used_field=false cleanup.sort_members=false cleanup.sort_members_all=false +cleanup.standard_comparison=false +cleanup.static_inner_class=false +cleanup.strictly_equal_or_different=false +cleanup.stringbuffer_to_stringbuilder=false +cleanup.stringbuilder=false +cleanup.stringbuilder_for_local_vars=true +cleanup.stringconcat_to_textblock=false +cleanup.substring=false +cleanup.switch=false +cleanup.system_property=false +cleanup.system_property_boolean=false +cleanup.system_property_file_encoding=false +cleanup.system_property_file_separator=false +cleanup.system_property_line_separator=false +cleanup.system_property_path_separator=false +cleanup.ternary_operator=false +cleanup.try_with_resource=false +cleanup.unlooped_while=false +cleanup.unreachable_block=false cleanup.use_anonymous_class_creation=false +cleanup.use_autoboxing=false cleanup.use_blocks=false cleanup.use_blocks_only_for_return_and_throw=false +cleanup.use_directly_map_method=false cleanup.use_lambda=true cleanup.use_parentheses_in_expressions=false +cleanup.use_string_is_blank=false cleanup.use_this_for_non_static_field_access=false cleanup.use_this_for_non_static_field_access_only_if_necessary=true cleanup.use_this_for_non_static_method_access=false cleanup.use_this_for_non_static_method_access_only_if_necessary=true +cleanup.use_unboxing=false +cleanup.use_var=false +cleanup.useless_continue=false +cleanup.useless_return=false +cleanup.valueof_rather_than_instantiation=false cleanup_profile=_CDT cleanup_settings_version=2 eclipse.preferences.version=1 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 cc54abd8c9f..db1b4c25598 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.0.0.qualifier +Bundle-Version: 6.2.200.qualifier Bundle-Activator: org.eclipse.cdt.internal.core.natives.CNativePlugin Bundle-Vendor: %providerName Bundle-Localization: plugin @@ -10,7 +10,9 @@ Export-Package: org.eclipse.cdt.core;native=split;mandatory:=native, org.eclipse.cdt.utils;native=split;mandatory:=native, org.eclipse.cdt.utils.pty;version="5.7", org.eclipse.cdt.utils.spawner;version="5.7" -Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.1.0,4.0.0)" +Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.1.0,4.0.0)", + com.sun.jna;bundle-version="[5.6.0,6.0.0)";resolution:=optional, + com.sun.jna.platform;bundle-version="[5.6.0,6.0.0)";resolution:=optional Bundle-ActivationPolicy: lazy -Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Bundle-RequiredExecutionEnvironment: JavaSE-11 Automatic-Module-Name: org.eclipse.cdt.core.native diff --git a/core/org.eclipse.cdt.core.native/about.html b/core/org.eclipse.cdt.core.native/about.html index 164f781a8fd..b3134865230 100644 --- a/core/org.eclipse.cdt.core.native/about.html +++ b/core/org.eclipse.cdt.core.native/about.html @@ -1,10 +1,11 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> + <head> -<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> -<title>About</title> + <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> + <title>About</title> </head> + <body lang="EN-US"> <h2>About This Content</h2> @@ -16,7 +17,7 @@ ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 ("EPL"). A copy of the EPL is - available at <a href="http://www.eclipse.org/legal/epl-2.0">http://www.eclipse.org/legal/epl-2.0</a>. + available at <a href="https://www.eclipse.org/legal/epl-2.0">https://www.eclipse.org/legal/epl-2.0</a>. For purposes of the EPL, "Program" will mean the Content. </p> @@ -29,8 +30,9 @@ license exists, contact the Redistributor. Unless otherwise indicated below, the terms and conditions of the EPL still apply to any source code in the Content and such source code may be obtained at <a - href="http://www.eclipse.org/">http://www.eclipse.org</a>. + href="https://www.eclipse.org/">https://www.eclipse.org</a>. </p> </body> + </html>
\ No newline at end of file diff --git a/core/org.eclipse.cdt.core.native/about.properties b/core/org.eclipse.cdt.core.native/about.properties index f5bd45e9b3d..b911cf839b4 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, 2022 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, 2022 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/build.properties b/core/org.eclipse.cdt.core.native/build.properties index 2e7a449116e..641b4f3e264 100644 --- a/core/org.eclipse.cdt.core.native/build.properties +++ b/core/org.eclipse.cdt.core.native/build.properties @@ -20,9 +20,11 @@ bin.includes = plugin.properties,\ about.mappings,\ cdt_logo_icon32.png,\ about.properties,\ - plugin.xml + plugin.xml,\ + .options src.includes = about.html,\ - schema/ + schema/,\ + native_src/ javadoc.packages = org.eclipse.cdt.utils.*,\ org.eclipse.cdt.utils.pty.*,\ org.eclipse.cdt.utils.spawner.* diff --git a/core/org.eclipse.cdt.core.native/native_src/Makefile b/core/org.eclipse.cdt.core.native/native_src/Makefile new file mode 100644 index 00000000000..e697a513efc --- /dev/null +++ b/core/org.eclipse.cdt.core.native/native_src/Makefile @@ -0,0 +1,197 @@ +#******************************************************************************* +# Copyright (c) 2002, 2015, 2020 QNX Software Systems 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: +# QNX Software Systems - initial API and implementation +# Torbjörn Svensson - Bug 521515 - Adopted jenkins build +#*******************************************************************************/ +SHELL=/bin/bash -o pipefail +ifeq ($(JAVA_HOME),) +$(error JAVA_HOME not set in environment) +endif + +REPRODUCIBLE_BUILD_WRAPPER := $(shell git rev-parse --show-toplevel)/releng/scripts/reproducible_build_wrapper.py + +OS_DIR_WIN32_X86_64 := ../../org.eclipse.cdt.core.win32.x86_64/os/win32/x86_64 +OS_DIR_LINUX_X86_64 := ../../org.eclipse.cdt.core.linux.x86_64/os/linux/x86_64 +OS_DIR_LINUX_AARCH64 := ../../org.eclipse.cdt.core.linux.aarch64/os/linux/aarch64 +OS_DIR_LINUX_PPC64LE := ../../org.eclipse.cdt.core.linux.ppc64le/os/linux/ppc64le +OS_DIR_MACOS_X86_64 := ../../org.eclipse.cdt.core.macosx/os/macosx/x86_64 +OS_DIR_MACOS_AARCH64 := ../../org.eclipse.cdt.core.macosx/os/macosx/aarch64 + +COMMON_CFLAGS := -Wall -pedantic -Werror + +UNAME = $(shell uname) +ifeq ($(UNAME),Linux) +LIBS = \ + $(OS_DIR_WIN32_X86_64)/starter.exe \ + $(OS_DIR_WIN32_X86_64)/spawner.dll \ + $(OS_DIR_WIN32_X86_64)/pty.dll \ + $(OS_DIR_LINUX_X86_64)/libspawner.so \ + $(OS_DIR_LINUX_X86_64)/libpty.so \ + $(OS_DIR_LINUX_AARCH64)/libspawner.so \ + $(OS_DIR_LINUX_AARCH64)/libpty.so \ + $(OS_DIR_LINUX_PPC64LE)/libspawner.so \ + $(OS_DIR_LINUX_PPC64LE)/libpty.so \ + $(OS_DIR_MACOS_X86_64)/libspawner.jnilib \ + $(OS_DIR_MACOS_X86_64)/libpty.jnilib \ + $(OS_DIR_MACOS_AARCH64)/libspawner.jnilib \ + $(OS_DIR_MACOS_AARCH64)/libpty.jnilib +else +ifeq ($(UNAME),Darwin) +LIBS = \ + $(OS_DIR_MACOS_X86_64)/libspawner.jnilib \ + $(OS_DIR_MACOS_X86_64)/libpty.jnilib \ + $(OS_DIR_MACOS_AARCH64)/libspawner.jnilib \ + $(OS_DIR_MACOS_AARCH64)/libpty.jnilib +else +LIBS = \ + $(OS_DIR_WIN32_X86_64)/starter.exe \ + $(OS_DIR_WIN32_X86_64)/spawner.dll \ + $(OS_DIR_WIN32_X86_64)/pty.dll +endif +endif + +all: $(LIBS) + +clean : + $(RM) $(LIBS) + +rebuild: clean all + +MAC_TO_SIGN=$(OS_DIR_MACOS_X86_64)/libspawner.jnilib \ + $(OS_DIR_MACOS_X86_64)/libpty.jnilib \ + $(OS_DIR_MACOS_AARCH64)/libspawner.jnilib \ + $(OS_DIR_MACOS_AARCH64)/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 +### This block of code also exists in native/org.eclipse.cdt.native.serial/native_src/Makefile +TMPDIR := $(shell mktemp -d -t production-XXXXXXXXXX) +.PHONY: production +production: $(MAC_TO_SIGN) $(WIN_TO_SIGN) + set -x ; $(foreach tosign,$(MAC_TO_SIGN),\ + temp=$(TMPDIR)/$(shell basename $(tosign)) && \ + mv $(tosign) $$temp && \ + curl -f --silent --show-error -o $(tosign) -F file=@$$temp https://cbi.eclipse.org/macos/codesign/sign && \ + rm $$temp && \ + ) true + set -x ; $(foreach tosign,$(WIN_TO_SIGN),\ + temp=$(TMPDIR)/$(shell basename $(tosign)) && \ + mv $(tosign) $$temp && \ + curl -f --silent --show-error -o $(tosign) -F file=@$$temp https://cbi.eclipse.org/authenticode/sign && \ + rm $$temp && \ + ) true + rmdir $(TMPDIR) + + +# Windows x86_64 +# Windows DLLs have a build timestamp in them. This makes it impossible to have reproducible builds. +# However, x86_64-w64-mingw32-ld on Debian/Ubuntu has a patch that overrides the current date +# using the SOURCE_DATE_EPOCH environment variable. Call REPRODUCIBLE_BUILD_WRAPPER to make sure the +# same binary is produced for the same source each time. +$(OS_DIR_WIN32_X86_64)/starter.exe: win/starter.c win/util.c + mkdir -p $(dir $@) && \ + $(REPRODUCIBLE_BUILD_WRAPPER) \ + x86_64-w64-mingw32-gcc $(COMMON_CFLAGS) -o $@ -Iinclude -I"$(JAVA_HOME)/include" -I"$(JAVA_HOME)/include/win32" \ + -DUNICODE \ + $^ \ + -lpsapi + +$(OS_DIR_WIN32_X86_64)/spawner.dll: win/iostream.c win/raise.c win/spawner.c win/Win32ProcessEx.c win/util.c + mkdir -p $(dir $@) && \ + $(REPRODUCIBLE_BUILD_WRAPPER) \ + x86_64-w64-mingw32-gcc $(COMMON_CFLAGS) -o $@ -Iinclude -I"$(JAVA_HOME)/include" -I"$(JAVA_HOME)/include/win32" \ + -DUNICODE \ + $^ \ + -Wl,--kill-at --shared + +$(OS_DIR_WIN32_X86_64)/pty.dll: win/pty.cpp win/pty_dllmain.cpp win/util.c + mkdir -p $(dir $@) && \ + $(REPRODUCIBLE_BUILD_WRAPPER) \ + x86_64-w64-mingw32-g++ $(COMMON_CFLAGS) -o $@ -Iinclude -Iwin/include -I"$(JAVA_HOME)/include" -I"$(JAVA_HOME)/include/win32" \ + -DUNICODE \ + $^ \ + -Wl,--kill-at --shared -L$(OS_DIR_WIN32_X86_64) -lwinpty -static-libstdc++ -static-libgcc + +# Linux x86_64 +$(OS_DIR_LINUX_X86_64)/libspawner.so: unix/spawner.c unix/io.c unix/exec_unix.c unix/exec_pty.c unix/openpty.c unix/pfind.c + mkdir -p $(dir $@) && \ + x86_64-linux-gnu-gcc $(COMMON_CFLAGS) -m64 -o $@ -Wl,-soname,$(notdir $@) -Iinclude -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux -fpic \ + -D_REENTRANT -D_GNU_SOURCE \ + $^ \ + -shared -lc + +$(OS_DIR_LINUX_X86_64)/libpty.so: unix/openpty.c unix/pty.c unix/ptyio.c + mkdir -p $(dir $@) && \ + x86_64-linux-gnu-gcc $(COMMON_CFLAGS) -m64 -o $@ -Wl,-soname,$(notdir $@) -Iinclude -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux -fpic \ + -D_REENTRANT -D_GNU_SOURCE \ + $^ \ + -shared -lc + +# Linux aarch64 +$(OS_DIR_LINUX_AARCH64)/libspawner.so: unix/spawner.c unix/io.c unix/exec_unix.c unix/exec_pty.c unix/openpty.c unix/pfind.c + mkdir -p $(dir $@) && \ + aarch64-linux-gnu-gcc $(COMMON_CFLAGS) -o $@ -Wl,-soname,$(notdir $@) -Iinclude -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux -fpic \ + -D_REENTRANT -D_GNU_SOURCE \ + $^ \ + -shared -lc + +$(OS_DIR_LINUX_AARCH64)/libpty.so: unix/openpty.c unix/pty.c unix/ptyio.c + mkdir -p $(dir $@) && \ + aarch64-linux-gnu-gcc $(COMMON_CFLAGS) -o $@ -Wl,-soname,$(notdir $@) -Iinclude -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux -fpic \ + -D_REENTRANT -D_GNU_SOURCE \ + $^ \ + -shared -lc + +# Linux ppc64le +$(OS_DIR_LINUX_PPC64LE)/libspawner.so: unix/spawner.c unix/io.c unix/exec_unix.c unix/exec_pty.c unix/openpty.c unix/pfind.c + mkdir -p $(dir $@) && \ + powerpc64le-linux-gnu-gcc $(COMMON_CFLAGS) -m64 -o $@ -Wl,-soname,$(notdir $@) -Iinclude -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux -fpic \ + -D_REENTRANT -D_GNU_SOURCE \ + $^ \ + -shared -lc + +$(OS_DIR_LINUX_PPC64LE)/libpty.so: unix/openpty.c unix/pty.c unix/ptyio.c + mkdir -p $(dir $@) && \ + powerpc64le-linux-gnu-gcc -m64 -o $@ -Wl,-soname,$(notdir $@) -Iinclude -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux -fpic \ + -D_REENTRANT -D_GNU_SOURCE \ + $^ \ + -shared -lc + +# macos x86_64 +$(OS_DIR_MACOS_X86_64)/libspawner.jnilib: unix/spawner.c unix/io.c unix/exec_unix.c unix/exec_pty.c unix/openpty.c unix/pfind.c + mkdir -p $(dir $@) && \ + x86_64-apple-darwin21.1-clang $(COMMON_CFLAGS) -o $@ -arch x86_64 -Iinclude -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/darwin -fPIC \ + -D_REENTRANT \ + $^ \ + -dynamiclib -lc + +$(OS_DIR_MACOS_X86_64)/libpty.jnilib: unix/openpty.c unix/pty.c unix/ptyio.c + mkdir -p $(dir $@) && \ + x86_64-apple-darwin21.1-clang $(COMMON_CFLAGS) -o $@ -arch x86_64 -Iinclude -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/darwin -fPIC \ + -D_REENTRANT \ + $^ \ + -dynamiclib -lc + +# macos aarch64 +$(OS_DIR_MACOS_AARCH64)/libspawner.jnilib: unix/spawner.c unix/io.c unix/exec_unix.c unix/exec_pty.c unix/openpty.c unix/pfind.c + mkdir -p $(dir $@) && \ + arm64-apple-darwin21.1-clang $(COMMON_CFLAGS) -o $@ -arch arm64 -Iinclude -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/darwin -fPIC \ + -D_REENTRANT \ + $^ \ + -dynamiclib -lc + +$(OS_DIR_MACOS_AARCH64)/libpty.jnilib: unix/openpty.c unix/pty.c unix/ptyio.c + mkdir -p $(dir $@) && \ + arm64-apple-darwin21.1-clang $(COMMON_CFLAGS) -o $@ -arch arm64 -Iinclude -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/darwin -fPIC \ + -D_REENTRANT \ + $^ \ + -dynamiclib -lc diff --git a/core/org.eclipse.cdt.core.win32/library/pty/jni/include/PTY.h b/core/org.eclipse.cdt.core.native/native_src/include/org_eclipse_cdt_utils_pty_PTY.h index d73d5c00e16..cdeb5ad662b 100644 --- a/core/org.eclipse.cdt.core.win32/library/pty/jni/include/PTY.h +++ b/core/org.eclipse.cdt.core.native/native_src/include/org_eclipse_cdt_utils_pty_PTY.h @@ -12,32 +12,30 @@ extern "C" { * Method: openMaster * Signature: (Z)Ljava/lang/String; */ -JNIEXPORT jstring JNICALL Java_org_eclipse_cdt_utils_pty_PTY_openMaster - (JNIEnv *, jobject, jboolean); +JNIEXPORT jstring JNICALL Java_org_eclipse_cdt_utils_pty_PTY_openMaster(JNIEnv *, jobject, jboolean); /* * Class: org_eclipse_cdt_utils_pty_PTY * Method: change_window_size * Signature: (III)I */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTY_change_1window_1size - (JNIEnv *, jobject, jint, jint, jint); +JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTY_change_1window_1size(JNIEnv *, jobject, jint, jint, jint); /* * Class: org_eclipse_cdt_utils_pty_PTY * Method: exec2 - * Signature: ([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[ILjava/lang/String;IZ)I + * Signature: + * ([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[Lorg/eclipse/cdt/utils/spawner/Spawner/IChannel;Ljava/lang/String;IZ)I */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTY_exec2 - (JNIEnv *, jobject, jobjectArray, jobjectArray, jstring, jintArray, jstring, jint, jboolean); +JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTY_exec2(JNIEnv *, jobject, jobjectArray, jobjectArray, jstring, + jobjectArray, jstring, jint, jboolean); /* * Class: org_eclipse_cdt_utils_pty_PTY * Method: waitFor * Signature: (II)I */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTY_waitFor - (JNIEnv *, jobject, jint, jint); +JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTY_waitFor(JNIEnv *, jobject, jint, jint); #ifdef __cplusplus } diff --git a/core/org.eclipse.cdt.core.win32/library/pty/jni/include/PTYInputStream.h b/core/org.eclipse.cdt.core.native/native_src/include/org_eclipse_cdt_utils_pty_PTYInputStream.h index 7767be6bd8c..29fae6fd63e 100644 --- a/core/org.eclipse.cdt.core.win32/library/pty/jni/include/PTYInputStream.h +++ b/core/org.eclipse.cdt.core.native/native_src/include/org_eclipse_cdt_utils_pty_PTYInputStream.h @@ -9,21 +9,23 @@ extern "C" { #endif #undef org_eclipse_cdt_utils_pty_PTYInputStream_MAX_SKIP_BUFFER_SIZE #define org_eclipse_cdt_utils_pty_PTYInputStream_MAX_SKIP_BUFFER_SIZE 2048L +#undef org_eclipse_cdt_utils_pty_PTYInputStream_DEFAULT_BUFFER_SIZE +#define org_eclipse_cdt_utils_pty_PTYInputStream_DEFAULT_BUFFER_SIZE 8192L +#undef org_eclipse_cdt_utils_pty_PTYInputStream_MAX_BUFFER_SIZE +#define org_eclipse_cdt_utils_pty_PTYInputStream_MAX_BUFFER_SIZE 2147483639L /* * Class: org_eclipse_cdt_utils_pty_PTYInputStream * Method: read0 * Signature: (I[BI)I */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTYInputStream_read0 - (JNIEnv *, jobject, jint, jbyteArray, jint); +JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTYInputStream_read0(JNIEnv *, jobject, jint, jbyteArray, jint); /* * Class: org_eclipse_cdt_utils_pty_PTYInputStream * Method: close0 * Signature: (I)I */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTYInputStream_close0 - (JNIEnv *, jobject, jint); +JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTYInputStream_close0(JNIEnv *, jobject, jint); #ifdef __cplusplus } diff --git a/core/org.eclipse.cdt.core.macosx/library/PTYOutputStream.h b/core/org.eclipse.cdt.core.native/native_src/include/org_eclipse_cdt_utils_pty_PTYOutputStream.h index fb28491060e..2473324b419 100644 --- a/core/org.eclipse.cdt.core.macosx/library/PTYOutputStream.h +++ b/core/org.eclipse.cdt.core.native/native_src/include/org_eclipse_cdt_utils_pty_PTYOutputStream.h @@ -7,21 +7,21 @@ #ifdef __cplusplus extern "C" { #endif +#undef org_eclipse_cdt_utils_pty_PTYOutputStream_EOT +#define org_eclipse_cdt_utils_pty_PTYOutputStream_EOT 4L /* * Class: org_eclipse_cdt_utils_pty_PTYOutputStream * Method: write0 * Signature: (I[BI)I */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTYOutputStream_write0 - (JNIEnv *, jobject, jint, jbyteArray, jint); +JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTYOutputStream_write0(JNIEnv *, jobject, jint, jbyteArray, jint); /* * Class: org_eclipse_cdt_utils_pty_PTYOutputStream * Method: close0 * Signature: (I)I */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTYOutputStream_close0 - (JNIEnv *, jobject, jint); +JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTYOutputStream_close0(JNIEnv *, jobject, jint); #ifdef __cplusplus } diff --git a/core/org.eclipse.cdt.core.native/native_src/include/org_eclipse_cdt_utils_spawner_Spawner.h b/core/org.eclipse.cdt.core.native/native_src/include/org_eclipse_cdt_utils_spawner_Spawner.h new file mode 100644 index 00000000000..d487596c364 --- /dev/null +++ b/core/org.eclipse.cdt.core.native/native_src/include/org_eclipse_cdt_utils_spawner_Spawner.h @@ -0,0 +1,73 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include <jni.h> +/* Header for class org_eclipse_cdt_utils_spawner_Spawner */ + +#ifndef _Included_org_eclipse_cdt_utils_spawner_Spawner +#define _Included_org_eclipse_cdt_utils_spawner_Spawner +#ifdef __cplusplus +extern "C" { +#endif +#undef org_eclipse_cdt_utils_spawner_Spawner_SIG_NOOP +#define org_eclipse_cdt_utils_spawner_Spawner_SIG_NOOP 0L +#undef org_eclipse_cdt_utils_spawner_Spawner_SIG_HUP +#define org_eclipse_cdt_utils_spawner_Spawner_SIG_HUP 1L +#undef org_eclipse_cdt_utils_spawner_Spawner_SIG_KILL +#define org_eclipse_cdt_utils_spawner_Spawner_SIG_KILL 9L +#undef org_eclipse_cdt_utils_spawner_Spawner_SIG_TERM +#define org_eclipse_cdt_utils_spawner_Spawner_SIG_TERM 15L +#undef org_eclipse_cdt_utils_spawner_Spawner_SIG_INT +#define org_eclipse_cdt_utils_spawner_Spawner_SIG_INT 2L +#undef org_eclipse_cdt_utils_spawner_Spawner_SIG_CTRLC +#define org_eclipse_cdt_utils_spawner_Spawner_SIG_CTRLC 1000L +/* + * Class: org_eclipse_cdt_utils_spawner_Spawner + * Method: exec0 + * Signature: + * ([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[Lorg/eclipse/cdt/utils/spawner/Spawner/IChannel;)I + */ +JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec0(JNIEnv *, jobject, jobjectArray, jobjectArray, + jstring, jobjectArray); + +/* + * Class: org_eclipse_cdt_utils_spawner_Spawner + * Method: exec1 + * Signature: ([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)I + */ +JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec1(JNIEnv *, jobject, jobjectArray, jobjectArray, + jstring); + +/* + * Class: org_eclipse_cdt_utils_spawner_Spawner + * Method: exec2 + * Signature: + * ([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[Lorg/eclipse/cdt/utils/spawner/Spawner/IChannel;Ljava/lang/String;IZ)I + */ +JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec2(JNIEnv *, jobject, jobjectArray, jobjectArray, + jstring, jobjectArray, jstring, jint, jboolean); + +/* + * Class: org_eclipse_cdt_utils_spawner_Spawner + * Method: raise + * Signature: (II)I + */ +JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_raise(JNIEnv *, jobject, jint, jint); + +/* + * Class: org_eclipse_cdt_utils_spawner_Spawner + * Method: waitFor + * Signature: (I)I + */ +JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_waitFor(JNIEnv *, jobject, jint); + +/* + * Class: org_eclipse_cdt_utils_spawner_Spawner + * Method: configureNativeTrace + * Signature: (ZZZZ)V + */ +JNIEXPORT void JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_configureNativeTrace(JNIEnv *, jclass, jboolean, + jboolean, jboolean, jboolean); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/core/org.eclipse.cdt.core.native/native_src/include/org_eclipse_cdt_utils_spawner_SpawnerInputStream.h b/core/org.eclipse.cdt.core.native/native_src/include/org_eclipse_cdt_utils_spawner_SpawnerInputStream.h new file mode 100644 index 00000000000..76662bb4d63 --- /dev/null +++ b/core/org.eclipse.cdt.core.native/native_src/include/org_eclipse_cdt_utils_spawner_SpawnerInputStream.h @@ -0,0 +1,41 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include <jni.h> +/* Header for class org_eclipse_cdt_utils_spawner_SpawnerInputStream */ + +#ifndef _Included_org_eclipse_cdt_utils_spawner_SpawnerInputStream +#define _Included_org_eclipse_cdt_utils_spawner_SpawnerInputStream +#ifdef __cplusplus +extern "C" { +#endif +#undef org_eclipse_cdt_utils_spawner_SpawnerInputStream_MAX_SKIP_BUFFER_SIZE +#define org_eclipse_cdt_utils_spawner_SpawnerInputStream_MAX_SKIP_BUFFER_SIZE 2048L +#undef org_eclipse_cdt_utils_spawner_SpawnerInputStream_DEFAULT_BUFFER_SIZE +#define org_eclipse_cdt_utils_spawner_SpawnerInputStream_DEFAULT_BUFFER_SIZE 8192L +#undef org_eclipse_cdt_utils_spawner_SpawnerInputStream_MAX_BUFFER_SIZE +#define org_eclipse_cdt_utils_spawner_SpawnerInputStream_MAX_BUFFER_SIZE 2147483639L +/* + * Class: org_eclipse_cdt_utils_spawner_SpawnerInputStream + * Method: read0 + * Signature: (Lorg/eclipse/cdt/utils/spawner/Spawner/IChannel;[BI)I + */ +JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_read0(JNIEnv *, jobject, jobject, + jbyteArray, jint); + +/* + * Class: org_eclipse_cdt_utils_spawner_SpawnerInputStream + * Method: close0 + * Signature: (Lorg/eclipse/cdt/utils/spawner/Spawner/IChannel;)I + */ +JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_close0(JNIEnv *, jobject, jobject); + +/* + * Class: org_eclipse_cdt_utils_spawner_SpawnerInputStream + * Method: available0 + * Signature: (Lorg/eclipse/cdt/utils/spawner/Spawner/IChannel;)I + */ +JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_available0(JNIEnv *, jobject, jobject); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/core/org.eclipse.cdt.core.native/native_src/include/org_eclipse_cdt_utils_spawner_SpawnerOutputStream.h b/core/org.eclipse.cdt.core.native/native_src/include/org_eclipse_cdt_utils_spawner_SpawnerOutputStream.h new file mode 100644 index 00000000000..bb94be6c533 --- /dev/null +++ b/core/org.eclipse.cdt.core.native/native_src/include/org_eclipse_cdt_utils_spawner_SpawnerOutputStream.h @@ -0,0 +1,28 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include <jni.h> +/* Header for class org_eclipse_cdt_utils_spawner_SpawnerOutputStream */ + +#ifndef _Included_org_eclipse_cdt_utils_spawner_SpawnerOutputStream +#define _Included_org_eclipse_cdt_utils_spawner_SpawnerOutputStream +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: org_eclipse_cdt_utils_spawner_SpawnerOutputStream + * Method: write0 + * Signature: (Lorg/eclipse/cdt/utils/spawner/Spawner/IChannel;[BI)I + */ +JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerOutputStream_write0(JNIEnv *, jobject, jobject, + jbyteArray, jint); + +/* + * Class: org_eclipse_cdt_utils_spawner_SpawnerOutputStream + * Method: close0 + * Signature: (Lorg/eclipse/cdt/utils/spawner/Spawner/IChannel;)I + */ +JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerOutputStream_close0(JNIEnv *, jobject, jobject); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/core/org.eclipse.cdt.core.linux/library/exec0.h b/core/org.eclipse.cdt.core.native/native_src/unix/exec0.h index 04f363d5e53..fb272ea9101 100644 --- a/core/org.eclipse.cdt.core.linux/library/exec0.h +++ b/core/org.eclipse.cdt.core.native/native_src/unix/exec0.h @@ -19,14 +19,9 @@ #include <signal.h> #include <errno.h> -extern pid_t exec0(const char *path, char *const argv[], - char *const envp[], const char *dirpath, - int channels[3]); +extern pid_t exec0(const char *path, char *const argv[], char *const envp[], const char *dirpath, int channels[3]); - -extern pid_t exec_pty(const char *path, char *const argv[], - char *const envp[], const char *dirpath, - int channels[3], const char *pts_name, int fdm, - int console); +extern pid_t exec_pty(const char *path, char *const argv[], char *const envp[], const char *dirpath, int channels[3], + const char *pts_name, int fdm, int console); extern int wait0(pid_t pid); diff --git a/core/org.eclipse.cdt.core.native/native_src/unix/exec_pty.c b/core/org.eclipse.cdt.core.native/native_src/unix/exec_pty.c new file mode 100644 index 00000000000..fb669736037 --- /dev/null +++ b/core/org.eclipse.cdt.core.native/native_src/unix/exec_pty.c @@ -0,0 +1,190 @@ +/******************************************************************************* + * Copyright (c) 2004, 2010 QNX Software Systems 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: + * QNX Software Systems - initial API and implementation + * Wind River Systems, Inc. + * Mikhail Zabaluev (Nokia) - bug 82744 + * Mikhail Sennikovsky - bug 145737 + *******************************************************************************/ +#include "exec0.h" +#include "openpty.h" +#include <unistd.h> +#include <stdlib.h> +#include <stdio.h> +#include <errno.h> +#include <string.h> +#include <libgen.h> +#include <stdlib.h> +#include <termios.h> + +/* from pfind.c */ +extern char *pfind(const char *name, char *const envp[]); + +pid_t exec_pty(const char *path, char *const argv[], char *const envp[], const char *dirpath, int channels[3], + const char *pts_name, int fdm, int console) { + int pipe2[2]; + pid_t childpid; + char *full_path; + + /* + * We use pfind() to check that the program exists and is an executable. + * If not pass the error up. Also execve() wants a full path. + */ + full_path = pfind(path, envp); + if (full_path == NULL) { + fprintf(stderr, "Unable to find full path for \"%s\"\n", (path) ? path : ""); + return -1; + } + + /* + * Make sure we can create our pipes before forking. + */ + if (channels != NULL && console) { + if (pipe(pipe2) < 0) { + fprintf(stderr, "%s(%d): returning due to error: %s\n", __func__, __LINE__, strerror(errno)); + free(full_path); + return -1; + } + } + + childpid = fork(); + + if (childpid < 0) { + fprintf(stderr, "%s(%d): returning due to error: %s\n", __func__, __LINE__, strerror(errno)); + free(full_path); + return -1; + } else if (childpid == 0) { /* child */ + + chdir(dirpath); + + if (channels) { + int fds; + + if (!console && setsid() < 0) { + perror("setsid()"); + return -1; + } + + fds = ptys_open(fdm, pts_name); + if (fds < 0) { + fprintf(stderr, "%s(%d): returning due to error: %s\n", __func__, __LINE__, strerror(errno)); + return -1; + } + + /* Close the read end of pipe2 */ + if (console && close(pipe2[0]) == -1) { + perror("close(pipe2[0]))"); + } + + /* close the master, no need in the child */ + close(fdm); + + if (console) { + set_noecho(fds); + if (setpgid(getpid(), getpid()) < 0) { + perror("setpgid()"); + return -1; + } + } + + /* redirections */ + dup2(fds, STDIN_FILENO); /* dup stdin */ + dup2(fds, STDOUT_FILENO); /* dup stdout */ + if (console) { + dup2(pipe2[1], STDERR_FILENO); /* dup stderr */ + } else { + dup2(fds, STDERR_FILENO); /* dup stderr */ + } + close(fds); /* done with fds. */ + } + + /* Close all the fd's in the child */ + { + int fdlimit = sysconf(_SC_OPEN_MAX); + int fd = 3; + + while (fd < fdlimit) { + close(fd++); + } + } + + if (envp && envp[0]) { + execve(full_path, argv, envp); + } else { + execv(full_path, argv); + } + + _exit(127); + + } else if (childpid != 0) { /* parent */ + if (console) { + set_noecho(fdm); + } + if (channels) { + channels[0] = fdm; /* Input Stream. */ + channels[1] = fdm; /* Output Stream. */ + if (console) { + /* close the write end of pipe1 */ + if (close(pipe2[1]) == -1) { + perror("close(pipe2[1])"); + } + channels[2] = pipe2[0]; /* stderr Stream. */ + } else { + channels[2] = fdm; /* Error Stream. */ + } + } + + free(full_path); + return childpid; + } + + free(full_path); + return -1; /*NOT REACHED */ +} + +#ifdef __STAND_ALONE__ +int main(int argc, char **argv, char **envp) { + const char *path = "./bufferring_test"; + int channels[3] = {-1, -1, -1}; + int status; + FILE *app_stdin; + FILE *app_stdout; + FILE *app_stderr; + char pts_name[32]; + int fdm; + char buffer[32]; + + fdm = ptym_open(pts_name); + status = exec_pty(path, argv, envp, ".", channels, pts_name, fdm); + if (status >= 0) { + app_stdin = fdopen(channels[0], "w"); + app_stdout = fdopen(channels[1], "r"); + app_stderr = fdopen(channels[2], "r"); + if (app_stdout == NULL || app_stderr == NULL || app_stdin == NULL) { + fprintf(stderr, "PROBLEMS\n"); + } else { + fputs("foo\n", app_stdin); + fputs("bar\n", app_stdin); + while (fgets(buffer, sizeof buffer, app_stdout)) { + fprintf(stdout, "STDOUT: %s\n", buffer); + } + while (fgets(buffer, sizeof buffer, app_stderr)) { + fprintf(stdout, "STDERR: %s\n", buffer); + } + } + } + fputs("bye\n", stdout); + close(channels[0]); + close(channels[1]); + close(channels[2]); + return 0; +} +#endif diff --git a/core/org.eclipse.cdt.core.native/native_src/unix/exec_unix.c b/core/org.eclipse.cdt.core.native/native_src/unix/exec_unix.c new file mode 100644 index 00000000000..e393cfff6a0 --- /dev/null +++ b/core/org.eclipse.cdt.core.native/native_src/unix/exec_unix.c @@ -0,0 +1,157 @@ +/******************************************************************************* + * Copyright (c) 2002, 2010 QNX Software Systems 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: + * QNX Software Systems - initial API and implementation + * Wind River Systems, Inc. + * Mikhail Sennikovsky - bug 145737 + *******************************************************************************/ +#include "exec0.h" +#include <unistd.h> +#include <stdlib.h> +#include <stdio.h> +#include <errno.h> +#include <string.h> +#include <libgen.h> +#include <stdlib.h> + +/* from pfind.c */ +extern char *pfind(const char *name, char *const envp[]); + +pid_t exec0(const char *path, char *const argv[], char *const envp[], const char *dirpath, int channels[3]) { + int pipe0[2], pipe1[2], pipe2[2]; + pid_t childpid; + char *full_path; + + /* + * We use pfind() to check that the program exists and is an executable. + * If not pass the error up. Also execve() wants a full path. + */ + full_path = pfind(path, envp); + if (full_path == NULL) { + fprintf(stderr, "Unable to find full path for \"%s\"\n", (path) ? path : ""); + return -1; + } + + /* + * Make sure we can create our pipes before forking. + */ + if (channels) { + if (pipe(pipe0) < 0 || pipe(pipe1) < 0 || pipe(pipe2) < 0) { + fprintf(stderr, "%s(%d): returning due to error.\n", __func__, __LINE__); + free(full_path); + return -1; + } + } + + childpid = fork(); + + if (childpid < 0) { + fprintf(stderr, "%s(%d): returning due to error: %s\n", __func__, __LINE__, strerror(errno)); + free(full_path); + return -1; + } else if (childpid == 0) { /* child */ + chdir(dirpath); + + if (channels) { + /* Close the write end of pipe0 */ + if (close(pipe0[1]) == -1) { + perror("close(pipe0[1])"); + } + + /* Close the read end of pipe1 */ + if (close(pipe1[0]) == -1) { + perror("close(pipe1[0])"); + } + + /* Close the read end of pipe2 */ + if (close(pipe2[0]) == -1) { + perror("close(pipe2[0]))"); + } + + /* redirections */ + dup2(pipe0[0], STDIN_FILENO); /* dup stdin */ + dup2(pipe1[1], STDOUT_FILENO); /* dup stdout */ + dup2(pipe2[1], STDERR_FILENO); /* dup stderr */ + } + + /* Close all the fd's in the child */ + { + int fdlimit = sysconf(_SC_OPEN_MAX); + int fd = 3; + + while (fd < fdlimit) { + close(fd++); + } + } + + setpgid(getpid(), getpid()); + + if (envp && envp[0]) { + execve(full_path, argv, envp); + } else { + execv(full_path, argv); + } + + _exit(127); + + } else if (childpid != 0) { /* parent */ + if (channels) { + /* close the read end of pipe1 */ + if (close(pipe0[0]) == -1) { + perror("close(pipe0[0])"); + } + + /* close the write end of pipe2 */ + if (close(pipe1[1]) == -1) { + perror("close(pipe1[1])"); + } + + /* close the write end of pipe2 */ + if (close(pipe2[1]) == -1) { + perror("close(pipe2[1])"); + } + + channels[0] = pipe0[1]; /* Output Stream. */ + channels[1] = pipe1[0]; /* Input Stream. */ + channels[2] = pipe2[0]; /* Input Stream. */ + } + + free(full_path); + return childpid; + } + + free(full_path); + return -1; /*NOT REACHED */ +} + +int wait0(pid_t pid) { + int status; + int val = -1; + + if (pid < 0) { + return -1; + } + + for (;;) { + if (waitpid(pid, &status, 0) < 0) { + if (errno == EINTR) { + // interrupted system call - retry + continue; + } + } + break; + } + if (WIFEXITED(status)) { + val = WEXITSTATUS(status); + } + + return val; +} diff --git a/core/org.eclipse.cdt.core.native/native_src/unix/io.c b/core/org.eclipse.cdt.core.native/native_src/unix/io.c new file mode 100644 index 00000000000..b29c4357b5a --- /dev/null +++ b/core/org.eclipse.cdt.core.native/native_src/unix/io.c @@ -0,0 +1,116 @@ +/******************************************************************************* + * Copyright (c) 2002, 2006 QNX Software Systems 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: + * QNX Software Systems - initial API and implementation + * Wind River Systems, Inc. + *******************************************************************************/ +#include <jni.h> +#include <stdio.h> +#include <org_eclipse_cdt_utils_spawner_SpawnerInputStream.h> +#include <org_eclipse_cdt_utils_spawner_SpawnerOutputStream.h> +#include <unistd.h> + +/* Header for class _org_eclipse_cdt_utils_spawner_SpawnerInputStream */ +/* Header for class _org_eclipse_cdt_utils_spawner_SpawnerOutputStream */ + +static void ThrowByName(JNIEnv *env, const char *name, const char *msg) { + jclass cls = (*env)->FindClass(env, name); + + if (cls) { /* Otherwise an exception has already been thrown */ + (*env)->ThrowNew(env, cls, msg); + } + + /* It's a good practice to clean up the local references. */ + (*env)->DeleteLocalRef(env, cls); +} + +static int channelToFileDesc(JNIEnv *env, jobject channel) { + if (channel == 0) { + ThrowByName(env, "java/io/IOException", "Invalid channel object"); + return -1; + } + + jclass cls = (*env)->GetObjectClass(env, channel); + if (cls == 0) { + ThrowByName(env, "java/io/IOException", "Unable to get channel class"); + return -1; + } + + jfieldID fid = (*env)->GetFieldID(env, cls, "fd", "I"); + if (fid == 0) { + ThrowByName(env, "java/io/IOException", "Unable to find fd"); + return -1; + } + + jint fd = (*env)->GetIntField(env, channel, fid); + return fd; +} + +JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_read0(JNIEnv *env, jobject jobj, + jobject channel, jbyteArray buf, + jint buf_len) { + int fd; + int status; + jbyte *data; + int data_len; + + data = (*env)->GetByteArrayElements(env, buf, 0); + data_len = buf_len; + fd = channelToFileDesc(env, channel); + + status = read(fd, data, data_len); + (*env)->ReleaseByteArrayElements(env, buf, data, 0); + + if (status == 0) { + /* EOF. */ + status = -1; + } else if (status == -1) { + /* Error, toss an exception */ + jclass exception = (*env)->FindClass(env, "java/io/IOException"); + if (exception == NULL) { + /* Give up. */ + return -1; + } + (*env)->ThrowNew(env, exception, "read error"); + } + + return status; +} + +JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_close0(JNIEnv *env, jobject jobj, + jobject channel) { + int fd = channelToFileDesc(env, channel); + return close(fd); +} + +JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerOutputStream_write0(JNIEnv *env, jobject jobj, + jobject channel, jbyteArray buf, + jint buf_len) { + int status; + int fd; + jbyte *data; + int data_len; + + data = (*env)->GetByteArrayElements(env, buf, 0); + data_len = buf_len; + fd = channelToFileDesc(env, channel); + + status = write(fd, data, data_len); + (*env)->ReleaseByteArrayElements(env, buf, data, 0); + + return status; +} + +JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerOutputStream_close0(JNIEnv *env, jobject jobj, + jobject channel) { + int fd = channelToFileDesc(env, channel); + return close(fd); +} diff --git a/core/org.eclipse.cdt.core.native/native_src/unix/openpty.c b/core/org.eclipse.cdt.core.native/native_src/unix/openpty.c new file mode 100644 index 00000000000..f5f763112ee --- /dev/null +++ b/core/org.eclipse.cdt.core.native/native_src/unix/openpty.c @@ -0,0 +1,134 @@ +/******************************************************************************* + * Copyright (c) 2002, 2010 QNX Software Systems 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: + * QNX Software Systems - initial API and implementation + * Wind River Systems, Inc. + * Mikhail Zabaluev (Nokia) - bug 82744 + * Corey Ashford (IBM) - bug 272370, bug 272372 + *******************************************************************************/ + +/* _XOPEN_SOURCE is needed to bring in the header for ptsname */ +#define _XOPEN_SOURCE +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/ioctl.h> +#include <fcntl.h> +#include <termios.h> +#include <errno.h> +#include <unistd.h> +#include <stdio.h> +#include <string.h> +#include <grp.h> + +#include <stdlib.h> + +/** + * This is taken from R. W. Stevens book. + * Alain Magloire. + */ + +int ptym_open(char *pts_name); +int ptys_open(int fdm, const char *pts_name); +void set_noecho(int fd); + +int openpty(int *amaster, int *aslave, char *name, struct termios *termp, struct winsize *winp) { + char line[20]; + line[0] = 0; + *amaster = ptym_open(line); + if (*amaster < 0) { + return -1; + } + *aslave = ptys_open(*amaster, line); + if (*aslave < 0) { + close(*amaster); + return -1; + } + + if (name) { + strcpy(name, line); + } +#ifndef TCSAFLUSH +#define TCSAFLUSH TCSETAF +#endif + if (termp) { + (void)tcsetattr(*aslave, TCSAFLUSH, termp); + } +#ifdef TIOCSWINSZ + if (winp) { + (void)ioctl(*aslave, TIOCSWINSZ, (char *)winp); + } +#endif + return 0; +} + +void set_noecho(int fd) { + struct termios stermios; + if (tcgetattr(fd, &stermios) < 0) { + return; + } + + /* turn off echo */ + stermios.c_lflag &= ~(ECHO | ECHOE | ECHOK | ECHONL); + /* Turn off the NL to CR/NL mapping ou output. */ + /*stermios.c_oflag &= ~(ONLCR);*/ + + stermios.c_iflag |= (IGNCR); + + tcsetattr(fd, TCSANOW, &stermios); +} + +int ptym_open(char *pts_name) { + int fdm; + char *ptr; + + strcpy(pts_name, "/dev/ptmx"); +#ifdef __APPLE__ + fdm = posix_openpt(O_RDWR | O_NOCTTY); +#else + fdm = getpt(); +#endif + if (fdm < 0) { + return -1; + } + if (grantpt(fdm) < 0) { /* grant access to slave */ + close(fdm); + return -2; + } + if (unlockpt(fdm) < 0) { /* clear slave's lock flag */ + close(fdm); + return -3; + } + ptr = ptsname(fdm); + if (ptr == NULL) { /* get slave's name */ + close(fdm); + return -4; + } + strcpy(pts_name, ptr); /* return name of slave */ + return fdm; /* return fd of master */ +} + +int ptys_open(int fdm, const char *pts_name) { + int fds; + /* following should allocate controlling terminal */ + fds = open(pts_name, O_RDWR); + if (fds < 0) { + close(fdm); + return -5; + } + +#if defined(TIOCSCTTY) + /* TIOCSCTTY is the BSD way to acquire a controlling terminal. */ + if (ioctl(fds, TIOCSCTTY, (char *)0) < 0) { + // ignore error: this is expected in console-mode + } +#endif + return fds; +} diff --git a/core/org.eclipse.cdt.core.linux/library/openpty.h b/core/org.eclipse.cdt.core.native/native_src/unix/openpty.h index 234a306415d..036233db08e 100644 --- a/core/org.eclipse.cdt.core.linux/library/openpty.h +++ b/core/org.eclipse.cdt.core.native/native_src/unix/openpty.h @@ -15,7 +15,7 @@ *******************************************************************************/ #ifndef _OPENPTY_H #define _OPENPTY_H -int ptym_open (char *pts_name); -int ptys_open (int fdm, const char * pts_name); +int ptym_open(char *pts_name); +int ptys_open(int fdm, const char *pts_name); void set_noecho(int fd); #endif diff --git a/core/org.eclipse.cdt.core.native/native_src/unix/pfind.c b/core/org.eclipse.cdt.core.native/native_src/unix/pfind.c new file mode 100644 index 00000000000..bf96c882895 --- /dev/null +++ b/core/org.eclipse.cdt.core.native/native_src/unix/pfind.c @@ -0,0 +1,111 @@ +/******************************************************************************* + * Copyright (c) 2002, 2010 QNX Software Systems 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: + * QNX Software Systems - initial API and implementation + * Wind River Systems, Inc. + * Mikhail Sennikovsky - bug 145737 + * Everton Rufino Constantino (IBM) - bug 237611 + *******************************************************************************/ +/* + * pfind.c - Search for a binary in $PATH. + */ + +#include <stdio.h> +#include <unistd.h> +#include <stdlib.h> +#include <string.h> +#include <limits.h> +#include <sys/stat.h> + +#ifndef PATH_MAX +#define PATH_MAX 1024 +#endif + +#define PATH_DEF "PATH=" +const int path_def_len = 5; /* strlen(PATH_DEF); */ + +char *path_val(char *const envp[]) { + if (!envp || !envp[0]) { + return getenv("PATH"); + } + + for (int i = 0; envp[i]; i++) { + char *p = envp[i]; + if (!strncmp(PATH_DEF, p, path_def_len)) { + return p + path_def_len; + } + } + + return NULL; +} + +char *pfind(const char *name, char *const envp[]) { + char *tok; + char *sp; + char *path; + char fullpath[PATH_MAX + 1]; + struct stat sb; + + /* Sanity check. */ + if (!name) { + fprintf(stderr, "pfind(): Null argument.\n"); + return NULL; + } + + /* For absolute name or name with a path, check if it is an executable. */ + if (name[0] == '/' || name[0] == '.') { + if (access(name, X_OK) == 0) { + return strdup(name); + } + return NULL; + } + + /* Search in the PATH environment. */ + path = path_val(envp); + + if (!path || strlen(path) <= 0) { + fprintf(stderr, "Unable to get $PATH.\n"); + return NULL; + } + + /* The value return by getenv() is read-only */ + path = strdup(path); + + tok = strtok_r(path, ":", &sp); + while (tok) { + snprintf(fullpath, sizeof(fullpath) - 1, "%s/%s", tok, name); + + if (stat(fullpath, &sb) == 0 && S_ISREG(sb.st_mode)) { /* fullpath is a file */ + if (access(fullpath, X_OK) == 0) { /* fullpath is executable */ + free(path); + return strdup(fullpath); + } + } + + tok = strtok_r(NULL, ":", &sp); + } + + free(path); + return NULL; +} + +#ifdef BUILD_WITH_MAIN +int main(int argc, char **argv) { + for (int i = 1; i < argc; i++) { + char *fullpath = pfind(argv[i], NULL); + if (fullpath) { + printf("Found %s @ %s.\n", argv[i], fullpath); + } else { + printf("Unable to find %s in $PATH.\n", argv[i]); + } + } +} +#endif diff --git a/core/org.eclipse.cdt.core.native/native_src/unix/pty.c b/core/org.eclipse.cdt.core.native/native_src/unix/pty.c new file mode 100644 index 00000000000..a0800620ef8 --- /dev/null +++ b/core/org.eclipse.cdt.core.native/native_src/unix/pty.c @@ -0,0 +1,71 @@ +/******************************************************************************* + * Copyright (c) 2002, 2010 QNX Software Systems 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: + * QNX Software Systems - initial API and implementation + * Wind River Systems, Inc. + *******************************************************************************/ +#include <sys/ioctl.h> +#include "org_eclipse_cdt_utils_pty_PTY.h" +#include "openpty.h" + +/* + * Class: org_eclipse_cdt_utils_pty_PTY + * Method: forkpty + * Signature: ()I + */ +JNIEXPORT jstring JNICALL Java_org_eclipse_cdt_utils_pty_PTY_openMaster(JNIEnv *env, jobject jobj, jboolean console) { + jfieldID fid; /* Store the field ID */ + jstring jstr = NULL; + int master = -1; + char line[1024]; /* FIXME: Should be enough */ + jclass cls; + + line[0] = '\0'; + + master = ptym_open(line); + if (master >= 0) { + // turn off echo + if (console) { + set_noecho(master); + } + + /* Get a reference to the obj's class */ + cls = (*env)->GetObjectClass(env, jobj); + + /* Set the master fd. */ + fid = (*env)->GetFieldID(env, cls, "master", "I"); + if (!fid) { + return NULL; + } + (*env)->SetIntField(env, jobj, fid, (jint)master); + + /* Create a new String for the slave. */ + jstr = (*env)->NewStringUTF(env, line); + } + return jstr; +} + +JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTY_change_1window_1size(JNIEnv *env, jobject jobj, jint fdm, + jint width, jint height) { +#ifdef TIOCSWINSZ + struct winsize win; + + win.ws_col = width; + win.ws_row = height; + win.ws_xpixel = 0; + win.ws_ypixel = 0; + + return ioctl(fdm, TIOCSWINSZ, &win); +#else +#error no TIOCSWINSZ + return 0; +#endif +} diff --git a/core/org.eclipse.cdt.core.macosx/library/ptyio.c b/core/org.eclipse.cdt.core.native/native_src/unix/ptyio.c index e022db11f99..44e879cd48c 100644 --- a/core/org.eclipse.cdt.core.macosx/library/ptyio.c +++ b/core/org.eclipse.cdt.core.native/native_src/unix/ptyio.c @@ -13,8 +13,8 @@ *******************************************************************************/ #include <jni.h> #include <stdio.h> -#include <PTYInputStream.h> -#include <PTYOutputStream.h> +#include <org_eclipse_cdt_utils_pty_PTYInputStream.h> +#include <org_eclipse_cdt_utils_pty_PTYOutputStream.h> #include <unistd.h> /* Header for class _org_eclipse_cdt_utils_pty_PTYInputStream */ @@ -25,13 +25,8 @@ * Method: read0 * Signature: (I)I */ -JNIEXPORT jint JNICALL -Java_org_eclipse_cdt_utils_pty_PTYInputStream_read0(JNIEnv * env, - jobject jobj, - jint jfd, - jbyteArray buf, - jint buf_len) -{ +JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTYInputStream_read0(JNIEnv *env, jobject jobj, jint jfd, + jbyteArray buf, jint buf_len) { int fd; int status; jbyte *data; @@ -41,7 +36,7 @@ Java_org_eclipse_cdt_utils_pty_PTYInputStream_read0(JNIEnv * env, data_len = buf_len; fd = jfd; - status = read( fd, data, data_len ); + status = read(fd, data, data_len); (*env)->ReleaseByteArrayElements(env, buf, data, 0); if (status == 0) { @@ -49,8 +44,7 @@ Java_org_eclipse_cdt_utils_pty_PTYInputStream_read0(JNIEnv * env, status = -1; } else if (status == -1) { /* Error, toss an exception */ - /* Ignore the error for now, the debugger will attempt - * to close this multiple time. */ + /* Ignore the error for now, the debugger will attempt to close this multiple time. */ #if 0 jclass exception = (*env)->FindClass(env, "java/io/IOException"); if (exception == NULL) { @@ -64,17 +58,12 @@ Java_org_eclipse_cdt_utils_pty_PTYInputStream_read0(JNIEnv * env, return status; } - /* * Class: org_eclipse_cdt_utils_pty_PTYInputStream * Method: close0 * Signature: (I)I */ -JNIEXPORT jint JNICALL -Java_org_eclipse_cdt_utils_pty_PTYInputStream_close0(JNIEnv * env, - jobject jobj, - jint fd) -{ +JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTYInputStream_close0(JNIEnv *env, jobject jobj, jint fd) { return close(fd); } @@ -83,13 +72,8 @@ Java_org_eclipse_cdt_utils_pty_PTYInputStream_close0(JNIEnv * env, * Method: write0 * Signature: (II)I */ -JNIEXPORT jint JNICALL -Java_org_eclipse_cdt_utils_pty_PTYOutputStream_write0(JNIEnv * env, - jobject jobj, - jint jfd, - jbyteArray buf, - jint buf_len) -{ +JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTYOutputStream_write0(JNIEnv *env, jobject jobj, jint jfd, + jbyteArray buf, jint buf_len) { int status; int fd; jbyte *data; @@ -105,16 +89,11 @@ Java_org_eclipse_cdt_utils_pty_PTYOutputStream_write0(JNIEnv * env, return status; } - /* * Class: org_eclipse_cdt_utils_pty_PTYOutputStream * Method: close0 * Signature: (I)I */ -JNIEXPORT jint JNICALL -Java_org_eclipse_cdt_utils_pty_PTYOutputStream_close0(JNIEnv * env, - jobject jobj, - jint fd) -{ +JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTYOutputStream_close0(JNIEnv *env, jobject jobj, jint fd) { return close(fd); } diff --git a/core/org.eclipse.cdt.core.native/native_src/unix/spawner.c b/core/org.eclipse.cdt.core.native/native_src/unix/spawner.c new file mode 100644 index 00000000000..5b74f1c0a0f --- /dev/null +++ b/core/org.eclipse.cdt.core.native/native_src/unix/spawner.c @@ -0,0 +1,245 @@ +/******************************************************************************* + * Copyright (c) 2002, 2010 QNX Software Systems 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: + * QNX Software Systems - initial API and implementation + * Wind River Systems, Inc. + * Mikhail Zabaluev (Nokia) - bug 82744 + *******************************************************************************/ +#include <unistd.h> +#include <stdlib.h> +#include <stdio.h> +#include <signal.h> +#include <string.h> +#include <jni.h> +#include <stdbool.h> + +#include "exec0.h" +#include <org_eclipse_cdt_utils_spawner_Spawner.h> + +static bool trace_enabled = false; + +static void print_array(FILE *stream, const char *str, char **c_array) { + if (c_array) { + bool hasElement = false; + + fprintf(stream, "%s [", str); + + for (char **p = c_array; *p; p++) { + if (*p) { + if (hasElement) { + fprintf(stream, ","); + } + hasElement = true; + fprintf(stream, "\n \"%s\"", *p); + } + } + + if (hasElement) { + fprintf(stream, "\n"); + } + + fprintf(stream, "]\n"); + } else { + fprintf(stream, "%s null\n", str); + } +} + +static char **alloc_c_array(JNIEnv *env, jobjectArray j_array) { + jint c_array_size = (*env)->GetArrayLength(env, j_array); + char **c_array = calloc(c_array_size + 1, sizeof(char *)); + + if (c_array == NULL) { + return NULL; + } + + for (int i = 0; i < c_array_size; i++) { + jstring j_str = (jstring)(*env)->GetObjectArrayElement(env, j_array, i); + const char *c_str = (*env)->GetStringUTFChars(env, j_str, NULL); + c_array[i] = (char *)strdup(c_str); + (*env)->ReleaseStringUTFChars(env, j_str, c_str); + (*env)->DeleteLocalRef(env, j_str); + } + + return c_array; +} + +static void free_c_array(char **c_array) { + if (c_array) { + for (char **p = c_array; *p; p++) { + free(*p); + } + free(c_array); + } +} + +JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec2(JNIEnv *env, jobject jobj, jobjectArray jcmd, + jobjectArray jenv, jstring jdir, + jobjectArray jchannels, jstring jslaveName, + jint masterFD, jboolean console) { + const char *dirpath = (*env)->GetStringUTFChars(env, jdir, NULL); + const char *pts_name = (*env)->GetStringUTFChars(env, jslaveName, NULL); + char **cmd = NULL; + char **envp = NULL; + int fd[3]; + pid_t pid = -1; + + if (!jchannels) { + goto bail_out; + } + + cmd = alloc_c_array(env, jcmd); + if (!cmd) { + goto bail_out; + } + + envp = alloc_c_array(env, jenv); + if (!envp) { + goto bail_out; + } + + if (trace_enabled) { + print_array(stderr, "command:", cmd); + print_array(stderr, "Envp:", envp); + fprintf(stderr, "dirpath: %s\n", dirpath); + fprintf(stderr, "pts_name: %s\n", pts_name); + } + + pid = exec_pty(cmd[0], cmd, envp, dirpath, fd, pts_name, masterFD, console); + if (pid < 0) { + goto bail_out; + } + + jobject cls = (*env)->FindClass(env, "org/eclipse/cdt/utils/spawner/Spawner$UnixChannel"); + jmethodID constructor = (*env)->GetMethodID(env, cls, "<init>", "(I)V"); + for (jsize i = 0; i < 3; i++) { + jobject chan = (*env)->NewObject(env, cls, constructor, fd[i]); + (*env)->SetObjectArrayElement(env, jchannels, i, chan); + } + +bail_out: + (*env)->ReleaseStringUTFChars(env, jdir, dirpath); + (*env)->ReleaseStringUTFChars(env, jslaveName, pts_name); + free_c_array(cmd); + free_c_array(envp); + return pid; +} + +JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec1(JNIEnv *env, jobject jobj, jobjectArray jcmd, + jobjectArray jenv, jstring jdir) { + const char *dirpath = (*env)->GetStringUTFChars(env, jdir, NULL); + char **cmd = NULL; + char **envp = NULL; + pid_t pid = -1; + + cmd = alloc_c_array(env, jcmd); + if (!cmd) { + goto bail_out; + } + + envp = alloc_c_array(env, jenv); + if (!envp) { + goto bail_out; + } + + if (trace_enabled) { + print_array(stderr, "command:", cmd); + print_array(stderr, "Envp:", envp); + fprintf(stderr, "dirpath: %s\n", dirpath); + } + + pid = exec0(cmd[0], cmd, envp, dirpath, NULL); + if (pid < 0) { + goto bail_out; + } + +bail_out: + (*env)->ReleaseStringUTFChars(env, jdir, dirpath); + free_c_array(cmd); + free_c_array(envp); + return pid; +} + +JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec0(JNIEnv *env, jobject jobj, jobjectArray jcmd, + jobjectArray jenv, jstring jdir, + jobjectArray jchannels) { + const char *dirpath = (*env)->GetStringUTFChars(env, jdir, NULL); + char **cmd = NULL; + char **envp = NULL; + int fd[3]; + pid_t pid = -1; + jclass channelClass = NULL; + jmethodID channelConstructor = NULL; + + if (!jchannels) { + goto bail_out; + } + + channelClass = (*env)->FindClass(env, "org/eclipse/cdt/utils/spawner/Spawner$UnixChannel"); + if (channelClass == 0) { + goto bail_out; + } + + channelConstructor = (*env)->GetMethodID(env, channelClass, "<init>", "(I)V"); + if (!channelConstructor) { + goto bail_out; + } + + cmd = alloc_c_array(env, jcmd); + if (!cmd) { + goto bail_out; + } + + envp = alloc_c_array(env, jenv); + if (!envp) { + goto bail_out; + } + + if (trace_enabled) { + print_array(stderr, "command:", cmd); + print_array(stderr, "Envp:", envp); + fprintf(stderr, "dirpath: %s\n", dirpath); + } + pid = exec0(cmd[0], cmd, envp, dirpath, fd); + if (pid < 0) { + goto bail_out; + } + + for (jsize i = 0; i < 3; i++) { + jobject chan = (*env)->NewObject(env, channelClass, channelConstructor, fd[i]); + (*env)->SetObjectArrayElement(env, jchannels, i, chan); + } + +bail_out: + (*env)->ReleaseStringUTFChars(env, jdir, dirpath); + free_c_array(cmd); + free_c_array(envp); + return pid; +} + +JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_raise(JNIEnv *env, jobject jobj, jint pid, jint sig) { + int status = killpg(pid, sig); + if (status == -1) { + status = kill(pid, sig); + } + + return status; +} + +JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_waitFor(JNIEnv *env, jobject jobj, jint pid) { + return wait0(pid); +} + +JNIEXPORT void JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_configureNativeTrace( + JNIEnv *env, jclass cls, jboolean spawner, jboolean spawnerDetails, jboolean starter, jboolean readReport) { + if (spawner) { + trace_enabled = true; + } +} 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 new file mode 100644 index 00000000000..5a7740edbe7 --- /dev/null +++ b/core/org.eclipse.cdt.core.native/native_src/win/Win32ProcessEx.c @@ -0,0 +1,866 @@ +/******************************************************************************* + * Copyright (c) 2002, 2015 QNX Software Systems 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: + * QNX Software Systems - initial API and implementation + * Wind River Systems, Inc. + * + * Win32ProcessEx.c + * + * This is a JNI implementation of spawner + *******************************************************************************/ + +#include <string.h> +#include <stdlib.h> +#include <process.h> +#include <tchar.h> +#include <windows.h> +#include <jni.h> + +#include "util.h" + +#include <org_eclipse_cdt_utils_spawner_Spawner.h> + +#define PIPE_SIZE 512 // Size of pipe buffer +#define MAX_CMD_SIZE 2049 // Initial size of command line +#define MAX_ENV_SIZE 4096 // Initial size of environment block +#define PIPE_NAME_LENGTH 100 // Size of pipe name buffer +#define PIPE_TIMEOUT 10000 // Default time-out value, in milliseconds. + +#define MAX_PROCS (100) // Maximum number of simultaneously running processes + +typedef struct _eventInfo { + HANDLE handle; + wchar_t *name; +} EventInfo_t; + +// Process description block. Should be created for each launched process +typedef struct _procInfo { + int pid; // Process ID + int uid; // quasi-unique process ID; we have to create it to avoid duplicated pid + // (actually this impossible from OS point of view but it is still possible + // a clash of new created and already finished process with one and the same PID. + // 4 events connected to this process (see starter) + EventInfo_t eventBreak; // signaled when Spawner.interrupt() is called; mildest of the terminate requests (SIGINT + // signal in UNIX world) + EventInfo_t eventWait; + EventInfo_t eventTerminate; // signaled when Spawner.terminate() is called; more forceful terminate request (SIGTERM + // signal in UNIX world) + EventInfo_t eventKill; // signaled when Spawner.kill() is called; most forceful terminate request (SIGKILL signal in + // UNIX world) + EventInfo_t eventCtrlc; // signaled when Spawner.interruptCTRLC() is called; like interrupt() but sends CTRL-C in + // all cases, even when inferior is a Cygwin program +} procInfo_t, *pProcInfo_t; + +static int procCounter = 0; // Number of running processes + +// This is a VM helper +void ThrowByName(JNIEnv *env, const char *name, const wchar_t *msg); + +// Creates _procInfo block for every launched process +pProcInfo_t createProcInfo(); + +// Find process description for this pid +pProcInfo_t findProcInfo(int pid); + +// We launch separate thread for each project to trap it termination +void _cdecl waitProcTermination(void *pv); + +// Use this function to clean project descriptor and return it to the pool of available blocks. +static void cleanUpProcBlock(pProcInfo_t pCurProcInfo); + +int interruptProcess(int pid); + +extern CRITICAL_SECTION cs; + +extern wchar_t path[MAX_PATH]; // Directory where spawner.dll is located + +static pProcInfo_t pInfo = NULL; + +static int nCounter = 0; // We use it to build unique synchronization object names + +///////////////////////////////////////////////////////////////////////////////////// +// Launcher; launchess process and traps its termination +// Arguments: (see Spawner.java) +// [in] cmdarray - array of command line elements +// [in] envp - array of environment variables +// [in] dir - working directory +// [out] channels - streams handlers +///////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +extern "C" +#endif + JNIEXPORT jint JNICALL + Java_org_eclipse_cdt_utils_spawner_Spawner_exec2(JNIEnv *env, jobject process, jobjectArray cmdarray, + jobjectArray envp, jstring dir, jobjectArray channels, + jstring slaveName, jint fdm, jboolean console) { + return -1; +} + +static bool createStandardNamedPipe(HANDLE *handle, DWORD stdHandle, int pid, int counter) { + wchar_t pipeName[PIPE_NAME_LENGTH]; + DWORD dwOpenMode; + + switch (stdHandle) { + case STD_INPUT_HANDLE: + BUILD_PIPE_NAME(pipeName, L"stdin", pid, counter); + dwOpenMode = PIPE_ACCESS_OUTBOUND; + break; + case STD_OUTPUT_HANDLE: + BUILD_PIPE_NAME(pipeName, L"stdout", pid, counter); + dwOpenMode = PIPE_ACCESS_INBOUND | FILE_FLAG_OVERLAPPED; + break; + case STD_ERROR_HANDLE: + BUILD_PIPE_NAME(pipeName, L"stderr", pid, counter); + dwOpenMode = PIPE_ACCESS_INBOUND | FILE_FLAG_OVERLAPPED; + break; + default: + if (isTraceEnabled(CDT_TRACE_SPAWNER)) { + cdtTrace(L"Invalid STD handle given %i", stdHandle); + } + return false; + } + + HANDLE pipe = CreateNamedPipeW(pipeName, dwOpenMode, PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT, + PIPE_UNLIMITED_INSTANCES, PIPE_SIZE, PIPE_SIZE, PIPE_TIMEOUT, NULL); + if (INVALID_HANDLE_VALUE == pipe) { + if (isTraceEnabled(CDT_TRACE_SPAWNER)) { + cdtTrace(L"Failed to create named pipe: %s\n", pipeName); + } + return false; + } + + SetHandleInformation(pipe, HANDLE_FLAG_INHERIT, TRUE); + + if (isTraceEnabled(CDT_TRACE_SPAWNER)) { + cdtTrace(L"Successfully created pipe %s -> %p\n", pipeName, pipe); + } + + *handle = pipe; + return true; +} + +static bool createNamedEvent(EventInfo_t *eventInfo, BOOL manualReset, const wchar_t *prefix, int pid, int counter) { + wchar_t eventName[50]; + swprintf(eventName, sizeof(eventName) / sizeof(eventName[0]), L"%s%04x%08x", prefix, pid, counter); + + HANDLE event = CreateEventW(NULL, manualReset, FALSE, eventName); + if (!event) { + if (isTraceEnabled(CDT_TRACE_SPAWNER)) { + cdtTrace(L"Failed to create event %s -> %i\n", eventName, GetLastError()); + } + return false; + } else if (GetLastError() == ERROR_ALREADY_EXISTS) { + if (isTraceEnabled(CDT_TRACE_SPAWNER)) { + cdtTrace(L"Event %s already exist -> %p\n", eventName, event); + } + return false; + } + + eventInfo->handle = event; + eventInfo->name = wcsdup(eventName); + + if (!eventInfo->name) { + if (isTraceEnabled(CDT_TRACE_SPAWNER)) { + cdtTrace(L"Failed to allocate memory for event %s -> %p\n", eventName, event); + } + return false; + } + + if (isTraceEnabled(CDT_TRACE_SPAWNER)) { + cdtTrace(L"Successfully created event %s -> %p\n", eventName, event); + } + + return true; +} + +static bool createCommandLine(JNIEnv *env, jobjectArray cmdarray, wchar_t **cmdLine, const wchar_t *fmt, ...) { + va_list ap; + + va_start(ap, fmt); + + wchar_t *buffer = NULL; + int size = MAX_CMD_SIZE; + int required = 0; + do { + // Free previous buffer + free(buffer); + + size *= 2; + buffer = (wchar_t *)malloc(size * sizeof(wchar_t)); + + if (buffer) { + // Try to format the string + required = vswprintf(buffer, size, fmt, ap); + } else { + // malloc failed, clean up and return + va_end(ap); + ThrowByName(env, "java/io/IOException", L"Not enough memory"); + return false; + } + } while (size <= required); + va_end(ap); + + int nPos = wcslen(buffer); + int nCmdTokens = (*env)->GetArrayLength(env, cmdarray); + for (int i = 0; i < nCmdTokens; ++i) { + jstring item = (jstring)(*env)->GetObjectArrayElement(env, cmdarray, i); + jsize len = (*env)->GetStringLength(env, item); + const jchar *str = (*env)->GetStringChars(env, item, NULL); + if (str) { + required = nPos + len + 2; // 2 => space + \0 + if (required > 32 * 1024) { + free(buffer); + ThrowByName(env, "java/io/IOException", L"Command line too long"); + return false; + } + + while (1) { + // Ensure enough space in buffer + if (required > size) { + size *= 2; + if (size < required) { + size = required; + } + + wchar_t *tmp = (wchar_t *)realloc(buffer, size * sizeof(wchar_t)); + if (tmp) { + // Allocation successful + buffer = tmp; + } else { + // Failed to realloc memory + free(buffer); + ThrowByName(env, "java/io/IOException", L"Not enough memory"); + return false; + } + } + + int nCpyLen = copyTo(buffer + nPos, (const wchar_t *)str, len, size - nPos); + if (nCpyLen < 0) { // Buffer too small + // Do a real count of number of chars required + required = nPos + copyTo(NULL, (const wchar_t *)str, len, INT_MAX) + 2; // 2 => space + \0 + continue; + } + + // Buffer was big enough. + nPos += nCpyLen; + break; + } + + buffer[nPos++] = _T(' '); + buffer[nPos] = _T('\0'); + (*env)->ReleaseStringChars(env, item, str); + } else { + free(buffer); + ThrowByName(env, "java/io/IOException", L"Command line contained null string"); + return false; + } + } + + *cmdLine = buffer; + return true; +} + +static bool createEnvironmentBlock(JNIEnv *env, jobjectArray envp, wchar_t **block) { + int nEnvVars = (*env)->GetArrayLength(env, envp); + + if (isTraceEnabled(CDT_TRACE_SPAWNER)) { + cdtTrace(L"There are %i environment variables \n", nEnvVars); + } + + if (nEnvVars == 0) { + *block = NULL; + return true; + } + + int nPos = 0; + int bufferSize = MAX_ENV_SIZE; + wchar_t *buffer = (wchar_t *)malloc(bufferSize * sizeof(wchar_t)); + for (int i = 0; i < nEnvVars; ++i) { + jstring item = (jstring)(*env)->GetObjectArrayElement(env, envp, i); + const jchar *str = (*env)->GetStringChars(env, item, 0); + if (str) { + int len = wcslen(str); + while (bufferSize - nPos <= len + 2) { // +2 for two '\0' + bufferSize += MAX_ENV_SIZE; + wchar_t *tmp = (wchar_t *)realloc(buffer, bufferSize * sizeof(wchar_t)); + if (tmp) { + buffer = tmp; + } else { + free(buffer); + (*env)->ReleaseStringChars(env, item, str); + ThrowByName(env, "java/io/IOException", L"Not enough memory"); + return false; + } + if (isTraceEnabled(CDT_TRACE_SPAWNER)) { + cdtTrace(L"Realloc environment block; new length is %i \n", bufferSize); + } + } + if (isTraceEnabled(CDT_TRACE_SPAWNER)) { + cdtTrace(L"%s\n", (const wchar_t *)str); + } + wcsncpy(buffer + nPos, str, len); + nPos += len; + buffer[nPos++] = _T('\0'); + + (*env)->ReleaseStringChars(env, item, str); + } + } + + buffer[nPos] = _T('\0'); + *block = buffer; + + return true; +} + +#ifdef __cplusplus +extern "C" +#endif + JNIEXPORT jint JNICALL + 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", 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", L"Unable to find channel class"); + return 0; + } + + jmethodID channelConstructor = (*env)->GetMethodID(env, channelClass, "<init>", "(J)V"); + if (!channelConstructor) { + ThrowByName(env, "java/io/IOException", L"Unable to find channel constructor"); + return 0; + } + + if ((HIBYTE(LOWORD(GetVersion()))) & 0x80) { + ThrowByName(env, "java/io/IOException", L"Does not support Windows 3.1/95/98/Me"); + return 0; + } + + if (!cmdarray) { + ThrowByName(env, "java/lang/NullPointerException", L"No command line specified"); + return 0; + } + + DWORD pid = GetCurrentProcessId(); + + // Create pipe names + EnterCriticalSection(&cs); + int nLocalCounter = nCounter++; + LeaveCriticalSection(&cs); + + HANDLE stdHandles[] = {INVALID_HANDLE_VALUE, INVALID_HANDLE_VALUE, INVALID_HANDLE_VALUE}; + if (!createStandardNamedPipe(&stdHandles[0], STD_INPUT_HANDLE, pid, nLocalCounter) || + !createStandardNamedPipe(&stdHandles[1], STD_OUTPUT_HANDLE, pid, nLocalCounter) || + !createStandardNamedPipe(&stdHandles[2], STD_ERROR_HANDLE, pid, nLocalCounter)) { + CLOSE_HANDLES(stdHandles); + ThrowByName(env, "java/io/IOException", L"CreatePipe"); + return 0; + } + + pProcInfo_t pCurProcInfo = createProcInfo(); + if (!pCurProcInfo) { + CLOSE_HANDLES(stdHandles); + ThrowByName(env, "java/io/IOException", L"Too many processes"); + return 0; + } + + // Create events + if (!createNamedEvent(&pCurProcInfo->eventBreak, FALSE, L"SABreak", pid, nLocalCounter) || + !createNamedEvent(&pCurProcInfo->eventWait, TRUE, L"SAWait", pid, nLocalCounter) || + !createNamedEvent(&pCurProcInfo->eventTerminate, FALSE, L"SATerm", pid, nLocalCounter) || + !createNamedEvent(&pCurProcInfo->eventKill, FALSE, L"SAKill", pid, nLocalCounter) || + !createNamedEvent(&pCurProcInfo->eventCtrlc, FALSE, L"SACtrlc", pid, nLocalCounter)) { + cleanUpProcBlock(pCurProcInfo); + CLOSE_HANDLES(stdHandles); + ThrowByName(env, "java/io/IOException", L"Cannot create event"); + return 0; + } + + // Prepare command line + wchar_t *cmdLine = NULL; + if (!createCommandLine(env, cmdarray, &cmdLine, L"\"%sstarter.exe\" %i %i %s %s %s %s %s %i ", path, // + pid, // + nLocalCounter, // + pCurProcInfo->eventBreak.name, // + pCurProcInfo->eventWait.name, // + pCurProcInfo->eventTerminate.name, // + pCurProcInfo->eventKill.name, // + pCurProcInfo->eventCtrlc.name, // + isTraceEnabled(CDT_TRACE_SPAWNER_STARTER))) { + // Exception already thrown, just clean up + cleanUpProcBlock(pCurProcInfo); + CLOSE_HANDLES(stdHandles); + return 0; + } + + // Prepare environment block + wchar_t *envBlock = NULL; + if (!createEnvironmentBlock(env, envp, &envBlock)) { + // Exception already thrown, just clean up + free(cmdLine); + cleanUpProcBlock(pCurProcInfo); + CLOSE_HANDLES(stdHandles); + return 0; + } + + wchar_t *cwd = NULL; + if (dir) { + const jchar *str = (*env)->GetStringChars(env, dir, NULL); + if (str) { + cwd = wcsdup((const wchar_t *)str); + (*env)->ReleaseStringChars(env, dir, str); + } + } + + STARTUPINFOW si; + ZeroMemory(&si, sizeof(si)); + si.cb = sizeof(si); + si.dwFlags |= STARTF_USESHOWWINDOW; + si.wShowWindow = SW_HIDE; // Processes in the Process Group are hidden + + DWORD flags = CREATE_NEW_CONSOLE; + flags |= CREATE_NO_WINDOW; + flags |= CREATE_UNICODE_ENVIRONMENT; + + if (isTraceEnabled(CDT_TRACE_SPAWNER)) { + cdtTrace(cmdLine); + } + + // launches starter; we need it to create another console group to correctly process + // emulation of SYSint signal (Ctrl-C) + PROCESS_INFORMATION pi = {0}; + int ret = CreateProcessW(NULL, /* executable name */ + cmdLine, /* command line */ + 0, /* process security attribute */ + 0, /* thread security attribute */ + FALSE, /* inherits system handles */ + flags, /* normal attached process */ + envBlock, /* environment block */ + cwd, /* change to the new current directory */ + &si, /* (in) startup information */ + &pi); /* (out) process information */ + + const DWORD error_CreateProcessW = GetLastError(); + + free(cwd); + free(envBlock); + free(cmdLine); + + if (ret) { + HANDLE h[2]; + + EnterCriticalSection(&cs); + + pCurProcInfo->pid = pi.dwProcessId; + h[0] = pCurProcInfo->eventWait.handle; + h[1] = pi.hProcess; + + int what = WaitForMultipleObjects(2, h, FALSE, INFINITE); + if (what != WAIT_OBJECT_0) { // CreateProcess failed + if (isTraceEnabled(CDT_TRACE_SPAWNER)) { + cdtTrace(L"Process %i failed\n", pi.dwProcessId); + } + cleanUpProcBlock(pCurProcInfo); + CLOSE_HANDLES(stdHandles); + ThrowByName(env, "java/io/IOException", L"Launching failed"); + if (isTraceEnabled(CDT_TRACE_SPAWNER)) { + cdtTrace(L"Process failed\n"); + } + } else { + ret = (long)(pCurProcInfo->uid); + + // Prepare stream handlers to return to java program + for (jsize i = 0; i < 3; i++) { + jobject chan = (*env)->NewObject(env, channelClass, channelConstructor, (jlong)stdHandles[i]); + (*env)->SetObjectArrayElement(env, channels, i, chan); + } + + // do the cleanup so launch the according thread + // create a copy of the PROCESS_INFORMATION as this might get destroyed + PROCESS_INFORMATION *piCopy = (PROCESS_INFORMATION *)malloc(sizeof(PROCESS_INFORMATION)); + memcpy(piCopy, &pi, sizeof(PROCESS_INFORMATION)); + _beginthread(waitProcTermination, 0, (void *)piCopy); + + if (isTraceEnabled(CDT_TRACE_SPAWNER)) { + cdtTrace(L"Process started\n"); + } + } + LeaveCriticalSection(&cs); + } else { // Launching error + wchar_t *lpMsgBuf; + CLOSE_HANDLES(stdHandles); + lpMsgBuf = formatWinErrorCode(error_CreateProcessW); + ThrowByName(env, "java/io/IOException", lpMsgBuf); + // Free the buffer. + free(lpMsgBuf); + cleanUpProcBlock(pCurProcInfo); + ret = -1; + } + + CloseHandle(pi.hThread); + + return ret; +} + +///////////////////////////////////////////////////////////////////////////////////// +// Launcher; just launches process and don't care about it any more +// Arguments: (see Spawner.java) +// [in] cmdarray - array of command line elements +// [in] envp - array of environment variables +// [in] dir - working directory +///////////////////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" +#endif + JNIEXPORT jint JNICALL + Java_org_eclipse_cdt_utils_spawner_Spawner_exec1(JNIEnv *env, jobject process, jobjectArray cmdarray, + jobjectArray envp, jstring dir) { + + // Prepare command line + wchar_t *cmdLine = NULL; + if (!createCommandLine(env, cmdarray, &cmdLine, L"")) { + // Exception already thrown + return 0; + } + + // Prepare environment block + wchar_t *envBlock = NULL; + if (!createEnvironmentBlock(env, envp, &envBlock)) { + free(cmdLine); + return 0; + } + + wchar_t *cwd = NULL; + if (dir) { + const jchar *str = (*env)->GetStringChars(env, dir, NULL); + if (str) { + cwd = wcsdup((const wchar_t *)str); + (*env)->ReleaseStringChars(env, dir, str); + } + } + + STARTUPINFOW si; + ZeroMemory(&si, sizeof(si)); + si.cb = sizeof(si); + + DWORD flags = CREATE_NEW_CONSOLE; + flags |= CREATE_UNICODE_ENVIRONMENT; + + PROCESS_INFORMATION pi = {0}; + int ret = CreateProcessW(NULL, /* executable name */ + cmdLine, /* command line */ + 0, /* process security attribute */ + 0, /* thread security attribute */ + TRUE, /* inherits system handles */ + flags, /* normal attached process */ + envBlock, /* environment block */ + cwd, /* change to the new current directory */ + &si, /* (in) startup information */ + &pi); /* (out) process information */ + const DWORD error_CreateProcessW = GetLastError(); + + free(cwd); + free(cmdLine); + free(envBlock); + + if (ret) { + // Clean-up + CloseHandle(pi.hThread); + CloseHandle(pi.hProcess); + ret = (long)pi.dwProcessId; // hProcess; + } else { // error + wchar_t *lpMsgBuf = formatWinErrorCode(error_CreateProcessW); + ThrowByName(env, "java/io/IOException", lpMsgBuf); + // Free the buffer. + free(lpMsgBuf); + ret = -1; + } + + return ret; +} + +///////////////////////////////////////////////////////////////////////////////////// +// Emulation of the signal raising +// Arguments: (see Spawner.java) +// [in] uid - unique process ID +// [in] signal - signal to raise +///////////////////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" +#endif + JNIEXPORT jint JNICALL + Java_org_eclipse_cdt_utils_spawner_Spawner_raise(JNIEnv *env, jobject process, jint uid, jint signal) { + jint ret = 0; + + HANDLE hProc; + pProcInfo_t pCurProcInfo = findProcInfo(uid); + + if (!pCurProcInfo) { + if (org_eclipse_cdt_utils_spawner_Spawner_SIG_INT == signal) { // Try another way + return interruptProcess(uid); + } + return -1; + } + + if (isTraceEnabled(CDT_TRACE_SPAWNER)) { + cdtTrace(L"Spawner received signal %i for process %i\n", signal, pCurProcInfo->pid); + } + + hProc = OpenProcess(SYNCHRONIZE, 0, pCurProcInfo->pid); + + if (!hProc) { + return -1; + } + + switch (signal) { + case org_eclipse_cdt_utils_spawner_Spawner_SIG_NOOP: + // Wait 0 msec -just check if the process has been still running + ret = ((WAIT_TIMEOUT == WaitForSingleObject(hProc, 0)) ? 0 : -1); + break; + case org_eclipse_cdt_utils_spawner_Spawner_SIG_HUP: + // Temporary do nothing + ret = 0; + break; + case org_eclipse_cdt_utils_spawner_Spawner_SIG_TERM: + if (isTraceEnabled(CDT_TRACE_SPAWNER)) { + cdtTrace(L"Spawner received TERM signal for process %i\n", pCurProcInfo->pid); + } + SetEvent(pCurProcInfo->eventTerminate.handle); + if (isTraceEnabled(CDT_TRACE_SPAWNER)) { + cdtTrace(L"Spawner signaled TERM event\n"); + } + ret = 0; + break; + + case org_eclipse_cdt_utils_spawner_Spawner_SIG_KILL: + if (isTraceEnabled(CDT_TRACE_SPAWNER)) { + cdtTrace(L"Spawner received KILL signal for process %i\n", pCurProcInfo->pid); + } + SetEvent(pCurProcInfo->eventKill.handle); + if (isTraceEnabled(CDT_TRACE_SPAWNER)) { + cdtTrace(L"Spawner signaled KILL event\n"); + } + ret = 0; + break; + case org_eclipse_cdt_utils_spawner_Spawner_SIG_INT: + ResetEvent(pCurProcInfo->eventWait.handle); + SetEvent(pCurProcInfo->eventBreak.handle); + ret = (WaitForSingleObject(pCurProcInfo->eventWait.handle, 100) == WAIT_OBJECT_0); + break; + case org_eclipse_cdt_utils_spawner_Spawner_SIG_CTRLC: + ResetEvent(pCurProcInfo->eventWait.handle); + SetEvent(pCurProcInfo->eventCtrlc.handle); + ret = (WaitForSingleObject(pCurProcInfo->eventWait.handle, 100) == WAIT_OBJECT_0); + break; + default: + if (isTraceEnabled(CDT_TRACE_SPAWNER)) { + cdtTrace(L"Spawner does not support custom signals on Windows\n"); + } + ret = -1; + break; + } + + CloseHandle(hProc); + return ret; +} + +///////////////////////////////////////////////////////////////////////////////////// +// Wait for process termination +// Arguments: (see Spawner.java) +// [in] uid - unique process ID +///////////////////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" +#endif + JNIEXPORT jint JNICALL + Java_org_eclipse_cdt_utils_spawner_Spawner_waitFor(JNIEnv *env, jobject process, jint uid) { + DWORD exit_code = -1; + int what = 0; + HANDLE hProc; + pProcInfo_t pCurProcInfo = findProcInfo(uid); + + if (!pCurProcInfo) { + return -1; + } + + hProc = OpenProcess(SYNCHRONIZE | PROCESS_QUERY_INFORMATION, 0, pCurProcInfo->pid); + + if (!hProc) { + return -1; + } + + what = WaitForSingleObject(hProc, INFINITE); + + if (what == WAIT_OBJECT_0) { + GetExitCodeProcess(hProc, &exit_code); + } + + if (hProc) { + CloseHandle(hProc); + } + + return exit_code; +} + +// Utilities + +///////////////////////////////////////////////////////////////////////////////////// +// Throws Java exception (will be trapped by VM). +// Arguments: +// [in] name - name of exception class +// [in] message to assign the event +///////////////////////////////////////////////////////////////////////////////////// +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 */ + 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. */ + (*env)->DeleteLocalRef(env, cls); +} + +///////////////////////////////////////////////////////////////////////////////////// +// Create process description block. +// Arguments: no +// Return : pointer to the process descriptor +///////////////////////////////////////////////////////////////////////////////////// +pProcInfo_t createProcInfo() { + pProcInfo_t p = NULL; + + EnterCriticalSection(&cs); + + if (!pInfo) { + pInfo = (pProcInfo_t)malloc(sizeof(procInfo_t) * MAX_PROCS); + ZeroMemory(pInfo, sizeof(procInfo_t) * MAX_PROCS); + } + + for (int i = 0; i < MAX_PROCS; ++i) { + if (pInfo[i].pid == 0) { + pInfo[i].pid = -1; + pInfo[i].uid = ++procCounter; + p = pInfo + i; + break; + } + } + + LeaveCriticalSection(&cs); + + return p; +} + +///////////////////////////////////////////////////////////////////////////////////// +// Using unique process ID finds process descriptor +// Arguments: no +// Return : pointer to the process descriptor +///////////////////////////////////////////////////////////////////////////////////// +pProcInfo_t findProcInfo(int uid) { + if (pInfo) { + for (int i = 0; i < MAX_PROCS; ++i) { + if (pInfo[i].uid == uid) { + return pInfo + i; + } + } + } + + return NULL; +} + +///////////////////////////////////////////////////////////////////////////////////// +// Cleans up vacant process descriptor +// Arguments: +// pCurProcInfo - pointer to descriptor to clean up +// Return : no +void cleanUpProcBlock(pProcInfo_t pCurProcInfo) { + EventInfo_t *eventInfos[] = { + &pCurProcInfo->eventBreak, &pCurProcInfo->eventWait, &pCurProcInfo->eventTerminate, + &pCurProcInfo->eventKill, &pCurProcInfo->eventCtrlc, + }; + + for (int i = 0; i < sizeof(eventInfos) / sizeof(eventInfos[0]); i++) { + EventInfo_t *p = eventInfos[i]; + if (p->handle) { + CloseHandle(p->handle); + p->handle = NULL; + } + + free(p->name); + p->name = NULL; + } + + pCurProcInfo->pid = 0; +} + +///////////////////////////////////////////////////////////////////////////////////// +// Running in separate thread and waiting for the process termination +// Arguments: +// pv - pointer to PROCESS_INFORMATION struct +// Return : no +///////////////////////////////////////////////////////////////////////////////////// +void _cdecl waitProcTermination(void *pv) { + PROCESS_INFORMATION *pi = (PROCESS_INFORMATION *)pv; + + // wait for process termination + WaitForSingleObject(pi->hProcess, INFINITE); + + for (int i = 0; i < MAX_PROCS; i++) { + if (pInfo[i].pid == pi->dwProcessId) { + cleanUpProcBlock(pInfo + i); + if (isTraceEnabled(CDT_TRACE_SPAWNER)) { + cdtTrace(L"waitProcTermination: set PID %i to 0\n", pi->dwProcessId); + } + } + } + CloseHandle(pi->hProcess); + + free(pi); +} + +#ifdef __cplusplus +extern "C" +#endif + JNIEXPORT void JNICALL + Java_org_eclipse_cdt_utils_spawner_Spawner_configureNativeTrace(JNIEnv *env, jclass cls, jboolean spawner, + jboolean spawnerDetails, jboolean starter, + jboolean readReport) { + + if (spawner) { + enableTraceFor(CDT_TRACE_SPAWNER); + } + + if (spawnerDetails) { + enableTraceFor(CDT_TRACE_SPAWNER_DETAILS); + } + + if (starter) { + enableTraceFor(CDT_TRACE_SPAWNER_STARTER); + } + + if (readReport) { + enableTraceFor(CDT_TRACE_SPAWNER_READ_REPORT); + } +} diff --git a/core/org.eclipse.cdt.core.native/native_src/win/include/winpty.h b/core/org.eclipse.cdt.core.native/native_src/win/include/winpty.h new file mode 100644 index 00000000000..7987c4de1fe --- /dev/null +++ b/core/org.eclipse.cdt.core.native/native_src/win/include/winpty.h @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2011-2012 Ryan Prichard + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef WINPTY_H +#define WINPTY_H + +#include <stdlib.h> +#include <windows.h> + +#ifdef WINPTY +#define WINPTY_API __declspec(dllexport) +#else +#define WINPTY_API __declspec(dllimport) +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct winpty_s winpty_t; + +/* + * winpty API. + */ + +/* + * Starts a new winpty instance with the given size. + * + * This function creates a new agent process and connects to it. + */ +WINPTY_API winpty_t *winpty_open(int cols, int rows); + +/* + * Start a child process. Either (but not both) of appname and cmdline may + * be NULL. cwd and env may be NULL. env is a pointer to an environment + * block like that passed to CreateProcess. + * + * This function never modifies the cmdline, unlike CreateProcess. + * + * Only one child process may be started. After the child process exits, the + * agent will scrape the console output one last time, then close the data pipe + * once all remaining data has been sent. + * + * Returns 0 on success or a Win32 error code on failure. + */ +WINPTY_API int winpty_start_process(winpty_t *pc, const wchar_t *appname, const wchar_t *cmdline, const wchar_t *cwd, + const wchar_t *env); + +/* + * Returns the exit code of the process started with winpty_start_process, + * or -1 none is available. + */ +WINPTY_API int winpty_get_exit_code(winpty_t *pc); + +/* + * Returns the process id of the process started with winpty_start_process, + * or -1 none is available. + */ +WINPTY_API int winpty_get_process_id(winpty_t *pc); + +/* + * Returns an overlapped-mode pipe handle that can be read and written + * like a Unix terminal. + */ +WINPTY_API HANDLE winpty_get_data_pipe(winpty_t *pc); + +/* + * Change the size of the Windows console. + */ +WINPTY_API int winpty_set_size(winpty_t *pc, int cols, int rows); + +/* + * Toggle the console mode. If in console mode, no terminal escape sequences are send. + */ +WINPTY_API int winpty_set_console_mode(winpty_t *pc, int mode); + +/* + * Closes the winpty. + */ +WINPTY_API void winpty_close(winpty_t *pc); + +#ifdef __cplusplus +} +#endif + +#endif /* WINPTY_H */ 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 new file mode 100644 index 00000000000..64d63415774 --- /dev/null +++ b/core/org.eclipse.cdt.core.native/native_src/win/iostream.c @@ -0,0 +1,220 @@ +/******************************************************************************* + * Copyright (c) 2002, 2009 QNX Software Systems 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: + * QNX Software Systems - initial API and implementation + * + * raise.c + * + * This is a part of JNI implementation of spawner + * Includes implementation of JNI methods (see Spawner.java) + *******************************************************************************/ +#include <string.h> +#include <stdlib.h> +#include <jni.h> +#include <windows.h> + +#include "util.h" + +#include <org_eclipse_cdt_utils_spawner_Spawner.h> + +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", L"Invalid channel object"); + return NULL; + } + + jclass cls = (*env)->GetObjectClass(env, channel); + if (!cls) { + 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", L"Unable to find handle"); + return NULL; + } + + jlong handle = (*env)->GetLongField(env, channel, fid); + return (HANDLE)handle; +} + +/* Inaccessible static: skipBuffer */ +#ifdef __cplusplus +extern "C" +#endif + JNIEXPORT jint JNICALL + Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_read0(JNIEnv *env, jobject proc, jobject channel, + jbyteArray buf, jint len) { + jbyte tmpBuf[BUFF_SIZE]; + int nBuffOffset = 0; + HANDLE handle = channelToHandle(env, channel); + OVERLAPPED overlapped; + overlapped.Offset = 0; + overlapped.OffsetHigh = 0; + overlapped.hEvent = CreateEvent(NULL, // no security attribute + TRUE, // manual-reset event + TRUE, // initial state = signaled + NULL); // unnamed event object + + if (!overlapped.hEvent) { + wchar_t *lpMsgBuf = formatWinErrorCode(GetLastError()); + ThrowByName(env, "java/io/IOException", lpMsgBuf); + // Free the buffer. + free(lpMsgBuf); + } + + if (isTraceEnabled(CDT_TRACE_SPAWNER) && isTraceEnabled(CDT_TRACE_SPAWNER_READ_REPORT)) { + cdtTrace(L"Start read %p\n", handle); + } + + while (len > nBuffOffset) { + DWORD nNumberOfBytesToRead = min(len - nBuffOffset, BUFF_SIZE); + DWORD nNumberOfBytesRead; + if (0 == ReadFile(handle, tmpBuf, nNumberOfBytesToRead, &nNumberOfBytesRead, &overlapped)) { + int err = GetLastError(); + + if (err == ERROR_IO_PENDING) { + // asynchronous i/o is still in progress + // check on the results of the asynchronous read + if (GetOverlappedResult(handle, &overlapped, &nNumberOfBytesRead, TRUE)) { + err = 0; + } else { // if there was a problem ... + err = GetLastError(); + } + } + if (err == ERROR_BROKEN_PIPE) { // Pipe was closed + break; + } + if (err != 0) { + 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 + wchar_t *lpMsgBuf = formatWinErrorCode(err); + ThrowByName(env, "java/io/IOException", lpMsgBuf); + free(lpMsgBuf); + nBuffOffset = 0; + break; + } else { + // buffer overflow? + // according to msdn this happens in message read mode only + if (isTraceEnabled(CDT_TRACE_SPAWNER)) { + cdtTrace(L"Buffer full - %p, bytes read: %i\n", handle, nNumberOfBytesRead); + } + // nNumberOfBytesRead can be 0 here for unknown reason (bug 269223) + nNumberOfBytesRead = nNumberOfBytesToRead; + } + } + } + if (nNumberOfBytesRead > 0) { + (*env)->SetByteArrayRegion(env, buf, nBuffOffset, nNumberOfBytesRead, tmpBuf); + } else { + break; + } + nBuffOffset += nNumberOfBytesRead; + if (nNumberOfBytesRead != nNumberOfBytesToRead) { + break; + } else { + // Is there data left in the pipe? + DWORD bytesAvailable = 0; + if (!PeekNamedPipe(handle, NULL, 0, NULL, &bytesAvailable, NULL) || bytesAvailable == 0) { + // No bytes left + break; + } + } + } + CloseHandle(overlapped.hEvent); + if (isTraceEnabled(CDT_TRACE_SPAWNER) && isTraceEnabled(CDT_TRACE_SPAWNER_READ_REPORT)) { + cdtTrace(L"End read %p - bytes read: %d\n", handle, nBuffOffset); + } + return nBuffOffset; // This is a real full readed length +} + +#ifdef __cplusplus +extern "C" +#endif + JNIEXPORT jint JNICALL + Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_close0(JNIEnv *env, jobject proc, jobject channel) { + int rc; + HANDLE handle = channelToHandle(env, channel); + if (isTraceEnabled(CDT_TRACE_SPAWNER)) { + cdtTrace(L"Close %p\n", handle); + } + rc = (CloseHandle(handle) ? 0 : -1); + if (isTraceEnabled(CDT_TRACE_SPAWNER)) { + cdtTrace(L"Closed %p\n", handle); + } + return (rc ? GetLastError() : 0); +} + +#ifdef __cplusplus +extern "C" +#endif + JNIEXPORT jint JNICALL + Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_available0(JNIEnv *env, jobject proc, jobject channel) { + DWORD nAvail = 0; + HANDLE handle = channelToHandle(env, channel); + + if (0 == PeekNamedPipe(handle, NULL, 0, NULL, &nAvail, NULL)) { + // error + return 0; + } + return nAvail; +} + +#ifdef __cplusplus +extern "C" +#endif + JNIEXPORT jint JNICALL + Java_org_eclipse_cdt_utils_spawner_SpawnerOutputStream_write0(JNIEnv *env, jobject proc, jobject channel, + jbyteArray buf, jint len) { + jbyte tmpBuf[BUFF_SIZE]; + int nBuffOffset = 0; + HANDLE handle = channelToHandle(env, channel); + + while (len > nBuffOffset) { + DWORD nNumberOfBytesToWrite = min(len - nBuffOffset, BUFF_SIZE); + DWORD nNumberOfBytesWritten; + (*env)->GetByteArrayRegion(env, buf, nBuffOffset, nNumberOfBytesToWrite, tmpBuf); + if (0 == WriteFile(handle, tmpBuf, nNumberOfBytesToWrite, &nNumberOfBytesWritten, NULL)) { + wchar_t *lpMsgBuf = formatWinErrorCode(GetLastError()); + ThrowByName(env, "java/io/IOException", lpMsgBuf); + free(lpMsgBuf); + return 0; + } + nBuffOffset += nNumberOfBytesWritten; + } + return 0; +} + +#ifdef __cplusplus +extern "C" +#endif + JNIEXPORT jint JNICALL + Java_org_eclipse_cdt_utils_spawner_SpawnerOutputStream_close0(JNIEnv *env, jobject proc, jobject channel) { + int rc; + HANDLE handle = channelToHandle(env, channel); + if (isTraceEnabled(CDT_TRACE_SPAWNER)) { + cdtTrace(L"Close %p\n", handle); + } + FlushFileBuffers(handle); + rc = (CloseHandle(handle) ? 0 : -1); + if (isTraceEnabled(CDT_TRACE_SPAWNER)) { + cdtTrace(L"Closed %p\n", handle); + } + return (rc ? GetLastError() : 0); +} diff --git a/core/org.eclipse.cdt.core.native/native_src/win/pty.cpp b/core/org.eclipse.cdt.core.native/native_src/win/pty.cpp new file mode 100644 index 00000000000..a974f68bb38 --- /dev/null +++ b/core/org.eclipse.cdt.core.native/native_src/win/pty.cpp @@ -0,0 +1,382 @@ +/******************************************************************************* + * Copyright (c) 2013, 2016 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ + +#include "org_eclipse_cdt_utils_pty_PTY.h" +#include "org_eclipse_cdt_utils_pty_PTYInputStream.h" +#include "org_eclipse_cdt_utils_pty_PTYOutputStream.h" +#include "winpty.h" + +#include <string> +#include <vector> +#include <map> +#include <stdlib.h> +#include <assert.h> +#include <ctime> + +static std::map<int, winpty_t *> fd2pty; +static std::map<int, int> fd2rc; + +JNIEXPORT jstring JNICALL Java_org_eclipse_cdt_utils_pty_PTY_openMaster(JNIEnv *env, jobject jobj, jboolean console) { + jfieldID fid; /* Store the field ID */ + jstring jstr = NULL; + jclass cls; + + int master = -1; + char line[1024]; + + line[0] = '\0'; + + /* Open new winpty handle */ + winpty_t *winpty = winpty_open(80, 40); + if (!winpty) { + return NULL; + } + + /* Configure console mode */ + if (console) { + winpty_set_console_mode(winpty, 1); + } + + /* Generate masterFD based on current system time */ + srand((unsigned int)time(NULL)); + master = rand(); + + /* Make sure masterFD does not exist */ + while (fd2pty.find(master) != fd2pty.end()) { + master++; + } + + sprintf(line, "winpty_%i", master); + + /* Remember the winpty handle for the generated masterFD */ + fd2pty.insert(std::pair<int, winpty_t *>(master, winpty)); + + /* Get a reference to the obj's class */ + cls = env->GetObjectClass(jobj); + + /* Set the master fd. */ + fid = env->GetFieldID(cls, "master", "I"); + if (!fid) { + return NULL; + } + env->SetIntField(jobj, fid, (jint)master); + + /* Create a new String for the slave. */ + jstr = env->NewStringUTF(line); + + return jstr; +} + +JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTY_change_1window_1size(JNIEnv *env, jobject jobj, jint fdm, + jint width, jint height) { + int fd; + std::map<int, winpty_t *>::const_iterator fd2pty_Iter; + + fd = fdm; + fd2pty_Iter = fd2pty.find(fd); + if (fd2pty_Iter != fd2pty.end()) { + winpty_t *winpty = fd2pty_Iter->second; + if (winpty) { + return winpty_set_size(winpty, width, height); + } + } + + return 0; +} + +JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTYInputStream_read0(JNIEnv *env, jobject jobj, jint jfd, + jbyteArray buf, jint buf_len) { + DWORD amount = -1; + OVERLAPPED over; + int fd; + std::map<int, winpty_t *>::const_iterator fd2pty_Iter; + + fd = jfd; + fd2pty_Iter = fd2pty.find(fd); + if (fd2pty_Iter != fd2pty.end()) { + winpty_t *winpty = fd2pty_Iter->second; + if (winpty) { + /* Get the pipe handle */ + HANDLE handle = winpty_get_data_pipe(winpty); + + memset(&over, 0, sizeof(over)); + over.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); + + char *buffer = new char[buf_len]; + memset(buffer, 0, sizeof(*buffer)); + + jbyte *data = env->GetByteArrayElements(buf, 0); + memset(data, 0, sizeof(*data)); + + amount = 0; + BOOL ret = ReadFile(handle, buffer, buf_len, &amount, &over); + if (!ret) { + DWORD error = GetLastError(); + if (error == ERROR_IO_PENDING) { + ret = GetOverlappedResult(handle, &over, &amount, TRUE); + } + } + + if (ret && amount > 0) { + memcpy(data, buffer, amount); + } + + if (!ret || amount == 0) { + amount = -1; + } + + if (!ret && fd2pty.find(fd) != fd2pty.end()) { + int rc = winpty_get_exit_code(winpty); + fd2rc.insert(std::pair<int, int>(fd, rc)); + } + + delete[] buffer; + env->ReleaseByteArrayElements(buf, data, 0); + ResetEvent(over.hEvent); + } + } + + return amount; +} + +JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTYInputStream_close0(JNIEnv *env, jobject jobj, jint jfd) { + int fd; + std::map<int, winpty_t *>::iterator fd2pty_Iter; + + fd = jfd; + fd2pty_Iter = fd2pty.find(fd); + if (fd2pty_Iter != fd2pty.end()) { + winpty_t *winpty = fd2pty_Iter->second; + fd2pty.erase(fd2pty_Iter); + if (winpty) { + winpty_close(winpty); + winpty = NULL; + } + } + + return 0; +} + +JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTYOutputStream_write0(JNIEnv *env, jobject jobj, jint jfd, + jbyteArray buf, jint buf_len) { + DWORD written = -1; + OVERLAPPED over; + int fd; + std::map<int, winpty_t *>::iterator fd2pty_Iter; + + fd = jfd; + fd2pty_Iter = fd2pty.find(fd); + if (fd2pty_Iter != fd2pty.end()) { + winpty_t *winpty = fd2pty_Iter->second; + if (winpty) { + /* Get the pipe handle */ + HANDLE handle = winpty_get_data_pipe(winpty); + + memset(&over, 0, sizeof(over)); + over.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); + + char *buffer = new char[buf_len]; + memset(buffer, 0, sizeof(*buffer)); + + jbyte *data = env->GetByteArrayElements(buf, 0); + memcpy(buffer, data, buf_len); + + BOOL ret = WriteFile(handle, buffer, buf_len, &written, &over); + env->ReleaseByteArrayElements(buf, data, 0); + + if (!ret && GetLastError() == ERROR_IO_PENDING) { + ret = GetOverlappedResult(handle, &over, &written, TRUE); + } + if (!ret || (int)written != buf_len) { + written = -1; + } + + delete[] buffer; + } + } + + return written; +} + +JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTYOutputStream_close0(JNIEnv *env, jobject jobj, jint jfd) { + int fd; + std::map<int, winpty_t *>::iterator fd2pty_Iter; + + fd = jfd; + fd2pty_Iter = fd2pty.find(fd); + if (fd2pty_Iter != fd2pty.end()) { + winpty_t *winpty = fd2pty_Iter->second; + fd2pty.erase(fd2pty_Iter); + if (winpty) { + winpty_close(winpty); + winpty = NULL; + } + } + + return 0; +} + +/* + * Convert convert slashes to backslashes. + */ +static std::wstring convertSlashes(const wchar_t *path) { + std::wstring ret; + + for (int i = 0; path[i] != L'\0'; ++i) { + if (path[i] == L'/') { + ret.push_back(L'\\'); + } else { + ret.push_back(path[i]); + } + } + + return ret; +} + +// Convert argc/argv into a Win32 command-line following the escaping convention +// documented on MSDN. (e.g. see CommandLineToArgvW documentation) +static std::wstring argvToCommandLine(const std::vector<std::wstring> &argv) { + std::wstring result; + for (size_t argIndex = 0; argIndex < argv.size(); ++argIndex) { + if (argIndex > 0) { + result.push_back(L' '); + } + const wchar_t *arg = argv[argIndex].c_str(); + const bool quote = wcschr(arg, L' ') || wcschr(arg, L'\t') || *arg == L'\0'; + if (quote) { + result.push_back(L'\"'); + } + int bsCount = 0; + for (const wchar_t *p = arg; *p != L'\0'; ++p) { + if (*p == L'\\') { + bsCount++; + } else if (*p == L'\"') { + result.append(bsCount * 2 + 1, L'\\'); + result.push_back(L'\"'); + bsCount = 0; + } else { + result.append(bsCount, L'\\'); + bsCount = 0; + result.push_back(*p); + } + } + if (quote) { + result.append(bsCount * 2, L'\\'); + result.push_back(L'\"'); + } else { + result.append(bsCount, L'\\'); + } + } + return result; +} + +JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTY_exec2(JNIEnv *env, jobject jobj, jobjectArray jcmd, + jobjectArray jenv, jstring jdir, jobjectArray jchannels, + jstring jslaveName, jint masterFD, jboolean console) { + int fd; + std::map<int, winpty_t *>::iterator fd2pty_Iter; + + const wchar_t *cwdW = (const wchar_t *)env->GetStringChars(jdir, NULL); + const char *pts_name = env->GetStringUTFChars(jslaveName, NULL); + + int pid = -1; + + jint argc = env->GetArrayLength(jcmd); + jint envc = env->GetArrayLength(jenv); + + if (!jchannels || env->GetArrayLength(jchannels) != 3) { + goto bail_out; + } + + fd = masterFD; + fd2pty_Iter = fd2pty.find(fd); + if (fd2pty_Iter != fd2pty.end()) { + winpty_t *winpty = fd2pty_Iter->second; + if (winpty) { + std::vector<std::wstring> argVector; + + for (int i = 0; i < argc; i++) { + jstring j_str = (jstring)env->GetObjectArrayElement(jcmd, i); + const wchar_t *w_str = (const wchar_t *)env->GetStringChars(j_str, NULL); + if (i == 0) { + argVector.push_back(convertSlashes(w_str)); + } else { + argVector.push_back(w_str); + } + env->ReleaseStringChars(j_str, (const jchar *)w_str); + env->DeleteLocalRef(j_str); + } + + std::wstring envp; + + for (int i = 0; i < envc; i++) { + jstring j_str = (jstring)env->GetObjectArrayElement(jenv, i); + const wchar_t *w_str = (const wchar_t *)env->GetStringChars(j_str, NULL); + envp.append(w_str); + envp.push_back(L'\0'); + env->ReleaseStringChars(j_str, (const jchar *)w_str); + env->DeleteLocalRef(j_str); + } + + std::wstring cmdLine = argvToCommandLine(argVector); + const wchar_t *cmdLineW = cmdLine.c_str(); + + int ret = winpty_start_process(winpty, NULL, cmdLineW, cwdW, envp.c_str()); + + if (ret == 0) { + // Success. Get the process id. + pid = winpty_get_process_id(winpty); + } + } + } + +bail_out: + env->ReleaseStringChars(jdir, (const jchar *)cwdW); + env->ReleaseStringUTFChars(jslaveName, pts_name); + + return pid; +} + +JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTY_waitFor(JNIEnv *env, jobject jobj, jint masterFD, jint pid) { + int status = -1; + DWORD flags; + + int fd; + std::map<int, winpty_t *>::iterator fd2pty_Iter; + std::map<int, int>::iterator fd2rc_Iter; + + fd = masterFD; + fd2pty_Iter = fd2pty.find(fd); + if (fd2pty_Iter != fd2pty.end()) { + winpty_t *winpty = fd2pty_Iter->second; + if (winpty) { + HANDLE handle = winpty_get_data_pipe(winpty); + BOOL success; + do { + success = GetHandleInformation(handle, &flags); + if (success) { + Sleep(500); + } + } while (success); + + fd2rc_Iter = fd2rc.find(fd); + if (fd2rc_Iter != fd2rc.end()) { + status = fd2rc_Iter->second; + fd2rc.erase(fd2rc_Iter); + } + } + } + + return status; +} diff --git a/core/org.eclipse.cdt.core.native/native_src/win/pty_dllmain.cpp b/core/org.eclipse.cdt.core.native/native_src/win/pty_dllmain.cpp new file mode 100644 index 00000000000..79e230e78ec --- /dev/null +++ b/core/org.eclipse.cdt.core.native/native_src/win/pty_dllmain.cpp @@ -0,0 +1,47 @@ +// dllmain.cpp : Defines the entry point for the DLL application. +#include <windows.h> +#include <delayimp.h> +#include <assert.h> + +static HMODULE getCurrentModule() { + HMODULE module; + if (!GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, + (LPCTSTR)getCurrentModule, &module)) { + assert(false); + } + return module; +} + +HMODULE PTYExplicitLoadLibrary(LPCSTR pszModuleName) { + if (lstrcmpiA(pszModuleName, "winpty.dll") == 0) { + CHAR szPath[MAX_PATH] = ""; + //_hdllInstance is the HMODULE of *this* module + DWORD cchPath = GetModuleFileNameA(getCurrentModule(), szPath, MAX_PATH); + while (cchPath > 0) { + switch (szPath[cchPath - 1]) { + case '\\': + case '/': + case ':': + break; + default: + --cchPath; + continue; + } + break; // stop searching; found path separator + } + lstrcpynA(szPath + cchPath, pszModuleName, MAX_PATH - cchPath); + return LoadLibraryA(szPath); // call with full path to dependent DLL + } + return NULL; +} + +FARPROC WINAPI PTYDliNotifyHook(unsigned dliNotify, PDelayLoadInfo pdli) { + if (dliNotify == dliNotePreLoadLibrary) { + return (FARPROC)PTYExplicitLoadLibrary(pdli->szDll); + } + return NULL; +} + +extern "C" { +PfnDliHook __pfnDliNotifyHook2 = PTYDliNotifyHook; +} diff --git a/core/org.eclipse.cdt.core.native/native_src/win/raise.c b/core/org.eclipse.cdt.core.native/native_src/win/raise.c new file mode 100644 index 00000000000..32ad071406e --- /dev/null +++ b/core/org.eclipse.cdt.core.native/native_src/win/raise.c @@ -0,0 +1,165 @@ +/******************************************************************************* + * Copyright (c) 2002, 2011 QNX Software Systems 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: + * QNX Software Systems - initial API and implementation + * + * raise.c + * + * This is a part of JNI implementation of spawner + *******************************************************************************/ +#include <jni.h> +#include <windows.h> + +#include "util.h" + +#include <org_eclipse_cdt_utils_spawner_Spawner.h> + +static HWND consoleHWND; + +///////////////////////////////////////////////////////////////////////////////////// +// Check if window is a console of process with pid +// Arguments: +// hwnd - window handler +// arg - process PID +// Return : TRUE if yes +///////////////////////////////////////////////////////////////////////////////////// +static BOOL CALLBACK find_child_console(HWND hwnd, LPARAM arg) { + DWORD process_id; + DWORD pid = arg; + + GetWindowThreadProcessId(hwnd, &process_id); + if (process_id == pid) { + wchar_t window_class[32]; + + GetClassName(hwnd, window_class, sizeof(window_class)); + if (wcscmp(window_class, L"ConsoleWindowClass") == 0) { + consoleHWND = hwnd; + return FALSE; + } + } + /* keep looking */ + return TRUE; +} + +// Need to declare this Win32 prototype ourselves. _WIN32_WINNT is getting +// defined to a Windows NT value, thus we don't get this. Can't assume +// we're running on XP, anyway (or can we by now?) +#if (_WIN32_WINNT < 0x0501) || defined(_MSC_VER) +typedef BOOL(WINAPI *DebugBreakProcessFunc)(HANDLE); +#endif + +///////////////////////////////////////////////////////////////////////////////////// +// Called to interrupt a process that we didn't launch (and thus does not share our +// console). Windows XP introduced the function 'DebugBreakProcess', which allows +// a process to interrupt another process even if if the two do not share a console. +// If we're running on 2000 or earlier, we have to resort to simulating a CTRL-C +// in the console by firing keyboard events. This will work only if the process +// has its own console. That means, e.g., the process should have been started at +// the cmdline with 'start myprogram.exe' instead of 'myprogram.exe'. +// +// Arguments: +// pid - process' pid +// Return : 0 if OK or error code +///////////////////////////////////////////////////////////////////////////////////// +int interruptProcess(int pid) { + // See if DebugBreakProcess is available (XP and beyond) + HMODULE hmod = LoadLibrary(L"Kernel32.dll"); + if (hmod) { + BOOL success = FALSE; + FARPROC procaddr = GetProcAddress(hmod, "DebugBreakProcess"); + if (procaddr != NULL) { + HANDLE proc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, (DWORD)pid); + if (proc != NULL) { + typedef BOOL WINAPI (*DebugBreakProcessFunc)(HANDLE); + DebugBreakProcessFunc pDebugBreakProcess = (DebugBreakProcessFunc)procaddr; + success = (*pDebugBreakProcess)(proc); + CloseHandle(proc); + } + } + FreeLibrary(hmod); + hmod = NULL; + + if (success) { + return 0; // 0 == OK; if not, try old-school way + } + } + + int rc = 0; + consoleHWND = NULL; + + if (isTraceEnabled(CDT_TRACE_SPAWNER)) { + cdtTrace(L"Try to interrupt process %i\n", pid); + } + // Find console + EnumWindows(find_child_console, (LPARAM)pid); + + if (consoleHWND) { // Yes, we found out it + // We are going to switch focus to console, + // send Ctrl-C and then restore focus + BYTE control_scan_code = (BYTE)MapVirtualKey(VK_CONTROL, 0); + /* Fake Ctrl-C for SIGINT, and Ctrl-Break for SIGQUIT. */ + BYTE vk_break_code = VK_CANCEL; + BYTE break_scan_code = (BYTE)MapVirtualKey(vk_break_code, 0); + HWND foreground_window; + + foreground_window = GetForegroundWindow(); + if (foreground_window) { + /* NT 5.0, and apparently also Windows 98, will not allow + * a Window to be set to foreground directly without the + * user's involvement. The workaround is to attach + * ourselves to the thread that owns the foreground + * window, since that is the only thread that can set the + * foreground window. + */ + DWORD foreground_thread, child_thread; + foreground_thread = GetWindowThreadProcessId(foreground_window, NULL); + if (foreground_thread == GetCurrentThreadId() || + !AttachThreadInput(GetCurrentThreadId(), foreground_thread, TRUE)) { + foreground_thread = 0; + } + + child_thread = GetWindowThreadProcessId(consoleHWND, NULL); + if (child_thread == GetCurrentThreadId() || !AttachThreadInput(GetCurrentThreadId(), child_thread, TRUE)) { + child_thread = 0; + } + + /* Set the foreground window to the child. */ + if (SetForegroundWindow(consoleHWND)) { + if (0 != break_scan_code) { + /* Generate keystrokes as if user had typed Ctrl-Break */ + keybd_event(VK_CONTROL, control_scan_code, 0, 0); + keybd_event(vk_break_code, break_scan_code, KEYEVENTF_EXTENDEDKEY, 0); + keybd_event(vk_break_code, break_scan_code, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); + keybd_event(VK_CONTROL, control_scan_code, KEYEVENTF_KEYUP, 0); + } + + /* Sleep for a bit to give time for respond */ + Sleep(100); + + SetForegroundWindow(foreground_window); + } + /* Detach from the foreground and child threads now that the foreground switching is over. */ + if (foreground_thread) { + AttachThreadInput(GetCurrentThreadId(), foreground_thread, FALSE); + } + if (child_thread) { + AttachThreadInput(GetCurrentThreadId(), child_thread, FALSE); + } + if (isTraceEnabled(CDT_TRACE_SPAWNER)) { + cdtTrace(L"Sent Ctrl-C & Ctrl-Break to process %i\n", pid); + } + } + } else if (isTraceEnabled(CDT_TRACE_SPAWNER)) { + cdtTrace(L"Cannot find console for process %i\n", pid); + } + + return rc; +} diff --git a/core/org.eclipse.cdt.core.native/native_src/win/spawner.c b/core/org.eclipse.cdt.core.native/native_src/win/spawner.c new file mode 100644 index 00000000000..adf5ccc3e24 --- /dev/null +++ b/core/org.eclipse.cdt.core.native/native_src/win/spawner.c @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright (c) 2002, 2007 QNX Software Systems 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: + * QNX Software Systems - initial API and implementation + * + * spawner.c + * + * This is a part of JNI implementation of spawner + *******************************************************************************/ + +#include <tchar.h> +#include <windows.h> + +#include "org_eclipse_cdt_utils_spawner_Spawner.h" + +CRITICAL_SECTION cs; + +wchar_t path[MAX_PATH + 1] = {_T('\0')}; // Directory where spawner.dll is located + +#if __cplusplus +extern "C" +#endif + BOOL APIENTRY + DllMain(HINSTANCE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { + switch (ul_reason_for_call) { + case DLL_PROCESS_ATTACH: { + wchar_t *p; + InitializeCriticalSection(&cs); + GetModuleFileNameW(hModule, path, MAX_PATH); + p = wcsrchr(path, _T('\\')); + if (p) { + *(p + 1) = _T('\0'); + } else { + wcscat(path, L"\\"); + } + } break; + case DLL_THREAD_ATTACH: + case DLL_THREAD_DETACH: + break; + case DLL_PROCESS_DETACH: + DeleteCriticalSection(&cs); + break; + } + return TRUE; +} 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 new file mode 100644 index 00000000000..690c21246b9 --- /dev/null +++ b/core/org.eclipse.cdt.core.native/native_src/win/starter.c @@ -0,0 +1,491 @@ +/******************************************************************************* + * Copyright (c) 2002, 2015 QNX Software Systems 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: + * QNX Software Systems - initial API and implementation + * Wind River Systems, Inc. + * + * starter.cpp + * + * This is a small utility for windows spawner + *******************************************************************************/ + +#define STRICT +#define _WIN32_WINNT 0x0500 +#include <windows.h> +#include <process.h> +#include <tchar.h> +#include <stdio.h> +#include <psapi.h> +#include <stdbool.h> + +#include "util.h" + +#define MAX_CMD_LINE_LENGTH (2049) +#define PIPE_NAME_LENGTH 100 + +int copyTo(wchar_t *target, const wchar_t *source, int cpyLength, int availSpace); +void DisplayErrorMessage(); + +// BOOL KillProcessEx(DWORD dwProcessId); // Handle of the process + +/////////////////////////////////////////////////////////////////////////////// +BOOL WINAPI HandlerRoutine(DWORD dwCtrlType) { // control signal type + BOOL ret = TRUE; + switch (dwCtrlType) { + case CTRL_C_EVENT: + break; + case CTRL_BREAK_EVENT: + break; + case CTRL_CLOSE_EVENT: + ret = FALSE; + break; + case CTRL_LOGOFF_EVENT: + ret = FALSE; + break; + case CTRL_SHUTDOWN_EVENT: + ret = FALSE; + break; + default: + break; + } + return ret; +} + +// The default here means we haven't checked yet +// i.e. cygwin is true but the bin dir hasn't been captured +wchar_t *cygwinBin = NULL; +bool _isCygwin = true; + +bool isCygwin(HANDLE process) { + // Have we checked before? + if (cygwinBin || !_isCygwin) { + return _isCygwin; + } + + // See if this process loaded cygwin, need a different SIGINT for them + HMODULE mods[1024]; + DWORD needed; + if (EnumProcessModules(process, mods, sizeof(mods), &needed)) { + int i; + needed /= sizeof(HMODULE); + for (i = 0; i < needed; ++i) { + wchar_t modName[MAX_PATH]; + if (GetModuleFileNameEx(process, mods[i], modName, MAX_PATH)) { + wchar_t *p = wcsrchr(modName, L'\\'); + if (p) { + *p = 0; // Null terminate there for future reference + if (!wcscmp(++p, L"cygwin1.dll")) { + _isCygwin = true; + // Store away the bind dir + cygwinBin = wcsdup(modName); + return _isCygwin; + } + } + } + } + } + + _isCygwin = false; + return _isCygwin; +} + +bool runCygwinCommand(wchar_t *command) { + wchar_t cygcmd[1024]; + swprintf(cygcmd, sizeof(cygcmd) / sizeof(cygcmd[0]), L"%s\\%s", cygwinBin, command); + + STARTUPINFO si; + ZeroMemory(&si, sizeof(si)); + si.cb = sizeof(si); + PROCESS_INFORMATION pi; + ZeroMemory(&pi, sizeof(pi)); + if (CreateProcess(NULL, cygcmd, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) { + WaitForSingleObject(pi.hProcess, INFINITE); + CloseHandle(pi.hThread); + CloseHandle(pi.hProcess); + return true; + } else if (CreateProcess(NULL, command, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) { + WaitForSingleObject(pi.hProcess, INFINITE); + CloseHandle(pi.hThread); + CloseHandle(pi.hProcess); + return true; + } + return false; +} + +static bool openNamedPipeAsStdHandle(HANDLE *handle, DWORD stdHandle, int parentPid, int counter, + SECURITY_ATTRIBUTES *sa) { + wchar_t pipeName[PIPE_NAME_LENGTH]; + DWORD dwDesiredAccess; + DWORD dwShareMode; + + switch (stdHandle) { + case STD_INPUT_HANDLE: + BUILD_PIPE_NAME(pipeName, L"stdin", parentPid, counter); + dwDesiredAccess = GENERIC_READ; + dwShareMode = FILE_SHARE_READ; + break; + case STD_OUTPUT_HANDLE: + BUILD_PIPE_NAME(pipeName, L"stdout", parentPid, counter); + dwDesiredAccess = GENERIC_WRITE; + dwShareMode = FILE_SHARE_WRITE; + break; + case STD_ERROR_HANDLE: + BUILD_PIPE_NAME(pipeName, L"stderr", parentPid, counter); + dwDesiredAccess = GENERIC_WRITE; + dwShareMode = FILE_SHARE_WRITE; + break; + default: + if (isTraceEnabled(CDT_TRACE_SPAWNER)) { + cdtTrace(L"Invalid STD handle given %i", stdHandle); + } + return false; + } + + *handle = CreateFileW(pipeName, dwDesiredAccess, dwShareMode, NULL, OPEN_EXISTING, 0, sa); + if (INVALID_HANDLE_VALUE == *handle) { + if (isTraceEnabled(CDT_TRACE_SPAWNER)) { + cdtTrace(L"Failed to open pipe: %s -> %p\n", pipeName, handle); + } + return false; + } + + SetHandleInformation(*handle, HANDLE_FLAG_INHERIT, TRUE); + + if (!SetStdHandle(stdHandle, *handle)) { + if (isTraceEnabled(CDT_TRACE_SPAWNER)) { + cdtTrace(L"Failed to reassign standard stream to pipe %s: %i\n", pipeName, GetLastError()); + } + return false; + } + + if (isTraceEnabled(CDT_TRACE_SPAWNER)) { + cdtTrace(L"Successfully assigned pipe %s -> %p\n", pipeName, *handle); + } + + return true; +} + +bool createCommandLine(int argc, wchar_t **argv, wchar_t **cmdLine) { + int size = MAX_CMD_LINE_LENGTH; + wchar_t *buffer = (wchar_t *)malloc(size * sizeof(wchar_t)); + + if (!buffer) { + // malloc failed + cdtTrace(L"Not enough memory to build cmd line!\n"); + return false; + } + + int nPos = 0; + for (int i = 0; i < argc; ++i) { + wchar_t *str = *(argv + i); + int len = wcslen(str); + if (str) { + int required = nPos + len + 2; // 2 => space + \0 + if (required > 32 * 1024) { + free(buffer); + if (isTraceEnabled(CDT_TRACE_SPAWNER)) { + cdtTrace(L"Command line too long!\n"); + } + return false; + } + + while (1) { + // Ensure enough space in buffer + if (required > size) { + size *= 2; + if (size < required) { + size = required; + } + + wchar_t *tmp = (wchar_t *)realloc(buffer, size * sizeof(wchar_t)); + if (tmp) { + // realloc successful + buffer = tmp; + } else { + // Failed to realloc memory + free(buffer); + if (isTraceEnabled(CDT_TRACE_SPAWNER)) { + cdtTrace(L"Not enough memory to build cmd line!\n"); + } + return false; + } + } + + int nCpyLen = copyTo(buffer + nPos, (const wchar_t *)str, len, size - nPos); + if (nCpyLen < 0) { // Buffer too small + // Do a real count of number of chars required + required = nPos + copyTo(NULL, (const wchar_t *)str, len, INT_MAX) + 2; // 2 => space + \0 + continue; + } + + // Buffer was big enough. + nPos += nCpyLen; + break; + } + + buffer[nPos++] = _T(' '); + buffer[nPos] = _T('\0'); + } else { + free(buffer); + if (isTraceEnabled(CDT_TRACE_SPAWNER)) { + cdtTrace(L"Invalid argument!\n"); + } + return false; + } + } + + *cmdLine = buffer; + return true; +} + +void raiseSignal(HANDLE h, int pid, const wchar_t *signal) { + if (isCygwin(h)) { + // Need to issue a kill command + wchar_t kill[1024]; + swprintf(kill, sizeof(kill) / sizeof(kill[0]), L"kill -%s %d", signal, pid); + if (!runCygwinCommand(kill)) { + // fall back to console event + GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0); + } + } else { + GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0); + } +} + +int main() { + + int argc; + wchar_t **argv = CommandLineToArgvW(GetCommandLine(), &argc); + + // Make sure that we've been passed the right number of arguments + if (argc < 9) { + wprintf( + L"Usage: %s (parent pid) (counter) (four inheritable event handles) (trace enable) (CommandLineToSpawn)\n", + argv[0]); + return 0; + } + + // Activate tracing... + if (wcstol(argv[8], NULL, 2)) { + for (int i = 0; i < sizeof(ALL_TRACE_KINDS) / sizeof(ALL_TRACE_KINDS[0]); i++) { + enableTraceFor(ALL_TRACE_KINDS[i]); + } + } + + STARTUPINFOW si = {sizeof(si)}; + PROCESS_INFORMATION pi = {0}; + DWORD dwExitCode = 0; + + BOOL exitProc = FALSE; + HANDLE waitEvent = OpenEventW(EVENT_ALL_ACCESS, TRUE, argv[4]); + HANDLE h[5]; + h[0] = OpenEventW(EVENT_ALL_ACCESS, TRUE, argv[3]); // simulated SIGINT (CTRL-C or Cygwin 'kill -SIGINT') + // h[1] we reserve for the process handle + h[2] = OpenEventW(EVENT_ALL_ACCESS, TRUE, argv[5]); // simulated SIGTERM + h[3] = OpenEventW(EVENT_ALL_ACCESS, TRUE, argv[6]); // simulated SIGKILL + h[4] = OpenEventW(EVENT_ALL_ACCESS, TRUE, argv[7]); // CTRL-C, in all cases + + SetConsoleCtrlHandler(HandlerRoutine, TRUE); + + int parentPid = wcstol(argv[1], NULL, 10); + int nCounter = wcstol(argv[2], NULL, 10); + + HANDLE stdHandles[] = { + INVALID_HANDLE_VALUE, // STDIN + INVALID_HANDLE_VALUE, // STDOUT + INVALID_HANDLE_VALUE // STDERR + }; + + SECURITY_ATTRIBUTES sa; + sa.nLength = sizeof(SECURITY_ATTRIBUTES); + sa.bInheritHandle = TRUE; + sa.lpSecurityDescriptor = NULL; + + if (!openNamedPipeAsStdHandle(&stdHandles[0], STD_INPUT_HANDLE, parentPid, nCounter, &sa) || + !openNamedPipeAsStdHandle(&stdHandles[1], STD_OUTPUT_HANDLE, parentPid, nCounter, &sa) || + !openNamedPipeAsStdHandle(&stdHandles[2], STD_ERROR_HANDLE, parentPid, nCounter, &sa)) { + CLOSE_HANDLES(stdHandles); + return -1; + } + + if (isTraceEnabled(CDT_TRACE_SPAWNER_DETAILS)) { + wchar_t *lpvEnv = GetEnvironmentStringsW(); + + if (lpvEnv) { + // Variable strings are separated by NULL byte, and the block is + // terminated by a NULL byte. + + cdtTrace(L"Starter: Environment\n"); + for (wchar_t *lpszVariable = lpvEnv; *lpszVariable; lpszVariable += wcslen(lpszVariable) + 1) { + cdtTrace(L"%s\n", lpszVariable); + } + + FreeEnvironmentStringsW(lpvEnv); + } else { + // If the returned pointer is NULL, exit. + cdtTrace(L"Cannot Read Environment\n"); + } + } + + // Create job object + HANDLE hJob = CreateJobObject(NULL, NULL); + if (hJob) { + // Configure job to + // - terminate all associated processes when the last handle to it is closed + // - allow child processes to break away from the job. + JOBOBJECT_EXTENDED_LIMIT_INFORMATION jobInfo; + ZeroMemory(&jobInfo, sizeof(jobInfo)); + jobInfo.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE | JOB_OBJECT_LIMIT_BREAKAWAY_OK; + if (!SetInformationJobObject(hJob, JobObjectExtendedLimitInformation, &jobInfo, sizeof(jobInfo))) { + if (isTraceEnabled(CDT_TRACE_SPAWNER)) { + cdtTrace(L"Cannot set job information\n"); + DisplayErrorMessage(); + } + } + } else if (isTraceEnabled(CDT_TRACE_SPAWNER)) { + cdtTrace(L"Cannot create job object\n"); + DisplayErrorMessage(); + } + + // Construct the full command line + wchar_t *cmdLine = NULL; + if (!createCommandLine(argc - 9, &argv[9], &cmdLine)) { + return 0; + } + + if (isTraceEnabled(CDT_TRACE_SPAWNER)) { + cdtTrace(L"Starting: %s\n", cmdLine); + } + + // Spawn the other processes as part of this Process Group + // If this process is already part of a job, the flag CREATE_BREAKAWAY_FROM_JOB + // makes the child process detach from the job, such that we can assign it + // to our own job object. + BOOL f = CreateProcessW(NULL, cmdLine, NULL, NULL, TRUE, CREATE_BREAKAWAY_FROM_JOB, NULL, NULL, &si, &pi); + // If breaking away from job is not permitted, retry without breakaway flag + if (!f) { + f = CreateProcessW(NULL, cmdLine, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi); + } + + // We don't need them any more + CLOSE_HANDLES(stdHandles); + + if (f) { + free(cmdLine); + cmdLine = NULL; + + if (isTraceEnabled(CDT_TRACE_SPAWNER)) { + cdtTrace(L"Process %i started\n", pi.dwProcessId); + } + SetEvent(waitEvent); // Means that process has been spawned + CloseHandle(pi.hThread); + h[1] = pi.hProcess; + + if (hJob) { + if (!AssignProcessToJobObject(hJob, pi.hProcess)) { + if (isTraceEnabled(CDT_TRACE_SPAWNER)) { + cdtTrace(L"Cannot assign process %i to a job\n", pi.dwProcessId); + DisplayErrorMessage(); + } + } + } + +#define SIGINT_EVENT (WAIT_OBJECT_0 + 0) +#define EXIT_EVENT (WAIT_OBJECT_0 + 1) +#define SIGTERM_EVENT (WAIT_OBJECT_0 + 2) +#define SIGKILL_EVENT (WAIT_OBJECT_0 + 3) +#define CTRLC_EVENT (WAIT_OBJECT_0 + 4) + while (!exitProc) { + // Wait for the spawned-process to die or for the event + // indicating that the processes should be forcibly killed. + DWORD event = WaitForMultipleObjects(5, h, FALSE, INFINITE); + switch (event) { + case SIGINT_EVENT: + case CTRLC_EVENT: + if (isTraceEnabled(CDT_TRACE_SPAWNER)) { + cdtTrace(L"starter (PID %i) received CTRL-C event\n", GetCurrentProcessId()); + } + if (event == SIGINT_EVENT) { + raiseSignal(h[1], pi.dwProcessId, L"SIGINT"); + } else { + GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0); + } + + SetEvent(waitEvent); + break; + + case EXIT_EVENT: // App terminated normally + // Make it's exit code our exit code + if (isTraceEnabled(CDT_TRACE_SPAWNER)) { + cdtTrace(L"starter: launched process has been terminated(PID %i)\n", pi.dwProcessId); + } + GetExitCodeProcess(pi.hProcess, &dwExitCode); + exitProc = TRUE; + break; + + case SIGTERM_EVENT: + if (isTraceEnabled(CDT_TRACE_SPAWNER)) { + cdtTrace(L"starter received TERM event (PID %i)\n", GetCurrentProcessId()); + } + + raiseSignal(h[1], pi.dwProcessId, L"TERM"); + SetEvent(waitEvent); + + // Note that we keep trucking until the child process terminates (case EXIT_EVENT) + break; + + case SIGKILL_EVENT: + if (isTraceEnabled(CDT_TRACE_SPAWNER)) { + cdtTrace(L"starter received KILL event (PID %i)\n", GetCurrentProcessId()); + } + + raiseSignal(h[1], pi.dwProcessId, L"KILL"); + SetEvent(waitEvent); + + if (hJob && !TerminateJobObject(hJob, (DWORD)-1)) { + if (isTraceEnabled(CDT_TRACE_SPAWNER)) { + cdtTrace(L"Cannot terminate job\n"); + DisplayErrorMessage(); + } + } + + // Note that we keep trucking until the child process terminates (case EXIT_EVENT) + break; + + default: + // Unexpected code + if (isTraceEnabled(CDT_TRACE_SPAWNER)) { + DisplayErrorMessage(); + } + exitProc = TRUE; + break; + } + } + } else if (isTraceEnabled(CDT_TRACE_SPAWNER)) { + cdtTrace(L"Cannot start: %s\n", cmdLine); + free(cmdLine); + + DisplayErrorMessage(); + } + + CloseHandle(waitEvent); + CLOSE_HANDLES(h); + + return dwExitCode; +} + +void DisplayErrorMessage() { + wchar_t *lpMsgBuf = formatWinErrorCode(GetLastError()); + OutputDebugStringW(lpMsgBuf); + // Free the buffer. + 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 new file mode 100644 index 00000000000..13041c39be6 --- /dev/null +++ b/core/org.eclipse.cdt.core.native/native_src/win/util.c @@ -0,0 +1,189 @@ +/******************************************************************************* + * Copyright (c) 2020 Torbjörn Svensson 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: + * Torbjörn Svensson - initial API and implementation + *******************************************************************************/ + +#include "util.h" + +#include <stdio.h> +#include <tchar.h> + +static bool spawner = false; +static bool spawnerDetails = false; +static bool spawnerStarter = false; +static bool readReport = false; + +void enableTraceFor(const TraceKind_t traceKind) { + switch (traceKind) { + case CDT_TRACE_SPAWNER: + spawner = true; + break; + case CDT_TRACE_SPAWNER_DETAILS: + spawnerDetails = true; + break; + case CDT_TRACE_SPAWNER_STARTER: + spawnerStarter = true; + break; + case CDT_TRACE_SPAWNER_READ_REPORT: + readReport = true; + break; + default: + cdtTrace(L"%S: Invalid trace kind supplied: %d\n", __func__, traceKind); + break; + } +} + +bool isTraceEnabled(const TraceKind_t traceKind) { + switch (traceKind) { + case CDT_TRACE_SPAWNER: + return spawner; + case CDT_TRACE_SPAWNER_DETAILS: + return spawnerDetails; + case CDT_TRACE_SPAWNER_STARTER: + return spawnerStarter; + case CDT_TRACE_SPAWNER_READ_REPORT: + return readReport; + default: + cdtTrace(L"%S: Invalid trace kind supplied: %d\n", __func__, traceKind); + return false; + } +} + +void cdtTrace(const wchar_t *fmt, ...) { + va_list ap; + wchar_t *buffer = NULL; + int size = 0; + + va_start(ap, fmt); + + do { + // Free previous buffer + free(buffer); + + // Allocate a slightly larger buffer + size += 256; + buffer = (wchar_t *)malloc(size * sizeof(wchar_t)); + + if (!buffer) { + // malloc failed + OutputDebugStringW(L"Failed to allocate buffer to format message into.\n"); + va_end(ap); + return; + } + } while (-1 == vswprintf(buffer, size, fmt, ap) && errno == ERANGE); + va_end(ap); + + // Send the output + OutputDebugStringW(buffer); + + // Clean up + free(buffer); +} + +int copyTo(wchar_t *target, const wchar_t *source, int cpyLength, int availSpace) { + bool bSlash = false; + int i = 0, j = 0; + + enum { QUOTATION_DO, QUOTATION_DONE, QUOTATION_NONE } nQuotationMode = QUOTATION_DO; + + if (availSpace <= cpyLength) { // = to reserve space for final '\0' + return -1; + } + + if ((_T('\"') == *source) && (_T('\"') == *(source + cpyLength - 1))) { + nQuotationMode = QUOTATION_DONE; + } else if (wcschr(source, _T(' '))) { + // Needs to be quoted + nQuotationMode = QUOTATION_DO; + if (target) { + *target = _T('\"'); + } + ++j; + } else { + // No reason to quote term because it doesn't have embedded spaces + nQuotationMode = QUOTATION_NONE; + } + + for (; i < cpyLength; ++i, ++j) { + if (source[i] == _T('\\')) { + bSlash = true; + } else { + // Don't escape embracing quotation marks + if ((source[i] == _T('\"')) && + !((nQuotationMode == QUOTATION_DONE) && ((i == 0) || (i == (cpyLength - 1))))) { + if (!bSlash) { // If still not escaped + if (j == availSpace) { + return -1; + } + target[j] = _T('\\'); + ++j; + } + } + bSlash = false; + } + + if (j == availSpace) { + return -1; + } + if (target) { + target[j] = source[i]; + } + } + + if (nQuotationMode == QUOTATION_DO) { + if (j == availSpace) { + return -1; + } + if (target) { + target[j] = _T('\"'); + } + ++j; + } + + 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 new file mode 100644 index 00000000000..1fa1ffd4ffb --- /dev/null +++ b/core/org.eclipse.cdt.core.native/native_src/win/util.h @@ -0,0 +1,54 @@ +/******************************************************************************* + * Copyright (c) 2020 Torbjörn Svensson 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: + * Torbjörn Svensson - initial API and implementation + *******************************************************************************/ + +#ifndef UTIL_H +#define UTIL_H + +#include <stdbool.h> +#include <windows.h> + +typedef enum { + CDT_TRACE_SPAWNER, + CDT_TRACE_SPAWNER_DETAILS, + CDT_TRACE_SPAWNER_STARTER, + CDT_TRACE_SPAWNER_READ_REPORT +} TraceKind_t; +static const TraceKind_t ALL_TRACE_KINDS[] = {CDT_TRACE_SPAWNER, CDT_TRACE_SPAWNER_DETAILS, CDT_TRACE_SPAWNER_STARTER, + CDT_TRACE_SPAWNER_READ_REPORT}; + +void enableTraceFor(const TraceKind_t traceKind); +bool isTraceEnabled(const TraceKind_t traceKind); +void cdtTrace(const wchar_t *fmt, ...); + +#define BUILD_PIPE_NAME(pipe, name, pid, counter) \ + do { \ + swprintf(pipe, sizeof(pipe) / sizeof(pipe[0]), L"\\\\.\\pipe\\%s%08i%010i", name, pid, counter); \ + } while (0) + +#define CLOSE_HANDLES(handles) \ + do { \ + for (int i = 0; i < sizeof(handles) / sizeof(handles[0]); i++) { \ + if (INVALID_HANDLE_VALUE != handles[i]) { \ + CloseHandle(handles[i]); \ + handles[i] = INVALID_HANDLE_VALUE; \ + } \ + } \ + } while (0) + +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/plugin.properties b/core/org.eclipse.cdt.core.native/plugin.properties index 1e8e0166d60..b78918fe964 100755..100644 --- a/core/org.eclipse.cdt.core.native/plugin.properties +++ b/core/org.eclipse.cdt.core.native/plugin.properties @@ -21,6 +21,7 @@ WindowsRegistry.name=Windows Registry fragmentName.linux = C/C++ Development Tools Core Native Utilities for Linux fragmentName.linux.ppc64le = C/C++ Development Tools Core Native Utilities for Linux (ppc64le) fragmentName.linux.x86_64 = C/C++ Development Tools Core Native Utilities for Linux (x86_64) +fragmentName.linux.aarch64 = C/C++ Development Tools Core Native Utilities for Linux (aarch64) fragmentName.win32 = C/C++ Development Tools Core Native Utilities for Windows fragmentName.win32.x86_64 = C/C++ Development Tools Core Native Utilities for Windows (x86_64) fragmentName.macosx = C/C++ Development Tools Core Native Utilities for MacOS X diff --git a/core/org.eclipse.cdt.core.native/pom.xml b/core/org.eclipse.cdt.core.native/pom.xml new file mode 100644 index 00000000000..e682bb34f5d --- /dev/null +++ b/core/org.eclipse.cdt.core.native/pom.xml @@ -0,0 +1,163 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 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 + https://www.eclipse.org/legal/epl-2.0/ + + SPDX-License-Identifier: EPL-2.0 + + Contributors: + Mat Booth (Red Hat) - initial implementation +--> +<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"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.eclipse.cdt</groupId> + <artifactId>cdt-parent</artifactId> + <version>10.7.0-SNAPSHOT</version> + <relativePath>../../pom.xml</relativePath> + </parent> + + <version>6.2.200-SNAPSHOT</version> + <artifactId>org.eclipse.cdt.core.native</artifactId> + <packaging>eclipse-plugin</packaging> + + <profiles> + <profile> + <id>build-native.all</id> + <activation> + <property> + <name>native</name> + <value>all</value> + </property> + </activation> + <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="rebuild" /> + </exec> + </target> + </configuration> + <goals> + <goal>run</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + <profile> + <id>build-native.docker</id> + <activation> + <property> + <name>native</name> + <value>docker</value> + </property> + </activation> + <build> + <plugins> + <plugin> + <artifactId>maven-antrun-plugin</artifactId> + <executions> + <execution> + <id>natives</id> + <phase>process-resources</phase> + <configuration> + <target> + <exec executable="docker" newenvironment="false" failOnError="true"> + <!-- docker run -\-rm -t -v $(git rev-parse -\-show-toplevel):/work -w /work/$(git rev-parse -\-show-prefix) quay.io/eclipse-cdt/cdt-infra-eclipse-full:latest make -C native_src rebuild --> + <arg value="run" /> + <arg value="--rm" /> + <arg value="-t" /> + <arg value="-v" /> + <arg value="${project.basedir}/../..:/work" /> + <arg value="-w" /> + <arg value="/work/core/org.eclipse.cdt.core.native" /> + <arg value="quay.io/eclipse-cdt/cdt-infra-eclipse-full:latest" /> + <arg value="make" /> + <arg value="-C" /> + <arg value="native_src" /> + <arg value="rebuild" /> + </exec> + </target> + </configuration> + <goals> + <goal>run</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + <profile> + <id>jniheaders</id> + <build> + <plugins> + <plugin> + <artifactId>maven-compiler-plugin</artifactId> + <version>3.8.1</version> + <executions> + <execution> + <id>headers</id> + <phase>process-resources</phase> + <configuration> + <compilerArgs> + <arg>-h</arg> + <arg>${project.basedir}/native_src/include</arg> + </compilerArgs> + <source>11</source> + <target>11</target> + <encoding>UTF-8</encoding> + </configuration> + <goals> + <goal>compile</goal> + </goals> + </execution> + </executions> + </plugin> + </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/internal/core/natives/Messages.java b/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/internal/core/natives/Messages.java index 5874288e568..b72519e70cb 100644 --- a/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/internal/core/natives/Messages.java +++ b/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/internal/core/natives/Messages.java @@ -16,6 +16,8 @@ package org.eclipse.cdt.internal.core.natives; import org.eclipse.osgi.util.NLS; public class Messages extends NLS { + public static String PTY_FailedToStartConPTY; + public static String PTY_NoClassDefFoundError; public static String Util_exception_cannotCreatePty; public static String Util_exception_cannotSetTerminalSize; public static String Util_error_cannotRun; diff --git a/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/internal/core/natives/Messages.properties b/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/internal/core/natives/Messages.properties index 9eb988affc0..8e91c7b37f8 100644 --- a/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/internal/core/natives/Messages.properties +++ b/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/internal/core/natives/Messages.properties @@ -13,6 +13,8 @@ # Martin Oberhuber (Wind River) - [303083] Split from CCorePluginResources.properties ############################################################################### +PTY_FailedToStartConPTY=Failed start a new style ConPTY. This is expected on Windows machines before Windows 10 1904 version and will fall back to WinPTY. Please consider upgrading to a newer version of Windows 10 to take advantage of the new improved console behavior. +PTY_NoClassDefFoundError=Failed start a new style ConPTY due to NoClassDefFoundError which probably means that the optional dependency on JNA is not available. Consider updating your product to include JNA to enable the ConPTY. Util_exception_cannotCreatePty=Cannot create pty Util_exception_closeError=close error Util_exception_cannotSetTerminalSize=Setting terminal size is not supported diff --git a/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/WindowsArgumentQuoter.java b/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/WindowsArgumentQuoter.java new file mode 100644 index 00000000000..fcfda8ed670 --- /dev/null +++ b/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/WindowsArgumentQuoter.java @@ -0,0 +1,75 @@ +/******************************************************************************* + * 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.utils; + +import java.util.regex.Pattern; + +/** + * Implementation of proper Windows quoting based on blog post: + * https://docs.microsoft.com/en-ca/archive/blogs/twistylittlepassagesallalike/everyone-quotes-command-line-arguments-the-wrong-way + * + * @noreference This class is not intended to be referenced by clients. + */ +public class WindowsArgumentQuoter { + + public static String quoteArgv(String[] cmdarray, boolean force) { + StringBuilder quoted = new StringBuilder(); + for (String arg : cmdarray) { + quoteArg(arg, quoted, force); + quoted.append(' '); + } + quoted.deleteCharAt(quoted.length() - 1); + return quoted.toString(); + } + + private static Pattern spaces = Pattern.compile(".*\\s.*"); //$NON-NLS-1$ + + private static void quoteArg(String arg, StringBuilder quoted, boolean force) { + + // Unless we're told otherwise, don't quote unless we actually + // need to do so --- hopefully avoid problems if programs won't + // parse quotes properly + + if (!force && !arg.isEmpty() && !spaces.matcher(arg).matches()) { + quoted.append(arg); + } else { + quoted.append('"'); + for (int i = 0; i < arg.length(); i++) { + int numberBackslashes = 0; + + while (i < arg.length() && arg.charAt(i) == '\\') { + i++; + numberBackslashes++; + } + + if (i == arg.length()) { + // Escape all backslashes, but let the terminating + // double quotation mark we add below be interpreted + // as a metacharacter. + quoted.append("\\".repeat(numberBackslashes * 2)); //$NON-NLS-1$ + break; + } else if (arg.charAt(i) == '"') { + + // Escape all backslashes and the following + // double quotation mark. + quoted.append("\\".repeat(numberBackslashes)); //$NON-NLS-1$ + quoted.append('"'); + } else { + // Backslashes aren't special here. + quoted.append("\\".repeat(numberBackslashes)); //$NON-NLS-1$ + quoted.append(arg.charAt(i)); + } + } + quoted.append('"'); + } + } + +} diff --git a/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/WindowsRegistry.java b/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/WindowsRegistry.java index f2054512232..27dbe96fa4c 100644 --- a/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/WindowsRegistry.java +++ b/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/WindowsRegistry.java @@ -13,8 +13,11 @@ *******************************************************************************/ package org.eclipse.cdt.utils; +import java.util.Map; + import org.eclipse.cdt.internal.core.natives.CNativePlugin; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.Platform; /** * @author DSchaefer @@ -31,14 +34,19 @@ public abstract class WindowsRegistry { } public static WindowsRegistry getRegistry() { - if (registry == null) { - try { - registry = CNativePlugin.getDefault().getWindowsRegistry(); - } catch (CoreException e) { + if (Platform.getOS().equals(Platform.OS_WIN32)) { + if (registry == null) { + try { + registry = CNativePlugin.getDefault().getWindowsRegistry(); + } catch (CoreException e) { + CNativePlugin.log("Failed to load WindowsRegistry", e); //$NON-NLS-1$ + } } + return registry; + } else { + return null; } - return registry; } /** @@ -52,6 +60,15 @@ public abstract class WindowsRegistry { public abstract String getLocalMachineValue(String subkey, String name); /** + * Given a subkey of HKEY_LOCAL_MACHINE, return the map of valueName =gt; value. + * The return value is an empty map on error or when the subkey does not exist. + * @param subkey subkey of HKEY_LOCAL_MACHINE + * @return valueName => value map of the entries in subkey + * @since 6.1 + */ + public abstract Map<String, Object> getLocalMachineValues(String subkey); + + /** * Given a subkey of HKEY_LOCAL_MACHINE, and an index (starting from 0) * to the key's array of values, return the name of the indexed value. * The return value is null on any error or when the index is invalid. @@ -69,7 +86,7 @@ public abstract class WindowsRegistry { * The return value is null on any error or when the index is invalid. * The key name can be used in the above getLocalMachineValueName() * to retrieve value names. - * @param subkey subkey of HKEY_CURRENT_USER + * @param subkey subkey of HKEY_LOCAL_MACHINE * @param index index to the subkey's array of values, starting from 0. * @return name of registry value or null if not found */ @@ -86,6 +103,15 @@ public abstract class WindowsRegistry { public abstract String getCurrentUserValue(String subkey, String name); /** + * Given a subkey of HKEY_CURRENT_USER, return the map of valueName => value. + * The return value is an empty map on error or when the subkey does not exist. + * @param subkey subkey of HKEY_CURRENT_USER + * @return valueName => value map of the entries in subkey + * @since 6.1 + */ + public abstract Map<String, Object> getCurrentUserValues(String subkey); + + /** * Given a subkey of HKEY_CURRENT_USER, and an index (starting from 0) * to the key's array of values, return the name of the indexed value. * The return value is null on any error or when the index is invalid. diff --git a/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/pty/ConPTY.java b/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/pty/ConPTY.java new file mode 100644 index 00000000000..22f2e4c738d --- /dev/null +++ b/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/pty/ConPTY.java @@ -0,0 +1,357 @@ +/******************************************************************************* + * 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.utils.pty; + +import static com.sun.jna.platform.win32.WinBase.CREATE_UNICODE_ENVIRONMENT; +import static com.sun.jna.platform.win32.WinBase.EXTENDED_STARTUPINFO_PRESENT; +import static com.sun.jna.platform.win32.WinBase.INFINITE; +import static com.sun.jna.platform.win32.WinBase.STARTF_USESTDHANDLES; +import static com.sun.jna.platform.win32.WinBase.WAIT_OBJECT_0; +import static com.sun.jna.platform.win32.WinError.S_OK; +import static com.sun.jna.platform.win32.WinNT.PROCESS_QUERY_INFORMATION; +import static com.sun.jna.platform.win32.WinNT.SYNCHRONIZE; +import static org.eclipse.cdt.utils.pty.ConPTYKernel32.PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.nio.charset.StandardCharsets; + +import org.eclipse.cdt.utils.WindowsArgumentQuoter; + +import com.sun.jna.Memory; +import com.sun.jna.Native; +import com.sun.jna.Pointer; +import com.sun.jna.platform.win32.BaseTSD.DWORD_PTR; +import com.sun.jna.platform.win32.BaseTSD.SIZE_T; +import com.sun.jna.platform.win32.Kernel32; +import com.sun.jna.platform.win32.Kernel32Util; +import com.sun.jna.platform.win32.WinBase; +import com.sun.jna.platform.win32.WinBase.PROCESS_INFORMATION; +import com.sun.jna.platform.win32.WinDef; +import com.sun.jna.platform.win32.WinDef.DWORD; +import com.sun.jna.platform.win32.WinDef.PVOID; +import com.sun.jna.platform.win32.WinError; +import com.sun.jna.platform.win32.WinNT; +import com.sun.jna.platform.win32.WinNT.HANDLE; +import com.sun.jna.platform.win32.WinNT.HANDLEByReference; +import com.sun.jna.platform.win32.WinNT.HRESULT; +import com.sun.jna.ptr.IntByReference; + +/** + * A JNA implementation for ConPTY to provide a Windows native (as opposed to WinPTY) + * implementation of a PTY. + * + * This class should be accessed/created via the PTY class which will use ConPTY when it + * is available. + * + * @noreference This class is not intended to be referenced by clients. + */ +public class ConPTY { + + private Handles handles = new Handles(); + + /** + * The handles that need to be closed when the PTY is done + */ + private static class Handles { + private HANDLEByReference pseudoConsole; + private ConPTYKernel32.STARTUPINFOEX startupInfo; + private Memory threadAttributeListMemory; + private WinBase.PROCESS_INFORMATION processInformation; + private HANDLEByReference pipeOut; + private HANDLEByReference pipeIn; + + /** Saved for convenience to make it easier to identify/find the process in process explorer */ + public int pid; + } + + /** + * Create a new Windows Pseudo Console (ConPTY) that an application can be attached to. + */ + public ConPTY() throws IOException { + handles.pseudoConsole = new HANDLEByReference(); + handles.pipeIn = new HANDLEByReference(); + handles.pipeOut = new HANDLEByReference(); + + var phPipePTYIn = new WinNT.HANDLEByReference(); + var phPipePTYOut = new WinNT.HANDLEByReference(); + + boolean res; + res = ConPTYKernel32.INSTANCE.CreatePipe(phPipePTYIn, handles.pipeOut, null, 0); + checkErr(res, "CreatePipe"); //$NON-NLS-1$ + + res = ConPTYKernel32.INSTANCE.CreatePipe(handles.pipeIn, phPipePTYOut, null, 0); + checkErr(res, "CreatePipe"); //$NON-NLS-1$ + + // The console will be resized later with ResizePseudoConsole, start with the old classic size! + var consoleSize = new ConPTYKernel32.COORD_ByValue(); + consoleSize.X = (short) 80; + consoleSize.Y = (short) 24; + + var hr = ConPTYKernel32.INSTANCE.CreatePseudoConsole(consoleSize, phPipePTYIn.getValue(), + phPipePTYOut.getValue(), new WinDef.DWORD(0), handles.pseudoConsole); + checkErr(hr, "CreatePseudoConsole"); //$NON-NLS-1$ + + res = ConPTYKernel32.INSTANCE.CloseHandle(phPipePTYOut.getValue()); + checkErr(res, "CloseHandle"); //$NON-NLS-1$ + res = ConPTYKernel32.INSTANCE.CloseHandle(phPipePTYIn.getValue()); + checkErr(res, "CloseHandle"); //$NON-NLS-1$ + } + + /** + * Executes the given process in the PTY + * + * @param cmdarray Command and arguments that will be quotes using standard Windows rules to make a + * command line. See {@link WindowsArgumentQuoter} + * @param envp + * @param dir + * @return the PID + * @throws IOException + */ + public int exec(String[] cmdarray, String[] envp, String dir) throws IOException { + String quoted = WindowsArgumentQuoter.quoteArgv(cmdarray, false); + handles.startupInfo = new ConPTYKernel32.STARTUPINFOEX(); + handles.threadAttributeListMemory = PrepareStartupInformation(handles.startupInfo, handles.pseudoConsole); + handles.processInformation = new PROCESS_INFORMATION(); + + var status = ConPTYKernel32.INSTANCE.CreateProcess(null, quoted, null, null, false, + new DWORD(CREATE_UNICODE_ENVIRONMENT | EXTENDED_STARTUPINFO_PRESENT), toByteArray(envp), dir, + handles.startupInfo, handles.processInformation); + checkErr(status, "CreateProcess"); //$NON-NLS-1$ + return getPID(); + } + + /** + * Convert envp to a byte array, encoding UTF_16LE. Remember to pass CREATE_UNICODE_ENVIRONMENT + * to CreateProcess + */ + public static Memory toByteArray(String[] envp) throws IOException { + if (envp == null) { + return null; + } + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + for (String string : envp) { + bos.write(string.getBytes(StandardCharsets.UTF_16LE)); + // Terminate each variable with two zero bytes + bos.write(0); + bos.write(0); + } + // Terminate the whole block with two additional zero bytes + bos.write(0); + bos.write(0); + byte[] byteArray = bos.toByteArray(); + Memory memory = new Memory(byteArray.length); + memory.write(0, byteArray, 0, byteArray.length); + return memory; + + } + + public int getPID() { + handles.pid = handles.processInformation.dwProcessId.intValue(); + return handles.pid; + } + + private static Memory PrepareStartupInformation(ConPTYKernel32.STARTUPINFOEX pStartupInfo, HANDLEByReference phPC) + throws IOException { + pStartupInfo.StartupInfo.cb = new DWORD(pStartupInfo.size()); + + pStartupInfo.StartupInfo.hStdOutput = new HANDLE(); + pStartupInfo.StartupInfo.hStdError = new HANDLE(); + pStartupInfo.StartupInfo.hStdInput = new HANDLE(); + pStartupInfo.StartupInfo.dwFlags = STARTF_USESTDHANDLES; + + boolean res; + + var attrListSize = new ConPTYKernel32.SIZE_TByReference(); + res = ConPTYKernel32.INSTANCE.InitializeProcThreadAttributeList(Pointer.NULL, new DWORD(1), new DWORD(0), + attrListSize); + Kernel32.INSTANCE.SetLastError(0); + var memory = new Memory(attrListSize.getValue().longValue()); + + res = ConPTYKernel32.INSTANCE.InitializeProcThreadAttributeList(memory, new DWORD(1), new DWORD(0), + attrListSize); + checkErr(res, "InitializeProcThreadAttributeList"); //$NON-NLS-1$ + + var dwPROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE = new DWORD_PTR(PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE); + + res = ConPTYKernel32.INSTANCE.UpdateProcThreadAttribute(memory, new DWORD(0), + dwPROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE, new PVOID(phPC.getValue().getPointer()), + new SIZE_T(Native.POINTER_SIZE), null, null); + checkErr(res, "UpdateProcThreadAttribute"); //$NON-NLS-1$ + + pStartupInfo.lpAttributeList = memory.share(0); + return memory; + } + + /** + * Implements the contract of {@link Process#waitFor()}. This is used by {@link PTY#waitFor(org.eclipse.cdt.utils.spawner.Spawner, int)}, + * but in the Spawner case the PID is passed around unnecessarily. This method therefore waits for the process it created only, + * like how Process#waitFor() behaves. + * + * @see Process#waitFor() + * @see PTY#waitFor(org.eclipse.cdt.utils.spawner.Spawner, int) + */ + public int waitFor() { + try { + int what = 0; + HANDLE hProc; + + hProc = Kernel32.INSTANCE.OpenProcess(SYNCHRONIZE | PROCESS_QUERY_INFORMATION, false, getPID()); + checkErr(hProc, "OpenProcess"); //$NON-NLS-1$ + + what = Kernel32.INSTANCE.WaitForSingleObject(hProc, INFINITE); + + IntByReference exit_code = new IntByReference(0); + if (what == WAIT_OBJECT_0) { + Kernel32.INSTANCE.GetExitCodeProcess(hProc, exit_code); + } + + boolean closeHandle = Kernel32.INSTANCE.CloseHandle(hProc); + checkErr(closeHandle, "CloseHandle"); //$NON-NLS-1$ + return exit_code.getValue(); + } catch (IOException e) { + // Returning -1 is the equivalent of what was done + // in error handling in the JNI versions of waitFor + return -1; + } + } + + /** + * Closes the entire PTY session. This will have the side effect of closing all the IO + * channels at once. The process will also be terminated when the console is closed if + * it isn't closed already. If the console's host (conhost) is closed then the process + * won't be automatically terminated. This happens if conhost crashes and the behaviour + * with winpty is the same in that case. + */ + public synchronized void close() throws IOException { + if (handles == null) { + return; + } + boolean res; + + res = ConPTYKernel32.INSTANCE.CloseHandle(handles.processInformation.hThread); + checkErr(res, "CloseHandle processInformation.hThread"); //$NON-NLS-1$ + + res = ConPTYKernel32.INSTANCE.CloseHandle(handles.processInformation.hProcess); + checkErr(res, "CloseHandle processInformation.hProcess"); //$NON-NLS-1$ + + ConPTYKernel32.INSTANCE.DeleteProcThreadAttributeList(handles.startupInfo.lpAttributeList); + handles.threadAttributeListMemory.clear(); + + ConPTYKernel32.INSTANCE.ClosePseudoConsole(handles.pseudoConsole.getValue()); + + res = ConPTYKernel32.INSTANCE.CancelIoEx(handles.pipeIn.getValue(), Pointer.NULL); + int err = Native.getLastError(); + if (err != WinError.ERROR_NOT_FOUND) { + checkErr(res, "CancelIoEx"); //$NON-NLS-1$ + } + + res = ConPTYKernel32.INSTANCE.CloseHandle(handles.pipeOut.getValue()); + checkErr(res, "CloseHandle pipeOut"); //$NON-NLS-1$ + + res = ConPTYKernel32.INSTANCE.CloseHandle(handles.pipeIn.getValue()); + checkErr(res, "CloseHandle pipeIn"); //$NON-NLS-1$ + + handles = null; + } + + /** + * Implements contract of {@link InputStream#read(byte[])} + * @see InputStream#read(byte[]) + */ + public int read(byte[] buf) throws IOException { + if (handles == null) { + throw new IOException("ConPTY is closed."); //$NON-NLS-1$ + } + + var pipe = handles.pipeIn; + + IntByReference dwBytesRead = new IntByReference(0); + boolean fRead = false; + + fRead = Kernel32.INSTANCE.ReadFile(pipe.getValue(), buf, buf.length, dwBytesRead, null); + checkErr(fRead, "ReadFile"); //$NON-NLS-1$ + int value = dwBytesRead.getValue(); + if (value == 0) { + // We are at EOF because we are doing Synchronous and non-overlapped operation + // Implementation note: I don't know how to get this with terminal programs, so + // I have not seen this happen in development. + return -1; + } + return value; + } + + /** + * Implements the contract of {@link OutputStream#write(byte[])} + * @see OutputStream#write(byte[]) + */ + public void write(byte[] buf) throws IOException { + if (handles == null) { + throw new IOException("ConPTY is closed."); //$NON-NLS-1$ + } + IntByReference dwBytesWritten = new IntByReference(0); + boolean fWritten = false; + fWritten = Kernel32.INSTANCE.WriteFile(handles.pipeOut.getValue(), buf, buf.length, dwBytesWritten, null); + checkErr(fWritten, "WriteFile"); //$NON-NLS-1$ + } + + /** + * Implements the contract of {@link PTY#setTerminalSize(int, int)}, but throws exceptions + * that PTY logs. + * @see PTY#setTerminalSize(int, int) + */ + public void setTerminalSize(int width, int height) throws IOException { + if (handles == null) { + throw new IOException("ConPTY is closed."); //$NON-NLS-1$ + } + + var consoleSize = new ConPTYKernel32.COORD_ByValue(); + consoleSize.X = (short) width; + consoleSize.Y = (short) height; + + HRESULT result = ConPTYKernel32.INSTANCE.ResizePseudoConsole(handles.pseudoConsole.getValue(), consoleSize); + checkErr(result, "ResizePseudoConsole"); //$NON-NLS-1$ + + } + + /** + * Throw an IOException if hr is not S_OK. + */ + private static void checkErr(WinNT.HRESULT hr, String method) throws IOException { + if (!S_OK.equals(hr)) { + String msg = Kernel32Util.getLastErrorMessage(); + throw new IOException(String.format("%s: %s", method, msg)); //$NON-NLS-1$ + } + } + + /** + * Throw an IOException if status is false. + */ + private static void checkErr(boolean status, String method) throws IOException { + if (!status) { + int lastError = Native.getLastError(); + String msg = Kernel32Util.formatMessage(lastError); + throw new IOException(String.format("%s: %s: %s", method, lastError, msg)); //$NON-NLS-1$ + } + } + + /** + * Throw an IOException if handle is null. + */ + private static void checkErr(HANDLE handle, String method) throws IOException { + if (handle == null) { + String msg = Kernel32Util.getLastErrorMessage(); + throw new IOException(String.format("%s: %s", method, msg)); //$NON-NLS-1$ + } + } +} diff --git a/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/pty/ConPTYInputStream.java b/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/pty/ConPTYInputStream.java new file mode 100644 index 00000000000..3274ec5d40c --- /dev/null +++ b/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/pty/ConPTYInputStream.java @@ -0,0 +1,67 @@ +/******************************************************************************* + * 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.utils.pty; + +import java.io.IOException; +import java.io.InputStream; + +/** + * @noreference This class is not intended to be referenced by clients. + */ +public class ConPTYInputStream extends PTYInputStream { + + private ConPTY conPty; + + public ConPTYInputStream(ConPTY conPty) { + super(null); + this.conPty = conPty; + } + + /** + * @see InputStream#read(byte[], int, int) + */ + @Override + public int read(byte[] buf, int off, int len) throws IOException { + if (buf == null) { + throw new NullPointerException(); + } else if ((off < 0) || (off > buf.length) || (len < 0) || ((off + len) > buf.length) || ((off + len) < 0)) { + throw new IndexOutOfBoundsException(); + } else if (len == 0) { + return 0; + } + byte[] tmpBuf = new byte[len]; + + len = conPty.read(tmpBuf); + if (len <= 0) + return -1; + + System.arraycopy(tmpBuf, 0, buf, off, len); + return len; + } + + /** + * Close the Reader + * @exception IOException on error. + */ + @Override + public void close() throws IOException { + if (conPty == null) { + return; + } + try { + conPty.close(); + } finally { + conPty = null; + } + + } + +} diff --git a/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/pty/ConPTYKernel32.java b/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/pty/ConPTYKernel32.java new file mode 100644 index 00000000000..bbcdb2db25a --- /dev/null +++ b/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/pty/ConPTYKernel32.java @@ -0,0 +1,69 @@ +/******************************************************************************* + * 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.utils.pty; + +import com.sun.jna.Native; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import com.sun.jna.platform.win32.Kernel32; + +/** + * This class is an extension of JNA and everything here needs to be contributed back + * to JNA. This class was written against JNA 5.6 + * + * @noreference This interface is not intended to be referenced by clients. + * @noimplement This interface is not intended to be implemented by clients. + * @noextend This interface is not intended to be extended by clients. + */ +public interface ConPTYKernel32 extends Kernel32 { + ConPTYKernel32 INSTANCE = Native.load("kernel32", ConPTYKernel32.class, //$NON-NLS-1$ + com.sun.jna.win32.W32APIOptions.DEFAULT_OPTIONS); + + int PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE = 0x00020016; + + class SIZE_TByReference extends ULONG_PTRByReference { + @Override + public SIZE_T getValue() { + return new SIZE_T(super.getValue().longValue()); + } + } + + boolean CancelIoEx(HANDLE hFile, Pointer lpOverlapped); + + public static class COORD_ByValue extends COORD implements Structure.ByValue { + } + + @Structure.FieldOrder({ "StartupInfo", "lpAttributeList" }) + class STARTUPINFOEX extends Structure { + public STARTUPINFO StartupInfo; + public Pointer lpAttributeList; + } + + HRESULT CreatePseudoConsole(COORD.ByValue size, HANDLE hInput, HANDLE hOutput, DWORD dwFlags, + HANDLEByReference phPC); + + HRESULT ResizePseudoConsole(HANDLE hPC, COORD.ByValue size); + + void ClosePseudoConsole(HANDLE hPC); + + boolean InitializeProcThreadAttributeList(Pointer lpAttributeList, DWORD dwAttributeCount, DWORD dwFlags, + SIZE_TByReference lpSize); + + boolean UpdateProcThreadAttribute(Pointer lpAttributeList, DWORD dwFlags, DWORD_PTR Attribute, PVOID lpValue, + SIZE_T cbSize, PVOID lpPreviousValue, SIZE_TByReference lpReturnSize); + + void DeleteProcThreadAttributeList(Pointer lpAttributeList); + + boolean CreateProcess(String lpApplicationName, String lpCommandLine, SECURITY_ATTRIBUTES lpProcessAttributes, + SECURITY_ATTRIBUTES lpThreadAttributes, boolean bInheritHandles, DWORD dwCreationFlags, + Pointer lpEnvironment, String lpCurrentDirectory, STARTUPINFOEX lpStartupInfo, + PROCESS_INFORMATION lpProcessInformation); +}
\ No newline at end of file diff --git a/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/pty/ConPTYOutputStream.java b/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/pty/ConPTYOutputStream.java new file mode 100644 index 00000000000..5d6239d161f --- /dev/null +++ b/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/pty/ConPTYOutputStream.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * 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.utils.pty; + +import java.io.IOException; + +/** + * @noreference This class is not intended to be referenced by clients. + */ +public class ConPTYOutputStream extends PTYOutputStream { + private ConPTY conPty; + + public ConPTYOutputStream(ConPTY conPty) { + super(null, false); + this.conPty = conPty; + } + + @Override + public void write(byte[] b, int off, int len) throws IOException { + if (b == null) { + throw new NullPointerException(); + } else if ((off < 0) || (off > b.length) || (len < 0) || ((off + len) > b.length) || ((off + len) < 0)) { + throw new IndexOutOfBoundsException(); + } else if (len == 0) { + return; + } + byte[] tmpBuf = new byte[len]; + System.arraycopy(b, off, tmpBuf, 0, len); + conPty.write(tmpBuf); + } + + @Override + public void close() throws IOException { + if (conPty == null) { + return; + } + try { + conPty.close(); + } finally { + conPty = null; + } + } +} diff --git a/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/pty/PTY.java b/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/pty/PTY.java index a92f5a06ace..ad169aadd22 100644 --- a/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/pty/PTY.java +++ b/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/pty/PTY.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2002, 2015 QNX Software Systems and others. + * Copyright (c) 2002, 2021 QNX Software Systems and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -20,6 +20,7 @@ import java.io.IOException; import org.eclipse.cdt.internal.core.natives.CNativePlugin; import org.eclipse.cdt.internal.core.natives.Messages; import org.eclipse.cdt.utils.spawner.Spawner; +import org.eclipse.cdt.utils.spawner.Spawner.IChannel; import org.eclipse.core.runtime.Platform; /** @@ -38,20 +39,37 @@ public class PTY { TERMINAL } - final boolean console; + final Mode mode; + /** + * Unused in conPTY. + * Created, but never read in winPTY. + * Important for Posix PTY. + */ final String slave; final PTYInputStream in; final PTYOutputStream out; /** * NOTE: Field is accessed by the native layer. Do not refactor! + * This field is NOT used by ConPTY layer. */ int master; private static boolean hasPTY; + + private enum IS_CONPTY { + CONPTY_UNKNOWN, CONPTY_YES, CONPTY_NO; + } + + /** + * We don't know if we have conpty until we try - so this starts + * null and will be true or false once it is determined. + */ + private static IS_CONPTY isConPTY = IS_CONPTY.CONPTY_UNKNOWN; private static boolean isWinPTY; private static boolean isConsoleModeSupported; private static boolean setTerminalSizeErrorAlreadyLogged; + private ConPTY conPTY; /** * The master fd is used on two streams. We need to wrap the fd @@ -71,6 +89,7 @@ public class PTY { /** * @return whether PTY support for console mode is available on this platform */ + @Deprecated public static boolean isSupported() { return isSupported(Mode.CONSOLE); } @@ -85,7 +104,7 @@ public class PTY { /** * Create PTY for use with Eclipse console. - * Identical to {@link PTY#PTY(boolean) PTY(Mode.CONSOLE)}. + * Identical to <code>PTY(Mode.CONSOLE)</code>. */ public PTY() throws IOException { this(Mode.CONSOLE); @@ -113,46 +132,44 @@ public class PTY { * @since 5.6 */ public PTY(Mode mode) throws IOException { - this(mode == Mode.CONSOLE); - } - - /** - * Create pseudo terminal. - * - * <p> - * The provided flag indicates whether the pseudo terminal is used with the interactive - * Eclipse console: - * <ul> - * <li>If <code>true</code> the terminal is configured with no echo and stderr is - * redirected to a pipe instead of the PTY. This mode is not supported on windows</li> - * <li>If <code>false</code> the terminal is configured with echo and stderr is - * connected to the PTY. This mode is best suited for use with a proper terminal emulation. - * Note that this mode might not be supported on all platforms. - * Known platforms which support this mode are: - * <code>linux-x86</code>, <code>linux-x86_64</code>, <code>solaris-sparc</code>, <code>macosx</code>. - * </li> - * </ul> - * </p> - * - * @param console whether terminal is used with Eclipse console - * @throws IOException if the PTY could not be created - * @deprecated Use {@link #PTY(Mode)} instead - * @since 5.2 - */ - @Deprecated - public PTY(boolean console) throws IOException { - this.console = console; - if (console && !isConsoleModeSupported) { + this.mode = mode; + if (isConsole() && !isConsoleModeSupported) { throw new IOException(Messages.Util_exception_cannotCreatePty); } - slave = hasPTY ? openMaster(console) : null; - - if (slave == null) { - throw new IOException(Messages.Util_exception_cannotCreatePty); + PTYInputStream inInit = null; + PTYOutputStream outInit = null; + String slaveInit = null; + if (isConPTY != IS_CONPTY.CONPTY_NO) { + try { + conPTY = new ConPTY(); + isConPTY = IS_CONPTY.CONPTY_YES; + slaveInit = "conpty"; //$NON-NLS-1$ + inInit = new ConPTYInputStream(conPTY); + outInit = new ConPTYOutputStream(conPTY); + } catch (NoClassDefFoundError e) { + isConPTY = IS_CONPTY.CONPTY_NO; + CNativePlugin.log(Messages.PTY_NoClassDefFoundError, e); + } catch (Throwable e) { + isConPTY = IS_CONPTY.CONPTY_NO; + CNativePlugin.log(Messages.PTY_FailedToStartConPTY, e); + } } - in = new PTYInputStream(new MasterFD()); - out = new PTYOutputStream(new MasterFD(), !isWinPTY); + // fall through in exception case as well as normal non-conPTY + if (isConPTY == IS_CONPTY.CONPTY_NO) { + + slaveInit = hasPTY ? openMaster(isConsole()) : null; + + if (slaveInit == null) { + throw new IOException(Messages.Util_exception_cannotCreatePty); + } + + inInit = new PTYInputStream(new MasterFD()); + outInit = new PTYOutputStream(new MasterFD(), !isWinPTY); + } + slave = slaveInit; + in = inInit; + out = outInit; } /** @@ -164,8 +181,9 @@ public class PTY { public void validateSlaveName() throws IOException { // on windows the slave name is just an internal identifier // and does not represent a real device - if (isWinPTY) + if (isWinPTY) { throw new IOException("Slave name is not valid"); //$NON-NLS-1$ + } } public String getSlaveName() { @@ -182,7 +200,7 @@ public class PTY { * @since 5.2 */ public final boolean isConsole() { - return console; + return mode == Mode.CONSOLE; } public PTYOutputStream getOutputStream() { @@ -210,12 +228,17 @@ public class PTY { */ public final void setTerminalSize(int width, int height) { try { - change_window_size(master, width, height); - } catch (UnsatisfiedLinkError ule) { + if (isConPTY == IS_CONPTY.CONPTY_YES) { + conPTY.setTerminalSize(width, height); + } else { + change_window_size(master, width, height); + } + } catch (UnsatisfiedLinkError | IOException e) { if (!setTerminalSizeErrorAlreadyLogged) { setTerminalSizeErrorAlreadyLogged = true; - CNativePlugin.log(Messages.Util_exception_cannotSetTerminalSize, ule); + CNativePlugin.log(Messages.Util_exception_cannotSetTerminalSize, e); } + } } @@ -223,11 +246,14 @@ public class PTY { * @noreference This method is not intended to be referenced by clients. * @since 5.6 */ - public int exec_pty(Spawner spawner, String[] cmdarray, String[] envp, String dir, int[] chan) throws IOException { - if (isWinPTY) { - return exec2(cmdarray, envp, dir, chan, slave, master, console); + public int exec_pty(Spawner spawner, String[] cmdarray, String[] envp, String dir, IChannel[] chan) + throws IOException { + if (isConPTY == IS_CONPTY.CONPTY_YES) { + return conPTY.exec(cmdarray, envp, dir); + } else if (isWinPTY) { + return exec2(cmdarray, envp, dir, chan, slave, master, isConsole()); } else { - return spawner.exec2(cmdarray, envp, dir, chan, slave, master, console); + return spawner.exec2(cmdarray, envp, dir, chan, slave, master, isConsole()); } } @@ -236,7 +262,9 @@ public class PTY { * @since 5.6 */ public int waitFor(Spawner spawner, int pid) { - if (isWinPTY) { + if (isConPTY == IS_CONPTY.CONPTY_YES) { + return conPTY.waitFor(); + } else if (isWinPTY) { return waitFor(master, pid); } else { return spawner.waitFor(pid); @@ -250,7 +278,7 @@ public class PTY { /** * Native method when executing with a terminal emulation (winpty only). */ - native int exec2(String[] cmdarray, String[] envp, String dir, int[] chan, String slaveName, int masterFD, + native int exec2(String[] cmdarray, String[] envp, String dir, IChannel[] chan, String slaveName, int masterFD, boolean console) throws IOException; /** @@ -260,18 +288,33 @@ public class PTY { static { try { + boolean isWindows = Platform.OS_WIN32.equals(Platform.getOS()); + if (!isWindows) { + isConPTY = IS_CONPTY.CONPTY_NO; + } + // Disable ConPTY if the user needs to + boolean conPtyEnabled = Boolean + .parseBoolean(System.getProperty("org.eclipse.cdt.core.conpty_enabled", "true")); //$NON-NLS-1$ //$NON-NLS-2$ + if (!conPtyEnabled) { + isConPTY = IS_CONPTY.CONPTY_NO; + } + + isWinPTY = isWindows; + if (isWindows) { + // When we used to build with VC++ we used DelayLoadDLLs (See Gerrit 167674 and Bug 521515) so that the winpty + // could be found. When we ported to mingw we didn't port across this feature because it was simpler to just + // manually load winpty first. + System.loadLibrary("winpty"); //$NON-NLS-1$ + } System.loadLibrary("pty"); //$NON-NLS-1$ hasPTY = true; - isWinPTY = Platform.OS_WIN32.equals(Platform.getOS()); // on windows console mode is not supported except for experimental use // to enable it, set system property org.eclipse.cdt.core.winpty_console_mode=true isConsoleModeSupported = !isWinPTY || Boolean.getBoolean("org.eclipse.cdt.core.winpty_console_mode"); //$NON-NLS-1$ - } catch (SecurityException e) { - // Comment out it worries the users too much - //CCorePlugin.log(e); - } catch (UnsatisfiedLinkError e) { - // Comment out it worries the users too much - //CCorePlugin.log(e); + } catch (SecurityException | UnsatisfiedLinkError e) { + CNativePlugin.log( + "Failed to load the PTY library. This may indicate a configuration problem, but can be ignored if no further problems are observed.", //$NON-NLS-1$ + e); } } diff --git a/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/pty/PTYInputStream.java b/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/pty/PTYInputStream.java index eeebd1a097c..ed0410a2310 100644 --- a/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/pty/PTYInputStream.java +++ b/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/pty/PTYInputStream.java @@ -20,7 +20,10 @@ import java.io.InputStream; import org.eclipse.cdt.utils.pty.PTY.MasterFD; -class PTYInputStream extends InputStream { +/** + * @since 6.0 + */ +public class PTYInputStream extends InputStream { MasterFD master; diff --git a/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/spawner/EnvironmentReader.java b/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/spawner/EnvironmentReader.java index ae005dc2e7b..b602d556b53 100644 --- a/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/spawner/EnvironmentReader.java +++ b/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/spawner/EnvironmentReader.java @@ -28,7 +28,8 @@ import org.eclipse.core.runtime.Platform; */ public class EnvironmentReader { private static Properties envVars; - private static List<String> toUppercaseEnvironmentVars = Arrays.asList("PATH"); //$NON-NLS-1$ + @SuppressWarnings("nls") + private static List<String> toUppercaseEnvironmentVars = Arrays.asList("PATH", "CYGWIN_HOME", "LANG"); static { boolean isWindows = Platform.OS_WIN32.equals(Platform.getOS()); diff --git a/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/spawner/ProcessFactory.java b/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/spawner/ProcessFactory.java index f032d545af3..cab299b909e 100644 --- a/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/spawner/ProcessFactory.java +++ b/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/spawner/ProcessFactory.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2014 QNX Software Systems and others. + * Copyright (c) 2000, 2020 QNX Software Systems and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -11,6 +11,7 @@ * Contributors: * QNX Software Systems - Initial API and implementation * Martin Oberhuber (Wind River) - [303083] Split out the Spawner + * Red Hat Inc. - add flatpak support *******************************************************************************/ package org.eclipse.cdt.utils.spawner; @@ -30,6 +31,7 @@ public class ProcessFactory { static private ProcessFactory instance; private boolean hasSpawner; private Runtime runtime; + private final static String FLATPAK_CMD = "flatpak-spawn --host --watch-bus "; //$NON-NLS-1$ private ProcessFactory() { hasSpawner = false; @@ -56,45 +58,124 @@ public class ProcessFactory { return instance; } + /** + * @deprecated Do not use this method it splits command line arguments on whitespace with no regard to quoting rules. See Bug 573677 + */ + @Deprecated public Process exec(String cmd) throws IOException { + cmd = modifyCmdIfFlatpak(cmd); if (hasSpawner) return new Spawner(cmd); return runtime.exec(cmd); } public Process exec(String[] cmdarray) throws IOException { + cmdarray = modifyCmdArrayIfFlatpak(cmdarray); if (hasSpawner) return new Spawner(cmdarray); return runtime.exec(cmdarray); } + /** + * @since 6.2 + */ + public Process exec(String[] cmdarray, int gracefulExitTimeMs) throws IOException { + cmdarray = modifyCmdArrayIfFlatpak(cmdarray); + if (hasSpawner) + return new Spawner(cmdarray, gracefulExitTimeMs); + return runtime.exec(cmdarray); + } + public Process exec(String[] cmdarray, String[] envp) throws IOException { + cmdarray = modifyCmdArrayIfFlatpak(cmdarray); if (hasSpawner) return new Spawner(cmdarray, envp); return runtime.exec(cmdarray, envp); } + /** + * @since 6.2 + */ + public Process exec(String[] cmdarray, String[] envp, int gracefulExitTimeMs) throws IOException { + cmdarray = modifyCmdArrayIfFlatpak(cmdarray); + if (hasSpawner) + return new Spawner(cmdarray, envp, gracefulExitTimeMs); + return runtime.exec(cmdarray, envp); + } + + /** + * @deprecated Do not use this method it splits command line arguments on whitespace with no regard to quoting rules. See Bug 573677 + */ + @Deprecated public Process exec(String cmd, String[] envp) throws IOException { + cmd = modifyCmdIfFlatpak(cmd); if (hasSpawner) return new Spawner(cmd, envp); return runtime.exec(cmd, envp); } + /** + * @deprecated Do not use this method it splits command line arguments on whitespace with no regard to quoting rules. See Bug 573677 + */ + @Deprecated public Process exec(String cmd, String[] envp, File dir) throws IOException { + cmd = modifyCmdIfFlatpak(cmd); if (hasSpawner) return new Spawner(cmd, envp, dir); return runtime.exec(cmd, envp, dir); } public Process exec(String cmdarray[], String[] envp, File dir) throws IOException { + cmdarray = modifyCmdArrayIfFlatpak(cmdarray); if (hasSpawner) return new Spawner(cmdarray, envp, dir); return runtime.exec(cmdarray, envp, dir); } + /** + * @since 6.2 + */ + public Process exec(String cmdarray[], String[] envp, File dir, int gracefulExitTimeMs) throws IOException { + cmdarray = modifyCmdArrayIfFlatpak(cmdarray); + if (hasSpawner) + return new Spawner(cmdarray, envp, dir, gracefulExitTimeMs); + return runtime.exec(cmdarray, envp, dir); + } + public Process exec(String cmdarray[], String[] envp, File dir, PTY pty) throws IOException { + cmdarray = modifyCmdArrayIfFlatpak(cmdarray); if (hasSpawner) return new Spawner(cmdarray, envp, dir, pty); throw new UnsupportedOperationException(Messages.Util_exception_cannotCreatePty); } + + /** + * @since 6.2 + */ + public Process exec(String cmdarray[], String[] envp, File dir, PTY pty, int gracefulExitTimeMs) + throws IOException { + cmdarray = modifyCmdArrayIfFlatpak(cmdarray); + if (hasSpawner) + return new Spawner(cmdarray, envp, dir, pty, gracefulExitTimeMs); + throw new UnsupportedOperationException(Messages.Util_exception_cannotCreatePty); + } + + private String modifyCmdIfFlatpak(String cmd) { + if (System.getenv("FLATPAK_SANDBOX_DIR") != null) { //$NON-NLS-1$ + cmd = FLATPAK_CMD + cmd; + } + return cmd; + } + + private String[] modifyCmdArrayIfFlatpak(String[] cmdarray) { + if (System.getenv("FLATPAK_SANDBOX_DIR") != null) { //$NON-NLS-1$ + String[] newArray = new String[cmdarray.length + 3]; + System.arraycopy(cmdarray, 0, newArray, 3, cmdarray.length); + newArray[0] = "flatpak-spawn"; //$NON-NLS-1$ + newArray[1] = "--host"; //$NON-NLS-1$ + newArray[2] = "--watch-bus"; //$NON-NLS-1$ + cmdarray = newArray; + } + return cmdarray; + } } 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 c5249b99cb0..172a93aca0e 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 @@ -29,10 +29,31 @@ import org.eclipse.osgi.util.NLS; public class Spawner extends Process { - public int NOOP = 0; - public int HUP = 1; - public int KILL = 9; - public int TERM = 15; + @Deprecated(forRemoval = true) + public int NOOP = SIG_NOOP; + + @Deprecated(forRemoval = true) + public int HUP = SIG_HUP; + + @Deprecated(forRemoval = true) + public int KILL = SIG_KILL; + + @Deprecated(forRemoval = true) + public int TERM = SIG_TERM; + + @Deprecated(forRemoval = true) + public int INT = SIG_INT; + + /** + * @since 5.2 + */ + @Deprecated(forRemoval = true) + public int CTRLC = SIG_CTRLC; + + private final static int SIG_NOOP = 0; + private final static int SIG_HUP = 1; + private final static int SIG_KILL = 9; + private final static int SIG_TERM = 15; /** * On Windows, what this does is far from easy to explain. @@ -51,28 +72,54 @@ public class Spawner extends Process { * </ul> * * On non-Windows, raising this just raises a POSIX SIGINT - * */ - public int INT = 2; + private final static int SIG_INT = 2; /** * A fabricated signal number for use on Windows only. Tells the starter program to send a CTRL-C * regardless of whether the process is a Cygwin one or not. - * - * @since 5.2 */ - public int CTRLC = 1000; // arbitrary high number to avoid collision + private final static int SIG_CTRLC = 1000; // arbitrary high number to avoid collision + + private final static int DEFAULT_GRACEFUL_EXIT_TIME_MS; + + static { + String timeStr = System.getProperty("org.eclipse.cdt.core.graceful_exit_time_ms"); //$NON-NLS-1$ + int time = 1000; + if (timeStr != null) { + try { + time = Integer.parseInt(timeStr); + } catch (NumberFormatException e) { + CNativePlugin.log( + "Failed to parse system property. Falling back to " + time + " ms graceful exit time.", //$NON-NLS-1$ //$NON-NLS-2$ + e); + } + } + DEFAULT_GRACEFUL_EXIT_TIME_MS = time; + } int pid = 0; int status; - final int[] fChannels = { -1, -1, -1 }; - boolean isDone; + final IChannel[] fChannels = { null, null, null }; OutputStream out; InputStream in; InputStream err; private PTY fPty; + private final int fGracefulExitTimeMs; + + private static enum State { + RUNNING, DESTROYING, DONE + } + + private State fState = State.RUNNING; + + /** + * @deprecated Do not use this method it splits command line arguments on whitespace with no regard to quoting rules. See Bug 573677 + */ + @Deprecated public Spawner(String command, boolean bNoRedirect) throws IOException { + fGracefulExitTimeMs = DEFAULT_GRACEFUL_EXIT_TIME_MS; StringTokenizer tokenizer = new StringTokenizer(command); String[] cmdarray = new String[tokenizer.countTokens()]; for (int n = 0; tokenizer.hasMoreTokens(); n++) @@ -83,11 +130,17 @@ public class Spawner extends Process { exec(cmdarray, new String[0], "."); //$NON-NLS-1$ } + protected Spawner(String[] cmdarray, String[] envp, File dir) throws IOException { + this(cmdarray, envp, dir, DEFAULT_GRACEFUL_EXIT_TIME_MS); + } + /** * Executes the specified command and arguments in a separate process with the * specified environment and working directory. + * @since 6.2 **/ - protected Spawner(String[] cmdarray, String[] envp, File dir) throws IOException { + protected Spawner(String[] cmdarray, String[] envp, File dir, int gracefulExitTimeMs) throws IOException { + fGracefulExitTimeMs = gracefulExitTimeMs; String dirpath = "."; //$NON-NLS-1$ if (dir != null) dirpath = dir.getAbsolutePath(); @@ -95,6 +148,14 @@ public class Spawner extends Process { } protected Spawner(String[] cmdarray, String[] envp, File dir, PTY pty) throws IOException { + this(cmdarray, envp, dir, pty, DEFAULT_GRACEFUL_EXIT_TIME_MS); + } + + /** + * @since 6.2 + */ + protected Spawner(String[] cmdarray, String[] envp, File dir, PTY pty, int gracefulExitTimeMs) throws IOException { + fGracefulExitTimeMs = gracefulExitTimeMs; String dirpath = "."; //$NON-NLS-1$ if (dir != null) dirpath = dir.getAbsolutePath(); @@ -104,7 +165,9 @@ public class Spawner extends Process { /** * Executes the specified string command in a separate process. - **/ + * @deprecated Do not use this method it splits command line arguments on whitespace with no regard to quoting rules. See Bug 573677 + */ + @Deprecated protected Spawner(String command) throws IOException { this(command, null); } @@ -117,6 +180,13 @@ public class Spawner extends Process { } /** + * @since 6.2 + */ + protected Spawner(String[] cmdarray, int gracefulExitTimeMs) throws IOException { + this(cmdarray, null, gracefulExitTimeMs); + } + + /** * Executes the specified command and arguments in a separate process with the * specified environment. **/ @@ -125,9 +195,18 @@ public class Spawner extends Process { } /** + * @since 6.2 + */ + protected Spawner(String[] cmdarray, String[] envp, int gracefulExitTimeMs) throws IOException { + this(cmdarray, envp, null, gracefulExitTimeMs); + } + + /** * Executes the specified string command in a separate process with the specified * environment. - **/ + * @deprecated Do not use this method it splits command line arguments on whitespace with no regard to quoting rules. See Bug 573677 + */ + @Deprecated protected Spawner(String cmd, String[] envp) throws IOException { this(cmd, envp, null); } @@ -135,8 +214,11 @@ public class Spawner extends Process { /** * Executes the specified string command in a separate process with the specified * environment and working directory. - **/ + * @deprecated Do not use this method it splits command line arguments on whitespace with no regard to quoting rules. See Bug 573677 + */ + @Deprecated protected Spawner(String command, String[] envp, File dir) throws IOException { + fGracefulExitTimeMs = DEFAULT_GRACEFUL_EXIT_TIME_MS; StringTokenizer tokenizer = new StringTokenizer(command); String[] cmdarray = new String[tokenizer.countTokens()]; for (int n = 0; tokenizer.hasMoreTokens(); n++) @@ -213,7 +295,7 @@ public class Spawner extends Process { **/ @Override public synchronized int waitFor() throws InterruptedException { - while (!isDone) { + while (fState != State.DONE) { wait(); } @@ -235,7 +317,7 @@ public class Spawner extends Process { **/ @Override public synchronized int exitValue() { - if (!isDone) { + if (fState != State.DONE) { throw new IllegalThreadStateException("Process not Terminated"); //$NON-NLS-1$ } return status; @@ -250,49 +332,65 @@ public class Spawner extends Process { **/ @Override public synchronized void destroy() { - // Sends the TERM - terminate(); - - // Close the streams on this side. - // - // We only close the streams that were - // never used by any client. - // So, if the stream was not created yet, - // we create it ourselves and close it - // right away, so as to release the pipe. - // Note that even if the stream was never - // created, the pipe has been allocated in - // native code, so we need to create the - // stream and explicitly close it. - // - // We don't close streams the clients have - // created because we don't know when the - // client will be finished using them. - // It is up to the client to close those - // streams. - // - // But 345164 - closeUnusedStreams(); - - // Grace before using the heavy gone. - if (!isDone) { - try { - wait(1000); - } catch (InterruptedException e) { + switch (fState) { + case RUNNING: + fState = State.DESTROYING; + + // Sends the TERM + terminate(); + + // Close the streams on this side. + // + // We only close the streams that were + // never used by any client. + // So, if the stream was not created yet, + // we create it ourselves and close it + // right away, so as to release the pipe. + // Note that even if the stream was never + // created, the pipe has been allocated in + // native code, so we need to create the + // stream and explicitly close it. + // + // We don't close streams the clients have + // created because we don't know when the + // client will be finished using them. + // It is up to the client to close those + // streams. + // + // But 345164 + closeUnusedStreams(); + + // Grace before using the heavy gun. + if (fState != State.DONE) { + try { + wait(fGracefulExitTimeMs); + } catch (InterruptedException e) { + } } - } - if (!isDone) { - kill(); + if (fState != State.DONE) { + kill(); + } + break; + + case DESTROYING: + case DONE: + // Nothing to do + break; } } + @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 * linux, interrupt it by raising a SIGINT. */ public int interrupt() { - return raise(pid, INT); + return raise(pid, SIG_INT); } /** @@ -303,26 +401,26 @@ public class Spawner extends Process { */ public int interruptCTRLC() { if (Platform.getOS().equals(Platform.OS_WIN32)) { - return raise(pid, CTRLC); + return raise(pid, SIG_CTRLC); } else { return interrupt(); } } public int hangup() { - return raise(pid, HUP); + return raise(pid, SIG_HUP); } public int kill() { - return raise(pid, KILL); + return raise(pid, SIG_KILL); } public int terminate() { - return raise(pid, TERM); + return raise(pid, SIG_TERM); } public boolean isRunning() { - return (raise(pid, NOOP) == 0); + return (raise(pid, SIG_NOOP) == 0); } private void exec(String[] cmdarray, String[] envp, String dirpath) throws IOException { @@ -363,7 +461,7 @@ public class Spawner extends Process { Reaper reaper = new Reaper(cmdarray, envp, dirpath) { @Override - int execute(String[] cmd, String[] env, String dir, int[] channels) throws IOException { + int execute(String[] cmd, String[] env, String dir, IChannel[] channels) throws IOException { return pty.exec_pty(Spawner.this, cmd, env, dir, channels); } @@ -429,7 +527,7 @@ public class Spawner extends Process { /** * Native method use in normal exec() calls. */ - native int exec0(String[] cmdarray, String[] envp, String dir, int[] chan) throws IOException; + native int exec0(String[] cmdarray, String[] envp, String dir, IChannel[] chan) throws IOException; /** * Native method use in no redirect meaning to streams will created. @@ -440,8 +538,8 @@ public class Spawner extends Process { * Native method when executing with a terminal emulation. * @noreference This method is not intended to be referenced by clients. */ - public native int exec2(String[] cmdarray, String[] envp, String dir, int[] chan, String slaveName, int masterFD, - boolean console) throws IOException; + public native int exec2(String[] cmdarray, String[] envp, String dir, IChannel[] chan, String slaveName, + int masterFD, boolean console) throws IOException; /** * Native method to drop a signal on the process with pid. @@ -449,6 +547,13 @@ public class Spawner extends Process { public native int raise(int processID, int sig); /** + * @since 6.2 + */ + public int raise(int sig) { + return raise(pid, sig); + } + + /** * Native method to wait(3) for process to terminate. * @noreference This method is not intended to be referenced by clients. */ @@ -457,6 +562,10 @@ public class Spawner extends Process { static { try { System.loadLibrary("spawner"); //$NON-NLS-1$ + configureNativeTrace(Platform.getDebugBoolean(CNativePlugin.PLUGIN_ID + "/debug/spawner"), //$NON-NLS-1$ + Platform.getDebugBoolean(CNativePlugin.PLUGIN_ID + "/debug/spawner/details"), //$NON-NLS-1$ + Platform.getDebugBoolean(CNativePlugin.PLUGIN_ID + "/debug/spawner/starter"), //$NON-NLS-1$ + Platform.getDebugBoolean(CNativePlugin.PLUGIN_ID + "/debug/spawner/read_report")); //$NON-NLS-1$ } catch (SecurityException e) { CNativePlugin.log(e); } catch (UnsatisfiedLinkError e) { @@ -464,6 +573,40 @@ public class Spawner extends Process { } } + /** + * @since 6.0 + */ + private static native void configureNativeTrace(boolean spawner, boolean spawnerDetails, boolean starter, + boolean readReport); + + /** + * @since 6.0 + */ + public static interface IChannel { + } + + /** + * @since 6.0 + */ + public static class WinChannel implements IChannel { + final long handle; + + public WinChannel(long handle) { + this.handle = handle; + } + } + + /** + * @since 6.0 + */ + public static class UnixChannel implements IChannel { + final int fd; + + public UnixChannel(int fd) { + this.fd = fd; + } + } + // Spawn a thread to handle the forking and waiting // We do it this way because on linux the SIGCHLD is // send to the one thread. So do the forking and @@ -482,7 +625,7 @@ public class Spawner extends Process { fException = null; } - int execute(String[] cmdarray, String[] envp, String dir, int[] channels) throws IOException { + int execute(String[] cmdarray, String[] envp, String dir, IChannel[] channels) throws IOException { return exec0(cmdarray, envp, dir, channels); } @@ -510,7 +653,7 @@ public class Spawner extends Process { // Sync with spawner and notify when done. status = waitFor(pid); synchronized (Spawner.this) { - isDone = true; + fState = Spawner.State.DONE; Spawner.this.notifyAll(); } } diff --git a/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/spawner/SpawnerInputStream.java b/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/spawner/SpawnerInputStream.java index 5e8e2926cc1..27533cc5fda 100644 --- a/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/spawner/SpawnerInputStream.java +++ b/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/spawner/SpawnerInputStream.java @@ -18,16 +18,17 @@ import java.io.IOException; import java.io.InputStream; import org.eclipse.cdt.internal.core.natives.Messages; +import org.eclipse.cdt.utils.spawner.Spawner.IChannel; class SpawnerInputStream extends InputStream { - private int fd; + private IChannel channel; /** * From a Unix valid file descriptor set a Reader. * @param fd file descriptor. */ - public SpawnerInputStream(int fd) { - this.fd = fd; + public SpawnerInputStream(IChannel channel) { + this.channel = channel; } /** @@ -48,7 +49,7 @@ class SpawnerInputStream extends InputStream { */ @Override public int read(byte[] buf, int off, int len) throws IOException { - if (fd == -1) { + if (channel == null) { return -1; } if (buf == null) { @@ -60,7 +61,7 @@ class SpawnerInputStream extends InputStream { } byte[] tmpBuf = off > 0 ? new byte[len] : buf; - len = read0(fd, tmpBuf, len); + len = read0(channel, tmpBuf, len); if (len <= 0) return -1; @@ -76,21 +77,21 @@ class SpawnerInputStream extends InputStream { */ @Override public void close() throws IOException { - if (fd == -1) + if (channel == null) return; - int status = close0(fd); + int status = close0(channel); if (status == -1) throw new IOException(Messages.Util_exception_closeError); - fd = -1; + channel = null; } @Override public int available() throws IOException { - if (fd == -1) { + if (channel == null) { return 0; } try { - return available0(fd); + return available0(channel); } catch (UnsatisfiedLinkError e) { // for those platforms that do not implement available0 return super.available(); @@ -102,11 +103,11 @@ class SpawnerInputStream extends InputStream { close(); } - private native int read0(int fileDesc, byte[] buf, int len) throws IOException; + private native int read0(IChannel channel, byte[] buf, int len) throws IOException; - private native int close0(int fileDesc) throws IOException; + private native int close0(IChannel channel) throws IOException; - private native int available0(int fileDesc) throws IOException; + private native int available0(IChannel channel) throws IOException; static { System.loadLibrary("spawner"); //$NON-NLS-1$ diff --git a/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/spawner/SpawnerOutputStream.java b/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/spawner/SpawnerOutputStream.java index 01863b491f0..a6e51e824da 100644 --- a/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/spawner/SpawnerOutputStream.java +++ b/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/spawner/SpawnerOutputStream.java @@ -16,19 +16,22 @@ package org.eclipse.cdt.utils.spawner; import java.io.IOException; import java.io.OutputStream; +import org.eclipse.cdt.utils.spawner.Spawner.IChannel; + /** * @noextend This class is not intended to be subclassed by clients. * @noinstantiate This class is not intended to be instantiated by clients. */ public class SpawnerOutputStream extends OutputStream { - private int fd; + private IChannel channel; /** * From a Unix valid file descriptor set a Reader. - * @param fd file descriptor. + * @param channel file descriptor. + * @since 6.0 */ - public SpawnerOutputStream(int fd) { - this.fd = fd; + public SpawnerOutputStream(IChannel channel) { + this.channel = channel; } /** @@ -45,7 +48,7 @@ public class SpawnerOutputStream extends OutputStream { } byte[] tmpBuf = new byte[len]; System.arraycopy(b, off, tmpBuf, off, len); - write0(fd, tmpBuf, len); + write0(channel, tmpBuf, len); } /** @@ -66,12 +69,12 @@ public class SpawnerOutputStream extends OutputStream { */ @Override public void close() throws IOException { - if (fd == -1) + if (channel == null) return; - int status = close0(fd); + int status = close0(channel); if (status == -1) throw new IOException("close error"); //$NON-NLS-1$ - fd = -1; + channel = null; } @Override @@ -79,9 +82,9 @@ public class SpawnerOutputStream extends OutputStream { close(); } - private native int write0(int fd, byte[] b, int len) throws IOException; + private native int write0(IChannel channel, byte[] b, int len) throws IOException; - private native int close0(int fd); + private native int close0(IChannel channel); static { System.loadLibrary("spawner"); //$NON-NLS-1$ diff --git a/core/org.eclipse.cdt.core.tests/.classpath b/core/org.eclipse.cdt.core.tests/.classpath index ead01df4a83..e38958c5cae 100644 --- a/core/org.eclipse.cdt.core.tests/.classpath +++ b/core/org.eclipse.cdt.core.tests/.classpath @@ -1,11 +1,31 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> - <classpathentry kind="src" path="misc"/> - <classpathentry kind="src" path="model"/> - <classpathentry kind="src" path="parser"/> - <classpathentry kind="src" path="suite"/> - <classpathentry kind="src" path="regression"/> + <classpathentry kind="src" path="misc"> + <attributes> + <attribute name="test" value="true"/> + </attributes> + </classpathentry> + <classpathentry kind="src" path="model"> + <attributes> + <attribute name="test" value="true"/> + </attributes> + </classpathentry> + <classpathentry kind="src" path="parser"> + <attributes> + <attribute name="test" value="true"/> + </attributes> + </classpathentry> + <classpathentry kind="src" path="suite"> + <attributes> + <attribute name="test" value="true"/> + </attributes> + </classpathentry> + <classpathentry kind="src" path="regression"> + <attributes> + <attribute name="test" value="true"/> + </attributes> + </classpathentry> <classpathentry kind="output" path="bin"/> </classpath> diff --git a/core/org.eclipse.cdt.core.tests/.project b/core/org.eclipse.cdt.core.tests/.project index 466f1c10b80..06a4ddffc04 100644 --- a/core/org.eclipse.cdt.core.tests/.project +++ b/core/org.eclipse.cdt.core.tests/.project @@ -20,11 +20,17 @@ <arguments> </arguments> </buildCommand> + <buildCommand> + <name>org.eclipse.pde.api.tools.apiAnalysisBuilder</name> + <arguments> + </arguments> + </buildCommand> </buildSpec> <natures> <nature>org.eclipse.jdt.core.javanature</nature> <nature>org.eclipse.pde.PluginNature</nature> <nature>org.eclipse.cdt.core.cnature</nature> <nature>org.eclipse.cdt.core.ccnature</nature> + <nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature> </natures> </projectDescription> diff --git a/core/org.eclipse.cdt.core.tests/.settings/.api_filters b/core/org.eclipse.cdt.core.tests/.settings/.api_filters new file mode 100644 index 00000000000..3015faeefa9 --- /dev/null +++ b/core/org.eclipse.cdt.core.tests/.settings/.api_filters @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<component id="org.eclipse.cdt.core.tests" version="2"> + <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="ExtendedScannerInfo"/> + <message_argument value="ExtendedScannerInfoSerializerDeserializerTest"/> + <message_argument value="getIncludeExportPatterns()"/> + </message_arguments> + </filter> + </resource> +</component> diff --git a/core/org.eclipse.cdt.core.tests/.settings/org.eclipse.core.resources.prefs b/core/org.eclipse.cdt.core.tests/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 00000000000..99f26c0203a --- /dev/null +++ b/core/org.eclipse.cdt.core.tests/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/<project>=UTF-8 diff --git a/core/org.eclipse.cdt.core.tests/.settings/org.eclipse.jdt.core.prefs b/core/org.eclipse.cdt.core.tests/.settings/org.eclipse.jdt.core.prefs index ad05599159f..5b1c443114d 100644 --- a/core/org.eclipse.cdt.core.tests/.settings/org.eclipse.jdt.core.prefs +++ b/core/org.eclipse.cdt.core.tests/.settings/org.eclipse.jdt.core.prefs @@ -30,9 +30,9 @@ org.eclipse.jdt.core.compiler.annotation.nullable.secondary= org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.methodParameters=generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.compliance=11 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -49,6 +49,7 @@ org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled org.eclipse.jdt.core.compiler.problem.discouragedReference=ignore org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning @@ -107,6 +108,7 @@ org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=igno org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled @@ -144,13 +146,14 @@ org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=ignore org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.release=disabled -org.eclipse.jdt.core.compiler.source=1.8 +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=11 org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns=false org.eclipse.jdt.core.formatter.align_with_spaces=false +org.eclipse.jdt.core.formatter.alignment_for_additive_operator=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 @@ -158,21 +161,24 @@ org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_c org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_assignment=0 -org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_bitwise_operator=16 org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 org.eclipse.jdt.core.formatter.alignment_for_compact_loops=16 org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 org.eclipse.jdt.core.formatter.alignment_for_enum_constants=16 org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0 +org.eclipse.jdt.core.formatter.alignment_for_logical_operator=16 org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 org.eclipse.jdt.core.formatter.alignment_for_module_statements=16 org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_multiplicative_operator=16 org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_string_concatenation=16 org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 @@ -264,11 +270,12 @@ org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_after_additive_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_bitwise_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert @@ -299,6 +306,8 @@ org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_after_logical_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_multiplicative_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert @@ -323,13 +332,17 @@ org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_relational_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert +org.eclipse.jdt.core.formatter.insert_space_after_shift_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_string_concatenation=insert org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_additive_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_bitwise_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert @@ -377,6 +390,8 @@ org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do no org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_before_logical_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_multiplicative_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert @@ -413,9 +428,12 @@ org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not inser org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_relational_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_shift_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_string_concatenation=insert org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert @@ -454,10 +472,14 @@ org.eclipse.jdt.core.formatter.tabulation.char=tab org.eclipse.jdt.core.formatter.tabulation.size=4 org.eclipse.jdt.core.formatter.use_on_off_tags=true org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false +org.eclipse.jdt.core.formatter.wrap_before_additive_operator=true org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false -org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true +org.eclipse.jdt.core.formatter.wrap_before_bitwise_operator=true org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true +org.eclipse.jdt.core.formatter.wrap_before_logical_operator=true +org.eclipse.jdt.core.formatter.wrap_before_multiplicative_operator=true org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true +org.eclipse.jdt.core.formatter.wrap_before_string_concatenation=true org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true org.eclipse.jdt.core.incompatibleJDKLevel=ignore org.eclipse.jdt.core.incompleteClasspath=error diff --git a/core/org.eclipse.cdt.core.tests/.settings/org.eclipse.jdt.ui.prefs b/core/org.eclipse.cdt.core.tests/.settings/org.eclipse.jdt.ui.prefs index e44576346c4..d35ba9b5231 100644 --- a/core/org.eclipse.cdt.core.tests/.settings/org.eclipse.jdt.ui.prefs +++ b/core/org.eclipse.cdt.core.tests/.settings/org.eclipse.jdt.ui.prefs @@ -1,3 +1,4 @@ +cleanup.add_all=false cleanup.add_default_serial_version_id=true cleanup.add_generated_serial_version_id=false cleanup.add_missing_annotations=true @@ -11,25 +12,72 @@ cleanup.always_use_blocks=true cleanup.always_use_parentheses_in_expressions=false cleanup.always_use_this_for_non_static_field_access=false cleanup.always_use_this_for_non_static_method_access=false +cleanup.array_with_curly=false +cleanup.arrays_fill=false +cleanup.bitwise_conditional_expression=false +cleanup.boolean_literal=false +cleanup.boolean_value_rather_than_comparison=false +cleanup.break_loop=false +cleanup.collection_cloning=false +cleanup.comparing_on_criteria=false +cleanup.comparison_statement=false +cleanup.controlflow_merge=false cleanup.convert_functional_interfaces=false cleanup.convert_to_enhanced_for_loop=false +cleanup.convert_to_enhanced_for_loop_if_loop_var_used=true +cleanup.convert_to_switch_expressions=false cleanup.correct_indentation=false +cleanup.do_while_rather_than_while=true +cleanup.double_negation=false +cleanup.else_if=false +cleanup.embedded_if=false +cleanup.evaluate_nullable=false +cleanup.extract_increment=false cleanup.format_source_code=true cleanup.format_source_code_changes_only=false +cleanup.hash=false +cleanup.if_condition=false cleanup.insert_inferred_type_arguments=false +cleanup.instanceof=false +cleanup.instanceof_keyword=false +cleanup.invert_equals=false +cleanup.join=false +cleanup.lazy_logical_operator=false cleanup.make_local_variable_final=true cleanup.make_parameters_final=false cleanup.make_private_fields_final=true cleanup.make_type_abstract_if_missing_method=false cleanup.make_variable_declarations_final=false +cleanup.map_cloning=false +cleanup.merge_conditional_blocks=false +cleanup.multi_catch=false cleanup.never_use_blocks=false cleanup.never_use_parentheses_in_expressions=true +cleanup.no_string_creation=false +cleanup.no_super=false +cleanup.number_suffix=false +cleanup.objects_equals=false +cleanup.one_if_rather_than_duplicate_blocks_that_fall_through=false +cleanup.operand_factorization=false cleanup.organize_imports=true +cleanup.overridden_assignment=false +cleanup.plain_replacement=false +cleanup.precompile_regex=false +cleanup.primitive_comparison=false +cleanup.primitive_parsing=false +cleanup.primitive_rather_than_wrapper=false +cleanup.primitive_serialization=false +cleanup.pull_out_if_from_if_else=false +cleanup.pull_up_assignment=false +cleanup.push_down_negation=false cleanup.qualify_static_field_accesses_with_declaring_class=false cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true cleanup.qualify_static_member_accesses_with_declaring_class=false cleanup.qualify_static_method_accesses_with_declaring_class=false +cleanup.reduce_indentation=false +cleanup.redundant_comparator=false +cleanup.redundant_falling_through_block_end=false cleanup.remove_private_constructors=true cleanup.remove_redundant_modifiers=false cleanup.remove_redundant_semicolons=true @@ -37,25 +85,57 @@ cleanup.remove_redundant_type_arguments=true cleanup.remove_trailing_whitespaces=true cleanup.remove_trailing_whitespaces_all=true cleanup.remove_trailing_whitespaces_ignore_empty=false +cleanup.remove_unnecessary_array_creation=false cleanup.remove_unnecessary_casts=true cleanup.remove_unnecessary_nls_tags=false cleanup.remove_unused_imports=true cleanup.remove_unused_local_variables=false +cleanup.remove_unused_method_parameters=false cleanup.remove_unused_private_fields=true cleanup.remove_unused_private_members=false cleanup.remove_unused_private_methods=true cleanup.remove_unused_private_types=true +cleanup.return_expression=false +cleanup.simplify_lambda_expression_and_method_ref=false +cleanup.single_used_field=false cleanup.sort_members=false cleanup.sort_members_all=false +cleanup.standard_comparison=false +cleanup.static_inner_class=false +cleanup.strictly_equal_or_different=false +cleanup.stringbuffer_to_stringbuilder=false +cleanup.stringbuilder=false +cleanup.stringbuilder_for_local_vars=true +cleanup.stringconcat_to_textblock=false +cleanup.substring=false +cleanup.switch=false +cleanup.system_property=false +cleanup.system_property_boolean=false +cleanup.system_property_file_encoding=false +cleanup.system_property_file_separator=false +cleanup.system_property_line_separator=false +cleanup.system_property_path_separator=false +cleanup.ternary_operator=false +cleanup.try_with_resource=false +cleanup.unlooped_while=false +cleanup.unreachable_block=false cleanup.use_anonymous_class_creation=false +cleanup.use_autoboxing=false cleanup.use_blocks=false cleanup.use_blocks_only_for_return_and_throw=false +cleanup.use_directly_map_method=false cleanup.use_lambda=true cleanup.use_parentheses_in_expressions=false +cleanup.use_string_is_blank=false cleanup.use_this_for_non_static_field_access=false cleanup.use_this_for_non_static_field_access_only_if_necessary=true cleanup.use_this_for_non_static_method_access=false cleanup.use_this_for_non_static_method_access_only_if_necessary=true +cleanup.use_unboxing=false +cleanup.use_var=false +cleanup.useless_continue=false +cleanup.useless_return=false +cleanup.valueof_rather_than_instantiation=false cleanup_profile=_CDT cleanup_settings_version=2 eclipse.preferences.version=1 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 90068381a7a..80281c25445 100644 --- a/core/org.eclipse.cdt.core.tests/META-INF/MANIFEST.MF +++ b/core/org.eclipse.cdt.core.tests/META-INF/MANIFEST.MF @@ -1,8 +1,8 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 -Bundle-Name: org.eclipse.cdt.core.tests +Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.cdt.core.tests; singleton:=true -Bundle-Version: 5.4.0.qualifier +Bundle-Version: 5.4.100.qualifier Bundle-Activator: org.eclipse.cdt.core.testplugin.CTestPlugin Export-Package: org.eclipse.cdt.core.cdescriptor.tests, org.eclipse.cdt.core.envvar, @@ -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,8 +43,12 @@ 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.core, + org.hamcrest.library, + com.google.gson;bundle-version="[2.8.6,3.0.0)" Bundle-ActivationPolicy: lazy -Bundle-Vendor: Eclipse CDT -Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Bundle-Vendor: %providerName +Bundle-RequiredExecutionEnvironment: JavaSE-11 Automatic-Module-Name: org.eclipse.cdt.core.tests +Bundle-Localization: plugin +Import-Package: org.junit.jupiter.api;version="5.7.0" diff --git a/core/org.eclipse.cdt.core.tests/about.html b/core/org.eclipse.cdt.core.tests/about.html index 164f781a8fd..b3134865230 100644 --- a/core/org.eclipse.cdt.core.tests/about.html +++ b/core/org.eclipse.cdt.core.tests/about.html @@ -1,10 +1,11 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> + <head> -<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> -<title>About</title> + <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> + <title>About</title> </head> + <body lang="EN-US"> <h2>About This Content</h2> @@ -16,7 +17,7 @@ ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 ("EPL"). A copy of the EPL is - available at <a href="http://www.eclipse.org/legal/epl-2.0">http://www.eclipse.org/legal/epl-2.0</a>. + available at <a href="https://www.eclipse.org/legal/epl-2.0">https://www.eclipse.org/legal/epl-2.0</a>. For purposes of the EPL, "Program" will mean the Content. </p> @@ -29,8 +30,9 @@ license exists, contact the Redistributor. Unless otherwise indicated below, the terms and conditions of the EPL still apply to any source code in the Content and such source code may be obtained at <a - href="http://www.eclipse.org/">http://www.eclipse.org</a>. + href="https://www.eclipse.org/">https://www.eclipse.org</a>. </p> </body> + </html>
\ No newline at end of file diff --git a/core/org.eclipse.cdt.core.tests/build.properties b/core/org.eclipse.cdt.core.tests/build.properties index fe05959b56d..edc11222857 100644 --- a/core/org.eclipse.cdt.core.tests/build.properties +++ b/core/org.eclipse.cdt.core.tests/build.properties @@ -12,6 +12,7 @@ # IBM Corporation - initial API and implementation ############################################################################### bin.includes = plugin.xml,\ + plugin.properties,\ about.html,\ .,\ test.xml,\ diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/cdescriptor/tests/CDescriptorTests.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/cdescriptor/tests/CDescriptorTests.java index 8c8b42f6f05..472d3650315 100644 --- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/cdescriptor/tests/CDescriptorTests.java +++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/cdescriptor/tests/CDescriptorTests.java @@ -16,6 +16,12 @@ ***********************************************************************/ package org.eclipse.cdt.core.cdescriptor.tests; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -32,7 +38,7 @@ import org.eclipse.cdt.core.ICOwnerInfo; import org.eclipse.cdt.core.settings.model.ICProjectDescription; import org.eclipse.cdt.core.settings.model.ICStorageElement; import org.eclipse.cdt.core.testplugin.CTestPlugin; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; +import org.eclipse.cdt.core.testplugin.util.BaseTestCase5; import org.eclipse.cdt.internal.core.pdom.PDOMManager; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; @@ -42,33 +48,20 @@ import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.IWorkspaceRunnable; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; -import org.junit.Assert; - -import junit.framework.Test; -import junit.framework.TestSuite; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -public class CDescriptorTests extends BaseTestCase { +@Tag(BaseTestCase5.FLAKY_TEST_TAG) +public class CDescriptorTests extends BaseTestCase5 { static String projectId = CTestPlugin.PLUGIN_ID + ".TestProject"; static IProject fProject; static CDescriptorListener listener = new CDescriptorListener(); static volatile CDescriptorEvent fLastEvent; - /** - * Constructor for CDescriptorTest. - * - * @param name - */ - public CDescriptorTests(String name) { - super(name); - } - - public static Test suite() { - TestSuite suite = new TestSuite(CDescriptorTests.class); - return suite; - } - - @Override - protected void setUp() throws Exception { + @BeforeEach + protected void setUpLocal() throws Exception { CTestPlugin.getWorkspace().run(new IWorkspaceRunnable() { @Override public void run(IProgressMonitor monitor) throws CoreException { @@ -97,8 +90,8 @@ public class CDescriptorTests extends BaseTestCase { }, null); } - @Override - protected void tearDown() throws Exception { + @AfterEach + protected void tearDownLocal() throws Exception { fProject.delete(true, true, null); } @@ -120,29 +113,32 @@ public class CDescriptorTests extends BaseTestCase { } } + @Test public void testDescriptorCreation() throws Exception { ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject, true); - Assert.assertNotNull(fLastEvent); - Assert.assertEquals(fLastEvent.getDescriptor(), desc); - Assert.assertEquals(fLastEvent.getType(), CDescriptorEvent.CDTPROJECT_ADDED); - Assert.assertEquals(fLastEvent.getFlags(), 0); + assertNotNull(fLastEvent); + assertEquals(fLastEvent.getDescriptor(), desc); + assertEquals(fLastEvent.getType(), CDescriptorEvent.CDTPROJECT_ADDED); + assertEquals(fLastEvent.getFlags(), 0); fLastEvent = null; - Assert.assertEquals(fProject, desc.getProject()); - Assert.assertEquals("*", desc.getPlatform()); + assertEquals(fProject, desc.getProject()); + assertEquals("*", desc.getPlatform()); } + @Test public void testDescriptorOwner() throws Exception { ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject, true); ICOwnerInfo owner = desc.getProjectOwner(); - Assert.assertEquals(projectId, owner.getID()); - Assert.assertEquals("*", owner.getPlatform()); - Assert.assertEquals("C/C++ Test Project", owner.getName()); + assertEquals(projectId, owner.getID()); + assertEquals("*", owner.getPlatform()); + assertEquals("C/C++ Test Project", owner.getName()); } // Disabled this test because it fails every now and then and it tests deprecated API // https://bugs.eclipse.org/bugs/show_bug.cgi?id=340123 + // @Test public void _testConcurrentDescriptorCreation() throws Exception { for (int i = 0; i < 100; i++) { fProject.close(null); @@ -179,6 +175,7 @@ public class CDescriptorTests extends BaseTestCase { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=185930 // https://bugs.eclipse.org/bugs/show_bug.cgi?id=193503 // https://bugs.eclipse.org/bugs/show_bug.cgi?id=196118 + @Test public void testConcurrentDescriptorModification() throws Exception { int lastLength = 0; for (int i = 0; i < 100; ++i) { @@ -230,12 +227,12 @@ public class CDescriptorTests extends BaseTestCase { } catch (InterruptedException e) { } } - assertNull("Exception occurred: " + exception[j], exception[j]); + assertNull(exception[j], "Exception occurred: " + exception[j]); } ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject, true); int lengthAfter = desc.getProjectStorageElement("testElement").getChildren().length; lastLength += threads.length; // Update last lengths to what we expect - assertEquals("Iteration count: " + i, lastLength, lengthAfter); + assertEquals(lastLength, lengthAfter, "Iteration count: " + i); fLastEvent = null; } @@ -245,6 +242,7 @@ public class CDescriptorTests extends BaseTestCase { * This test should pass as two threads, operating on the different storage elements * (outside of an operation) should be safe. */ + @Test public void testConcurrentDifferentStorageElementModification() throws Exception { for (int i = 0; i < 100; ++i) { Thread t = new Thread() { @@ -273,15 +271,16 @@ public class CDescriptorTests extends BaseTestCase { fLastEvent = null; } - Assert.assertEquals(100, CCorePlugin.getDefault().getCProjectDescription(fProject, false) + assertEquals(100, CCorePlugin.getDefault().getCProjectDescription(fProject, false) .getProjectStorageElement("testElement4").getChildren().length); - Assert.assertEquals(100, CCorePlugin.getDefault().getCProjectDescription(fProject, false) + assertEquals(100, CCorePlugin.getDefault().getCProjectDescription(fProject, false) .getProjectStorageElement("testElement5").getChildren().length); } /* * Tests that (non-structural) changes to the storage element tree work as expected. */ + @Test public void testConcurrentSameStorageElementModification() throws Exception { for (int i = 0; i < 100; ++i) { Thread t = new Thread() { @@ -310,17 +309,18 @@ public class CDescriptorTests extends BaseTestCase { fLastEvent = null; } - Assert.assertEquals(200, CCorePlugin.getDefault().getCProjectDescription(fProject, false) + assertEquals(200, CCorePlugin.getDefault().getCProjectDescription(fProject, false) .getProjectStorageElement("testElement6").getChildren().length); } /* * Tests deadlock when accessing c project description concurrently from two threads */ + @Test public void testDeadlockDuringProjectCreation() throws Exception { for (int i = 0; i < 10; ++i) { - tearDown(); - setUp(); + tearDownLocal(); + setUpLocal(); Thread t = new Thread() { @Override public void run() { @@ -348,33 +348,37 @@ public class CDescriptorTests extends BaseTestCase { } } + @Test public void testDescriptorConversion() { } + @Test public void testExtensionCreation() throws Exception { ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject, true); ICExtensionReference extRef = desc.create("org.eclipse.cdt.testextension", "org.eclipse.cdt.testextensionID"); - Assert.assertNotNull(fLastEvent); - Assert.assertEquals(fLastEvent.getDescriptor(), desc); - Assert.assertEquals(fLastEvent.getType(), CDescriptorEvent.CDTPROJECT_CHANGED); - Assert.assertEquals(fLastEvent.getFlags(), CDescriptorEvent.EXTENSION_CHANGED); + assertNotNull(fLastEvent); + assertEquals(fLastEvent.getDescriptor(), desc); + assertEquals(fLastEvent.getType(), CDescriptorEvent.CDTPROJECT_CHANGED); + assertEquals(fLastEvent.getFlags(), CDescriptorEvent.EXTENSION_CHANGED); fLastEvent = null; - Assert.assertEquals("org.eclipse.cdt.testextension", extRef.getExtension()); - Assert.assertEquals("org.eclipse.cdt.testextensionID", extRef.getID()); + assertEquals("org.eclipse.cdt.testextension", extRef.getExtension()); + assertEquals("org.eclipse.cdt.testextensionID", extRef.getID()); } + @Test public void testExtensionGet() throws Exception { ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject, true); desc.create("org.eclipse.cdt.testextension", "org.eclipse.cdt.testextensionID"); ICExtensionReference extRef[] = desc.get("org.eclipse.cdt.testextension"); - Assert.assertEquals("org.eclipse.cdt.testextension", extRef[0].getExtension()); - Assert.assertEquals("org.eclipse.cdt.testextensionID", extRef[0].getID()); + assertEquals("org.eclipse.cdt.testextension", extRef[0].getExtension()); + assertEquals("org.eclipse.cdt.testextensionID", extRef[0].getID()); } + @Test public void testExtensionData() throws Exception { ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject, true); desc.create("org.eclipse.cdt.testextension", "org.eclipse.cdt.testextensionID"); @@ -382,17 +386,18 @@ public class CDescriptorTests extends BaseTestCase { ICExtensionReference extRef[] = desc.get("org.eclipse.cdt.testextension"); extRef[0].setExtensionData("testKey", "testValue"); - Assert.assertNotNull(fLastEvent); - Assert.assertEquals(fLastEvent.getDescriptor(), desc); - Assert.assertEquals(fLastEvent.getType(), CDescriptorEvent.CDTPROJECT_CHANGED); - Assert.assertEquals(fLastEvent.getFlags(), 0); + assertNotNull(fLastEvent); + assertEquals(fLastEvent.getDescriptor(), desc); + assertEquals(fLastEvent.getType(), CDescriptorEvent.CDTPROJECT_CHANGED); + assertEquals(fLastEvent.getFlags(), 0); fLastEvent = null; - Assert.assertEquals("testValue", extRef[0].getExtensionData("testKey")); + assertEquals("testValue", extRef[0].getExtensionData("testKey")); extRef[0].setExtensionData("testKey", null); - Assert.assertEquals(null, extRef[0].getExtensionData("testKey")); + assertEquals(null, extRef[0].getExtensionData("testKey")); } + @Test public void testExtensionRemove() throws Exception { ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject, true); desc.create("org.eclipse.cdt.testextension", "org.eclipse.cdt.testextensionID"); @@ -400,43 +405,46 @@ public class CDescriptorTests extends BaseTestCase { ICExtensionReference extRef[] = desc.get("org.eclipse.cdt.testextension"); desc.remove(extRef[0]); - Assert.assertNotNull(fLastEvent); - Assert.assertEquals(fLastEvent.getDescriptor(), desc); - Assert.assertEquals(fLastEvent.getType(), CDescriptorEvent.CDTPROJECT_CHANGED); - Assert.assertEquals(fLastEvent.getFlags(), CDescriptorEvent.EXTENSION_CHANGED); + assertNotNull(fLastEvent); + assertEquals(fLastEvent.getDescriptor(), desc); + assertEquals(fLastEvent.getType(), CDescriptorEvent.CDTPROJECT_CHANGED); + assertEquals(fLastEvent.getFlags(), CDescriptorEvent.EXTENSION_CHANGED); fLastEvent = null; } + @Test public void testProjectDataCreate() throws Exception { ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject, true); ICStorageElement data = desc.getProjectStorageElement("testElement"); data.createChild("test"); desc.saveProjectData(); - Assert.assertNotNull(fLastEvent); - Assert.assertEquals(fLastEvent.getDescriptor(), desc); - Assert.assertEquals(fLastEvent.getType(), CDescriptorEvent.CDTPROJECT_CHANGED); - Assert.assertEquals(fLastEvent.getFlags(), 0); + assertNotNull(fLastEvent); + assertEquals(fLastEvent.getDescriptor(), desc); + assertEquals(fLastEvent.getType(), CDescriptorEvent.CDTPROJECT_CHANGED); + assertEquals(fLastEvent.getFlags(), 0); fLastEvent = null; } + @Test public void testProjectDataDelete() throws Exception { ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject, true); ICStorageElement data = desc.getProjectStorageElement("testElement"); data.createChild("test"); ICStorageElement[] list = data.getChildrenByName("test"); - Assert.assertEquals(1, list.length); + assertEquals(1, list.length); data.removeChild(list[0]); desc.saveProjectData(); - Assert.assertNotNull(fLastEvent); - Assert.assertEquals(fLastEvent.getDescriptor(), desc); - Assert.assertEquals(fLastEvent.getType(), CDescriptorEvent.CDTPROJECT_CHANGED); - Assert.assertEquals(fLastEvent.getFlags(), 0); + assertNotNull(fLastEvent); + assertEquals(fLastEvent.getDescriptor(), desc); + assertEquals(fLastEvent.getType(), CDescriptorEvent.CDTPROJECT_CHANGED); + assertEquals(fLastEvent.getFlags(), 0); fLastEvent = null; } + @Test public void testCProjectDescriptionDescriptorInteraction() throws Exception { for (int i = 1; i < 100; i++) { // Create a descriptor with some test data @@ -469,6 +477,7 @@ public class CDescriptorTests extends BaseTestCase { } } + @Test public void testAccumulatingBlankLinesInProjectData() throws Exception { ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject, true); ICStorageElement data = desc.getProjectStorageElement("testElement"); @@ -491,8 +500,8 @@ public class CDescriptorTests extends BaseTestCase { String dotCProject2 = readDotCProjectFile(fProject); long mtime2 = fProject.getFile(".cproject").getLocalTimeStamp(); - assertEquals("Difference in .cproject file", dotCProject1, dotCProject2); - assertTrue(".cproject file has been written", mtime1 == mtime2); + assertEquals(dotCProject1, dotCProject2, "Difference in .cproject file"); + assertTrue(mtime1 == mtime2, ".cproject file has been written"); // do it a second time - just to be sure fProject.close(null); @@ -508,8 +517,8 @@ public class CDescriptorTests extends BaseTestCase { String dotCProject3 = readDotCProjectFile(fProject); long mtime3 = fProject.getFile(".cproject").getLocalTimeStamp(); - assertEquals("Difference in .cproject file", dotCProject2, dotCProject3); - assertTrue(".cproject file has been written", mtime2 == mtime3); + assertEquals(dotCProject2, dotCProject3, "Difference in .cproject file"); + assertTrue(mtime2 == mtime3, ".cproject file has been written"); } /** diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/ErrorParserTests.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/ErrorParserTestSuite.java index b2c9e0762dc..1fa2c479292 100644 --- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/ErrorParserTests.java +++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/ErrorParserTestSuite.java @@ -16,10 +16,14 @@ package org.eclipse.cdt.core.internal.errorparsers.tests; import junit.framework.Test; import junit.framework.TestSuite; -public class ErrorParserTests { +/** + * @deprecated In preparation for moving to JUnit5 test suites are deprecated. See Bug 569839 + */ +@Deprecated +public class ErrorParserTestSuite { public static Test suite() { - TestSuite suite = new TestSuite(ErrorParserTests.class.getName()); + TestSuite suite = new TestSuite(ErrorParserTestSuite.class.getName()); // Just add more test cases here as you create them for // each class being tested 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 1514d2fde78..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 @@ -206,4 +206,34 @@ public class GCCErrorParserTests extends GenericErrorParserTests { new String[] { GCC_ERROR_PARSER_ID }); } + public void testGccErrorMessages_TemplateInstantiation_bug500798() throws IOException { + runParserTest(new String[] { + "test.hpp:309:18: [ skipping 2 instantiation contexts, use -ftemplate-backtrace-limit=0 to disable ]", + "test2.hpp:83:60: required from here", + "test3.hpp:78:38: warning: conversion from 'long int' to 'float' may change value [-Wconversion]" }, 0, // errors + 1, //warnings + 2, //infos + new String[] { "test.hpp", "test2.hpp", "test3.hpp" }, + new String[] { "[ skipping 2 instantiation contexts, use -ftemplate-backtrace-limit=0 to disable ]", + "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/misc/org/eclipse/cdt/core/preferences/tests/TestScopeOfBuildConfigResourceChangesPreference.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/preferences/tests/ScopeOfBuildConfigResourceChangesPreferenceTests.java index 8d681ce381d..e65d53c0792 100644 --- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/preferences/tests/TestScopeOfBuildConfigResourceChangesPreference.java +++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/preferences/tests/ScopeOfBuildConfigResourceChangesPreferenceTests.java @@ -29,7 +29,7 @@ import junit.framework.TestSuite; * * @author Simeon Andreev */ -public class TestScopeOfBuildConfigResourceChangesPreference extends TestCase { +public class ScopeOfBuildConfigResourceChangesPreferenceTests extends TestCase { private static final String PREFERENCE_NAME = CCorePreferenceConstants.PREF_BUILD_CONFIGS_RESOURCE_CHANGES; @@ -37,7 +37,7 @@ public class TestScopeOfBuildConfigResourceChangesPreference extends TestCase { private boolean oldDefaultScopeValue; public static Test suite() { - return new TestSuite(TestScopeOfBuildConfigResourceChangesPreference.class); + return new TestSuite(ScopeOfBuildConfigResourceChangesPreferenceTests.class); } @Override diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/winreg/tests/WinRegTests.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/winreg/tests/WinRegTests.java index b0c3d005b5c..d9be3a28dab 100644 --- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/winreg/tests/WinRegTests.java +++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/winreg/tests/WinRegTests.java @@ -30,7 +30,7 @@ public class WinRegTests extends TestCase { assertEquals("C:\\Program Files", value); } else { // Should be null on non-Windows platforms - assertNotNull(registry); + assertNull(registry); } } @@ -43,7 +43,7 @@ public class WinRegTests extends TestCase { assertNull(value); } else { // Should be null on non-Windows platforms - assertNotNull(registry); + assertNull(registry); } } } diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/CdtVariableResolverTest.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/CdtVariableResolverTest.java index 362336f1c6a..5d202c7894a 100644 --- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/CdtVariableResolverTest.java +++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/CdtVariableResolverTest.java @@ -13,6 +13,8 @@ *******************************************************************************/ package org.eclipse.cdt.utils; +import static org.junit.Assert.assertNotEquals; + import org.eclipse.cdt.core.cdtvariables.CdtVariableException; import org.eclipse.cdt.core.cdtvariables.ICdtVariableStatus; import org.eclipse.cdt.utils.cdtvariables.CdtVariableResolver; @@ -23,6 +25,7 @@ import junit.framework.TestCase; import junit.framework.TestSuite; public class CdtVariableResolverTest extends TestCase { + private static String acceptedChars = "\\<>&é\"'(§è!çà |@#^¨* []?./+,;:=~)"; public static Test suite() { return new TestSuite(CdtVariableResolverTest.class); @@ -35,12 +38,30 @@ public class CdtVariableResolverTest extends TestCase { if (macroName.equals("null")) { return null; } + if (macroName.equals("op")) { + return "op"; + } + if (macroName.equals("ro")) { + return "ro"; + } if (macroName.equals("loop")) { return "${LOOP}"; } if (macroName.equals("LOOP")) { return "${loop}"; } + if (macroName.equals("VAR1")) { + return "var1"; + } + if (macroName.equals("VAR2")) { + return "var\n2"; + } + if (macroName.equals("VAR3")) { + return "var3"; + } + if (macroName.equals(acceptedChars)) { + return "OK"; + } if (macroName.equals("throw")) { throw new CdtVariableException(ICdtVariableStatus.TYPE_MACRO_UNDEFINED, null, null, null); } @@ -64,50 +85,62 @@ public class CdtVariableResolverTest extends TestCase { private MockSubstitutor mockSubstitutor = new MockSubstitutor(); + //wrapper method to make code easier to read + private String resolveToString(String key) throws CdtVariableException { + return CdtVariableResolver.resolveToString(key, mockSubstitutor); + } + public void testResolveToString() throws CdtVariableException { - assertEquals("", CdtVariableResolver.resolveToString(null, mockSubstitutor)); - assertEquals("", CdtVariableResolver.resolveToString("", mockSubstitutor)); - assertEquals("Text", CdtVariableResolver.resolveToString("Text", mockSubstitutor)); - assertEquals("#Macro#", CdtVariableResolver.resolveToString("${Macro}", mockSubstitutor)); - assertEquals("", CdtVariableResolver.resolveToString("${}", mockSubstitutor)); - assertEquals("${Nomacro", CdtVariableResolver.resolveToString("${Nomacro", mockSubstitutor)); - assertEquals("Nomacro}", CdtVariableResolver.resolveToString("Nomacro}", mockSubstitutor)); - assertEquals("Text/#Macro#", CdtVariableResolver.resolveToString("Text/${Macro}", mockSubstitutor)); - assertEquals("#Macro#/Text", CdtVariableResolver.resolveToString("${Macro}/Text", mockSubstitutor)); - assertEquals("#Macro1#/#Macro2#", CdtVariableResolver.resolveToString("${Macro1}/${Macro2}", mockSubstitutor)); - assertEquals("${Macro}", CdtVariableResolver.resolveToString("\\${Macro}", mockSubstitutor)); - assertEquals("${Macro}:#Macro#", CdtVariableResolver.resolveToString("\\${Macro}:${Macro}", mockSubstitutor)); - assertEquals("\\#Macro#", CdtVariableResolver.resolveToString("\\\\${Macro}", mockSubstitutor)); - assertEquals("\\${Macro}", CdtVariableResolver.resolveToString("\\\\\\${Macro}", mockSubstitutor)); - assertEquals("C:\\tmp\\", CdtVariableResolver.resolveToString("C:\\tmp\\", mockSubstitutor)); - - assertEquals("#workspace_loc:#Macro##", - CdtVariableResolver.resolveToString("${workspace_loc:${Macro}}", mockSubstitutor)); - assertEquals("#workspace_loc:#Macro1#/#Macro2##", - CdtVariableResolver.resolveToString("${workspace_loc:${Macro1}/${Macro2}}", mockSubstitutor)); + assertEquals("", resolveToString(null)); + assertEquals("", resolveToString("")); + assertEquals("Text", resolveToString("Text")); + assertEquals("#Macro#", resolveToString("${Macro}")); + assertEquals("", resolveToString("${}")); + assertEquals("${Nomacro", resolveToString("${Nomacro")); + assertEquals("Nomacro}", resolveToString("Nomacro}")); + assertEquals("Text/#Macro#", resolveToString("Text/${Macro}")); + assertEquals("#Macro#/Text", resolveToString("${Macro}/Text")); + assertEquals("#Macro1#/#Macro2#", resolveToString("${Macro1}/${Macro2}")); + assertEquals("#=Macro#", resolveToString("${=Macro}")); + assertEquals("#=Macro#:#Macro#", resolveToString("${=Macro}:${Macro}")); + assertEquals("\\#Macro#", resolveToString("\\${Macro}")); + assertEquals("\\#=Macro#", resolveToString("\\${=Macro}")); + assertEquals("Text/#=Macro#", resolveToString("Text/${=Macro}")); + assertEquals("Text/#=Macro#text", resolveToString("Text/${=Macro}text")); + assertEquals("Text/#Macro#text", resolveToString("Text/${Macro}text")); + assertEquals("Text/#Macro#text", resolveToString("Text/${Mac${ro}}text")); + assertEquals("C:\\tmp\\", resolveToString("C:\\tmp\\")); + assertEquals("OK", resolveToString("${" + acceptedChars + "}")); + //resolve should only resolve 1 level deep + assertNotEquals(resolveToString("${LOOP}"), resolveToString(resolveToString("${LOOP}"))); + + assertEquals("#workspace_loc:#Macro##", resolveToString("${workspace_loc:${Macro}}")); + assertEquals("#workspace_loc:#Macro1#/#Macro2##", resolveToString("${workspace_loc:${Macro1}/${Macro2}}")); assertEquals("#workspace_loc:#project_loc:/#Macro###", - CdtVariableResolver.resolveToString("${workspace_loc:${project_loc:/${Macro}}}", mockSubstitutor)); + resolveToString("${workspace_loc:${project_loc:/${Macro}}}")); + assertEquals("${ignored}\n${multiline}", resolveToString("${ignored}\n${multiline}")); + assertEquals("var1 var\n2 var3", resolveToString("${VAR1} ${VAR2} ${VAR3}")); } public void testExceptions() throws CdtVariableException { // test exceptions try { - assertEquals("Unreacheable", CdtVariableResolver.resolveToString("${null}", mockSubstitutor)); + assertEquals("Unreacheable", resolveToString("${null}")); fail("Exception expected"); } catch (CdtVariableException e) { // expected behavior } try { - assertEquals("Unreacheable", CdtVariableResolver.resolveToString("${throw}", mockSubstitutor)); + assertEquals("Unreacheable", resolveToString("${throw}")); fail("Exception expected"); } catch (CdtVariableException e) { // expected behavior } // make sure there is no infinite loop - assertEquals("${LOOP}", CdtVariableResolver.resolveToString("${loop}", mockSubstitutor)); + assertEquals("${LOOP}", resolveToString("${loop}")); } public void testAsList() throws CdtVariableException { diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/AllLanguageTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/AllLanguageTestSuite.java index 79c5dc7fe4d..2301e0d436c 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/AllLanguageTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/AllLanguageTestSuite.java @@ -18,11 +18,12 @@ import junit.framework.TestSuite; /** * @author crecoskie - * + * @deprecated In preparation for moving to JUnit5 test suites are deprecated. See Bug 569839 */ -public class AllLanguageTests extends TestSuite { +@Deprecated +public class AllLanguageTestSuite extends TestSuite { public static Test suite() { - TestSuite suite = new AllLanguageTests(); + TestSuite suite = new AllLanguageTestSuite(); suite.addTest(LanguageInheritanceTests.suite()); diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/AllLanguageSettingsProvidersCoreTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/AllLanguageSettingsProvidersCoreTestSuite.java index 126b115341c..e8c6498023e 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/AllLanguageSettingsProvidersCoreTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/AllLanguageSettingsProvidersCoreTestSuite.java @@ -18,19 +18,21 @@ import junit.framework.TestSuite; /** * Test suite to cover core Language Settings Providers functionality. + * @deprecated In preparation for moving to JUnit5 test suites are deprecated. See Bug 569839 */ -public class AllLanguageSettingsProvidersCoreTests { +@Deprecated +public class AllLanguageSettingsProvidersCoreTestSuite { public static void main(String[] args) { junit.textui.TestRunner.run(suite()); } public static Test suite() { - TestSuite suite = new TestSuite(AllLanguageSettingsProvidersCoreTests.class.getName()); + TestSuite suite = new TestSuite(AllLanguageSettingsProvidersCoreTestSuite.class.getName()); suite.addTest(LanguageSettingsExtensionsTests.suite()); suite.addTest(LanguageSettingsManagerTests.suite()); suite.addTest(LanguageSettingsSerializableProviderTests.suite()); - suite.addTest(LanguageSettingsPersistenceProjectTests.suite()); + // Test converted to JUnit5: suite.addTest(LanguageSettingsPersistenceProjectTests.suite()); suite.addTest(LanguageSettingsListenersTests.suite()); suite.addTest(LanguageSettingsScannerInfoProviderTests.suite()); suite.addTest(LanguageSettingsProviderReferencedProjectsTests.suite()); diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsPersistenceProjectTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsPersistenceProjectTests.java index 9ff5fd507b6..c2825c761d9 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsPersistenceProjectTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsPersistenceProjectTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2013 Andrew Gvozdev and others. + * Copyright (c) 2009, 2020 Andrew Gvozdev and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -14,6 +14,13 @@ package org.eclipse.cdt.core.language.settings.providers; +import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -26,7 +33,7 @@ import org.eclipse.cdt.core.settings.model.ICProjectDescription; import org.eclipse.cdt.core.settings.model.WriteAccessException; import org.eclipse.cdt.core.testplugin.CModelMock; import org.eclipse.cdt.core.testplugin.ResourceHelper; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; +import org.eclipse.cdt.core.testplugin.util.BaseTestCase5; import org.eclipse.cdt.internal.core.XmlUtil; import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsProvidersSerializer; import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager; @@ -34,15 +41,16 @@ import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.IPath; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import org.w3c.dom.Document; import org.w3c.dom.Element; -import junit.framework.TestSuite; - /** * Test cases testing LanguageSettingsProvider functionality related to persistence. */ -public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { +public class LanguageSettingsPersistenceProjectTests extends BaseTestCase5 { // These should match extension points defined in plugin.xml private static final String EXTENSION_BASE_PROVIDER_ID = LanguageSettingsExtensionsTests.EXTENSION_BASE_PROVIDER_ID; private static final String EXTENSION_BASE_PROVIDER_NAME = LanguageSettingsExtensionsTests.EXTENSION_BASE_PROVIDER_NAME; @@ -130,39 +138,9 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { } } - /** - * Constructor. - * @param name - name of the test. - */ - public LanguageSettingsPersistenceProjectTests(String name) { - super(name); - } - - @Override - protected void setUp() throws Exception { - super.setUp(); - } - - @Override - protected void tearDown() throws Exception { + @AfterEach + protected void tearDownLocal() throws Exception { LanguageSettingsManager.setWorkspaceProviders(null); - super.tearDown(); // includes ResourceHelper cleanup - } - - /** - * @return - new TestSuite. - */ - public static TestSuite suite() { - return new TestSuite(LanguageSettingsPersistenceProjectTests.class); - } - - /** - * main function of the class. - * - * @param args - arguments - */ - public static void main(String[] args) { - junit.textui.TestRunner.run(suite()); } /** @@ -195,6 +173,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { /** * Persist and reload when no customized providers are defined in the workspace. */ + @Test public void testWorkspacePersistence_NoProviders() throws Exception { // serialize language settings of user defined providers (on workspace level) LanguageSettingsProvidersSerializer.serializeLanguageSettingsWorkspace(); @@ -206,6 +185,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { /** * Make sure providers in configuration cannot be modified accidentally outside of API. */ + @Test public void testProjectDescription_PreventBackDoorAccess() throws Exception { // create a project IProject project = ResourceHelper.createCDTProjectWithConfig(getName()); @@ -239,6 +219,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { /** * Test assigning providers to read-only vs. writable configuration descriptions. */ + @Test public void testProjectDescription_ReadWriteDescription() throws Exception { // create a project IProject project = ResourceHelper.createCDTProjectWithConfig(getName()); @@ -367,6 +348,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { /** * Persist and reload a customized provider defined in the workspace. */ + @Test public void testWorkspacePersistence_ModifiedExtensionProvider() throws Exception { List<ICLanguageSettingEntry> entries = new ArrayList<>(); entries.add(new CIncludePathEntry("path0", 0)); @@ -416,6 +398,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { /** * Check persistence of unmodified extension provider in the workspace. */ + @Test public void testWorkspacePersistence_UnmodifiedExtensionProvider() throws Exception { List<ICLanguageSettingEntry> extensionEntries = new ArrayList<>(); extensionEntries.add(EXTENSION_SERIALIZABLE_PROVIDER_ENTRY); @@ -463,6 +446,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { /** * Test persistence of global providers in the workspace. */ + @Test public void testWorkspacePersistence_GlobalProvider() throws Exception { { // get the raw extension provider @@ -498,6 +482,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { /** * Test persistence of global providers with ID matching an extension provider in the workspace. */ + @Test public void testWorkspacePersistence_ShadowedExtensionProvider() throws Exception { { // get the raw extension provider @@ -569,6 +554,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { /** * Test serialization of providers to project storage. */ + @Test public void testProjectPersistence_SerializableProviderDOM() throws Exception { Element rootElement = null; @@ -631,6 +617,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { /** * Test User language settings provider defined as extension in cdt.ui. */ + @Test public void testProjectPersistence_UserProviderDOM() throws Exception { Element rootElement = null; @@ -695,6 +682,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { /** * Test serialization of providers to project storage where the project has multiple configurations. */ + @Test public void testProjectPersistence_TwoConfigurationsDOM() throws Exception { Element rootElement = null; @@ -837,6 +825,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { /** * Test serialization of providers subclassing {@link LanguageSettingsSerializableProvider}. */ + @Test public void testProjectPersistence_SubclassedSerializableProviderDOM() throws Exception { Element rootElement = null; @@ -898,6 +887,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { /** * Serialization of providers exactly equal extension providers. */ + @Test public void testProjectPersistence_ReferenceExtensionProviderDOM() throws Exception { Element rootElement = null; @@ -953,6 +943,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { /** * Test serialization of providers overriding/shadowing extension providers. */ + @Test public void testProjectPersistence_OverrideExtensionProviderDOM() throws Exception { Element rootElement = null; @@ -1013,6 +1004,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { /** * Test serialization flavors in one storage. */ + @Test public void testProjectPersistence_MixedProvidersDOM() throws Exception { Element rootElement = null; @@ -1107,6 +1099,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { /** * Test serialization of real project. */ + @Test public void testProjectPersistence_RealProject() throws Exception { IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName()); IFile xmlStorageFilePrj = project.getFile(LANGUAGE_SETTINGS_PROJECT_XML); @@ -1224,17 +1217,17 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { String xmlStorageFileLocation = xmlStorageFilePrj.getLocation().toOSString(); java.io.File xmlFile = new java.io.File(xmlStorageFileLocation); xmlFile.delete(); - assertFalse("File " + xmlFile + " still exist", xmlFile.exists()); + assertNotExists(xmlFile); java.io.File xmlFileOut = new java.io.File(xmlPrjOutOfTheWay); xmlFileOut.renameTo(xmlFile); - assertTrue("File " + xmlFile + " does not exist", xmlFile.exists()); - assertFalse("File " + xmlFileOut + " still exist", xmlFileOut.exists()); + assertExists(xmlFile); + assertNotExists(xmlFileOut); // Wait out in case indexer thread hijacks refreshLocal(), see bug 415970 waitForIndexer(CCorePlugin.getDefault().getCoreModel().create(project)); // Refresh storage in workspace xmlStorageFilePrj.refreshLocal(IResource.DEPTH_ZERO, null); - assertTrue("File " + xmlStorageFilePrj + " does not exist", xmlStorageFilePrj.exists()); + assertExists(xmlStorageFilePrj); // and close project.close(null); @@ -1266,6 +1259,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { /** * Test case when the storage is split between project and workspace area. */ + @Test public void testProjectPersistence_SplitStorageDOM() throws Exception { Element prjStorageElement = null; Element wspStorageElement = null; @@ -1343,6 +1337,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { /** * Test split storage in a real project. */ + @Test public void testProjectPersistence_RealProjectSplitStorage() throws Exception { IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName()); IFile xmlStorageFilePrj; @@ -1472,17 +1467,17 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { String xmlStorageFilePrjLocation = xmlStorageFilePrj.getLocation().toOSString(); java.io.File xmlFile = new java.io.File(xmlStorageFilePrjLocation); xmlFile.delete(); - assertFalse("File " + xmlFile + " still exist", xmlFile.exists()); + assertNotExists(xmlFile); java.io.File xmlFileOut = new java.io.File(xmlPrjOutOfTheWay); xmlFileOut.renameTo(xmlFile); - assertTrue("File " + xmlFile + " does not exist", xmlFile.exists()); - assertFalse("File " + xmlFileOut + " still exist", xmlFileOut.exists()); + assertExists(xmlFile); + assertNotExists(xmlFileOut); // Wait out in case indexer thread hijacks refreshLocal(), see bug 415970 waitForIndexer(CCorePlugin.getDefault().getCoreModel().create(project)); // Refresh storage in workspace xmlStorageFilePrj.refreshLocal(IResource.DEPTH_ZERO, null); - assertTrue("File " + xmlStorageFilePrj + " does not exist", xmlStorageFilePrj.exists()); + assertExists(xmlStorageFilePrj); // and close project.close(null); @@ -1492,11 +1487,11 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { // Move workspace storage back java.io.File xmlWspFile = new java.io.File(xmlStorageFileWspLocation); xmlWspFile.delete(); - assertFalse("File " + xmlWspFile + " still exist", xmlWspFile.exists()); + assertNotExists(xmlWspFile); java.io.File xmlWspFileOut = new java.io.File(xmlWspOutOfTheWay); xmlWspFileOut.renameTo(xmlWspFile); - assertTrue("File " + xmlWspFile + " does not exist", xmlWspFile.exists()); - assertFalse("File " + xmlWspFileOut + " still exist", xmlWspFileOut.exists()); + assertExists(xmlWspFile); + assertNotExists(xmlWspFileOut); } { @@ -1525,6 +1520,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { /** * Test serialization of providers referring to global shared instance. */ + @Test public void testProjectPersistence_ProviderExtensionReferenceDOM() throws Exception { Document doc = XmlUtil.newDocument(); Element storageElement = XmlUtil.appendElement(doc, ELEM_TEST); @@ -1582,6 +1578,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { /** * Walk the scenario when a provider is cloned to a configuration from extension. */ + @Test public void testProjectPersistence_ProviderExtensionCopyDOM() throws Exception { Document doc = XmlUtil.newDocument(); Element storageElement = XmlUtil.appendElement(doc, ELEM_TEST); @@ -1639,6 +1636,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { /** * Test that default settings do not cause the files to appear in the project or file-system. */ + @Test public void testProjectPersistence_Defaults() throws Exception { IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName()); IFile xmlStorageFilePrj = project.getFile(LANGUAGE_SETTINGS_PROJECT_XML); @@ -1653,6 +1651,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { /** * Test serialization of global providers exactly equal extension in workspace area. */ + @Test + @Tag(FLAKY_TEST_TAG) public void testWorkspacePersistence_ProviderExtensionCopy() throws Exception { List<ICLanguageSettingEntry> entries = new ArrayList<>(); List<ILanguageSettingsProvider> providers = new ArrayList<>(); @@ -1698,6 +1698,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { /** * Test that default settings do not cause the file to appear on the file-system. */ + @Test public void testWorkspacePersistence_Defaults() throws Exception { // reset and serialize workspace providers LanguageSettingsManager.setWorkspaceProviders(null); diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/AllCoreTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/AllCoreTestSuite.java index 9cd2ac2735f..997bf019ad6 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/AllCoreTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/AllCoreTestSuite.java @@ -14,8 +14,8 @@ *******************************************************************************/ package org.eclipse.cdt.core.model.tests; -import org.eclipse.cdt.core.language.settings.providers.AllLanguageSettingsProvidersCoreTests; -import org.eclipse.cdt.core.settings.model.AllCProjectDescriptionTests; +import org.eclipse.cdt.core.language.settings.providers.AllLanguageSettingsProvidersCoreTestSuite; +import org.eclipse.cdt.core.settings.model.AllCProjectDescriptionTestSuite; import org.eclipse.cdt.core.settings.model.PathSettingsContainerTests; import junit.framework.Test; @@ -29,19 +29,21 @@ import junit.framework.TestSuite; * * @author Judy N. Green * @since Jul 19, 2002 + * @deprecated In preparation for moving to JUnit5 test suites are deprecated. See Bug 569839 */ -public class AllCoreTests { +@Deprecated +public class AllCoreTestSuite { public static void main(String[] args) { junit.textui.TestRunner.run(suite()); } public static Test suite() { - TestSuite suite = new TestSuite(AllCoreTests.class.getName()); + TestSuite suite = new TestSuite(AllCoreTestSuite.class.getName()); // Just add more test cases here as you create them for // each class being tested - suite.addTest(AllLanguageInterfaceTests.suite()); + suite.addTest(AllLanguageInterfaceTestSuite.suite()); suite.addTest(CModelTests.suite()); suite.addTest(CModelElementsTests.suite()); suite.addTest(CModelIdentifierTests.suite()); @@ -57,14 +59,14 @@ public class AllCoreTests { suite.addTest(CPathEntryTest.suite()); //the CProjectDescriptionTests now groups all New Project Model related tests //which includes the CConfigurationDescriptionReferenceTests - suite.addTest(AllCProjectDescriptionTests.suite()); + suite.addTest(AllCProjectDescriptionTestSuite.suite()); suite.addTest(PathSettingsContainerTests.suite()); suite.addTest(ASTCacheTests.suite()); suite.addTest(AsmModelBuilderTest.suite()); suite.addTest(CModelBuilderBugsTest.suite()); - suite.addTest(Bug311189.suite()); + suite.addTest(Bug311189Tests.suite()); - suite.addTest(AllLanguageSettingsProvidersCoreTests.suite()); + suite.addTest(AllLanguageSettingsProvidersCoreTestSuite.suite()); return suite; } diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/AllLanguageInterfaceTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/AllLanguageInterfaceTestSuite.java index 795a7d8f123..32ce5922982 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/AllLanguageInterfaceTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/AllLanguageInterfaceTestSuite.java @@ -26,14 +26,16 @@ import junit.framework.TestSuite; * to be tested. * @author bnicolle * + * @deprecated In preparation for moving to JUnit5 test suites are deprecated. See Bug 569839 */ -public class AllLanguageInterfaceTests { +@Deprecated +public class AllLanguageInterfaceTestSuite { /** * */ public static Test suite() { - TestSuite suite = new TestSuite(AllLanguageInterfaceTests.class.getName()); + TestSuite suite = new TestSuite(AllLanguageInterfaceTestSuite.class.getName()); // Just add more test cases here as you create them for // each class being tested diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/Bug311189.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/Bug311189Tests.java index 4370373a8b0..e696740ec97 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/Bug311189.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/Bug311189Tests.java @@ -39,10 +39,10 @@ import junit.framework.Test; * we must ensure that we don't corrupt the set of includes in the incoming * project's metadata */ -public class Bug311189 extends BaseTestCase { +public class Bug311189Tests extends BaseTestCase { public static Test suite() { - return suite(Bug311189.class, "_"); + return suite(Bug311189Tests.class, "_"); } private IProject project; diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelElementsTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelElementsTests.java index 00920e6bb1a..04772796b82 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelElementsTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelElementsTests.java @@ -35,6 +35,7 @@ import org.eclipse.cdt.core.model.IMethodDeclaration; import org.eclipse.cdt.core.model.IMethodTemplateDeclaration; import org.eclipse.cdt.core.model.INamespace; import org.eclipse.cdt.core.model.IParent; +import org.eclipse.cdt.core.model.IPragma; import org.eclipse.cdt.core.model.ISourceRange; import org.eclipse.cdt.core.model.ISourceReference; import org.eclipse.cdt.core.model.IStructure; @@ -137,6 +138,98 @@ public class CModelElementsTests extends BaseTestCase { checkBug180815(tu); checkBug352350(tu); + + checkPragmas(tu); + } + + private void checkPragmas(ITranslationUnit tu) throws CModelException { + List pragmas = tu.getChildrenOfType(ICElement.C_PRAGMA); + + int line = 0; + { + IPragma pragma = (IPragma) pragmas.get(line++); + assertEquals("mark - before and after -", pragma.getElementName()); + assertEquals(true, pragma.getPragmaMarkInfo().get().isDividerBeforeMark()); + assertEquals(true, pragma.getPragmaMarkInfo().get().isDividerAfterMark()); + assertEquals("before and after", pragma.getPragmaMarkInfo().get().getMarkName()); + } + { + IPragma pragma = (IPragma) pragmas.get(line++); + assertEquals("mark - before", pragma.getElementName()); + assertEquals(true, pragma.getPragmaMarkInfo().get().isDividerBeforeMark()); + assertEquals(false, pragma.getPragmaMarkInfo().get().isDividerAfterMark()); + assertEquals("before", pragma.getPragmaMarkInfo().get().getMarkName()); + } + { + IPragma pragma = (IPragma) pragmas.get(line++); + assertEquals("mark after -", pragma.getElementName()); + assertEquals(false, pragma.getPragmaMarkInfo().get().isDividerBeforeMark()); + assertEquals(true, pragma.getPragmaMarkInfo().get().isDividerAfterMark()); + assertEquals("after", pragma.getPragmaMarkInfo().get().getMarkName()); + } + { + IPragma pragma = (IPragma) pragmas.get(line++); + assertEquals("mark neither", pragma.getElementName()); + assertEquals(false, pragma.getPragmaMarkInfo().get().isDividerBeforeMark()); + assertEquals(false, pragma.getPragmaMarkInfo().get().isDividerAfterMark()); + assertEquals("neither", pragma.getPragmaMarkInfo().get().getMarkName()); + } + { + IPragma pragma = (IPragma) pragmas.get(line++); + assertEquals("mark -", pragma.getElementName()); + assertEquals(true, pragma.getPragmaMarkInfo().get().isDividerBeforeMark()); + assertEquals(false, pragma.getPragmaMarkInfo().get().isDividerAfterMark()); + assertEquals("", pragma.getPragmaMarkInfo().get().getMarkName()); + } + { + IPragma pragma = (IPragma) pragmas.get(line++); + assertEquals("mark", pragma.getElementName()); + assertEquals(false, pragma.getPragmaMarkInfo().get().isDividerBeforeMark()); + assertEquals(false, pragma.getPragmaMarkInfo().get().isDividerAfterMark()); + assertEquals("", pragma.getPragmaMarkInfo().get().getMarkName()); + } + { + // region no name + IPragma pragma = (IPragma) pragmas.get(line++); + assertEquals("region", pragma.getElementName()); + assertEquals(true, pragma.getPragmaMarkInfo().get().isDividerBeforeMark()); + assertEquals(false, pragma.getPragmaMarkInfo().get().isDividerAfterMark()); + assertEquals("", pragma.getPragmaMarkInfo().get().getMarkName()); + } + { + IPragma pragma = (IPragma) pragmas.get(line++); + assertEquals("region named", pragma.getElementName()); + assertEquals(true, pragma.getPragmaMarkInfo().get().isDividerBeforeMark()); + assertEquals(true, pragma.getPragmaMarkInfo().get().isDividerAfterMark()); + assertEquals("named", pragma.getPragmaMarkInfo().get().getMarkName()); + } + { + IPragma pragma = (IPragma) pragmas.get(line++); + assertEquals("endregion", pragma.getElementName()); + assertEquals(true, pragma.getPragmaMarkInfo().get().isDividerBeforeMark()); + assertEquals(false, pragma.getPragmaMarkInfo().get().isDividerAfterMark()); + assertEquals("", pragma.getPragmaMarkInfo().get().getMarkName()); + } + { + IPragma pragma = (IPragma) pragmas.get(line++); + assertEquals("endregion endnamed", pragma.getElementName()); + assertEquals(true, pragma.getPragmaMarkInfo().get().isDividerBeforeMark()); + assertEquals(true, pragma.getPragmaMarkInfo().get().isDividerAfterMark()); + assertEquals("endnamed", pragma.getPragmaMarkInfo().get().getMarkName()); + } + { + IPragma pragma = (IPragma) pragmas.get(line++); + assertEquals("ms_struct on", pragma.getElementName()); + assertEquals(true, pragma.getPragmaMarkInfo().isEmpty()); + assertEquals(false, pragma.isPragmaOperator()); + } + { + IPragma pragma = (IPragma) pragmas.get(line++); + assertEquals("_Pragma(\"once\")", pragma.getElementName()); + assertEquals(true, pragma.getPragmaMarkInfo().isEmpty()); + assertEquals(true, pragma.isPragmaOperator()); + } + assertEquals(line, pragmas.size()); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=180815 diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelTests.java index 43d48513a15..1c71311173e 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelTests.java @@ -295,12 +295,18 @@ public class CModelTests extends TestCase { testProject.accept(new ICElementVisitor() { @Override public boolean visit(ICElement element) throws CoreException { + if (".settings".equals(element.getElementName())) { + return false; + } actual.add("visit " + element.getResource().getName()); return true; } @Override public void leave(ICElement element) throws CoreException { + if (".settings".equals(element.getElementName())) { + return; + } actual.add("leave " + element.getResource().getName()); } }); @@ -309,169 +315,181 @@ public class CModelTests extends TestCase { // bug 275609 public void testSourceExclusionFilters_275609() throws Exception { - ICProject testProject; - testProject = CProjectHelper.createCProject("bug257609", "none", IPDOMManager.ID_NO_INDEXER); - if (testProject == null) - fail("Unable to create project"); - - IFolder testFolder = testProject.getProject().getFolder("test"); - testFolder.create(true, true, monitor); - IFolder subFolder1 = testFolder.getFolder("1"); - subFolder1.create(true, true, monitor); - IFolder subFolder2 = testFolder.getFolder("2"); - subFolder2.create(true, true, monitor); - IFile file0 = testFolder.getFile("test0.c"); - file0.create(new ByteArrayInputStream(new byte[0]), true, monitor); - IFile file1 = subFolder1.getFile("test1.c"); - file1.create(new ByteArrayInputStream(new byte[0]), true, monitor); - IFile file2 = subFolder2.getFile("test2.c"); - file2.create(new ByteArrayInputStream(new byte[0]), true, monitor); - - List<ICElement> cSourceRoots = testProject.getChildrenOfType(ICElement.C_CCONTAINER); - assertEquals(1, cSourceRoots.size()); - assertEquals(testProject.getElementName(), cSourceRoots.get(0).getElementName()); - - ISourceRoot sourceRoot = (ISourceRoot) cSourceRoots.get(0); - - List<ICElement> cContainers = sourceRoot.getChildrenOfType(ICElement.C_CCONTAINER); - assertEquals(1, cContainers.size()); - assertEquals("test", cContainers.get(0).getElementName()); - - ICContainer testContainer = (ICContainer) cContainers.get(0); - - List<ICElement> subContainers = testContainer.getChildrenOfType(ICElement.C_CCONTAINER); - assertEquals(2, subContainers.size()); - assertEquals("1", subContainers.get(0).getElementName()); - assertEquals("2", subContainers.get(1).getElementName()); - Object[] nonCResources = testContainer.getNonCResources(); - assertEquals(0, nonCResources.length); - - List<ICElement> tUnits = testContainer.getChildrenOfType(ICElement.C_UNIT); - assertEquals(1, tUnits.size()); - assertEquals("test0.c", tUnits.get(0).getElementName()); - - ICProjectDescription prjDesc = CoreModel.getDefault().getProjectDescription(testProject.getProject(), true); - ICConfigurationDescription activeCfg = prjDesc.getActiveConfiguration(); - assertNotNull(activeCfg); - - // add filter to source entry - ICSourceEntry[] entries = activeCfg.getSourceEntries(); - final String sourceEntryName = entries[0].getName(); - final IPath[] exclusionPatterns = new IPath[] { new Path("test/*") }; - - ICSourceEntry entry = new CSourceEntry(sourceEntryName, exclusionPatterns, entries[0].getFlags()); - activeCfg.setSourceEntries(new ICSourceEntry[] { entry }); - - // store the changed configuration - CoreModel.getDefault().setProjectDescription(testProject.getProject(), prjDesc); - - cSourceRoots = testProject.getChildrenOfType(ICElement.C_CCONTAINER); - assertEquals(1, cSourceRoots.size()); - assertEquals(testProject.getElementName(), cSourceRoots.get(0).getElementName()); - - sourceRoot = (ISourceRoot) cSourceRoots.get(0); - - cContainers = sourceRoot.getChildrenOfType(ICElement.C_CCONTAINER); - assertEquals(1, cContainers.size()); - assertEquals("test", cContainers.get(0).getElementName()); - - testContainer = (ICContainer) cContainers.get(0); - - tUnits = testContainer.getChildrenOfType(ICElement.C_UNIT); - assertEquals(0, tUnits.size()); - - subContainers = testContainer.getChildrenOfType(ICElement.C_CCONTAINER); - assertEquals(0, subContainers.size()); - nonCResources = testContainer.getNonCResources(); - assertEquals(3, nonCResources.length); - assertEquals(subFolder1, nonCResources[0]); - assertEquals(subFolder2, nonCResources[1]); - assertEquals(file0, nonCResources[2]); - + ICProject testProject = null; try { - testProject.getProject().delete(true, true, monitor); - } catch (CoreException e) { + testProject = CProjectHelper.createCProject("bug257609", "none", IPDOMManager.ID_NO_INDEXER); + if (testProject == null) + fail("Unable to create project"); + + IFolder testFolder = testProject.getProject().getFolder("test"); + testFolder.create(true, true, monitor); + IFolder subFolder1 = testFolder.getFolder("1"); + subFolder1.create(true, true, monitor); + IFolder subFolder2 = testFolder.getFolder("2"); + subFolder2.create(true, true, monitor); + IFile file0 = testFolder.getFile("test0.c"); + file0.create(new ByteArrayInputStream(new byte[0]), true, monitor); + IFile file1 = subFolder1.getFile("test1.c"); + file1.create(new ByteArrayInputStream(new byte[0]), true, monitor); + IFile file2 = subFolder2.getFile("test2.c"); + file2.create(new ByteArrayInputStream(new byte[0]), true, monitor); + + List<ICElement> cSourceRoots = testProject.getChildrenOfType(ICElement.C_CCONTAINER); + assertEquals(1, cSourceRoots.size()); + assertEquals(testProject.getElementName(), cSourceRoots.get(0).getElementName()); + + ISourceRoot sourceRoot = (ISourceRoot) cSourceRoots.get(0); + + List<ICElement> cContainers = sourceRoot.getChildrenOfType(ICElement.C_CCONTAINER); + cContainers.removeIf(element -> ".settings".equals(element.getElementName())); + assertEquals(1, cContainers.size()); + assertEquals("test", cContainers.get(0).getElementName()); + + ICContainer testContainer = (ICContainer) cContainers.get(0); + + List<ICElement> subContainers = testContainer.getChildrenOfType(ICElement.C_CCONTAINER); + assertEquals(2, subContainers.size()); + assertEquals("1", subContainers.get(0).getElementName()); + assertEquals("2", subContainers.get(1).getElementName()); + Object[] nonCResources = testContainer.getNonCResources(); + assertEquals(0, nonCResources.length); + + List<ICElement> tUnits = testContainer.getChildrenOfType(ICElement.C_UNIT); + assertEquals(1, tUnits.size()); + assertEquals("test0.c", tUnits.get(0).getElementName()); + + ICProjectDescription prjDesc = CoreModel.getDefault().getProjectDescription(testProject.getProject(), true); + ICConfigurationDescription activeCfg = prjDesc.getActiveConfiguration(); + assertNotNull(activeCfg); + + // add filter to source entry + ICSourceEntry[] entries = activeCfg.getSourceEntries(); + final String sourceEntryName = entries[0].getName(); + final IPath[] exclusionPatterns = new IPath[] { new Path("test/*") }; + + ICSourceEntry entry = new CSourceEntry(sourceEntryName, exclusionPatterns, entries[0].getFlags()); + activeCfg.setSourceEntries(new ICSourceEntry[] { entry }); + + // store the changed configuration + CoreModel.getDefault().setProjectDescription(testProject.getProject(), prjDesc); + + cSourceRoots = testProject.getChildrenOfType(ICElement.C_CCONTAINER); + assertEquals(1, cSourceRoots.size()); + assertEquals(testProject.getElementName(), cSourceRoots.get(0).getElementName()); + + sourceRoot = (ISourceRoot) cSourceRoots.get(0); + + cContainers = sourceRoot.getChildrenOfType(ICElement.C_CCONTAINER); + cContainers.removeIf(element -> ".settings".equals(element.getElementName())); + assertEquals(1, cContainers.size()); + assertEquals("test", cContainers.get(0).getElementName()); + + testContainer = (ICContainer) cContainers.get(0); + + tUnits = testContainer.getChildrenOfType(ICElement.C_UNIT); + assertEquals(0, tUnits.size()); + + subContainers = testContainer.getChildrenOfType(ICElement.C_CCONTAINER); + assertEquals(0, subContainers.size()); + nonCResources = testContainer.getNonCResources(); + assertEquals(3, nonCResources.length); + assertEquals(subFolder1, nonCResources[0]); + assertEquals(subFolder2, nonCResources[1]); + assertEquals(file0, nonCResources[2]); + } finally { + try { + if (testProject != null) { + testProject.getProject().delete(true, true, monitor); + } + } catch (CoreException e) { + } } } // bug 179474 public void testSourceExclusionFilters_179474() throws Exception { - ICProject testProject; - testProject = CProjectHelper.createCProject("bug179474", "none", IPDOMManager.ID_NO_INDEXER); - if (testProject == null) - fail("Unable to create project"); + ICProject testProject = null; + try { + testProject = CProjectHelper.createCProject("bug179474", "none", IPDOMManager.ID_NO_INDEXER); + if (testProject == null) + fail("Unable to create project"); - IFolder subFolder = testProject.getProject().getFolder("sub"); - subFolder.create(true, true, monitor); - IFile fileA = testProject.getProject().getFile("a.cpp"); - fileA.create(new ByteArrayInputStream(new byte[0]), true, monitor); - IFile fileB = subFolder.getFile("b.cpp"); - fileB.create(new ByteArrayInputStream(new byte[0]), true, monitor); + IFolder subFolder = testProject.getProject().getFolder("sub"); + subFolder.create(true, true, monitor); + IFile fileA = testProject.getProject().getFile("a.cpp"); + fileA.create(new ByteArrayInputStream(new byte[0]), true, monitor); + IFile fileB = subFolder.getFile("b.cpp"); + fileB.create(new ByteArrayInputStream(new byte[0]), true, monitor); - List<ICElement> cSourceRoots = testProject.getChildrenOfType(ICElement.C_CCONTAINER); - assertEquals(1, cSourceRoots.size()); - assertEquals(testProject.getElementName(), cSourceRoots.get(0).getElementName()); + List<ICElement> cSourceRoots = testProject.getChildrenOfType(ICElement.C_CCONTAINER); + assertEquals(1, cSourceRoots.size()); + assertEquals(testProject.getElementName(), cSourceRoots.get(0).getElementName()); - ISourceRoot sourceRoot = (ISourceRoot) cSourceRoots.get(0); + ISourceRoot sourceRoot = (ISourceRoot) cSourceRoots.get(0); - List<ICElement> cContainers = sourceRoot.getChildrenOfType(ICElement.C_CCONTAINER); - assertEquals(1, cContainers.size()); - assertEquals(subFolder.getName(), cContainers.get(0).getElementName()); + List<ICElement> cContainers = sourceRoot.getChildrenOfType(ICElement.C_CCONTAINER); + cContainers.removeIf(element -> ".settings".equals(element.getElementName())); + assertEquals(1, cContainers.size()); + assertEquals(subFolder.getName(), cContainers.get(0).getElementName()); - ICContainer subContainer = (ICContainer) cContainers.get(0); + ICContainer subContainer = (ICContainer) cContainers.get(0); - List<ICElement> tUnits = subContainer.getChildrenOfType(ICElement.C_UNIT); - assertEquals(1, tUnits.size()); - assertEquals(fileB.getName(), tUnits.get(0).getElementName()); + List<ICElement> tUnits = subContainer.getChildrenOfType(ICElement.C_UNIT); + assertEquals(1, tUnits.size()); + assertEquals(fileB.getName(), tUnits.get(0).getElementName()); - tUnits = sourceRoot.getChildrenOfType(ICElement.C_UNIT); - assertEquals(1, tUnits.size()); - assertEquals(fileA.getName(), tUnits.get(0).getElementName()); + tUnits = sourceRoot.getChildrenOfType(ICElement.C_UNIT); + assertEquals(1, tUnits.size()); + assertEquals(fileA.getName(), tUnits.get(0).getElementName()); - ICProjectDescription prjDesc = CoreModel.getDefault().getProjectDescription(testProject.getProject(), true); - ICConfigurationDescription activeCfg = prjDesc.getActiveConfiguration(); - assertNotNull(activeCfg); + ICProjectDescription prjDesc = CoreModel.getDefault().getProjectDescription(testProject.getProject(), true); + ICConfigurationDescription activeCfg = prjDesc.getActiveConfiguration(); + assertNotNull(activeCfg); - // add filter to source entry - ICSourceEntry[] entries = activeCfg.getSourceEntries(); - final String sourceEntryName = entries[0].getName(); - final IPath[] exclusionPatterns = new IPath[] { new Path("**/*.cpp") }; + // add filter to source entry + ICSourceEntry[] entries = activeCfg.getSourceEntries(); + final String sourceEntryName = entries[0].getName(); + final IPath[] exclusionPatterns = new IPath[] { new Path("**/*.cpp") }; - ICSourceEntry entry = new CSourceEntry(sourceEntryName, exclusionPatterns, entries[0].getFlags()); - activeCfg.setSourceEntries(new ICSourceEntry[] { entry }); + ICSourceEntry entry = new CSourceEntry(sourceEntryName, exclusionPatterns, entries[0].getFlags()); + activeCfg.setSourceEntries(new ICSourceEntry[] { entry }); - // store the changed configuration - CoreModel.getDefault().setProjectDescription(testProject.getProject(), prjDesc); + // store the changed configuration + CoreModel.getDefault().setProjectDescription(testProject.getProject(), prjDesc); - cSourceRoots = testProject.getChildrenOfType(ICElement.C_CCONTAINER); - assertEquals(1, cSourceRoots.size()); - assertEquals(testProject.getElementName(), cSourceRoots.get(0).getElementName()); + cSourceRoots = testProject.getChildrenOfType(ICElement.C_CCONTAINER); + assertEquals(1, cSourceRoots.size()); + assertEquals(testProject.getElementName(), cSourceRoots.get(0).getElementName()); - sourceRoot = (ISourceRoot) cSourceRoots.get(0); + sourceRoot = (ISourceRoot) cSourceRoots.get(0); - cContainers = sourceRoot.getChildrenOfType(ICElement.C_CCONTAINER); - assertEquals(1, cContainers.size()); - assertEquals(subFolder.getName(), cContainers.get(0).getElementName()); + cContainers = sourceRoot.getChildrenOfType(ICElement.C_CCONTAINER); + cContainers.removeIf(element -> ".settings".equals(element.getElementName())); + assertEquals(1, cContainers.size()); + assertEquals(subFolder.getName(), cContainers.get(0).getElementName()); - subContainer = (ICContainer) cContainers.get(0); + subContainer = (ICContainer) cContainers.get(0); - tUnits = subContainer.getChildrenOfType(ICElement.C_UNIT); - assertEquals(0, tUnits.size()); + tUnits = subContainer.getChildrenOfType(ICElement.C_UNIT); + assertEquals(0, tUnits.size()); - tUnits = sourceRoot.getChildrenOfType(ICElement.C_UNIT); - assertEquals(0, tUnits.size()); + tUnits = sourceRoot.getChildrenOfType(ICElement.C_UNIT); + assertEquals(0, tUnits.size()); - Object[] nonCResources = subContainer.getNonCResources(); - assertEquals(1, nonCResources.length); - assertEquals(fileB, nonCResources[0]); + Object[] nonCResources = subContainer.getNonCResources(); + assertEquals(1, nonCResources.length); + assertEquals(fileB, nonCResources[0]); - nonCResources = sourceRoot.getNonCResources(); - assertTrue(Arrays.asList(nonCResources).contains(fileA)); - - try { - testProject.getProject().delete(true, true, monitor); - } catch (CoreException e) { + nonCResources = sourceRoot.getNonCResources(); + assertTrue(Arrays.asList(nonCResources).contains(fileA)); + } finally { + try { + if (testProject != null) { + testProject.getProject().delete(true, true, monitor); + } + } catch (CoreException e) { + } } } diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/TranslationUnitBaseTest.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/TranslationUnitBaseTest.java index 398ac110b33..ccd886b751e 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/TranslationUnitBaseTest.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/TranslationUnitBaseTest.java @@ -34,7 +34,7 @@ import junit.framework.TestCase; * @author jcamelon * */ -public class TranslationUnitBaseTest extends TestCase { +public abstract class TranslationUnitBaseTest extends TestCase { /** * */ diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/AllCProjectDescriptionTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/AllCProjectDescriptionTestSuite.java index 632ec266b32..8019a4a7733 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/AllCProjectDescriptionTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/AllCProjectDescriptionTestSuite.java @@ -16,18 +16,22 @@ package org.eclipse.cdt.core.settings.model; import junit.framework.Test; import junit.framework.TestSuite; -public class AllCProjectDescriptionTests { +/** + * @deprecated In preparation for moving to JUnit5 test suites are deprecated. See Bug 569839 + */ +@Deprecated +public class AllCProjectDescriptionTestSuite { public static void main(String[] args) { junit.textui.TestRunner.run(suite()); } public static Test suite() { - TestSuite suite = new TestSuite(AllCProjectDescriptionTests.class.getName()); + TestSuite suite = new TestSuite(AllCProjectDescriptionTestSuite.class.getName()); // Just add more test cases here as you create them for // each class being tested suite.addTest(CConfigurationDescriptionReferenceTests.suite()); - suite.addTest(CConfigurationDescriptionExportSettings.suite()); + suite.addTest(CConfigurationDescriptionExportSettingsTests.suite()); suite.addTest(ExternalSettingsProviderTests.suite()); suite.addTest(CfgSettingsTests.suite()); suite.addTest(CProjectDescriptionDeltaTests.suite()); diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CConfigurationDescriptionExportSettings.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CConfigurationDescriptionExportSettingsTests.java index a5a3751e864..add611d7b67 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CConfigurationDescriptionExportSettings.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CConfigurationDescriptionExportSettingsTests.java @@ -40,12 +40,12 @@ import junit.framework.TestSuite; * This functionality is provided by the CfgExportSettingContainerFactory which plugins * into the CExternalSettingsManager */ -public class CConfigurationDescriptionExportSettings extends BaseTestCase { +public class CConfigurationDescriptionExportSettingsTests extends BaseTestCase { CoreModel coreModel = CoreModel.getDefault(); public static TestSuite suite() { - return suite(CConfigurationDescriptionExportSettings.class, "_"); + return suite(CConfigurationDescriptionExportSettingsTests.class, "_"); } // Setting entries 1 diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionDeltaTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionDeltaTests.java index 3b864e88416..c6ff685dfa3 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionDeltaTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionDeltaTests.java @@ -971,6 +971,8 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase { assertNotNull(prjDescription); assertEquals(2, prjDescription.getConfigurations().length); + prjDescription.setConfigurationRelations(ICProjectDescription.CONFIGS_INDEPENDENT); + ICConfigurationDescription cfgDescription0 = prjDescription.getConfigurations()[0]; assertNotNull(cfgDescription0); assertSame(cfgDescription0, prjDescription.getDefaultSettingConfiguration()); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/FileBasePluginTestCase.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/FileBasePluginTestCase.java index c906818fd72..2166dc55452 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/FileBasePluginTestCase.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/FileBasePluginTestCase.java @@ -35,7 +35,7 @@ import junit.framework.TestCase; /** * @author dsteffle */ -public class FileBasePluginTestCase extends TestCase { +public abstract class FileBasePluginTestCase extends TestCase { static NullProgressMonitor monitor; static IWorkspace workspace; static IProject project; diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ParserTestSuite.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ParserTestSuite.java index f74906d08d7..753508e692e 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ParserTestSuite.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ParserTestSuite.java @@ -27,7 +27,9 @@ import junit.framework.TestSuite; /** * Combines all tests for the parsers. + * @deprecated In preparation for moving to JUnit5 test suites are deprecated. See Bug 569839 */ +@Deprecated public class ParserTestSuite extends TestCase { public static Test suite() { TestSuite suite = new TestSuite(ParserTestSuite.class.getName()); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java index 96b72dcd5bf..3290710927f 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java @@ -4716,7 +4716,7 @@ public class AST2CPPTests extends AST2CPPTestBase { IASTTranslationUnit tu = parse(getAboveComment(), CPP); ICPPASTCastExpression dynamic_cast = (ICPPASTCastExpression) ((IASTEqualsInitializer) ((IASTSimpleDeclaration) ((IASTDeclarationStatement) ((IASTCompoundStatement) ((IASTFunctionDefinition) tu .getDeclarations()[2]).getBody()).getStatements()[0]).getDeclaration()).getDeclarators()[0] - .getInitializer()).getInitializerClause(); + .getInitializer()).getInitializerClause(); assertEquals(dynamic_cast.getOperator(), ICPPASTCastExpression.op_dynamic_cast); } @@ -11382,6 +11382,19 @@ public class AST2CPPTests extends AST2CPPTestBase { parseAndCheckBindings(getAboveComment(), CPP, true /* use GNU extensions */); } + // enum class TestEnum : char { + // }; + // + // void bar(__underlying_type(TestEnum) as) { + // } + // + // void foo() { + // bar('a'); // Invalid arguments 'Candidates are: void bar(@120932903)' + // } + public void testUnderlyingType_568625() throws Exception { + parseAndCheckBindings(getAboveComment(), CPP, true /* use GNU extensions */); + } + // void ptrFunc(void*); // void intFunc(int); // void foo(int* pi, unsigned i) { @@ -13574,4 +13587,140 @@ public class AST2CPPTests extends AST2CPPTestBase { public void testExplicitSpecPointerType_562697() throws Exception { parseAndCheckBindings(); } + + // using MyBool = bool; + // + // class Foo { + // }; + // + // template<typename T = void> + // class Templated { + // }; + // + // template<bool> + // class Test { + // public: + // constexpr static int false_val = 0; + // }; + // + // template<> + // class Test<true> { + // public: + // constexpr static int true_val = 0; + // }; + // + // enum Enum { + // }; + // + // enum EnumChar : char { + // }; + // + // template<typename T, typename U> + // class TemplateArgs { + // public: + // constexpr static bool Value = __is_same(T, U); + // }; + // + // int main() { + // Test<__is_same(bool, bool)>::true_val; + // Test<__is_same_as(bool, bool)>::true_val; + // Test<__is_same(bool, bool&)>::false_val; + // Test<__is_same(bool, bool*)>::false_val; + // Test<__is_same(bool*, bool*)>::true_val; + // Test<__is_same(bool&, bool&)>::true_val; + // Test<__is_same(bool[], bool[])>::true_val; + // Test<__is_same(bool[], bool*)>::false_val; + // Test<__is_same(bool, const volatile MyBool)>::false_val; + // Test<__is_same(bool, MyBool)>::true_val; + // Test<__is_same(bool, Foo)>::false_val; + // Test<__is_same(Templated<bool>, Templated<Foo>)>::false_val; + // Test<__is_same(Templated<>, Templated<void>)>::true_val; + // + // auto func = []() { + // }; + // auto func2 = []() { + // }; + // Test<__is_same(decltype(func), decltype(func))>::true_val; + // Test<__is_same(decltype(func), decltype(func2))>::false_val; + // + // Test<__is_same(void (*)(int), void (*)(int))>::true_val; + // Test<__is_same(void (*)(bool), void (*)(MyBool))>::true_val; + // + // Test<__is_same(Enum, Enum)>::true_val; + // Test<__is_same(Enum, int)>::false_val; + // Test<__is_same(EnumChar, char)>::false_val; + // Test<__is_same(__underlying_type(EnumChar), char)>::true_val; + // + // Test<TemplateArgs<int, bool>::Value>::false_val; + // Test<TemplateArgs<int, int>::Value>::true_val; + // } + public void testIsSame() throws Exception { + parseAndCheckBindings(getAboveComment(), CPP, true); + } + + // void function(int * a) { } + // void function(unsigned int b) { } + // + // void functionPtr(decltype(nullptr) c) { } + // + // int main() + // { + // function(0); // 0 + // function(nullptr); // 1 + // functionPtr(0); // 2 + // functionPtr(nullptr); // 3 + // + // function(0 & 1); // 4 + // functionPtr(0 & 1); // 5 + // + // function(0 << 1); // 6 + // functionPtr(0 << 1); // 7 + // + // function((0,0)); // 8 + // functionPtr((0,0)); // 9 + // + // function(int{0}); // 10 + // functionPtr(int{0}); // 11 + // + // function(true ? 0 : 0); // 12 + // functionPtr(true ? 0 : 0); // 13 + // } + public void testNullPointerConstantConversion_573764() throws Exception { + IASTTranslationUnit tu = parse(getAboveComment(), CPP); + NameCollector collector = new NameCollector(); + tu.accept(collector); + + IBinding funcDeclA = collector.getName(0).resolveBinding(); + IBinding funcDeclB = collector.getName(2).resolveBinding(); + IBinding funcDeclC = collector.getName(4).resolveBinding(); + + int callIndexStart = 7; + // Ambiguous + assertTrue(collector.getName(callIndexStart + 0).resolveBinding() instanceof IProblemBinding); + assertEquals(funcDeclA, collector.getName(callIndexStart + 1).resolveBinding()); + assertEquals(funcDeclC, collector.getName(callIndexStart + 2).resolveBinding()); + assertEquals(funcDeclC, collector.getName(callIndexStart + 3).resolveBinding()); + + assertEquals(funcDeclB, collector.getName(callIndexStart + 4).resolveBinding()); + // Invalid argument (not null pointer constant) + assertTrue(collector.getName(callIndexStart + 5).resolveBinding() instanceof IProblemBinding); + + assertEquals(funcDeclB, collector.getName(callIndexStart + 6).resolveBinding()); + // Invalid argument (not null pointer constant) + assertTrue(collector.getName(callIndexStart + 7).resolveBinding() instanceof IProblemBinding); + + // EvalComma + assertEquals(funcDeclB, collector.getName(callIndexStart + 8).resolveBinding()); + // Invalid argument (not null pointer constant) + assertTrue(collector.getName(callIndexStart + 9).resolveBinding() instanceof IProblemBinding); + + assertEquals(funcDeclB, collector.getName(callIndexStart + 10).resolveBinding()); + // Invalid argument (not null pointer constant) + assertTrue(collector.getName(callIndexStart + 11).resolveBinding() instanceof IProblemBinding); + + // EvalConditional + assertEquals(funcDeclB, collector.getName(callIndexStart + 12).resolveBinding()); + // Invalid argument (not null pointer constant) + assertTrue(collector.getName(callIndexStart + 13).resolveBinding() instanceof IProblemBinding); + } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2FileBasePluginTestCase.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2FileBasePluginTestCase.java index 66b7a246221..0f5f7a74f6f 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2FileBasePluginTestCase.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2FileBasePluginTestCase.java @@ -38,7 +38,7 @@ import junit.framework.TestCase; /** * @author dsteffle */ -public class AST2FileBasePluginTestCase extends TestCase { +public abstract class AST2FileBasePluginTestCase extends TestCase { static NullProgressMonitor monitor; static IWorkspace workspace; static IProject project; diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2KnRTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2KnRTests.java index 81ca1ccb5c7..0f2aef8f87f 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2KnRTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2KnRTests.java @@ -595,7 +595,7 @@ public class AST2KnRTests extends AST2TestBase { .getParameterDeclarations()[0]).getDeclarators()[1].getName(); IASTName list3 = ((IASTIdExpression) ((IASTArraySubscriptExpression) ((IASTUnaryExpression) ((IASTBinaryExpression) ((IASTExpressionStatement) ((IASTCompoundStatement) getinp .getBody()).getStatements()[0]).getExpression()).getOperand1()).getOperand()).getArrayExpression()) - .getName(); + .getName(); assertEquals(prompt1.resolveBinding(), prompt2.resolveBinding()); assertEquals(list1.resolveBinding(), list2.resolveBinding()); @@ -673,10 +673,10 @@ public class AST2KnRTests extends AST2TestBase { .getParameterDeclarations()[0]).getDeclarators()[0].getName(); IASTName lemp_name3 = ((IASTIdExpression) ((IASTFieldReference) ((IASTArraySubscriptExpression) ((IASTFieldReference) ((IASTBinaryExpression) ((IASTExpressionStatement) ((IASTCompoundStatement) f_def .getBody()).getStatements()[0]).getExpression()).getOperand1()).getFieldOwner()).getArrayExpression()) - .getFieldOwner()).getName(); + .getFieldOwner()).getName(); IASTName symbols_name2 = ((IASTFieldReference) ((IASTArraySubscriptExpression) ((IASTFieldReference) ((IASTBinaryExpression) ((IASTExpressionStatement) ((IASTCompoundStatement) f_def .getBody()).getStatements()[0]).getExpression()).getOperand1()).getFieldOwner()).getArrayExpression()) - .getFieldName(); + .getFieldName(); IASTName lambda_name2 = ((IASTFieldReference) ((IASTBinaryExpression) ((IASTExpressionStatement) ((IASTCompoundStatement) f_def .getBody()).getStatements()[0]).getExpression()).getOperand1()).getFieldName(); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateLValueRValueTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateLValueRValueTests.java new file mode 100644 index 00000000000..a0598857c48 --- /dev/null +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateLValueRValueTests.java @@ -0,0 +1,878 @@ +package org.eclipse.cdt.core.parser.tests.ast2; + +import static org.eclipse.cdt.core.parser.ParserLanguage.CPP; + +import java.io.IOException; + +import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunction; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunctionInstance; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunctionTemplate; +import org.eclipse.cdt.internal.core.parser.ParserException; + +public class AST2TemplateLValueRValueTests extends AST2CPPTestBase { + + public AST2TemplateLValueRValueTests() { + } + + public AST2TemplateLValueRValueTests(String name) { + super(name); + } + + // class clazz { + // }; + // + // template<class C> void demo(C &&cont) + // { + // } + // + // template<class C> void demo(C &cont) + // { + // } + // + // clazz getClazz() + // { + // clazz c; + // return c; + // } + // + // void testLValue() + // { + // clazz c; + // demo(c); + // } + // + // void testRValue() + // { + // demo(getClazz()); + // } + public void test_lvalue_rvalue_caller_templateLvalue_templateRvalue_function() throws Exception { + parseAndCheckBindings(); + BindingAssertionHelper helper = getAssertionHelper(); + CPPFunctionTemplate targetLvalue = helper.assertNonProblem("demo(C &cont)", "demo"); + CPPFunctionTemplate targetRvalue = helper.assertNonProblem("demo(C &&cont)", "demo"); + CPPFunctionInstance actualTargetLvalue = helper.assertNonProblem("demo(c)", "demo"); + CPPFunctionInstance actualTargetRvalue = helper.assertNonProblem("demo(getClazz())", "demo"); + assertEquals(targetLvalue, actualTargetLvalue.getTemplateDefinition()); + assertEquals(targetRvalue, actualTargetRvalue.getTemplateDefinition()); + } + + // class clazz { + // }; + // + // typedef clazz clazzz; + // + // template<class C> void demo(C &&cont) + // { + // } + // + // template<class C> void demo(C &cont) + // { + // } + // + // clazz getClazz() + // { + // clazzz c; + // return c; + // } + // + // void testLValue() + // { + // clazzz c; + // demo(c); + // } + // + // void testRValue() + // { + // demo(getClazz()); + // } + public void test_lvalueTypedef_rvalueTypedef_caller_templateLvalue_templateRvalue_function() throws Exception { + parseAndCheckBindings(); + + BindingAssertionHelper helper = getAssertionHelper(); + CPPFunctionTemplate targetLvalue = helper.assertNonProblem("demo(C &cont)", "demo"); + CPPFunctionTemplate targetRvalue = helper.assertNonProblem("demo(C &&cont)", "demo"); + CPPFunctionInstance actualTargetLvalue = helper.assertNonProblem("demo(c)", "demo"); + CPPFunctionInstance actualTargetRvalue = helper.assertNonProblem("demo(getClazz())", "demo"); + assertEquals(targetLvalue, actualTargetLvalue.getTemplateDefinition()); + assertEquals(targetRvalue, actualTargetRvalue.getTemplateDefinition()); + } + + // class clazz { + // }; + // + // template <class C> + // using Ref = C&; + // + // template<class C> void demo(C &&cont) + // { + // } + // + // template<class C> void demo(Ref<C> cont) + // { + // } + // + // clazz getClazz() + // { + // clazz c; + // return c; + // } + // + // void testLValue() + // { + // clazz c; + // demo(c); + // } + // + // void testRValue() + // { + // demo(getClazz()); + // } + public void test_lvalueTypedefRef_rvalueTypedefRef_caller_templateLvalue_templateRvalue_function() + throws Exception { + parseAndCheckBindings(); + + BindingAssertionHelper helper = getAssertionHelper(); + CPPFunctionTemplate targetLvalue = helper.assertNonProblem("demo(Ref<C> cont)", "demo"); + CPPFunctionTemplate targetRvalue = helper.assertNonProblem("demo(C &&cont)", "demo"); + CPPFunctionInstance actualTargetLvalue = helper.assertNonProblem("demo(c)", "demo"); + CPPFunctionInstance actualTargetRvalue = helper.assertNonProblem("demo(getClazz())", "demo"); + assertEquals(targetLvalue, actualTargetLvalue.getTemplateDefinition()); + assertEquals(targetRvalue, actualTargetRvalue.getTemplateDefinition()); + } + + // class clazz { + // }; + // + // typedef clazz & clazzRef; + // + // template<class C> void demo(C &&cont) + // { + // } + // + // template<class C> void demo(clazzRef cont) + // { + // } + // + // clazz getClazz() + // { + // clazz c; + // return c; + // } + // + // void testLValue() + // { + // clazz c; + // demo<clazz>(c); + // } + // + // void testRValue() + // { + // demo(getClazz()); + // } + public void test_lvalueTypedefRef_rvalueTypedefRef_caller_templateTpedefLvalue_templateRvalue_function() + throws Exception { + parseAndCheckBindings(); + + BindingAssertionHelper helper = getAssertionHelper(); + CPPFunctionTemplate targetLvalue = helper.assertNonProblem("demo(clazzRef cont)", "demo"); + CPPFunctionTemplate targetRvalue = helper.assertNonProblem("demo(C &&cont)", "demo"); + CPPFunctionTemplate actualTargetLvalue = helper.assertNonProblem("demo<clazz>(c)", "demo"); + CPPFunctionInstance actualTargetRvalue = helper.assertNonProblem("demo(getClazz())", "demo"); + assertEquals(targetLvalue, actualTargetLvalue); + assertEquals(targetRvalue, actualTargetRvalue.getTemplateDefinition()); + } + + // template<class C> void demo(C &&cont) + // { + // } + // + // template<class C> void demo(C &cont) + // { + // } + // + // void demo(int &&cont) + // { + // } + // + // void demo(int &cont) + // { + // } + // + // int main() + // { + // int c; + // demo(c); + // } + public void test_lvalue_rvalue_caller_templateLvalue_templateRvalue_lvalue_function() throws Exception { + parseAndCheckBindings(); + + BindingAssertionHelper helper = getAssertionHelper(); + CPPFunction intendedTarget = helper.assertNonProblem("demo(int &cont)", "demo"); + CPPFunction actualTarget = helper.assertNonProblem("demo(c)", "demo"); + assertEquals(intendedTarget, actualTarget); + } + + // class clazz { + // }; + // + // void demo(clazz &&cont) + // { + // } + // + // void testLValue() + // { + // clazz c; + // demo(c); + // } + public void test_lvalue_caller_rvalue_function() throws Exception { + parseAndCheckBindingsForOneProblem(); + } + + // class clazz { + // }; + // + // void demo(clazz &cont) + // { + // } + // + // void testLValue() + // { + // clazz c; + // demo(c); + // } + public void test_lvalue_caller_lvalue_function() throws Exception { + parseAndCheckBindings(); + } + + // class clazz { + // }; + // + // void demo(clazz &&cont) + // { + // } + // + // void demo(clazz &cont) + // { + // } + // + // + // clazz getClazz() + // { + // clazz c; + // return c; + // } + // + // void testRValue() + // { + // demo(getClazz()); + // } + public void test_rvalue_caller_lvalue_rvalue_function() throws Exception { + parseAndCheckBindings(); + } + + // class clazz { + // }; + // + // template<class C> void demo(C &&cont) + // { + // } + // + // void demo(clazz &cont) + // { + // } + // + // void testLValue() + // { + // clazz c; + // demo(c); + // } + public void test_lvalue_caller_templateRvalue_lvalue_function() throws Exception { + parseAndCheckBindings(); + } + + // class clazz { + // }; + // + // template<class C> void demo(C &&cont) + // { + // } + // + // void demo(clazz &cont) + // { + // } + // + // clazz getClazz() + // { + // clazz c; + // return c; + // } + // + // void testRValue() + // { + // demo(getClazz()); + // } + public void test_rvalue_caller_templateRvalue_lvalue_function() throws Exception { + parseAndCheckBindings(); + } + + // class clazz { + // }; + // + // void demo(clazz &cont) + // { + // } + // clazz getClazz() + // { + // clazz c; + // return c; + // } + // + // void testRValue() + // { + // demo(getClazz()); + // } + public void test_rvalue_caller_lvalue_function() throws Exception { + parseAndCheckBindingsForOneProblem(); + } + + // class clazz { + // }; + // + // void demo(clazz &&cont) + // { + // } + // clazz getClazz() + // { + // clazz c; + // return c; + // } + // + // void testRValue() + // { + // demo(getClazz()); + // } + public void test_rvalue_caller_rvalue_function() throws Exception { + parseAndCheckBindings(); + } + + // class clazz { + // }; + // + // template<class C> void demo(C &cont) + // { + // } + // clazz getClazz() + // { + // clazz c; + // return c; + // } + // + // void testRValue() + // { + // demo(getClazz()); + // } + public void test_rvalue_caller_templateLvalue_function() throws Exception { + parseAndCheckBindingsForOneProblem(); + } + + // class clazz { + // }; + // + // template<class C> void demo(C &&cont) + // { + // } + // + // clazz getClazz() + // { + // clazz c; + // return c; + // } + // + // void testRValue() + // { + // demo(getClazz()); + // } + public void test_rvalue_caller_templateRvalue_function() throws Exception { + parseAndCheckBindings(); + } + + // class clazz { + // }; + // + // template<class C> void demo(C &&cont) + // { + // } + // + // clazz getClazz() + // { + // clazz c; + // return c; + // } + // + // void testRValue() + // { + // demo<clazz>(getClazz()); + // } + public void test_templatedRvalue_caller__templateRvalue_lvalue_function() throws Exception { + parseAndCheckBindings(); + } + + // class clazz { + // }; + // + // template<class C> void demo(C &&cont) + // { + // } + // + // void demo(clazz &cont) { + // } + // + // void testLValue() + // { + // clazz c; + // demo<clazz>(c); + // } + public void test_templatedLvalue_caller__templateRvalue_lvalue_function() throws Exception { + parseAndCheckBindingsForProblem(); + } + + // class clazz { + // }; + // + // template<class C> void demo(C &cont) + // { + // } + // + // void demo(clazz &cont) { + // } + // + // void testLValue() + // { + // clazz c; + // demo(c); + // } + public void test_lvalue_caller_templateLvalue_lvalue_function() throws Exception { + parseAndCheckBindings(); + } + + // class clazz { + // }; + // + // template<class C> void demo(C &cont) + // { + // } + // + // void demo(clazz &cont) { + // } + // + // clazz getClazz() + // { + // clazz c; + // return c; + // } + // + // void testRValue() + // { + // demo(getClazz()); + // } + public void test_rvalue_caller_templateLvalue_lvalue_function() throws Exception { + parseAndCheckBindingsForOneProblem(); + } + + // class clazz { + // }; + // + // template<class C> void demo(C &cont) + // { + // } + // + // void demo(clazz &cont) { + // } + // + // clazz getClazz() + // { + // clazz c; + // return c; + // } + // + // void testRValue() + // { + // demo<clazz>(getClazz()); + // } + public void test_templatedRvalue_caller_templatedLValue_lvalAST2TemplateRValueRValueTestsue_function() + throws Exception { + parseAndCheckBindingsForProblem(); + } + + // class clazz { + // }; + // + // template<class C> void demo(C &cont) + // { + // } + // + // void demo(clazz &cont) { + // } + // + // void testRValue() + // { + // clazz c; + // demo<clazz>(c); + // } + public void test_templatedLvalue_caller_templatedLValue_lvalue_function() throws Exception { + parseAndCheckBindings(); + } + + // class clazz { + // }; + // + // template<class C> void demo(C &&cont) + // { + // } + // + // void demo(clazz &&cont) { + // } + // + // void testLValue() + // { + // clazz c; + // demo(c); + // } + public void test_lvalue_caller_templatedRvalue_rvalue_function() throws Exception { + parseAndCheckBindings(); + } + + // class clazz { + // }; + // + // template<class C> void demo(C &&cont) + // { + // } + // + // void demo(clazz &&cont) { + // } + // + // clazz getClazz() + // { + // clazz c; + // return c; + // } + // + // void testRValue() + // { + // demo(getClazz()); + // } + public void test_rvalue_caller_templatedRvalue_rvalue_function() throws Exception { + parseAndCheckBindings(); + } + + // class clazz { + // }; + // + // template<class C> void demo(C &&cont) + // { + // } + // + // void demo(clazz &&cont) { + // } + // + // clazz getClazz() + // { + // clazz c; + // return c; + // } + // + // void testRValue() + // { + // demo<clazz>(getClazz()); + // } + public void test_templatedRvalue_caller_templatedRvalue_rvalue_function() throws Exception { + parseAndCheckBindings(); + } + + // class clazz { + // }; + // + // template<class C> void demo(C &&cont) + // { + // } + // + // void demo(clazz &&cont) { + // } + // + // void testLValue() + // { + // clazz c; + // demo<clazz>(c); + // } + public void test_templatedLvalue_caller_templatedRvalue_rvalue_function() throws Exception { + parseAndCheckBindingsForProblem(); + } + + // class clazz { + // }; + // + // template<class C> void demo(C &cont) + // { + // } + // + // void demo(clazz &&cont) { + // } + // + // void testLValue() + // { + // clazz c; + // demo(c); + // } + public void test_lvalue_caller_templatedLvalue_rvalue_function() throws Exception { + parseAndCheckBindings(); + } + + // class clazz { + // }; + // + // template<class C> void demo(C &cont) + // { + // } + // + // void demo(clazz &&cont) { + // } + // + // clazz getClazz() + // { + // clazz c; + // return c; + // } + // + // void testRValue() + // { + // demo(getClazz()); + // } + public void test_rvalue_caller_templatedLvalue_rvalue_function() throws Exception { + parseAndCheckBindings(); + } + + // class clazz { + // }; + // + // template<class C> void demo(C &cont) + // { + // } + // + // void demo(clazz &&cont) { + // } + // + // clazz getClazz() + // { + // clazz c; + // return c; + // } + // + // void testRValue() + // { + // demo<clazz>(getClazz()); + // } + public void test_templatedRvalue_caller_templatedLvalue_rvalue_function() throws Exception { + parseAndCheckBindingsForProblem(); + } + + // class clazz { + // }; + // + // template<class C> void demo(C &cont) + // { + // } + // + // void demo(clazz &&cont) { + // } + // + // void testRValue() + // { + // clazz c; + // demo<clazz>(c); + // } + public void test_templatedLvalue_caller_templatedLvalue_rvalue_function() throws Exception { + parseAndCheckBindings(); + } + + // class clazz { + // }; + // + // template<class C> void demo(C &cont) + // { + // } + // + // template<class C> void demo(C &&cont) + // { + // } + // + // void testLValue() + // { + // clazz c; + // demo(c); + // } + public void test_lvalue_caller_templatedLvalue_templatedRvalue_function() throws Exception { + parseAndCheckBindings(); + } + + // class clazz { + // }; + // + // template<class C> void demo(C &cont) + // { + // } + // + // template<class C> void demo(C &&cont) + // { + // } + // + // clazz getClazz() + // { + // clazz c; + // return c; + // } + // + // void testRValue() + // { + // demo(getClazz()); + // } + public void test_rvalue_caller_templatedLvalue_templatedRvalue_function() throws Exception { + parseAndCheckBindings(); + } + + // class clazz { + // }; + // + // template<class C> void demo(C &cont) + // { + // } + // + // template<class C> void demo(C &&cont) + // { + // } + // + // clazz getClazz() + // { + // clazz c; + // return c; + // } + // + // void testRValue() + // { + // demo<clazz>(getClazz()); + // } + public void test_templatedRvalue_caller_templatedLvalue_templatedRvalue_function() throws Exception { + parseAndCheckBindings(); + } + + // class clazz { + // }; + // + // template<class C> void demo(C &cont) + // { + // } + // + // template<class C> void demo(C &&cont) + // { + // } + // + // void testLValue() + // { + // clazz c; + // demo<clazz>(c); + // } + public void test_templatedLvalue_caller_templatedLvalue_templatedRvalue_function() throws Exception { + parseAndCheckBindings(); + } + + // class clazz { + // }; + // + // template<class C> void demo(C &cont) + // { + // } + // + // clazz getClazz() + // { + // clazz c; + // return c; + // } + // + // void testRValue() + // { + // demo<clazz>(getClazz()); + // } + public void test_templatedRvalue_caller_templatedLvalue_function() throws Exception { + parseAndCheckBindingsForProblem(); + } + + // class clazz { + // }; + // + // template<class C> void demo(C &&cont) + // { + // } + // + // clazz getClazz() + // { + // clazz c; + // return c; + // } + // + // void testRValue() + // { + // demo<clazz>(getClazz()); + // } + public void test_templatedRvalue_caller_templatedRvalue_function() throws Exception { + parseAndCheckBindings(); + } + + // class clazz { + // }; + // + // template<class C> void demo(C &cont) + // { + // } + // + // void testLValue() + // { + // clazz c; + // demo<clazz>(c); + // } + public void test_templatedLvalue_caller_templatedLvalue_function() throws Exception { + parseAndCheckBindings(); + } + + // class clazz { + // }; + // + // template<class C> void demo(C &&cont) + // { + // } + // + // void testLValue() + // { + // clazz c; + // demo<clazz>(c); + // } + public void test_templatedLvalue_caller_templatedRvalue_function() throws Exception { + parseAndCheckBindingsForProblem(); + } + + private void parseAndCheckBindingsForOneProblem() throws IOException, ParserException { + final String code = getAboveComment(); + IASTTranslationUnit tu = parse(code, CPP, true, false); + NameCollector nc = new NameCollector(); + tu.accept(nc); + assertProblemBindings(nc, 1); + } + + private void parseAndCheckBindingsForProblem() throws IOException, ParserException { + final String code = getAboveComment(); + IASTTranslationUnit tu = parse(code, CPP, true, false); + NameCollector nc = new NameCollector(); + tu.accept(nc); + assertProblemBindings(nc); + } +}
\ No newline at end of file diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TestBase.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TestBase.java index 569c4fbdede..755bf7bafea 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TestBase.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TestBase.java @@ -113,6 +113,7 @@ public class AST2TestBase extends SemanticTestBase { map.put("__SIZEOF_SHORT__", "2"); map.put("__SIZEOF_INT__", "4"); map.put("__SIZEOF_LONG__", "8"); + map.put("__SIZEOF_LONG_LONG__", "8"); map.put("__SIZEOF_DOUBLE__", "8"); map.put("__SIZEOF_POINTER__", "8"); return map; @@ -123,6 +124,7 @@ public class AST2TestBase extends SemanticTestBase { map.put("__SIZEOF_SHORT__", "2"); map.put("__SIZEOF_INT__", "4"); map.put("__SIZEOF_LONG__", "8"); + map.put("__SIZEOF_LONG_LONG__", "8"); map.put("__SIZEOF_DOUBLE__", "8"); map.put("__SIZEOF_POINTER__", "8"); return map; @@ -532,12 +534,23 @@ public class AST2TestBase extends SemanticTestBase { final protected void assertProblemBindings(NameCollector col, int count) { int sum = 0; for (IASTName n : col.nameList) { - if (n.resolveBinding() instanceof IProblemBinding) + if (n.resolveBinding() instanceof IProblemBinding) { ++sum; + } } assertEquals(count, sum); } + final protected void assertProblemBindings(NameCollector col) { + int sum = 0; + for (IASTName n : col.nameList) { + if (n.resolveBinding() instanceof IProblemBinding) { + ++sum; + } + } + assertTrue(sum > 0); + } + final protected <T extends IASTDeclaration> T getDeclaration(IASTTranslationUnit tu, int i_decl) { Class<T> tclass; IASTDeclaration[] decls = tu.getDeclarations(); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java index 381c576ce28..571fa566393 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java @@ -2533,7 +2533,7 @@ public class AST2Tests extends AST2TestBase { public void testBug80978() throws Exception { ICASTArrayModifier mod = (ICASTArrayModifier) ((IASTArrayDeclarator) ((IASTStandardFunctionDeclarator) ((IASTSimpleDeclaration) parse( getAboveComment(), C).getDeclarations()[0]).getDeclarators()[0]).getParameters()[0].getDeclarator()) - .getArrayModifiers()[0]; + .getArrayModifiers()[0]; assertTrue(mod.isConst()); assertTrue(mod.isVariableSized()); assertFalse(mod.isStatic()); @@ -2846,7 +2846,7 @@ public class AST2Tests extends AST2TestBase { public void testBug84250() throws Exception { assertTrue(((IASTDeclarationStatement) ((IASTCompoundStatement) ((IASTFunctionDefinition) parse( "void f() { int (*p) [2]; }", C).getDeclarations()[0]).getBody()).getStatements()[0]) //$NON-NLS-1$ - .getDeclaration() instanceof IASTSimpleDeclaration); + .getDeclaration() instanceof IASTSimpleDeclaration); } // struct s1 { struct s2 *s2p; /* ... */ }; // D1 @@ -5421,6 +5421,29 @@ public class AST2Tests extends AST2TestBase { } } + // using MyType = __declspec(dllexport) int; + // + // template <typename T> + // class Vector { + // }; + // void test() { + // Vector <__declspec(dllexport) int> a; + // } + public void testDeclspecTypeId_574578() throws Exception { + parseAndCheckBindings(getAboveComment(), CPP, true); + } + + //typedef struct _MyStruct { + //} MyStruct; + // + //MyStruct __declspec(dllexport) foo; + //MyStruct __declspec(dllexport) __declspec(deprecated) bar; + public void testDeclspecAfterDeclSpecifierIdentifier_464624() throws Exception { + for (ParserLanguage lang : ParserLanguage.values()) { + parseAndCheckBindings(getAboveComment(), lang, true); + } + } + // struct Outer { // struct {int a1;}; // struct {int a2;} a3; diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMFileBasePluginTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMFileBasePluginTest.java index c068e99b690..3e643a48c93 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMFileBasePluginTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMFileBasePluginTest.java @@ -39,7 +39,7 @@ import junit.framework.TestCase; /** * @author dsteffle */ -public class DOMFileBasePluginTest extends TestCase { +public abstract class DOMFileBasePluginTest extends TestCase { static NullProgressMonitor monitor; static IWorkspace workspace; static IProject project; diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMGCCParserExtensionTestSuite.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMGCCParserExtensionTestSuite.java index e07a843f9fd..577a1167d78 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMGCCParserExtensionTestSuite.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMGCCParserExtensionTestSuite.java @@ -19,8 +19,9 @@ import junit.framework.TestSuite; /** * @author jcamelon - * + * @deprecated In preparation for moving to JUnit5 test suites are deprecated. See Bug 569839 */ +@Deprecated public class DOMGCCParserExtensionTestSuite extends TestCase { public static Test suite() { diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMParserTestSuite.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMParserTestSuite.java index f1fe6b37975..dbe0749d5b0 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMParserTestSuite.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMParserTestSuite.java @@ -20,7 +20,6 @@ import org.eclipse.cdt.core.parser.tests.ast2.cxx14.GenericLambdaTests; import org.eclipse.cdt.core.parser.tests.ast2.cxx14.InitCaptureTests; import org.eclipse.cdt.core.parser.tests.ast2.cxx14.ReturnTypeDeductionTests; import org.eclipse.cdt.core.parser.tests.ast2.cxx14.VariableTemplateTests; -import org.eclipse.cdt.core.parser.tests.ast2.cxx17.DeductionGuideTests; import org.eclipse.cdt.core.parser.tests.ast2.cxx17.LambdaExpressionTests; import org.eclipse.cdt.core.parser.tests.ast2.cxx17.StructuredBindingTests; import org.eclipse.cdt.core.parser.tests.ast2.cxx17.TemplateAutoTests; @@ -32,7 +31,9 @@ import junit.framework.TestSuite; /** * @author jcamelon + * @deprecated In preparation for moving to JUnit5 test suites are deprecated. See Bug 569839 */ +@Deprecated public class DOMParserTestSuite extends TestCase { public static Test suite() { TestSuite suite = new TestSuite(DOMParserTestSuite.class.getName()); @@ -77,7 +78,6 @@ public class DOMParserTestSuite extends TestCase { suite.addTest(TemplateAutoTests.suite()); suite.addTestSuite(LambdaExpressionTests.class); suite.addTestSuite(StructuredBindingTests.class); - suite.addTestSuite(DeductionGuideTests.class); return suite; } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/AllConstexprEvalTestSuite.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/AllConstexprEvalTestSuite.java new file mode 100644 index 00000000000..2909cec8fa8 --- /dev/null +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/AllConstexprEvalTestSuite.java @@ -0,0 +1,76 @@ +/******************************************************************************* +* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik +* Rapperswil, University of applied sciences 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.ast2.cxx14.constexpr; + +import junit.framework.Test; +import junit.framework.TestSuite; + +/** + * @deprecated In preparation for moving to JUnit5 test suites are deprecated. See Bug 569839 + */ +@Deprecated +public class AllConstexprEvalTestSuite { + public static Test suite() throws Exception { + final TestSuite suite = new TestSuite(); + suite.addTest(ConstructorTests.NonIndexingTests.suite()); + suite.addTest(ConstructorTests.SingleProjectTests.suite()); + suite.addTest(MemberFunctionTests.NonIndexingTests.suite()); + suite.addTest(MemberFunctionTests.SingleProjectTests.suite()); + suite.addTest(MemberVariableTests.NonIndexingTests.suite()); + suite.addTest(MemberVariableTests.SingleProjectTests.suite()); + suite.addTest(FunctionTests.NonIndexingTests.suite()); + suite.addTest(FunctionTests.SingleProjectTests.suite()); + suite.addTest(FunctionTemplateTests.NonIndexingTests.suite()); + suite.addTest(FunctionTemplateTests.SingleProjectTests.suite()); + suite.addTest(ClassTemplateTests.NonIndexingTests.suite()); + suite.addTest(ClassTemplateTests.SingleProjectTests.suite()); + suite.addTest(IfStatementTests.NonIndexingTests.suite()); + suite.addTest(IfStatementTests.SingleProjectTests.suite()); + suite.addTest(SwitchStatementTests.NonIndexingTests.suite()); + suite.addTest(SwitchStatementTests.SingleProjectTests.suite()); + suite.addTest(WhileStatementTests.NonIndexingTests.suite()); + suite.addTest(WhileStatementTests.SingleProjectTests.suite()); + suite.addTest(DoWhileStatementTests.NonIndexingTests.suite()); + suite.addTest(DoWhileStatementTests.SingleProjectTests.suite()); + suite.addTest(ForStatementTests.NonIndexingTests.suite()); + suite.addTest(ForStatementTests.SingleProjectTests.suite()); + suite.addTest(RangeBasedForStatementTests.NonIndexingTests.suite()); + suite.addTest(RangeBasedForStatementTests.SingleProjectTests.suite()); + suite.addTest(BinaryOperatorOverloadingTests.NonIndexingTests.suite()); + suite.addTest(BinaryOperatorOverloadingTests.SingleProjectTests.suite()); + suite.addTest(UnaryOperatorOverloadingTests.NonIndexingTests.suite()); + suite.addTest(UnaryOperatorOverloadingTests.SingleProjectTests.suite()); + suite.addTest(ArrayTests.NonIndexingTests.suite()); + suite.addTest(ArrayTests.SingleProjectTests.suite()); + suite.addTest(BinaryExpressionTests.NonIndexingTests.suite()); + suite.addTest(BinaryExpressionTests.SingleProjectTests.suite()); + suite.addTest(UnaryExpressionTests.NonIndexingTests.suite()); + suite.addTest(UnaryExpressionTests.SingleProjectTests.suite()); + suite.addTest(ReferenceTests.NonIndexingTests.suite()); + suite.addTest(ReferenceTests.SingleProjectTests.suite()); + suite.addTest(TypeAliasTests.NonIndexingTests.suite()); + suite.addTest(TypeAliasTests.SingleProjectTests.suite()); + suite.addTest(PointerTests.NonIndexingTests.suite()); + suite.addTest(PointerTests.SingleProjectTests.suite()); + suite.addTest(UserDefinedLiteralTests.NonIndexingTests.suite()); + suite.addTest(UserDefinedLiteralTests.SingleProjectTests.suite()); + suite.addTest(IntegralValueTests.NonIndexingTests.suite()); + suite.addTest(IntegralValueTests.SingleProjectTests.suite()); + suite.addTest(FloatingPointValueTests.NonIndexingTests.suite()); + suite.addTest(FloatingPointValueTests.SingleProjectTests.suite()); + suite.addTest(CStringValueTests.NonIndexingTests.suite()); + suite.addTest(CStringValueTests.SingleProjectTests.suite()); + suite.addTest(StructuredBindingTests.NonIndexingTests.suite()); + suite.addTest(StructuredBindingTests.SingleProjectTests.suite()); + return suite; + } +} diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/AllConstexprEvalTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/AllConstexprEvalTests.java deleted file mode 100644 index 79eb731d114..00000000000 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/AllConstexprEvalTests.java +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik -* Rapperswil, University of applied sciences 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.ast2.cxx14.constexpr; - -import junit.framework.Test; -import junit.framework.TestSuite; - -public class AllConstexprEvalTests { - public static Test suite() throws Exception { - final TestSuite suite = new TestSuite(); - suite.addTest(ConstructorTests.NonIndexing.suite()); - suite.addTest(ConstructorTests.SingleProject.suite()); - suite.addTest(MemberFunctionTests.NonIndexing.suite()); - suite.addTest(MemberFunctionTests.SingleProject.suite()); - suite.addTest(MemberVariableTests.NonIndexing.suite()); - suite.addTest(MemberVariableTests.SingleProject.suite()); - suite.addTest(FunctionTests.NonIndexing.suite()); - suite.addTest(FunctionTests.SingleProject.suite()); - suite.addTest(FunctionTemplateTests.NonIndexing.suite()); - suite.addTest(FunctionTemplateTests.SingleProject.suite()); - suite.addTest(ClassTemplateTests.NonIndexing.suite()); - suite.addTest(ClassTemplateTests.SingleProject.suite()); - suite.addTest(IfStatementTests.NonIndexing.suite()); - suite.addTest(IfStatementTests.SingleProject.suite()); - suite.addTest(SwitchStatementTests.NonIndexing.suite()); - suite.addTest(SwitchStatementTests.SingleProject.suite()); - suite.addTest(WhileStatementTests.NonIndexing.suite()); - suite.addTest(WhileStatementTests.SingleProject.suite()); - suite.addTest(DoWhileStatementTests.NonIndexing.suite()); - suite.addTest(DoWhileStatementTests.SingleProject.suite()); - suite.addTest(ForStatementTests.NonIndexing.suite()); - suite.addTest(ForStatementTests.SingleProject.suite()); - suite.addTest(RangeBasedForStatementTests.NonIndexing.suite()); - suite.addTest(RangeBasedForStatementTests.SingleProject.suite()); - suite.addTest(BinaryOperatorOverloadingTests.NonIndexing.suite()); - suite.addTest(BinaryOperatorOverloadingTests.SingleProject.suite()); - suite.addTest(UnaryOperatorOverloadingTests.NonIndexing.suite()); - suite.addTest(UnaryOperatorOverloadingTests.SingleProject.suite()); - suite.addTest(ArrayTests.NonIndexing.suite()); - suite.addTest(ArrayTests.SingleProject.suite()); - suite.addTest(BinaryExpressionTests.NonIndexing.suite()); - suite.addTest(BinaryExpressionTests.SingleProject.suite()); - suite.addTest(UnaryExpressionTests.NonIndexing.suite()); - suite.addTest(UnaryExpressionTests.SingleProject.suite()); - suite.addTest(ReferenceTests.NonIndexing.suite()); - suite.addTest(ReferenceTests.SingleProject.suite()); - suite.addTest(TypeAliasTests.NonIndexing.suite()); - suite.addTest(TypeAliasTests.SingleProject.suite()); - suite.addTest(PointerTests.NonIndexing.suite()); - suite.addTest(PointerTests.SingleProject.suite()); - suite.addTest(UserDefinedLiteralTests.NonIndexing.suite()); - suite.addTest(UserDefinedLiteralTests.SingleProject.suite()); - suite.addTest(IntegralValueTests.NonIndexing.suite()); - suite.addTest(IntegralValueTests.SingleProject.suite()); - suite.addTest(FloatingPointValueTests.NonIndexing.suite()); - suite.addTest(FloatingPointValueTests.SingleProject.suite()); - suite.addTest(CStringValueTests.NonIndexing.suite()); - suite.addTest(CStringValueTests.SingleProject.suite()); - suite.addTest(StructuredBindingTests.NonIndexing.suite()); - suite.addTest(StructuredBindingTests.SingleProject.suite()); - return suite; - } -} diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ArrayTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ArrayTests.java index 7d33789eed2..929b6d29d85 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ArrayTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ArrayTests.java @@ -13,24 +13,24 @@ package org.eclipse.cdt.core.parser.tests.ast2.cxx14.constexpr; import junit.framework.TestSuite; -public class ArrayTests extends TestBase { - public static class NonIndexing extends ArrayTests { - public NonIndexing() { +public abstract class ArrayTests extends TestBase { + public static class NonIndexingTests extends ArrayTests { + public NonIndexingTests() { setStrategy(new NonIndexingTestStrategy()); } public static TestSuite suite() { - return suite(NonIndexing.class); + return suite(NonIndexingTests.class); } } - public static class SingleProject extends ArrayTests { - public SingleProject() { + public static class SingleProjectTests extends ArrayTests { + public SingleProjectTests() { setStrategy(new SinglePDOMTestStrategy(true, false)); } public static TestSuite suite() { - return suite(SingleProject.class); + return suite(SingleProjectTests.class); } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/BinaryExpressionTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/BinaryExpressionTests.java index abe0a57b9fa..5a675a92f2c 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/BinaryExpressionTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/BinaryExpressionTests.java @@ -13,24 +13,24 @@ package org.eclipse.cdt.core.parser.tests.ast2.cxx14.constexpr; import junit.framework.TestSuite; -public class BinaryExpressionTests extends TestBase { - public static class NonIndexing extends BinaryExpressionTests { - public NonIndexing() { +public abstract class BinaryExpressionTests extends TestBase { + public static class NonIndexingTests extends BinaryExpressionTests { + public NonIndexingTests() { setStrategy(new NonIndexingTestStrategy()); } public static TestSuite suite() { - return suite(NonIndexing.class); + return suite(NonIndexingTests.class); } } - public static class SingleProject extends BinaryExpressionTests { - public SingleProject() { + public static class SingleProjectTests extends BinaryExpressionTests { + public SingleProjectTests() { setStrategy(new SinglePDOMTestStrategy(true, false)); } public static TestSuite suite() { - return suite(SingleProject.class); + return suite(SingleProjectTests.class); } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/BinaryOperatorOverloadingTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/BinaryOperatorOverloadingTests.java index 2052811815a..7b9b1b2db12 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/BinaryOperatorOverloadingTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/BinaryOperatorOverloadingTests.java @@ -13,24 +13,24 @@ package org.eclipse.cdt.core.parser.tests.ast2.cxx14.constexpr; import junit.framework.TestSuite; -public class BinaryOperatorOverloadingTests extends TestBase { - public static class NonIndexing extends BinaryOperatorOverloadingTests { - public NonIndexing() { +public abstract class BinaryOperatorOverloadingTests extends TestBase { + public static class NonIndexingTests extends BinaryOperatorOverloadingTests { + public NonIndexingTests() { setStrategy(new NonIndexingTestStrategy()); } public static TestSuite suite() { - return suite(NonIndexing.class); + return suite(NonIndexingTests.class); } } - public static class SingleProject extends BinaryOperatorOverloadingTests { - public SingleProject() { + public static class SingleProjectTests extends BinaryOperatorOverloadingTests { + public SingleProjectTests() { setStrategy(new SinglePDOMTestStrategy(true, false)); } public static TestSuite suite() { - return suite(SingleProject.class); + return suite(SingleProjectTests.class); } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/CStringValueTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/CStringValueTests.java index 12cf893691d..1c5c084c712 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/CStringValueTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/CStringValueTests.java @@ -13,24 +13,24 @@ package org.eclipse.cdt.core.parser.tests.ast2.cxx14.constexpr; import junit.framework.TestSuite; -public class CStringValueTests extends TestBase { - public static class NonIndexing extends CStringValueTests { - public NonIndexing() { +public abstract class CStringValueTests extends TestBase { + public static class NonIndexingTests extends CStringValueTests { + public NonIndexingTests() { setStrategy(new NonIndexingTestStrategy()); } public static TestSuite suite() { - return suite(NonIndexing.class); + return suite(NonIndexingTests.class); } } - public static class SingleProject extends CStringValueTests { - public SingleProject() { + public static class SingleProjectTests extends CStringValueTests { + public SingleProjectTests() { setStrategy(new SinglePDOMTestStrategy(true, false)); } public static TestSuite suite() { - return suite(SingleProject.class); + return suite(SingleProjectTests.class); } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ClassTemplateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ClassTemplateTests.java index 85853da3d15..56f7f718c56 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ClassTemplateTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ClassTemplateTests.java @@ -13,24 +13,24 @@ package org.eclipse.cdt.core.parser.tests.ast2.cxx14.constexpr; import junit.framework.TestSuite; -public class ClassTemplateTests extends TestBase { - public static class NonIndexing extends ClassTemplateTests { - public NonIndexing() { +public abstract class ClassTemplateTests extends TestBase { + public static class NonIndexingTests extends ClassTemplateTests { + public NonIndexingTests() { setStrategy(new NonIndexingTestStrategy()); } public static TestSuite suite() { - return suite(NonIndexing.class); + return suite(NonIndexingTests.class); } } - public static class SingleProject extends ClassTemplateTests { - public SingleProject() { + public static class SingleProjectTests extends ClassTemplateTests { + public SingleProjectTests() { setStrategy(new SinglePDOMTestStrategy(true, false)); } public static TestSuite suite() { - return suite(SingleProject.class); + return suite(SingleProjectTests.class); } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ConstructorTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ConstructorTests.java index bd597e750b2..4f3f3933f03 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ConstructorTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ConstructorTests.java @@ -15,24 +15,24 @@ import org.eclipse.cdt.internal.core.dom.parser.IntegralValue; import junit.framework.TestSuite; -public class ConstructorTests extends TestBase { - public static class NonIndexing extends ConstructorTests { - public NonIndexing() { +public abstract class ConstructorTests extends TestBase { + public static class NonIndexingTests extends ConstructorTests { + public NonIndexingTests() { setStrategy(new NonIndexingTestStrategy()); } public static TestSuite suite() { - return suite(NonIndexing.class); + return suite(NonIndexingTests.class); } } - public static class SingleProject extends ConstructorTests { - public SingleProject() { + public static class SingleProjectTests extends ConstructorTests { + public SingleProjectTests() { setStrategy(new SinglePDOMTestStrategy(true, false)); } public static TestSuite suite() { - return suite(SingleProject.class); + return suite(SingleProjectTests.class); } } @@ -41,7 +41,7 @@ public class ConstructorTests extends TestBase { } public static TestSuite suite() { - return suite(NonIndexing.class); + return suite(NonIndexingTests.class); } // struct S { diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/DoWhileStatementTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/DoWhileStatementTests.java index c0f21f23527..1d1c5712bc6 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/DoWhileStatementTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/DoWhileStatementTests.java @@ -15,24 +15,24 @@ import org.eclipse.cdt.internal.core.dom.parser.IntegralValue; import junit.framework.TestSuite; -public class DoWhileStatementTests extends TestBase { - public static class NonIndexing extends DoWhileStatementTests { - public NonIndexing() { +public abstract class DoWhileStatementTests extends TestBase { + public static class NonIndexingTests extends DoWhileStatementTests { + public NonIndexingTests() { setStrategy(new NonIndexingTestStrategy()); } public static TestSuite suite() { - return suite(NonIndexing.class); + return suite(NonIndexingTests.class); } } - public static class SingleProject extends DoWhileStatementTests { - public SingleProject() { + public static class SingleProjectTests extends DoWhileStatementTests { + public SingleProjectTests() { setStrategy(new SinglePDOMTestStrategy(true, false)); } public static TestSuite suite() { - return suite(SingleProject.class); + return suite(SingleProjectTests.class); } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/FloatingPointValueTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/FloatingPointValueTests.java index 2727a202128..10466ca6a59 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/FloatingPointValueTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/FloatingPointValueTests.java @@ -13,24 +13,24 @@ package org.eclipse.cdt.core.parser.tests.ast2.cxx14.constexpr; import junit.framework.TestSuite; -public class FloatingPointValueTests extends TestBase { - public static class NonIndexing extends FloatingPointValueTests { - public NonIndexing() { +public abstract class FloatingPointValueTests extends TestBase { + public static class NonIndexingTests extends FloatingPointValueTests { + public NonIndexingTests() { setStrategy(new NonIndexingTestStrategy()); } public static TestSuite suite() { - return suite(NonIndexing.class); + return suite(NonIndexingTests.class); } } - public static class SingleProject extends FloatingPointValueTests { - public SingleProject() { + public static class SingleProjectTests extends FloatingPointValueTests { + public SingleProjectTests() { setStrategy(new SinglePDOMTestStrategy(true, false)); } public static TestSuite suite() { - return suite(SingleProject.class); + return suite(SingleProjectTests.class); } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ForStatementTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ForStatementTests.java index 81257e33b9e..f1f15bbd867 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ForStatementTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ForStatementTests.java @@ -15,24 +15,24 @@ import org.eclipse.cdt.internal.core.dom.parser.IntegralValue; import junit.framework.TestSuite; -public class ForStatementTests extends TestBase { - public static class NonIndexing extends ForStatementTests { - public NonIndexing() { +public abstract class ForStatementTests extends TestBase { + public static class NonIndexingTests extends ForStatementTests { + public NonIndexingTests() { setStrategy(new NonIndexingTestStrategy()); } public static TestSuite suite() { - return suite(NonIndexing.class); + return suite(NonIndexingTests.class); } } - public static class SingleProject extends ForStatementTests { - public SingleProject() { + public static class SingleProjectTests extends ForStatementTests { + public SingleProjectTests() { setStrategy(new SinglePDOMTestStrategy(true, false)); } public static TestSuite suite() { - return suite(SingleProject.class); + return suite(SingleProjectTests.class); } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/FunctionTemplateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/FunctionTemplateTests.java index 24e530ba9e8..beb16f03c28 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/FunctionTemplateTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/FunctionTemplateTests.java @@ -13,24 +13,24 @@ package org.eclipse.cdt.core.parser.tests.ast2.cxx14.constexpr; import junit.framework.TestSuite; -public class FunctionTemplateTests extends TestBase { - public static class NonIndexing extends FunctionTemplateTests { - public NonIndexing() { +public abstract class FunctionTemplateTests extends TestBase { + public static class NonIndexingTests extends FunctionTemplateTests { + public NonIndexingTests() { setStrategy(new NonIndexingTestStrategy()); } public static TestSuite suite() { - return suite(NonIndexing.class); + return suite(NonIndexingTests.class); } } - public static class SingleProject extends FunctionTemplateTests { - public SingleProject() { + public static class SingleProjectTests extends FunctionTemplateTests { + public SingleProjectTests() { setStrategy(new SinglePDOMTestStrategy(true, false)); } public static TestSuite suite() { - return suite(SingleProject.class); + return suite(SingleProjectTests.class); } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/FunctionTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/FunctionTests.java index 90bc538a0f4..e93634e893d 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/FunctionTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/FunctionTests.java @@ -20,24 +20,24 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPExecution; import junit.framework.TestSuite; -public class FunctionTests extends TestBase { - public static class NonIndexing extends FunctionTests { - public NonIndexing() { +public abstract class FunctionTests extends TestBase { + public static class NonIndexingTests extends FunctionTests { + public NonIndexingTests() { setStrategy(new NonIndexingTestStrategy()); } public static TestSuite suite() { - return suite(NonIndexing.class); + return suite(NonIndexingTests.class); } } - public static class SingleProject extends FunctionTests { - public SingleProject() { + public static class SingleProjectTests extends FunctionTests { + public SingleProjectTests() { setStrategy(new SinglePDOMTestStrategy(true, false)); } public static TestSuite suite() { - return suite(SingleProject.class); + return suite(SingleProjectTests.class); } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/IfStatementTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/IfStatementTests.java index e8c32fe5320..cac71883df0 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/IfStatementTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/IfStatementTests.java @@ -13,24 +13,24 @@ package org.eclipse.cdt.core.parser.tests.ast2.cxx14.constexpr; import junit.framework.TestSuite; -public class IfStatementTests extends TestBase { - public static class NonIndexing extends IfStatementTests { - public NonIndexing() { +public abstract class IfStatementTests extends TestBase { + public static class NonIndexingTests extends IfStatementTests { + public NonIndexingTests() { setStrategy(new NonIndexingTestStrategy()); } public static TestSuite suite() { - return suite(NonIndexing.class); + return suite(NonIndexingTests.class); } } - public static class SingleProject extends IfStatementTests { - public SingleProject() { + public static class SingleProjectTests extends IfStatementTests { + public SingleProjectTests() { setStrategy(new SinglePDOMTestStrategy(true, false)); } public static TestSuite suite() { - return suite(SingleProject.class); + return suite(SingleProjectTests.class); } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/IntegralValueTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/IntegralValueTests.java index 641fdfc411f..226ac681328 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/IntegralValueTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/IntegralValueTests.java @@ -11,31 +11,42 @@ *******************************************************************************/ package org.eclipse.cdt.core.parser.tests.ast2.cxx14.constexpr; +import org.eclipse.cdt.core.testplugin.TestScannerProvider; import org.eclipse.cdt.internal.core.dom.parser.IntegralValue; import junit.framework.TestSuite; -public class IntegralValueTests extends TestBase { - public static class NonIndexing extends IntegralValueTests { - public NonIndexing() { +public abstract class IntegralValueTests extends TestBase { + public static class NonIndexingTests extends IntegralValueTests { + public NonIndexingTests() { setStrategy(new NonIndexingTestStrategy()); } public static TestSuite suite() { - return suite(NonIndexing.class); + return suite(NonIndexingTests.class); } } - public static class SingleProject extends IntegralValueTests { - public SingleProject() { + public static class SingleProjectTests extends IntegralValueTests { + public SingleProjectTests() { setStrategy(new SinglePDOMTestStrategy(true, false)); } public static TestSuite suite() { - return suite(SingleProject.class); + return suite(SingleProjectTests.class); } } + @Override + protected void setUp() throws Exception { + TestScannerProvider.sDefinedSymbols.put("__SIZEOF_SHORT__", "2"); + TestScannerProvider.sDefinedSymbols.put("__SIZEOF_INT__", "4"); + TestScannerProvider.sDefinedSymbols.put("__SIZEOF_LONG__", "8"); + TestScannerProvider.sDefinedSymbols.put("__SIZEOF_LONG_LONG__", "8"); + TestScannerProvider.sDefinedSymbols.put("__SIZEOF_POINTER__", "8"); + super.setUp(); + } + // constexpr auto x = int{} + int(); public void testIntDefaultValue() throws Exception { assertEvaluationEquals(0); @@ -269,4 +280,64 @@ public class IntegralValueTests extends TestBase { public void testHexLiteral() throws Exception { assertEvaluationEquals(42); } + + // constexpr int x = __builtin_ffs(0) + __builtin_ffs(16); + public void testBuiltinFfs() throws Exception { + assertEvaluationEquals(5); + } + + // constexpr int x = __builtin_ffs(0x100000000); + public void testBuiltinFfsNarrowing() throws Exception { + assertEvaluationEquals(0); + } + + // constexpr int x = __builtin_ffsl(0x100000000); + public void testBuiltinFfsl() throws Exception { + assertEvaluationEquals(33); + } + + // constexpr int x = __builtin_ctz(16); + public void testBuiltinCtz() throws Exception { + assertEvaluationEquals(4); + } + + // constexpr int x = __builtin_popcount(128 + 32 + 8 + 4 + 2); + public void testBuiltinPopcount() throws Exception { + assertEvaluationEquals(5); + } + + // constexpr int x = __builtin_popcountl(0x80000001); + public void testBuiltinPopcountHighBitSet() throws Exception { + assertEvaluationEquals(2); + } + + // constexpr int x = __builtin_popcountl(0x8000000000000001); + public void testBuiltinPopcountlHighBitSet() throws Exception { + assertEvaluationEquals(2); + } + + // constexpr int x = __builtin_popcountll(0x8000000000000001); + public void testBuiltinPopcountllHighBitSet() throws Exception { + assertEvaluationEquals(2); + } + + // constexpr int x = __builtin_parity(128 + 32 + 8 + 4 + 2) + __builtin_parity(64) + __builtin_parity(0); + public void testBuiltinParity() throws Exception { + assertEvaluationEquals(2); + } + + // constexpr int x = __builtin_abs(700) + __builtin_abs(50); + public void testBuiltinAbs() throws Exception { + assertEvaluationEquals(750); + } + + // constexpr int x = __builtin_abs(-1); + public void testBuiltinAbsNegativeInput() throws Exception { + assertEvaluationEquals(1); + } + + // constexpr int x = __builtin_abs(0xFFFFFFFF); + public void testBuiltinAbsNarrowing() throws Exception { + assertEvaluationEquals(1); + } }
\ No newline at end of file diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/MemberFunctionTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/MemberFunctionTests.java index a9d192722f4..652c8bf8c31 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/MemberFunctionTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/MemberFunctionTests.java @@ -13,24 +13,24 @@ package org.eclipse.cdt.core.parser.tests.ast2.cxx14.constexpr; import junit.framework.TestSuite; -public class MemberFunctionTests extends TestBase { - public static class NonIndexing extends MemberFunctionTests { - public NonIndexing() { +public abstract class MemberFunctionTests extends TestBase { + public static class NonIndexingTests extends MemberFunctionTests { + public NonIndexingTests() { setStrategy(new NonIndexingTestStrategy()); } public static TestSuite suite() { - return suite(NonIndexing.class); + return suite(NonIndexingTests.class); } } - public static class SingleProject extends MemberFunctionTests { - public SingleProject() { + public static class SingleProjectTests extends MemberFunctionTests { + public SingleProjectTests() { setStrategy(new SinglePDOMTestStrategy(true, false)); } public static TestSuite suite() { - return suite(SingleProject.class); + return suite(SingleProjectTests.class); } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/MemberVariableTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/MemberVariableTests.java index ab09b0b55ff..cee47b77829 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/MemberVariableTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/MemberVariableTests.java @@ -13,24 +13,24 @@ package org.eclipse.cdt.core.parser.tests.ast2.cxx14.constexpr; import junit.framework.TestSuite; -public class MemberVariableTests extends TestBase { - public static class NonIndexing extends MemberVariableTests { - public NonIndexing() { +public abstract class MemberVariableTests extends TestBase { + public static class NonIndexingTests extends MemberVariableTests { + public NonIndexingTests() { setStrategy(new NonIndexingTestStrategy()); } public static TestSuite suite() { - return suite(NonIndexing.class); + return suite(NonIndexingTests.class); } } - public static class SingleProject extends MemberVariableTests { - public SingleProject() { + public static class SingleProjectTests extends MemberVariableTests { + public SingleProjectTests() { setStrategy(new SinglePDOMTestStrategy(true, false)); } public static TestSuite suite() { - return suite(SingleProject.class); + return suite(SingleProjectTests.class); } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/PointerTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/PointerTests.java index 789684cc470..4ca449e1299 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/PointerTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/PointerTests.java @@ -15,24 +15,24 @@ import org.eclipse.cdt.internal.core.dom.parser.IntegralValue; import junit.framework.TestSuite; -public class PointerTests extends TestBase { - public static class NonIndexing extends PointerTests { - public NonIndexing() { +public abstract class PointerTests extends TestBase { + public static class NonIndexingTests extends PointerTests { + public NonIndexingTests() { setStrategy(new NonIndexingTestStrategy()); } public static TestSuite suite() { - return suite(NonIndexing.class); + return suite(NonIndexingTests.class); } } - public static class SingleProject extends PointerTests { - public SingleProject() { + public static class SingleProjectTests extends PointerTests { + public SingleProjectTests() { setStrategy(new SinglePDOMTestStrategy(true, false)); } public static TestSuite suite() { - return suite(SingleProject.class); + return suite(SingleProjectTests.class); } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/RangeBasedForStatementTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/RangeBasedForStatementTests.java index 35d5b3af90f..aebe27f1777 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/RangeBasedForStatementTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/RangeBasedForStatementTests.java @@ -15,24 +15,24 @@ import org.eclipse.cdt.internal.core.dom.parser.IntegralValue; import junit.framework.TestSuite; -public class RangeBasedForStatementTests extends TestBase { - public static class NonIndexing extends RangeBasedForStatementTests { - public NonIndexing() { +public abstract class RangeBasedForStatementTests extends TestBase { + public static class NonIndexingTests extends RangeBasedForStatementTests { + public NonIndexingTests() { setStrategy(new NonIndexingTestStrategy()); } public static TestSuite suite() { - return suite(NonIndexing.class); + return suite(NonIndexingTests.class); } } - public static class SingleProject extends RangeBasedForStatementTests { - public SingleProject() { + public static class SingleProjectTests extends RangeBasedForStatementTests { + public SingleProjectTests() { setStrategy(new SinglePDOMTestStrategy(true, false)); } public static TestSuite suite() { - return suite(SingleProject.class); + return suite(SingleProjectTests.class); } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ReferenceTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ReferenceTests.java index 7a790030299..35a2ad0be0e 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ReferenceTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/ReferenceTests.java @@ -13,24 +13,24 @@ package org.eclipse.cdt.core.parser.tests.ast2.cxx14.constexpr; import junit.framework.TestSuite; -public class ReferenceTests extends TestBase { - public static class NonIndexing extends ReferenceTests { - public NonIndexing() { +public abstract class ReferenceTests extends TestBase { + public static class NonIndexingTests extends ReferenceTests { + public NonIndexingTests() { setStrategy(new NonIndexingTestStrategy()); } public static TestSuite suite() { - return suite(NonIndexing.class); + return suite(NonIndexingTests.class); } } - public static class SingleProject extends ReferenceTests { - public SingleProject() { + public static class SingleProjectTests extends ReferenceTests { + public SingleProjectTests() { setStrategy(new SinglePDOMTestStrategy(true, false)); } public static TestSuite suite() { - return suite(SingleProject.class); + return suite(SingleProjectTests.class); } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/StructuredBindingTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/StructuredBindingTests.java index dd6b20c6cb9..93a3eb4029b 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/StructuredBindingTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/StructuredBindingTests.java @@ -13,24 +13,24 @@ package org.eclipse.cdt.core.parser.tests.ast2.cxx14.constexpr; import junit.framework.TestSuite; -public class StructuredBindingTests extends TestBase { - public static class NonIndexing extends StructuredBindingTests { - public NonIndexing() { +public abstract class StructuredBindingTests extends TestBase { + public static class NonIndexingTests extends StructuredBindingTests { + public NonIndexingTests() { setStrategy(new NonIndexingTestStrategy()); } public static TestSuite suite() { - return suite(NonIndexing.class); + return suite(NonIndexingTests.class); } } - public static class SingleProject extends StructuredBindingTests { - public SingleProject() { + public static class SingleProjectTests extends StructuredBindingTests { + public SingleProjectTests() { setStrategy(new SinglePDOMTestStrategy(true, false)); } public static TestSuite suite() { - return suite(SingleProject.class); + return suite(SingleProjectTests.class); } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/SwitchStatementTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/SwitchStatementTests.java index 678263064f1..5712181043d 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/SwitchStatementTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/SwitchStatementTests.java @@ -13,24 +13,24 @@ package org.eclipse.cdt.core.parser.tests.ast2.cxx14.constexpr; import junit.framework.TestSuite; -public class SwitchStatementTests extends TestBase { - public static class NonIndexing extends SwitchStatementTests { - public NonIndexing() { +public abstract class SwitchStatementTests extends TestBase { + public static class NonIndexingTests extends SwitchStatementTests { + public NonIndexingTests() { setStrategy(new NonIndexingTestStrategy()); } public static TestSuite suite() { - return suite(NonIndexing.class); + return suite(NonIndexingTests.class); } } - public static class SingleProject extends SwitchStatementTests { - public SingleProject() { + public static class SingleProjectTests extends SwitchStatementTests { + public SingleProjectTests() { setStrategy(new SinglePDOMTestStrategy(true, false)); } public static TestSuite suite() { - return suite(SingleProject.class); + return suite(SingleProjectTests.class); } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/TestBase.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/TestBase.java index 2a2b7504632..81ef2344c50 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/TestBase.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/TestBase.java @@ -21,7 +21,7 @@ import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.core.dom.ast.IValue; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializerClause; import org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration; -import org.eclipse.cdt.core.dom.parser.cpp.ANSICPPParserExtensionConfiguration; +import org.eclipse.cdt.core.dom.parser.cpp.GPPParserExtensionConfiguration; import org.eclipse.cdt.core.dom.parser.cpp.GPPScannerExtensionConfiguration; import org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration; import org.eclipse.cdt.core.index.IIndex; @@ -50,7 +50,7 @@ import org.eclipse.cdt.internal.core.parser.ParserException; import org.eclipse.cdt.internal.core.parser.scanner.CPreprocessor; import org.eclipse.cdt.internal.index.tests.IndexBindingResolutionTestBase; -public class TestBase extends IndexBindingResolutionTestBase { +public abstract class TestBase extends IndexBindingResolutionTestBase { private static final String TEST_CODE = "<testcode>"; private static final IParserLogService NULL_LOG = new NullLogService(); private static final ScannerInfo SCANNER_INFO = new ScannerInfo(getStdMap()); @@ -66,6 +66,7 @@ public class TestBase extends IndexBindingResolutionTestBase { map.put("__SIZEOF_SHORT__", "2"); map.put("__SIZEOF_INT__", "4"); map.put("__SIZEOF_LONG__", "8"); + map.put("__SIZEOF_LONG_LONG__", "8"); map.put("__SIZEOF_POINTER__", "8"); return map; } @@ -194,7 +195,7 @@ public class TestBase extends IndexBindingResolutionTestBase { IScanner scanner = createScanner(FileContent.create(TEST_CODE, code.toCharArray()), ParserLanguage.CPP, ParserMode.COMPLETE_PARSE, SCANNER_INFO); AbstractGNUSourceCodeParser parser = null; - ICPPParserExtensionConfiguration config = new ANSICPPParserExtensionConfiguration(); + ICPPParserExtensionConfiguration config = new GPPParserExtensionConfiguration(); parser = new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config, null); parser.setMaximumTrivialExpressionsInAggregateInitializers(Integer.MAX_VALUE); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/TypeAliasTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/TypeAliasTests.java index f8bfe848d71..fba57b250bd 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/TypeAliasTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/TypeAliasTests.java @@ -13,24 +13,24 @@ package org.eclipse.cdt.core.parser.tests.ast2.cxx14.constexpr; import junit.framework.TestSuite; -public class TypeAliasTests extends TestBase { - public static class NonIndexing extends TypeAliasTests { - public NonIndexing() { +public abstract class TypeAliasTests extends TestBase { + public static class NonIndexingTests extends TypeAliasTests { + public NonIndexingTests() { setStrategy(new NonIndexingTestStrategy()); } public static TestSuite suite() { - return suite(NonIndexing.class); + return suite(NonIndexingTests.class); } } - public static class SingleProject extends TypeAliasTests { - public SingleProject() { + public static class SingleProjectTests extends TypeAliasTests { + public SingleProjectTests() { setStrategy(new SinglePDOMTestStrategy(true, false)); } public static TestSuite suite() { - return suite(SingleProject.class); + return suite(SingleProjectTests.class); } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/UnaryExpressionTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/UnaryExpressionTests.java index d75d427392b..cf9d4108e99 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/UnaryExpressionTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/UnaryExpressionTests.java @@ -13,24 +13,24 @@ package org.eclipse.cdt.core.parser.tests.ast2.cxx14.constexpr; import junit.framework.TestSuite; -public class UnaryExpressionTests extends TestBase { - public static class NonIndexing extends UnaryExpressionTests { - public NonIndexing() { +public abstract class UnaryExpressionTests extends TestBase { + public static class NonIndexingTests extends UnaryExpressionTests { + public NonIndexingTests() { setStrategy(new NonIndexingTestStrategy()); } public static TestSuite suite() { - return suite(NonIndexing.class); + return suite(NonIndexingTests.class); } } - public static class SingleProject extends UnaryExpressionTests { - public SingleProject() { + public static class SingleProjectTests extends UnaryExpressionTests { + public SingleProjectTests() { setStrategy(new SinglePDOMTestStrategy(true, false)); } public static TestSuite suite() { - return suite(SingleProject.class); + return suite(SingleProjectTests.class); } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/UnaryOperatorOverloadingTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/UnaryOperatorOverloadingTests.java index 854f2abafca..ff78ad19ba1 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/UnaryOperatorOverloadingTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/UnaryOperatorOverloadingTests.java @@ -13,24 +13,24 @@ package org.eclipse.cdt.core.parser.tests.ast2.cxx14.constexpr; import junit.framework.TestSuite; -public class UnaryOperatorOverloadingTests extends TestBase { - public static class NonIndexing extends UnaryOperatorOverloadingTests { - public NonIndexing() { +public abstract class UnaryOperatorOverloadingTests extends TestBase { + public static class NonIndexingTests extends UnaryOperatorOverloadingTests { + public NonIndexingTests() { setStrategy(new NonIndexingTestStrategy()); } public static TestSuite suite() { - return suite(NonIndexing.class); + return suite(NonIndexingTests.class); } } - public static class SingleProject extends UnaryOperatorOverloadingTests { - public SingleProject() { + public static class SingleProjectTests extends UnaryOperatorOverloadingTests { + public SingleProjectTests() { setStrategy(new SinglePDOMTestStrategy(true, false)); } public static TestSuite suite() { - return suite(SingleProject.class); + return suite(SingleProjectTests.class); } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/UserDefinedLiteralTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/UserDefinedLiteralTests.java index cf32d1a7a2f..34ec4b7d5e2 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/UserDefinedLiteralTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/UserDefinedLiteralTests.java @@ -15,24 +15,24 @@ import org.eclipse.cdt.internal.core.dom.parser.IntegralValue; import junit.framework.TestSuite; -public class UserDefinedLiteralTests extends TestBase { - public static class NonIndexing extends UserDefinedLiteralTests { - public NonIndexing() { +public abstract class UserDefinedLiteralTests extends TestBase { + public static class NonIndexingTests extends UserDefinedLiteralTests { + public NonIndexingTests() { setStrategy(new NonIndexingTestStrategy()); } public static TestSuite suite() { - return suite(NonIndexing.class); + return suite(NonIndexingTests.class); } } - public static class SingleProject extends UserDefinedLiteralTests { - public SingleProject() { + public static class SingleProjectTests extends UserDefinedLiteralTests { + public SingleProjectTests() { setStrategy(new SinglePDOMTestStrategy(true, false)); } public static TestSuite suite() { - return suite(SingleProject.class); + return suite(SingleProjectTests.class); } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/WhileStatementTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/WhileStatementTests.java index ba5c5fe33e8..050cce97de0 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/WhileStatementTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/WhileStatementTests.java @@ -15,24 +15,24 @@ import org.eclipse.cdt.internal.core.dom.parser.IntegralValue; import junit.framework.TestSuite; -public class WhileStatementTests extends TestBase { - public static class NonIndexing extends WhileStatementTests { - public NonIndexing() { +public abstract class WhileStatementTests extends TestBase { + public static class NonIndexingTests extends WhileStatementTests { + public NonIndexingTests() { setStrategy(new NonIndexingTestStrategy()); } public static TestSuite suite() { - return suite(NonIndexing.class); + return suite(NonIndexingTests.class); } } - public static class SingleProject extends WhileStatementTests { - public SingleProject() { + public static class SingleProjectTests extends WhileStatementTests { + public SingleProjectTests() { setStrategy(new SinglePDOMTestStrategy(true, false)); } public static TestSuite suite() { - return suite(SingleProject.class); + return suite(SingleProjectTests.class); } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx17/DeductionGuideTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx17/DeductionGuideTests.java deleted file mode 100644 index 02705d96e5b..00000000000 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx17/DeductionGuideTests.java +++ /dev/null @@ -1,187 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2018, Institute for Software and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Felix Morgner - initial API and implementation - *******************************************************************************/ - -package org.eclipse.cdt.core.parser.tests.ast2.cxx17; - -import static org.hamcrest.Matchers.arrayWithSize; -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.hasToString; -import static org.hamcrest.Matchers.is; - -import org.eclipse.cdt.core.dom.ast.IASTDeclaration; -import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration; -import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeductionGuide; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration; -import org.eclipse.cdt.core.parser.tests.ast2.AST2CPPTestBase; -import org.eclipse.cdt.core.parser.util.ArrayUtil; -import org.hamcrest.MatcherAssert; - -public class DeductionGuideTests extends AST2CPPTestBase { - - private static ICPPASTDeductionGuide firstGuide(IASTDeclaration[] array) { - return (ICPPASTDeductionGuide) ArrayUtil.filter(array, d -> d instanceof ICPPASTDeductionGuide)[0]; - } - - // template<typename> struct U; - // U() -> U<int>; - public void testDeductionGuideWithoutArguments() throws Exception { - IASTDeclaration[] declarations = parseAndCheckBindings().getDeclarations(); - - ICPPASTDeductionGuide guide = firstGuide(declarations); - MatcherAssert.assertThat(guide.getParameters(), is(arrayWithSize(0))); - MatcherAssert.assertThat(guide.getTemplateName(), hasToString("U")); - MatcherAssert.assertThat(guide.getSimpleTemplateId().getTemplateName(), hasToString("U")); - MatcherAssert.assertThat(guide.isExplicit(), is(equalTo(false))); - } - - // template<typename> struct U; - // U(int, float) -> U<int>; - public void testDeductionGuideWithArguments() throws Exception { - IASTDeclaration[] declarations = parseAndCheckBindings().getDeclarations(); - - ICPPASTDeductionGuide guide = firstGuide(declarations); - MatcherAssert.assertThat(guide.getParameters(), is(arrayWithSize(2))); - MatcherAssert.assertThat(guide.getTemplateName(), hasToString("U")); - MatcherAssert.assertThat(guide.getSimpleTemplateId().getTemplateName(), hasToString("U")); - MatcherAssert.assertThat(guide.isExplicit(), is(equalTo(false))); - } - - // template<typename> struct U; - // template<typename T> - // U(T) -> U<T>; - public void testDeductionGuideTemplate() throws Exception { - IASTDeclaration[] declarations = parseAndCheckBindings().getDeclarations(); - ICPPASTTemplateDeclaration template = (ICPPASTTemplateDeclaration) declarations[1]; - ICPPASTDeductionGuide guide = (ICPPASTDeductionGuide) template.getDeclaration(); - - MatcherAssert.assertThat(guide.getParameters(), is(arrayWithSize(1))); - MatcherAssert.assertThat(guide.getTemplateName(), hasToString("U")); - MatcherAssert.assertThat(guide.getSimpleTemplateId().getTemplateName(), hasToString("U")); - MatcherAssert.assertThat(guide.isExplicit(), is(equalTo(false))); - } - - // template<typename> struct U; - // explicit U() -> U<int>; - public void testExplicitDeductionGuide() throws Exception { - IASTDeclaration[] declarations = parseAndCheckBindings().getDeclarations(); - - ICPPASTDeductionGuide guide = firstGuide(declarations); - MatcherAssert.assertThat(guide.getParameters(), is(arrayWithSize(0))); - MatcherAssert.assertThat(guide.getTemplateName(), hasToString("U")); - MatcherAssert.assertThat(guide.getSimpleTemplateId().getTemplateName(), hasToString("U")); - MatcherAssert.assertThat(guide.isExplicit(), is(equalTo(true))); - } - - // template<typename> struct U; - // template<typename T> - // explicit U(T) -> U<T>; - public void testExplicitDeductionGuideTemplate() throws Exception { - IASTDeclaration[] declarations = parseAndCheckBindings().getDeclarations(); - ICPPASTTemplateDeclaration template = (ICPPASTTemplateDeclaration) declarations[1]; - ICPPASTDeductionGuide guide = (ICPPASTDeductionGuide) template.getDeclaration(); - - MatcherAssert.assertThat(guide.getParameters(), is(arrayWithSize(1))); - MatcherAssert.assertThat(guide.getTemplateName(), hasToString("U")); - MatcherAssert.assertThat(guide.getSimpleTemplateId().getTemplateName(), hasToString("U")); - MatcherAssert.assertThat(guide.isExplicit(), is(equalTo(true))); - } - - // struct S { - // template<typename> struct U; - // U() -> U<int>; - // }; - public void testDeductionGuideWithoutArgumentsForNestedClassType() throws Exception { - IASTTranslationUnit tu = parseAndCheckBindings(); - IASTSimpleDeclaration declaration = (IASTSimpleDeclaration) tu.getDeclarations()[0]; - ICPPASTCompositeTypeSpecifier struct = (ICPPASTCompositeTypeSpecifier) declaration.getDeclSpecifier(); - IASTDeclaration[] members = struct.getMembers(); - - ICPPASTDeductionGuide guide = firstGuide(members); - MatcherAssert.assertThat(guide.getParameters(), is(arrayWithSize(0))); - MatcherAssert.assertThat(guide.getTemplateName(), hasToString("U")); - MatcherAssert.assertThat(guide.getSimpleTemplateId().getTemplateName(), hasToString("U")); - MatcherAssert.assertThat(guide.isExplicit(), is(equalTo(false))); - } - - // struct S { - // template<typename> struct U; - // U(char, bool) -> U<double>; - // }; - public void testDeductionGuideWithArgumentsForNestedClassType() throws Exception { - IASTTranslationUnit tu = parseAndCheckBindings(); - IASTSimpleDeclaration declaration = (IASTSimpleDeclaration) tu.getDeclarations()[0]; - ICPPASTCompositeTypeSpecifier struct = (ICPPASTCompositeTypeSpecifier) declaration.getDeclSpecifier(); - IASTDeclaration[] members = struct.getMembers(); - - ICPPASTDeductionGuide guide = firstGuide(members); - MatcherAssert.assertThat(guide.getParameters(), is(arrayWithSize(2))); - MatcherAssert.assertThat(guide.getTemplateName(), hasToString("U")); - MatcherAssert.assertThat(guide.getSimpleTemplateId().getTemplateName(), hasToString("U")); - MatcherAssert.assertThat(guide.isExplicit(), is(equalTo(false))); - } - - // struct S { - // template<typename> struct U; - // template<typename T> - // U(T) -> U<T>; - // }; - public void testDeductionGuideTemplateWithArgumentsForNestedClassType() throws Exception { - IASTTranslationUnit tu = parseAndCheckBindings(); - IASTSimpleDeclaration declaration = (IASTSimpleDeclaration) tu.getDeclarations()[0]; - ICPPASTCompositeTypeSpecifier struct = (ICPPASTCompositeTypeSpecifier) declaration.getDeclSpecifier(); - IASTDeclaration[] members = struct.getMembers(); - ICPPASTTemplateDeclaration template = (ICPPASTTemplateDeclaration) members[1]; - - ICPPASTDeductionGuide guide = (ICPPASTDeductionGuide) template.getDeclaration(); - MatcherAssert.assertThat(guide.getParameters(), is(arrayWithSize(1))); - MatcherAssert.assertThat(guide.getTemplateName(), hasToString("U")); - MatcherAssert.assertThat(guide.getSimpleTemplateId().getTemplateName(), hasToString("U")); - MatcherAssert.assertThat(guide.isExplicit(), is(equalTo(false))); - } - - // struct S { - // template<typename> struct U; - // explicit U() -> U<int>; - // }; - public void testExplicitDeductionGuideForNestedClassType() throws Exception { - IASTTranslationUnit tu = parseAndCheckBindings(); - IASTSimpleDeclaration declaration = (IASTSimpleDeclaration) tu.getDeclarations()[0]; - ICPPASTCompositeTypeSpecifier struct = (ICPPASTCompositeTypeSpecifier) declaration.getDeclSpecifier(); - IASTDeclaration[] members = struct.getMembers(); - - ICPPASTDeductionGuide guide = firstGuide(members); - MatcherAssert.assertThat(guide.getParameters(), is(arrayWithSize(0))); - MatcherAssert.assertThat(guide.getTemplateName(), hasToString("U")); - MatcherAssert.assertThat(guide.getSimpleTemplateId().getTemplateName(), hasToString("U")); - MatcherAssert.assertThat(guide.isExplicit(), is(equalTo(true))); - } - - // struct S { - // template<typename> struct U; - // template<typename T> - // explicit U(T) -> U<T>; - // }; - public void testExplicitDeductionGuideTemplateForNestedClassType() throws Exception { - IASTTranslationUnit tu = parseAndCheckBindings(); - IASTSimpleDeclaration declaration = (IASTSimpleDeclaration) tu.getDeclarations()[0]; - ICPPASTCompositeTypeSpecifier struct = (ICPPASTCompositeTypeSpecifier) declaration.getDeclSpecifier(); - IASTDeclaration[] members = struct.getMembers(); - ICPPASTTemplateDeclaration template = (ICPPASTTemplateDeclaration) members[1]; - - ICPPASTDeductionGuide guide = (ICPPASTDeductionGuide) template.getDeclaration(); - MatcherAssert.assertThat(guide.getParameters(), is(arrayWithSize(1))); - MatcherAssert.assertThat(guide.getTemplateName(), hasToString("U")); - MatcherAssert.assertThat(guide.getSimpleTemplateId().getTemplateName(), hasToString("U")); - MatcherAssert.assertThat(guide.isExplicit(), is(equalTo(true))); - } -} diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/CompletionTestSuite.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/CompletionTestSuite.java index 370a6efeb7b..c21d9d4798a 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/CompletionTestSuite.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/CompletionTestSuite.java @@ -17,6 +17,10 @@ import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; +/** + * @deprecated In preparation for moving to JUnit5 test suites are deprecated. See Bug 569839 + */ +@Deprecated public class CompletionTestSuite extends TestCase { public static Test suite() { diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/RewriteTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/RewriteTestSuite.java index 61fbef38589..27dca43e533 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/RewriteTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/RewriteTestSuite.java @@ -21,10 +21,14 @@ import org.eclipse.cdt.core.parser.tests.rewrite.comenthandler.CommentHandlingTe import junit.framework.Test; import junit.framework.TestSuite; -public class RewriteTests extends TestSuite { +/** + * @deprecated In preparation for moving to JUnit5 test suites are deprecated. See Bug 569839 + */ +@Deprecated +public class RewriteTestSuite extends TestSuite { public static Test suite() throws Exception { - TestSuite suite = new TestSuite(RewriteTests.class.getName()); + TestSuite suite = new TestSuite(RewriteTestSuite.class.getName()); suite.addTest(AstWriterTestSuite.suite()); suite.addTest(CommentHandlingTestSuite.suite()); suite.addTest(ChangeGeneratorTestSuite.suite()); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/ASTWriterTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/ASTWriterTester.java index 2cf218d0ba9..5818791bef3 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/ASTWriterTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/ASTWriterTester.java @@ -46,12 +46,12 @@ import org.eclipse.core.resources.IFile; /** * @author Guido Zgraggen */ -public class ASTWriterTest extends RewriteBaseTest { +public class ASTWriterTester extends RewriteBaseTest { private static final IParserLogService NULL_LOG = new NullLogService(); private IFile file; - public ASTWriterTest(String name, ASTWriterTestSourceFile file) { + public ASTWriterTester(String name, ASTWriterTestSourceFile file) { super(name); fileMap.put(file.getName(), file); } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/AstWriterTestSuite.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/AstWriterTestSuite.java index 46215cffe46..78a4bd634e7 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/AstWriterTestSuite.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/AstWriterTestSuite.java @@ -20,49 +20,14 @@ import junit.framework.TestSuite; /** * @author Emanuel Graf + * @deprecated In preparation for moving to JUnit5 test suites are deprecated. See Bug 569839 */ +@Deprecated public class AstWriterTestSuite { public static Test suite() throws Exception { - TestSuite suite = new TestSuite("AstWriterTests"); - suite.addTest( - SourceRewriteTester.suite("ExpressionTests", "resources/rewrite/ASTWriterExpressionTestSource.awts")); - - suite.addTest( - SourceRewriteTester.suite("DelcSpecifierTests", "resources/rewrite/ASTWriterDeclSpecTestSource.awts")); - suite.addTest(SourceRewriteTester.suite("Commented DelcSpecifierTests", - "resources/rewrite/ASTWriterCommentedDeclSpecTestSource.awts")); - - suite.addTest( - SourceRewriteTester.suite("DeclaratorTests", "resources/rewrite/ASTWriterDeclaratorTestSource.awts")); - suite.addTest(SourceRewriteTester.suite("Commented DeclaratorTests", - "resources/rewrite/ASTWriterCommentedDeclaratorTestSource.awts")); - - suite.addTest( - SourceRewriteTester.suite("StatementsTests", "resources/rewrite/ASTWriterStatementTestSource.awts")); - suite.addTest(SourceRewriteTester.suite("Commented StatementsTests", - "resources/rewrite/ASTWriterCommentedStatementTestSource.awts")); - - suite.addTest(SourceRewriteTester.suite("NameTests", "resources/rewrite/ASTWriterNameTestSource.awts")); - suite.addTest(SourceRewriteTester.suite("Commented NameTests", - "resources/rewrite/ASTWriterCommentedNameTestSource.awts")); - - suite.addTest( - SourceRewriteTester.suite("InitializerTests", "resources/rewrite/ASTWriterInitializerTestSource.awts")); - - suite.addTest( - SourceRewriteTester.suite("DeclarationTests", "resources/rewrite/ASTWriterDeclarationTestSource.awts")); - suite.addTest(SourceRewriteTester.suite("Commented DeclarationTests", - "resources/rewrite/ASTWriterCommentedDeclarationTestSource.awts")); - - suite.addTest( - SourceRewriteTester.suite("TemplatesTests", "resources/rewrite/ASTWriterTemplateTestSource.awts")); - - suite.addTest(SourceRewriteTester.suite("CommentTests", "resources/rewrite/ASTWriterCommentedTestSource.awts")); - suite.addTest( - SourceRewriteTester.suite("NewCommentTests", "resources/rewrite/ASTWriterCommentedTestSource2.awts")); - suite.addTest( - SourceRewriteTester.suite("AttributeTests", "resources/rewrite/ASTWriterAttributeTestSource.awts")); + TestSuite suite = new TestSuite("AstWriterTestSuite"); + suite.addTest(SourceRewriteTest.suite()); suite.addTestSuite(ExpressionWriterTest.class); return suite; } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/SourceRewriteTester.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/SourceRewriteTest.java index 384f4f0add7..bcccc29f09a 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/SourceRewriteTester.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/SourceRewriteTest.java @@ -32,7 +32,7 @@ import org.osgi.framework.Bundle; import junit.framework.Test; import junit.framework.TestSuite; -public class SourceRewriteTester extends TestSuite { +public class SourceRewriteTest extends TestSuite { private static final String testRegexp = "//!(.*)\\s*(\\w*)*$"; //$NON-NLS-1$ private static final String codeTypeRegexp = "//%(C|CPP)( GNU)?$"; //$NON-NLS-1$ private static final String resultRegexp = "//=.*$"; //$NON-NLS-1$ @@ -48,6 +48,48 @@ public class SourceRewriteTester extends TestSuite { return new BufferedReader(new FileReader(file)); } + public static Test suite() throws Exception { + TestSuite suite = new TestSuite("AstWriterTests"); + suite.addTest( + SourceRewriteTest.suite("ExpressionTests", "resources/rewrite/ASTWriterExpressionTestSource.awts")); + + suite.addTest( + SourceRewriteTest.suite("DelcSpecifierTests", "resources/rewrite/ASTWriterDeclSpecTestSource.awts")); + suite.addTest(SourceRewriteTest.suite("Commented DelcSpecifierTests", + "resources/rewrite/ASTWriterCommentedDeclSpecTestSource.awts")); + + suite.addTest( + SourceRewriteTest.suite("DeclaratorTests", "resources/rewrite/ASTWriterDeclaratorTestSource.awts")); + suite.addTest(SourceRewriteTest.suite("Commented DeclaratorTests", + "resources/rewrite/ASTWriterCommentedDeclaratorTestSource.awts")); + + suite.addTest( + SourceRewriteTest.suite("StatementsTests", "resources/rewrite/ASTWriterStatementTestSource.awts")); + suite.addTest(SourceRewriteTest.suite("Commented StatementsTests", + "resources/rewrite/ASTWriterCommentedStatementTestSource.awts")); + + suite.addTest(SourceRewriteTest.suite("NameTests", "resources/rewrite/ASTWriterNameTestSource.awts")); + suite.addTest(SourceRewriteTest.suite("Commented NameTests", + "resources/rewrite/ASTWriterCommentedNameTestSource.awts")); + + suite.addTest( + SourceRewriteTest.suite("InitializerTests", "resources/rewrite/ASTWriterInitializerTestSource.awts")); + + suite.addTest( + SourceRewriteTest.suite("DeclarationTests", "resources/rewrite/ASTWriterDeclarationTestSource.awts")); + suite.addTest(SourceRewriteTest.suite("Commented DeclarationTests", + "resources/rewrite/ASTWriterCommentedDeclarationTestSource.awts")); + + suite.addTest(SourceRewriteTest.suite("TemplatesTests", "resources/rewrite/ASTWriterTemplateTestSource.awts")); + + suite.addTest(SourceRewriteTest.suite("CommentTests", "resources/rewrite/ASTWriterCommentedTestSource.awts")); + suite.addTest( + SourceRewriteTest.suite("NewCommentTests", "resources/rewrite/ASTWriterCommentedTestSource2.awts")); + suite.addTest(SourceRewriteTest.suite("AttributeTests", "resources/rewrite/ASTWriterAttributeTestSource.awts")); + suite.addTestSuite(ExpressionWriterTest.class); + return suite; + } + public static Test suite(String name, String file) throws Exception { BufferedReader in = createReader(file); ArrayList<RewriteBaseTest> testCases = createTests(in); @@ -157,7 +199,7 @@ public class SourceRewriteTester extends TestSuite { } private static RewriteBaseTest createTestClass(String testName, ASTWriterTestSourceFile file) throws Exception { - ASTWriterTest test = new ASTWriterTest(testName, file); + ASTWriterTester test = new ASTWriterTester(testName, file); TextSelection sel = file.getSelection(); if (sel != null) { test.setFileWithSelection(file.getName()); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/ChangeGeneratorTestSuite.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/ChangeGeneratorTestSuite.java index 69cc22dd83c..d6cb1974425 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/ChangeGeneratorTestSuite.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/ChangeGeneratorTestSuite.java @@ -19,7 +19,9 @@ import junit.framework.TestSuite; /** * @author Thomas Corbat + * @deprecated In preparation for moving to JUnit5 test suites are deprecated. See Bug 569839 */ +@Deprecated public class ChangeGeneratorTestSuite { public static Test suite() throws Exception { diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/comenthandler/CommentHandlingTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/comenthandler/CommentHandlingTest.java index 68f0ad65715..223e4023b20 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/comenthandler/CommentHandlingTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/comenthandler/CommentHandlingTest.java @@ -29,12 +29,16 @@ import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.parser.tests.rewrite.RewriteBaseTest; +import org.eclipse.cdt.core.parser.tests.rewrite.RewriteTester; import org.eclipse.cdt.core.parser.tests.rewrite.TestSourceFile; import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.ASTCommenter; import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.Path; +import junit.framework.Test; +import junit.framework.TestSuite; + /** * This test tests the behavior of the class ASTCommenter. It checks if the ASTCommenter assigns * the comments contained in an AST to the right ASTNodes.<br> @@ -92,6 +96,12 @@ public class CommentHandlingTest extends RewriteBaseTest { super(name, files); } + public static Test suite() throws Exception { + TestSuite suite = new TestSuite(CommentHandlingTestSuite.class.getName()); + suite.addTest(RewriteTester.suite("CommentTests", "resources/rewrite/CommentHandlingTestSource.rts")); //$NON-NLS-1$ + return suite; + } + @Override protected void runTest() throws Throwable { if (fileMap.isEmpty()) { diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/comenthandler/CommentHandlingTestSuite.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/comenthandler/CommentHandlingTestSuite.java index 75cd37ff73f..d851284002a 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/comenthandler/CommentHandlingTestSuite.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/comenthandler/CommentHandlingTestSuite.java @@ -14,21 +14,20 @@ ******************************************************************************/ package org.eclipse.cdt.core.parser.tests.rewrite.comenthandler; -import org.eclipse.cdt.core.parser.tests.rewrite.RewriteTester; - import junit.framework.Test; import junit.framework.TestSuite; /** * @author Guido Zgraggen IFS + * @deprecated In preparation for moving to JUnit5 test suites are deprecated. See Bug 569839 */ +@Deprecated public class CommentHandlingTestSuite extends TestSuite { public static Test suite() throws Exception { TestSuite suite = new TestSuite(CommentHandlingTestSuite.class.getName()); - suite.addTest(RewriteTester.suite("CommentTests", "resources/rewrite/CommentHandlingTestSource.rts")); //$NON-NLS-1$ - suite.addTest( - RewriteTester.suite("CommentMultiFileTests", "resources/rewrite/CommentHandlingWithRewriteTest.rts")); //$NON-NLS-1$ + suite.addTest(CommentHandlingTest.suite()); + suite.addTest(CommentHandlingWithRewriteTest.suite()); suite.addTestSuite(NodeCommentMapTest.class); return suite; } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/comenthandler/CommentHandlingWithRewriteTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/comenthandler/CommentHandlingWithRewriteTest.java index 0e20d7e8401..0b867d23ef2 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/comenthandler/CommentHandlingWithRewriteTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/comenthandler/CommentHandlingWithRewriteTest.java @@ -20,10 +20,14 @@ import java.util.List; import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.core.dom.rewrite.ASTRewrite; +import org.eclipse.cdt.core.parser.tests.rewrite.RewriteTester; import org.eclipse.cdt.core.parser.tests.rewrite.TestSourceFile; import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap; import org.eclipse.text.edits.TextEditGroup; +import junit.framework.Test; +import junit.framework.TestSuite; + public class CommentHandlingWithRewriteTest extends CommentHandlingTest { private ASTRewrite newRewrite; @@ -31,6 +35,13 @@ public class CommentHandlingWithRewriteTest extends CommentHandlingTest { super(name, files); } + public static Test suite() throws Exception { + TestSuite suite = new TestSuite(CommentHandlingTestSuite.class.getName()); + suite.addTest( + RewriteTester.suite("CommentMultiFileTests", "resources/rewrite/CommentHandlingWithRewriteTest.rts")); //$NON-NLS-1$ + return suite; + } + @Override protected void runTest() throws Throwable { IASTTranslationUnit tu = getUnit("main.cpp"); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/InclusionTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/InclusionTests.java index 1f81668a075..882a9b89077 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/InclusionTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/InclusionTests.java @@ -16,10 +16,13 @@ package org.eclipse.cdt.core.parser.tests.scanner; import java.util.Collections; +import java.util.HashMap; +import java.util.Map; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.parser.ExtendedScannerInfo; import org.eclipse.cdt.core.parser.FileContent; +import org.eclipse.cdt.core.parser.IProblem; import org.eclipse.cdt.core.parser.IScannerInfo; import org.eclipse.cdt.core.parser.IToken; import org.eclipse.cdt.core.parser.ParserLanguage; @@ -261,6 +264,136 @@ public class InclusionTests extends PreprocessorTestsBase { validateEOF(); } + // #if __has_include("does_not_exist.h") + // inactive + // #endif + // #if !__has_include("does_not_exist.h") + // identifier + // #endif + // + // #if __has_include("test.h") + // identifier2 + // #endif + // #if !__has_include("test.h") + // inactive + // #endif + // + // #if __has_include(<test.h>) + // identifier3 + // #endif + // + // #define MACRO __has_include("test.h") + // #if MACRO + // identifier4 + // #endif + // + // #define MACRO2 __has_include(<test.h>) + // #if MACRO2 + // identifier5 + // #endif + // + // #define HEADER_NAME "test.h" + // #define MACRO3 __has_include(HEADER_NAME) + // #if MACRO3 + // identifier6 + // #endif + // + // //Note: This one works with Clang and MSVC but not GCC. + // #define HEADER_NAME2 ("test.h") + // #define MACRO4 __has_include HEADER_NAME2 + // #if MACRO4 + // identifier7 + // #endif + // + // #ifdef __has_include + // identifier8 + // #endif + // + // #if defined(__has_include) + // identifier9 + // #endif + public void testHasInclude() throws Exception { + importFile("test.h", ""); + IFile base = importFile("test.cpp", getAboveComment()); + IScannerInfo scannerInfo = new ExtendedScannerInfo(Collections.EMPTY_MAP, + new String[] { fProject.getProject().getLocation().toOSString() }, new String[] {}, null); + FileContent reader = FileContent.create(base); + initializeScanner(reader, ParserLanguage.CPP, ParserMode.COMPLETE_PARSE, scannerInfo); + validateIdentifier("identifier"); + validateIdentifier("identifier2"); + validateIdentifier("identifier3"); + validateIdentifier("identifier4"); + validateIdentifier("identifier5"); + validateIdentifier("identifier6"); + validateIdentifier("identifier7"); + validateIdentifier("identifier8"); + validateIdentifier("identifier9"); + validateEOF(); + } + + // #include "foo.h" + // + // #ifdef __has_include_next + // identifier4 + // #endif + // + // #if defined(__has_include_next) + // identifier5 + // #endif + + // identifier + // #include "intermed.h" + + // identifier2 + // #if __has_include_next(<foo.h>) + // #include_next <foo.h> + // #endif + + // identifier3 + public void testHasIncludeNext() throws Exception { + StringBuilder[] sections = getTestContent(4); + String baseFile = sections[0].toString(); //$NON-NLS-1$ + String foo1 = sections[1].toString(); //$NON-NLS-1$ + String intermed = sections[2].toString(); //$NON-NLS-1$ + String foo2 = sections[3].toString(); //$NON-NLS-1$ + + IFolder one = importFolder("one"); //$NON-NLS-1$ + IFolder two = importFolder("two"); //$NON-NLS-1$ + IFile base = importFile("base.cpp", baseFile); //$NON-NLS-1$ + importFile("one/foo.h", foo1); //$NON-NLS-1$ + importFile("one/intermed.h", intermed); //$NON-NLS-1$ + importFile("two/foo.h", foo2); //$NON-NLS-1$ + + String[] path = new String[2]; + path[0] = one.getLocation().toOSString(); + path[1] = two.getLocation().toOSString(); + + Map<String, String> definedSymbols = new HashMap<>(); + definedSymbols.put("__GNUC__", "5"); + definedSymbols.put("__GNUC_MINOR__", "0"); + + IScannerInfo scannerInfo = new ExtendedScannerInfo(definedSymbols, path, new String[] {}, null); + FileContent reader = FileContent.create(base); + initializeScanner(reader, ParserLanguage.CPP, ParserMode.COMPLETE_PARSE, scannerInfo); + validateIdentifier("identifier"); + validateIdentifier("identifier2"); + validateIdentifier("identifier3"); + validateIdentifier("identifier4"); + validateIdentifier("identifier5"); + } + + // void foo() { + // __has_include; + // } + public void testHasIncludeProblem() throws Exception { + IFile base = importFile("test.cpp", getAboveComment()); + IScannerInfo scannerInfo = new ExtendedScannerInfo(Collections.EMPTY_MAP, null, new String[] {}, null); + FileContent reader = FileContent.create(base); + initializeScanner(reader, ParserLanguage.CPP, ParserMode.COMPLETE_PARSE, scannerInfo); + fullyTokenize(); + validateProblem(0, IProblem.PREPROCESSOR_INVALID_USE_OUTSIDE_PREPROCESSOR_DIRECTIVE, "__has_include"); + } + // #include <inc/test.h> public void testRelativeIncludes_243170() throws Exception { String content = getAboveComment(); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/ScannerTestSuite.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/ScannerTestSuite.java index 66430a1d156..8c00d61e3e6 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/ScannerTestSuite.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/ScannerTestSuite.java @@ -16,6 +16,10 @@ package org.eclipse.cdt.core.parser.tests.scanner; import junit.framework.Test; import junit.framework.TestSuite; +/** + * @deprecated In preparation for moving to JUnit5 test suites are deprecated. See Bug 569839 + */ +@Deprecated public class ScannerTestSuite extends TestSuite { public static Test suite() { 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/parser/org/eclipse/cdt/internal/index/tests/IndexCBindingResolutionBugs.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCBindingResolutionBugsTest.java index d65e0fc4295..ef8a437da2b 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCBindingResolutionBugs.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCBindingResolutionBugsTest.java @@ -36,31 +36,31 @@ import junit.framework.TestSuite; /** * For testing PDOM binding resolution */ -public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase { +public abstract class IndexCBindingResolutionBugsTest extends IndexBindingResolutionTestBase { - public static class SingleProject extends IndexCBindingResolutionBugs { - public SingleProject() { + public static class SingleProjectTest extends IndexCBindingResolutionBugsTest { + public SingleProjectTest() { setStrategy(new SinglePDOMTestStrategy(false)); } public static TestSuite suite() { - return suite(SingleProject.class); + return suite(SingleProjectTest.class); } } - public static class ProjectWithDepProj extends IndexCBindingResolutionBugs { - public ProjectWithDepProj() { + public static class ProjectWithDepProjTest extends IndexCBindingResolutionBugsTest { + public ProjectWithDepProjTest() { setStrategy(new ReferencedProject(false)); } public static TestSuite suite() { - return suite(ProjectWithDepProj.class); + return suite(ProjectWithDepProjTest.class); } } public static void addTests(TestSuite suite) { - suite.addTest(SingleProject.suite()); - suite.addTest(ProjectWithDepProj.suite()); + suite.addTest(SingleProjectTest.suite()); + suite.addTest(ProjectWithDepProjTest.suite()); } // #include <stdio.h> diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCBindingResolutionTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCBindingResolutionTest.java index 75812e04f7a..f0ef997430a 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCBindingResolutionTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCBindingResolutionTest.java @@ -38,31 +38,31 @@ import junit.framework.TestSuite; * additionally check that the binding obtained has characteristics as * expected (type,name,etc..) */ -public class IndexCBindingResolutionTest extends IndexBindingResolutionTestBase { +public abstract class IndexCBindingResolutionTest extends IndexBindingResolutionTestBase { - public static class SingleProject extends IndexCBindingResolutionTest { - public SingleProject() { + public static class SingleProjectTest extends IndexCBindingResolutionTest { + public SingleProjectTest() { setStrategy(new SinglePDOMTestStrategy(false)); } public static TestSuite suite() { - return suite(SingleProject.class); + return suite(SingleProjectTest.class); } } - public static class ProjectWithDepProj extends IndexCBindingResolutionTest { - public ProjectWithDepProj() { + public static class ProjectWithDepProjTest extends IndexCBindingResolutionTest { + public ProjectWithDepProjTest() { setStrategy(new ReferencedProject(false)); } public static TestSuite suite() { - return suite(ProjectWithDepProj.class); + return suite(ProjectWithDepProjTest.class); } } public static void addTests(TestSuite suite) { - suite.addTest(SingleProject.suite()); - suite.addTest(ProjectWithDepProj.suite()); + suite.addTest(SingleProjectTest.suite()); + suite.addTest(ProjectWithDepProjTest.suite()); } public IndexCBindingResolutionTest() { diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionBugsSingleProjectFirstAST.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionBugsSingleProjectFirstASTTest.java index dc8a280a747..df0645588a4 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionBugsSingleProjectFirstAST.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionBugsSingleProjectFirstASTTest.java @@ -15,13 +15,13 @@ package org.eclipse.cdt.internal.index.tests; import junit.framework.TestSuite; -public class IndexCPPBindingResolutionBugsSingleProjectFirstAST extends IndexCPPBindingResolutionBugs { - public IndexCPPBindingResolutionBugsSingleProjectFirstAST() { +public class IndexCPPBindingResolutionBugsSingleProjectFirstASTTest extends IndexCPPBindingResolutionBugsTest { + public IndexCPPBindingResolutionBugsSingleProjectFirstASTTest() { setStrategy(new SinglePDOMTestFirstASTStrategy(true)); } public static TestSuite suite() { - return suite(IndexCPPBindingResolutionBugsSingleProjectFirstAST.class); + return suite(IndexCPPBindingResolutionBugsSingleProjectFirstASTTest.class); } /* Invalid tests for this strategy, they assume that the second file is already indexed. */ diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionBugs.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionBugsTest.java index d1f4f6c6239..75c2e29af3c 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionBugs.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionBugsTest.java @@ -70,39 +70,39 @@ import junit.framework.TestSuite; /** * For testing PDOM binding resolution */ -public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBase { +public abstract class IndexCPPBindingResolutionBugsTest extends IndexBindingResolutionTestBase { - public static class SingleProject extends IndexCPPBindingResolutionBugs { - public SingleProject() { + public static class SingleProjectTest extends IndexCPPBindingResolutionBugsTest { + public SingleProjectTest() { setStrategy(new SinglePDOMTestStrategy(true)); } public static TestSuite suite() { - return suite(SingleProject.class); + return suite(SingleProjectTest.class); } } - public static class ProjectWithDepProj extends IndexCPPBindingResolutionBugs { - public ProjectWithDepProj() { + public static class ProjectWithDepProjTest extends IndexCPPBindingResolutionBugsTest { + public ProjectWithDepProjTest() { setStrategy(new ReferencedProject(true)); } public static TestSuite suite() { - return suite(ProjectWithDepProj.class); + return suite(ProjectWithDepProjTest.class); } } public static void addTests(TestSuite suite) { - suite.addTest(IndexCPPBindingResolutionBugsSingleProjectFirstAST.suite()); - suite.addTest(SingleProject.suite()); - suite.addTest(ProjectWithDepProj.suite()); + suite.addTest(IndexCPPBindingResolutionBugsSingleProjectFirstASTTest.suite()); + suite.addTest(SingleProjectTest.suite()); + suite.addTest(ProjectWithDepProjTest.suite()); } public static TestSuite suite() { - return suite(IndexCPPBindingResolutionBugs.class); + return suite(IndexCPPBindingResolutionBugsTest.class); } - public IndexCPPBindingResolutionBugs() { + public IndexCPPBindingResolutionBugsTest() { setStrategy(new SinglePDOMTestStrategy(true)); } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java index 5385a977821..96c2b0a2a42 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java @@ -65,31 +65,31 @@ import junit.framework.TestSuite; * additionally check that the binding obtained has characteristics as * expected (type,name,etc..) */ -public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBase { +public abstract class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBase { - public static class SingleProject extends IndexCPPBindingResolutionTest { - public SingleProject() { + public static class SingleProjectTest extends IndexCPPBindingResolutionTest { + public SingleProjectTest() { setStrategy(new SinglePDOMTestStrategy(true)); } public static TestSuite suite() { - return suite(SingleProject.class); + return suite(SingleProjectTest.class); } } - public static class ProjectWithDepProj extends IndexCPPBindingResolutionTest { - public ProjectWithDepProj() { + public static class ProjectWithDepProjTest extends IndexCPPBindingResolutionTest { + public ProjectWithDepProjTest() { setStrategy(new ReferencedProject(true)); } public static TestSuite suite() { - return suite(ProjectWithDepProj.class); + return suite(ProjectWithDepProjTest.class); } } public static void addTests(TestSuite suite) { - suite.addTest(SingleProject.suite()); - suite.addTest(ProjectWithDepProj.suite()); + suite.addTest(SingleProjectTest.suite()); + suite.addTest(ProjectWithDepProjTest.suite()); } public IndexCPPBindingResolutionTest() { @@ -97,7 +97,7 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas } public static TestSuite suite() { - return suite(SingleProject.class); + return suite(SingleProjectTest.class); } /* Assertion helpers */ diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java index 6c4e7560dd2..74f72fda672 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java @@ -77,25 +77,25 @@ import junit.framework.TestSuite; /** * Tests for exercising resolution of template bindings against IIndex */ -public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBase { +public abstract class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBase { - public static class SingleProject extends IndexCPPTemplateResolutionTest { - public SingleProject() { + public static class SingleProjectTest extends IndexCPPTemplateResolutionTest { + public SingleProjectTest() { setStrategy(new SinglePDOMTestStrategy(true)); } public static TestSuite suite() { - return suite(SingleProject.class); + return suite(SingleProjectTest.class); } } - public static class ProjectWithDepProj extends IndexCPPTemplateResolutionTest { - public ProjectWithDepProj() { + public static class ProjectWithDepProjTest extends IndexCPPTemplateResolutionTest { + public ProjectWithDepProjTest() { setStrategy(new ReferencedProject(true)); } public static TestSuite suite() { - return suite(ProjectWithDepProj.class); + return suite(ProjectWithDepProjTest.class); } @Override @@ -106,8 +106,8 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa } public static void addTests(TestSuite suite) { - suite.addTest(SingleProject.suite()); - suite.addTest(ProjectWithDepProj.suite()); + suite.addTest(SingleProjectTest.suite()); + suite.addTest(ProjectWithDepProjTest.suite()); } public IndexCPPTemplateResolutionTest() { diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPVariableTemplateResolutionTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPVariableTemplateResolutionTest.java index d33fb2b7140..8f824880d25 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPVariableTemplateResolutionTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPVariableTemplateResolutionTest.java @@ -24,31 +24,31 @@ import org.eclipse.cdt.core.index.IIndexBinding; import junit.framework.TestSuite; -public class IndexCPPVariableTemplateResolutionTest extends IndexBindingResolutionTestBase { +public abstract class IndexCPPVariableTemplateResolutionTest extends IndexBindingResolutionTestBase { - public static class SingleProject extends IndexCPPVariableTemplateResolutionTest { - public SingleProject() { + public static class SingleProjectTest extends IndexCPPVariableTemplateResolutionTest { + public SingleProjectTest() { setStrategy(new SinglePDOMTestStrategy(true)); } public static TestSuite suite() { - return suite(SingleProject.class); + return suite(SingleProjectTest.class); } } - public static class ProjectWithDepProj extends IndexCPPVariableTemplateResolutionTest { - public ProjectWithDepProj() { + public static class ProjectWithDepProjTest extends IndexCPPVariableTemplateResolutionTest { + public ProjectWithDepProjTest() { setStrategy(new ReferencedProject(true)); } public static TestSuite suite() { - return suite(ProjectWithDepProj.class); + return suite(ProjectWithDepProjTest.class); } } public static void addTests(TestSuite suite) { - suite.addTest(SingleProject.suite()); - suite.addTest(ProjectWithDepProj.suite()); + suite.addTest(SingleProjectTest.suite()); + suite.addTest(ProjectWithDepProjTest.suite()); } public IndexCPPVariableTemplateResolutionTest() { diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexGPPBindingResolutionTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexGPPBindingResolutionTest.java index 1b362f46077..0949aba788d 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexGPPBindingResolutionTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexGPPBindingResolutionTest.java @@ -70,29 +70,29 @@ public abstract class IndexGPPBindingResolutionTest extends IndexBindingResoluti } } - public static class SingleProject extends IndexGPPBindingResolutionTest { - public SingleProject() { + public static class SingleProjectTest extends IndexGPPBindingResolutionTest { + public SingleProjectTest() { setStrategy(new GPPSinglePDOMTestStrategy()); } public static TestSuite suite() { - return suite(SingleProject.class); + return suite(SingleProjectTest.class); } } - public static class ProjectWithDepProj extends IndexGPPBindingResolutionTest { - public ProjectWithDepProj() { + public static class ProjectWithDepProjTest extends IndexGPPBindingResolutionTest { + public ProjectWithDepProjTest() { setStrategy(new GPPReferencedProject()); } public static TestSuite suite() { - return suite(ProjectWithDepProj.class); + return suite(ProjectWithDepProjTest.class); } } public static void addTests(TestSuite suite) { - suite.addTest(SingleProject.suite()); - suite.addTest(ProjectWithDepProj.suite()); + suite.addTest(SingleProjectTest.suite()); + suite.addTest(ProjectWithDepProjTest.suite()); } // struct B { diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexIncludeTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexIncludeTest.java index 4f59f62f746..805e6e1ad7d 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexIncludeTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexIncludeTest.java @@ -14,7 +14,11 @@ *******************************************************************************/ package org.eclipse.cdt.internal.index.tests; +import static org.eclipse.cdt.core.testplugin.util.TestSourceReader.createFile; + import java.io.ByteArrayInputStream; +import java.util.HashSet; +import java.util.Set; import java.util.regex.Pattern; import org.eclipse.cdt.core.CCorePlugin; @@ -25,6 +29,7 @@ import org.eclipse.cdt.core.dom.ast.IVariable; import org.eclipse.cdt.core.index.IIndex; import org.eclipse.cdt.core.index.IIndexBinding; import org.eclipse.cdt.core.index.IIndexFile; +import org.eclipse.cdt.core.index.IIndexFileLocation; import org.eclipse.cdt.core.index.IIndexInclude; import org.eclipse.cdt.core.index.IndexFilter; import org.eclipse.cdt.core.index.IndexLocationFactory; @@ -36,11 +41,13 @@ import org.eclipse.cdt.core.testplugin.TestScannerProvider; import org.eclipse.cdt.core.testplugin.util.TestSourceReader; import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences; import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IWorkspaceRunnable; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.Path; +import org.junit.Assert; import junit.framework.TestSuite; @@ -642,6 +649,143 @@ public class IndexIncludeTest extends IndexTestBase { } } + // #pragma once + // #ifdef ABC + // int x = 5; + // #endif + + // #pragma once + // #include "b.hpp" + + // #pragma once + // #include "b.hpp" + + // #include "a1.hpp" + // #include "a2.hpp" + public void testSignificantMacrosWithPragmeOnceSemantic() throws Exception { + waitForIndexer(); + IProject prj = fProject.getProject(); + TestScannerProvider.sIncludes = new String[] { prj.getLocation().toOSString() }; + CharSequence[] contents = getContentsForTest(5); + + IFile b = createFile(prj, "b.hpp", contents[0].toString()); + IFile a1 = createFile(prj, "a1.hpp", contents[1].toString()); + IFile a2 = createFile(prj, "a2.hpp", contents[2].toString()); + + final IFile main = createFile(prj, "UltimateTest.cpp", contents[3].toString()); + + waitUntilFileIsIndexed(fIndex, b); + waitUntilFileIsIndexed(fIndex, a1); + waitUntilFileIsIndexed(fIndex, a2); + waitUntilFileIsIndexed(fIndex, main); + + fIndex.acquireReadLock(); + try { + IIndexFile[] indexFiles = fIndex.getFiles(ILinkage.CPP_LINKAGE_ID, + IndexLocationFactory.getWorkspaceIFL(main)); + + IIndexFile ultimateTestCppIdx = indexFiles[0]; + IIndexFile includes[] = new IIndexFile[3]; + includes[0] = fIndex.getFiles(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(b))[0]; + includes[1] = fIndex.getFiles(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(a1))[0]; + includes[2] = fIndex.getFiles(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(a2))[0]; + + for (int i = 0; i < includes.length; i++) { + IIndexFile include = includes[i]; + outputUnresolvedIncludes(fIndex, include.getLocation(), ultimateTestCppIdx, new HashSet<IIndexFile>()); + } + } finally { + fIndex.releaseReadLock(); + } + } + + // #pragma once + // #ifdef ABC + // int x = 5; + // #endif + + // #pragma once + // #include "b.hpp" + + // #pragma once + // #include "b.hpp" + + // #pragma once + // #include "b.hpp" + + // #pragma once + // #include "b.hpp" + + // #include "a1.hpp" + // #include "a2.hpp" + + // #include "a3.hpp" + // #include "a4.hpp" + public void testSignificantMacrosWithPragmeOnceFromIdxSemantic() throws Exception { + waitForIndexer(); + IProject prj = fProject.getProject(); + TestScannerProvider.sIncludes = new String[] { prj.getLocation().toOSString() }; + CharSequence[] contents = getContentsForTest(7); + + IFile b = createFile(prj, "b.hpp", contents[0].toString()); + IFile a1 = createFile(prj, "a1.hpp", contents[1].toString()); + IFile a2 = createFile(prj, "a2.hpp", contents[2].toString()); + IFile a3 = createFile(prj, "a3.hpp", contents[3].toString()); + IFile a4 = createFile(prj, "a4.hpp", contents[4].toString()); + + final IFile s1 = createFile(prj, "s1.cpp", contents[5].toString()); + final IFile s2 = createFile(prj, "s2.cpp", contents[6].toString()); + + waitUntilFileIsIndexed(fIndex, b); + waitUntilFileIsIndexed(fIndex, a1); + waitUntilFileIsIndexed(fIndex, a2); + waitUntilFileIsIndexed(fIndex, a3); + waitUntilFileIsIndexed(fIndex, a4); + waitUntilFileIsIndexed(fIndex, s1); + waitUntilFileIsIndexed(fIndex, s2); + + fIndex.acquireReadLock(); + try { + IIndexFile[] indexFiles = fIndex.getFiles(ILinkage.CPP_LINKAGE_ID, + IndexLocationFactory.getWorkspaceIFL(s1)); + + IIndexFile ultimateTestCppIdx = indexFiles[0]; + IIndexFile includes[] = new IIndexFile[5]; + includes[0] = fIndex.getFiles(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(b))[0]; + includes[1] = fIndex.getFiles(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(a1))[0]; + includes[2] = fIndex.getFiles(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(a2))[0]; + includes[3] = fIndex.getFiles(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(a3))[0]; + includes[4] = fIndex.getFiles(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(a4))[0]; + + for (int i = 0; i < includes.length; i++) { + IIndexFile include = includes[i]; + outputUnresolvedIncludes(fIndex, include.getLocation(), ultimateTestCppIdx, new HashSet<IIndexFile>()); + } + } finally { + fIndex.releaseReadLock(); + } + } + + private void outputUnresolvedIncludes(IIndex index, IIndexFileLocation ifl, IIndexFile ifile, + Set<IIndexFile> handled) throws CoreException { + if (ifile == null) { + Assert.fail(ifl.getURI() + " is not indexed"); + } else if (handled.add(ifile)) { + IIndexInclude[] includes = ifile.getIncludes(); + for (IIndexInclude inc : includes) { + if (inc.isActive()) { + if (inc.isResolved()) { + IIndexFile next = index.resolveInclude(inc); + outputUnresolvedIncludes(index, inc.getIncludesLocation(), next, handled); + } else { + Assert.fail("Unresolved inclusion: " + inc.getFullName() + " in file " + + inc.getIncludedByLocation().getURI()); + } + } + } + } + } + private void standardCheckUpdateIncludes(IFile header, IFile s1, String tag) throws Exception { fIndex.acquireReadLock(); try { diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexTestSuite.java index 12a6ac0f346..6e970d10e30 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexTestSuite.java @@ -24,10 +24,12 @@ import junit.framework.TestSuite; /** * Test suite for the indexer tests + * @deprecated In preparation for moving to JUnit5 test suites are deprecated. See Bug 569839 */ -public class IndexTests extends TestSuite { +@Deprecated +public class IndexTestSuite extends TestSuite { public static Test suite() { - TestSuite suite = new IndexTests(); + TestSuite suite = new IndexTestSuite(); suite.addTest(IndexCompositeTests.suite()); suite.addTest(IndexListenerTest.suite()); @@ -51,11 +53,11 @@ public class IndexTests extends TestSuite { suite.addTestSuite(TemplateAutoIndexTests.class); suite.addTestSuite(StructuredBindingIndexTests.class); - IndexCPPBindingResolutionBugs.addTests(suite); + IndexCPPBindingResolutionBugsTest.addTests(suite); IndexCPPBindingResolutionTest.addTests(suite); IndexGPPBindingResolutionTest.addTests(suite); IndexCPPTemplateResolutionTest.addTests(suite); - IndexCBindingResolutionBugs.addTests(suite); + IndexCBindingResolutionBugsTest.addTests(suite); IndexCBindingResolutionTest.addTests(suite); IndexCPPVariableTemplateResolutionTest.addTests(suite); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/TeamSharedIndexTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/TeamSharedIndexTest.java index 1bcdecaf8b3..4c7486907f5 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/TeamSharedIndexTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/TeamSharedIndexTest.java @@ -29,6 +29,7 @@ import org.eclipse.cdt.core.index.IndexFilter; import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.testplugin.CProjectHelper; +import org.eclipse.cdt.core.testplugin.util.ModelJoiner; import org.eclipse.cdt.core.testplugin.util.TestSourceReader; import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences; import org.eclipse.core.resources.IFile; diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/BTreeExpensiveTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/BTreeExpensiveTests.java index 6243210c693..cc937ccaa4d 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/BTreeExpensiveTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/BTreeExpensiveTests.java @@ -13,7 +13,9 @@ *******************************************************************************/ package org.eclipse.cdt.internal.pdom.tests; -import junit.framework.Test; +import org.eclipse.cdt.core.testplugin.util.BaseTestCase5; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; /** * Tests which are too expensive to run as part of normal testing, but @@ -23,36 +25,31 @@ import junit.framework.Test; * invariants after each B-tree operation, and so are especially * expensive and cpu hungry. */ +@Tag(BaseTestCase5.SLOW_TEST_TAG) public class BTreeExpensiveTests extends BTreeTests { - public static Test suite() { - return suite(BTreeExpensiveTests.class); - } - + @Test public void testBySortedSetMirror() throws Exception { sortedMirrorTest(100); } - // @Override - @Override - public void testInsertion() throws Exception { - super.testInsertion(); - } - /* * N.B. Each of the following tests are quite expensive (i.e. > 10mins each on a 2Ghz machine) */ + @Test public void testBySortedSetMirror1682762087() throws Exception { System.out.println("1682762087 Full Checking"); trial(1682762087, true); // exposed bugs in 2a,b } + @Test public void testBySortedSetMirror322922974() throws Exception { System.out.println("322922974 Full Checking"); trial(322922974, true); // exposed bugs in 3b(ii) } + @Test public void testBySortedSetMirror_588448152() throws Exception { System.out.println("-588448152 Full Checking"); trial(-588448152, true); // exposed root-delete-on-merge problems diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/BTreeTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/BTreeTests.java index 85ccc104029..cdf508afccc 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/BTreeTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/BTreeTests.java @@ -14,6 +14,9 @@ *******************************************************************************/ package org.eclipse.cdt.internal.pdom.tests; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; + import java.io.File; import java.util.ArrayList; import java.util.Iterator; @@ -22,22 +25,21 @@ import java.util.Random; import java.util.SortedSet; import java.util.TreeSet; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; +import org.eclipse.cdt.core.testplugin.util.BaseTestCase5; import org.eclipse.cdt.internal.core.pdom.db.BTree; import org.eclipse.cdt.internal.core.pdom.db.ChunkCache; import org.eclipse.cdt.internal.core.pdom.db.Database; import org.eclipse.cdt.internal.core.pdom.db.IBTreeComparator; import org.eclipse.cdt.internal.core.pdom.db.IBTreeVisitor; import org.eclipse.core.runtime.CoreException; - -import junit.framework.Test; +import org.junit.jupiter.api.Test; /** * Test insertion/deletion of records of a mock record type in a B-tree. * * @author aferguso */ -public class BTreeTests extends BaseTestCase { +public class BTreeTests extends BaseTestCase5 { private static int DEBUG = 0; protected File dbFile; protected Database db; @@ -45,10 +47,6 @@ public class BTreeTests extends BaseTestCase { protected int rootRecord; protected IBTreeComparator comparator; - public static Test suite() { - return suite(BTreeTests.class); - } - // setUp is not used since we need to parameterize this method, // and invoke it multiple times per Junit test protected void init(int degree) throws Exception { @@ -66,6 +64,7 @@ public class BTreeTests extends BaseTestCase { dbFile.deleteOnExit(); } + @Test public void testBySortedSetMirrorLite() throws Exception { sortedMirrorTest(8); } @@ -91,6 +90,7 @@ public class BTreeTests extends BaseTestCase { * and use TreeSet as a reference implementation to check behaviour against. * @throws Exception */ + @Test public void testInsertion() throws Exception { Random seeder = new Random(); @@ -105,6 +105,7 @@ public class BTreeTests extends BaseTestCase { /** * Bug 402177: BTree.insert should return the matching record if the new record was not inserted. */ + @Test public void testEquivalentRecordInsert_Bug402177() throws Exception { init(8); try { @@ -208,7 +209,7 @@ public class BTreeTests extends BaseTestCase { BTMockRecord btValue = new BTMockRecord(record, db); if (i.hasNext()) { Integer exp = ((Integer) i.next()); - assertEquals(msg + " Differ at index: " + k, btValue.intValue(), exp.intValue()); + assertEquals(btValue.intValue(), exp.intValue(), msg + " Differ at index: " + k); k++; } else { fail("Sizes different"); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/ChangeConfigurationTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/ChangeConfigurationTests.java index 86d90490a8d..8f6b1dab75c 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/ChangeConfigurationTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/ChangeConfigurationTests.java @@ -31,6 +31,7 @@ import org.eclipse.cdt.core.settings.model.ICSettingEntry; import org.eclipse.cdt.core.settings.model.util.CDataUtil; import org.eclipse.cdt.core.testplugin.CProjectHelper; import org.eclipse.cdt.core.testplugin.CTestPlugin; +import org.eclipse.cdt.core.testplugin.util.ModelJoiner; import org.eclipse.cdt.core.testplugin.util.TestSourceReader; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMSearchTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMSearchTest.java index cb3069e238b..42a6f15461d 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMSearchTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMSearchTest.java @@ -48,7 +48,7 @@ import junit.framework.Test; * @author Vivian Kong */ public class PDOMSearchTest extends PDOMTestBase { - final Comparator<IBinding> BINDING_COMPARATOR = new Comparator<IBinding>() { + final Comparator<IBinding> BINDING_COMPARATOR = new Comparator<>() { @Override public int compare(IBinding b1, IBinding b2) { return b1.getName().compareTo(b2.getName()); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMTestBase.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMTestBase.java index 9bb0fe1f6d7..5d4f6a97937 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMTestBase.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMTestBase.java @@ -38,6 +38,7 @@ import org.eclipse.cdt.core.parser.tests.VisibilityAsserts; import org.eclipse.cdt.core.testplugin.CProjectHelper; import org.eclipse.cdt.core.testplugin.CTestPlugin; import org.eclipse.cdt.core.testplugin.util.BaseTestCase; +import org.eclipse.cdt.core.testplugin.util.ModelJoiner; import org.eclipse.cdt.core.testplugin.util.TestSourceReader; import org.eclipse.cdt.internal.core.index.IIndexFragment; import org.eclipse.cdt.internal.core.pdom.PDOM; diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMTestSuite.java index 8f5f8242613..a751b64317f 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMTestSuite.java @@ -21,11 +21,13 @@ import junit.framework.TestSuite; /** * @author Doug Schaefer + * @deprecated In preparation for moving to JUnit5 test suites are deprecated. See Bug 569839 */ -public class PDOMTests extends TestSuite { +@Deprecated +public class PDOMTestSuite extends TestSuite { public static Test suite() { - TestSuite suite = new PDOMTests(); + TestSuite suite = new PDOMTestSuite(); suite.addTest(DatabaseTest.suite()); suite.addTest(DBPropertiesTests.suite()); @@ -41,7 +43,7 @@ public class PDOMTests extends TestSuite { suite.addTest(IncludesTests.suite()); suite.addTest(OverloadsWithinSingleTUTests.suite()); suite.addTest(OverloadsWithinCommonHeaderTests.suite()); - suite.addTest(BTreeTests.suite()); + // Test converted to JUnit5: suite.addTest(BTreeTests.suite()); suite.addTest(PDOMStringSetTests.suite()); suite.addTest(PDOMTagIndexTests.suite()); suite.addTest(FilesOnReindexTests.suite()); diff --git a/core/org.eclipse.cdt.core.tests/plugin.properties b/core/org.eclipse.cdt.core.tests/plugin.properties new file mode 100644 index 00000000000..862a907dddb --- /dev/null +++ b/core/org.eclipse.cdt.core.tests/plugin.properties @@ -0,0 +1,14 @@ +################################################################################## +# Copyright (c) 2020 Torbjörn Svensson and others. All rights reserved. +# 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: +# Torbjörn Svensson - initial API and implementation +################################################################################## + +pluginName = org.eclipse.cdt.core.tests +providerName = Eclipse CDT diff --git a/core/org.eclipse.cdt.core.tests/pom.xml b/core/org.eclipse.cdt.core.tests/pom.xml index 786c83c4a05..a7cf08572d1 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,11 +17,11 @@ <parent> <groupId>org.eclipse.cdt</groupId> <artifactId>cdt-parent</artifactId> - <version>10.0.0-SNAPSHOT</version> + <version>10.7.0-SNAPSHOT</version> <relativePath>../../pom.xml</relativePath> </parent> - <version>5.4.0-SNAPSHOT</version> + <version>5.4.100-SNAPSHOT</version> <artifactId>org.eclipse.cdt.core.tests</artifactId> <packaging>eclipse-test-plugin</packaging> @@ -44,9 +54,14 @@ <!-- Core tests actually use eclipse.ui classes, see CProjectHelper --> <argLine>${tycho.testArgLine} ${base.ui.test.vmargs} ${extra.vmargs}</argLine> <appArgLine>-pluginCustomization ${basedir}/../../disable_intro_in_tests.ini</appArgLine> - <includes> - <include>**/AutomatedIntegrationSuite.*</include> - </includes> + <excludes> + <!-- The default Excludes omits nested static classes, this reenables them. + See org.eclipse.cdt.core.parser.tests.ast2.cxx14.constexpr.ArrayTests.NonIndexingTests + for an example of a test that would not be run otherwise. + For reference, the default exclude is "**/*$*" + --> + <exclude></exclude> + </excludes> </configuration> </plugin> <plugin> diff --git a/core/org.eclipse.cdt.core.tests/regression/org/eclipse/cdt/core/tests/BaseTestFramework.java b/core/org.eclipse.cdt.core.tests/regression/org/eclipse/cdt/core/tests/BaseTestFramework.java index 546b5c169a4..1cfdded6006 100644 --- a/core/org.eclipse.cdt.core.tests/regression/org/eclipse/cdt/core/tests/BaseTestFramework.java +++ b/core/org.eclipse.cdt.core.tests/regression/org/eclipse/cdt/core/tests/BaseTestFramework.java @@ -92,8 +92,6 @@ abstract public class BaseTestFramework extends BaseTestCase { public void cleanupProject() throws Exception { try { project.delete(true, false, monitor); - } catch (Throwable e) { - /*boo*/ } finally { project = null; } @@ -116,11 +114,7 @@ abstract public class BaseTestFramework extends BaseTestCase { continue; if (member.getName().equals(".settings")) continue; - try { - member.delete(false, monitor); - } catch (Throwable e) { - /*boo*/ - } + member.delete(false, monitor); } } diff --git a/core/org.eclipse.cdt.core.tests/regression/org/eclipse/cdt/core/tests/FailingTest.java b/core/org.eclipse.cdt.core.tests/regression/org/eclipse/cdt/core/tests/FailingTester.java index 0273378aa07..492b245be8b 100644 --- a/core/org.eclipse.cdt.core.tests/regression/org/eclipse/cdt/core/tests/FailingTest.java +++ b/core/org.eclipse.cdt.core.tests/regression/org/eclipse/cdt/core/tests/FailingTester.java @@ -27,11 +27,11 @@ import junit.framework.TestResult; * Wraps a test case to check for its failure. * @author aniefer */ -public class FailingTest extends TestCase { +public class FailingTester extends TestCase { private TestCase test = null; private int bugNum = -1; - public FailingTest(TestCase test, int bugNumber) { + public FailingTester(TestCase test, int bugNumber) { this.test = test; this.bugNum = bugNumber; String name = "Failing " + test.getName(); @@ -41,7 +41,7 @@ public class FailingTest extends TestCase { setName(name); } - public FailingTest(TestCase test) { + public FailingTester(TestCase test) { this(test, -1); } diff --git a/core/org.eclipse.cdt.core.tests/resources/cfiles/CModelElementsTestStart.h b/core/org.eclipse.cdt.core.tests/resources/cfiles/CModelElementsTestStart.h index d9736eff1d3..4d3e8071910 100644 --- a/core/org.eclipse.cdt.core.tests/resources/cfiles/CModelElementsTestStart.h +++ b/core/org.eclipse.cdt.core.tests/resources/cfiles/CModelElementsTestStart.h @@ -143,4 +143,18 @@ struct bug180815 { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=352350 namespace { int bug352350; -}
\ No newline at end of file +} + +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=574271 +#pragma mark - before and after - +#pragma mark - before +#pragma mark after - +#pragma mark neither +#pragma mark -// blank1 +#pragma mark // blank2 +#pragma region // no name +#pragma region named +#pragma endregion // no name +#pragma endregion endnamed +#pragma ms_struct on +_Pragma("once") diff --git a/core/org.eclipse.cdt.core.tests/resources/elf/unit_test/simple-be32.elf b/core/org.eclipse.cdt.core.tests/resources/elf/unit_test/simple-be32.elf Binary files differindex a94056380df..a94056380df 100755..100644 --- a/core/org.eclipse.cdt.core.tests/resources/elf/unit_test/simple-be32.elf +++ b/core/org.eclipse.cdt.core.tests/resources/elf/unit_test/simple-be32.elf diff --git a/core/org.eclipse.cdt.core.tests/resources/elf/unit_test/simple-be64.elf b/core/org.eclipse.cdt.core.tests/resources/elf/unit_test/simple-be64.elf Binary files differindex 0855753db3f..0855753db3f 100755..100644 --- a/core/org.eclipse.cdt.core.tests/resources/elf/unit_test/simple-be64.elf +++ b/core/org.eclipse.cdt.core.tests/resources/elf/unit_test/simple-be64.elf diff --git a/core/org.eclipse.cdt.core.tests/resources/elf/unit_test/simple-le32.elf b/core/org.eclipse.cdt.core.tests/resources/elf/unit_test/simple-le32.elf Binary files differindex 89c539d3e36..89c539d3e36 100755..100644 --- a/core/org.eclipse.cdt.core.tests/resources/elf/unit_test/simple-le32.elf +++ b/core/org.eclipse.cdt.core.tests/resources/elf/unit_test/simple-le32.elf diff --git a/core/org.eclipse.cdt.core.tests/resources/testlib/x86/so.g/libtestlib_g.so b/core/org.eclipse.cdt.core.tests/resources/testlib/x86/so.g/libtestlib_g.so Binary files differindex c0e76f7695b..c0e76f7695b 100644..100755 --- a/core/org.eclipse.cdt.core.tests/resources/testlib/x86/so.g/libtestlib_g.so +++ b/core/org.eclipse.cdt.core.tests/resources/testlib/x86/so.g/libtestlib_g.so diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/suite/AutomatedIntegrationSuite.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/suite/AutomatedIntegrationSuite.java index 1e36b0c4f8b..c6e0b263bb1 100644 --- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/suite/AutomatedIntegrationSuite.java +++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/suite/AutomatedIntegrationSuite.java @@ -17,24 +17,23 @@ package org.eclipse.cdt.core.suite; import org.eclipse.cdt.core.cdescriptor.tests.CDescriptorOldTests; -import org.eclipse.cdt.core.cdescriptor.tests.CDescriptorTests; import org.eclipse.cdt.core.envvar.IEnvironmentVariableManagerTests; import org.eclipse.cdt.core.internal.efsextension.tests.EFSExtensionTests; -import org.eclipse.cdt.core.internal.errorparsers.tests.ErrorParserTests; +import org.eclipse.cdt.core.internal.errorparsers.tests.ErrorParserTestSuite; import org.eclipse.cdt.core.internal.tests.PositionTrackerTests; import org.eclipse.cdt.core.internal.tests.ResourceLookupTests; import org.eclipse.cdt.core.internal.tests.StringBuilderTest; -import org.eclipse.cdt.core.language.AllLanguageTests; -import org.eclipse.cdt.core.model.tests.AllCoreTests; +import org.eclipse.cdt.core.language.AllLanguageTestSuite; +import org.eclipse.cdt.core.model.tests.AllCoreTestSuite; import org.eclipse.cdt.core.model.tests.ElementDeltaTests; import org.eclipse.cdt.core.model.tests.WorkingCopyTests; import org.eclipse.cdt.core.parser.tests.ParserTestSuite; -import org.eclipse.cdt.core.parser.tests.ast2.cxx14.constexpr.AllConstexprEvalTests; -import org.eclipse.cdt.core.parser.tests.rewrite.RewriteTests; -import org.eclipse.cdt.core.preferences.tests.TestScopeOfBuildConfigResourceChangesPreference; +import org.eclipse.cdt.core.parser.tests.ast2.cxx14.constexpr.AllConstexprEvalTestSuite; +import org.eclipse.cdt.core.parser.tests.rewrite.RewriteTestSuite; +import org.eclipse.cdt.core.preferences.tests.ScopeOfBuildConfigResourceChangesPreferenceTests; import org.eclipse.cdt.core.resources.tests.RefreshScopeTests; -import org.eclipse.cdt.internal.index.tests.IndexTests; -import org.eclipse.cdt.internal.pdom.tests.PDOMTests; +import org.eclipse.cdt.internal.index.tests.IndexTestSuite; +import org.eclipse.cdt.internal.pdom.tests.PDOMTestSuite; import org.eclipse.cdt.utils.ByteUtilsTest; import org.eclipse.cdt.utils.CdtVariableResolverTest; import org.eclipse.cdt.utils.CommandLineUtilTest; @@ -52,7 +51,9 @@ import junit.framework.TestSuite; /** * @author vhirsl + * @deprecated In preparation for moving to JUnit5 test suites are deprecated. See Bug 569839 */ +@Deprecated public class AutomatedIntegrationSuite extends TestSuite { public AutomatedIntegrationSuite() { @@ -75,21 +76,21 @@ public class AutomatedIntegrationSuite extends TestSuite { // Has intermittent failures if (System.getProperty("cdt.skip.known.test.failures") == null) { - suite.addTest(CDescriptorTests.suite()); + // Test converted to JUnit5: suite.addTest(CDescriptorTests.suite()); } - suite.addTest(AllConstexprEvalTests.suite()); + suite.addTest(AllConstexprEvalTestSuite.suite()); suite.addTest(ParserTestSuite.suite()); suite.addTest(CDescriptorOldTests.suite()); suite.addTest(IEnvironmentVariableManagerTests.suite()); - suite.addTest(ErrorParserTests.suite()); - suite.addTest(AllCoreTests.suite()); + suite.addTest(ErrorParserTestSuite.suite()); + suite.addTest(AllCoreTestSuite.suite()); suite.addTest(ElementDeltaTests.suite()); suite.addTest(WorkingCopyTests.suite()); suite.addTest(PositionTrackerTests.suite()); suite.addTest(ResourceLookupTests.suite()); suite.addTest(StringBuilderTest.suite()); - suite.addTest(AllLanguageTests.suite()); - suite.addTest(RewriteTests.suite()); + suite.addTest(AllLanguageTestSuite.suite()); + suite.addTest(RewriteTestSuite.suite()); suite.addTest(CdtVariableResolverTest.suite()); suite.addTest(StorableCdtVariablesTest.suite()); suite.addTest(CommandLineUtilTest.suite()); @@ -98,13 +99,13 @@ public class AutomatedIntegrationSuite extends TestSuite { suite.addTest(EFSExtensionTests.suite()); suite.addTest(ByteUtilsTest.suite()); suite.addTest(UNCPathConverterTest.suite()); - suite.addTest(TestScopeOfBuildConfigResourceChangesPreference.suite()); + suite.addTest(ScopeOfBuildConfigResourceChangesPreferenceTests.suite()); suite.addTest(ElfParserTest.suite()); suite.addTest(new JUnit4TestAdapter(ElfTest.class)); // Add in PDOM tests - suite.addTest(PDOMTests.suite()); - suite.addTest(IndexTests.suite()); + suite.addTest(PDOMTestSuite.suite()); + suite.addTest(IndexTestSuite.suite()); suite.addTest(RefreshScopeTests.suite()); diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/BaseTestCase.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/BaseTestCase.java index 58dcc367bd7..c6efc350e43 100644 --- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/BaseTestCase.java +++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/BaseTestCase.java @@ -20,36 +20,21 @@ import java.io.IOException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.ArrayDeque; -import java.util.ArrayList; -import java.util.Collections; import java.util.Deque; import java.util.HashSet; -import java.util.List; import java.util.Set; -import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IValue; import org.eclipse.cdt.core.dom.ast.IVariable; import org.eclipse.cdt.core.index.IIndex; -import org.eclipse.cdt.core.model.CoreModel; -import org.eclipse.cdt.core.model.ElementChangedEvent; import org.eclipse.cdt.core.model.ICProject; -import org.eclipse.cdt.core.model.IElementChangedListener; import org.eclipse.cdt.core.testplugin.ResourceHelper; import org.eclipse.cdt.core.testplugin.TestScannerProvider; -import org.eclipse.cdt.internal.core.CCoreInternals; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNameBase; import org.eclipse.cdt.internal.core.pdom.CModelListener; import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResourceStatus; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.ILogListener; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.MultiStatus; import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.jobs.Job; import junit.framework.AssertionFailedError; import junit.framework.Test; @@ -58,29 +43,33 @@ import junit.framework.TestFailure; import junit.framework.TestResult; import junit.framework.TestSuite; -public class BaseTestCase extends TestCase { - private static final String DEFAULT_INDEXER_TIMEOUT_SEC = "10"; - private static final String INDEXER_TIMEOUT_PROPERTY = "indexer.timeout"; +/** + * @deprecated Please migrate tests away from JUnit3 style to JUnit5 style by using {@link BaseTestCase5} + * as base class. + */ +@Deprecated +public abstract class BaseTestCase extends TestCase { + private static final String DEFAULT_INDEXER_TIMEOUT_SEC = BaseTestCase5.DEFAULT_INDEXER_TIMEOUT_SEC; + private static final String INDEXER_TIMEOUT_PROPERTY = BaseTestCase5.INDEXER_TIMEOUT_PROPERTY; /** * Indexer timeout used by tests. To avoid this timeout expiring during debugging add * -Dindexer.timeout=some_large_number to VM arguments of the test launch configuration. */ - protected static final int INDEXER_TIMEOUT_SEC = Integer - .parseInt(System.getProperty(INDEXER_TIMEOUT_PROPERTY, DEFAULT_INDEXER_TIMEOUT_SEC)); - protected static final int INDEXER_TIMEOUT_MILLISEC = INDEXER_TIMEOUT_SEC * 1000; + protected static final int INDEXER_TIMEOUT_SEC = BaseTestCase5.INDEXER_TIMEOUT_SEC; + protected static final int INDEXER_TIMEOUT_MILLISEC = BaseTestCase5.INDEXER_TIMEOUT_MILLISEC; /** * The GCC version to emulate when running tests. * We emulate the latest version whose extensions we support. */ - protected static final int GCC_MAJOR_VERSION_FOR_TESTS = 8; - protected static final int GCC_MINOR_VERSION_FOR_TESTS = 1; + protected static final int GCC_MAJOR_VERSION_FOR_TESTS = BaseTestCase5.GCC_MAJOR_VERSION_FOR_TESTS; + protected static final int GCC_MINOR_VERSION_FOR_TESTS = BaseTestCase5.GCC_MINOR_VERSION_FOR_TESTS; /** * This provides the systems new line separator. Use this if you do String comparisons in tests * instead of hard coding '\n' or '\r\n' respectively. */ - protected static final String NL = System.getProperty("line.separator"); + protected static final String NL = BaseTestCase5.NL; private boolean fExpectFailure; private int fBugNumber; @@ -187,74 +176,13 @@ public class BaseTestCase extends TestCase { @Override public void runBare() throws Throwable { - final List<IStatus> statusLog = Collections.synchronizedList(new ArrayList()); - ILogListener logListener = new ILogListener() { - @Override - public void logging(IStatus status, String plugin) { - if (!status.isOK() && status.getSeverity() != IStatus.INFO) { - switch (status.getCode()) { - case IResourceStatus.NOT_FOUND_LOCAL: - case IResourceStatus.NO_LOCATION_LOCAL: - case IResourceStatus.FAILED_READ_LOCAL: - case IResourceStatus.RESOURCE_NOT_LOCAL: - // Logged by the resources plugin. - return; - } - statusLog.add(status); - } - } - }; - final CCorePlugin corePlugin = CCorePlugin.getDefault(); - if (corePlugin != null) { // Iff we don't run as a JUnit Plugin Test. - corePlugin.getLog().addLogListener(logListener); - } - - Throwable testThrowable = null; + LogMonitoring monitoring = new LogMonitoring(); + monitoring.start(); try { - try { - super.runBare(); - } catch (Throwable e) { - testThrowable = e; - } - - if (statusLog.size() != fExpectedLoggedNonOK) { - StringBuilder msg = new StringBuilder("Expected number (").append(fExpectedLoggedNonOK).append(") of "); - msg.append("Non-OK status objects in log differs from actual (").append(statusLog.size()) - .append(").\n"); - Throwable cause = null; - if (!statusLog.isEmpty()) { - synchronized (statusLog) { - for (IStatus status : statusLog) { - IStatus[] ss = { status }; - ss = status instanceof MultiStatus ? ((MultiStatus) status).getChildren() : ss; - for (IStatus s : ss) { - msg.append('\t').append(s.getMessage()).append(' '); - - Throwable t = s.getException(); - cause = cause != null ? cause : t; - if (t != null) { - msg.append( - t.getMessage() != null ? t.getMessage() : t.getClass().getCanonicalName()); - } - - msg.append("\n"); - } - } - } - } - cause = cause != null ? cause : testThrowable; - AssertionFailedError afe = new AssertionFailedError(msg.toString()); - afe.initCause(cause); - throw afe; - } + super.runBare(); } finally { - if (corePlugin != null) { - corePlugin.getLog().removeLogListener(logListener); - } + monitoring.stop(fExpectedLoggedNonOK); } - - if (testThrowable != null) - throw testThrowable; } @Override @@ -302,97 +230,29 @@ public class BaseTestCase extends TestCase { fExpectedLoggedNonOK = count; } - /** - * Some test steps need synchronizing against a CModel event. This class - * is a very basic means of doing that. - */ - static protected class ModelJoiner implements IElementChangedListener { - private final boolean[] changed = new boolean[1]; - - public ModelJoiner() { - CoreModel.getDefault().addElementChangedListener(this); - } - - public void clear() { - synchronized (changed) { - changed[0] = false; - changed.notifyAll(); - } - } - - public void join() throws CoreException { - try { - synchronized (changed) { - while (!changed[0]) { - changed.wait(); - } - } - } catch (InterruptedException e) { - throw new CoreException(CCorePlugin.createStatus("Interrupted", e)); - } - } - - public void dispose() { - CoreModel.getDefault().removeElementChangedListener(this); - } - - @Override - public void elementChanged(ElementChangedEvent event) { - // Only respond to post change events - if (event.getType() != ElementChangedEvent.POST_CHANGE) - return; - - synchronized (changed) { - changed[0] = true; - changed.notifyAll(); - } - } - } - public static void waitForIndexer(ICProject project) throws InterruptedException { - Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_REFRESH, null); - assertTrue(CCoreInternals.getPDOMManager().joinIndexer(INDEXER_TIMEOUT_SEC * 1000, npm())); + BaseTestCase5.waitForIndexer(project); } public static void waitUntilFileIsIndexed(IIndex index, IFile file) throws Exception { - TestSourceReader.waitUntilFileIsIndexed(index, file, INDEXER_TIMEOUT_SEC * 1000); + BaseTestCase5.waitUntilFileIsIndexed(index, file); } - // Assertion helpers + // Assertion helpers (redirected to the common implementation) protected static <T> T assertInstance(Object o, Class<T> clazz, Class... cs) { - assertNotNull("Expected object of " + clazz.getName() + " but got a null value", o); - assertTrue("Expected " + clazz.getName() + " but got " + o.getClass().getName(), clazz.isInstance(o)); - for (Class c : cs) { - assertNotNull("Expected object of " + c.getName() + " but got a null value", o); - assertTrue("Expected " + c.getName() + " but got " + o.getClass().getName(), c.isInstance(o)); - } - return clazz.cast(o); + return BaseTestCase5.assertInstance(o, clazz, cs); } protected static void assertValue(IValue value, long expectedValue) { - assertNotNull(value); - assertTrue(value.numberValue() instanceof Long); - assertEquals(expectedValue, value.numberValue().longValue()); + BaseTestCase5.assertValue(value, expectedValue); } protected static void assertVariableValue(IVariable var, long expectedValue) { - assertValue(var.getInitialValue(), expectedValue); + BaseTestCase5.assertVariableValue(var, expectedValue); } protected static String formatForPrinting(IASTName name) { - String signature = name.getRawSignature(); - boolean saved = CPPASTNameBase.sAllowNameComputation; - CPPASTNameBase.sAllowNameComputation = true; - try { - String nameStr = name.toString(); - if (signature.replace(" ", "").equals(nameStr.replace(" ", ""))) - return signature; - return nameStr + " in " + signature; - } catch (Throwable e) { - return signature; - } finally { - CPPASTNameBase.sAllowNameComputation = saved; - } + return BaseTestCase5.formatForPrinting(name); } } diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/BaseTestCase5.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/BaseTestCase5.java new file mode 100644 index 00000000000..d486ac35829 --- /dev/null +++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/BaseTestCase5.java @@ -0,0 +1,309 @@ +/******************************************************************************* + * Copyright (c) 2006, 2020 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: + * Markus Schorn - initial API and implementation + * Andrew Ferguson (Symbian) + * Sergey Prigogin (Google) + *******************************************************************************/ +package org.eclipse.cdt.core.testplugin.util; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayDeque; +import java.util.Deque; + +import org.eclipse.cdt.core.dom.ast.IASTName; +import org.eclipse.cdt.core.dom.ast.IValue; +import org.eclipse.cdt.core.dom.ast.IVariable; +import org.eclipse.cdt.core.index.IIndex; +import org.eclipse.cdt.core.model.ICProject; +import org.eclipse.cdt.core.testplugin.ResourceHelper; +import org.eclipse.cdt.core.testplugin.TestScannerProvider; +import org.eclipse.cdt.internal.core.CCoreInternals; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNameBase; +import org.eclipse.cdt.internal.core.pdom.CModelListener; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.jobs.Job; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.TestInfo; + +import junit.framework.Test; +import junit.framework.TestResult; + +/** + * BaseTestCase for JUnit5. + */ +public abstract class BaseTestCase5 { + /** + * Bug 499777: Numerous tests are flaky and of little value on gerrit verification builds. This + * tag can be applied to JUnit5 tests with the {@link Tag} annotation to skip flaky tests in + * such circumstances. + */ + public static final String FLAKY_TEST_TAG = "flakyTest"; + + /** + * Bug 499777: Numerous tests are very slow and of little value on gerrit verification builds. This + * tag can be applied to JUnit5 tests with the {@link Tag} annotation to skip slow tests in + * such circumstances. + */ + public static final String SLOW_TEST_TAG = "slowTest"; + + protected static final String DEFAULT_INDEXER_TIMEOUT_SEC = "10"; + protected static final String INDEXER_TIMEOUT_PROPERTY = "indexer.timeout"; + /** + * Indexer timeout used by tests. To avoid this timeout expiring during debugging add + * -Dindexer.timeout=some_large_number to VM arguments of the test launch configuration. + */ + protected static final int INDEXER_TIMEOUT_SEC = Integer + .parseInt(System.getProperty(INDEXER_TIMEOUT_PROPERTY, DEFAULT_INDEXER_TIMEOUT_SEC)); + protected static final int INDEXER_TIMEOUT_MILLISEC = INDEXER_TIMEOUT_SEC * 1000; + + /** + * The GCC version to emulate when running tests. + * We emulate the latest version whose extensions we support. + */ + protected static final int GCC_MAJOR_VERSION_FOR_TESTS = 10; + protected static final int GCC_MINOR_VERSION_FOR_TESTS = 1; + + /** + * This provides the systems new line separator. Use this if you do String comparisons in tests + * instead of hard coding '\n' or '\r\n' respectively. + */ + protected static final String NL = System.getProperty("line.separator"); + + private boolean fExpectFailure; + private int fBugNumber; + private int fExpectedLoggedNonOK; + private Deque<File> filesToDeleteOnTearDown = new ArrayDeque<>(); + private TestInfo testInfo; + + LogMonitoring logMonitoring = new LogMonitoring(); + + /** + * Backwards support for JUnit3 style test that had a getName. This is not 100% the same, but close + * enough for the general use case of getName. + */ + public String getName() { + return testInfo.getDisplayName(); + } + + public static NullProgressMonitor npm() { + return new NullProgressMonitor(); + } + + @BeforeEach + protected void setupBase(TestInfo testInfo) throws Exception { + this.testInfo = testInfo; + + logMonitoring.start(); + + CPPASTNameBase.sAllowRecursionBindings = false; + CPPASTNameBase.sAllowNameComputation = false; + CModelListener.sSuppressUpdateOfLastRecentlyUsed = true; + } + + @AfterEach + protected void tearDownBase() throws Exception { + for (File file; (file = filesToDeleteOnTearDown.pollLast()) != null;) { + file.delete(); + } + ResourceHelper.cleanUp(getName()); + TestScannerProvider.clear(); + + logMonitoring.stop(fExpectedLoggedNonOK); + } + + protected void deleteOnTearDown(File file) { + filesToDeleteOnTearDown.add(file); + } + + protected File createTempFile(String prefix, String suffix) throws IOException { + File file = File.createTempFile(prefix, suffix); + filesToDeleteOnTearDown.add(file); + return file; + } + + protected File nonExistentTempFile(String prefix, String suffix) { + File file = new File(System.getProperty("java.io.tmpdir"), prefix + System.currentTimeMillis() + suffix); + filesToDeleteOnTearDown.add(file); + return file; + } + + /** + * The last value passed to this method in the body of a testXXX method + * will be used to determine whether or not the presence of non-OK status objects + * in the log should fail the test. If the logged number of non-OK status objects + * differs from the last value passed, the test is failed. If this method is not called + * at all, the expected number defaults to zero. + * @param count the expected number of logged error and warning messages + */ + public void setExpectedNumberOfLoggedNonOKStatusObjects(int count) { + fExpectedLoggedNonOK = count; + } + + public static void waitForIndexer(ICProject project) throws InterruptedException { + Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_REFRESH, null); + assertTrue(CCoreInternals.getPDOMManager().joinIndexer(INDEXER_TIMEOUT_SEC * 1000, npm())); + } + + public static void waitUntilFileIsIndexed(IIndex index, IFile file) throws Exception { + TestSourceReader.waitUntilFileIsIndexed(index, file, INDEXER_TIMEOUT_SEC * 1000); + } + + // Assertion helpers + + /** + * Asserts that the file does exist and prints a niceish error message if not. + */ + public static void assertExists(File f) { + assertTrue(f.exists(), "File " + f + " does not exist"); + } + + /** + * Asserts that the resource does exist and prints a niceish error message if not. + */ + public static void assertExists(IResource f) { + assertTrue(f.exists(), "Resource " + f + " does not exist"); + } + + /** + * Asserts that the file does exist and prints a niceish error message if not. + */ + public static void assertNotExists(File f) { + assertFalse(f.exists(), "File " + f + " should not exist"); + } + + /** + * Asserts that the Resource does exist and prints a niceish error message if not. + */ + public static void assertNotExists(IResource f) { + assertFalse(f.exists(), "Resource " + f + " should not exist"); + } + + public static <T> T assertInstance(Object o, Class<T> clazz, Class... cs) { + assertNotNull(o, "Expected object of " + clazz.getName() + " but got a null value"); + assertTrue(clazz.isInstance(o), "Expected " + clazz.getName() + " but got " + o.getClass().getName()); + for (Class c : cs) { + assertNotNull(o, "Expected object of " + c.getName() + " but got a null value"); + assertTrue(c.isInstance(o), "Expected " + c.getName() + " but got " + o.getClass().getName()); + } + return clazz.cast(o); + } + + public static void assertValue(IValue value, long expectedValue) { + assertNotNull(value); + assertTrue(value.numberValue() instanceof Long); + assertEquals(expectedValue, value.numberValue().longValue()); + } + + public static void assertVariableValue(IVariable var, long expectedValue) { + assertValue(var.getInitialValue(), expectedValue); + } + + public static String formatForPrinting(IASTName name) { + String signature = name.getRawSignature(); + boolean saved = CPPASTNameBase.sAllowNameComputation; + CPPASTNameBase.sAllowNameComputation = true; + try { + String nameStr = name.toString(); + if (signature.replace(" ", "").equals(nameStr.replace(" ", ""))) + return signature; + return nameStr + " in " + signature; + } catch (Throwable e) { + return signature; + } finally { + CPPASTNameBase.sAllowNameComputation = saved; + } + } + + // These methods help migrate from JUnit3 to JUnit5 version by providing errors as early as possible + // in the migration cycle + + public BaseTestCase5() { + // This constructor is expected to be called + } + + /** + * This JUnit3 style constructor is not supported. + */ + private BaseTestCase5(String name) { + fail("Test not migrated properly to JUnit5 yet."); + } + + /** + * This method is declared as final to help transition to JUnit5 to ensure that + * accidental override of the method is not left in subclasses when migrating. + */ + final protected void setUp() { + fail("Test not migrated properly to JUnit5 yet."); + } + + /** + * This method is declared as final to help transition to JUnit5 to ensure that + * accidental override of the method is not left in subclasses when migrating. + */ + final protected static Test suite() { + fail("Test not migrated properly to JUnit5 yet."); + return null; // unreachable + } + + /** + * This method is declared as final to help transition to JUnit5 to ensure that + * accidental override of the method is not left in subclasses when migrating. + */ + final protected void tearDown() { + fail("Test not migrated properly to JUnit5 yet."); + } + + /** + * This method is declared as final to help transition to JUnit5 to ensure that + * accidental override of the method is not left in subclasses when migrating. + */ + final protected void runBare() { + fail("Test not migrated properly to JUnit5 yet."); + } + + /** + * This method is declared as final to help transition to JUnit5 to ensure that + * accidental override of the method is not left in subclasses when migrating. + */ + final protected void run(TestResult result) { + fail("Test not migrated properly to JUnit5 yet."); + } + + /** + * This method is declared as final to help transition to JUnit5 to ensure that + * accidental override of the method is not left in subclasses when migrating. + */ + final protected void runTest() throws Throwable { + fail("Test not migrated properly to JUnit5 yet."); + } + + /** + * Setting expected failures in this way is not support with the BaseTestCase5. If this + * is functionality that is needed, please find a new way to do it. + */ + public void setExpectFailure(int bugNumber) { + fail("Test not migrated properly to JUnit5 yet."); + } + +} diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/LogMonitoring.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/LogMonitoring.java new file mode 100644 index 00000000000..88b630230d3 --- /dev/null +++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/LogMonitoring.java @@ -0,0 +1,90 @@ +/******************************************************************************* + * Copyright (c) 2006, 2020 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 + *******************************************************************************/ +package org.eclipse.cdt.core.testplugin.util; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.core.resources.IResourceStatus; +import org.eclipse.core.runtime.ILogListener; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.MultiStatus; + +import junit.framework.AssertionFailedError; + +class LogMonitoring { + + private List<IStatus> statusLog; + + private ILogListener logListener; + + private CCorePlugin corePlugin; + + void start() { + statusLog = Collections.synchronizedList(new ArrayList()); + logListener = new ILogListener() { + @Override + public void logging(IStatus status, String plugin) { + if (!status.isOK() && status.getSeverity() != IStatus.INFO) { + switch (status.getCode()) { + case IResourceStatus.NOT_FOUND_LOCAL: + case IResourceStatus.NO_LOCATION_LOCAL: + case IResourceStatus.FAILED_READ_LOCAL: + case IResourceStatus.RESOURCE_NOT_LOCAL: + // Logged by the resources plugin. + return; + } + statusLog.add(status); + } + } + }; + corePlugin = CCorePlugin.getDefault(); + if (corePlugin != null) { // Iff we don't run as a JUnit Plugin Test. + corePlugin.getLog().addLogListener(logListener); + } + + } + + void stop(int expectedLoggedNonOK) { + if (statusLog.size() != expectedLoggedNonOK) { + StringBuilder msg = new StringBuilder("Expected number (").append(expectedLoggedNonOK).append(") of "); + msg.append("Non-OK status objects in log differs from actual (").append(statusLog.size()).append(").\n"); + Throwable cause = null; + if (!statusLog.isEmpty()) { + synchronized (statusLog) { + for (IStatus status : statusLog) { + IStatus[] ss = { status }; + ss = status instanceof MultiStatus ? ((MultiStatus) status).getChildren() : ss; + for (IStatus s : ss) { + msg.append('\t').append(s.getMessage()).append(' '); + + Throwable t = s.getException(); + cause = cause != null ? cause : t; + if (t != null) { + msg.append(t.getMessage() != null ? t.getMessage() : t.getClass().getCanonicalName()); + } + + msg.append("\n"); + } + } + } + } + AssertionFailedError afe = new AssertionFailedError(msg.toString()); + afe.initCause(cause); + throw afe; + } + if (corePlugin != null) { + corePlugin.getLog().removeLogListener(logListener); + } + } +}
\ No newline at end of file diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/ModelJoiner.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/ModelJoiner.java new file mode 100644 index 00000000000..189544d6bae --- /dev/null +++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/ModelJoiner.java @@ -0,0 +1,69 @@ +/******************************************************************************* + * Copyright (c) 2006, 2016 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: + * Markus Schorn - initial API and implementation + * Andrew Ferguson (Symbian) + * Sergey Prigogin (Google) + *******************************************************************************/ +package org.eclipse.cdt.core.testplugin.util; + +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.model.CoreModel; +import org.eclipse.cdt.core.model.ElementChangedEvent; +import org.eclipse.cdt.core.model.IElementChangedListener; +import org.eclipse.core.runtime.CoreException; + +/** + * Some test steps need synchronizing against a CModel event. This class + * is a very basic means of doing that. + */ +public class ModelJoiner implements IElementChangedListener { + private final boolean[] changed = new boolean[1]; + + public ModelJoiner() { + CoreModel.getDefault().addElementChangedListener(this); + } + + public void clear() { + synchronized (changed) { + changed[0] = false; + changed.notifyAll(); + } + } + + public void join() throws CoreException { + try { + synchronized (changed) { + while (!changed[0]) { + changed.wait(); + } + } + } catch (InterruptedException e) { + throw new CoreException(CCorePlugin.createStatus("Interrupted", e)); + } + } + + public void dispose() { + CoreModel.getDefault().removeElementChangedListener(this); + } + + @Override + public void elementChanged(ElementChangedEvent event) { + // Only respond to post change events + if (event.getType() != ElementChangedEvent.POST_CHANGE) + return; + + synchronized (changed) { + changed[0] = true; + changed.notifyAll(); + } + } +}
\ No newline at end of file diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/OneSourceMultipleHeadersTestCase.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/OneSourceMultipleHeadersTestCase.java index 75d45a4e5af..80f5515a251 100644 --- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/OneSourceMultipleHeadersTestCase.java +++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/OneSourceMultipleHeadersTestCase.java @@ -34,7 +34,7 @@ import org.eclipse.core.runtime.Path; * header1.h, header2.h, etc. The AST is created for the source file only and can be obtained * by calling getAst(). */ -public class OneSourceMultipleHeadersTestCase extends BaseTestCase { +public abstract class OneSourceMultipleHeadersTestCase extends BaseTestCase { private static final boolean DEBUG = false; private final TestSourceReader testSourceReader; diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/TestSourceReader.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/TestSourceReader.java index 5fe92d9187d..3290acb2ab6 100644 --- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/TestSourceReader.java +++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/TestSourceReader.java @@ -102,6 +102,10 @@ public class TestSourceReader { * Returns an array of StringBuilder objects for each comment section found preceding the named * test in the source code. * + * Trailing whitespace can be removed by editor/clean-up actions. To enforce whitespace + * at end of line, use ${whitspace_eol}, which will be removed, but cause the + * whitespace to the left of it to be preserved. + * * @param bundle the bundle containing the source, if {@code null} can try to load using * classpath (source folder has to be in the classpath for this to work) * @param srcRoot the directory inside the bundle containing the packages diff --git a/core/org.eclipse.cdt.core.win32.x86_64/.settings/org.eclipse.core.resources.prefs b/core/org.eclipse.cdt.core.win32.x86_64/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 00000000000..99f26c0203a --- /dev/null +++ b/core/org.eclipse.cdt.core.win32.x86_64/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/<project>=UTF-8 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 8529f94bd49..895807016d3 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.0.qualifier +Bundle-Version: 6.0.600.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/about.html b/core/org.eclipse.cdt.core.win32.x86_64/about.html index 164f781a8fd..b3134865230 100644 --- a/core/org.eclipse.cdt.core.win32.x86_64/about.html +++ b/core/org.eclipse.cdt.core.win32.x86_64/about.html @@ -1,10 +1,11 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> + <head> -<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> -<title>About</title> + <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> + <title>About</title> </head> + <body lang="EN-US"> <h2>About This Content</h2> @@ -16,7 +17,7 @@ ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 ("EPL"). A copy of the EPL is - available at <a href="http://www.eclipse.org/legal/epl-2.0">http://www.eclipse.org/legal/epl-2.0</a>. + available at <a href="https://www.eclipse.org/legal/epl-2.0">https://www.eclipse.org/legal/epl-2.0</a>. For purposes of the EPL, "Program" will mean the Content. </p> @@ -29,8 +30,9 @@ license exists, contact the Redistributor. Unless otherwise indicated below, the terms and conditions of the EPL still apply to any source code in the Content and such source code may be obtained at <a - href="http://www.eclipse.org/">http://www.eclipse.org</a>. + href="https://www.eclipse.org/">https://www.eclipse.org</a>. </p> </body> + </html>
\ No newline at end of file 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 Binary files differindex 221ac7deab5..db374f73310 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 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 Binary files differindex 3dba4a71679..00b9a5c003d 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 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 Binary files differindex 9816ad5427e..f66b4210461 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 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 ace69533697..a76beb2cea8 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.0.0-SNAPSHOT</version> + <version>10.7.0-SNAPSHOT</version> <relativePath>../../pom.xml</relativePath> </parent> - <version>6.0.0-SNAPSHOT</version> + <version>6.0.600-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/.classpath b/core/org.eclipse.cdt.core.win32/.classpath index 01836c4842f..e801ebfb468 100644 --- a/core/org.eclipse.cdt.core.win32/.classpath +++ b/core/org.eclipse.cdt.core.win32/.classpath @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> - <classpathentry kind="src" path="src"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> + <classpathentry kind="src" path="src"/> <classpathentry kind="output" path="bin"/> </classpath> diff --git a/core/org.eclipse.cdt.core.win32/.project b/core/org.eclipse.cdt.core.win32/.project index 09821b72158..427e0771d5c 100644 --- a/core/org.eclipse.cdt.core.win32/.project +++ b/core/org.eclipse.cdt.core.win32/.project @@ -20,9 +20,15 @@ <arguments> </arguments> </buildCommand> + <buildCommand> + <name>org.eclipse.pde.api.tools.apiAnalysisBuilder</name> + <arguments> + </arguments> + </buildCommand> </buildSpec> <natures> <nature>org.eclipse.jdt.core.javanature</nature> <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature> </natures> </projectDescription> diff --git a/core/org.eclipse.cdt.core.win32/.settings/org.eclipse.core.resources.prefs b/core/org.eclipse.cdt.core.win32/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 00000000000..99f26c0203a --- /dev/null +++ b/core/org.eclipse.cdt.core.win32/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/<project>=UTF-8 diff --git a/core/org.eclipse.cdt.core.win32/.settings/org.eclipse.jdt.core.prefs b/core/org.eclipse.cdt.core.win32/.settings/org.eclipse.jdt.core.prefs index 2b6ecff8a01..e3a8104f9ca 100644 --- a/core/org.eclipse.cdt.core.win32/.settings/org.eclipse.jdt.core.prefs +++ b/core/org.eclipse.cdt.core.win32/.settings/org.eclipse.jdt.core.prefs @@ -30,9 +30,9 @@ org.eclipse.jdt.core.compiler.annotation.nullable.secondary= org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.methodParameters=generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.compliance=11 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -49,6 +49,7 @@ org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled org.eclipse.jdt.core.compiler.problem.discouragedReference=warning org.eclipse.jdt.core.compiler.problem.emptyStatement=warning +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning @@ -107,6 +108,7 @@ org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=igno org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled @@ -144,13 +146,14 @@ org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.release=disabled -org.eclipse.jdt.core.compiler.source=1.8 +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=11 org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns=false org.eclipse.jdt.core.formatter.align_with_spaces=false +org.eclipse.jdt.core.formatter.alignment_for_additive_operator=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 @@ -158,21 +161,24 @@ org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_c org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_assignment=0 -org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_bitwise_operator=16 org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 org.eclipse.jdt.core.formatter.alignment_for_compact_loops=16 org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 org.eclipse.jdt.core.formatter.alignment_for_enum_constants=16 org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0 +org.eclipse.jdt.core.formatter.alignment_for_logical_operator=16 org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 org.eclipse.jdt.core.formatter.alignment_for_module_statements=16 org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_multiplicative_operator=16 org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_string_concatenation=16 org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 @@ -264,11 +270,12 @@ org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_after_additive_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_bitwise_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert @@ -299,6 +306,8 @@ org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_after_logical_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_multiplicative_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert @@ -323,13 +332,17 @@ org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_relational_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert +org.eclipse.jdt.core.formatter.insert_space_after_shift_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_string_concatenation=insert org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_additive_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_bitwise_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert @@ -377,6 +390,8 @@ org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do no org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_before_logical_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_multiplicative_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert @@ -413,9 +428,12 @@ org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not inser org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_relational_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_shift_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_string_concatenation=insert org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert @@ -454,10 +472,14 @@ org.eclipse.jdt.core.formatter.tabulation.char=tab org.eclipse.jdt.core.formatter.tabulation.size=4 org.eclipse.jdt.core.formatter.use_on_off_tags=true org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false +org.eclipse.jdt.core.formatter.wrap_before_additive_operator=true org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false -org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true +org.eclipse.jdt.core.formatter.wrap_before_bitwise_operator=true org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true +org.eclipse.jdt.core.formatter.wrap_before_logical_operator=true +org.eclipse.jdt.core.formatter.wrap_before_multiplicative_operator=true org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true +org.eclipse.jdt.core.formatter.wrap_before_string_concatenation=true org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true org.eclipse.jdt.core.incompatibleJDKLevel=ignore org.eclipse.jdt.core.incompleteClasspath=error diff --git a/core/org.eclipse.cdt.core.win32/.settings/org.eclipse.jdt.ui.prefs b/core/org.eclipse.cdt.core.win32/.settings/org.eclipse.jdt.ui.prefs index e44576346c4..d35ba9b5231 100644 --- a/core/org.eclipse.cdt.core.win32/.settings/org.eclipse.jdt.ui.prefs +++ b/core/org.eclipse.cdt.core.win32/.settings/org.eclipse.jdt.ui.prefs @@ -1,3 +1,4 @@ +cleanup.add_all=false cleanup.add_default_serial_version_id=true cleanup.add_generated_serial_version_id=false cleanup.add_missing_annotations=true @@ -11,25 +12,72 @@ cleanup.always_use_blocks=true cleanup.always_use_parentheses_in_expressions=false cleanup.always_use_this_for_non_static_field_access=false cleanup.always_use_this_for_non_static_method_access=false +cleanup.array_with_curly=false +cleanup.arrays_fill=false +cleanup.bitwise_conditional_expression=false +cleanup.boolean_literal=false +cleanup.boolean_value_rather_than_comparison=false +cleanup.break_loop=false +cleanup.collection_cloning=false +cleanup.comparing_on_criteria=false +cleanup.comparison_statement=false +cleanup.controlflow_merge=false cleanup.convert_functional_interfaces=false cleanup.convert_to_enhanced_for_loop=false +cleanup.convert_to_enhanced_for_loop_if_loop_var_used=true +cleanup.convert_to_switch_expressions=false cleanup.correct_indentation=false +cleanup.do_while_rather_than_while=true +cleanup.double_negation=false +cleanup.else_if=false +cleanup.embedded_if=false +cleanup.evaluate_nullable=false +cleanup.extract_increment=false cleanup.format_source_code=true cleanup.format_source_code_changes_only=false +cleanup.hash=false +cleanup.if_condition=false cleanup.insert_inferred_type_arguments=false +cleanup.instanceof=false +cleanup.instanceof_keyword=false +cleanup.invert_equals=false +cleanup.join=false +cleanup.lazy_logical_operator=false cleanup.make_local_variable_final=true cleanup.make_parameters_final=false cleanup.make_private_fields_final=true cleanup.make_type_abstract_if_missing_method=false cleanup.make_variable_declarations_final=false +cleanup.map_cloning=false +cleanup.merge_conditional_blocks=false +cleanup.multi_catch=false cleanup.never_use_blocks=false cleanup.never_use_parentheses_in_expressions=true +cleanup.no_string_creation=false +cleanup.no_super=false +cleanup.number_suffix=false +cleanup.objects_equals=false +cleanup.one_if_rather_than_duplicate_blocks_that_fall_through=false +cleanup.operand_factorization=false cleanup.organize_imports=true +cleanup.overridden_assignment=false +cleanup.plain_replacement=false +cleanup.precompile_regex=false +cleanup.primitive_comparison=false +cleanup.primitive_parsing=false +cleanup.primitive_rather_than_wrapper=false +cleanup.primitive_serialization=false +cleanup.pull_out_if_from_if_else=false +cleanup.pull_up_assignment=false +cleanup.push_down_negation=false cleanup.qualify_static_field_accesses_with_declaring_class=false cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true cleanup.qualify_static_member_accesses_with_declaring_class=false cleanup.qualify_static_method_accesses_with_declaring_class=false +cleanup.reduce_indentation=false +cleanup.redundant_comparator=false +cleanup.redundant_falling_through_block_end=false cleanup.remove_private_constructors=true cleanup.remove_redundant_modifiers=false cleanup.remove_redundant_semicolons=true @@ -37,25 +85,57 @@ cleanup.remove_redundant_type_arguments=true cleanup.remove_trailing_whitespaces=true cleanup.remove_trailing_whitespaces_all=true cleanup.remove_trailing_whitespaces_ignore_empty=false +cleanup.remove_unnecessary_array_creation=false cleanup.remove_unnecessary_casts=true cleanup.remove_unnecessary_nls_tags=false cleanup.remove_unused_imports=true cleanup.remove_unused_local_variables=false +cleanup.remove_unused_method_parameters=false cleanup.remove_unused_private_fields=true cleanup.remove_unused_private_members=false cleanup.remove_unused_private_methods=true cleanup.remove_unused_private_types=true +cleanup.return_expression=false +cleanup.simplify_lambda_expression_and_method_ref=false +cleanup.single_used_field=false cleanup.sort_members=false cleanup.sort_members_all=false +cleanup.standard_comparison=false +cleanup.static_inner_class=false +cleanup.strictly_equal_or_different=false +cleanup.stringbuffer_to_stringbuilder=false +cleanup.stringbuilder=false +cleanup.stringbuilder_for_local_vars=true +cleanup.stringconcat_to_textblock=false +cleanup.substring=false +cleanup.switch=false +cleanup.system_property=false +cleanup.system_property_boolean=false +cleanup.system_property_file_encoding=false +cleanup.system_property_file_separator=false +cleanup.system_property_line_separator=false +cleanup.system_property_path_separator=false +cleanup.ternary_operator=false +cleanup.try_with_resource=false +cleanup.unlooped_while=false +cleanup.unreachable_block=false cleanup.use_anonymous_class_creation=false +cleanup.use_autoboxing=false cleanup.use_blocks=false cleanup.use_blocks_only_for_return_and_throw=false +cleanup.use_directly_map_method=false cleanup.use_lambda=true cleanup.use_parentheses_in_expressions=false +cleanup.use_string_is_blank=false cleanup.use_this_for_non_static_field_access=false cleanup.use_this_for_non_static_field_access_only_if_necessary=true cleanup.use_this_for_non_static_method_access=false cleanup.use_this_for_non_static_method_access_only_if_necessary=true +cleanup.use_unboxing=false +cleanup.use_var=false +cleanup.useless_continue=false +cleanup.useless_return=false +cleanup.valueof_rather_than_instantiation=false cleanup_profile=_CDT cleanup_settings_version=2 eclipse.preferences.version=1 diff --git a/core/org.eclipse.cdt.core.win32/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.core.win32/META-INF/MANIFEST.MF index 44e5fb77cb9..2da0838951f 100644 --- a/core/org.eclipse.cdt.core.win32/META-INF/MANIFEST.MF +++ b/core/org.eclipse.cdt.core.win32/META-INF/MANIFEST.MF @@ -2,12 +2,12 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %fragmentName.win32 Bundle-SymbolicName: org.eclipse.cdt.core.win32; singleton:=true -Bundle-Version: 6.0.0.qualifier +Bundle-Version: 6.0.300.qualifier Bundle-Vendor: %providerName -Fragment-Host: org.eclipse.cdt.core.native;bundle-version="[6.0.0,7.0.0)" +Fragment-Host: org.eclipse.cdt.core.native;bundle-version="[6.1.0,7.0.0)" Bundle-Localization: plugin -Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Bundle-RequiredExecutionEnvironment: JavaSE-11 Eclipse-PlatformFilter: (osgi.os=win32) Automatic-Module-Name: org.eclipse.cdt.core.win32 -Require-Bundle: com.sun.jna;bundle-version="4.5.1", - com.sun.jna.platform;bundle-version="4.5.1" +Require-Bundle: com.sun.jna;bundle-version="[5.6.0,6.0.0)", + com.sun.jna.platform;bundle-version="[5.6.0,6.0.0)" diff --git a/core/org.eclipse.cdt.core.win32/about.html b/core/org.eclipse.cdt.core.win32/about.html index 164f781a8fd..b3134865230 100644 --- a/core/org.eclipse.cdt.core.win32/about.html +++ b/core/org.eclipse.cdt.core.win32/about.html @@ -1,10 +1,11 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> + <head> -<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> -<title>About</title> + <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> + <title>About</title> </head> + <body lang="EN-US"> <h2>About This Content</h2> @@ -16,7 +17,7 @@ ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 ("EPL"). A copy of the EPL is - available at <a href="http://www.eclipse.org/legal/epl-2.0">http://www.eclipse.org/legal/epl-2.0</a>. + available at <a href="https://www.eclipse.org/legal/epl-2.0">https://www.eclipse.org/legal/epl-2.0</a>. For purposes of the EPL, "Program" will mean the Content. </p> @@ -29,8 +30,9 @@ license exists, contact the Redistributor. Unless otherwise indicated below, the terms and conditions of the EPL still apply to any source code in the Content and such source code may be obtained at <a - href="http://www.eclipse.org/">http://www.eclipse.org</a>. + href="https://www.eclipse.org/">https://www.eclipse.org</a>. </p> </body> + </html>
\ No newline at end of file diff --git a/core/org.eclipse.cdt.core.win32/build.properties b/core/org.eclipse.cdt.core.win32/build.properties index 41066b2e23d..eadebecf134 100644 --- a/core/org.eclipse.cdt.core.win32/build.properties +++ b/core/org.eclipse.cdt.core.win32/build.properties @@ -16,6 +16,5 @@ bin.includes = fragment.xml,\ .,\ META-INF/,\ plugin.properties -src.includes = about.html,\ - library/ +src.includes = about.html source.. = src/ diff --git a/core/org.eclipse.cdt.core.win32/library/.gitignore b/core/org.eclipse.cdt.core.win32/library/.gitignore deleted file mode 100644 index 4d4ec54ac04..00000000000 --- a/core/org.eclipse.cdt.core.win32/library/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -/ipch/ -*.obj -*.idb -*.pdb -*.sdf -*.suo -*.pch -*.log diff --git a/core/org.eclipse.cdt.core.win32/library/Makefile b/core/org.eclipse.cdt.core.win32/library/Makefile deleted file mode 100644 index 76bb655800f..00000000000 --- a/core/org.eclipse.cdt.core.win32/library/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -# makefile for libspawner.so - -ifeq ($(JAVA_HOME),) -$(error JAVA_HOME not set in environment) -endif - -# Defaults which can be overridden. -OS = win32 -ARCH = x86 - -JDK_INCLUDES= "$(JAVA_HOME)/include" -JDK_OS_INCLUDES= "$(JAVA_HOME)/include/$(OS)" - -CC=g++ -DEBUG_FLAGS = -D_UNICODE -DDEBUG_MONITOR -DREAD_REPORT -CFLAGS = -DUNICODE -I$(JDK_INCLUDES) -I$(JDK_OS_INCLUDES) -CXX=g++ -CXXFLAGS=$(CFLAGS) - -INSTALL_DIR = ../../org.eclipse.cdt.core.$(OS).$(ARCH)/os/$(OS)/$(ARCH) - -LIB_NAME_SPAWNER = spawner.dll -LIB_NAME_FULL_SPAWNER = $(INSTALL_DIR)/spawner.dll -OBJS_SPAWNER=StdAfx.o Win32ProcessEx.o iostream.o raise.o spawner.o - -all: $(LIB_NAME_FULL_SPAWNER) - -rebuild: clean all - -$(LIB_NAME_FULL_SPAWNER) : $(OBJS_SPAWNER) - $(CC) -Wl,--kill-at -shared -o $(LIB_NAME_FULL_SPAWNER) $(OBJS_SPAWNER) -lpsapi - -clean : - $(RM) $(OBJS_SPAWNER) diff --git a/core/org.eclipse.cdt.core.win32/library/Makefile_x86_64.mk b/core/org.eclipse.cdt.core.win32/library/Makefile_x86_64.mk deleted file mode 100644 index aeb5c889190..00000000000 --- a/core/org.eclipse.cdt.core.win32/library/Makefile_x86_64.mk +++ /dev/null @@ -1,60 +0,0 @@ -#******************************************************************************* -# Copyright (c) 2011 Marc-Andre Laperle -# -# 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: -# Marc-Andre Laperle - initial API and implementation -#******************************************************************************* - -# Makefile (nmake) for Core fragment on Windows x86_64 - -OS = win32 -ARCH = x86_64 - -JDK_INCLUDES= "$(JAVA_HOME)\include" -JDK_OS_INCLUDES= "$(JAVA_HOME)\include/$(OS)" - -CC=cl -DEBUG_FLAGS = -DDEBUG_MONITOR -DREAD_REPORT -CFLAGS = /TP /I$(JDK_INCLUDES) /I$(JDK_OS_INCLUDES) /EHs /nologo -CFLAGS_UNICODE = /D "_UNICODE" /D "UNICODE" $(CFLAGS) - -INSTALL_DIR = ..\..\org.eclipse.cdt.core.$(OS).$(ARCH)\os\$(OS)\$(ARCH) - -DLL_SPAWNER = spawner.dll -OBJS_SPAWNER=StdAfx.obj Win32ProcessEx.obj iostream.obj raise.obj spawner.obj - -EXE_STARTER = starter.exe -OBJS_STARTER=starter/starter.obj - -.c.obj: - cl /c $(CFLAGS_UNICODE) $*.c /Fo$@ - -.cpp.obj: - cl /c $(CFLAGS_UNICODE) $*.cpp /Fo$@ - -spawner: $(OBJS_SPAWNER) - link /dll /nologo /out:$(DLL_SPAWNER) $(OBJS_SPAWNER) User32.lib - -starter: $(OBJS_STARTER) - link /nologo /out:$(EXE_STARTER) $(OBJS_STARTER) Psapi.Lib Shell32.lib - -all: spawner starter - -clean: - del *.obj *.lib *.exp *.exe *.dll starter\*.obj - -rebuild: clean all - -install: all - copy *.dll $(INSTALL_DIR) - copy *.exe $(INSTALL_DIR) - -uninstall: - del $(INSTALL_DIR)\*.dll $(INSTALL_DIR)\*.exe diff --git a/core/org.eclipse.cdt.core.win32/library/Readme64.txt b/core/org.eclipse.cdt.core.win32/library/Readme64.txt deleted file mode 100644 index 2fb8b08feee..00000000000 --- a/core/org.eclipse.cdt.core.win32/library/Readme64.txt +++ /dev/null @@ -1,26 +0,0 @@ -#******************************************************************************* -# Copyright (c) 2011 Marc-Andre Laperle -# -# 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: -# Marc-Andre Laperle - initial API and implementation -#******************************************************************************* - -How to build the Win32 x86_64 core fragment: - -1. Prerequisites -- Install Windows SDK 7.1. If the SDK is not installed in the default location or if you want to try a different SDK, modify setenv64.bat accordingly. -- Make sure your JAVA_HOME environment variable is set and points to a 64 bit JDK (C:\Program Files\Java\jdkX.X.X not C:\Program Files (x86)\Java\jdkX.X.X ) - -2. Build and install -- In a command prompt, execute setenv64.bat. -The command prompt should turn to a different color and print a message about targeting x64. -- Execute build64.bat -This will build the dlls and executables, copy them to org.eclipse.cdt.core.win32.x86_64\os\win32\x86_64 then clean the build directories. -Optionally, you can use nmake /f Makefile_x86_64.mk TARGET directly. Refer to Makefile_x86_64.mk for valid targets. diff --git a/core/org.eclipse.cdt.core.win32/library/Spawner.h b/core/org.eclipse.cdt.core.win32/library/Spawner.h deleted file mode 100644 index 0e10a7b0af5..00000000000 --- a/core/org.eclipse.cdt.core.win32/library/Spawner.h +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2010 QNX Software Systems 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: - * QNX Software Systems - initial API and implementation - * - * Spawner.h - * - * This is a part of JNI implementation of spawner - *******************************************************************************/ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include <jni.h> -/* Header for class org_eclipse_cdt_utils_spawner_Spawner */ - -#ifndef _Included_org_eclipse_cdt_utils_spawner_Spawner -#define _Included_org_eclipse_cdt_utils_spawner_Spawner -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: org_eclipse_cdt_utils_spawner_Spawner - * Method: exec0 - * Signature: ([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[I)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec0 - (JNIEnv *, jobject, jobjectArray, jobjectArray, jstring, jintArray); - -/* - * Class: org_eclipse_cdt_utils_spawner_Spawner - * Method: exec1 - * Signature: ([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec1 - (JNIEnv *, jobject, jobjectArray, jobjectArray, jstring); - -/* - * Class: org_eclipse_cdt_utils_spawner_Spawner - * Method: exec2 - * Signature: ([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;LILjava/lang/String;IZ)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec2 - (JNIEnv * env, jobject process, jobjectArray cmdarray, jobjectArray envp, jstring dir, jintArray channels, jstring slaveName, jint fdm, jboolean console); - -/* - * Class: org_eclipse_cdt_utils_spawner_Spawner - * Method: raise - * Signature: (II)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_raise - (JNIEnv *, jobject, jint, jint); - - -/* - * Class: org_eclipse_cdt_utils_spawner_Spawner - * Method: waitFor - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_waitFor - (JNIEnv *, jobject, jint); - -// #define DEBUG_MONITOR - -int interruptProcess(int pid); - - -#ifdef __cplusplus -} -#endif - -// #define DEBUG_MONITOR - -#endif diff --git a/core/org.eclipse.cdt.core.win32/library/SpawnerInputStream.h b/core/org.eclipse.cdt.core.win32/library/SpawnerInputStream.h deleted file mode 100644 index 294977dfd31..00000000000 --- a/core/org.eclipse.cdt.core.win32/library/SpawnerInputStream.h +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2007 QNX Software Systems 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: - * QNX Software Systems - initial API and implementation - * - * SpawnerInputStream.h - * - * This is a part of JNI implementation of spawner - *******************************************************************************/ - -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include <jni.h> -/* Header for class com_qnx_tools_utils_spawner_SpawnerInputStream */ - -#ifndef _Included_com_qnx_tools_utils_spawner_SpawnerInputStream -#define _Included_com_qnx_tools_utils_spawner_SpawnerInputStream -#ifdef __cplusplus -extern "C" { -#endif -#undef com_qnx_tools_utils_spawner_SpawnerInputStream_SKIP_BUFFER_SIZE -#define com_qnx_tools_utils_spawner_SpawnerInputStream_SKIP_BUFFER_SIZE 2048L -/* Inaccessible static: skipBuffer */ -/* - * Class: com_qnx_tools_utils_spawner_SpawnerInputStream - * Method: read0 - * Signature: (I[BI)I - */ -JNIEXPORT jint JNICALL Java_com_qnx_tools_utils_spawner_SpawnerInputStream_read0 - (JNIEnv *, jobject, jint, jbyteArray, jint); - -/* - * Class: com_qnx_tools_utils_spawner_SpawnerInputStream - * Method: close0 - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_com_qnx_tools_utils_spawner_SpawnerInputStream_close0 - (JNIEnv *, jobject, jint); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/core/org.eclipse.cdt.core.win32/library/SpawnerOutputStream.h b/core/org.eclipse.cdt.core.win32/library/SpawnerOutputStream.h deleted file mode 100644 index 4ed58014d39..00000000000 --- a/core/org.eclipse.cdt.core.win32/library/SpawnerOutputStream.h +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2007 QNX Software Systems 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: - * QNX Software Systems - initial API and implementation - * - * SpawnerOutputStream.h - * - * This is a part of JNI implementation of spawner - *******************************************************************************/ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include <jni.h> -/* Header for class com_qnx_tools_utils_spawner_SpawnerOutputStream */ - -#ifndef _Included_com_qnx_tools_utils_spawner_SpawnerOutputStream -#define _Included_com_qnx_tools_utils_spawner_SpawnerOutputStream -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: com_qnx_tools_utils_spawner_SpawnerOutputStream - * Method: write0 - * Signature: (I[BI)I - */ -JNIEXPORT jint JNICALL Java_com_qnx_tools_utils_spawner_SpawnerOutputStream_write0 - (JNIEnv *, jobject, jint, jbyteArray, jint); - -/* - * Class: com_qnx_tools_utils_spawner_SpawnerOutputStream - * Method: close0 - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_com_qnx_tools_utils_spawner_SpawnerOutputStream_close0 - (JNIEnv *, jobject, jint); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/core/org.eclipse.cdt.core.win32/library/StdAfx.c b/core/org.eclipse.cdt.core.win32/library/StdAfx.c deleted file mode 100644 index ea8e1023e93..00000000000 --- a/core/org.eclipse.cdt.core.win32/library/StdAfx.c +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2007 QNX Software Systems 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: - * QNX Software Systems - initial API and implementation - * - * StdAfx.c - * - * This is a part of JNI implementation of spawner - *******************************************************************************/ -// stdafx.cpp : source file that includes just the standard includes -// spawner.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - -// TODO: reference any additional headers you need in STDAFX.H -// and not in this file diff --git a/core/org.eclipse.cdt.core.win32/library/StdAfx.h b/core/org.eclipse.cdt.core.win32/library/StdAfx.h deleted file mode 100644 index c176fed0ad0..00000000000 --- a/core/org.eclipse.cdt.core.win32/library/StdAfx.h +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2007 QNX Software Systems 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: - * QNX Software Systems - initial API and implementation - * - * StdAfx.h - * - * This is a part of JNI implementation of spawner - *******************************************************************************/ - -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#if !defined(AFX_STDAFX_H__9D84F180_36E5_47D6_96AB_22723242789C__INCLUDED_) -#define AFX_STDAFX_H__9D84F180_36E5_47D6_96AB_22723242789C__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - - -// Insert your headers here -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers - -#include <tchar.h> - -#include <windows.h> - -// TODO: reference additional headers your program requires here - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_STDAFX_H__9D84F180_36E5_47D6_96AB_22723242789C__INCLUDED_) diff --git a/core/org.eclipse.cdt.core.win32/library/Win32ProcessEx.c b/core/org.eclipse.cdt.core.win32/library/Win32ProcessEx.c deleted file mode 100644 index 1554983330a..00000000000 --- a/core/org.eclipse.cdt.core.win32/library/Win32ProcessEx.c +++ /dev/null @@ -1,1009 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2015 QNX Software Systems 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: - * QNX Software Systems - initial API and implementation - * Wind River Systems, Inc. - * - * Win32ProcessEx.c - * - * This is a JNI implementation of spawner - *******************************************************************************/ - -#include "stdafx.h" -#include <string.h> -#include <stdlib.h> -#include <process.h> -#include "Spawner.h" - -#include "jni.h" -#include "io.h" - - -#define PIPE_SIZE 512 // Size of pipe buffer -#define MAX_CMD_SIZE 2049 // Initial size of command line -#define MAX_ENV_SIZE 4096 // Initial size of environment block -#define PIPE_NAME_LENGTH 100 // Size of pipe name buffer -#define PIPE_TIMEOUT 10000 // Default time-out value, in milliseconds. - -#define MAX_PROCS (100) // Maximum number of simultaneously running processes - - -// Process description block. Should be created for each launched process -typedef struct _procInfo { - int pid; // Process ID - int uid; // quasi-unique process ID; we have to create it to avoid duplicated pid - // (actually this impossible from OS point of view but it is still possible - // a clash of new created and already finished process with one and the same PID. - // 4 events connected to this process (see starter) - HANDLE eventBreak; // signaled when Spawner.interrupt() is called; mildest of the terminate requests (SIGINT signal in UNIX world) - HANDLE eventWait; - HANDLE eventTerminate; // signaled when Spawner.terminate() is called; more forceful terminate request (SIGTERM signal in UNIX world) - HANDLE eventKill; // signaled when Spawner.kill() is called; most forceful terminate request (SIGKILL signal in UNIX world) - HANDLE eventCtrlc; // signaled when Spawner.interruptCTRLC() is called; like interrupt() but sends CTRL-C in all cases, even when inferior is a Cygwin program -} procInfo_t, * pProcInfo_t; - -static int procCounter = 0; // Number of running processes - - -// This is a VM helper -void ThrowByName(JNIEnv *env, const char *name, const char *msg); - -// Creates _procInfo block for every launched process -pProcInfo_t createProcInfo(); - -// Find process description for this pid -pProcInfo_t findProcInfo(int pid); - -// We launch separate thread for each project to trap it termination -void _cdecl waitProcTermination(void* pv) ; - -// This is a helper function to prevent losing of quotation marks -static int copyTo(wchar_t * target, const wchar_t * source, int cpyLenght, int availSpace); - -// Use this function to clean project descriptor and return it to the pool of available blocks. -static void cleanUpProcBlock(pProcInfo_t pCurProcInfo); - - -// Signal codes -typedef enum { - SIG_NOOP, - SIG_HUP, - SIG_INT, - SIG_KILL = 9, - SIG_TERM = 15, - CTRLC = 1000 // special, Windows only. Sends CTRL-C in all cases, even when inferior is a Cygwin program -} signals; - -extern CRITICAL_SECTION cs; - - -extern wchar_t path[MAX_PATH]; // Directory where spawner.dll is located - -static HMODULE hVM = NULL; // VM handler - - -static pProcInfo_t pInfo = NULL; - -static int nCounter = 0; // We use it to build unique synchronization object names - -///////////////////////////////////////////////////////////////////////////////////// -// Launcher; launchess process and traps its termination -// Arguments: (see Spawner.java) -// [in] cmdarray - array of command line elements -// [in] envp - array of environment variables -// [in] dir - working directory -// [out] channels - streams handlers -///////////////////////////////////////////////////////////////////////////////////// - -extern "C" -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec2 - (JNIEnv * env, jobject process, jobjectArray cmdarray, jobjectArray envp, jstring dir, jintArray channels, jstring slaveName, jint fdm, jboolean console) -{ - return -1; -} - -void ensureSize(wchar_t** ptr, int* psize, int requiredLength) -{ - int size= *psize; - if (requiredLength > size) { - size= 2*size; - if (size < requiredLength) { - size= requiredLength; - } - *ptr= (wchar_t *)realloc(*ptr, size * sizeof(wchar_t)); - if (NULL == *ptr) { - *psize= 0; - } - else { - *psize= size; - } - } -} - -extern "C" -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec0 - (JNIEnv * env, jobject process, jobjectArray cmdarray, jobjectArray envp, jstring dir, jintArray channels) -{ - HANDLE stdHandles[3]; - PROCESS_INFORMATION pi = {0}, *piCopy; - STARTUPINFOW si; - DWORD flags = 0; - const wchar_t * cwd = NULL; - LPVOID envBlk = NULL; - int ret = 0; - int nCmdLineLength= 0; - wchar_t * szCmdLine= 0; - int nBlkSize = MAX_ENV_SIZE; - wchar_t * szEnvBlock = NULL; - jsize nCmdTokens = 0; - jsize nEnvVars = 0; - int i; - DWORD pid = GetCurrentProcessId(); - int nPos; - pProcInfo_t pCurProcInfo; - - // This needs to be big enough to contain the name of the event used when calling CreateEventW bellow. - // It is made of a prefix (7 characters max) plus the value of a pointer that gets output in characters. - // This will be bigger in the case of 64 bit. - static const int MAX_EVENT_NAME_LENGTH = 50; - wchar_t eventBreakName[MAX_EVENT_NAME_LENGTH]; - wchar_t eventWaitName[MAX_EVENT_NAME_LENGTH]; - wchar_t eventTerminateName[MAX_EVENT_NAME_LENGTH]; - wchar_t eventKillName[MAX_EVENT_NAME_LENGTH]; - wchar_t eventCtrlcName[MAX_EVENT_NAME_LENGTH]; -#ifdef DEBUG_MONITOR - wchar_t buffer[4000]; -#endif - int nLocalCounter; - wchar_t inPipeName[PIPE_NAME_LENGTH]; - wchar_t outPipeName[PIPE_NAME_LENGTH]; - wchar_t errPipeName[PIPE_NAME_LENGTH]; - - nCmdLineLength= MAX_CMD_SIZE; - szCmdLine= (wchar_t *)malloc(nCmdLineLength * sizeof(wchar_t)); - szCmdLine[0]= _T('\0'); - if((HIBYTE(LOWORD(GetVersion()))) & 0x80) - { - ThrowByName(env, "java/io/IOException", "Does not support Windows 3.1/95/98/Me"); - return 0; - } - - if (cmdarray == 0) - { - ThrowByName(env, "java/lang/NullPointerException", "No command line specified"); - return 0; - } - - ZeroMemory(stdHandles, sizeof(stdHandles)); - - // Create pipe names - EnterCriticalSection(&cs); - swprintf(inPipeName, L"\\\\.\\pipe\\stdin%08i%010i", pid, nCounter); - swprintf(outPipeName, L"\\\\.\\pipe\\stdout%08i%010i", pid, nCounter); - swprintf(errPipeName, L"\\\\.\\pipe\\stderr%08i%010i", pid, nCounter); - nLocalCounter = nCounter; - ++nCounter; - LeaveCriticalSection(&cs); - - if ((INVALID_HANDLE_VALUE == (stdHandles[0] = CreateNamedPipeW(inPipeName, PIPE_ACCESS_OUTBOUND, - PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT, - PIPE_UNLIMITED_INSTANCES, PIPE_SIZE, PIPE_SIZE, PIPE_TIMEOUT, NULL))) || - (INVALID_HANDLE_VALUE == (stdHandles[1] = CreateNamedPipeW(outPipeName, PIPE_ACCESS_INBOUND | FILE_FLAG_OVERLAPPED, - PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT, - PIPE_UNLIMITED_INSTANCES, PIPE_SIZE, PIPE_SIZE, PIPE_TIMEOUT, NULL))) || - (INVALID_HANDLE_VALUE == (stdHandles[2] = CreateNamedPipeW(errPipeName, PIPE_ACCESS_INBOUND | FILE_FLAG_OVERLAPPED, - PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT, - PIPE_UNLIMITED_INSTANCES, PIPE_SIZE, PIPE_SIZE, PIPE_TIMEOUT, NULL)))) { - CloseHandle(stdHandles[0]); - CloseHandle(stdHandles[1]); - CloseHandle(stdHandles[2]); - ThrowByName(env, "java/io/IOException", "CreatePipe"); - return 0; - } - -#ifdef DEBUG_MONITOR - swprintf(buffer, _T("Opened pipes: %s, %s, %s\n"), inPipeName, outPipeName, errPipeName); - OutputDebugStringW(buffer); -#endif - - - nCmdTokens = env->GetArrayLength(cmdarray); - nEnvVars = env->GetArrayLength(envp); - - pCurProcInfo = createProcInfo(); - - if(NULL == pCurProcInfo) - { - ThrowByName(env, "java/io/IOException", "Too many processes"); - return 0; - } - - // Construct starter's command line - swprintf(eventBreakName, L"SABreak%04x%08x", pid, nLocalCounter); - swprintf(eventWaitName, L"SAWait%004x%08x", pid, nLocalCounter); - swprintf(eventTerminateName, L"SATerm%004x%08x", pid, nLocalCounter); - swprintf(eventKillName, L"SAKill%04x%08x", pid, nLocalCounter); - swprintf(eventCtrlcName, L"SACtrlc%04x%08x", pid, nLocalCounter); - - pCurProcInfo->eventBreak = CreateEventW(NULL, FALSE, FALSE, eventBreakName); - if(NULL == pCurProcInfo->eventBreak || GetLastError() == ERROR_ALREADY_EXISTS) - { - ThrowByName(env, "java/io/IOException", "Cannot create event"); - return 0; - } - pCurProcInfo->eventWait = CreateEventW(NULL, TRUE, FALSE, eventWaitName); - pCurProcInfo->eventTerminate = CreateEventW(NULL, FALSE, FALSE, eventTerminateName); - pCurProcInfo->eventKill = CreateEventW(NULL, FALSE, FALSE, eventKillName); - pCurProcInfo->eventCtrlc = CreateEventW(NULL, FALSE, FALSE, eventCtrlcName); - - swprintf(szCmdLine, L"\"%sstarter.exe\" %i %i %s %s %s %s %s ", path, pid, nLocalCounter, eventBreakName, eventWaitName, eventTerminateName, eventKillName, eventCtrlcName); - nPos = wcslen(szCmdLine); - - // Prepare command line - for(i = 0; i < nCmdTokens; ++i) - { - jstring item = (jstring)env->GetObjectArrayElement(cmdarray, i); - jsize len = env->GetStringLength(item); - int nCpyLen; - const wchar_t * str = (const wchar_t *)env->GetStringChars(item, 0); - if(NULL != str) - { - int requiredSize= nPos+len+2; - if (requiredSize > 32*1024) { - ThrowByName(env, "java/io/IOException", "Command line too long"); - return 0; - } - ensureSize(&szCmdLine, &nCmdLineLength, requiredSize); - if (NULL == szCmdLine) { - ThrowByName(env, "java/io/IOException", "Not enough memory"); - return 0; - } - - if(0 > (nCpyLen = copyTo(szCmdLine + nPos, str, len, nCmdLineLength - nPos))) - { - ThrowByName(env, "java/io/IOException", "Command line too long"); - return 0; - } - nPos += nCpyLen; - szCmdLine[nPos] = _T(' '); - ++nPos; - env->ReleaseStringChars(item, (const jchar *)str); - } - } - szCmdLine[nPos] = _T('\0'); - -#ifdef DEBUG_MONITOR - swprintf(buffer, _T("There are %i environment variables \n"), nEnvVars); - OutputDebugStringW(buffer); -#endif - // Prepare environment block - if (nEnvVars > 0) - { - nPos = 0; - szEnvBlock = (wchar_t *)malloc(nBlkSize * sizeof(wchar_t)); - for(i = 0; i < nEnvVars; ++i) - { - jstring item = (jstring)env->GetObjectArrayElement(envp, i); - jsize len = env->GetStringLength(item); - const wchar_t * str = (const wchar_t *)env->GetStringChars(item, 0); - if(NULL != str) - { - while((nBlkSize - nPos) <= (len + 2)) // +2 for two '\0' - { - nBlkSize += MAX_ENV_SIZE; - szEnvBlock = (wchar_t *)realloc(szEnvBlock, nBlkSize * sizeof(wchar_t)); - if(NULL == szEnvBlock) - { - ThrowByName(env, "java/io/IOException", "Not enough memory"); - return 0; - } -#ifdef DEBUG_MONITOR - swprintf(buffer, _T("Realloc environment block; new length is %i \n"), nBlkSize); - OutputDebugStringW(buffer); -#endif - - } -#ifdef DEBUG_MONITOR - swprintf(buffer, _T("%s\n"), str); - OutputDebugStringW(buffer); -#endif - wcsncpy(szEnvBlock + nPos, str, len); - nPos += len; - szEnvBlock[nPos] = _T('\0'); - ++nPos; - env->ReleaseStringChars(item, (const jchar *)str); - } - } - szEnvBlock[nPos] = _T('\0'); - } - - - - if (dir != 0) - { - const wchar_t * str = (const wchar_t *)env->GetStringChars(dir, 0); - if(NULL != str) - { - cwd = wcsdup(str); - env->ReleaseStringChars(dir, (const jchar *)str); - } - } - - - ZeroMemory(&si, sizeof(si)); - si.cb = sizeof(si); - si.dwFlags |= STARTF_USESHOWWINDOW; - si.wShowWindow = SW_HIDE; // Processes in the Process Group are hidden - - - - SetHandleInformation(stdHandles[0], HANDLE_FLAG_INHERIT, FALSE); - SetHandleInformation(stdHandles[1], HANDLE_FLAG_INHERIT, FALSE); - SetHandleInformation(stdHandles[2], HANDLE_FLAG_INHERIT, FALSE); - - flags = CREATE_NEW_CONSOLE; - flags |= CREATE_NO_WINDOW; - flags |= CREATE_UNICODE_ENVIRONMENT; - -#ifdef DEBUG_MONITOR - OutputDebugStringW(szCmdLine); -#endif - // launches starter; we need it to create another console group to correctly process - // emulation of SYSint signal (Ctrl-C) - ret = CreateProcessW(0, /* executable name */ - szCmdLine, /* command line */ - 0, /* process security attribute */ - 0, /* thread security attribute */ - FALSE, /* inherits system handles */ - flags, /* normal attached process */ - szEnvBlock, /* environment block */ - cwd, /* change to the new current directory */ - &si, /* (in) startup information */ - &pi); /* (out) process information */ - - if(NULL != cwd) - free((void *)cwd); - - if(NULL != szEnvBlock) - free(szEnvBlock); - - if(NULL != szCmdLine) - free(szCmdLine); - - if (!ret) // Launching error - { - char * lpMsgBuf; - CloseHandle(stdHandles[0]); - CloseHandle(stdHandles[1]); - CloseHandle(stdHandles[2]); - 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 - ); - ThrowByName(env, "java/io/IOException", lpMsgBuf); - // Free the buffer. - LocalFree( lpMsgBuf ); - cleanUpProcBlock(pCurProcInfo); - ret = -1; - } - else - { - int file_handles[3]; - HANDLE h[2]; - int what; - - EnterCriticalSection(&cs); - - pCurProcInfo -> pid = pi.dwProcessId; - h[0] = pCurProcInfo -> eventWait; - h[1] = pi.hProcess; - - what = WaitForMultipleObjects(2, h, FALSE, INFINITE); - if(what != WAIT_OBJECT_0) // CreateProcess failed - { -#ifdef DEBUG_MONITOR - swprintf(buffer, _T("Process %i failed\n"), pi.dwProcessId); - OutputDebugStringW(buffer); -#endif - cleanUpProcBlock(pCurProcInfo); - ThrowByName(env, "java/io/IOException", "Launching failed"); -#ifdef DEBUG_MONITOR - OutputDebugStringW(_T("Process failed\n")); -#endif - } - else - { - ret = (long)(pCurProcInfo -> uid); - - // Prepare stream handlers to return to java program - file_handles[0] = (int)stdHandles[0]; - file_handles[1] = (int)stdHandles[1]; - file_handles[2] = (int)stdHandles[2]; - env->SetIntArrayRegion(channels, 0, 3, (jint *)file_handles); - - // do the cleanup so launch the according thread - // create a copy of the PROCESS_INFORMATION as this might get destroyed - piCopy = (PROCESS_INFORMATION *)malloc(sizeof(PROCESS_INFORMATION)); - memcpy(piCopy, &pi, sizeof(PROCESS_INFORMATION)); - _beginthread(waitProcTermination, 0, (void *)piCopy); - -#ifdef DEBUG_MONITOR - OutputDebugStringW(_T("Process started\n")); -#endif - } - LeaveCriticalSection(&cs); - - } - - CloseHandle(pi.hThread); - - return ret; - -} - - -///////////////////////////////////////////////////////////////////////////////////// -// Launcher; just launches process and don't care about it any more -// Arguments: (see Spawner.java) -// [in] cmdarray - array of command line elements -// [in] envp - array of environment variables -// [in] dir - working directory -///////////////////////////////////////////////////////////////////////////////////// -extern "C" -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec1 - (JNIEnv * env, jobject process, jobjectArray cmdarray, jobjectArray envp, jstring dir) -{ - - SECURITY_ATTRIBUTES sa; - PROCESS_INFORMATION pi = {0}; - STARTUPINFOW si; - DWORD flags = 0; - wchar_t * cwd = NULL; - wchar_t * envBlk = NULL; - int ret = 0; - jsize nCmdTokens = 0; - jsize nEnvVars = 0; - int i; - int nPos; - int nCmdLineLength= 0; - wchar_t * szCmdLine= 0; - int nBlkSize = MAX_ENV_SIZE; - wchar_t * szEnvBlock = NULL; - - nCmdLineLength= MAX_CMD_SIZE; - szCmdLine= (wchar_t *)malloc(nCmdLineLength * sizeof(wchar_t)); - szCmdLine[0]= 0; - - sa.nLength = sizeof(sa); - sa.lpSecurityDescriptor = 0; - sa.bInheritHandle = TRUE; - - - nCmdTokens = env->GetArrayLength(cmdarray); - nEnvVars = env->GetArrayLength(envp); - - nPos = 0; - - // Prepare command line - for(i = 0; i < nCmdTokens; ++i) - { - jstring item = (jstring)env->GetObjectArrayElement(cmdarray, i); - jsize len = env->GetStringLength(item); - int nCpyLen; - const wchar_t * str = (const wchar_t *)env->GetStringChars(item, 0); - if(NULL != str) - { - int requiredSize= nPos+len+2; - if (requiredSize > 32*1024) { - ThrowByName(env, "java/io/IOException", "Command line too long"); - return 0; - } - ensureSize(&szCmdLine, &nCmdLineLength, requiredSize); - if (NULL == szCmdLine) { - ThrowByName(env, "java/io/IOException", "Not enough memory"); - return 0; - } - - if(0 > (nCpyLen = copyTo(szCmdLine + nPos, str, len, nCmdLineLength - nPos))) - { - ThrowByName(env, "java/io/Exception", "Command line too long"); - return 0; - } - nPos += nCpyLen; - szCmdLine[nPos] = _T(' '); - ++nPos; - env->ReleaseStringChars(item, (const jchar *)str); - } - } - - szCmdLine[nPos] = _T('\0'); - - // Prepare environment block - if (nEnvVars > 0) - { - szEnvBlock = (wchar_t *)malloc(nBlkSize * sizeof(wchar_t)); - nPos = 0; - for(i = 0; i < nEnvVars; ++i) - { - jstring item = (jstring)env->GetObjectArrayElement(envp, i); - jsize len = env->GetStringLength(item); - const wchar_t * str = (const wchar_t *)env->GetStringChars(item, 0); - if(NULL != str) - { - while((nBlkSize - nPos) <= (len + 2)) // +2 for two '\0' - { - nBlkSize += MAX_ENV_SIZE; - szEnvBlock = (wchar_t *)realloc(szEnvBlock, nBlkSize * sizeof(wchar_t)); - if(NULL == szEnvBlock) - { - ThrowByName(env, "java/io/Exception", "Not enough memory"); - return 0; - } - } - wcsncpy(szEnvBlock + nPos, str, len); - nPos += len; - szEnvBlock[nPos] = _T('\0'); - ++nPos; - env->ReleaseStringChars(item, (const jchar *)str); - } - } - szEnvBlock[nPos] = _T('\0'); - envBlk = szEnvBlock; - } - - - - if (dir != 0) - { - const wchar_t * str = (const wchar_t *)env->GetStringChars(dir, 0); - if(NULL != str) - { - cwd = wcsdup(str); - env->ReleaseStringChars(dir, (const jchar *)str); - } - } - - - ZeroMemory(&si, sizeof(si)); - si.cb = sizeof(si); - - - - - - flags = CREATE_NEW_CONSOLE; - flags |= CREATE_UNICODE_ENVIRONMENT; - ret = CreateProcessW(0, /* executable name */ - szCmdLine, /* command line */ - 0, /* process security attribute */ - 0, /* thread security attribute */ - TRUE, /* inherits system handles */ - flags, /* normal attached process */ - envBlk, /* environment block */ - cwd, /* change to the new current directory */ - &si, /* (in) startup information */ - &pi); /* (out) process information */ - - - - if(NULL != cwd) - free(cwd); - if(NULL != szEnvBlock) - free(szEnvBlock); - if(NULL != szCmdLine) - free(szCmdLine); - - if (!ret) // 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 - ); - ThrowByName(env, "java/io/IOException", lpMsgBuf); - // Free the buffer. - LocalFree( lpMsgBuf ); - ret = -1; - } - else - { - // Clean-up - CloseHandle(pi.hThread); - CloseHandle(pi.hProcess); - ret = (long)pi.dwProcessId; //hProcess; - } - - - return ret; - -} - - -///////////////////////////////////////////////////////////////////////////////////// -// Emulation of the signal raising -// Arguments: (see Spawner.java) -// [in] uid - unique process ID -// [in] signal - signal to raise -///////////////////////////////////////////////////////////////////////////////////// -extern "C" -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_raise - (JNIEnv * env, jobject process, jint uid, jint signal) -{ - jint ret = 0; - - HANDLE hProc; - pProcInfo_t pCurProcInfo = findProcInfo(uid); -#ifdef DEBUG_MONITOR - wchar_t buffer[100]; -#endif - - if(NULL == pCurProcInfo) { - if(SIG_INT == signal) { // Try another way - return interruptProcess(uid) ; - } - return -1; - } - -#ifdef DEBUG_MONITOR - swprintf(buffer, _T("Spawner received signal %i for process %i\n"), signal, pCurProcInfo -> pid); - OutputDebugStringW(buffer); -#endif - - hProc = OpenProcess(SYNCHRONIZE, 0, pCurProcInfo -> pid); - - if(NULL == hProc) - return -1; - - switch(signal) - { - case SIG_NOOP: - // Wait 0 msec -just check if the process has been still running - ret = ((WAIT_TIMEOUT == WaitForSingleObject(hProc, 0)) ? 0 : -1); - break; - case SIG_HUP: - // Temporary do nothing - ret = 0; - break; - case SIG_TERM: -#ifdef DEBUG_MONITOR - swprintf(buffer, _T("Spawner received TERM signal for process %i\n"), - pCurProcInfo -> pid); - OutputDebugStringW(buffer); -#endif - SetEvent(pCurProcInfo -> eventTerminate); -#ifdef DEBUG_MONITOR - OutputDebugStringW(_T("Spawner signaled TERM event\n")); -#endif - ret = 0; - break; - - case SIG_KILL: -#ifdef DEBUG_MONITOR - swprintf(buffer, _T("Spawner received KILL signal for process %i\n"), - pCurProcInfo -> pid); - OutputDebugStringW(buffer); -#endif - SetEvent(pCurProcInfo -> eventKill); -#ifdef DEBUG_MONITOR - OutputDebugStringW(_T("Spawner signaled KILL event\n")); -#endif - ret = 0; - break; - case SIG_INT: - ResetEvent(pCurProcInfo -> eventWait); - SetEvent(pCurProcInfo -> eventBreak); - ret = (WaitForSingleObject(pCurProcInfo -> eventWait, 100) == WAIT_OBJECT_0); - break; - case CTRLC: - ResetEvent(pCurProcInfo -> eventWait); - SetEvent(pCurProcInfo -> eventCtrlc); - ret = (WaitForSingleObject(pCurProcInfo -> eventWait, 100) == WAIT_OBJECT_0); - break; - default: - break; - } - - CloseHandle(hProc); - return ret; - - -} - - - -///////////////////////////////////////////////////////////////////////////////////// -// Wait for process termination -// Arguments: (see Spawner.java) -// [in] uid - unique process ID -///////////////////////////////////////////////////////////////////////////////////// -extern "C" -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_waitFor - (JNIEnv * env, jobject process, jint uid) -{ - DWORD exit_code = -1; - int what=0; - HANDLE hProc; - pProcInfo_t pCurProcInfo = findProcInfo(uid); - - if(NULL == pCurProcInfo) - return -1; - - hProc = OpenProcess(SYNCHRONIZE | PROCESS_QUERY_INFORMATION, 0, pCurProcInfo -> pid); - - if(NULL == hProc) - return -1; - - what = WaitForSingleObject(hProc, INFINITE); - - - if (what == WAIT_OBJECT_0) - { - GetExitCodeProcess(hProc, &exit_code); - } - - - if(hProc) - CloseHandle(hProc); - - return exit_code; -} - - - - - -// Utilities - -///////////////////////////////////////////////////////////////////////////////////// -// Throws Java exception (will be trapped by VM). -// Arguments: -// [in] name - name of exception class -// [in] message to assign thi event -///////////////////////////////////////////////////////////////////////////////////// -void ThrowByName(JNIEnv *env, const char *name, const char *msg) -{ - jclass cls = env->FindClass(name); - - if (cls != 0) /* Otherwise an exception has already been thrown */ - env->ThrowNew(cls, msg); - - /* It's a good practice to clean up the local references. */ - env->DeleteLocalRef(cls); -} - - - - -///////////////////////////////////////////////////////////////////////////////////// -// Create process description block. -// Arguments: no -// Return : pointer to the process descriptor -///////////////////////////////////////////////////////////////////////////////////// -pProcInfo_t createProcInfo() -{ - int i; - pProcInfo_t p = NULL; - - EnterCriticalSection(&cs); - - if(NULL == pInfo) - { - pInfo = (pProcInfo_t)malloc(sizeof(procInfo_t) * MAX_PROCS); - ZeroMemory(pInfo, sizeof(procInfo_t) * MAX_PROCS); - } - - for(i = 0; i < MAX_PROCS; ++i) - { - if(pInfo[i].pid == 0) - { - pInfo[i].pid = -1; - pInfo[i].uid = ++procCounter; - p = pInfo + i; - break; - } - } - - LeaveCriticalSection(&cs); - - return p; -} - -///////////////////////////////////////////////////////////////////////////////////// -// Using unique process ID finds process descriptor -// Arguments: no -// Return : pointer to the process descriptor -///////////////////////////////////////////////////////////////////////////////////// -pProcInfo_t findProcInfo(int uid) -{ - int i; - pProcInfo_t p = NULL; - if(NULL == pInfo) - return NULL; - - for(i = 0; i < MAX_PROCS; ++i) - { - if(pInfo[i].uid == uid) - { - p = pInfo + i; - break; - } - } - - return p; -} - -///////////////////////////////////////////////////////////////////////////////////// -// Cleans up vacant process descriptor -// Arguments: -// pCurProcInfo - pointer to descriptor to clean up -// Return : no -void cleanUpProcBlock(pProcInfo_t pCurProcInfo) -{ - if(0 != pCurProcInfo -> eventBreak) - { - CloseHandle(pCurProcInfo -> eventBreak); - pCurProcInfo -> eventBreak = 0; - } - if(0 != pCurProcInfo -> eventWait) - { - CloseHandle(pCurProcInfo -> eventWait); - pCurProcInfo -> eventWait = 0; - } - if(0 != pCurProcInfo -> eventTerminate) - { - CloseHandle(pCurProcInfo -> eventTerminate); - pCurProcInfo -> eventTerminate = 0; - } - - if(0 != pCurProcInfo -> eventKill) - { - CloseHandle(pCurProcInfo -> eventKill); - pCurProcInfo -> eventKill = 0; - } - - if(0 != pCurProcInfo -> eventCtrlc) - { - CloseHandle(pCurProcInfo -> eventCtrlc); - pCurProcInfo -> eventCtrlc = 0; - } - - pCurProcInfo -> pid = 0; -} - -///////////////////////////////////////////////////////////////////////////////////// -// Running in separate thread and waiting for the process termination -// Arguments: -// pv - pointer to PROCESS_INFORMATION struct -// Return : no -///////////////////////////////////////////////////////////////////////////////////// -void _cdecl waitProcTermination(void* pv) -{ - PROCESS_INFORMATION *pi = (PROCESS_INFORMATION *)pv; - int i; -#ifdef DEBUG_MONITOR - wchar_t buffer[1000]; -#endif - - // wait for process termination - WaitForSingleObject(pi->hProcess, INFINITE); - - for(i = 0; i < MAX_PROCS; ++i) - { - if(pInfo[i].pid == pi->dwProcessId) - { - cleanUpProcBlock(pInfo + i); -#ifdef DEBUG_MONITOR - swprintf(buffer, _T("waitProcTermination: set PID %i to 0\n"), - pi->dwProcessId); - OutputDebugStringW(buffer); -#endif - } - } - CloseHandle(pi->hProcess); - - free(pi); -} - -///////////////////////////////////////////////////////////////////////////////////// -// Use this utility program to process correctly quotation marks in the command line -// Arguments: -// target - string to copy to -// source - string to copy from -// cpyLength - copy length -// availSpace - size of the target buffer -// Return :number of bytes used in target, or -1 in case of error -///////////////////////////////////////////////////////////////////////////////////// -int copyTo(wchar_t * target, const wchar_t * source, int cpyLength, int availSpace) -{ - BOOL bSlash = FALSE; - int i = 0, j = 0; - int totCpyLength = cpyLength; - -#define QUOTATION_DO 0 -#define QUOTATION_DONE 1 -#define QUOTATION_NONE 2 - - int nQuotationMode = 0; - - - - if(availSpace <= cpyLength) // = to reserve space for final '\0' - return -1; - - if((_T('\"') == *source) && (_T('\"') == *(source + cpyLength - 1))) - { - nQuotationMode = QUOTATION_DONE; - } - else - if(wcschr(source, _T(' ')) == NULL) - { - // No reason to quote term because it doesn't have embedded spaces - nQuotationMode = QUOTATION_NONE; - } - else - { - // Needs to be quoted - nQuotationMode = QUOTATION_DO; - *target = _T('\"'); - ++j; - } - - - for(; i < cpyLength; ++i, ++j) - { - if(source[i] == _T('\\')) - bSlash = TRUE; - else - { - // Don't escape embracing quotation marks - if((source[i] == _T('\"')) && !((nQuotationMode == QUOTATION_DONE) && ((i == 0) || (i == (cpyLength - 1))) ) ) - { - if(!bSlash) // If still not escaped - { - if(j == availSpace) - return -1; - target[j] = _T('\\'); - ++j; - } - } - bSlash = FALSE; - } - - if(j == availSpace) - return -1; - target[j] = source[i]; - } - - if(nQuotationMode == QUOTATION_DO) - { - if(j == availSpace) - return -1; - target[j] = _T('\"'); - ++j; - } - - return j; -} diff --git a/core/org.eclipse.cdt.core.win32/library/build64.bat b/core/org.eclipse.cdt.core.win32/library/build64.bat deleted file mode 100644 index f866c8befc0..00000000000 --- a/core/org.eclipse.cdt.core.win32/library/build64.bat +++ /dev/null @@ -1,14 +0,0 @@ -@rem *************************************************************************** -@rem Copyright (c) 2011 Marc-Andre Laperle and others. -@rem This program and the accompanying materials -@rem are made available under the terms of the Eclipse Public License 2.0 -@rem which accompanies this distribution, and is available at -@rem https://www.eclipse.org/legal/epl-2.0/ -em -em SPDX-License-Identifier: EPL-2.0 -@rem -@rem Contributors: -@rem Marc-Andre Laperle - initial API and implementation -@rem *************************************************************************** - -nmake /f Makefile_x86_64.mk /NOLOGO install clean
\ No newline at end of file diff --git a/core/org.eclipse.cdt.core.win32/library/iostream.c b/core/org.eclipse.cdt.core.win32/library/iostream.c deleted file mode 100644 index 3b8d11259d4..00000000000 --- a/core/org.eclipse.cdt.core.win32/library/iostream.c +++ /dev/null @@ -1,272 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2009 QNX Software Systems 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: - * QNX Software Systems - initial API and implementation - * - * raise.c - * - * This is a part of JNI implementation of spawner - * Includes implementation of JNI methods (see Spawner.java) - *******************************************************************************/ -#include "stdafx.h" -#include <string.h> -#include <stdlib.h> -#include "spawner.h" -#include "SpawnerInputStream.h" -#include "SpawnerOutputStream.h" - -#include "jni.h" -#include "io.h" - -//#define READ_REPORT - -void ThrowByName(JNIEnv *env, const char *name, const char *msg); - -#define BUFF_SIZE (1024) - -/* Inaccessible static: skipBuffer */ -/* - * Class: SpawnerInputStream - * Method: read0 - * Signature: (I)I - */ -extern "C" -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_read0 - (JNIEnv * env, jobject proc, jint fd, jbyteArray buf, jint len) -{ - jbyte tmpBuf[BUFF_SIZE]; - int nBuffOffset = 0; -#ifdef DEBUG_MONITOR - _TCHAR buffer[1000]; -#endif - OVERLAPPED overlapped; - overlapped.Offset = 0; - overlapped.OffsetHigh = 0; - overlapped.hEvent = CreateEvent(NULL, // no security attribute - TRUE, // manual-reset event - TRUE, // initial state = signaled - NULL); // unnamed event object - - if(NULL == 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 - ); - - ThrowByName(env, "java/io/IOException", lpMsgBuf); - // Free the buffer. - LocalFree( lpMsgBuf ); - } - -#ifdef DEBUG_MONITOR -#ifdef READ_REPORT - _stprintf(buffer, _T("Start read %i\n"), fd); - OutputDebugStringW(buffer); -#endif -#endif - - while(len > nBuffOffset) - { - DWORD nNumberOfBytesToRead = min(len - nBuffOffset, BUFF_SIZE); - DWORD nNumberOfBytesRead; - if(0 == ReadFile((HANDLE)fd, tmpBuf, nNumberOfBytesToRead, &nNumberOfBytesRead, &overlapped )) - { - int err = GetLastError(); - - if(err == ERROR_IO_PENDING) - { - // asynchronous i/o is still in progress - // check on the results of the asynchronous read - if(GetOverlappedResult((HANDLE)fd, &overlapped, - &nNumberOfBytesRead, TRUE)) - err = 0; - // if there was a problem ... - else - err = GetLastError(); - } - if(err == ERROR_BROKEN_PIPE) // Pipe was closed - break; - if(err != 0) - { - char * lpMsgBuf; -#ifdef DEBUG_MONITOR - _stprintf(buffer, _T("Read failed - %i, error %i\n"), fd, err); - OutputDebugStringW(buffer); -#endif - 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 - ); - - ThrowByName(env, "java/io/IOException", lpMsgBuf); - LocalFree( lpMsgBuf ); - nBuffOffset = 0; - break; - } - else - { - // buffer overflow? - // according to msdn this happens in message read mode only -#ifdef DEBUG_MONITOR - _stprintf(buffer, _T("Buffer full - %i, bytes read: %i\n"), fd, nNumberOfBytesRead); - OutputDebugStringW(buffer); -#endif - // nNumberOfBytesRead can be 0 here for unknown reason (bug 269223) - nNumberOfBytesRead = nNumberOfBytesToRead; - } - } - } - if(nNumberOfBytesRead > 0) - env->SetByteArrayRegion(buf, nBuffOffset, nNumberOfBytesRead, tmpBuf); - else - break; - nBuffOffset += nNumberOfBytesRead; - if(nNumberOfBytesRead != nNumberOfBytesToRead) - break; - else - { - // Is there data left in the pipe? - DWORD bytesAvailable = 0; - if (!::PeekNamedPipe((HANDLE)fd, NULL, 0, NULL, &bytesAvailable, NULL) - || bytesAvailable == 0) - // No bytes left - break; - } - } - CloseHandle(overlapped.hEvent); -#ifdef DEBUG_MONITOR -#ifdef READ_REPORT - _stprintf(buffer, _T("End read %i - bytes read: %d\n"), fd, nBuffOffset); - OutputDebugStringW(buffer); -#endif -#endif - return nBuffOffset; // This is a real full readed length - -} - -/* - * Class: SpawnerInputStream - * Method: close0 - * Signature: (I)I - */ -extern "C" -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_close0 - (JNIEnv * env, jobject proc, jint fd) -{ - int rc; -#ifdef DEBUG_MONITOR - _TCHAR buffer[1000]; - _stprintf(buffer, _T("Close %i\n"), fd); - OutputDebugStringW(buffer); -#endif - rc = (CloseHandle((HANDLE)fd) ? 0 : -1); -#ifdef DEBUG_MONITOR - _stprintf(buffer, _T("Closed %i\n"), fd); - OutputDebugStringW(buffer); -#endif - return (rc ? GetLastError() : 0); -} - -extern "C" -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_available0 - (JNIEnv * env, jobject proc, jint fd) -{ - DWORD nAvail = 0; - - if (0 == PeekNamedPipe((HANDLE)fd, NULL, 0, NULL, &nAvail, NULL)) { - // error - return 0; - } - return nAvail; -} - -/* - * Class: SpawnerOutputStream - * Method: write0 - * Signature: (I[BI)I - */ -extern "C" -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerOutputStream_write0 - (JNIEnv * env, jobject proc, jint fd, jbyteArray buf, jint len) -{ - jbyte tmpBuf[BUFF_SIZE]; - int nBuffOffset = 0; - - - while(len > nBuffOffset) - { - DWORD nNumberOfBytesToWrite = min(len - nBuffOffset, BUFF_SIZE); - DWORD nNumberOfBytesWritten; - env->GetByteArrayRegion(buf, nBuffOffset, nNumberOfBytesToWrite, tmpBuf); - if(0 == WriteFile((HANDLE)fd, 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 - ); - - ThrowByName(env, "java/io/IOException", lpMsgBuf); - LocalFree( lpMsgBuf ); - return 0; - } - nBuffOffset += nNumberOfBytesWritten; - } - return 0; -} - -/* - * Class: SpawnerOutputStream - * Method: close0 - * Signature: (I)I - */ -extern "C" -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerOutputStream_close0 - (JNIEnv * env, jobject proc, jint fd) -{ - int rc; -#ifdef DEBUG_MONITOR - _TCHAR buffer[1000]; - _stprintf(buffer, _T("Close %i\n"), fd); - OutputDebugStringW(buffer); -#endif - FlushFileBuffers((HANDLE)fd); - rc = (CloseHandle((HANDLE)fd) ? 0 : -1); -#ifdef DEBUG_MONITOR - _stprintf(buffer, _T("Closed %i\n"), fd); - OutputDebugStringW(buffer); -#endif - return (rc ? GetLastError() : 0); -} diff --git a/core/org.eclipse.cdt.core.win32/library/pty/jni/include/PTYOutputStream.h b/core/org.eclipse.cdt.core.win32/library/pty/jni/include/PTYOutputStream.h deleted file mode 100644 index fb28491060e..00000000000 --- a/core/org.eclipse.cdt.core.win32/library/pty/jni/include/PTYOutputStream.h +++ /dev/null @@ -1,29 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include <jni.h> -/* Header for class org_eclipse_cdt_utils_pty_PTYOutputStream */ - -#ifndef _Included_org_eclipse_cdt_utils_pty_PTYOutputStream -#define _Included_org_eclipse_cdt_utils_pty_PTYOutputStream -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: org_eclipse_cdt_utils_pty_PTYOutputStream - * Method: write0 - * Signature: (I[BI)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTYOutputStream_write0 - (JNIEnv *, jobject, jint, jbyteArray, jint); - -/* - * Class: org_eclipse_cdt_utils_pty_PTYOutputStream - * Method: close0 - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTYOutputStream_close0 - (JNIEnv *, jobject, jint); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/core/org.eclipse.cdt.core.win32/library/pty/jni/src/dllmain.cpp b/core/org.eclipse.cdt.core.win32/library/pty/jni/src/dllmain.cpp deleted file mode 100644 index c19f2ebbdcc..00000000000 --- a/core/org.eclipse.cdt.core.win32/library/pty/jni/src/dllmain.cpp +++ /dev/null @@ -1,71 +0,0 @@ -// dllmain.cpp : Defines the entry point for the DLL application. -#include <windows.h> -#include <delayimp.h> -#include <assert.h> - -#pragma comment(lib, "delayimp") - -BOOL APIENTRY DllMain( HMODULE hModule, - DWORD ul_reason_for_call, - LPVOID lpReserved - ) -{ - switch (ul_reason_for_call) - { - case DLL_PROCESS_ATTACH: - case DLL_THREAD_ATTACH: - case DLL_THREAD_DETACH: - case DLL_PROCESS_DETACH: - break; - } - return TRUE; -} - -static HMODULE getCurrentModule() -{ - HMODULE module; - if (!GetModuleHandleEx( - GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | - GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, - (LPCTSTR)getCurrentModule, - &module)) { - assert(false); - } - return module; -} - -HMODULE PTYExplicitLoadLibrary( LPCSTR pszModuleName ) -{ - if( lstrcmpiA( pszModuleName, "winpty.dll" ) == 0 ) - { - CHAR szPath[MAX_PATH] = ""; - //_hdllInstance is the HMODULE of *this* module - DWORD cchPath = GetModuleFileNameA(getCurrentModule(), szPath, MAX_PATH ); - while( cchPath > 0 ) - { - switch( szPath[cchPath - 1] ) - { - case '\\': - case '/': - case ':': - break; - default: - --cchPath; - continue; - } - break; //stop searching; found path separator - } - lstrcpynA( szPath + cchPath, pszModuleName, MAX_PATH - cchPath ); - return LoadLibraryA( szPath ); //call with full path to dependent DLL - } - return NULL; -} - -FARPROC WINAPI PTYDliNotifyHook( unsigned dliNotify, PDelayLoadInfo pdli ) -{ - if( dliNotify == dliNotePreLoadLibrary ) - return (FARPROC)PTYExplicitLoadLibrary( pdli->szDll ); - return NULL; -} - -extern "C" PfnDliHook __pfnDliNotifyHook2 = PTYDliNotifyHook; diff --git a/core/org.eclipse.cdt.core.win32/library/pty/jni/src/pty.cpp b/core/org.eclipse.cdt.core.win32/library/pty/jni/src/pty.cpp deleted file mode 100644 index f7aef2a3d6a..00000000000 --- a/core/org.eclipse.cdt.core.win32/library/pty/jni/src/pty.cpp +++ /dev/null @@ -1,424 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013, 2016 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: - * Wind River Systems - initial API and implementation - *******************************************************************************/ - -#include "PTY.h" -#include "PTYInputStream.h" -#include "PTYOutputStream.h" -#include "winpty.h" - -#include <string> -#include <vector> -#include <map> -#include <stdlib.h> -#include <assert.h> -#include <ctime> - -static std::map<int, winpty_t*> fd2pty; -static std::map<int, int> fd2rc; - -/* - * Class: org_eclipse_cdt_utils_pty_PTY - * Method: openMaster - * Signature: (Z)Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL Java_org_eclipse_cdt_utils_pty_PTY_openMaster(JNIEnv *env, jobject jobj, jboolean console) -{ - jfieldID fid; /* Store the field ID */ - jstring jstr = NULL; - jclass cls; - - int master = -1; - char line[1024]; - - line[0] = '\0'; - - /* Open new winpty handle */ - winpty_t* winpty = winpty_open(80, 40); - if (winpty == NULL) { - return NULL; - } - - /* Configure console mode */ - if (console) { - winpty_set_console_mode(winpty, 1); - } - - /* Generate masterFD based on current system time */ - srand((unsigned int)time(NULL)); - master = rand(); - - /* Make sure masterFD does not exist */ - while (fd2pty.find(master) != fd2pty.end()) - master++; - - sprintf(line, "winpty_%i", master); - - /* Remember the winpty handle for the generated masterFD */ - fd2pty.insert(std::pair<int, winpty_t*>(master, winpty)); - - /* Get a reference to the obj's class */ - cls = env->GetObjectClass(jobj); - - /* Set the master fd. */ - fid = env->GetFieldID(cls, "master", "I"); - if (fid == NULL) { - return NULL; - } - env->SetIntField(jobj, fid, (jint)master); - - /* Create a new String for the slave. */ - jstr = env->NewStringUTF(line); - - return jstr; -} - -/* - * Class: org_eclipse_cdt_utils_pty_PTY - * Method: change_window_size - * Signature: (III)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTY_change_1window_1size(JNIEnv *env, jobject jobj, jint fdm, jint width, jint height) -{ - int fd; - std::map<int, winpty_t*> :: const_iterator fd2pty_Iter; - - fd = fdm; - fd2pty_Iter = fd2pty.find(fd); - if (fd2pty_Iter != fd2pty.end()) { - winpty_t* winpty = fd2pty_Iter -> second; - if (winpty != NULL) - return winpty_set_size(winpty, width, height); - } - - return 0; -} - -/* - * Class: org_eclipse_cdt_utils_pty_PTYInputStream - * Method: read0 - * Signature: (I[BI)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTYInputStream_read0 - (JNIEnv *env, jobject jobj, jint jfd, jbyteArray buf, jint buf_len) -{ - DWORD amount = -1; - OVERLAPPED over; - int fd; - std::map<int, winpty_t*> :: const_iterator fd2pty_Iter; - - fd = jfd; - fd2pty_Iter = fd2pty.find(fd); - if (fd2pty_Iter != fd2pty.end()) { - winpty_t* winpty = fd2pty_Iter -> second; - if (winpty != NULL) { - /* Get the pipe handle */ - HANDLE handle = winpty_get_data_pipe(winpty); - - memset(&over, 0, sizeof(over)); - over.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); - - char *buffer = new char[buf_len]; - memset(buffer, 0, sizeof(*buffer)); - - jbyte *data = env->GetByteArrayElements(buf, 0); - memset(data, 0, sizeof(*data)); - - amount = 0; - BOOL ret = ReadFile(handle, buffer, buf_len, &amount, &over); - if (!ret) { - DWORD error = GetLastError(); - if (error == ERROR_IO_PENDING) - ret = GetOverlappedResult(handle, &over, &amount, TRUE); - } - - if (ret && amount > 0) - memcpy(data, buffer, amount); - - if (!ret || amount == 0) - amount = -1; - - if (!ret && fd2pty.find(fd) != fd2pty.end()) { - int rc = winpty_get_exit_code(winpty); - fd2rc.insert(std::pair<int, int>(fd, rc)); - } - - delete[] buffer; - env->ReleaseByteArrayElements(buf, data, 0); - ResetEvent(over.hEvent); - } - } - - return amount; -} - -/* - * Class: org_eclipse_cdt_utils_pty_PTYInputStream - * Method: close0 - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTYInputStream_close0(JNIEnv *env, jobject jobj, jint jfd) -{ - int fd; - std::map<int, winpty_t*> :: iterator fd2pty_Iter; - - fd = jfd; - fd2pty_Iter = fd2pty.find(fd); - if (fd2pty_Iter != fd2pty.end()) { - winpty_t* winpty = fd2pty_Iter -> second; - fd2pty.erase(fd2pty_Iter); - if (winpty != NULL) { - winpty_close(winpty); - winpty = NULL; - } - } - - return 0; -} - -/* - * Class: org_eclipse_cdt_utils_pty_PTYOutputStream - * Method: write0 - * Signature: (I[BI)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTYOutputStream_write0(JNIEnv *env, jobject jobj, jint jfd, jbyteArray buf, jint buf_len) -{ - DWORD written = -1; - OVERLAPPED over; - int fd; - std::map<int, winpty_t*> :: iterator fd2pty_Iter; - - fd = jfd; - fd2pty_Iter = fd2pty.find(fd); - if (fd2pty_Iter != fd2pty.end()) { - winpty_t* winpty = fd2pty_Iter -> second; - if (winpty != NULL) { - /* Get the pipe handle */ - HANDLE handle = winpty_get_data_pipe(winpty); - - memset(&over, 0, sizeof(over)); - over.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); - - char *buffer = new char[buf_len]; - memset(buffer, 0, sizeof(*buffer)); - - jbyte *data = env->GetByteArrayElements(buf, 0); - memcpy(buffer, data, buf_len); - - BOOL ret = WriteFile(handle, buffer, buf_len, &written, &over); - env->ReleaseByteArrayElements(buf, data, 0); - - if (!ret && GetLastError() == ERROR_IO_PENDING) - ret = GetOverlappedResult(handle, &over, &written, TRUE); - if (!ret || (int)written != buf_len) - written = -1; - - delete[] buffer; - } - } - - return written; -} - -/* - * Class: org_eclipse_cdt_utils_pty_PTYOutputStream - * Method: close0 - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTYOutputStream_close0(JNIEnv *env, jobject jobj, jint jfd) -{ - int fd; - std::map<int, winpty_t*> :: iterator fd2pty_Iter; - - fd = jfd; - fd2pty_Iter = fd2pty.find(fd); - if (fd2pty_Iter != fd2pty.end()) { - winpty_t* winpty = fd2pty_Iter -> second; - fd2pty.erase(fd2pty_Iter); - if (winpty != NULL) { - winpty_close(winpty); - winpty = NULL; - } - } - - return 0; -} - -/* - * Convert convert slashes to backslashes. - */ -static std::wstring convertSlashes(const wchar_t *path) -{ - std::wstring ret; - - for (int i = 0; path[i] != L'\0'; ++i) { - if (path[i] == L'/') - ret.push_back(L'\\'); - else - ret.push_back(path[i]); - } - - return ret; -} - -// Convert argc/argv into a Win32 command-line following the escaping convention -// documented on MSDN. (e.g. see CommandLineToArgvW documentation) -static std::wstring argvToCommandLine(const std::vector<std::wstring> &argv) -{ - std::wstring result; - for (size_t argIndex = 0; argIndex < argv.size(); ++argIndex) { - if (argIndex > 0) - result.push_back(L' '); - const wchar_t *arg = argv[argIndex].c_str(); - const bool quote = - wcschr(arg, L' ') != NULL || - wcschr(arg, L'\t') != NULL || - *arg == L'\0'; - if (quote) - result.push_back(L'\"'); - int bsCount = 0; - for (const wchar_t *p = arg; *p != L'\0'; ++p) { - if (*p == L'\\') { - bsCount++; - } else if (*p == L'\"') { - result.append(bsCount * 2 + 1, L'\\'); - result.push_back(L'\"'); - bsCount = 0; - } else { - result.append(bsCount, L'\\'); - bsCount = 0; - result.push_back(*p); - } - } - if (quote) { - result.append(bsCount * 2, L'\\'); - result.push_back(L'\"'); - } else { - result.append(bsCount, L'\\'); - } - } - return result; -} - -/* - * Class: org_eclipse_cdt_utils_pty_PTY - * Method: exec2 - * Signature: ([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[ILjava/lang/String;IZ)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTY_exec2 - (JNIEnv *env, jobject jobj, jobjectArray jcmd, jobjectArray jenv, jstring jdir, jintArray jchannels, jstring jslaveName, jint masterFD, jboolean console) -{ - int fd; - std::map<int, winpty_t*> :: iterator fd2pty_Iter; - - jint *channels = env->GetIntArrayElements(jchannels, 0); - const wchar_t *cwdW = (const wchar_t *) env->GetStringChars(jdir, NULL); - const char *pts_name = env->GetStringUTFChars(jslaveName, NULL); - - int pid = -1; - - int i; - jint argc = env->GetArrayLength(jcmd); - jint envc = env->GetArrayLength(jenv); - - if (channels == NULL) - goto bail_out; - - fd = masterFD; - fd2pty_Iter = fd2pty.find(fd); - if (fd2pty_Iter != fd2pty.end()) { - winpty_t* winpty = fd2pty_Iter -> second; - if (winpty != NULL) { - std::vector<std::wstring> argVector; - - for (i = 0; i < argc; i++) { - jstring j_str = (jstring) env->GetObjectArrayElement(jcmd, i); - const wchar_t *w_str = (const wchar_t *) env->GetStringChars(j_str, NULL); - if (i == 0) argVector.push_back(convertSlashes(w_str)); - else argVector.push_back(w_str); - env->ReleaseStringChars(j_str, (const jchar *) w_str); - env->DeleteLocalRef(j_str); - } - - std::wstring envp; - - for (i = 0; i < envc; i++) { - jstring j_str = (jstring) env->GetObjectArrayElement(jenv, i); - const wchar_t *w_str = (const wchar_t *) env->GetStringChars(j_str, NULL); - envp.append(w_str); - envp.push_back(L'\0'); - env->ReleaseStringChars(j_str, (const jchar *) w_str); - env->DeleteLocalRef(j_str); - } - - std::wstring cmdLine = argvToCommandLine(argVector); - const wchar_t *cmdLineW = cmdLine.c_str(); - - int ret = winpty_start_process(winpty, - NULL, - cmdLineW, - cwdW, - envp.c_str()); - - if (ret == 0) { - // Success. Get the process id. - pid = winpty_get_process_id(winpty); - } - } - } - -bail_out: - env->ReleaseIntArrayElements(jchannels, channels, 0); - env->ReleaseStringChars(jdir, (const jchar *) cwdW); - env->ReleaseStringUTFChars(jslaveName, pts_name); - - return pid; -} - -/* - * Class: org_eclipse_cdt_utils_pty_PTY - * Method: waitFor - * Signature: (II)I - */ -JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTY_waitFor - (JNIEnv *env, jobject jobj, jint masterFD, jint pid) -{ - int status = -1; - DWORD flags; - - int fd; - std::map<int, winpty_t*> :: iterator fd2pty_Iter; - std::map<int, int> :: iterator fd2rc_Iter; - - fd = masterFD; - fd2pty_Iter = fd2pty.find(fd); - if (fd2pty_Iter != fd2pty.end()) { - winpty_t* winpty = fd2pty_Iter -> second; - if (winpty != NULL) { - HANDLE handle = winpty_get_data_pipe(winpty); - BOOL success; - do { - success = GetHandleInformation(handle, &flags); - if (success) Sleep(500); - } while (success); - - fd2rc_Iter = fd2rc.find(fd); - if (fd2rc_Iter != fd2rc.end()) { - status = fd2rc_Iter -> second; - fd2rc.erase(fd2rc_Iter); - } - } - } - - return status; -} diff --git a/core/org.eclipse.cdt.core.win32/library/pty/pty.sln b/core/org.eclipse.cdt.core.win32/library/pty/pty.sln deleted file mode 100644 index 220c281aade..00000000000 --- a/core/org.eclipse.cdt.core.win32/library/pty/pty.sln +++ /dev/null @@ -1,46 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual C++ Express 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pty", "pty.vcxproj", "{5589D515-1C56-4641-97CF-3C4561109258}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "winpty", "winpty.vcxproj", "{D7BFF73A-A86A-47FF-AD2B-CC2EFCAD5ABD}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "winpty-agent", "winpty-agent.vcxproj", "{E7A42398-12E7-4BC1-B72B-5D62B71E9816}" -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 - {5589D515-1C56-4641-97CF-3C4561109258}.Debug|Win32.ActiveCfg = Debug|Win32 - {5589D515-1C56-4641-97CF-3C4561109258}.Debug|Win32.Build.0 = Debug|Win32 - {5589D515-1C56-4641-97CF-3C4561109258}.Debug|x64.ActiveCfg = Debug|x64 - {5589D515-1C56-4641-97CF-3C4561109258}.Debug|x64.Build.0 = Debug|x64 - {5589D515-1C56-4641-97CF-3C4561109258}.Release|Win32.ActiveCfg = Release|Win32 - {5589D515-1C56-4641-97CF-3C4561109258}.Release|Win32.Build.0 = Release|Win32 - {5589D515-1C56-4641-97CF-3C4561109258}.Release|x64.ActiveCfg = Release|x64 - {5589D515-1C56-4641-97CF-3C4561109258}.Release|x64.Build.0 = Release|x64 - {D7BFF73A-A86A-47FF-AD2B-CC2EFCAD5ABD}.Debug|Win32.ActiveCfg = Debug|Win32 - {D7BFF73A-A86A-47FF-AD2B-CC2EFCAD5ABD}.Debug|Win32.Build.0 = Debug|Win32 - {D7BFF73A-A86A-47FF-AD2B-CC2EFCAD5ABD}.Debug|x64.ActiveCfg = Debug|x64 - {D7BFF73A-A86A-47FF-AD2B-CC2EFCAD5ABD}.Debug|x64.Build.0 = Debug|x64 - {D7BFF73A-A86A-47FF-AD2B-CC2EFCAD5ABD}.Release|Win32.ActiveCfg = Release|Win32 - {D7BFF73A-A86A-47FF-AD2B-CC2EFCAD5ABD}.Release|Win32.Build.0 = Release|Win32 - {D7BFF73A-A86A-47FF-AD2B-CC2EFCAD5ABD}.Release|x64.ActiveCfg = Release|x64 - {D7BFF73A-A86A-47FF-AD2B-CC2EFCAD5ABD}.Release|x64.Build.0 = Release|x64 - {E7A42398-12E7-4BC1-B72B-5D62B71E9816}.Debug|Win32.ActiveCfg = Debug|Win32 - {E7A42398-12E7-4BC1-B72B-5D62B71E9816}.Debug|Win32.Build.0 = Debug|Win32 - {E7A42398-12E7-4BC1-B72B-5D62B71E9816}.Debug|x64.ActiveCfg = Debug|x64 - {E7A42398-12E7-4BC1-B72B-5D62B71E9816}.Debug|x64.Build.0 = Debug|x64 - {E7A42398-12E7-4BC1-B72B-5D62B71E9816}.Release|Win32.ActiveCfg = Release|Win32 - {E7A42398-12E7-4BC1-B72B-5D62B71E9816}.Release|Win32.Build.0 = Release|Win32 - {E7A42398-12E7-4BC1-B72B-5D62B71E9816}.Release|x64.ActiveCfg = Release|x64 - {E7A42398-12E7-4BC1-B72B-5D62B71E9816}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/core/org.eclipse.cdt.core.win32/library/pty/pty.vcxproj b/core/org.eclipse.cdt.core.win32/library/pty/pty.vcxproj deleted file mode 100644 index 7d526ce88b1..00000000000 --- a/core/org.eclipse.cdt.core.win32/library/pty/pty.vcxproj +++ /dev/null @@ -1,177 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <ItemGroup Label="ProjectConfigurations"> - <ProjectConfiguration Include="Debug|Win32"> - <Configuration>Debug</Configuration> - <Platform>Win32</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Debug|x64"> - <Configuration>Debug</Configuration> - <Platform>x64</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Release|Win32"> - <Configuration>Release</Configuration> - <Platform>Win32</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Release|x64"> - <Configuration>Release</Configuration> - <Platform>x64</Platform> - </ProjectConfiguration> - </ItemGroup> - <PropertyGroup Label="Globals"> - <ProjectGuid>{5589D515-1C56-4641-97CF-3C4561109258}</ProjectGuid> - <Keyword>Win32Proj</Keyword> - <RootNamespace>pty</RootNamespace> - </PropertyGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> - <ConfigurationType>DynamicLibrary</ConfigurationType> - <UseDebugLibraries>true</UseDebugLibraries> - <CharacterSet>Unicode</CharacterSet> - <PlatformToolset>Windows7.1SDK</PlatformToolset> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> - <ConfigurationType>DynamicLibrary</ConfigurationType> - <UseDebugLibraries>true</UseDebugLibraries> - <CharacterSet>Unicode</CharacterSet> - <PlatformToolset>Windows7.1SDK</PlatformToolset> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> - <ConfigurationType>DynamicLibrary</ConfigurationType> - <UseDebugLibraries>false</UseDebugLibraries> - <WholeProgramOptimization>true</WholeProgramOptimization> - <CharacterSet>Unicode</CharacterSet> - <PlatformToolset>Windows7.1SDK</PlatformToolset> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> - <ConfigurationType>DynamicLibrary</ConfigurationType> - <UseDebugLibraries>false</UseDebugLibraries> - <WholeProgramOptimization>true</WholeProgramOptimization> - <CharacterSet>Unicode</CharacterSet> - <PlatformToolset>Windows7.1SDK</PlatformToolset> - </PropertyGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> - <ImportGroup Label="ExtensionSettings"> - </ImportGroup> - <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - </ImportGroup> - <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - </ImportGroup> - <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - </ImportGroup> - <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - </ImportGroup> - <PropertyGroup Label="UserMacros" /> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <LinkIncremental>true</LinkIncremental> - <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir> - <IntDir>$(Platform)\$(Configuration)\$(ProjectName)\</IntDir> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> - <LinkIncremental>true</LinkIncremental> - <IntDir>$(Platform)\$(Configuration)\$(ProjectName)\</IntDir> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <LinkIncremental>false</LinkIncremental> - <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir> - <IntDir>$(Platform)\$(Configuration)\$(ProjectName)\</IntDir> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> - <LinkIncremental>false</LinkIncremental> - <IntDir>$(Platform)\$(Configuration)\$(ProjectName)\</IntDir> - </PropertyGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <ClCompile> - <PrecompiledHeader>NotUsing</PrecompiledHeader> - <WarningLevel>Level3</WarningLevel> - <Optimization>Disabled</Optimization> - <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;_SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <AdditionalIncludeDirectories>./jni/include;C:\NoScan\Apps\Java\jdk1.6.0_31\include;C:\NoScan\Apps\Java\jdk1.6.0_31\include\win32;..\winpty\include;.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> - </ClCompile> - <Link> - <SubSystem>Windows</SubSystem> - <GenerateDebugInformation>true</GenerateDebugInformation> - <AdditionalDependencies>DelayImp.lib;winpty.lib;%(AdditionalDependencies)</AdditionalDependencies> - <AdditionalLibraryDirectories>$(SolutionDir)$(Platform)\$(Configuration)\</AdditionalLibraryDirectories> - <DelayLoadDLLs>winpty.dll;%(DelayLoadDLLs)</DelayLoadDLLs> - </Link> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> - <ClCompile> - <PrecompiledHeader>NotUsing</PrecompiledHeader> - <WarningLevel>Level3</WarningLevel> - <Optimization>Disabled</Optimization> - <PreprocessorDefinitions>_SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <AdditionalIncludeDirectories>./jni/include;C:\NoScan\Apps\Java\jdk1.6.0_31\include;C:\NoScan\Apps\Java\jdk1.6.0_31\include\win32;..\winpty\include;.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> - </ClCompile> - <Link> - <SubSystem>Windows</SubSystem> - <GenerateDebugInformation>true</GenerateDebugInformation> - <AdditionalDependencies>DelayImp.lib;winpty.lib;%(AdditionalDependencies)</AdditionalDependencies> - <AdditionalLibraryDirectories>$(SolutionDir)$(Platform)\$(Configuration)\</AdditionalLibraryDirectories> - <DelayLoadDLLs>winpty.dll;%(DelayLoadDLLs)</DelayLoadDLLs> - </Link> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <ClCompile> - <WarningLevel>Level3</WarningLevel> - <PrecompiledHeader> - </PrecompiledHeader> - <Optimization>MaxSpeed</Optimization> - <FunctionLevelLinking>true</FunctionLevelLinking> - <IntrinsicFunctions>true</IntrinsicFunctions> - <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;_SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <AdditionalIncludeDirectories>./jni/include;C:\NoScan\Apps\Java\jdk1.6.0_31\include;C:\NoScan\Apps\Java\jdk1.6.0_31\include\win32;..\winpty\include;.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - <RuntimeLibrary>MultiThreaded</RuntimeLibrary> - </ClCompile> - <Link> - <SubSystem>Windows</SubSystem> - <GenerateDebugInformation>true</GenerateDebugInformation> - <EnableCOMDATFolding>true</EnableCOMDATFolding> - <OptimizeReferences>true</OptimizeReferences> - <AdditionalDependencies>DelayImp.lib;winpty.lib;%(AdditionalDependencies)</AdditionalDependencies> - <AdditionalLibraryDirectories>$(SolutionDir)$(Platform)\$(Configuration)\</AdditionalLibraryDirectories> - <DelayLoadDLLs>winpty.dll;%(DelayLoadDLLs)</DelayLoadDLLs> - </Link> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> - <ClCompile> - <WarningLevel>Level3</WarningLevel> - <PrecompiledHeader> - </PrecompiledHeader> - <Optimization>MaxSpeed</Optimization> - <FunctionLevelLinking>true</FunctionLevelLinking> - <IntrinsicFunctions>true</IntrinsicFunctions> - <PreprocessorDefinitions>_SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <AdditionalIncludeDirectories>./jni/include;C:\NoScan\Apps\Java\jdk1.6.0_31\include;C:\NoScan\Apps\Java\jdk1.6.0_31\include\win32;..\winpty\include;.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - <RuntimeLibrary>MultiThreaded</RuntimeLibrary> - </ClCompile> - <Link> - <SubSystem>Windows</SubSystem> - <GenerateDebugInformation>true</GenerateDebugInformation> - <EnableCOMDATFolding>true</EnableCOMDATFolding> - <OptimizeReferences>true</OptimizeReferences> - <AdditionalDependencies>DelayImp.lib;winpty.lib;%(AdditionalDependencies)</AdditionalDependencies> - <AdditionalLibraryDirectories>$(SolutionDir)$(Platform)\$(Configuration)\</AdditionalLibraryDirectories> - <DelayLoadDLLs>winpty.dll;%(DelayLoadDLLs)</DelayLoadDLLs> - </Link> - </ItemDefinitionGroup> - <ItemGroup> - <ClInclude Include="jni\include\PTY.h" /> - <ClInclude Include="jni\include\PTYInputStream.h" /> - <ClInclude Include="jni\include\PTYOutputStream.h" /> - </ItemGroup> - <ItemGroup> - <ClCompile Include="jni\src\dllmain.cpp" /> - <ClCompile Include="jni\src\pty.cpp" /> - </ItemGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> - <ImportGroup Label="ExtensionTargets"> - </ImportGroup> -</Project>
\ No newline at end of file diff --git a/core/org.eclipse.cdt.core.win32/library/pty/pty.vcxproj.filters b/core/org.eclipse.cdt.core.win32/library/pty/pty.vcxproj.filters deleted file mode 100644 index b92d3375bf7..00000000000 --- a/core/org.eclipse.cdt.core.win32/library/pty/pty.vcxproj.filters +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <ItemGroup> - <Filter Include="include"> - <UniqueIdentifier>{679c3039-d4a8-48db-9a3b-33f73f3b44c0}</UniqueIdentifier> - </Filter> - <Filter Include="src"> - <UniqueIdentifier>{b7f98685-8f42-40d2-bd2b-65bcbac17645}</UniqueIdentifier> - </Filter> - </ItemGroup> - <ItemGroup> - <ClInclude Include="jni\include\PTY.h"> - <Filter>include</Filter> - </ClInclude> - <ClInclude Include="jni\include\PTYInputStream.h"> - <Filter>include</Filter> - </ClInclude> - <ClInclude Include="jni\include\PTYOutputStream.h"> - <Filter>include</Filter> - </ClInclude> - </ItemGroup> - <ItemGroup> - <ClCompile Include="jni\src\pty.cpp"> - <Filter>src</Filter> - </ClCompile> - <ClCompile Include="jni\src\dllmain.cpp"> - <Filter>src</Filter> - </ClCompile> - </ItemGroup> -</Project>
\ No newline at end of file diff --git a/core/org.eclipse.cdt.core.win32/library/pty/winpty-agent.vcxproj b/core/org.eclipse.cdt.core.win32/library/pty/winpty-agent.vcxproj deleted file mode 100644 index 0eef37a0900..00000000000 --- a/core/org.eclipse.cdt.core.win32/library/pty/winpty-agent.vcxproj +++ /dev/null @@ -1,185 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <ItemGroup Label="ProjectConfigurations"> - <ProjectConfiguration Include="Debug|Win32"> - <Configuration>Debug</Configuration> - <Platform>Win32</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Debug|x64"> - <Configuration>Debug</Configuration> - <Platform>x64</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Release|Win32"> - <Configuration>Release</Configuration> - <Platform>Win32</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Release|x64"> - <Configuration>Release</Configuration> - <Platform>x64</Platform> - </ProjectConfiguration> - </ItemGroup> - <PropertyGroup Label="Globals"> - <ProjectGuid>{E7A42398-12E7-4BC1-B72B-5D62B71E9816}</ProjectGuid> - <Keyword>Win32Proj</Keyword> - <RootNamespace>winptyagent</RootNamespace> - </PropertyGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> - <ConfigurationType>Application</ConfigurationType> - <UseDebugLibraries>true</UseDebugLibraries> - <CharacterSet>Unicode</CharacterSet> - <PlatformToolset>Windows7.1SDK</PlatformToolset> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> - <ConfigurationType>Application</ConfigurationType> - <UseDebugLibraries>true</UseDebugLibraries> - <CharacterSet>Unicode</CharacterSet> - <PlatformToolset>Windows7.1SDK</PlatformToolset> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> - <ConfigurationType>Application</ConfigurationType> - <UseDebugLibraries>false</UseDebugLibraries> - <WholeProgramOptimization>true</WholeProgramOptimization> - <CharacterSet>Unicode</CharacterSet> - <PlatformToolset>Windows7.1SDK</PlatformToolset> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> - <ConfigurationType>Application</ConfigurationType> - <UseDebugLibraries>false</UseDebugLibraries> - <WholeProgramOptimization>true</WholeProgramOptimization> - <CharacterSet>Unicode</CharacterSet> - <PlatformToolset>Windows7.1SDK</PlatformToolset> - </PropertyGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> - <ImportGroup Label="ExtensionSettings"> - </ImportGroup> - <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - </ImportGroup> - <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - </ImportGroup> - <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - </ImportGroup> - <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - </ImportGroup> - <PropertyGroup Label="UserMacros" /> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <LinkIncremental>true</LinkIncremental> - <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir> - <IntDir>$(Platform)\$(Configuration)\$(ProjectName)\</IntDir> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> - <LinkIncremental>true</LinkIncremental> - <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir> - <IntDir>$(Platform)\$(Configuration)\$(ProjectName)\</IntDir> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <LinkIncremental>false</LinkIncremental> - <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir> - <IntDir>$(Platform)\$(Configuration)\$(ProjectName)\</IntDir> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> - <LinkIncremental>false</LinkIncremental> - <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir> - <IntDir>$(Platform)\$(Configuration)\$(ProjectName)\</IntDir> - </PropertyGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <ClCompile> - <PrecompiledHeader>NotUsing</PrecompiledHeader> - <WarningLevel>Level3</WarningLevel> - <Optimization>Disabled</Optimization> - <PreprocessorDefinitions>WIN32;_WINDOWS;NOMINMAX;_DEBUG;_CONSOLE;_SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <AdditionalIncludeDirectories>..\winpty\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> - </ClCompile> - <Link> - <SubSystem>Console</SubSystem> - <GenerateDebugInformation>true</GenerateDebugInformation> - </Link> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> - <ClCompile> - <PrecompiledHeader>NotUsing</PrecompiledHeader> - <WarningLevel>Level3</WarningLevel> - <Optimization>Disabled</Optimization> - <PreprocessorDefinitions>WIN32;_WINDOWS;NOMINMAX;_DEBUG;_CONSOLE;_SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <AdditionalIncludeDirectories>..\winpty\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> - </ClCompile> - <Link> - <SubSystem>Console</SubSystem> - <GenerateDebugInformation>true</GenerateDebugInformation> - </Link> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <ClCompile> - <WarningLevel>Level3</WarningLevel> - <PrecompiledHeader>NotUsing</PrecompiledHeader> - <Optimization>MaxSpeed</Optimization> - <FunctionLevelLinking>true</FunctionLevelLinking> - <IntrinsicFunctions>true</IntrinsicFunctions> - <PreprocessorDefinitions>WIN32;_WINDOWS;NOMINMAX;NDEBUG;_CONSOLE;_SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <AdditionalIncludeDirectories>..\winpty\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - <RuntimeLibrary>MultiThreaded</RuntimeLibrary> - </ClCompile> - <Link> - <SubSystem>Console</SubSystem> - <GenerateDebugInformation>false</GenerateDebugInformation> - <EnableCOMDATFolding>true</EnableCOMDATFolding> - <OptimizeReferences>true</OptimizeReferences> - </Link> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> - <ClCompile> - <WarningLevel>Level3</WarningLevel> - <PrecompiledHeader>NotUsing</PrecompiledHeader> - <Optimization>MaxSpeed</Optimization> - <FunctionLevelLinking>true</FunctionLevelLinking> - <IntrinsicFunctions>true</IntrinsicFunctions> - <PreprocessorDefinitions>WIN32;_WINDOWS;NOMINMAX;NDEBUG;_CONSOLE;_SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <AdditionalIncludeDirectories>..\winpty\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - <RuntimeLibrary>MultiThreaded</RuntimeLibrary> - </ClCompile> - <Link> - <SubSystem>Console</SubSystem> - <GenerateDebugInformation>false</GenerateDebugInformation> - <EnableCOMDATFolding>true</EnableCOMDATFolding> - <OptimizeReferences>true</OptimizeReferences> - </Link> - </ItemDefinitionGroup> - <ItemGroup> - <ClInclude Include="..\winpty\agent\Agent.h" /> - <ClInclude Include="..\winpty\agent\AgentAssert.h" /> - <ClInclude Include="..\winpty\agent\ConsoleInput.h" /> - <ClInclude Include="..\winpty\agent\Coord.h" /> - <ClInclude Include="..\winpty\agent\DsrSender.h" /> - <ClInclude Include="..\winpty\agent\EventLoop.h" /> - <ClInclude Include="..\winpty\agent\NamedPipe.h" /> - <ClInclude Include="..\winpty\agent\SmallRect.h" /> - <ClInclude Include="..\winpty\agent\Terminal.h" /> - <ClInclude Include="..\winpty\agent\Win32Console.h" /> - <ClInclude Include="..\winpty\shared\AgentMsg.h" /> - <ClInclude Include="..\winpty\shared\Buffer.h" /> - <ClInclude Include="..\winpty\shared\c99_snprintf.h" /> - <ClInclude Include="..\winpty\shared\DebugClient.h" /> - </ItemGroup> - <ItemGroup> - <ClCompile Include="..\winpty\agent\Agent.cc" /> - <ClCompile Include="..\winpty\agent\AgentAssert.cc" /> - <ClCompile Include="..\winpty\agent\ConsoleInput.cc" /> - <ClCompile Include="..\winpty\agent\Coord.cc" /> - <ClCompile Include="..\winpty\agent\EventLoop.cc" /> - <ClCompile Include="..\winpty\agent\main.cc" /> - <ClCompile Include="..\winpty\agent\NamedPipe.cc" /> - <ClCompile Include="..\winpty\agent\SmallRect.cc" /> - <ClCompile Include="..\winpty\agent\Terminal.cc" /> - <ClCompile Include="..\winpty\agent\Win32Console.cc" /> - <ClCompile Include="..\winpty\shared\DebugClient.cc" /> - </ItemGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> - <ImportGroup Label="ExtensionTargets"> - </ImportGroup> -</Project>
\ No newline at end of file diff --git a/core/org.eclipse.cdt.core.win32/library/pty/winpty-agent.vcxproj.filters b/core/org.eclipse.cdt.core.win32/library/pty/winpty-agent.vcxproj.filters deleted file mode 100644 index 46cdf6beaa8..00000000000 --- a/core/org.eclipse.cdt.core.win32/library/pty/winpty-agent.vcxproj.filters +++ /dev/null @@ -1,90 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <ItemGroup> - <Filter Include="agent"> - <UniqueIdentifier>{a7174beb-334f-4496-868c-348a80e5f4d8}</UniqueIdentifier> - </Filter> - <Filter Include="shared"> - <UniqueIdentifier>{0c9e153d-99b4-4f47-ba3c-57e53e1c71b7}</UniqueIdentifier> - </Filter> - </ItemGroup> - <ItemGroup> - <ClInclude Include="..\winpty\shared\AgentMsg.h"> - <Filter>shared</Filter> - </ClInclude> - <ClInclude Include="..\winpty\shared\Buffer.h"> - <Filter>shared</Filter> - </ClInclude> - <ClInclude Include="..\winpty\shared\c99_snprintf.h"> - <Filter>shared</Filter> - </ClInclude> - <ClInclude Include="..\winpty\shared\DebugClient.h"> - <Filter>shared</Filter> - </ClInclude> - <ClInclude Include="..\winpty\agent\Agent.h"> - <Filter>agent</Filter> - </ClInclude> - <ClInclude Include="..\winpty\agent\AgentAssert.h"> - <Filter>agent</Filter> - </ClInclude> - <ClInclude Include="..\winpty\agent\ConsoleInput.h"> - <Filter>agent</Filter> - </ClInclude> - <ClInclude Include="..\winpty\agent\Coord.h"> - <Filter>agent</Filter> - </ClInclude> - <ClInclude Include="..\winpty\agent\DsrSender.h"> - <Filter>agent</Filter> - </ClInclude> - <ClInclude Include="..\winpty\agent\EventLoop.h"> - <Filter>agent</Filter> - </ClInclude> - <ClInclude Include="..\winpty\agent\NamedPipe.h"> - <Filter>agent</Filter> - </ClInclude> - <ClInclude Include="..\winpty\agent\SmallRect.h"> - <Filter>agent</Filter> - </ClInclude> - <ClInclude Include="..\winpty\agent\Terminal.h"> - <Filter>agent</Filter> - </ClInclude> - <ClInclude Include="..\winpty\agent\Win32Console.h"> - <Filter>agent</Filter> - </ClInclude> - </ItemGroup> - <ItemGroup> - <ClCompile Include="..\winpty\shared\DebugClient.cc"> - <Filter>shared</Filter> - </ClCompile> - <ClCompile Include="..\winpty\agent\Agent.cc"> - <Filter>agent</Filter> - </ClCompile> - <ClCompile Include="..\winpty\agent\AgentAssert.cc"> - <Filter>agent</Filter> - </ClCompile> - <ClCompile Include="..\winpty\agent\ConsoleInput.cc"> - <Filter>agent</Filter> - </ClCompile> - <ClCompile Include="..\winpty\agent\Coord.cc"> - <Filter>agent</Filter> - </ClCompile> - <ClCompile Include="..\winpty\agent\EventLoop.cc"> - <Filter>agent</Filter> - </ClCompile> - <ClCompile Include="..\winpty\agent\main.cc"> - <Filter>agent</Filter> - </ClCompile> - <ClCompile Include="..\winpty\agent\NamedPipe.cc"> - <Filter>agent</Filter> - </ClCompile> - <ClCompile Include="..\winpty\agent\SmallRect.cc"> - <Filter>agent</Filter> - </ClCompile> - <ClCompile Include="..\winpty\agent\Terminal.cc"> - <Filter>agent</Filter> - </ClCompile> - <ClCompile Include="..\winpty\agent\Win32Console.cc"> - <Filter>agent</Filter> - </ClCompile> - </ItemGroup> -</Project>
\ No newline at end of file diff --git a/core/org.eclipse.cdt.core.win32/library/pty/winpty.vcxproj b/core/org.eclipse.cdt.core.win32/library/pty/winpty.vcxproj deleted file mode 100644 index e83366bc905..00000000000 --- a/core/org.eclipse.cdt.core.win32/library/pty/winpty.vcxproj +++ /dev/null @@ -1,167 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <ItemGroup Label="ProjectConfigurations"> - <ProjectConfiguration Include="Debug|Win32"> - <Configuration>Debug</Configuration> - <Platform>Win32</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Debug|x64"> - <Configuration>Debug</Configuration> - <Platform>x64</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Release|Win32"> - <Configuration>Release</Configuration> - <Platform>Win32</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Release|x64"> - <Configuration>Release</Configuration> - <Platform>x64</Platform> - </ProjectConfiguration> - </ItemGroup> - <PropertyGroup Label="Globals"> - <ProjectGuid>{D7BFF73A-A86A-47FF-AD2B-CC2EFCAD5ABD}</ProjectGuid> - <Keyword>Win32Proj</Keyword> - <RootNamespace>winpty</RootNamespace> - </PropertyGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> - <ConfigurationType>DynamicLibrary</ConfigurationType> - <UseDebugLibraries>true</UseDebugLibraries> - <CharacterSet>Unicode</CharacterSet> - <PlatformToolset>Windows7.1SDK</PlatformToolset> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> - <ConfigurationType>DynamicLibrary</ConfigurationType> - <UseDebugLibraries>true</UseDebugLibraries> - <CharacterSet>Unicode</CharacterSet> - <PlatformToolset>Windows7.1SDK</PlatformToolset> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> - <ConfigurationType>DynamicLibrary</ConfigurationType> - <UseDebugLibraries>false</UseDebugLibraries> - <WholeProgramOptimization>true</WholeProgramOptimization> - <CharacterSet>Unicode</CharacterSet> - <PlatformToolset>Windows7.1SDK</PlatformToolset> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> - <ConfigurationType>DynamicLibrary</ConfigurationType> - <UseDebugLibraries>false</UseDebugLibraries> - <WholeProgramOptimization>true</WholeProgramOptimization> - <CharacterSet>Unicode</CharacterSet> - <PlatformToolset>Windows7.1SDK</PlatformToolset> - </PropertyGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> - <ImportGroup Label="ExtensionSettings"> - </ImportGroup> - <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - </ImportGroup> - <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - </ImportGroup> - <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - </ImportGroup> - <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - </ImportGroup> - <PropertyGroup Label="UserMacros" /> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <LinkIncremental>true</LinkIncremental> - <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir> - <IntDir>$(Platform)\$(Configuration)\$(ProjectName)\</IntDir> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> - <LinkIncremental>true</LinkIncremental> - <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir> - <IntDir>$(Platform)\$(Configuration)\$(ProjectName)\</IntDir> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <LinkIncremental>false</LinkIncremental> - <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir> - <IntDir>$(Platform)\$(Configuration)\$(ProjectName)\</IntDir> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> - <LinkIncremental>false</LinkIncremental> - <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir> - <IntDir>$(Platform)\$(Configuration)\$(ProjectName)\</IntDir> - </PropertyGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <ClCompile> - <PrecompiledHeader>NotUsing</PrecompiledHeader> - <WarningLevel>Level3</WarningLevel> - <Optimization>Disabled</Optimization> - <PreprocessorDefinitions>WIN32;NOMINMAX;_DEBUG;_WINDOWS;_USRDLL;_SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;WINPTY;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <AdditionalIncludeDirectories>..\winpty\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> - </ClCompile> - <Link> - <SubSystem>Windows</SubSystem> - <GenerateDebugInformation>true</GenerateDebugInformation> - </Link> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> - <ClCompile> - <PrecompiledHeader>NotUsing</PrecompiledHeader> - <WarningLevel>Level3</WarningLevel> - <Optimization>Disabled</Optimization> - <PreprocessorDefinitions>WIN32;_WINDOWS;NOMINMAX;_DEBUG;_USRDLL;_SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;WINPTY;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <AdditionalIncludeDirectories>..\winpty\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> - </ClCompile> - <Link> - <SubSystem>Windows</SubSystem> - <GenerateDebugInformation>true</GenerateDebugInformation> - </Link> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <ClCompile> - <WarningLevel>Level3</WarningLevel> - <PrecompiledHeader>NotUsing</PrecompiledHeader> - <Optimization>MaxSpeed</Optimization> - <FunctionLevelLinking>true</FunctionLevelLinking> - <IntrinsicFunctions>true</IntrinsicFunctions> - <PreprocessorDefinitions>WIN32;NOMINMAX;NDEBUG;_WINDOWS;_USRDLL;_SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;WINPTY;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <AdditionalIncludeDirectories>..\winpty\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - <RuntimeLibrary>MultiThreaded</RuntimeLibrary> - </ClCompile> - <Link> - <SubSystem>Windows</SubSystem> - <GenerateDebugInformation>false</GenerateDebugInformation> - <EnableCOMDATFolding>true</EnableCOMDATFolding> - <OptimizeReferences>true</OptimizeReferences> - </Link> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> - <ClCompile> - <WarningLevel>Level3</WarningLevel> - <PrecompiledHeader>NotUsing</PrecompiledHeader> - <Optimization>MaxSpeed</Optimization> - <FunctionLevelLinking>true</FunctionLevelLinking> - <IntrinsicFunctions>true</IntrinsicFunctions> - <PreprocessorDefinitions>WIN32;_WINDOWS;NOMINMAX;NDEBUG;_USRDLL;_SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;WINPTY;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <AdditionalIncludeDirectories>..\winpty\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - <RuntimeLibrary>MultiThreaded</RuntimeLibrary> - </ClCompile> - <Link> - <SubSystem>Windows</SubSystem> - <GenerateDebugInformation>false</GenerateDebugInformation> - <EnableCOMDATFolding>true</EnableCOMDATFolding> - <OptimizeReferences>true</OptimizeReferences> - </Link> - </ItemDefinitionGroup> - <ItemGroup> - <ClInclude Include="..\winpty\include\winpty.h" /> - <ClInclude Include="..\winpty\shared\AgentMsg.h" /> - <ClInclude Include="..\winpty\shared\Buffer.h" /> - <ClInclude Include="..\winpty\shared\c99_snprintf.h" /> - <ClInclude Include="..\winpty\shared\DebugClient.h" /> - </ItemGroup> - <ItemGroup> - <ClCompile Include="..\winpty\libwinpty\winpty.cc" /> - <ClCompile Include="..\winpty\shared\DebugClient.cc" /> - </ItemGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> - <ImportGroup Label="ExtensionTargets"> - </ImportGroup> -</Project>
\ No newline at end of file diff --git a/core/org.eclipse.cdt.core.win32/library/pty/winpty.vcxproj.filters b/core/org.eclipse.cdt.core.win32/library/pty/winpty.vcxproj.filters deleted file mode 100644 index 86016e30242..00000000000 --- a/core/org.eclipse.cdt.core.win32/library/pty/winpty.vcxproj.filters +++ /dev/null @@ -1,39 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <ItemGroup> - <Filter Include="include"> - <UniqueIdentifier>{6f8f9f7f-1797-423e-9189-990b2baff405}</UniqueIdentifier> - </Filter> - <Filter Include="libwinpty"> - <UniqueIdentifier>{6fa1f334-3a7c-4a8c-970b-15c2a6a08ba2}</UniqueIdentifier> - </Filter> - <Filter Include="shared"> - <UniqueIdentifier>{84962cba-90e7-4b83-8656-6563b933bb73}</UniqueIdentifier> - </Filter> - </ItemGroup> - <ItemGroup> - <ClInclude Include="..\winpty\shared\AgentMsg.h"> - <Filter>shared</Filter> - </ClInclude> - <ClInclude Include="..\winpty\shared\Buffer.h"> - <Filter>shared</Filter> - </ClInclude> - <ClInclude Include="..\winpty\shared\c99_snprintf.h"> - <Filter>shared</Filter> - </ClInclude> - <ClInclude Include="..\winpty\shared\DebugClient.h"> - <Filter>shared</Filter> - </ClInclude> - <ClInclude Include="..\winpty\include\winpty.h"> - <Filter>include</Filter> - </ClInclude> - </ItemGroup> - <ItemGroup> - <ClCompile Include="..\winpty\shared\DebugClient.cc"> - <Filter>shared</Filter> - </ClCompile> - <ClCompile Include="..\winpty\libwinpty\winpty.cc"> - <Filter>libwinpty</Filter> - </ClCompile> - </ItemGroup> -</Project>
\ No newline at end of file diff --git a/core/org.eclipse.cdt.core.win32/library/raise.c b/core/org.eclipse.cdt.core.win32/library/raise.c deleted file mode 100644 index e34a8259d39..00000000000 --- a/core/org.eclipse.cdt.core.win32/library/raise.c +++ /dev/null @@ -1,194 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2011 QNX Software Systems 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: - * QNX Software Systems - initial API and implementation - * - * raise.c - * - * This is a part of JNI implementation of spawner - *******************************************************************************/ -#include "stdafx.h" -#include "Spawner.h" - - -#include "jni.h" - -extern void JNICALL ThrowByName(JNIEnv *env, const char *name, const char *msg); - - -static HWND consoleHWND; - - -///////////////////////////////////////////////////////////////////////////////////// -// Check if window is a console of process with pid -// Arguments: -// hwnd - window handler -// arg - process PID -// Return : TRUE if yes -///////////////////////////////////////////////////////////////////////////////////// -static BOOL CALLBACK -find_child_console (HWND hwnd, LPARAM arg) -{ - DWORD thread_id; - DWORD process_id; - DWORD pid = arg; - - thread_id = GetWindowThreadProcessId (hwnd, &process_id); - if (process_id == pid) - { - wchar_t window_class[32]; - - GetClassName (hwnd, window_class, sizeof (window_class)); - if (wcscmp (window_class, L"ConsoleWindowClass") == 0) - { - consoleHWND = hwnd; - return FALSE; - } - } - /* keep looking */ - return TRUE; -} - -// Need to declare this Win32 prototype ourselves. _WIN32_WINNT is getting -// defined to a Windows NT value, thus we don't get this. Can't assume -// we're running on XP, anyway (or can we by now?) -#if (_WIN32_WINNT < 0x0501) || defined(_MSC_VER) -typedef BOOL (WINAPI *DebugBreakProcessFunc)(HANDLE); -#endif - -///////////////////////////////////////////////////////////////////////////////////// -// Called to interrupt a process that we didn't launch (and thus does not share our -// console). Windows XP introduced the function 'DebugBreakProcess', which allows -// a process to interrupt another process even if if the two do not share a console. -// If we're running on 2000 or earlier, we have to resort to simulating a CTRL-C -// in the console by firing keyboard events. This will work only if the process -// has its own console. That means, e.g., the process should have been started at -// the cmdline with 'start myprogram.exe' instead of 'myprogram.exe'. -// -// Arguments: -// pid - process' pid -// Return : 0 if OK or error code -///////////////////////////////////////////////////////////////////////////////////// -int interruptProcess(int pid) -{ - // See if DebugBreakProcess is available (XP and beyond) - HMODULE hmod = LoadLibrary(L"Kernel32.dll"); - if (hmod != NULL) - { - BOOL success = FALSE; - FARPROC procaddr = GetProcAddress(hmod, "DebugBreakProcess"); - if (procaddr != NULL) - { - HANDLE proc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, (DWORD)pid); - if (proc != NULL) - { - DebugBreakProcessFunc pDebugBreakProcess = (DebugBreakProcessFunc)procaddr; - success = (*pDebugBreakProcess)(proc); - CloseHandle(proc); - } - } - FreeLibrary(hmod); - hmod = NULL; - - if (success) - return 0; // 0 == OK; if not, try old-school way - } - -#ifdef DEBUG_MONITOR - _TCHAR buffer[1000]; -#endif - int rc = 0; - consoleHWND = NULL; - -#ifdef DEBUG_MONITOR - _stprintf(buffer, _T("Try to interrupt process %i\n"), pid); - OutputDebugStringW(buffer); -#endif - // Find console - EnumWindows (find_child_console, (LPARAM) pid); - - if(NULL != consoleHWND) // Yes, we found out it - { - // We are going to switch focus to console, - // send Ctrl-C and then restore focus - BYTE control_scan_code = (BYTE) MapVirtualKey (VK_CONTROL, 0); - /* Fake Ctrl-C for SIGINT, and Ctrl-Break for SIGQUIT. */ - BYTE vk_c_code = 'C'; - BYTE vk_break_code = VK_CANCEL; - BYTE c_scan_code = (BYTE) MapVirtualKey (vk_c_code, 0); - BYTE break_scan_code = (BYTE) MapVirtualKey (vk_break_code, 0); - HWND foreground_window; - - - foreground_window = GetForegroundWindow (); - if (foreground_window) - { - /* NT 5.0, and apparently also Windows 98, will not allow - a Window to be set to foreground directly without the - user's involvement. The workaround is to attach - ourselves to the thread that owns the foreground - window, since that is the only thread that can set the - foreground window. */ - DWORD foreground_thread, child_thread; - foreground_thread = - GetWindowThreadProcessId (foreground_window, NULL); - if (foreground_thread == GetCurrentThreadId () - || !AttachThreadInput (GetCurrentThreadId (), - foreground_thread, TRUE)) - foreground_thread = 0; - - child_thread = GetWindowThreadProcessId (consoleHWND, NULL); - if (child_thread == GetCurrentThreadId () - || !AttachThreadInput (GetCurrentThreadId (), - child_thread, TRUE)) - child_thread = 0; - - /* Set the foreground window to the child. */ - if (SetForegroundWindow (consoleHWND)) - { - if(0 != break_scan_code) { - /* Generate keystrokes as if user had typed Ctrl-Break */ - keybd_event (VK_CONTROL, control_scan_code, 0, 0); - keybd_event (vk_break_code, break_scan_code, KEYEVENTF_EXTENDEDKEY, 0); - keybd_event (vk_break_code, break_scan_code, - KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); - keybd_event (VK_CONTROL, control_scan_code, KEYEVENTF_KEYUP, 0); - } - - /* Sleep for a bit to give time for respond */ - Sleep (100); - - SetForegroundWindow (foreground_window); - } - /* Detach from the foreground and child threads now that - the foreground switching is over. */ - if (foreground_thread) - AttachThreadInput (GetCurrentThreadId (), - foreground_thread, FALSE); - if (child_thread) - AttachThreadInput (GetCurrentThreadId (), - child_thread, FALSE); -#ifdef DEBUG_MONITOR - _stprintf(buffer, _T("Sent Ctrl-C & Ctrl-Break to process %i\n"), pid); - OutputDebugStringW(buffer); -#endif - } - } -#ifdef DEBUG_MONITOR - else { - _stprintf(buffer, _T("Cannot find console for process %i\n"), pid); - OutputDebugStringW(buffer); - } -#endif - - return rc; -} - diff --git a/core/org.eclipse.cdt.core.win32/library/setenv64.bat b/core/org.eclipse.cdt.core.win32/library/setenv64.bat deleted file mode 100644 index dfe68b7394a..00000000000 --- a/core/org.eclipse.cdt.core.win32/library/setenv64.bat +++ /dev/null @@ -1 +0,0 @@ -"C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\setenv.cmd" /x64 /2003 /Release
\ No newline at end of file diff --git a/core/org.eclipse.cdt.core.win32/library/spawner.c b/core/org.eclipse.cdt.core.win32/library/spawner.c deleted file mode 100644 index c4d52bb8a41..00000000000 --- a/core/org.eclipse.cdt.core.win32/library/spawner.c +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2007 QNX Software Systems 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: - * QNX Software Systems - initial API and implementation - * - * spawner.c - * - * This is a part of JNI implementation of spawner - *******************************************************************************/ - -#include "stdafx.h" -#include "spawner.h" - - -CRITICAL_SECTION cs; - - -wchar_t path[MAX_PATH + 1] = {_T('\0') }; // Directory where spawner.dll is located - -extern "C" -BOOL APIENTRY DllMain( HINSTANCE hModule, - DWORD ul_reason_for_call, - LPVOID lpReserved - ) -{ - switch (ul_reason_for_call) - { - case DLL_PROCESS_ATTACH: - { - wchar_t * p; - InitializeCriticalSection(&cs); - GetModuleFileNameW(hModule, path, MAX_PATH); - p = wcsrchr(path, _T('\\')); - if(NULL != p) - *(p + 1) = _T('\0'); - else - wcscat(path, L"\\"); - } - break; - case DLL_THREAD_ATTACH: - case DLL_THREAD_DETACH: - break; - case DLL_PROCESS_DETACH: - DeleteCriticalSection(&cs); - break; - } - return TRUE; -} - diff --git a/core/org.eclipse.cdt.core.win32/library/starter/Makefile b/core/org.eclipse.cdt.core.win32/library/starter/Makefile deleted file mode 100644 index 54c92c5b829..00000000000 --- a/core/org.eclipse.cdt.core.win32/library/starter/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -OS = win32 -ARCH = x86 - -TARGET = $(INSTALL_DIR)/starter.exe - -OBJS = starter.o - -LIBS = -lpsapi - -CXX = g++ -CXXFLAGS = -DUNICODE - -INSTALL_DIR = ../../../org.eclipse.cdt.core.$(OS).$(ARCH)/os/$(OS)/$(ARCH) - -all: $(TARGET) - -rebuild: clean all - -clean : - $(RM) $(OBJS) - -$(TARGET) : $(OBJS) - $(CXX) -o $(TARGET) $(OBJS) $(LIBS) diff --git a/core/org.eclipse.cdt.core.win32/library/starter/starter.cpp b/core/org.eclipse.cdt.core.win32/library/starter/starter.cpp deleted file mode 100644 index 30dfe2f078b..00000000000 --- a/core/org.eclipse.cdt.core.win32/library/starter/starter.cpp +++ /dev/null @@ -1,526 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2015 QNX Software Systems 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: - * QNX Software Systems - initial API and implementation - * Wind River Systems, Inc. - * - * starter.cpp - * - * This is a small utility for windows spawner - *******************************************************************************/ - -#define STRICT -#define _WIN32_WINNT 0x0500 -#include <windows.h> -#include <process.h> -#include <tchar.h> -#include <stdio.h> -#include <psapi.h> - -//#define DEBUG_MONITOR -#define MAX_CMD_LINE_LENGTH (2049) -#define PIPE_NAME_LENGTH 100 - -int copyTo(wchar_t * target, const wchar_t * source, int cpyLength, - int availSpace); -void DisplayErrorMessage(); - -//BOOL KillProcessEx(DWORD dwProcessId); // Handle of the process - -/////////////////////////////////////////////////////////////////////////////// -BOOL WINAPI HandlerRoutine( DWORD dwCtrlType) // control signal type -{ - BOOL ret = TRUE; - switch(dwCtrlType) - { - case CTRL_C_EVENT: - break; - case CTRL_BREAK_EVENT: - break; - case CTRL_CLOSE_EVENT: - ret = FALSE; - break; - case CTRL_LOGOFF_EVENT: - ret = FALSE; - break; - case CTRL_SHUTDOWN_EVENT: - ret = FALSE; - break; - default: - break; - } - return ret; -} - -// The default here means we haven't checked yet -// i.e. cygwin is true but the bin dir hasn't been captured -wchar_t * cygwinBin = NULL; -bool _isCygwin = true; - -bool isCygwin(HANDLE process) { - // Have we checked before? - if (cygwinBin != NULL || !_isCygwin) - return _isCygwin; - - // See if this process loaded cygwin, need a different SIGINT for them - HMODULE mods[1024]; - DWORD needed; - if (EnumProcessModules(process, mods, sizeof(mods), &needed)) { - int i; - needed /= sizeof(HMODULE); - for (i = 0; i < needed; ++i ) { - wchar_t modName[MAX_PATH]; - if (GetModuleFileNameEx(process, mods[i], modName, MAX_PATH)) { - wchar_t * p = wcsrchr(modName, L'\\'); - if (p) { - *p = 0; // Null terminate there for future reference - if (!wcscmp(++p, L"cygwin1.dll")) { - _isCygwin = true; - // Store away the bind dir - cygwinBin = wcsdup(modName); - return _isCygwin; - } - } - } - } - } - - _isCygwin = false; - return _isCygwin; -} - -bool runCygwinCommand(wchar_t * command) { - wchar_t cygcmd[1024]; - swprintf(cygcmd, L"%s\\%s", cygwinBin, command); - - STARTUPINFO si; - ZeroMemory(&si, sizeof(si)); - si.cb = sizeof(si); - PROCESS_INFORMATION pi; - ZeroMemory(&pi, sizeof(pi)); - if (CreateProcess(NULL, cygcmd, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) { - WaitForSingleObject(pi.hProcess, INFINITE); - CloseHandle(pi.hThread); - CloseHandle(pi.hProcess); - return true; - } else if (CreateProcess(NULL, command, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) { - WaitForSingleObject(pi.hProcess, INFINITE); - CloseHandle(pi.hThread); - CloseHandle(pi.hProcess); - return true; - } - return false; -} - -void ensureSize(wchar_t** ptr, int* psize, int requiredLength) { - int size= *psize; - if (requiredLength > size) { - size= 2*size; - if (size < requiredLength) { - size= requiredLength; - } - *ptr= (wchar_t *)realloc(*ptr, size * sizeof(wchar_t)); - if (NULL == *ptr) { - *psize= 0; - } else { - *psize= size; - } - } -} - -int main() { - - int argc; - wchar_t ** argv = CommandLineToArgvW(GetCommandLine(), &argc); - - // Make sure that we've been passed the right number of arguments - if (argc < 8) { - _tprintf(_T("Usage: %s (four inheritable event handles) (CommandLineToSpawn)\n"), - argv[0]); - return(0); - } - - // Construct the full command line - int nCmdLineLength= MAX_CMD_LINE_LENGTH; - wchar_t * szCmdLine= (wchar_t *)malloc(nCmdLineLength * sizeof(wchar_t)); - szCmdLine[0]= 0; - int nPos = 0; - - for(int i = 8; i < argc; ++i) - { - int nCpyLen; - int len= wcslen(argv[i]); - int requiredSize= nPos+len+2; - if (requiredSize > 32*1024) { -#ifdef DEBUG_MONITOR - OutputDebugStringW(_T("Command line too long!\n")); -#endif - return 0; - } - ensureSize(&szCmdLine, &nCmdLineLength, requiredSize); - if (NULL == szCmdLine) { -#ifdef DEBUG_MONITOR - OutputDebugStringW(_T("Not enough memory to build cmd line!\n")); -#endif - return 0; - } - if(0 > (nCpyLen = copyTo(szCmdLine + nPos, argv[i], len, nCmdLineLength - nPos))) - { -#ifdef DEBUG_MONITOR - OutputDebugStringW(_T("Not enough space to build command line\n")); -#endif - return 0; - } - nPos += nCpyLen; - szCmdLine[nPos] = _T(' '); - ++nPos; - } - szCmdLine[nPos] = _T('\0'); - - STARTUPINFOW si = {sizeof(si)}; - PROCESS_INFORMATION pi = {0}; - DWORD dwExitCode = 0; -#ifdef DEBUG_MONITOR - int currentPID = GetCurrentProcessId(); - wchar_t buffer[MAX_CMD_LINE_LENGTH]; -#endif - - BOOL exitProc = FALSE; - HANDLE waitEvent = OpenEventW(EVENT_ALL_ACCESS, TRUE, argv[4]); - HANDLE h[5]; - h[0] = OpenEventW(EVENT_ALL_ACCESS, TRUE, argv[3]); // simulated SIGINT (CTRL-C or Cygwin 'kill -SIGINT') -// h[1] we reserve for the process handle - h[2] = OpenEventW(EVENT_ALL_ACCESS, TRUE, argv[5]); // simulated SIGTERM - h[3] = OpenEventW(EVENT_ALL_ACCESS, TRUE, argv[6]); // simulated SIGKILL - h[4] = OpenEventW(EVENT_ALL_ACCESS, TRUE, argv[7]); // CTRL-C, in all cases - - SetConsoleCtrlHandler(HandlerRoutine, TRUE); - - int parentPid = wcstol(argv[1], NULL, 10); - int nCounter = wcstol(argv[2], NULL, 10); - wchar_t inPipeName[PIPE_NAME_LENGTH]; - wchar_t outPipeName[PIPE_NAME_LENGTH]; - wchar_t errPipeName[PIPE_NAME_LENGTH]; - - swprintf(inPipeName, L"\\\\.\\pipe\\stdin%08i%010i", parentPid, nCounter); - swprintf(outPipeName, L"\\\\.\\pipe\\stdout%08i%010i", parentPid, nCounter); - swprintf(errPipeName, L"\\\\.\\pipe\\stderr%08i%010i", parentPid, nCounter); -#ifdef DEBUG_MONITOR - swprintf(buffer, _T("Pipes: %s, %s, %s\n"), inPipeName, outPipeName, errPipeName); - OutputDebugStringW(buffer); -#endif - - HANDLE stdHandles[3]; - - SECURITY_ATTRIBUTES sa; - sa.nLength = sizeof(SECURITY_ATTRIBUTES); - sa.bInheritHandle = TRUE; - sa.lpSecurityDescriptor = NULL; - - if((INVALID_HANDLE_VALUE == (stdHandles[0] = CreateFileW(inPipeName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, &sa))) || - (INVALID_HANDLE_VALUE == (stdHandles[1] = CreateFileW(outPipeName, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, &sa))) || - (INVALID_HANDLE_VALUE == (stdHandles[2] = CreateFileW(errPipeName, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, &sa)))) - { -#ifdef DEBUG_MONITOR - swprintf(buffer, _T("Failed to open pipe %i, %i, %i: %i\n"), stdHandles[0], stdHandles[1], stdHandles[2], GetLastError()); - OutputDebugStringW(buffer); -#endif - CloseHandle(stdHandles[0]); - CloseHandle(stdHandles[1]); - CloseHandle(stdHandles[2]); - return -1;; - } - SetHandleInformation(stdHandles[0], HANDLE_FLAG_INHERIT, TRUE); - SetHandleInformation(stdHandles[1], HANDLE_FLAG_INHERIT, TRUE); - SetHandleInformation(stdHandles[2], HANDLE_FLAG_INHERIT, TRUE); - - if(!SetStdHandle(STD_INPUT_HANDLE, stdHandles[0]) || - !SetStdHandle(STD_OUTPUT_HANDLE, stdHandles[1]) || - !SetStdHandle(STD_ERROR_HANDLE, stdHandles[2])) { -#ifdef DEBUG_MONITOR - swprintf(buffer, _T("Failed to reassign standard streams: %i\n"), GetLastError()); - OutputDebugStringW(buffer); -#endif - CloseHandle(stdHandles[0]); - CloseHandle(stdHandles[1]); - CloseHandle(stdHandles[2]); - return -1;; - } - -#ifdef DEBUG_MONITOR_DETAILS - wchar_t * lpvEnv = GetEnvironmentStringsW(); - - // If the returned pointer is NULL, exit. - if (lpvEnv == NULL) - OutputDebugStringW(_T("Cannot Read Environment\n")); - else { - // Variable strings are separated by NULL byte, and the block is - // terminated by a NULL byte. - - OutputDebugStringW(_T("Starter: Environment\n")); - for (wchar_t * lpszVariable = (wchar_t *) lpvEnv; *lpszVariable; lpszVariable+=wcslen(lpszVariable) + 1) { - swprintf(buffer, _T("%s\n"), lpszVariable); - OutputDebugStringW(buffer); - } - - FreeEnvironmentStringsW(lpvEnv); - } -#endif -#ifdef DEBUG_MONITOR - swprintf(buffer, _T("Starting: %s\n"), szCmdLine); - OutputDebugStringW(buffer); -#endif - // Create job object - HANDLE hJob = CreateJobObject(NULL, NULL); - if (hJob != NULL) { - // Configure job to - // - terminate all associated processes when the last handle to it is closed - // - allow child processes to break away from the job. - JOBOBJECT_EXTENDED_LIMIT_INFORMATION jobInfo; - ZeroMemory(&jobInfo, sizeof(jobInfo)); - jobInfo.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE | JOB_OBJECT_LIMIT_BREAKAWAY_OK; - if (!SetInformationJobObject(hJob, JobObjectExtendedLimitInformation, &jobInfo, sizeof(jobInfo))) { -#ifdef DEBUG_MONITOR - OutputDebugStringW(_T("Cannot set job information\n")); - DisplayErrorMessage(); -#endif - } - } else { -#ifdef DEBUG_MONITOR - OutputDebugStringW(_T("Cannot create job object\n")); - DisplayErrorMessage(); -#endif - } - // Spawn the other processes as part of this Process Group - // If this process is already part of a job, the flag CREATE_BREAKAWAY_FROM_JOB - // makes the child process detach from the job, such that we can assign it - // to our own job object. - BOOL f = CreateProcessW(NULL, szCmdLine, NULL, NULL, TRUE, - CREATE_BREAKAWAY_FROM_JOB, NULL, NULL, &si, &pi); - // If breaking away from job is not permitted, retry without breakaway flag - if (!f) - f = CreateProcessW(NULL, szCmdLine, NULL, NULL, TRUE, - 0, NULL, NULL, &si, &pi); - - // We don't need them any more - CloseHandle(stdHandles[0]); - CloseHandle(stdHandles[1]); - CloseHandle(stdHandles[2]); - - if (f) { -#ifdef DEBUG_MONITOR - swprintf(buffer, _T("Process %i started\n"), pi.dwProcessId); - OutputDebugStringW(buffer); -#endif - SetEvent(waitEvent); // Means that process has been spawned - CloseHandle(pi.hThread); - h[1] = pi.hProcess; - - if(NULL != hJob) { - if(!AssignProcessToJobObject(hJob, pi.hProcess)) { -#ifdef DEBUG_MONITOR - swprintf(buffer, _T("Cannot assign process %i to a job\n"), pi.dwProcessId); - OutputDebugStringW(buffer); - DisplayErrorMessage(); -#endif - } - } - - while(!exitProc) - { - // Wait for the spawned-process to die or for the event - // indicating that the processes should be forcibly killed. - DWORD event = WaitForMultipleObjects(5, h, FALSE, INFINITE); - switch (event) - { - case WAIT_OBJECT_0 + 0: // SIGINT - case WAIT_OBJECT_0 + 4: // CTRL-C -#ifdef DEBUG_MONITOR - swprintf(buffer, _T("starter (PID %i) received CTRL-C event\n"), currentPID); - OutputDebugStringW(buffer); -#endif - if ((event == (WAIT_OBJECT_0 + 0)) && isCygwin(h[1])) { - // Need to issue a kill command - wchar_t kill[1024]; - swprintf(kill, L"kill -SIGINT %d", pi.dwProcessId); - if (!runCygwinCommand(kill)) { - // fall back to console event - GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0); - } - } else { - GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0); - } - - SetEvent(waitEvent); - break; - - case WAIT_OBJECT_0 + 1: // App terminated normally - // Make it's exit code our exit code -#ifdef DEBUG_MONITOR - swprintf(buffer, _T("starter: launched process has been terminated(PID %i)\n"), - pi.dwProcessId); - OutputDebugStringW(buffer); -#endif - GetExitCodeProcess(pi.hProcess, &dwExitCode); - exitProc = TRUE; - break; - - // Terminate and Kill behavior differ only for cygwin processes, where - // we use the cygwin 'kill' command. We send a SIGKILL in one case, - // SIGTERM in the other. For non-cygwin processes, both requests - // are treated exactly the same - case WAIT_OBJECT_0 + 2: // TERM - case WAIT_OBJECT_0 + 3: // KILL - { - const wchar_t* signal = (event == WAIT_OBJECT_0 + 2) ? L"TERM" : L"KILL"; -#ifdef DEBUG_MONITOR - swprintf(buffer, _T("starter received %s event (PID %i)\n"), signal, currentPID); - OutputDebugStringW(buffer); -#endif - if (isCygwin(h[1])) { - // Need to issue a kill command - wchar_t kill[1024]; - swprintf(kill, L"kill -%s %d", signal, pi.dwProcessId); - if (!runCygwinCommand(kill)) { - // fall back to console event - GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0); - } - } else { - GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0); - } - - SetEvent(waitEvent); - - if(NULL != hJob) { - if(!TerminateJobObject(hJob, (DWORD)-1)) { -#ifdef DEBUG_MONITOR - OutputDebugStringW(_T("Cannot terminate job\n")); - DisplayErrorMessage(); -#endif - } - } - - // Note that we keep trucking until the child process terminates (case WAIT_OBJECT_0 + 1) - break; - } - - default: - // Unexpected code -#ifdef DEBUG_MONITOR - DisplayErrorMessage(); -#endif - exitProc = TRUE; - break; - } - - } - } else { -#ifdef DEBUG_MONITOR - swprintf(buffer, _T("Cannot start: %s\n"), szCmdLine); - OutputDebugStringW(buffer); - - DisplayErrorMessage(); -#endif - } - - if (NULL != szCmdLine) - { - free(szCmdLine); - } - - CloseHandle(waitEvent); - CloseHandle(h[0]); - CloseHandle(h[1]); - CloseHandle(h[2]); - CloseHandle(h[3]); - CloseHandle(h[4]); - - return(dwExitCode); -} - -///////////////////////////////////////////////////////////////////////////////////// -// Use this utility program to process correctly quotation marks in the command line -// Arguments: -// target - string to copy to -// source - string to copy from -// cpyLength - copy length -// availSpace - size of the target buffer -// Return :number of bytes used in target, or -1 in case of error -///////////////////////////////////////////////////////////////////////////////////// -int copyTo(wchar_t * target, const wchar_t * source, int cpyLength, - int availSpace) { - BOOL bSlash = FALSE; - int i = 0, j = 0; - int totCpyLength = cpyLength; - -#define QUOTATION_DO 0 -#define QUOTATION_DONE 1 -#define QUOTATION_NONE 2 - - int nQuotationMode = 0; - if (availSpace <= cpyLength) // = to reserve space for '\0' - return -1; - - if ((_T('\"') == *source) && (_T('\"') == *(source + cpyLength - 1))) { - // Already done - nQuotationMode = QUOTATION_DONE; - } else if (wcschr(source, _T(' '))== NULL) { - // No reason to quotate term becase it doesn't have embedded spaces - nQuotationMode = QUOTATION_NONE; - } else { - // Needs to be quotated - nQuotationMode = QUOTATION_DO; - *target = _T('\"'); - ++j; - } - - for (; i < cpyLength; ++i, ++j) { - if (source[i] == _T('\\')) - bSlash = TRUE; - else - // Don't escape embracing quotation marks - if ((source[i] == _T('\"')) && !((nQuotationMode == QUOTATION_DONE) && ((i == 0) || (i == (cpyLength - 1))) )) { - if (!bSlash) { - if (j == availSpace) - return -1; - target[j] = _T('\\'); - ++j; - } - bSlash = FALSE; - } else - bSlash = FALSE; - - if (j == availSpace) - return -1; - target[j] = source[i]; - } - - if (nQuotationMode == QUOTATION_DO) { - if (j == availSpace) - return -1; - target[j] = _T('\"'); - ++j; - } - return j; -} - -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); - OutputDebugStringW(lpMsgBuf); - // Free the buffer. - LocalFree(lpMsgBuf); -} - -//////////////////////////////// End of File ////////////////////////////////// diff --git a/core/org.eclipse.cdt.core.win32/plugin.properties b/core/org.eclipse.cdt.core.win32/plugin.properties index 9dec4fd06a0..1e0fb54479d 100644 --- a/core/org.eclipse.cdt.core.win32/plugin.properties +++ b/core/org.eclipse.cdt.core.win32/plugin.properties @@ -1,2 +1,2 @@ -fragmentName.linux=C/C++ Development Tools Core for Windows +fragmentName.win32=C/C++ Development Tools Core for Windows providerName=Eclipse CDT diff --git a/core/org.eclipse.cdt.core.win32/pom.xml b/core/org.eclipse.cdt.core.win32/pom.xml index ea1183095c0..2ed280caae1 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,11 +17,11 @@ <parent> <groupId>org.eclipse.cdt</groupId> <artifactId>cdt-parent</artifactId> - <version>10.0.0-SNAPSHOT</version> + <version>10.7.0-SNAPSHOT</version> <relativePath>../../pom.xml</relativePath> </parent> - <version>6.0.0-SNAPSHOT</version> + <version>6.0.300-SNAPSHOT</version> <artifactId>org.eclipse.cdt.core.win32</artifactId> <packaging>eclipse-plugin</packaging> diff --git a/core/org.eclipse.cdt.core.win32/src/org/eclipse/cdt/internal/core/win32/ProcessList.java b/core/org.eclipse.cdt.core.win32/src/org/eclipse/cdt/internal/core/win32/ProcessList.java index ba3af06c6c2..4810f09c248 100644 --- a/core/org.eclipse.cdt.core.win32/src/org/eclipse/cdt/internal/core/win32/ProcessList.java +++ b/core/org.eclipse.cdt.core.win32/src/org/eclipse/cdt/internal/core/win32/ProcessList.java @@ -15,79 +15,16 @@ package org.eclipse.cdt.internal.core.win32; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import org.eclipse.cdt.core.IProcessInfo; import org.eclipse.cdt.core.IProcessList; -import com.sun.jna.Native; -import com.sun.jna.platform.win32.Kernel32; +import com.sun.jna.platform.win32.Kernel32Util; +import com.sun.jna.platform.win32.PsapiUtil; import com.sun.jna.platform.win32.Win32Exception; -import com.sun.jna.platform.win32.WinDef.DWORD; -import com.sun.jna.platform.win32.WinNT; -import com.sun.jna.platform.win32.WinNT.HANDLE; -import com.sun.jna.ptr.IntByReference; -import com.sun.jna.win32.W32APIOptions; public class ProcessList implements IProcessList { - // TODO: Remove this inner class when JNA 5.6 is available - private static abstract class PsapiUtil { - public interface Psapi extends com.sun.jna.platform.win32.Psapi { - Psapi INSTANCE = Native.loadLibrary("psapi", Psapi.class, W32APIOptions.DEFAULT_OPTIONS); //$NON-NLS-1$ - - boolean EnumProcesses(int[] lpidProcess, int cb, IntByReference lpcbNeeded); - } - - public static int[] enumProcesses() { - int size = 0; - int[] lpidProcess = null; - IntByReference lpcbNeeded = new IntByReference(); - do { - size += 1024; - lpidProcess = new int[size]; - if (!Psapi.INSTANCE.EnumProcesses(lpidProcess, size * DWORD.SIZE, lpcbNeeded)) { - throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); - } - } while (size == lpcbNeeded.getValue() / DWORD.SIZE); - - return Arrays.copyOf(lpidProcess, lpcbNeeded.getValue() / DWORD.SIZE); - } - } - - // TODO: Remove this inner class when JNA 5.6 is available - private static abstract class Kernel32Util extends com.sun.jna.platform.win32.Kernel32Util { - public static final String QueryFullProcessImageName(int pid, int dwFlags) { - HANDLE hProcess = null; - Win32Exception we = null; - - try { - hProcess = Kernel32.INSTANCE.OpenProcess(WinNT.PROCESS_QUERY_INFORMATION | WinNT.PROCESS_VM_READ, false, - pid); - if (hProcess == null) { - throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); - } - return QueryFullProcessImageName(hProcess, dwFlags); - } catch (Win32Exception e) { - we = e; - throw we; // re-throw to invoke finally block - } finally { - try { - closeHandle(hProcess); - } catch (Win32Exception e) { - if (we == null) { - we = e; - } else { - we.addSuppressed(e); - } - } - if (we != null) { - throw we; - } - } - } - } - private IProcessInfo[] NOPROCESS = new IProcessInfo[0]; @Override diff --git a/core/org.eclipse.cdt.core.win32/src/org/eclipse/cdt/internal/core/win32/WindowsRegistryImpl.java b/core/org.eclipse.cdt.core.win32/src/org/eclipse/cdt/internal/core/win32/WindowsRegistryImpl.java index dcb48a8fc7b..c54dd22ccd0 100644 --- a/core/org.eclipse.cdt.core.win32/src/org/eclipse/cdt/internal/core/win32/WindowsRegistryImpl.java +++ b/core/org.eclipse.cdt.core.win32/src/org/eclipse/cdt/internal/core/win32/WindowsRegistryImpl.java @@ -13,10 +13,15 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.win32; +import java.util.Collections; +import java.util.Map; + import org.eclipse.cdt.internal.core.natives.CNativePlugin; import org.eclipse.cdt.utils.WindowsRegistry; +import org.eclipse.core.runtime.Platform; import com.sun.jna.Native; +import com.sun.jna.Pointer; import com.sun.jna.platform.win32.Advapi32; import com.sun.jna.platform.win32.Advapi32Util; import com.sun.jna.platform.win32.Advapi32Util.EnumKey; @@ -33,12 +38,19 @@ import com.sun.jna.ptr.IntByReference; */ public class WindowsRegistryImpl extends WindowsRegistry { + private final static boolean DEBUG = Platform.getDebugBoolean(CNativePlugin.PLUGIN_ID + "/debug/win32/registry"); //$NON-NLS-1$ + @Override public String getLocalMachineValue(String subkey, String name) { return getValue(WinReg.HKEY_LOCAL_MACHINE, subkey, name); } @Override + public Map<String, Object> getLocalMachineValues(String subkey) { + return getValues(WinReg.HKEY_LOCAL_MACHINE, subkey); + } + + @Override public String getLocalMachineValueName(String subkey, int index) { return getValueName(WinReg.HKEY_LOCAL_MACHINE, subkey, index); } @@ -54,6 +66,11 @@ public class WindowsRegistryImpl extends WindowsRegistry { } @Override + public Map<String, Object> getCurrentUserValues(String subkey) { + return getValues(WinReg.HKEY_CURRENT_USER, subkey); + } + + @Override public String getCurrentUserValueName(String subkey, int index) { return getValueName(WinReg.HKEY_CURRENT_USER, subkey, index); } @@ -67,7 +84,9 @@ public class WindowsRegistryImpl extends WindowsRegistry { try { return Advapi32Util.registryGetStringValue(key, subkey, name); } catch (Win32Exception e) { - CNativePlugin.log(String.format("Unable to get value for %s in %s", name, subkey), e); //$NON-NLS-1$ + if (DEBUG) { + CNativePlugin.log(String.format("Unable to get value for %s in %s", name, subkey), e); //$NON-NLS-1$ + } return null; } } @@ -82,7 +101,9 @@ public class WindowsRegistryImpl extends WindowsRegistry { Advapi32Util.registryCloseKey(phkKey.getValue()); } } catch (Win32Exception e) { - CNativePlugin.log(String.format("Unable to get keyname for %s at index %d", subkey, index), e); //$NON-NLS-1$ + if (DEBUG) { + CNativePlugin.log(String.format("Unable to get keyname for %s at index %d", subkey, index), e); //$NON-NLS-1$ + } return null; } } @@ -94,7 +115,7 @@ public class WindowsRegistryImpl extends WindowsRegistry { char[] lpValueName = new char[Advapi32.MAX_KEY_LENGTH]; IntByReference lpcchValueName = new IntByReference(Advapi32.MAX_KEY_LENGTH); int rc = Advapi32.INSTANCE.RegEnumValue(phkKey.getValue(), index, lpValueName, lpcchValueName, null, - null, null, null); + null, (Pointer) null, null); if (rc != W32Errors.ERROR_SUCCESS) { throw new Win32Exception(rc); @@ -105,8 +126,21 @@ public class WindowsRegistryImpl extends WindowsRegistry { Advapi32Util.registryCloseKey(phkKey.getValue()); } } catch (Win32Exception e) { - CNativePlugin.log(String.format("Unable to get valuename for %s at index %d", subkey, index), e); //$NON-NLS-1$ + if (DEBUG) { + CNativePlugin.log(String.format("Unable to get valuename for %s at index %d", subkey, index), e); //$NON-NLS-1$ + } return null; } } + + private Map<String, Object> getValues(HKEY key, String subkey) { + try { + return Advapi32Util.registryGetValues(key, subkey); + } catch (Win32Exception e) { + if (DEBUG) { + CNativePlugin.log(String.format("Unable to get values for %s", subkey), e); //$NON-NLS-1$ + } + return Collections.emptyMap(); + } + } } diff --git a/core/org.eclipse.cdt.core/.classpath b/core/org.eclipse.cdt.core/.classpath index af08a45ddfb..2d596d6e9c6 100644 --- a/core/org.eclipse.cdt.core/.classpath +++ b/core/org.eclipse.cdt.core/.classpath @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="src" path="model"/> <classpathentry kind="src" path="browser"/> diff --git a/core/org.eclipse.cdt.core/.settings/.api_filters b/core/org.eclipse.cdt.core/.settings/.api_filters new file mode 100644 index 00000000000..a05364d729a --- /dev/null +++ b/core/org.eclipse.cdt.core/.settings/.api_filters @@ -0,0 +1,239 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<component id="org.eclipse.cdt.core" version="2"> + <resource path="browser/org/eclipse/cdt/core/browser/IndexTypeInfo.java" type="org.eclipse.cdt.core.browser.IndexTypeInfo"> + <filter comment="Squash over zealous warning from PDE. See Bug 558477" id="576725006"> + <message_arguments> + <message_argument value="IFunctionInfo"/> + <message_argument value="IndexTypeInfo"/> + </message_arguments> + </filter> + <filter comment="Squash over zealous warning from PDE. See Bug 558477" id="576725006"> + <message_arguments> + <message_argument value="ITypeInfo"/> + <message_argument value="IndexTypeInfo"/> + </message_arguments> + </filter> + </resource> + <resource path="browser/org/eclipse/cdt/core/browser/QualifiedTypeName.java" type="org.eclipse.cdt.core.browser.QualifiedTypeName"> + <filter comment="Squash over zealous warning from PDE. See Bug 558477" id="576725006"> + <message_arguments> + <message_argument value="IQualifiedTypeName"/> + <message_argument value="QualifiedTypeName"/> + </message_arguments> + </filter> + </resource> + <resource path="browser/org/eclipse/cdt/core/browser/TypeInfo.java" type="org.eclipse.cdt.core.browser.TypeInfo"> + <filter comment="Squash over zealous warning from PDE. See Bug 558477" id="576725006"> + <message_arguments> + <message_argument value="ITypeInfo"/> + <message_argument value="TypeInfo"/> + </message_arguments> + </filter> + </resource> + <resource path="browser/org/eclipse/cdt/core/browser/TypeReference.java" type="org.eclipse.cdt.core.browser.TypeReference"> + <filter comment="Squash over zealous warning from PDE. See Bug 558477" id="576725006"> + <message_arguments> + <message_argument value="ITypeReference"/> + <message_argument value="TypeReference"/> + </message_arguments> + </filter> + </resource> + <resource path="browser/org/eclipse/cdt/core/browser/TypeSearchScope.java" type="org.eclipse.cdt.core.browser.TypeSearchScope"> + <filter comment="Squash over zealous warning from PDE. See Bug 558477" id="576725006"> + <message_arguments> + <message_argument value="ITypeSearchScope"/> + <message_argument value="TypeSearchScope"/> + </message_arguments> + </filter> + </resource> + <resource path="model/org/eclipse/cdt/core/model/AbstractLanguage.java" type="org.eclipse.cdt.core.model.AbstractLanguage"> + <filter comment="Squash over zealous warning from PDE. See Bug 558477" id="576725006"> + <message_arguments> + <message_argument value="ILanguage"/> + <message_argument value="AbstractLanguage"/> + </message_arguments> + </filter> + </resource> + <resource path="model/org/eclipse/cdt/core/model/LanguageMappingChangeEvent.java" type="org.eclipse.cdt.core.model.LanguageMappingChangeEvent"> + <filter comment="Squash over zealous warning from PDE. See Bug 558477" id="576725006"> + <message_arguments> + <message_argument value="ILanguageMappingChangeEvent"/> + <message_argument value="LanguageMappingChangeEvent"/> + </message_arguments> + </filter> + </resource> + <resource path="model/org/eclipse/cdt/core/settings/model/ACSettingEntry.java" type="org.eclipse.cdt.core.settings.model.ACSettingEntry"> + <filter comment="Squash over zealous warning from PDE. See Bug 558477" id="576725006"> + <message_arguments> + <message_argument value="ICSettingEntry"/> + <message_argument value="ACSettingEntry"/> + </message_arguments> + </filter> + </resource> + <resource path="model/org/eclipse/cdt/core/settings/model/util/XmlStorageElement.java" type="org.eclipse.cdt.core.settings.model.util.XmlStorageElement"> + <filter comment="Squash over zealous warning from PDE. See Bug 558477" id="576725006"> + <message_arguments> + <message_argument value="ICStorageElement"/> + <message_argument value="XmlStorageElement"/> + </message_arguments> + </filter> + </resource> + <resource path="parser/org/eclipse/cdt/core/dom/ast/ASTCompletionNode.java" type="org.eclipse.cdt.core.dom.ast.ASTCompletionNode"> + <filter comment="Squash over zealous warning from PDE. See Bug 558477" id="576725006"> + <message_arguments> + <message_argument value="IASTCompletionNode"/> + <message_argument value="ASTCompletionNode"/> + </message_arguments> + </filter> + </resource> + <resource path="parser/org/eclipse/cdt/core/dom/parser/AbstractScannerExtensionConfiguration.java" type="org.eclipse.cdt.core.dom.parser.AbstractScannerExtensionConfiguration"> + <filter comment="Squash over zealous warning from PDE. See Bug 558477" id="576725006"> + <message_arguments> + <message_argument value="IScannerExtensionConfiguration"/> + <message_argument value="AbstractScannerExtensionConfiguration"/> + </message_arguments> + </filter> + </resource> + <resource path="parser/org/eclipse/cdt/core/dom/parser/c/AbstractCParserExtensionConfiguration.java" type="org.eclipse.cdt.core.dom.parser.c.AbstractCParserExtensionConfiguration"> + <filter comment="Squash over zealous warning from PDE. See Bug 558477" id="576725006"> + <message_arguments> + <message_argument value="ICParserExtensionConfiguration"/> + <message_argument value="AbstractCParserExtensionConfiguration"/> + </message_arguments> + </filter> + </resource> + <resource path="parser/org/eclipse/cdt/core/dom/parser/cpp/AbstractCPPParserExtensionConfiguration.java" type="org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration"> + <filter comment="Squash over zealous warning from PDE. See Bug 558477" id="576725006"> + <message_arguments> + <message_argument value="ICPPParserExtensionConfiguration"/> + <message_argument value="AbstractCPPParserExtensionConfiguration"/> + </message_arguments> + </filter> + </resource> + <resource path="parser/org/eclipse/cdt/core/index/IPDOMASTProcessor.java" type="org.eclipse.cdt.core.index.IPDOMASTProcessor$Abstract"> + <filter comment="Squash over zealous warning from PDE. See Bug 558477" id="576725006"> + <message_arguments> + <message_argument value="IPDOMASTProcessor"/> + <message_argument value="Abstract"/> + </message_arguments> + </filter> + </resource> + <resource path="parser/org/eclipse/cdt/core/index/ResourceContainerRelativeLocationConverter.java" type="org.eclipse.cdt.core.index.ResourceContainerRelativeLocationConverter"> + <filter comment="Squash over zealous warning from PDE. See Bug 558477" id="576725006"> + <message_arguments> + <message_argument value="IIndexLocationConverter"/> + <message_argument value="ResourceContainerRelativeLocationConverter"/> + </message_arguments> + </filter> + </resource> + <resource path="parser/org/eclipse/cdt/core/index/URIRelativeLocationConverter.java" type="org.eclipse.cdt.core.index.URIRelativeLocationConverter"> + <filter comment="Squash over zealous warning from PDE. See Bug 558477" id="576725006"> + <message_arguments> + <message_argument value="IIndexLocationConverter"/> + <message_argument value="URIRelativeLocationConverter"/> + </message_arguments> + </filter> + </resource> + <resource path="parser/org/eclipse/cdt/core/index/export/AbstractExportProjectProvider.java" type="org.eclipse.cdt.core.index.export.AbstractExportProjectProvider"> + <filter comment="Squash over zealous warning from PDE. See Bug 558477" id="576725006"> + <message_arguments> + <message_argument value="IExportProjectProvider"/> + <message_argument value="AbstractExportProjectProvider"/> + </message_arguments> + </filter> + </resource> + <resource path="parser/org/eclipse/cdt/core/parser/AbstractPersistableProblem.java" type="org.eclipse.cdt.core.parser.AbstractPersistableProblem"> + <filter comment="Squash over zealous warning from PDE. See Bug 558477" id="576725006"> + <message_arguments> + <message_argument value="IPersistableProblem"/> + <message_argument value="AbstractPersistableProblem"/> + </message_arguments> + </filter> + </resource> + <resource path="parser/org/eclipse/cdt/core/parser/IParserSettings2.java" type="org.eclipse.cdt.core.parser.IParserSettings2$Default"> + <filter comment="Squash over zealous warning from PDE. See Bug 558477" id="576725006"> + <message_arguments> + <message_argument value="IParserSettings2"/> + <message_argument value="Default"/> + </message_arguments> + </filter> + </resource> + <resource path="src/org/eclipse/cdt/core/AbstractCExtension.java" type="org.eclipse.cdt.core.AbstractCExtension"> + <filter comment="Squash over zealous warning from PDE. See Bug 558477" id="576725006"> + <message_arguments> + <message_argument value="ICExtension"/> + <message_argument value="AbstractCExtension"/> + </message_arguments> + </filter> + </resource> + <resource path="src/org/eclipse/cdt/core/cdtvariables/CdtVariableStatus.java" type="org.eclipse.cdt.core.cdtvariables.CdtVariableStatus"> + <filter comment="Squash over zealous warning from PDE. See Bug 558477" id="576725006"> + <message_arguments> + <message_argument value="ICdtVariableStatus"/> + <message_argument value="CdtVariableStatus"/> + </message_arguments> + </filter> + </resource> + <resource path="src/org/eclipse/cdt/core/envvar/EnvironmentVariable.java" type="org.eclipse.cdt.core.envvar.EnvironmentVariable"> + <filter comment="Squash over zealous warning from PDE. See Bug 558477" id="576725006"> + <message_arguments> + <message_argument value="IEnvironmentVariable"/> + <message_argument value="EnvironmentVariable"/> + </message_arguments> + </filter> + </resource> + <resource path="utils/org/eclipse/cdt/utils/DefaultCygwinToolFactory.java" type="org.eclipse.cdt.utils.DefaultCygwinToolFactory"> + <filter comment="Squash over zealous warning from PDE. See Bug 558477" id="576725006"> + <message_arguments> + <message_argument value="ICygwinToolsFactroy"/> + <message_argument value="DefaultCygwinToolFactory"/> + </message_arguments> + </filter> + </resource> + <resource path="utils/org/eclipse/cdt/utils/DefaultGnuToolFactory.java" type="org.eclipse.cdt.utils.DefaultGnuToolFactory"> + <filter comment="Squash over zealous warning from PDE. See Bug 558477" id="576725006"> + <message_arguments> + <message_argument value="IGnuToolFactory"/> + <message_argument value="DefaultGnuToolFactory"/> + </message_arguments> + </filter> + </resource> + <resource path="utils/org/eclipse/cdt/utils/cdtvariables/SupplierBasedCdtVariableSubstitutor.java" type="org.eclipse.cdt.utils.cdtvariables.SupplierBasedCdtVariableSubstitutor"> + <filter comment="Squash over zealous warning from PDE. See Bug 558477" id="576725006"> + <message_arguments> + <message_argument value="IVariableSubstitutor"/> + <message_argument value="SupplierBasedCdtVariableSubstitutor"/> + </message_arguments> + </filter> + </resource> + <resource path="utils/org/eclipse/cdt/utils/coff/CodeViewReader.java" type="org.eclipse.cdt.utils.coff.CodeViewReader"> + <filter comment="Squash over zealous warning from PDE. See Bug 558477" id="576725006"> + <message_arguments> + <message_argument value="ISymbolReader"/> + <message_argument value="CodeViewReader"/> + </message_arguments> + </filter> + </resource> + <resource path="utils/org/eclipse/cdt/utils/debug/dwarf/DwarfReader.java" type="org.eclipse.cdt.utils.debug.dwarf.DwarfReader"> + <filter comment="Squash over zealous warning from PDE. See Bug 558477" id="576725006"> + <message_arguments> + <message_argument value="ICompileOptionsFinder"/> + <message_argument value="DwarfReader"/> + </message_arguments> + </filter> + <filter comment="Squash over zealous warning from PDE. See Bug 558477" id="576725006"> + <message_arguments> + <message_argument value="ISymbolReader"/> + <message_argument value="DwarfReader"/> + </message_arguments> + </filter> + </resource> + <resource path="utils/org/eclipse/cdt/utils/debug/stabs/StabsReader.java" type="org.eclipse.cdt.utils.debug.stabs.StabsReader"> + <filter comment="Squash over zealous warning from PDE. See Bug 558477" id="576725006"> + <message_arguments> + <message_argument value="ISymbolReader"/> + <message_argument value="StabsReader"/> + </message_arguments> + </filter> + </resource> +</component> diff --git a/core/org.eclipse.cdt.core/.settings/org.eclipse.core.resources.prefs b/core/org.eclipse.cdt.core/.settings/org.eclipse.core.resources.prefs index a297482b44b..34f39fc76e2 100644 --- a/core/org.eclipse.cdt.core/.settings/org.eclipse.core.resources.prefs +++ b/core/org.eclipse.cdt.core/.settings/org.eclipse.core.resources.prefs @@ -3,3 +3,4 @@ encoding//parser/org/eclipse/cdt/internal/core/index/Messages.properties=8859_1 encoding//parser/org/eclipse/cdt/internal/core/pdom/Messages.properties=8859_1 encoding//parser/org/eclipse/cdt/internal/core/pdom/db/Messages.properties=8859_1 encoding//parser/org/eclipse/cdt/internal/core/pdom/indexer/Messages.properties=8859_1 +encoding/<project>=UTF-8 diff --git a/core/org.eclipse.cdt.core/.settings/org.eclipse.jdt.core.prefs b/core/org.eclipse.cdt.core/.settings/org.eclipse.jdt.core.prefs index 2b6ecff8a01..e3a8104f9ca 100644 --- a/core/org.eclipse.cdt.core/.settings/org.eclipse.jdt.core.prefs +++ b/core/org.eclipse.cdt.core/.settings/org.eclipse.jdt.core.prefs @@ -30,9 +30,9 @@ org.eclipse.jdt.core.compiler.annotation.nullable.secondary= org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.methodParameters=generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.compliance=11 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -49,6 +49,7 @@ org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled org.eclipse.jdt.core.compiler.problem.discouragedReference=warning org.eclipse.jdt.core.compiler.problem.emptyStatement=warning +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning @@ -107,6 +108,7 @@ org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=igno org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled @@ -144,13 +146,14 @@ org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.release=disabled -org.eclipse.jdt.core.compiler.source=1.8 +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=11 org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns=false org.eclipse.jdt.core.formatter.align_with_spaces=false +org.eclipse.jdt.core.formatter.alignment_for_additive_operator=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 @@ -158,21 +161,24 @@ org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_c org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_assignment=0 -org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_bitwise_operator=16 org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 org.eclipse.jdt.core.formatter.alignment_for_compact_loops=16 org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 org.eclipse.jdt.core.formatter.alignment_for_enum_constants=16 org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0 +org.eclipse.jdt.core.formatter.alignment_for_logical_operator=16 org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 org.eclipse.jdt.core.formatter.alignment_for_module_statements=16 org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_multiplicative_operator=16 org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_string_concatenation=16 org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 @@ -264,11 +270,12 @@ org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_after_additive_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_bitwise_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert @@ -299,6 +306,8 @@ org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_after_logical_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_multiplicative_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert @@ -323,13 +332,17 @@ org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_relational_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert +org.eclipse.jdt.core.formatter.insert_space_after_shift_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_string_concatenation=insert org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_additive_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_bitwise_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert @@ -377,6 +390,8 @@ org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do no org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_before_logical_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_multiplicative_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert @@ -413,9 +428,12 @@ org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not inser org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_relational_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_shift_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_string_concatenation=insert org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert @@ -454,10 +472,14 @@ org.eclipse.jdt.core.formatter.tabulation.char=tab org.eclipse.jdt.core.formatter.tabulation.size=4 org.eclipse.jdt.core.formatter.use_on_off_tags=true org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false +org.eclipse.jdt.core.formatter.wrap_before_additive_operator=true org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false -org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true +org.eclipse.jdt.core.formatter.wrap_before_bitwise_operator=true org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true +org.eclipse.jdt.core.formatter.wrap_before_logical_operator=true +org.eclipse.jdt.core.formatter.wrap_before_multiplicative_operator=true org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true +org.eclipse.jdt.core.formatter.wrap_before_string_concatenation=true org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true org.eclipse.jdt.core.incompatibleJDKLevel=ignore org.eclipse.jdt.core.incompleteClasspath=error diff --git a/core/org.eclipse.cdt.core/.settings/org.eclipse.jdt.ui.prefs b/core/org.eclipse.cdt.core/.settings/org.eclipse.jdt.ui.prefs index e44576346c4..d35ba9b5231 100644 --- a/core/org.eclipse.cdt.core/.settings/org.eclipse.jdt.ui.prefs +++ b/core/org.eclipse.cdt.core/.settings/org.eclipse.jdt.ui.prefs @@ -1,3 +1,4 @@ +cleanup.add_all=false cleanup.add_default_serial_version_id=true cleanup.add_generated_serial_version_id=false cleanup.add_missing_annotations=true @@ -11,25 +12,72 @@ cleanup.always_use_blocks=true cleanup.always_use_parentheses_in_expressions=false cleanup.always_use_this_for_non_static_field_access=false cleanup.always_use_this_for_non_static_method_access=false +cleanup.array_with_curly=false +cleanup.arrays_fill=false +cleanup.bitwise_conditional_expression=false +cleanup.boolean_literal=false +cleanup.boolean_value_rather_than_comparison=false +cleanup.break_loop=false +cleanup.collection_cloning=false +cleanup.comparing_on_criteria=false +cleanup.comparison_statement=false +cleanup.controlflow_merge=false cleanup.convert_functional_interfaces=false cleanup.convert_to_enhanced_for_loop=false +cleanup.convert_to_enhanced_for_loop_if_loop_var_used=true +cleanup.convert_to_switch_expressions=false cleanup.correct_indentation=false +cleanup.do_while_rather_than_while=true +cleanup.double_negation=false +cleanup.else_if=false +cleanup.embedded_if=false +cleanup.evaluate_nullable=false +cleanup.extract_increment=false cleanup.format_source_code=true cleanup.format_source_code_changes_only=false +cleanup.hash=false +cleanup.if_condition=false cleanup.insert_inferred_type_arguments=false +cleanup.instanceof=false +cleanup.instanceof_keyword=false +cleanup.invert_equals=false +cleanup.join=false +cleanup.lazy_logical_operator=false cleanup.make_local_variable_final=true cleanup.make_parameters_final=false cleanup.make_private_fields_final=true cleanup.make_type_abstract_if_missing_method=false cleanup.make_variable_declarations_final=false +cleanup.map_cloning=false +cleanup.merge_conditional_blocks=false +cleanup.multi_catch=false cleanup.never_use_blocks=false cleanup.never_use_parentheses_in_expressions=true +cleanup.no_string_creation=false +cleanup.no_super=false +cleanup.number_suffix=false +cleanup.objects_equals=false +cleanup.one_if_rather_than_duplicate_blocks_that_fall_through=false +cleanup.operand_factorization=false cleanup.organize_imports=true +cleanup.overridden_assignment=false +cleanup.plain_replacement=false +cleanup.precompile_regex=false +cleanup.primitive_comparison=false +cleanup.primitive_parsing=false +cleanup.primitive_rather_than_wrapper=false +cleanup.primitive_serialization=false +cleanup.pull_out_if_from_if_else=false +cleanup.pull_up_assignment=false +cleanup.push_down_negation=false cleanup.qualify_static_field_accesses_with_declaring_class=false cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true cleanup.qualify_static_member_accesses_with_declaring_class=false cleanup.qualify_static_method_accesses_with_declaring_class=false +cleanup.reduce_indentation=false +cleanup.redundant_comparator=false +cleanup.redundant_falling_through_block_end=false cleanup.remove_private_constructors=true cleanup.remove_redundant_modifiers=false cleanup.remove_redundant_semicolons=true @@ -37,25 +85,57 @@ cleanup.remove_redundant_type_arguments=true cleanup.remove_trailing_whitespaces=true cleanup.remove_trailing_whitespaces_all=true cleanup.remove_trailing_whitespaces_ignore_empty=false +cleanup.remove_unnecessary_array_creation=false cleanup.remove_unnecessary_casts=true cleanup.remove_unnecessary_nls_tags=false cleanup.remove_unused_imports=true cleanup.remove_unused_local_variables=false +cleanup.remove_unused_method_parameters=false cleanup.remove_unused_private_fields=true cleanup.remove_unused_private_members=false cleanup.remove_unused_private_methods=true cleanup.remove_unused_private_types=true +cleanup.return_expression=false +cleanup.simplify_lambda_expression_and_method_ref=false +cleanup.single_used_field=false cleanup.sort_members=false cleanup.sort_members_all=false +cleanup.standard_comparison=false +cleanup.static_inner_class=false +cleanup.strictly_equal_or_different=false +cleanup.stringbuffer_to_stringbuilder=false +cleanup.stringbuilder=false +cleanup.stringbuilder_for_local_vars=true +cleanup.stringconcat_to_textblock=false +cleanup.substring=false +cleanup.switch=false +cleanup.system_property=false +cleanup.system_property_boolean=false +cleanup.system_property_file_encoding=false +cleanup.system_property_file_separator=false +cleanup.system_property_line_separator=false +cleanup.system_property_path_separator=false +cleanup.ternary_operator=false +cleanup.try_with_resource=false +cleanup.unlooped_while=false +cleanup.unreachable_block=false cleanup.use_anonymous_class_creation=false +cleanup.use_autoboxing=false cleanup.use_blocks=false cleanup.use_blocks_only_for_return_and_throw=false +cleanup.use_directly_map_method=false cleanup.use_lambda=true cleanup.use_parentheses_in_expressions=false +cleanup.use_string_is_blank=false cleanup.use_this_for_non_static_field_access=false cleanup.use_this_for_non_static_field_access_only_if_necessary=true cleanup.use_this_for_non_static_method_access=false cleanup.use_this_for_non_static_method_access_only_if_necessary=true +cleanup.use_unboxing=false +cleanup.use_var=false +cleanup.useless_continue=false +cleanup.useless_return=false +cleanup.valueof_rather_than_instantiation=false cleanup_profile=_CDT cleanup_settings_version=2 eclipse.preferences.version=1 diff --git a/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF index 0de39d9b106..bc52049ddfe 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.0.0.qualifier +Bundle-Version: 7.5.0.qualifier Bundle-Activator: org.eclipse.cdt.core.CCorePlugin Bundle-Vendor: %providerName Bundle-Localization: plugin @@ -49,6 +49,7 @@ Export-Package: org.eclipse.cdt.core, org.eclipse.cdt.internal.core; x-friends:="org.eclipse.cdt.codan.core.cxx, org.eclipse.cdt.debug.core, + org.eclipse.cdt.dsf, org.eclipse.cdt.dsf.gdb, org.eclipse.cdt.make.core, org.eclipse.cdt.make.ui, @@ -97,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", @@ -120,22 +122,21 @@ Export-Package: org.eclipse.cdt.core, org.eclipse.cdt.utils.som.parser, org.eclipse.cdt.utils.xcoff, org.eclipse.cdt.utils.xcoff.parser -Require-Bundle: org.eclipse.cdt.core.native;bundle-version="[6.0.0,7.0.0)";visibility:=reexport, - org.eclipse.core.contenttype;bundle-version="[3.7.400,4.0.0)", - org.eclipse.core.expressions;bundle-version="[3.6.500,4.0.0)", - org.eclipse.core.filebuffers;bundle-version="[3.6.700,4.0.0)", - org.eclipse.core.filesystem;bundle-version="[1.7.500,2.0.0)", - org.eclipse.core.resources;bundle-version="[3.13.500,4.0.0)", - org.eclipse.core.runtime;bundle-version="[3.16.0,4.0.0)", - org.eclipse.core.variables;bundle-version="[3.4.600,4.0.0)", - 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, +Require-Bundle: org.eclipse.cdt.core.native;bundle-version="[6.2.0,7.0.0)";visibility:=reexport, + org.eclipse.core.contenttype;bundle-version="[3.8.100,4.0.0)", + org.eclipse.core.expressions;bundle-version="[3.8.100,4.0.0)", + org.eclipse.core.filebuffers;bundle-version="[3.7.100,4.0.0)", + org.eclipse.core.filesystem;bundle-version="[1.9.200,2.0.0)", + org.eclipse.core.resources;bundle-version="[3.16.0,4.0.0)", + org.eclipse.core.runtime;bundle-version="[3.24.0,4.0.0)", + org.eclipse.core.variables;bundle-version="[3.5.100,4.0.0)", + org.eclipse.ltk.core.refactoring;bundle-version="[3.12.100,4.0.0)", + org.eclipse.osgi.services;bundle-version="[3.10.200,4.0.0)", + org.eclipse.text;bundle-version="[3.12.0,4.0.0)", + 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-1.8 -Import-Package: javax.xml.bind;version="2.2.0" +Bundle-RequiredExecutionEnvironment: JavaSE-11 Automatic-Module-Name: org.eclipse.cdt.core Service-Component: OSGI-INF/*.xml diff --git a/core/org.eclipse.cdt.core/about.html b/core/org.eclipse.cdt.core/about.html index 164f781a8fd..b3134865230 100644 --- a/core/org.eclipse.cdt.core/about.html +++ b/core/org.eclipse.cdt.core/about.html @@ -1,10 +1,11 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> + <head> -<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> -<title>About</title> + <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> + <title>About</title> </head> + <body lang="EN-US"> <h2>About This Content</h2> @@ -16,7 +17,7 @@ ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 ("EPL"). A copy of the EPL is - available at <a href="http://www.eclipse.org/legal/epl-2.0">http://www.eclipse.org/legal/epl-2.0</a>. + available at <a href="https://www.eclipse.org/legal/epl-2.0">https://www.eclipse.org/legal/epl-2.0</a>. For purposes of the EPL, "Program" will mean the Content. </p> @@ -29,8 +30,9 @@ license exists, contact the Redistributor. Unless otherwise indicated below, the terms and conditions of the EPL still apply to any source code in the Content and such source code may be obtained at <a - href="http://www.eclipse.org/">http://www.eclipse.org</a>. + href="https://www.eclipse.org/">https://www.eclipse.org</a>. </p> </body> + </html>
\ No newline at end of file diff --git a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/PathUtil.java b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/PathUtil.java deleted file mode 100644 index e1d8dccb6b5..00000000000 --- a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/PathUtil.java +++ /dev/null @@ -1,178 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2009 QNX Software Systems 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: - * QNX Software Systems - initial API and implementation - * Markus Schorn (Wind River Systems) - *******************************************************************************/ -package org.eclipse.cdt.core.browser; - -import java.io.File; -import java.io.IOException; - -import org.eclipse.cdt.core.CCorePlugin; -import org.eclipse.cdt.core.model.CoreModel; -import org.eclipse.cdt.core.model.ICProject; -import org.eclipse.cdt.core.parser.IScannerInfo; -import org.eclipse.cdt.core.parser.IScannerInfoProvider; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; - -/** - * @deprecated use {@link org.eclipse.cdt.utils.PathUtil}, instead. - * @noextend This class is not intended to be subclassed by clients. - * @noinstantiate This class is not intended to be instantiated by clients. - */ -@Deprecated -public class PathUtil { - - public static boolean isWindowsFileSystem() { - String os = System.getProperty("os.name"); //$NON-NLS-1$ - return (os != null && os.startsWith("Win")); //$NON-NLS-1$ - } - - public static IWorkspaceRoot getWorkspaceRoot() { - IWorkspace workspace = ResourcesPlugin.getWorkspace(); - if (workspace != null) { - return workspace.getRoot(); - } - return null; - } - - public static IPath getCanonicalPath(IPath fullPath) { - File file = fullPath.toFile(); - try { - String canonPath = file.getCanonicalPath(); - return new Path(canonPath); - } catch (IOException ex) { - } - return null; - } - - public static IPath getWorkspaceRelativePath(IPath fullPath) { - IWorkspaceRoot workspaceRoot = getWorkspaceRoot(); - if (workspaceRoot != null) { - IPath workspaceLocation = workspaceRoot.getLocation(); - if (workspaceLocation != null && workspaceLocation.isPrefixOf(fullPath)) { - int segments = fullPath.matchingFirstSegments(workspaceLocation); - IPath relPath = fullPath.setDevice(null).removeFirstSegments(segments); - return new Path("").addTrailingSeparator().append(relPath); //$NON-NLS-1$ - } - } - return fullPath; - } - - public static IPath getProjectRelativePath(IPath fullPath, IProject project) { - IPath projectPath = project.getFullPath(); - if (projectPath.isPrefixOf(fullPath)) { - return fullPath.removeFirstSegments(projectPath.segmentCount()); - } - projectPath = project.getLocation(); - if (projectPath.isPrefixOf(fullPath)) { - return fullPath.removeFirstSegments(projectPath.segmentCount()); - } - return getWorkspaceRelativePath(fullPath); - } - - public static IPath getWorkspaceRelativePath(String fullPath) { - return getWorkspaceRelativePath(new Path(fullPath)); - } - - public static IPath getRawLocation(IPath wsRelativePath) { - IWorkspaceRoot workspaceRoot = getWorkspaceRoot(); - if (workspaceRoot != null && wsRelativePath != null) { - IPath workspaceLocation = workspaceRoot.getLocation(); - if (workspaceLocation != null && !workspaceLocation.isPrefixOf(wsRelativePath)) { - return workspaceLocation.append(wsRelativePath); - } - } - return wsRelativePath; - } - - public static IPath makeRelativePath(IPath path, IPath relativeTo) { - int segments = relativeTo.matchingFirstSegments(path); - if (segments > 0) { - IPath prefix = relativeTo.removeFirstSegments(segments); - IPath suffix = path.removeFirstSegments(segments); - IPath relativePath = new Path(""); //$NON-NLS-1$ - for (int i = 0; i < prefix.segmentCount(); ++i) { - relativePath = relativePath.append(".." + IPath.SEPARATOR); //$NON-NLS-1$ - } - return relativePath.append(suffix); - } - return null; - } - - public static IPath makeRelativePathToProjectIncludes(IPath fullPath, IProject project) { - IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(project); - if (provider != null) { - IScannerInfo info = provider.getScannerInformation(project); - if (info != null) { - return makeRelativePathToIncludes(fullPath, info.getIncludePaths()); - } - } - return null; - } - - public static IPath makeRelativePathToIncludes(IPath fullPath, String[] includePaths) { - IPath relativePath = null; - int mostSegments = 0; - for (int i = 0; i < includePaths.length; ++i) { - IPath includePath = new Path(includePaths[i]); - if (includePath.isPrefixOf(fullPath)) { - int segments = includePath.matchingFirstSegments(fullPath); - if (segments > mostSegments) { - relativePath = fullPath.removeFirstSegments(segments).setDevice(null); - mostSegments = segments; - } - } - } - return relativePath; - } - - /** - * @noreference This method is not intended to be referenced by clients. - */ - public static ICProject getEnclosingProject(IPath fullPath) { - IWorkspaceRoot root = getWorkspaceRoot(); - if (root != null) { - IPath path = getWorkspaceRelativePath(fullPath); - while (path.segmentCount() > 0) { - IResource res = root.findMember(path); - if (res != null) - return CoreModel.getDefault().create(res.getProject()); - - path = path.removeLastSegments(1); - } - } - return null; - } - - public static IPath getValidEnclosingFolder(IPath fullPath) { - IWorkspaceRoot root = getWorkspaceRoot(); - if (root != null) { - IPath path = getWorkspaceRelativePath(fullPath); - while (path.segmentCount() > 0) { - IResource res = root.findMember(path); - if (res != null && res.exists() - && (res.getType() == IResource.PROJECT || res.getType() == IResource.FOLDER)) - return path; - - path = path.removeLastSegments(1); - } - } - return null; - } -} diff --git a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/TypeSearchScope.java b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/TypeSearchScope.java index 8c892b30d1d..e29cf5c24df 100644 --- a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/TypeSearchScope.java +++ b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/TypeSearchScope.java @@ -151,10 +151,6 @@ public class TypeSearchScope implements ITypeSearchScope { } // check projects that were explicity added to scope - if (fProjectSet.contains(path)) - return true; - - // check projects that were explicity added to scope if (fProjects == null) { fProjects = fProjectSet.toArray(new ICProject[fProjectSet.size()]); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsManager.java index 2fc760c77ad..2d75d6c975d 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsManager.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsManager.java @@ -48,7 +48,7 @@ public class LanguageSettingsManager { * for the given configuration description, resource and language. This is a * combined list for all providers taking into account settings of parent folder * if settings for the given resource are not defined. For include paths both - * local (#include "...") and system (#include <...>) entries are returned. + * local (#include "...") and system (#include <...>) entries are returned. * * @param cfgDescription - configuration description. * @param rc - resource such as file or folder. diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsSerializableProvider.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsSerializableProvider.java index a11e4a7903e..bcd849b1074 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsSerializableProvider.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsSerializableProvider.java @@ -165,7 +165,7 @@ public class LanguageSettingsSerializableProvider extends LanguageSettingsBasePr * {@link #setSettingEntries(ICConfigurationDescription, IResource, String, List)}. * <br><br> * Note also that <b>you can compare these lists with simple equality operator ==</b>, - * as the lists themselves are backed by WeakHashSet<List<ICLanguageSettingEntry>> where + * as the lists themselves are backed by WeakHashSet<List<ICLanguageSettingEntry>> where * identical copies (deep comparison is used) are replaced with the same one instance. */ @Override diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java index 90630584253..34fc11b7b75 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java @@ -1424,10 +1424,10 @@ public class CoreModel { * * Each getProjectDescription(project, true) returns a new copy of the project description * - * The writable description uses the cached data untill the first set call + * The writable description uses the cached data until the first set call * after that the description communicates directly to the Build System * i.e. the implementer of the org.eclipse.cdt.core.CConfigurationDataProvider extension - * This ensures the Core<->Build System settings integrity + * This ensures the Core<->Build System settings integrity * * @return {@link ICProjectDescription} or null if the project does not contain the * CDT data associated with it. diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ICElement.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ICElement.java index 28034b42238..c4e069976ec 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ICElement.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ICElement.java @@ -244,6 +244,12 @@ public interface ICElement extends IAdaptable { static final int ASM_LABEL = 94; /** + * A pragma statement. + * @since 7.3 + */ + static final int C_PRAGMA = 95; + + /** * @deprecated use {@link IMethodDeclaration#isConstructor()} * @noreference This field is not intended to be referenced by clients. */ diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IPragma.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IPragma.java new file mode 100644 index 00000000000..334f9ed971e --- /dev/null +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IPragma.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * 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.model; + +import java.util.Optional; + +/** + * Represents a pragma statement. + * + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + * @since 7.3 + */ +public interface IPragma extends ICElement, ISourceManipulation, ISourceReference { + + public interface PragmaMarkInfo { + /** + * Whether the pragma indicates a divider before it. + */ + public boolean isDividerBeforeMark(); + + /** + * Whether the pragma indicates a divider after it. + */ + public boolean isDividerAfterMark(); + + /** + * The display string of the mark. + */ + public String getMarkName(); + } + + /** + * Returns whether this uses the pragma operator syntax, e.g: <code>_Pragma("once")</code> + * @since 5.2 + */ + public boolean isPragmaOperator(); + + /** + * Returns the PragmaMarkInfo if the pragma represents a <code>#pragma mark</code> or similar pragma + * that should be interpreted as such. + * @return {@link Optional} of the {@link PragmaMarkInfo} + */ + Optional<PragmaMarkInfo> getPragmaMarkInfo(); +} diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICConfigurationDescription.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICConfigurationDescription.java index 9bdc0a3ff55..ffb3a87215f 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICConfigurationDescription.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICConfigurationDescription.java @@ -234,7 +234,7 @@ public interface ICConfigurationDescription extends ICSettingContainer, ICSettin * If the current configuration does not reference any other configurations, * an empty map is returned. * - * @return Map<String,String> of referenced Project -> Configuration ID + * @return Map<String,String> of referenced Project -> Configuration ID * @see #setReferenceInfo(Map) * @see #getExternalSettings() * @see #createExternalSetting(String[], String[], String[], ICSettingEntry[]) @@ -250,7 +250,7 @@ public interface ICConfigurationDescription extends ICSettingContainer, ICSettin * The empty string is a special configuration value which indicates the reference * tracks the Active configuration in the referenced Project. * - * @param refs Map of project name -> configuration ID of referenced configurations + * @param refs Map of project name -> configuration ID of referenced configurations * @throws WriteAccessException when the configuration description is read-only * see {@link CoreModel#getProjectDescription(org.eclipse.core.resources.IProject, boolean)} * @see {@link #getReferenceInfo()} <br/> diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICProjectDescriptionManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICProjectDescriptionManager.java index 17c382f5f70..a7ca68e58bc 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICProjectDescriptionManager.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICProjectDescriptionManager.java @@ -176,7 +176,7 @@ public interface ICProjectDescriptionManager { * The writable description uses the cached data until the first set call * after that the description communicates directly to the Build System * i.e. the implementer of the org.eclipse.cdt.core.CConfigurationDataProvider extension - * This ensures the Core<->Build System settings integrity + * This ensures the Core<->Build System settings integrity * * @return {@link ICProjectDescription} or null if the project does not contain the * CDT data associated with it. diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICSettingEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICSettingEntry.java index db7eda528ea..8836a863fd8 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICSettingEntry.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICSettingEntry.java @@ -47,7 +47,7 @@ public interface ICSettingEntry { /** * Flag {@code LOCAL} is used during creation of {@link IIncludeEntry} * to indicate that an include path is not a system path. - * "System" path is denoted by angle brackets as in #include <x.h> + * "System" path is denoted by angle brackets as in #include <x.h> * "Local" path is denoted by quotes as in #include "x.h" */ int LOCAL = 1 << 2; diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CConfigurationDataProvider.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CConfigurationDataProvider.java index cee85a47d8f..eb57aaeacec 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CConfigurationDataProvider.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CConfigurationDataProvider.java @@ -37,7 +37,7 @@ public abstract class CConfigurationDataProvider { * The method can be called in following cases: * <br> * 1. Loading configuration from external data source such as .cproject.<br> - * 2. Loading preference configuration defined in Preferences -> C/C++ -> New project Wizard -> Makefile Project. + * 2. Loading preference configuration defined in Preferences -> C/C++ -> New project Wizard -> Makefile Project. * * @param cfgDescription - configuration description being loaded. * @param monitor - progress monitor. diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsProvidersSerializer.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsProvidersSerializer.java index 02110ec446f..987de9f6f1b 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsProvidersSerializer.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsProvidersSerializer.java @@ -40,7 +40,6 @@ import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; import org.eclipse.cdt.core.settings.model.ICProjectDescription; import org.eclipse.cdt.core.settings.model.ICSettingEntry; import org.eclipse.cdt.internal.core.XmlUtil; -import org.eclipse.cdt.internal.core.model.Util; import org.eclipse.cdt.internal.core.settings.model.CConfigurationSpecSettings; import org.eclipse.cdt.internal.core.settings.model.IInternalCCfgInfo; import org.eclipse.cdt.internal.core.settings.model.SettingsModelMessages; @@ -588,11 +587,7 @@ public class LanguageSettingsProvidersSerializer { try { serializingLockWsp.acquire(); - String eol = Util.getLineSeparator(uriStoreWsp); - if (eol == null) { - eol = Util.getDefaultLineSeparator(); - } - XmlUtil.serializeXml(doc, uriStoreWsp, eol); + XmlUtil.serializeXml(doc, uriStoreWsp); // manufacture events while inside the lock events = createLanguageSettingsChangeEvents(broadcastingWorkspaceProviders); } finally { @@ -902,7 +897,13 @@ public class LanguageSettingsProvidersSerializer { fileStorePrj.delete(true, null); } } else { - project.getWorkspace().validateEdit(new IFile[] { fileStorePrj }, IWorkspace.VALIDATE_PROMPT); + if (fileStorePrj.isReadOnly()) { + IStatus editStatus = project.getWorkspace().validateEdit(new IFile[] { fileStorePrj }, + IWorkspace.VALIDATE_PROMPT); + if (!editStatus.isOK()) { + throw new CoreException(editStatus); + } + } IContainer folder = fileStorePrj.getParent(); if (folder instanceof IFolder && !folder.exists()) { ((IFolder) folder).create(true, true, null); @@ -915,11 +916,7 @@ public class LanguageSettingsProvidersSerializer { if (isWorkspaceStoreEmpty) { new java.io.File(uriStoreWsp).delete(); } else { - String eol = Util.getLineSeparator(uriStoreWsp); - if (eol == null) { - eol = Util.getDefaultLineSeparator(project); - } - XmlUtil.serializeXml(docStoreWsp, uriStoreWsp, eol); + XmlUtil.serializeXml(docStoreWsp, uriStoreWsp); } // manufacture the event only if serialization was successful diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/PathEntryScannerInfoLanguageSettingsProvider.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/PathEntryScannerInfoLanguageSettingsProvider.java index 0c10b459325..9b20c56fe1d 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/PathEntryScannerInfoLanguageSettingsProvider.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/PathEntryScannerInfoLanguageSettingsProvider.java @@ -118,6 +118,8 @@ public class PathEntryScannerInfoLanguageSettingsProvider extends LanguageSettin } } catch (CoreException e) { CCorePlugin.log(e); + } finally { + pathEntryStore.close(); } Set<ICLanguageSettingEntry> lsEntries = new LinkedHashSet<>(); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/ReferencedProjectsLanguageSettingsProvider.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/ReferencedProjectsLanguageSettingsProvider.java index 7a6f688bbc5..1a34db0b7da 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/ReferencedProjectsLanguageSettingsProvider.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/ReferencedProjectsLanguageSettingsProvider.java @@ -34,7 +34,7 @@ public class ReferencedProjectsLanguageSettingsProvider extends LanguageSettings /** ID of the provider used in extension point from plugin.xml */ public static final String ID = "org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider"; //$NON-NLS-1$ - final private ThreadLocal<Boolean> recursiveCallIndicator = new ThreadLocal<Boolean>() { + final private ThreadLocal<Boolean> recursiveCallIndicator = new ThreadLocal<>() { @Override protected Boolean initialValue() { return false; diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ArchiveContainerInfo.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ArchiveContainerInfo.java index bd79fed2ed7..23788a58cc5 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ArchiveContainerInfo.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ArchiveContainerInfo.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 QNX Software Systems and others. + * Copyright (c) 2000, 2021 QNX Software Systems and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -36,8 +36,6 @@ public class ArchiveContainerInfo extends OpenableInfo { @Override protected void addChild(ICElement child) { - if (!includesChild(child)) { - super.addChild(child); - } + addChildIfAbsent(child); } } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Binary.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Binary.java index ee9005af52e..17a4a36e620 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Binary.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Binary.java @@ -474,8 +474,7 @@ public class Binary extends Openable implements IBinary { IBinaryObject bin = getBinaryObject(); if (bin != null) { StringBuilder sb = new StringBuilder(); - try { - BufferedReader stream = new BufferedReader(new InputStreamReader(bin.getContents())); + try (BufferedReader stream = new BufferedReader(new InputStreamReader(bin.getContents()))) { char[] buf = new char[512]; int len; while ((len = stream.read(buf, 0, buf.length)) != -1) { diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryContainerInfo.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryContainerInfo.java index 07340c2d67c..4196d3a8db3 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryContainerInfo.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryContainerInfo.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 QNX Software Systems and others. + * Copyright (c) 2000, 2021 QNX Software Systems and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -29,8 +29,6 @@ public class BinaryContainerInfo extends OpenableInfo { @Override protected void addChild(ICElement child) { - if (!includesChild(child)) { - super.addChild(child); - } + addChildIfAbsent(child); } } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CElementInfo.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CElementInfo.java index 8e0e70f69e0..88a44167a80 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CElementInfo.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CElementInfo.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 QNX Software Systems and others. + * Copyright (c) 2000, 2021 QNX Software Systems and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -64,6 +64,14 @@ public class CElementInfo { fChildren.add(child); } + protected void addChildIfAbsent(ICElement child) { + synchronized (fChildren) { + if (!fChildren.contains(child)) { + fChildren.add(child); + } + } + } + protected ICElement[] getChildren() { synchronized (fChildren) { ICElement[] array = new ICElement[fChildren.size()]; diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelBuilder2.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelBuilder2.java index 4364123abb1..97c13fac1f5 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelBuilder2.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelBuilder2.java @@ -43,6 +43,8 @@ import org.eclipse.cdt.core.dom.ast.IASTNodeLocation; import org.eclipse.cdt.core.dom.ast.IASTPreprocessorFunctionStyleMacroDefinition; import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement; import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition; +import org.eclipse.cdt.core.dom.ast.IASTPreprocessorPragmaStatement; +import org.eclipse.cdt.core.dom.ast.IASTPreprocessorStatement; import org.eclipse.cdt.core.dom.ast.IASTProblem; import org.eclipse.cdt.core.dom.ast.IASTProblemDeclaration; import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier; @@ -55,7 +57,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAliasDeclaration; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeductionGuide; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExplicitTemplateInstantiation; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator; @@ -110,6 +111,14 @@ public class CModelBuilder2 implements IContributedModelBuilder { private HashMap<ISourceReference, int[]> fEqualElements; /** + * To support the new feature "#pragma mark to Outline view" (Bug 546981) the model was updated + * to include pragmas. Because the model is widely used, this feature flag allows turning off + * including pragmas in the model. + */ + private static final boolean INCLUDE_PRAGMAS_IN_MODEL = Boolean + .parseBoolean(System.getProperty("org.eclipse.cdt.core.model_include_pragmas", "true")); //$NON-NLS-1$ //$NON-NLS-2$ + + /** * Create a model builder for the given translation unit. * * @param tu the translation unit (must be a {@link TranslationUnit} @@ -211,20 +220,24 @@ public class CModelBuilder2 implements IContributedModelBuilder { fVisibilityStack = new Stack<>(); fEqualElements = new HashMap<>(); - // includes - final IASTPreprocessorIncludeStatement[] includeDirectives = ast.getIncludeDirectives(); - for (IASTPreprocessorIncludeStatement includeDirective : includeDirectives) { - if (isLocalToFile(includeDirective)) { - createInclusion(fTranslationUnit, includeDirective); - } - } - // Macros - final IASTPreprocessorMacroDefinition[] macroDefinitions = ast.getMacroDefinitions(); - for (IASTPreprocessorMacroDefinition macroDefinition : macroDefinitions) { - if (isLocalToFile(macroDefinition)) { - createMacro(fTranslationUnit, macroDefinition); + for (IASTPreprocessorStatement statement : ast.getAllPreprocessorStatements()) { + if (statement instanceof IASTPreprocessorIncludeStatement) { + if (isLocalToFile(statement)) { + createInclusion(fTranslationUnit, (IASTPreprocessorIncludeStatement) statement); + } + } else if (statement instanceof IASTPreprocessorMacroDefinition) { + if (isLocalToFile(statement)) { + createMacro(fTranslationUnit, (IASTPreprocessorMacroDefinition) statement); + } + } else if (statement instanceof IASTPreprocessorPragmaStatement) { + if (INCLUDE_PRAGMAS_IN_MODEL) { + if (isLocalToFile(statement)) { + createPragma(fTranslationUnit, (IASTPreprocessorPragmaStatement) statement); + } + } } } + // Declarations final IASTDeclaration[] declarations = ast.getDeclarations(true); for (IASTDeclaration declaration : declarations) { @@ -322,6 +335,27 @@ public class CModelBuilder2 implements IContributedModelBuilder { return element; } + private Pragma createPragma(Parent parent, IASTPreprocessorPragmaStatement pragma) throws CModelException { + // Create element + String name; + if (pragma.isPragmaOperator()) { + name = pragma.getRawSignature(); + } else { + char[] message = pragma.getMessage(); + name = new String(message); + } + Pragma element = new Pragma(parent, name); + setIndex(element); + element.setActive(pragma.isActive()); + // Add to parent + parent.addChild(element); + // Set positions + setIdentifierPosition(element, pragma); + setBodyPosition(element, pragma); + element.setPragmaOperator(pragma.isPragmaOperator()); + return element; + } + private void createDeclaration(Parent parent, IASTDeclaration declaration) throws CModelException, DOMException { if (declaration instanceof IASTFunctionDefinition) { createFunctionDefinition(parent, (IASTFunctionDefinition) declaration, false); @@ -353,8 +387,6 @@ public class CModelBuilder2 implements IContributedModelBuilder { // TODO [cmodel] problem declaration? } else if (declaration instanceof ICPPASTStaticAssertDeclaration) { // ignore - } else if (declaration instanceof ICPPASTDeductionGuide) { - // TODO [cmodel] deduction guide? } else { assert false : "TODO: " + declaration.getClass().getName(); //$NON-NLS-1$ } @@ -419,8 +451,6 @@ public class CModelBuilder2 implements IContributedModelBuilder { createTemplateDeclaration(parent, (ICPPASTTemplateDeclaration) declaration); } else if (declaration instanceof IASTProblemDeclaration) { // ignore problem declarations (or create special elements for debugging?) - } else if (declaration instanceof ICPPASTDeductionGuide) { - // TODO [cmodel] deduction guide? } else { assert false : "TODO: " + declaration.getClass().getName(); //$NON-NLS-1$ } @@ -1226,6 +1256,16 @@ public class CModelBuilder2 implements IContributedModelBuilder { } /** + * Utility method to set the identifier position of an element from an AST node. + * + * @param element + * @param astNode + */ + private void setIdentifierPosition(SourceManipulation element, IASTNode astNode) { + setIdentifierPosition(getSourceManipulationInfo(element), astNode); + } + + /** * Utility method to set the identifier position of an element from an AST name. * * @param element diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Pragma.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Pragma.java new file mode 100644 index 00000000000..ba083cbe16b --- /dev/null +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Pragma.java @@ -0,0 +1,121 @@ +/******************************************************************************* + * 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.model; + +import java.util.Optional; +import java.util.StringTokenizer; + +import org.eclipse.cdt.core.model.ICElement; +import org.eclipse.cdt.core.model.IPragma; + +public class Pragma extends SourceManipulation implements IPragma { + + private boolean isPragmaOperator = false; + private Optional<PragmaMarkInfo> pragmaMarkInfo = null; + + public Pragma(ICElement parent, String name) { + super(parent, name, ICElement.C_PRAGMA); + } + + private PragmaMarkInfo calculateMarkInfo(String name) { + String nameTrimmed = name.trim(); + + StringTokenizer tokenizer = new StringTokenizer(nameTrimmed); + if (tokenizer.hasMoreTokens()) { + + boolean dividerBeforeMark = false; + boolean dividerAfterMark = false; + String markName = ""; //$NON-NLS-1$ + + String pragmaName = tokenizer.nextToken(); + String restOfLine; + if (tokenizer.hasMoreTokens()) { + restOfLine = tokenizer.nextToken("").trim(); //$NON-NLS-1$ + } else { + restOfLine = ""; //$NON-NLS-1$ + } + switch (pragmaName) { + case "mark": { //$NON-NLS-1$ + if (restOfLine.startsWith("-")) { //$NON-NLS-1$ + dividerBeforeMark = true; + restOfLine = restOfLine.substring(1); + } + if (restOfLine.endsWith("-")) { //$NON-NLS-1$ + dividerAfterMark = true; + restOfLine = restOfLine.substring(0, restOfLine.length() - 1); + } + markName = restOfLine.trim(); + } + break; + case "region": //$NON-NLS-1$ + case "endregion": { //$NON-NLS-1$ + if (restOfLine.isEmpty()) { + dividerBeforeMark = true; + dividerAfterMark = false; + } else { + dividerBeforeMark = true; + dividerAfterMark = true; + markName = restOfLine; + } + } + break; + default: + return null; + } + + boolean finalDividerBeforeMark = dividerBeforeMark; + boolean finalDividerAfterMark = dividerAfterMark; + String finalMarkName = markName; + return new PragmaMarkInfo() { + + @Override + public boolean isDividerBeforeMark() { + return finalDividerBeforeMark; + } + + @Override + public boolean isDividerAfterMark() { + return finalDividerAfterMark; + } + + @Override + public String getMarkName() { + return finalMarkName; + } + }; + } else { + return null; + } + } + + @Override + protected CElementInfo createElementInfo() { + return new SourceManipulationInfo(this); + } + + public void setPragmaOperator(boolean isPragmaOperator) { + this.isPragmaOperator = isPragmaOperator; + } + + @Override + public boolean isPragmaOperator() { + return isPragmaOperator; + } + + @Override + public Optional<PragmaMarkInfo> getPragmaMarkInfo() { + if (pragmaMarkInfo == null) { + pragmaMarkInfo = Optional.ofNullable(calculateMarkInfo(getElementName())); + } + return pragmaMarkInfo; + } +} diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/AbstractCProjectDescriptionStorage.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/AbstractCProjectDescriptionStorage.java index 0e2acbff464..8cc60070635 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/AbstractCProjectDescriptionStorage.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/AbstractCProjectDescriptionStorage.java @@ -70,7 +70,7 @@ public abstract class AbstractCProjectDescriptionStorage { protected volatile IProject project; /** Flag used to detect if setProjectDescription(...) is called by the thread already in a setProjectDescription(...) */ - final private ThreadLocal<Boolean> setProjectDescriptionOperationRunning = new ThreadLocal<Boolean>() { + final private ThreadLocal<Boolean> setProjectDescriptionOperationRunning = new ThreadLocal<>() { @Override protected Boolean initialValue() { return false; diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java index f1d7e921256..c566cb899c3 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java @@ -822,7 +822,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { } /** ThreadLocal flag to let CDescriptor know whether already in a setProjectDescription */ - ThreadLocal<Boolean> settingProjectDescription = new ThreadLocal<Boolean>() { + ThreadLocal<Boolean> settingProjectDescription = new ThreadLocal<>() { @Override protected Boolean initialValue() { return false; diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionPreferences.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionPreferences.java index c7d4ff4cd5e..ee8e4cd124d 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionPreferences.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionPreferences.java @@ -13,14 +13,19 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.settings.model; +import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.settings.model.ICProjectDescriptionPreferences; import org.eclipse.cdt.core.settings.model.ICStorageElement; import org.eclipse.cdt.core.settings.model.util.CDataUtil; +import org.eclipse.core.runtime.preferences.DefaultScope; public class CProjectDescriptionPreferences implements ICProjectDescriptionPreferences { + private static final String ATTR_CONFIG_RELATIONS = "configRelations"; //$NON-NLS-1$ - private static final int DEFAULT_RELATIONS = CONFIGS_INDEPENDENT; + // This preference is only used at Default Scope to allow product preference customization (plugin_customization.ini) + private static final String PREF_CPROJECTDESCRIPTION_CONFIG_RELATIONS_KEY = "cprojectdescription.configRelations"; //$NON-NLS-1$ + private boolean fIsReadOnly; private boolean fIsModified; @@ -43,7 +48,8 @@ public class CProjectDescriptionPreferences implements ICProjectDescriptionPrefe fIsReadOnly = isReadOnly; if (el != null) { if (el.getAttribute(ATTR_CONFIG_RELATIONS) != null) - fConfigRelations = Integer.valueOf(CDataUtil.getInteger(el, ATTR_CONFIG_RELATIONS, DEFAULT_RELATIONS)); + fConfigRelations = Integer + .valueOf(CDataUtil.getInteger(el, ATTR_CONFIG_RELATIONS, getDefaultRelations())); } this.fSuperPreference = superPreference; @@ -61,6 +67,11 @@ public class CProjectDescriptionPreferences implements ICProjectDescriptionPrefe CDataUtil.setInteger(el, ATTR_CONFIG_RELATIONS, fConfigRelations.intValue()); } + public static int getDefaultRelations() { + return DefaultScope.INSTANCE.getNode(CCorePlugin.PLUGIN_ID) + .getInt(PREF_CPROJECTDESCRIPTION_CONFIG_RELATIONS_KEY, CONFIGS_LINK_SETTINGS_AND_ACTIVE); + } + @Override public int getConfigurationRelations() { if (fConfigRelations != null) @@ -68,7 +79,7 @@ public class CProjectDescriptionPreferences implements ICProjectDescriptionPrefe CProjectDescriptionPreferences superPrefs = getSuperPreferences(); if (superPrefs != null) return superPrefs.getConfigurationRelations(); - return DEFAULT_RELATIONS; + return getDefaultRelations(); } @Override diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionStorageManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionStorageManager.java index 4a07bbb340c..8636b6030f2 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionStorageManager.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionStorageManager.java @@ -178,7 +178,8 @@ public class CProjectDescriptionStorageManager { Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$ transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); //$NON-NLS-1$ - transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$ + // Indentation is done with XmlUtil.prettyFormat(doc) + transformer.setOutputProperty(OutputKeys.INDENT, "no"); //$NON-NLS-1$ DOMSource source = new DOMSource(doc); StreamResult result = new StreamResult(stream); transformer.transform(source, result); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/SetCProjectDescriptionOperation.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/SetCProjectDescriptionOperation.java index 5211a782a67..329046d18db 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/SetCProjectDescriptionOperation.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/SetCProjectDescriptionOperation.java @@ -133,6 +133,13 @@ public class SetCProjectDescriptionOperation extends CModelOperation { fSetDescription, delta); cProject.close(); // Why? + // M-A.L: Here is an explanation I came up with from an investigation I did a long time ago (https://bugs.eclipse.org/bugs/show_bug.cgi?id=349564#c10) : + // "Some information in the CModel cache depends on the CProjectDescription. For example, + // CContainerInfo caches the non-C resources (like excluded files). By closing the CProject, + // that cache is deleted and rebuilt from CProjectDescription when needed. As a test, + // I removed this line and excluded some files then I could see the cache not + // being rebuilt and the icons for exclusion became out of sync." + // If you are tempted to remove this line please consider this. // ExternalSettingsManager.getInstance().updateDepentents(delta); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/xml/XmlProjectDescriptionStorage.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/xml/XmlProjectDescriptionStorage.java index 01c99e4e24c..a6df97cb85a 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/xml/XmlProjectDescriptionStorage.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/xml/XmlProjectDescriptionStorage.java @@ -176,7 +176,7 @@ public class XmlProjectDescriptionStorage extends AbstractCProjectDescriptionSto // end Bug 249951 & Bug 310007 serializingLock.acquire(); LanguageSettingsProvidersSerializer.serializeLanguageSettings(fDes); - projectModificaitonStamp = serialize(fDes.getProject(), + projectModificationStamp = serialize(fDes.getProject(), ICProjectDescriptionStorageType.STORAGE_FILE_NAME, fElement); ((ContributedEnvironment) CCorePlugin.getDefault().getBuildEnvironmentManager() .getContributedEnvironment()).serialize(fDes); @@ -192,7 +192,7 @@ public class XmlProjectDescriptionStorage extends AbstractCProjectDescriptionSto * Volatile provides a memory barrier in Java 5+ */ private volatile Reference<ICProjectDescription> fProjectDescription = new SoftReference<>(null); /** The last modification stamp of the .cproject project description file */ - private volatile long projectModificaitonStamp = IResource.NULL_STAMP; + private volatile long projectModificationStamp = IResource.NULL_STAMP; /** A lock that is held during project description serialization * This lock is also head during load to prevent a load overlapping @@ -305,9 +305,9 @@ public class XmlProjectDescriptionStorage extends AbstractCProjectDescriptionSto // If loaded, and we have cached the modification stamp, reload long currentModificationStamp = getModificationStamp( project.getFile(ICProjectDescriptionStorageType.STORAGE_FILE_NAME)); - if (projectModificaitonStamp != currentModificationStamp) { + if (projectModificationStamp != currentModificationStamp) { setCurrentDescription(null, true); - projectModificaitonStamp = currentModificationStamp; + projectModificationStamp = currentModificationStamp; return true; } return false; @@ -499,7 +499,7 @@ public class XmlProjectDescriptionStorage extends AbstractCProjectDescriptionSto ICProjectDescriptionStorageType.STORAGE_FILE_NAME, true, false, false); try { // Update the modification stamp - projectModificaitonStamp = getModificationStamp( + projectModificationStamp = getModificationStamp( project.getFile(ICProjectDescriptionStorageType.STORAGE_FILE_NAME)); CProjectDescription des = new CProjectDescription(project, new XmlStorage(storage), storage, true, false); @@ -546,7 +546,8 @@ public class XmlProjectDescriptionStorage extends AbstractCProjectDescriptionSto Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$ transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); //$NON-NLS-1$ - transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$ + // Indentation is done with XmlUtil.prettyFormat(doc) + transformer.setOutputProperty(OutputKeys.INDENT, "no"); //$NON-NLS-1$ DOMSource source = new DOMSource(doc); StreamResult result = new StreamResult(stream); transformer.transform(source, result); @@ -584,6 +585,7 @@ public class XmlProjectDescriptionStorage extends AbstractCProjectDescriptionSto utfString = stream.toString("UTF-8"); //$NON-NLS-1$ String eol = Util.getLineSeparator(projectFile); utfString = XmlUtil.replaceLineSeparatorInternal(utfString, eol); + utfString = XmlUtil.insertNewlineAfterXMLVersionTag(utfString, eol); } finally { if (stream != null) stream.close(); // Cleanup the stream diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/xml/XmlStorageElement.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/xml/XmlStorageElement.java index 45e6cec2b5b..47941d136b6 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/xml/XmlStorageElement.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/xml/XmlStorageElement.java @@ -514,7 +514,10 @@ public class XmlStorageElement implements ICStorageElement { try { ByteArrayOutputStream stream = new ByteArrayOutputStream(); Transformer transformer = TransformerFactory.newInstance().newTransformer(); - transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$ + // Indentation is done with XmlUtil.prettyFormat(doc). + // For debugging, the prettyFormat may not have been run yet, + // so turning this to "yes" may be helpful on occasion. + transformer.setOutputProperty(OutputKeys.INDENT, "no"); //$NON-NLS-1$ DOMSource source = new DOMSource(fElement); StreamResult result = new StreamResult(stream); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTTypeUtil.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTTypeUtil.java index 60dab642d73..213ea822bb6 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTTypeUtil.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTTypeUtil.java @@ -89,7 +89,7 @@ public class ASTTypeUtil { // sizes of type strings from getting out of control for certain code patterns. private static final int TYPE_STRING_LENGTH_THRESHOLD = 100000; - private static final ThreadLocal<Set<IBinding>> fSourceFileOnlyCheckInProgress = new ThreadLocal<Set<IBinding>>() { + private static final ThreadLocal<Set<IBinding>> fSourceFileOnlyCheckInProgress = new ThreadLocal<>() { @Override protected Set<IBinding> initialValue() { return new HashSet<>(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTAlignmentSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTAlignmentSpecifier.java index 9d555ad597c..8e17c414e6f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTAlignmentSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTAlignmentSpecifier.java @@ -20,11 +20,11 @@ package org.eclipse.cdt.core.dom.ast; * * Possible forms are: * C++: - * alignas(<type-id>) - * alignas(<expression>) + * alignas(<type-id>) + * alignas(<expression>) * C: - * _Alignas(<type-id>) - * _Alignas(<expression>) + * _Alignas(<type-id>) + * _Alignas(<expression>) * @noimplement This interface is not intended to be implemented by clients. * @noextend This interface is not intended to be extended by clients. * @since 5.10 @@ -39,13 +39,13 @@ public interface IASTAlignmentSpecifier extends IASTNode { "IASTAlignmentSpecifier.ALIGNMENT_TYPEID - Type-id in alignment specifier"); //$NON-NLS-1$ /** - * If the specifier is of the form 'alignas(<expression>)' or '_Alignas(<expression>)', + * If the specifier is of the form 'alignas(<expression>)' or '_Alignas(<expression>)', * returns the enclosed expression. Otherwise, returns null. */ IASTExpression getExpression(); /** - * If the specifier is of the form 'alignas(<type-id>)' or '_Alignas(<type-id>)', + * If the specifier is of the form 'alignas(<type-id>)' or '_Alignas(<type-id>)', * returns the enclosed type-id. Otherwise, returns null. */ IASTTypeId getTypeId(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTBinaryExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTBinaryExpression.java index a010247656e..af70cd64de0 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTBinaryExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTBinaryExpression.java @@ -77,37 +77,37 @@ public interface IASTBinaryExpression extends IASTExpression { public static final int op_minus = 5; /** - * shift left << + * shift left << */ public static final int op_shiftLeft = 6; /** - * shift right >> + * shift right >> */ public static final int op_shiftRight = 7; /** - * less than < + * less than < */ public static final int op_lessThan = 8; /** - * greater than > + * greater than > */ public static final int op_greaterThan = 9; /** - * less than or equals <= + * less than or equals <= */ public static final int op_lessEqual = 10; /** - * greater than or equals >= + * greater than or equals >= */ public static final int op_greaterEqual = 11; /** - * binary and & + * binary and & */ public static final int op_binaryAnd = 12; @@ -122,7 +122,7 @@ public interface IASTBinaryExpression extends IASTExpression { public static final int op_binaryOr = 14; /** - * logical and && + * logical and && */ public static final int op_logicalAnd = 15; @@ -162,17 +162,17 @@ public interface IASTBinaryExpression extends IASTExpression { public static final int op_minusAssign = 22; /** - * shift left assignment <<= + * shift left assignment <<= */ public static final int op_shiftLeftAssign = 23; /** - * shift right assign >>= + * shift right assign >>= */ public static final int op_shiftRightAssign = 24; /** - * binary and assign &= + * binary and assign &= */ public static final int op_binaryAndAssign = 25; @@ -210,13 +210,13 @@ public interface IASTBinaryExpression extends IASTExpression { /** * For g++, only. - * <code>op_max</code> represents >? + * <code>op_max</code> represents >? */ public static final int op_max = 32; /** * For g++, only. - * <code>op_min</code> represents <? + * <code>op_min</code> represents <? */ public static final int op_min = 33; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTBinaryTypeIdExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTBinaryTypeIdExpression.java index abcd5de01a0..3a98edeb2ee 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTBinaryTypeIdExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTBinaryTypeIdExpression.java @@ -30,7 +30,11 @@ public interface IASTBinaryTypeIdExpression extends IASTExpression { public static enum Operator { __is_base_of, /** @since 6.0 */ - __is_trivially_assignable + __is_trivially_assignable, + /** + * @since 7.1 + */ + __is_same, } /** diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTElaboratedTypeSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTElaboratedTypeSpecifier.java index fa5adac9fb0..48b567b058a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTElaboratedTypeSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTElaboratedTypeSpecifier.java @@ -14,7 +14,7 @@ package org.eclipse.cdt.core.dom.ast; /** - * This represents an elaborated type specifier in the C & C++ language grammar. + * This represents an elaborated type specifier in the C & C++ language grammar. * * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTFieldReference.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTFieldReference.java index f2964382946..9aed1bff89f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTFieldReference.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTFieldReference.java @@ -14,8 +14,8 @@ package org.eclipse.cdt.core.dom.ast; /** - * This interface represents expressions that access a field reference. e.g. a.b => a - * is the expression, b is the field name. e.g. a()->def => a() is the + * This interface represents expressions that access a field reference. e.g. a.b => a + * is the expression, b is the field name. e.g. a()->def => a() is the * expression, def is the field name. * * @noextend This interface is not intended to be extended by clients. diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTNode.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTNode.java index 685f176845d..b19df0a2ab1 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTNode.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTNode.java @@ -63,7 +63,7 @@ public interface IASTNode { * <p> * Nodes that span file context into a macro expansion (and potentially out * of the macro expansion again) result in an IASTNodeLocation[] result - * that is of length > 1. + * that is of length > 1. * <p> * We do not provide meaningful node locations for nested macro references * (see {@link IASTPreprocessorMacroExpansion#getNestedMacroReferences()}). diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTStandardFunctionDeclarator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTStandardFunctionDeclarator.java index 5b16a8ad407..7b866cada12 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTStandardFunctionDeclarator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTStandardFunctionDeclarator.java @@ -15,7 +15,7 @@ package org.eclipse.cdt.core.dom.ast; /** - * This is a declarator for a non K&R C function. + * This is a declarator for a non K&R C function. * * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTUnaryExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTUnaryExpression.java index 9c78146e9f7..683be73d85d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTUnaryExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTUnaryExpression.java @@ -53,7 +53,7 @@ public interface IASTUnaryExpression extends IASTExpression { /** * Operator ampersand. - * {@code op_amper}: &exp + * {@code op_amper}: &exp */ public static final int op_amper = 5; @@ -129,7 +129,7 @@ public interface IASTUnaryExpression extends IASTExpression { public static final int op_noexcept = 17; /** - * For GCC parsers, only. {@code op_labelReference} is used for &&label type expressions. + * For GCC parsers, only. {@code op_labelReference} is used for &&label type expressions. * @since 5.8 */ public static final int op_labelReference = 18; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTAliasDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTAliasDeclaration.java index 723dcff8829..130f657c172 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTAliasDeclaration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTAliasDeclaration.java @@ -38,7 +38,7 @@ public interface ICPPASTAliasDeclaration extends IASTDeclaration, IASTNameOwner, "ICPPASTAliasDeclaration.ALIAS_NAME - Introduced alias name"); //$NON-NLS-1$ /** - * <code>MAPPING_TYPE<ID/code> represents the pre-existing type id which + * <code>MAPPING_TYPEID</code> represents the pre-existing type id which * the new symbol aliases. */ public static final ASTNodeProperty TARGET_TYPEID = new ASTNodeProperty( diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTCastExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTCastExpression.java index 7f276883075..e095152ccf7 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTCastExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTCastExpression.java @@ -23,22 +23,22 @@ import org.eclipse.cdt.core.dom.ast.IASTCastExpression; */ public interface ICPPASTCastExpression extends IASTCastExpression, ICPPASTExpression { /** - * <code>op_dynamic_cast</code> is used for dynamic_cast<>'s. + * <code>op_dynamic_cast</code> is used for dynamic_cast<>'s. */ public static final int op_dynamic_cast = IASTCastExpression.op_last + 1; /** - * <code>op_static_cast</code> is used for static_cast<>'s. + * <code>op_static_cast</code> is used for static_cast<>'s. */ public static final int op_static_cast = IASTCastExpression.op_last + 2; /** - * <oode>op_reinterpret_cast</code> is used for reinterpret_cast<>'s. + * <oode>op_reinterpret_cast</code> is used for reinterpret_cast<>'s. */ public static final int op_reinterpret_cast = IASTCastExpression.op_last + 3; /** - * <code>op_const_cast</code> is used for const_cast<>'s. + * <code>op_const_cast</code> is used for const_cast<>'s. */ public static final int op_const_cast = IASTCastExpression.op_last + 4; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTDeductionGuide.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTDeductionGuide.java deleted file mode 100644 index 5aa81170753..00000000000 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTDeductionGuide.java +++ /dev/null @@ -1,99 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2018, Institute for Software 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: - * Felix Morgner - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.core.dom.ast.cpp; - -import org.eclipse.cdt.core.dom.ast.ASTNodeProperty; -import org.eclipse.cdt.core.dom.ast.IASTDeclaration; -import org.eclipse.cdt.core.dom.ast.IASTName; - -/** - * A C++ class-template argument deduction guide - * <p> - * e.g: - * - * <pre> - * SomeTemplateName(int) -> SomeTemplateName<float>; - * - * template<typename I> - * SomeTemplateName(I, I) -> SomeTemplateName<typename std::iterator_traits<I>::value_type>; - * </pre> - * </p> - * - * @noimplement This interface is not intended to be implemented by clients. - * @noextend This interface is not intended to be extended by clients. - * @since 7.0 - */ -public interface ICPPASTDeductionGuide extends IASTDeclaration, ICPPASTParameterListOwner { - - /** - * <code>TEMPLATE_NAME</code> represents the relationship between an - * <code>ICPPASTDeductionGuide</code> and it's nested - * <code>IASTName</code>. - */ - static final ASTNodeProperty TEMPLATE_NAME = new ASTNodeProperty( - "ICPPASTDeductionGuide.TEMPLATE_NAME - IASTName for ICPPASTDeductionGuide"); //$NON-NLS-1$ - - /** - * <code>TEMPLATE_ID</code> represents the relationship between an - * <code>ICPPASTDeductionGuide</code> and it's nested - * <code>ICPPASTTemplateId</code>. - */ - static final ASTNodeProperty TEMPLATE_ID = new ASTNodeProperty( - "ICPPASTDeductionGuide.TEMPLATE_ID - ICPPASTTemplateId for ICPPASTDeductionGuide"); //$NON-NLS-1$ - - /** - * <code>PARAMETER</code> represents the relationship between an - * <code>ICPPASTDeductionGuide</code> and it's nested - * <code>IASTParameterDeclaration</code>. - */ - public final static ASTNodeProperty PARAMETER = new ASTNodeProperty( - "ICPPASTDeductionGuide.PARAMETER - IASTParameterDeclaration for ICPPASTDeductionGuide"); //$NON-NLS-1$ - - /** - * Check if the deduction guide was declared as 'explicit'. - */ - boolean isExplicit(); - - /** - * Set whether or not the deduction guide is marked explicit - */ - void setExplicit(boolean isExplict); - - /** - * Get the name of the template type the deduction guide refers to - */ - IASTName getTemplateName(); - - /** - * Set the name of the template type the deduction guide refers to - */ - void setTemplateName(IASTName name); - - /** - * Get the template id of the deduction guide - */ - ICPPASTTemplateId getSimpleTemplateId(); - - /** - * Set the template id of the deduction guide - */ - void setSimpleTemplateId(ICPPASTTemplateId id); - - @Override - public ICPPASTDeductionGuide copy(); - - @Override - public ICPPASTDeductionGuide copy(CopyStyle style); - -} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionDeclarator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionDeclarator.java index 6439663bb7b..ca4304ce84c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionDeclarator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionDeclarator.java @@ -29,8 +29,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation; * @noimplement This interface is not intended to be implemented by clients. * @noextend This interface is not intended to be extended by clients. */ -public interface ICPPASTFunctionDeclarator - extends IASTStandardFunctionDeclarator, ICPPASTDeclarator, ICPPASTParameterListOwner { +public interface ICPPASTFunctionDeclarator extends IASTStandardFunctionDeclarator, ICPPASTDeclarator { /** * @since 5.9 */ @@ -183,13 +182,13 @@ public interface ICPPASTFunctionDeclarator public void setNoexceptExpression(ICPPASTExpression expression); /** - * Returns the trailing return type as in <code> auto f() -> int </code>, or <code>null</code>. + * Returns the trailing return type as in <code> auto f() -gt; int </code>, or <code>null</code>. * @since 5.2 */ public IASTTypeId getTrailingReturnType(); /** - * Trailing return type as in <code> auto f() -> int </code>. + * Trailing return type as in <code> auto f() -> int </code>. * @since 5.2 */ public void setTrailingReturnType(IASTTypeId typeId); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTParameterListOwner.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTParameterListOwner.java deleted file mode 100644 index a5106773295..00000000000 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTParameterListOwner.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2018, Institute for Software and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Felix Morgner - initial API and implementation - *******************************************************************************/ - -package org.eclipse.cdt.core.dom.ast.cpp; - -import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration; - -/** - * Internal interface to describe the ability of having a parameter list - * @since 7.0 - */ -public interface ICPPASTParameterListOwner { - - /** - * Add a parameter to the parameter list of the parameter list owner. - */ - public void addParameterDeclaration(IASTParameterDeclaration parameter); - - /** - * Gets the parameter declarations for the parameter list owner - */ - public IASTParameterDeclaration[] getParameters(); - - /** - * Set whether or not the parameter list owner takes a variable number of - * arguments. - */ - public void setVarArgs(boolean value); - - /** - * Check if the parameter list owner takes a variable number of arguments. - */ - public boolean takesVarArgs(); -} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTReferenceOperator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTReferenceOperator.java index fb667e08eb3..4943f4684ae 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTReferenceOperator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTReferenceOperator.java @@ -17,14 +17,14 @@ package org.eclipse.cdt.core.dom.ast.cpp; import org.eclipse.cdt.core.dom.ast.IASTPointerOperator; /** - * This is C++'s reference operator, i.e. &, used in a declarator. + * This is C++'s reference operator, i.e. &, used in a declarator. * * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPASTReferenceOperator extends IASTPointerOperator { /** - * Returns whether the operator denotes a rvalue reference (e.g. <code>int &&</code>). + * Returns whether the operator denotes a rvalue reference (e.g. <code>int &&</code>). * @since 5.2 */ public boolean isRValueReference(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTStructuredBindingDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTStructuredBindingDeclaration.java index 8eff34af474..ff6b95412ff 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTStructuredBindingDeclaration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTStructuredBindingDeclaration.java @@ -32,8 +32,8 @@ import org.eclipse.jdt.annotation.Nullable; * Examples: * <ul> * <li><code>auto [x, y]{coordinate};</code></li> - * <li><code>auto & [x, y](coordinate);</code></li> - * <li><code>auto && [x, y] = createCoordinte();</code></li> + * <li><code>auto & [x, y](coordinate);</code></li> + * <li><code>auto && [x, y] = createCoordinte();</code></li> * </ul> * * @since 6.9 @@ -64,8 +64,8 @@ public interface ICPPASTStructuredBindingDeclaration * Examples: * <ul> * <li>For <code>auto [x, y] = coordinate;</code> it returns the empty <code>Optional</code></li> - * <li>For <code>auto & [x, y] = coordinate;</code> it returns <code>Optional.of(RefQualifier.LVALUE)</code></li> - * <li>For <code>auto && [x, y] = createCoordinte();</code> it returns <code>Optional.of(RefQualifier.RVALUE)</code></li> + * <li>For <code>auto & [x, y] = coordinate;</code> it returns <code>Optional.of(RefQualifier.LVALUE)</code></li> + * <li>For <code>auto && [x, y] = createCoordinte();</code> it returns <code>Optional.of(RefQualifier.RVALUE)</code></li> * </ul> * * @return The returned <code>RefQualifier</code> of the C++ declaration or <code>null</code> if there is no reference qualifier. @@ -78,7 +78,7 @@ public interface ICPPASTStructuredBindingDeclaration /** * Returns the list of names declared by this structured binding declaration. * <p> - * Example: For <code>auto & [x, y] = coordinate;</code> it returns the names <code>x</code> and <code>y</code>. + * Example: For <code>auto & [x, y] = coordinate;</code> it returns the names <code>x</code> and <code>y</code>. * * @return All declared names of the structured binding as<code>IASTName[]</code> * @see IASTName @@ -93,8 +93,8 @@ public interface ICPPASTStructuredBindingDeclaration * * Examples: * <ul> * <li>For <code>auto [x, y]{coordinate};</code> it returns an <code>ICPPASTInitializerList</code></li> - * <li>For <code>auto & [x, y](coordinate);</code> it returns an <code>ICPPASTConstructorInitializer</code></li> - * <li>For <code>auto && [x, y] = createCoordinte();</code> it returns an <code>IASTEqualsInitializer</code></li> + * <li>For <code>auto & [x, y](coordinate);</code> it returns an <code>ICPPASTConstructorInitializer</code></li> + * <li>For <code>auto && [x, y] = createCoordinte();</code> it returns an <code>IASTEqualsInitializer</code></li> * </ul> * * @return The <code>IASTInitializer</code> of this structured binding. It can be <code>null</code> if the C++ declaration is lacking an initializer. diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTemplatedTypeTemplateParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTemplatedTypeTemplateParameter.java index 6d0d382ec0a..815f040651f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTemplatedTypeTemplateParameter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTemplatedTypeTemplateParameter.java @@ -21,7 +21,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNameOwner; /** * This is a template template parameter as <code> V </code> in - * <code>template<template<typename T> class V> class CT;</code> + * <code>template<template<typename T> class V> class CT;</code> * * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPClassTemplatePartialSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPClassTemplatePartialSpecialization.java index e2413572319..d543fbe93b2 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPClassTemplatePartialSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPClassTemplatePartialSpecialization.java @@ -19,8 +19,8 @@ package org.eclipse.cdt.core.dom.ast.cpp; * a class template in its own right. * * E.g.: - * template <class T> class A {}; // the primary class template - * template <class T> class A<T*> {}; // a partial specialization of the primary class template + * template <class T> class A {}; // the primary class template + * template <class T> class A<T*> {}; // a partial specialization of the primary class template * * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPReferenceType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPReferenceType.java index 76f2c6148cf..b9be8aa5211 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPReferenceType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPReferenceType.java @@ -27,7 +27,7 @@ public interface ICPPReferenceType extends IType { public IType getType(); /** - * Returns whether this is an rvalue reference (e.g: int&&) + * Returns whether this is an rvalue reference (e.g: int&&) * @since 5.2 */ public boolean isRValueReference(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/IGNUASTGotoStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/IGNUASTGotoStatement.java index 8ffd30eafcd..84f45b48ed4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/IGNUASTGotoStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/IGNUASTGotoStatement.java @@ -23,7 +23,7 @@ import org.eclipse.cdt.core.dom.ast.IASTStatement; * * <code> * foo: - * void *labelPtr = &&foo; + * void *labelPtr = &&foo; * goto *labelPtr; * </code> * diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/c/ICASTKnRFunctionDeclarator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/c/ICASTKnRFunctionDeclarator.java index 2d1f46dca31..b198908968b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/c/ICASTKnRFunctionDeclarator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/c/ICASTKnRFunctionDeclarator.java @@ -20,14 +20,14 @@ import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator; import org.eclipse.cdt.core.dom.ast.IASTName; /** - * This is the declarator for a K&R C Function. + * This is the declarator for a K&R C Function. * * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. */ public interface ICASTKnRFunctionDeclarator extends IASTFunctionDeclarator { /** - * <code>PARAMETER_NAME</code> refers to the names qualified in a K&R C + * <code>PARAMETER_NAME</code> refers to the names qualified in a K&R C * function definition. */ public static final ASTNodeProperty PARAMETER_NAME = new ASTNodeProperty( @@ -35,7 +35,7 @@ public interface ICASTKnRFunctionDeclarator extends IASTFunctionDeclarator { /** * <code>FUNCTION_PARAMETER</code> represents the relationship between an - * K&R function declarator and the full parameter declarations. + * K&R function declarator and the full parameter declarations. */ public static final ASTNodeProperty FUNCTION_PARAMETER = new ASTNodeProperty( "ICASTKnRFunctionDeclarator.FUNCTION_PARAMETER - Full K&R Parameter Declaration"); //$NON-NLS-1$ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/IGPPASTBinaryExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/IGPPASTBinaryExpression.java index cc33507d0e4..6f08087359f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/IGPPASTBinaryExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/IGPPASTBinaryExpression.java @@ -24,12 +24,12 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTBinaryExpression; */ public interface IGPPASTBinaryExpression extends ICPPASTBinaryExpression { /** - * <code>op_max</code> represents >? + * <code>op_max</code> represents >? */ public static final int op_max = IASTBinaryExpression.op_max; /** - * <code>op_min</code> represents <? + * <code>op_min</code> represents <? */ public static final int op_min = IASTBinaryExpression.op_min; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/AbstractScannerExtensionConfiguration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/AbstractScannerExtensionConfiguration.java index 810288e77af..61d4860740f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/AbstractScannerExtensionConfiguration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/AbstractScannerExtensionConfiguration.java @@ -155,7 +155,7 @@ public abstract class AbstractScannerExtensionConfiguration implements IScannerE * The macro can either be of object- or of function-style. * <pre> * Example: - * addMacro("max(a,b)", "(((a)>(b) ? (a) : (b))"); + * addMacro("max(a,b)", "(((a)>(b) ? (a) : (b))"); * </pre> * @param signature the signature of the macro, see {@link IMacro#getSignature()}. * @param value the macro value diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/GNUScannerExtensionConfiguration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/GNUScannerExtensionConfiguration.java index 212cf1e4c62..f168e395577 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/GNUScannerExtensionConfiguration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/GNUScannerExtensionConfiguration.java @@ -51,6 +51,8 @@ public abstract class GNUScannerExtensionConfiguration extends AbstractScannerEx addMacro("__builtin_va_arg(ap,type)", "*(typeof(type) *)ap"); addMacro("__builtin_types_compatible_p(x,y)", "__builtin_types_compatible_p(sizeof(x),sizeof(y))"); addMacro("__offsetof__(x)", "(x)"); + addMacro("__has_include", ""); + addMacro("__has_include_next", ""); addPreprocessorKeyword(Keywords.cINCLUDE_NEXT, IPreprocessorDirective.ppInclude_next); addPreprocessorKeyword(Keywords.cIMPORT, IPreprocessorDirective.ppImport); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/c/GCCScannerExtensionConfiguration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/c/GCCScannerExtensionConfiguration.java index be5fcebaa0e..cf84e29ebfb 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/c/GCCScannerExtensionConfiguration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/c/GCCScannerExtensionConfiguration.java @@ -56,6 +56,7 @@ public class GCCScannerExtensionConfiguration extends GNUScannerExtensionConfigu String mscVer = definedSymbols.get("_MSC_VER"); //$NON-NLS-1$ if (mscVer != null && Integer.valueOf(mscVer) > 0) { + // Note: this is also used for clang-cl. return CONFIG_MSVC; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/c/ICParserExtensionConfiguration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/c/ICParserExtensionConfiguration.java index 132722b448e..0a66ebee486 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/c/ICParserExtensionConfiguration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/c/ICParserExtensionConfiguration.java @@ -67,9 +67,9 @@ public interface ICParserExtensionConfiguration { public boolean supportAlignOfUnaryExpression(); /** - * Support for Kernighan and Richie (K&R) C. + * Support for Kernighan and Richie (K&R) C. * - * @return <code>true</code> if support for K&R C should be enabled + * @return <code>true</code> if support for K&R C should be enabled */ public boolean supportKnRC(); @@ -101,7 +101,7 @@ public interface ICParserExtensionConfiguration { /** * Skips information in brackets provided at the beginning of a parameter declaration: * <br> - * void accelerate([proc=marsh] const Speed &data); + * void accelerate([proc=marsh] const Speed &data); * @since 5.1 */ public boolean supportParameterInfoBlock(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/GPPScannerExtensionConfiguration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/GPPScannerExtensionConfiguration.java index b113e67ba71..08c71bf393a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/GPPScannerExtensionConfiguration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/GPPScannerExtensionConfiguration.java @@ -32,7 +32,7 @@ import org.eclipse.cdt.core.parser.Keywords; */ public class GPPScannerExtensionConfiguration extends GNUScannerExtensionConfiguration { private static enum CompilerType { - GCC, Clang, MSVC + GCC, Clang, ClangCl, MSVC } private static final int VERSION_4_2 = version(4, 2); @@ -40,16 +40,22 @@ public class GPPScannerExtensionConfiguration extends GNUScannerExtensionConfigu private static final int VERSION_4_6 = version(4, 6); private static final int VERSION_4_7 = version(4, 7); private static final int VERSION_5_0 = version(5, 0); + private static final int VERSION_6_0 = version(6, 0); private static final int VERSION_8_0 = version(8, 0); + private static final int VERSION_10_0 = version(10, 0); private static GPPScannerExtensionConfiguration CONFIG = new GPPScannerExtensionConfiguration(); private static GPPScannerExtensionConfiguration CONFIG_4_2 = new GPPScannerExtensionConfiguration(VERSION_4_2); private static GPPScannerExtensionConfiguration CONFIG_4_3 = new GPPScannerExtensionConfiguration(VERSION_4_3); private static GPPScannerExtensionConfiguration CONFIG_4_6 = new GPPScannerExtensionConfiguration(VERSION_4_6); private static GPPScannerExtensionConfiguration CONFIG_4_7 = new GPPScannerExtensionConfiguration(VERSION_4_7); private static GPPScannerExtensionConfiguration CONFIG_5_0 = new GPPScannerExtensionConfiguration(VERSION_5_0); + private static GPPScannerExtensionConfiguration CONFIG_6_0 = new GPPScannerExtensionConfiguration(VERSION_6_0); private static GPPScannerExtensionConfiguration CONFIG_8_0 = new GPPScannerExtensionConfiguration(VERSION_8_0); + private static GPPScannerExtensionConfiguration CONFIG_10_0 = new GPPScannerExtensionConfiguration(VERSION_10_0); private static GPPScannerExtensionConfiguration CONFIG_CLANG = new GPPScannerExtensionConfiguration( CompilerType.Clang, 0 /* version is ignored for now */); + private static GPPScannerExtensionConfiguration CONFIG_CLANG_CL = new GPPScannerExtensionConfiguration( + CompilerType.ClangCl, 0 /* version is ignored for now */); private static GPPScannerExtensionConfiguration CONFIG_MSVC = new GPPScannerExtensionConfiguration( CompilerType.MSVC, 0 /* version is ignored for now */); @@ -65,14 +71,17 @@ public class GPPScannerExtensionConfiguration extends GNUScannerExtensionConfigu try { final Map<String, String> definedSymbols = info.getDefinedSymbols(); - // Clang. Needs to be checked first since it pretends to be GCC too. + // Clang. Needs to be checked first since it pretends to be GCC and MSVC too. String clang = definedSymbols.get("__clang__"); //$NON-NLS-1$ + String mscVer = definedSymbols.get("_MSC_VER"); //$NON-NLS-1$ + boolean hasMsc = mscVer != null && Integer.valueOf(mscVer) > 0; if (clang != null && Integer.valueOf(clang) > 0) { + if (hasMsc) + return CONFIG_CLANG_CL; return CONFIG_CLANG; } - String mscVer = definedSymbols.get("_MSC_VER"); //$NON-NLS-1$ - if (mscVer != null && Integer.valueOf(mscVer) > 0) { + if (hasMsc) { return CONFIG_MSVC; } @@ -80,9 +89,15 @@ public class GPPScannerExtensionConfiguration extends GNUScannerExtensionConfigu int major = Integer.valueOf(definedSymbols.get("__GNUC__")); //$NON-NLS-1$ int minor = Integer.valueOf(definedSymbols.get("__GNUC_MINOR__")); //$NON-NLS-1$ int version = version(major, minor); + if (version >= VERSION_10_0) { + return CONFIG_10_0; + } if (version >= VERSION_8_0) { return CONFIG_8_0; } + if (version >= VERSION_6_0) { + return CONFIG_6_0; + } if (version >= VERSION_5_0) { return CONFIG_5_0; } @@ -127,7 +142,7 @@ public class GPPScannerExtensionConfiguration extends GNUScannerExtensionConfigu addKeyword(Keywords.c_COMPLEX, IToken.t__Complex); addKeyword(Keywords.c_IMAGINARY, IToken.t__Imaginary); - if (compiler != CompilerType.MSVC) { + if (!(compiler == CompilerType.MSVC || compiler == CompilerType.ClangCl)) { // MSVC only defines this when compiling in C mode and /Za is used. addMacro("__STDC__", "1"); } @@ -173,36 +188,90 @@ public class GPPScannerExtensionConfiguration extends GNUScannerExtensionConfigu addKeyword(GCCKeywords.cp__is_trivially_constructible, IGCCToken.tTT_is_trivially_constructible); addKeyword(GCCKeywords.cp__is_trivially_assignable, IGCCToken.tTT_is_trivially_assignable); } + if (version >= VERSION_6_0) { + addKeyword(GCCKeywords.cp__is_same_as, IGCCToken.tTT_is_same); + } if (version >= VERSION_8_0) { addKeyword(GCCKeywords.cp__is_constructible, IGCCToken.tTT_is_constructible); addKeyword(GCCKeywords.cp__integer_pack, IGCCToken.tTT_integer_pack); } - } else if (compiler == CompilerType.Clang) { + if (version >= VERSION_10_0) { + addKeyword(GCCKeywords.cp__is_same, IGCCToken.tTT_is_same); + } + } else if (compiler == CompilerType.Clang || compiler == CompilerType.ClangCl) { // As documented at // http://clang.llvm.org/docs/LanguageExtensions.html#checks-for-type-trait-primitives. // For now we don't make it dependent on the version. + // Missing ones are in comments addKeyword(GCCKeywords.cp__has_nothrow_assign, IGCCToken.tTT_has_nothrow_assign); - addKeyword(GCCKeywords.cp__has_nothrow_constructor, IGCCToken.tTT_has_nothrow_constructor); + // __has_nothrow_move_assign addKeyword(GCCKeywords.cp__has_nothrow_copy, IGCCToken.tTT_has_nothrow_copy); + addKeyword(GCCKeywords.cp__has_nothrow_constructor, IGCCToken.tTT_has_nothrow_constructor); addKeyword(GCCKeywords.cp__has_trivial_assign, IGCCToken.tTT_has_trivial_assign); - addKeyword(GCCKeywords.cp__has_trivial_constructor, IGCCToken.tTT_has_trivial_constructor); + // __has_trivial_move_assign addKeyword(GCCKeywords.cp__has_trivial_copy, IGCCToken.tTT_has_trivial_copy); + addKeyword(GCCKeywords.cp__has_trivial_constructor, IGCCToken.tTT_has_trivial_constructor); addKeyword(GCCKeywords.cp__has_trivial_destructor, IGCCToken.tTT_has_trivial_destructor); + // __has_unique_object_representations addKeyword(GCCKeywords.cp__has_virtual_destructor, IGCCToken.tTT_has_virtual_destructor); addKeyword(GCCKeywords.cp__is_abstract, IGCCToken.tTT_is_abstract); + // __is_aggregate + // __is_arithmetic + // __is_array + // __is_assignable addKeyword(GCCKeywords.cp__is_base_of, IGCCToken.tTT_is_base_of); addKeyword(GCCKeywords.cp__is_class, IGCCToken.tTT_is_class); + // __is_complete_type + // __is_compound + // __is_const + addKeyword(GCCKeywords.cp__is_constructible, IGCCToken.tTT_is_constructible); + // __is_convertible + // __is_convertible_to + // __is_destructible addKeyword(GCCKeywords.cp__is_empty, IGCCToken.tTT_is_empty); addKeyword(GCCKeywords.cp__is_enum, IGCCToken.tTT_is_enum); + addKeyword(GCCKeywords.cp__is_final, IGCCToken.tTT_is_final); + // __is_floating_point + // __is_function + // __is_fundamental + // __is_integral + // __is_interface_class + addKeyword(GCCKeywords.cp__is_literal, IGCCToken.tTT_is_literal_type); + addKeyword(GCCKeywords.cp__is_literal_type, IGCCToken.tTT_is_literal_type); + // __is_lvalue_reference + // __is_member_object_pointer + // __is_member_function_pointer + // __is_member_pointer + // __is_nothrow_assignable + // __is_nothrow_constructible + // __is_nothrow_destructible + // __is_object addKeyword(GCCKeywords.cp__is_pod, IGCCToken.tTT_is_pod); + // __is_pointer addKeyword(GCCKeywords.cp__is_polymorphic, IGCCToken.tTT_is_polymorphic); + // __is_reference + // __is_rvalue_reference + addKeyword(GCCKeywords.cp__is_same, IGCCToken.tTT_is_same); + addKeyword(GCCKeywords.cp__is_same_as, IGCCToken.tTT_is_same); + // __is_scalar + // __is_sealed + // __is_signed + addKeyword(GCCKeywords.cp__is_standard_layout, IGCCToken.tTT_is_standard_layout); + addKeyword(GCCKeywords.cp__is_trivial, IGCCToken.tTT_is_trivial); + addKeyword(GCCKeywords.cp__is_trivially_assignable, IGCCToken.tTT_is_trivially_assignable); + addKeyword(GCCKeywords.cp__is_trivially_constructible, IGCCToken.tTT_is_trivially_constructible); + addKeyword(GCCKeywords.cp__is_trivially_copyable, IGCCToken.tTT_is_trivially_copyable); + // __is_trivially_destructible addKeyword(GCCKeywords.cp__is_union, IGCCToken.tTT_is_union); - addKeyword(GCCKeywords.cp__is_final, IGCCToken.tTT_is_final); + // __is_unsigned + // __is_void + // __reference_binds_to_temporary addKeyword(GCCKeywords.cp__underlying_type, IGCCToken.tTT_underlying_type); - addKeyword(GCCKeywords.cp__is_trivially_constructible, IGCCToken.tTT_is_trivially_constructible); - addKeyword(GCCKeywords.cp__is_trivially_assignable, IGCCToken.tTT_is_trivially_assignable); - addKeyword(GCCKeywords.cp__is_constructible, IGCCToken.tTT_is_constructible); addKeyword(GCCKeywords.cp__integer_pack, IGCCToken.tTT_integer_pack); + + addKeyword(GCCKeywords.cp__float128, IGCCToken.t__float128); + addKeyword(GCCKeywords.cp__int128, IGCCToken.t__int128); + //TODO verify other gcc ones } else if (compiler == CompilerType.MSVC) { // As documented at // https://docs.microsoft.com/en-us/cpp/extensions/compiler-support-for-type-traits-cpp-component-extensions?view=vs-2017 diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/ICPPParserExtensionConfiguration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/ICPPParserExtensionConfiguration.java index 4694648664d..6865ec253c4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/ICPPParserExtensionConfiguration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/ICPPParserExtensionConfiguration.java @@ -92,9 +92,9 @@ public interface ICPPParserExtensionConfiguration { public boolean supportAlignOfUnaryExpression(); /** - * Support for Kernighan and Richie (K&R) C. + * Support for Kernighan and Richie (K&R) C. * - * @return {@code true} if support for K&R C should be enabled + * @return {@code true} if support for K&R C should be enabled */ public boolean supportKnRC(); @@ -123,7 +123,7 @@ public interface ICPPParserExtensionConfiguration { /** * Skips information in brackets provided at the beginning of a parameter declaration: * <br> - * void accelerate([proc=marsh] const Speed &data); + * void accelerate([proc=marsh] const Speed &data); * @since 5.1 */ public boolean supportParameterInfoBlock(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/rewrite/MacroExpansionExplorer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/rewrite/MacroExpansionExplorer.java index eb404c83eca..0b97e11e9f9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/rewrite/MacroExpansionExplorer.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/rewrite/MacroExpansionExplorer.java @@ -88,7 +88,7 @@ public abstract class MacroExpansionExplorer { /** * Returns a description for the requested step within the expansion of the region of this * expansion explorer. - * @throws IndexOutOfBoundsException if step < 0 or step >= getExpansionStepCount(). + * @throws IndexOutOfBoundsException if step < 0 or step >= getExpansionStepCount(). */ public abstract IMacroExpansionStep getExpansionStep(int step) throws IndexOutOfBoundsException; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/export/AbstractExportProjectProvider.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/export/AbstractExportProjectProvider.java index 42c97a279b6..ce70474f8d0 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/export/AbstractExportProjectProvider.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/export/AbstractExportProjectProvider.java @@ -61,7 +61,7 @@ public abstract class AbstractExportProjectProvider implements IExportProjectPro * Returns a mapping from string option to parameter string list * <br> * For example, if -option p1 p2 p3 appears on the command line, then - * the mapping option=>[p1,p2,p3] will be present in the map + * the mapping option=>[p1,p2,p3] will be present in the map * @return a mapping from string option to parameter string list */ protected Map<String, List<String>> getParsedArgs() { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/GCCKeywords.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/GCCKeywords.java index 207ef6d89d9..b7374946fce 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/GCCKeywords.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/GCCKeywords.java @@ -93,4 +93,15 @@ public class GCCKeywords { /** @since 6.11*/ public static final char[] cp__integer_pack = "__integer_pack".toCharArray(); + + /** + * This is actually for Clang but we don't maintain separate keywords right now. + * @since 7.1 + */ + public static final char[] cp__is_literal = "__is_literal".toCharArray(); + + /** + * @since 7.1 + */ + public static final char[] cp__is_same = "__is_same".toCharArray(), cp__is_same_as = "__is_same_as".toCharArray(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IGCCToken.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IGCCToken.java index 62033d7c35c..61dd350c9e6 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IGCCToken.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IGCCToken.java @@ -96,4 +96,9 @@ public interface IGCCToken extends IToken { /** @since 6.11*/ int tTT_integer_pack = FIRST_RESERVED_IGCCToken + 36; + + /** + * @since 7.1 + */ + int tTT_is_same = FIRST_RESERVED_IGCCToken + 37; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IProblem.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IProblem.java index 76c6accc4a0..4ee891997fc 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IProblem.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IProblem.java @@ -123,7 +123,7 @@ public interface IProblem { * types of problems. * * @param bitmask - * @return true if ( (id & bit-mask ) != 0 ) + * @return true if ( (id & bit-mask ) != 0 ) */ public boolean checkCategory(int bitmask); @@ -346,6 +346,11 @@ public interface IProblem { */ public final static int PREPROCESSOR_MULTIPLE_USER_DEFINED_SUFFIXES_IN_CONCATENATION = PREPROCESSOR_RELATED | 0x010; + /** + * @since 7.1 + */ + public final static int PREPROCESSOR_INVALID_USE_OUTSIDE_PREPROCESSOR_DIRECTIVE = PREPROCESSOR_RELATED | 0x011; + /* * Syntax error, detected by the parser. */ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IScanner.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IScanner.java index 684e98ac6c1..025933621d1 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IScanner.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IScanner.java @@ -124,7 +124,7 @@ public interface IScanner { /** * Returns a list of additional (compiler specific) suffixes which can - * be placed on numbers. e.g. 'u' 'l' -> 1l or 1u. + * be placed on numbers. e.g. 'u' 'l' -> 1l or 1u. * * @noreference This method is not intended to be referenced by clients. */ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/Keywords.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/Keywords.java index beb29f190be..88b56e076db 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/Keywords.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/Keywords.java @@ -314,6 +314,14 @@ public class Keywords { public static final char[] cDEFINED = "defined".toCharArray(); /** @since 5.11 */ public static final char[] c__HAS_FEATURE = "__has_feature".toCharArray(); + /** + * @since 7.1 + */ + public static final char[] c__HAS_INCLUDE = "__has_include".toCharArray(); + /** + * @since 7.1 + */ + public static final char[] c__HAS_INCLUDE_NEXT = "__has_include_next".toCharArray(); /** @since 5.2*/ public static final char[] _Pragma = "_Pragma".toCharArray(); public static final char[] cVA_ARGS = "__VA_ARGS__".toCharArray(); 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/parser/org/eclipse/cdt/core/parser/util/ArrayUtil.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/ArrayUtil.java index f1262a972f3..7d561deb2f6 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/ArrayUtil.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/ArrayUtil.java @@ -352,7 +352,7 @@ public abstract class ArrayUtil { /** * Adds all elements of an array to a collection. For an {@link ArrayList} this method is - * slightly more efficient than {@link java.util.Collections#addAll(Collection, T...)}. + * slightly more efficient than {@link java.util.Collections#addAll(Collection, Object...)}. * @since 5.4 */ @SafeVarargs diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/CharArrayObjectMap.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/CharArrayObjectMap.java index de61b078028..78a91a67d0e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/CharArrayObjectMap.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/CharArrayObjectMap.java @@ -33,7 +33,7 @@ public class CharArrayObjectMap<T> extends CharTable { /** * An empty immutable {@code CharArrayObjectMap}. */ - public static final CharArrayObjectMap<?> EMPTY_MAP = new CharArrayObjectMap<Object>(0) { + public static final CharArrayObjectMap<?> EMPTY_MAP = new CharArrayObjectMap<>(0) { @Override public Object clone() { return this; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/CollectionUtils.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/CollectionUtils.java index 850435cb8ad..a7e968a3197 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/CollectionUtils.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/CollectionUtils.java @@ -41,7 +41,7 @@ public final class CollectionUtils { * @throws NullPointerException if list is {@code null} */ public static <T> Iterator<T> reverseIterator(final List<T> list) { - return new Iterator<T>() { + return new Iterator<>() { ListIterator<T> iterator = list.listIterator(list.size()); @Override @@ -93,7 +93,7 @@ public final class CollectionUtils { if (iter == null) throw new NullPointerException("iter parameter is null"); //$NON-NLS-1$ - return new Iterable<T>() { + return new Iterable<>() { @Override public Iterator<T> iterator() { return iter; @@ -145,7 +145,7 @@ public final class CollectionUtils { } /** - * Returns a List<U> corresponding to a T in a Map<T, List<U>>. If the mapping doesn't exist, + * Returns a List<U> corresponding to a T in a Map<T, List<U>>. If the mapping doesn't exist, * creates it with an empty list as the initial value. * @since 5.6 */ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/ObjectTable.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/ObjectTable.java index 331aa7ba873..3a2205c28f0 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/ObjectTable.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/ObjectTable.java @@ -174,7 +174,7 @@ public abstract class ObjectTable<T> extends HashTable implements Iterable<T> { */ @Override public Iterator<T> iterator() { - return new Iterator<T>() { + return new Iterator<>() { int nextIndex; @Override diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTProblem.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTProblem.java index 17518bba0e5..5746be46fc1 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTProblem.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTProblem.java @@ -97,6 +97,8 @@ public class ASTProblem extends ASTNode implements IASTProblem { ParserMessages.getString("ScannerProblemFactory.error.scanner.floatWithBadPrefix")); //$NON-NLS-1$ errorMessages.put(Integer.valueOf(PREPROCESSOR_MULTIPLE_USER_DEFINED_SUFFIXES_IN_CONCATENATION), ParserMessages .getString("ScannerProblemFactory.error.preproc.multipleUserDefinedLiteralSuffixesOnStringLiteral")); //$NON-NLS-1$ + errorMessages.put(Integer.valueOf(PREPROCESSOR_INVALID_USE_OUTSIDE_PREPROCESSOR_DIRECTIVE), + ParserMessages.getString("ScannerProblemFactory.error.preproc.invalidUsageOutsidePreprocDirective")); //$NON-NLS-1$ errorMessages.put(Integer.valueOf(SYNTAX_ERROR), ParserMessages.getString("ParserProblemFactory.error.syntax.syntaxError")); //$NON-NLS-1$ errorMessages.put(Integer.valueOf(MISSING_SEMICOLON), diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTTranslationUnit.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTTranslationUnit.java index 1e7b1d279b9..158d2b515c3 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTTranslationUnit.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTTranslationUnit.java @@ -95,13 +95,13 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat private IBuiltinBindingsProvider fBuiltinBindingsProvider; // Caches - private final ThreadLocal<WeakHashMap<IType, String>> fUnnormalizedTypeStringCache = new ThreadLocal<WeakHashMap<IType, String>>() { + private final ThreadLocal<WeakHashMap<IType, String>> fUnnormalizedTypeStringCache = new ThreadLocal<>() { @Override protected WeakHashMap<IType, String> initialValue() { return new WeakHashMap<>(); } }; - private final ThreadLocal<WeakHashMap<IType, String>> fNormalizedTypeStringCache = new ThreadLocal<WeakHashMap<IType, String>>() { + private final ThreadLocal<WeakHashMap<IType, String>> fNormalizedTypeStringCache = new ThreadLocal<>() { @Override protected WeakHashMap<IType, String> initialValue() { return new WeakHashMap<>(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java index 9698bfac8e5..58e28e2f276 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java @@ -2816,6 +2816,9 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser { case IGCCToken.t__attribute__: case IGCCToken.tTT_underlying_type: + // msvc-compatibility + case IGCCToken.t__declspec: + // content assist case IToken.tCOMPLETION: return true; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/CompositeValue.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/CompositeValue.java index c3192b799f6..4c8a1eb6515 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/CompositeValue.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/CompositeValue.java @@ -160,7 +160,7 @@ public final class CompositeValue implements IValue { // The set of class types for which composite value creation is in progress on each thread. // Used to guard against infinite recursion due to a class (illegally) aggregating itself. - private static final ThreadLocal<Set<ICPPClassType>> fCreateInProgress = new ThreadLocal<Set<ICPPClassType>>() { + private static final ThreadLocal<Set<ICPPClassType>> fCreateInProgress = new ThreadLocal<>() { @Override protected Set<ICPPClassType> initialValue() { return new TreeSet<>((type1, type2) -> { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/DeclarationOptions.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/DeclarationOptions.java index 50376275f05..1c8285c104b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/DeclarationOptions.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/DeclarationOptions.java @@ -34,15 +34,14 @@ public class DeclarationOptions { final public static int SINGLE_DTOR = 0x4000; final public static int ALLOW_FUNCTION_DEFINITION = 0x8000; final public static int NO_COMPOSITE_SPECIFIER = 0x10000; - final public static int ALLOW_DEDUCTION_GUIDE = 0x20000; public static final DeclarationOptions GLOBAL = new DeclarationOptions( - ALLOW_EMPTY_SPECIFIER | ALLOW_OPAQUE_ENUM | ALLOW_FUNCTION_DEFINITION | ALLOW_DEDUCTION_GUIDE), + ALLOW_EMPTY_SPECIFIER | ALLOW_OPAQUE_ENUM | ALLOW_FUNCTION_DEFINITION), FUNCTION_STYLE_ASM = new DeclarationOptions( ALLOW_EMPTY_SPECIFIER | NO_INITIALIZER | ALLOW_ABSTRACT | ALLOW_FUNCTION_DEFINITION), C_MEMBER = new DeclarationOptions(ALLOW_BITFIELD | ALLOW_ABSTRACT), CPP_MEMBER = new DeclarationOptions(ALLOW_EMPTY_SPECIFIER | ALLOW_BITFIELD | ALLOW_OPAQUE_ENUM - | NO_CTOR_STYLE_INITIALIZER | ALLOW_FUNCTION_DEFINITION | ALLOW_DEDUCTION_GUIDE), + | NO_CTOR_STYLE_INITIALIZER | ALLOW_FUNCTION_DEFINITION), LOCAL = new DeclarationOptions(ALLOW_OPAQUE_ENUM), PARAMETER = new DeclarationOptions(ALLOW_ABSTRACT | ALLOW_PARAMETER_PACKS | REQUIRE_SIMPLE_NAME | NO_BRACED_INITIALIZER | NO_CTOR_STYLE_INITIALIZER), diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/GCCBuiltinSymbolProvider.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/GCCBuiltinSymbolProvider.java index bf2469eb5f9..407c02e1d05 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/GCCBuiltinSymbolProvider.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/GCCBuiltinSymbolProvider.java @@ -53,6 +53,8 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPImplicitTypedef; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerType; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPQualifierType; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPReferenceType; +import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPExecution; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExecBuiltin; /** * This is the IBuiltinBindingsProvider used to implement the "Other" built-in GCC symbols defined: @@ -188,9 +190,25 @@ public class GCCBuiltinSymbolProvider implements IBuiltinBindingsProvider { function("bool", "__atomic_always_lock_free", "size_t", "void*"); function("bool", "__atomic_is_lock_free", "size_t", "void*"); + ICPPExecution builtinFfs = new ExecBuiltin(ExecBuiltin.BUILTIN_FFS); + ICPPExecution builtinFfsl = new ExecBuiltin(ExecBuiltin.BUILTIN_FFSL); + ICPPExecution builtinFfsll = new ExecBuiltin(ExecBuiltin.BUILTIN_FFSLL); + ICPPExecution builtinCtz = new ExecBuiltin(ExecBuiltin.BUILTIN_CTZ); + ICPPExecution builtinCtzl = new ExecBuiltin(ExecBuiltin.BUILTIN_CTZL); + ICPPExecution builtinCtzll = new ExecBuiltin(ExecBuiltin.BUILTIN_CTZLL); + ICPPExecution builtinPopcount = new ExecBuiltin(ExecBuiltin.BUILTIN_POPCOUNT); + ICPPExecution builtinPopcountl = new ExecBuiltin(ExecBuiltin.BUILTIN_POPCOUNTL); + ICPPExecution builtinPopcountll = new ExecBuiltin(ExecBuiltin.BUILTIN_POPCOUNTLL); + ICPPExecution builtinParity = new ExecBuiltin(ExecBuiltin.BUILTIN_PARITY); + ICPPExecution builtinParityl = new ExecBuiltin(ExecBuiltin.BUILTIN_PARITYL); + ICPPExecution builtinParityll = new ExecBuiltin(ExecBuiltin.BUILTIN_PARITYLL); + ICPPExecution builtinAbs = new ExecBuiltin(ExecBuiltin.BUILTIN_ABS); + ICPPExecution builtinLabs = new ExecBuiltin(ExecBuiltin.BUILTIN_LABS); + ICPPExecution builtinLlabs = new ExecBuiltin(ExecBuiltin.BUILTIN_LLABS); + // Other Builtins (https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html) [incomplete] function("void", "__builtin_abort"); - function("int", "__builtin_abs", "int"); + function("int", "__builtin_abs", builtinAbs, "int"); function("double", "__builtin_acos", "double"); function("float", "__builtin_acosf", "float"); function("long double", "__builtin_acosl", "long double"); @@ -224,6 +242,10 @@ public class GCCBuiltinSymbolProvider implements IBuiltinBindingsProvider { function("double", "__builtin_cimag", "complex double"); function("float", "__builtin_cimagf", "complex float"); function("long double", "__builtin_cimagl", "complex long double"); + function("void", "__builtin___clear_cache", "void*", "void*"); + function("int", "__builtin_clrsb", "int"); + function("int", "__builtin_clrsbl", "long"); + function("int", "__builtin_clrsbll", "long long"); function("int", "__builtin_clz", "unsigned int"); function("int", "__builtin_clzl", "unsigned long"); function("int", "__builtin_clzll", "unsigned long long"); @@ -243,9 +265,9 @@ public class GCCBuiltinSymbolProvider implements IBuiltinBindingsProvider { function("double", "__builtin_creal", "complex double"); function("float", "__builtin_crealf", "complex float"); function("long double", "__builtin_creall", "complex long double"); - function("int", "__builtin_ctz", "unsigned int"); - function("int", "__builtin_ctzl", "unsigned long"); - function("int", "__builtin_ctzll", "unsigned long long"); + function("int", "__builtin_ctz", builtinCtz, "unsigned int"); + function("int", "__builtin_ctzl", builtinCtzl, "unsigned long"); + function("int", "__builtin_ctzll", builtinCtzll, "unsigned long long"); function("double", "__builtin_erf", "double"); function("float", "__builtin_erff", "float"); function("long double", "__builtin_erfl", "long double"); @@ -265,15 +287,17 @@ public class GCCBuiltinSymbolProvider implements IBuiltinBindingsProvider { function("float", "__builtin_expm1f", "float"); function("long double", "__builtin_expm1l", "long double"); function("long", "__builtin_expect", "long", "long"); + function("long", "__builtin_expect_with_probability", "long", "long", "double"); + function("unsigned long long int", "__builtin_extend_pointer", "void*"); function("double", "__builtin_fabs", "double"); function("float", "__builtin_fabsf", "float"); function("long double", "__builtin_fabsl", "long double"); function("double", "__builtin_fdim", "double", "double"); function("float", "__builtin_fdimf", "float", "float"); function("long double", "__builtin_fdiml", "long double", "long double"); - function("int", "__builtin_ffs", "unsigned int"); - function("int", "__builtin_ffsl", "unsigned long"); - function("int", "__builtin_ffsll", "unsigned long long"); + function("int", "__builtin_ffs", builtinFfs, "unsigned int"); + function("int", "__builtin_ffsl", builtinFfsl, "unsigned long"); + function("int", "__builtin_ffsll", builtinFfsll, "unsigned long long"); function("double", "__builtin_floor", "double"); function("float", "__builtin_floorf", "float"); function("long double", "__builtin_floorl", "long double"); @@ -295,6 +319,8 @@ public class GCCBuiltinSymbolProvider implements IBuiltinBindingsProvider { function("double", "__builtin_frexp", "double", "int*"); function("float", "__builtin_frexpf", "float", "int*"); function("long double", "__builtin_frexpl", "long double", "int*"); + function("int", "__builtin_goacc_parlevel_id", "int"); + function("int", "__builtin_goacc_parlevel_size", "int"); function("double", "__builtin_huge_val"); function("float", "__builtin_huge_valf"); function("long double", "__builtin_huge_vall"); @@ -306,8 +332,12 @@ public class GCCBuiltinSymbolProvider implements IBuiltinBindingsProvider { function("int", "__builtin_ilogbl", "long double"); function("long long", "__builtin_imaxabs", "long long"); function("double", "__builtin_inf"); + function("_Decimal32", "__builtin_infd32"); + function("_Decimal64", "__builtin_infd64"); + function("_Decimal128", "__builtin_infd128"); function("float", "__builtin_inff"); function("long double", "__builtin_infl"); + function("int", "__builtin_isinf_sign", "..."); function("bool", "__builtin_isfinite", "double"); function("bool", "__builtin_isgreater", "float", "float"); function("bool", "__builtin_isgreaterequal", "float", "float"); @@ -318,14 +348,17 @@ public class GCCBuiltinSymbolProvider implements IBuiltinBindingsProvider { function("bool", "__builtin_isnan", "double"); function("bool", "__builtin_isnormal", "double"); function("bool", "__builtin_isunordered", "float", "float"); - function("long", "__builtin_labs", "long"); + function("long", "__builtin_labs", builtinLabs, "long"); function("double", "__builtin_ldexp", "double", "int"); function("float", "__builtin_ldexpf", "float", "int"); function("long double", "__builtin_ldexpl", "long double", "int"); function("double", "__builtin_lgamma", "double"); function("float", "__builtin_lgammaf", "float"); function("long double", "__builtin_lgammal", "long double"); - function("long long", "__builtin_llabs", "long long"); + function("int", "__builtin_LINE"); //TODO: This should technically be a constant integer expression + function("const char *", "__builtin_FUNCTION"); + function("const char *", "__builtin_FILE"); + function("long long", "__builtin_llabs", builtinLlabs, "long long"); function("long long", "__builtin_llrint", "double"); function("long long", "__builtin_llrintf", "float"); function("long long", "__builtin_llrintl", "long double"); @@ -361,6 +394,9 @@ public class GCCBuiltinSymbolProvider implements IBuiltinBindingsProvider { function("void*", "__builtin_memmove", "void*", "const void*", "size_t"); // not in the manual function("void*", "__builtin_memset", "void*", "int", "size_t"); function("double", "__builtin_nan", "const char*"); + function("_Decimal32", "__builtin_nand32"); + function("_Decimal64", "__builtin_nand64"); + function("_Decimal128", "__builtin_nand128"); function("float", "__builtin_nanf", "const char*"); function("long double", "__builtin_nanl", "const char*"); function("double", "__builtin_nans", "const char*"); @@ -375,12 +411,12 @@ public class GCCBuiltinSymbolProvider implements IBuiltinBindingsProvider { function("double", "__builtin_nexttoward", "double", "long double"); function("float", "__builtin_nexttowardf", "float", "long double"); function("long double", "__builtin_nexttowardl", "long double", "long double"); - function("int", "__builtin_parity", "unsigned int"); - function("int", "__builtin_parityl", "unsigned long"); - function("int", "__builtin_parityll", "unsigned long long"); - function("int", "__builtin_popcount", "unsigned int"); - function("int", "__builtin_popcountl", "unsigned long"); - function("int", "__builtin_popcountll", "unsigned long long"); + function("int", "__builtin_parity", builtinParity, "unsigned int"); + function("int", "__builtin_parityl", builtinParityl, "unsigned long"); + function("int", "__builtin_parityll", builtinParityll, "unsigned long long"); + function("int", "__builtin_popcount", builtinPopcount, "unsigned int"); + function("int", "__builtin_popcountl", builtinPopcountl, "unsigned long"); + function("int", "__builtin_popcountll", builtinPopcountll, "unsigned long long"); function("double", "__builtin_pow", "double", "double"); function("float", "__builtin_powf", "float", "float"); function("long double", "__builtin_powl", "long double", "long double"); @@ -445,10 +481,12 @@ public class GCCBuiltinSymbolProvider implements IBuiltinBindingsProvider { function("double", "__builtin_tgamma", "double"); function("float", "__builtin_tgammaf", "float"); function("long double", "__builtin_tgammal", "long double"); + function("void", "__builtin_trap"); function("double", "__builtin_trunc", "double"); function("float", "__builtin_truncf", "float"); function("long double", "__builtin_truncl", "long double"); function("int", "__builtin_types_compatible_p", "", ""); + function("void", "__builtin_unreachable"); function("int", "__builtin_vprintf", "const char*", "va_list"); function("int", "__builtin_vscanf", "const char*", "va_list"); function("int", "__builtin_vsnprintf", "char*", "size_t", "const char*", "va_list"); @@ -481,6 +519,13 @@ public class GCCBuiltinSymbolProvider implements IBuiltinBindingsProvider { } private void function(String returnType, String name, String... parameterTypes) { + function(returnType, name, null, parameterTypes); + } + + /* + * Create a function which can possibly be constexpr-evaluated + */ + private void function(String returnType, String name, ICPPExecution exec, String... parameterTypes) { int len = parameterTypes.length; boolean varargs = len > 0 && parameterTypes[len - 1].equals("..."); if (varargs) @@ -491,14 +536,14 @@ public class GCCBuiltinSymbolProvider implements IBuiltinBindingsProvider { for (int i = 0; i < len; i++) { IType pType = toType(parameterTypes[i]); pTypes[i] = pType; - theParms[i] = fCpp ? new CPPBuiltinParameter(pType) : new CBuiltinParameter(pType); + theParms[i] = fCpp ? new CPPBuiltinParameter(pType, i) : new CBuiltinParameter(pType); } IType rt = toType(returnType); IFunctionType ft = fCpp ? new CPPFunctionType(rt, pTypes, null) : new CFunctionType(rt, pTypes); IBinding b = fCpp - ? new CPPImplicitFunction(toCharArray(name), fScope, (ICPPFunctionType) ft, (ICPPParameter[]) theParms, - false, varargs) + ? new CPPBuiltinImplicitFunction(toCharArray(name), fScope, (ICPPFunctionType) ft, + (ICPPParameter[]) theParms, varargs, exec) : new CImplicitFunction(toCharArray(name), fScope, ft, theParms, varargs); fBindingList.add(b); } @@ -591,6 +636,15 @@ public class GCCBuiltinSymbolProvider implements IBuiltinBindingsProvider { } else if (tstr.equals("char")) { Kind kind = Kind.eChar; t = fCpp ? new CPPBasicType(kind, q) : new CBasicType(kind, q); + } else if (tstr.equals("_Decimal32")) { + Kind kind = Kind.eDecimal32; + t = fCpp ? new CPPBasicType(kind, q) : new CBasicType(kind, q); + } else if (tstr.equals("_Decimal64")) { + Kind kind = Kind.eDecimal64; + t = fCpp ? new CPPBasicType(kind, q) : new CBasicType(kind, q); + } else if (tstr.equals("_Decimal128")) { + Kind kind = Kind.eDecimal128; + t = fCpp ? new CPPBasicType(kind, q) : new CBasicType(kind, q); } else if (tstr.equals("int")) { Kind kind = Kind.eInt; t = fCpp ? new CPPBasicType(kind, q) : new CBasicType(kind, q); @@ -632,4 +686,22 @@ public class GCCBuiltinSymbolProvider implements IBuiltinBindingsProvider { public boolean isKnownBuiltin(char[] builtinName) { return fKnownBuiltins.containsKey(builtinName); } + + /* + * A builtin function which can be evaluated in a constexpr context + */ + private static class CPPBuiltinImplicitFunction extends CPPImplicitFunction { + private ICPPExecution execution; + + public CPPBuiltinImplicitFunction(char[] name, IScope scope, ICPPFunctionType type, ICPPParameter[] params, + boolean takesVarArgs, ICPPExecution execution) { + super(name, scope, type, params, true, takesVarArgs); + this.execution = execution; + } + + @Override + public ICPPExecution getFunctionBodyExecution() { + return execution; + } + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ITypeMarshalBuffer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ITypeMarshalBuffer.java index cc215747ed2..b7e352d7bf1 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ITypeMarshalBuffer.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ITypeMarshalBuffer.java @@ -52,7 +52,7 @@ public interface ITypeMarshalBuffer { EXEC_DECLARATION_STATEMENT = 0x05, EXEC_DECLARATOR = 0x06, EXEC_DEFAULT = 0x07, EXEC_SIMPLE_DECLARATION = 0x08, EXEC_RETURN = 0x09, EXEC_EXPRESSION_STATEMENT = 0x0A, EXEC_IF = 0x0B, EXEC_WHILE = 0x0C, EXEC_DO = 0x0D, EXEC_FOR = 0x0E, EXEC_RANGE_BASED_FOR = 0x0F, EXEC_SWITCH = 0x10, - EXEC_CONSTRUCTOR_CHAIN = 0x11, EXEC_INCOMPLETE = 0x12; + EXEC_CONSTRUCTOR_CHAIN = 0x11, EXEC_INCOMPLETE = 0x12, EXEC_BUILTIN = 0x13; // Can add more executions up to 0x1C, after that it will collide with TypeMarshalBuffer.UNSTORABLE_TYPE. static final short KIND_MASK = 0x001F; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ValueFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ValueFactory.java index 9d104b03465..68651b83224 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ValueFactory.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ValueFactory.java @@ -603,6 +603,11 @@ public class ValueFactory { return IntegralValue.create(1); } return IntegralValue.create(0); + case __is_same: + if (type1.isSameType(type2)) { + return IntegralValue.create(1); + } + return IntegralValue.create(0); case __is_trivially_assignable: return IntegralValue.UNKNOWN; // TODO: Implement. } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVariable.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVariable.java index 576190d1363..6314292ed60 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVariable.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVariable.java @@ -51,7 +51,7 @@ public class CVariable extends PlatformObject implements ICInternalBinding, IVar * The set of CVariable objects for which initial value computation is in progress on each thread. * This is used to guard against recursion during initial value computation. */ - private static final ThreadLocal<Set<CVariable>> fInitialValueInProgress = new ThreadLocal<Set<CVariable>>() { + private static final ThreadLocal<Set<CVariable>> fInitialValueInProgress = new ThreadLocal<>() { @Override protected Set<CVariable> initialValue() { return new HashSet<>(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java index 77e2f6da450..bd63a89dfab 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java @@ -1162,8 +1162,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser { throwBacktrack(LA(1)); attributes = CollectionUtils.merge(attributes, __attribute_decl_seq(true, false)); break; - case IGCCToken.t__declspec: // __declspec precedes the identifier - if (identifier != null || !supportDeclspecSpecifiers) + case IGCCToken.t__declspec: + if (!supportDeclspecSpecifiers) throwBacktrack(LA(1)); __attribute_decl_seq(false, true); break; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/AbstractCPPClassSpecializationScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/AbstractCPPClassSpecializationScope.java index 6119aebacb2..e77cad25114 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/AbstractCPPClassSpecializationScope.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/AbstractCPPClassSpecializationScope.java @@ -54,7 +54,7 @@ public class AbstractCPPClassSpecializationScope implements ICPPClassSpecializat // The following fields are used by the PDOM bindings and need to be volatile. private volatile ICPPBase[] fBases; private volatile ICPPMethod[] ownInheritedConstructors; - private final ThreadLocal<Boolean> fComputingBases = new ThreadLocal<Boolean>() { + private final ThreadLocal<Boolean> fComputingBases = new ThreadLocal<>() { @Override protected Boolean initialValue() { return false; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousTemplateArgument.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousTemplateArgument.java index 5fc12dbdfd0..29590cb6bcc 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousTemplateArgument.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousTemplateArgument.java @@ -47,7 +47,6 @@ public class CPPASTAmbiguousTemplateArgument extends ASTAmbiguousNode implements fNodes = new ArrayList<>(2); for (IASTNode node : nodes) { if (node instanceof IASTTypeId || node instanceof IASTExpression) { - node.setParent(this); fNodes.add(node); } else { Assert.isLegal(false, node == null ? "null" : node.getClass().getName()); //$NON-NLS-1$ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDeductionGuide.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDeductionGuide.java deleted file mode 100644 index edcfcddb3f4..00000000000 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDeductionGuide.java +++ /dev/null @@ -1,174 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2018, Institute for Software and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Felix Morgner - initial API and implementation - *******************************************************************************/ - -package org.eclipse.cdt.internal.core.dom.parser.cpp; - -import org.eclipse.cdt.core.dom.ast.ASTVisitor; -import org.eclipse.cdt.core.dom.ast.IASTName; -import org.eclipse.cdt.core.dom.ast.IASTNode; -import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeductionGuide; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterDeclaration; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId; -import org.eclipse.cdt.core.parser.util.ArrayUtil; -import org.eclipse.cdt.internal.core.dom.parser.ASTNode; -import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; - -public class CPPASTDeductionGuide extends ASTNode implements ICPPASTDeductionGuide, IASTAmbiguityParent { - - private IASTParameterDeclaration[] parameters; - private IASTName templateName; - private ICPPASTTemplateId templateId; - private boolean takesVarArgs; - private boolean isExplicit; - - @Override - public boolean accept(ASTVisitor visitor) { - if (visitor.shouldVisitDeclarations) { - switch (visitor.visit(this)) { - case ASTVisitor.PROCESS_ABORT: - return false; - case ASTVisitor.PROCESS_SKIP: - return true; - default: - break; - } - } - - if (!templateName.accept(visitor)) { - return false; - } - - if (parameters != null) { - for (IASTParameterDeclaration parameter : parameters) { - if (parameter != null && !parameter.accept(visitor)) { - return false; - } - } - } - - if (!templateId.accept(visitor)) { - return false; - } - - if (visitor.shouldVisitDeclarations) { - switch (visitor.leave(this)) { - case ASTVisitor.PROCESS_ABORT: - return false; - case ASTVisitor.PROCESS_SKIP: - return true; - default: - break; - } - } - return true; - } - - @Override - public void addParameterDeclaration(IASTParameterDeclaration parameter) { - assertNotFrozen(); - assert (parameter != null); - parameter.setParent(this); - parameter.setPropertyInParent(PARAMETER); - parameters = ArrayUtil.append(IASTParameterDeclaration.class, parameters, parameter); - } - - @Override - public IASTParameterDeclaration[] getParameters() { - if (parameters == null) { - return ICPPASTParameterDeclaration.EMPTY_CPPPARAMETERDECLARATION_ARRAY; - } - return ArrayUtil.trim(parameters); - } - - @Override - public void setVarArgs(boolean value) { - assertNotFrozen(); - takesVarArgs = value; - } - - @Override - public boolean takesVarArgs() { - return takesVarArgs; - } - - @Override - public boolean isExplicit() { - return isExplicit; - } - - @Override - public void setExplicit(boolean value) { - assertNotFrozen(); - isExplicit = value; - } - - @Override - public IASTName getTemplateName() { - return templateName; - } - - @Override - public void setTemplateName(IASTName name) { - assertNotFrozen(); - assert (name != null); - name.setParent(this); - name.setPropertyInParent(TEMPLATE_NAME); - templateName = name; - } - - @Override - public ICPPASTTemplateId getSimpleTemplateId() { - return templateId; - } - - @Override - public void setSimpleTemplateId(ICPPASTTemplateId id) { - assertNotFrozen(); - assert (id != null); - id.setParent(this); - id.setPropertyInParent(TEMPLATE_ID); - templateId = id; - } - - @Override - public ICPPASTDeductionGuide copy() { - return copy(CopyStyle.withoutLocations); - } - - @Override - public ICPPASTDeductionGuide copy(CopyStyle style) { - CPPASTDeductionGuide copy = new CPPASTDeductionGuide(); - copy.isExplicit = isExplicit; - copy.takesVarArgs = takesVarArgs; - copy.setTemplateName(templateName.copy(style)); - copy.setSimpleTemplateId(templateId.copy(style)); - if (parameters != null) { - for (IASTParameterDeclaration parameter : parameters) { - if (parameter != null) { - copy.addParameterDeclaration(parameter.copy(style)); - } - } - } - return super.copy(copy, style); - } - - @Override - public void replace(IASTNode child, IASTNode other) { - int indexOfChild = ArrayUtil.indexOfEqual(parameters, child); - if (indexOfChild > -1) { - other.setParent(this); - other.setPropertyInParent(PARAMETER); - child.setParent(null); - parameters[indexOfChild] = (IASTParameterDeclaration) other; - } - } -} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBasicType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBasicType.java index c26dde91be6..d51a95775a9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBasicType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBasicType.java @@ -17,6 +17,9 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp; import static org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter.EMPTY_CPPPARAMETER_ARRAY; +import java.text.MessageFormat; + +import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.ast.ASTTypeUtil; import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression; @@ -58,10 +61,16 @@ public class CPPBasicType implements ICPPBasicType, ISerializableType { public static final CPPBasicType CHAR = new CPPBasicType(Kind.eChar, 0); public static final CPPBasicType VOID = new CPPBasicType(Kind.eVoid, 0); - private static final int FROM_STRING_LITERAL = 1 << 31; + public static final int FROM_LITERAL = 1 << 30; + public static final int FROM_STRING_LITERAL = 1 << 31; + + private static final short TYPE_BUFFER_KIND_OFFSET = ITypeMarshalBuffer.FIRST_FLAG; + private static final short TYPE_BUFFER_FROM_LITERAL_FLAG = ITypeMarshalBuffer.SECOND_LAST_FLAG / 2; + private static final short TYPE_BUFFER_FIRST_FLAG_AFTER_KIND = TYPE_BUFFER_FROM_LITERAL_FLAG; + private static final int MAX_KIND_INT_VALUE = (TYPE_BUFFER_FIRST_FLAG_AFTER_KIND - 1) / TYPE_BUFFER_KIND_OFFSET; private final Kind fKind; - private final int fModifiers; + private int fModifiers; private Long fAssociatedValue; private ICPPFunction fPseudoDestructor; @@ -77,9 +86,11 @@ public class CPPBasicType implements ICPPBasicType, ISerializableType { } else { fKind = kind; } - if (expression instanceof IASTLiteralExpression - && ((IASTLiteralExpression) expression).getKind() == IASTLiteralExpression.lk_string_literal) { - qualifiers |= FROM_STRING_LITERAL; + if (expression instanceof IASTLiteralExpression) { + qualifiers |= FROM_LITERAL; + if (((IASTLiteralExpression) expression).getKind() == IASTLiteralExpression.lk_string_literal) { + qualifiers |= FROM_STRING_LITERAL; + } } fModifiers = qualifiers; if (expression instanceof ICPPASTInitializerClause) { @@ -209,9 +220,19 @@ public class CPPBasicType implements ICPPBasicType, ISerializableType { @Override public CPPBasicType clone() { + return clone(~0); + } + + /** + * Clone as normal but keep only requested flags. + * + * @param flagsMask The mask of flags to preserve during the clone. + */ + public CPPBasicType clone(int flagsMask) { CPPBasicType t = null; try { t = (CPPBasicType) super.clone(); + t.fModifiers &= flagsMask; } catch (CloneNotSupportedException e) { // Not going to happen. } @@ -235,15 +256,22 @@ public class CPPBasicType implements ICPPBasicType, ISerializableType { } /** - * Returns {@code true} if the type was created for a string literal. + * Returns {@code true} if the type was created from a string literal. */ public final boolean isFromStringLiteral() { return (fModifiers & FROM_STRING_LITERAL) != 0; } + /** + * Returns {@code true} if the type was created from a literal. + */ + public final boolean isFromLiteral() { + return (fModifiers & FROM_LITERAL) != 0; + } + @Override public final int getModifiers() { - return fModifiers & ~FROM_STRING_LITERAL; + return fModifiers & ~FROM_STRING_LITERAL & ~FROM_LITERAL; } @Override @@ -254,27 +282,47 @@ public class CPPBasicType implements ICPPBasicType, ISerializableType { @Override public void marshal(ITypeMarshalBuffer buffer) throws CoreException { final int kind = getKind().ordinal(); - final int shiftedKind = kind * ITypeMarshalBuffer.FIRST_FLAG; + // 'kind' uses the space of the first few flags so make sure it doesn't overflow to the actual used flags further. + if (kind > MAX_KIND_INT_VALUE) { + throw new CoreException(CCorePlugin.createStatus( + MessageFormat.format("Cannot marshal a basic type, kind ''{0}'' would overflow following flags.", //$NON-NLS-1$ + getKind().toString()))); + } + final int shiftedKind = kind * TYPE_BUFFER_KIND_OFFSET; final int modifiers = getModifiers(); short firstBytes = (short) (ITypeMarshalBuffer.BASIC_TYPE | shiftedKind); - if (modifiers != 0) - firstBytes |= ITypeMarshalBuffer.LAST_FLAG; + if (isFromLiteral()) + firstBytes = setFirstBytesFlag(firstBytes, TYPE_BUFFER_FROM_LITERAL_FLAG); if (fAssociatedValue != null) - firstBytes |= ITypeMarshalBuffer.SECOND_LAST_FLAG; + firstBytes = setFirstBytesFlag(firstBytes, ITypeMarshalBuffer.SECOND_LAST_FLAG); + if (modifiers != 0) + firstBytes = setFirstBytesFlag(firstBytes, ITypeMarshalBuffer.LAST_FLAG); buffer.putShort(firstBytes); if (modifiers != 0) buffer.putByte((byte) modifiers); if (fAssociatedValue != null) buffer.putLong(getAssociatedNumericalValue()); + + } + + private static short setFirstBytesFlag(short firstBytes, short flag) throws CoreException { + if (flag < TYPE_BUFFER_FIRST_FLAG_AFTER_KIND) { + throw new CoreException(CCorePlugin.createStatus( + MessageFormat.format("Cannot marshal a basic type, flag ''0x{0}'' overlaps ''kind'' bytes.", //$NON-NLS-1$ + Integer.toHexString(flag)))); + } + return (short) (firstBytes | flag); } public static IType unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException { final boolean haveModifiers = (firstBytes & ITypeMarshalBuffer.LAST_FLAG) != 0; final boolean haveAssociatedNumericalValue = (firstBytes & ITypeMarshalBuffer.SECOND_LAST_FLAG) != 0; int modifiers = 0; - int kind = (firstBytes & (ITypeMarshalBuffer.SECOND_LAST_FLAG - 1)) / ITypeMarshalBuffer.FIRST_FLAG; + int kind = (firstBytes & (TYPE_BUFFER_FIRST_FLAG_AFTER_KIND - 1)) / TYPE_BUFFER_KIND_OFFSET; if (haveModifiers) modifiers = buffer.getByte(); + if ((firstBytes & TYPE_BUFFER_FROM_LITERAL_FLAG) != 0) + modifiers |= FROM_LITERAL; CPPBasicType result = new CPPBasicType(Kind.values()[kind], modifiers); if (haveAssociatedNumericalValue) result.setAssociatedNumericalValue(buffer.getLong()); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBuiltinParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBuiltinParameter.java index 3dd21dc3de9..754da65a108 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBuiltinParameter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBuiltinParameter.java @@ -38,9 +38,16 @@ public class CPPBuiltinParameter extends PlatformObject implements ICPPParameter } private IType type; + private int position; public CPPBuiltinParameter(IType type) { this.type = type; + this.position = -1; + } + + public CPPBuiltinParameter(IType type, int position) { + this.type = type; + this.position = position; } @Override @@ -75,6 +82,9 @@ public class CPPBuiltinParameter extends PlatformObject implements ICPPParameter @Override public String getName() { + if (position != -1) { + return "arg" + position; //$NON-NLS-1$ + } return ""; //$NON-NLS-1$ } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecialization.java index db1d5b2455d..64271bedd79 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecialization.java @@ -190,7 +190,7 @@ public class CPPClassSpecialization extends CPPSpecialization private ICPPClassSpecializationScope specScope; private ObjectMap specializationMap = ObjectMap.EMPTY_MAP; private ICPPBase[] bases; - private final ThreadLocal<Set<IBinding>> fInProgress = new ThreadLocal<Set<IBinding>>() { + private final ThreadLocal<Set<IBinding>> fInProgress = new ThreadLocal<>() { @Override protected Set<IBinding> initialValue() { return new HashSet<>(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVariable.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVariable.java index b77e1b87038..78099e91259 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVariable.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVariable.java @@ -69,7 +69,7 @@ public class CPPVariable extends PlatformObject implements ICPPInternalDeclaredV * The set of CPPVariable objects for which initial value computation is in progress on each thread. * This is used to guard against recursion during initial value computation. */ - private static final ThreadLocal<Set<CPPVariable>> fInitialValueInProgress = new ThreadLocal<Set<CPPVariable>>() { + private static final ThreadLocal<Set<CPPVariable>> fInitialValueInProgress = new ThreadLocal<>() { @Override protected Set<CPPVariable> initialValue() { return new HashSet<>(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java index 227f8699cb2..4709d51a4e7 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java @@ -127,7 +127,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTOperatorName; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPackExpandable; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterDeclaration; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterListOwner; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTRangeBasedForStatement; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTReferenceOperator; @@ -1567,6 +1566,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { case IGCCToken.tTT_is_trivially_constructible: case IGCCToken.tTT_is_trivially_assignable: case IGCCToken.tTT_is_constructible: + case IGCCToken.tTT_is_same: return parseTypeTrait(); default: @@ -1618,6 +1618,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { switch (first.getType()) { case IGCCToken.tTT_is_base_of: case IGCCToken.tTT_is_trivially_assignable: + case IGCCToken.tTT_is_same: return true; } return false; @@ -1638,6 +1639,8 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { return IASTBinaryTypeIdExpression.Operator.__is_base_of; case IGCCToken.tTT_is_trivially_assignable: return IASTBinaryTypeIdExpression.Operator.__is_trivially_assignable; + case IGCCToken.tTT_is_same: + return IASTBinaryTypeIdExpression.Operator.__is_same; } assert false; @@ -3056,35 +3059,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { throwBacktrack(LA(1)); } - if (dtor instanceof ICPPASTFunctionDeclarator - && ((ICPPASTFunctionDeclarator) dtor).getTrailingReturnType() != null) { - if (declSpec instanceof IASTSimpleDeclSpecifier - && ((IASTSimpleDeclSpecifier) declSpec).getType() == IASTSimpleDeclSpecifier.t_unspecified) { - // we encountered something that looks like a ctor with trailing return type - CPPASTDeductionGuide guide = new CPPASTDeductionGuide(); - guide.setExplicit(((ICPPASTDeclSpecifier) declSpec).isExplicit()); - guide.setTemplateName(dtor.getName()); - ICPPASTParameterDeclaration[] params = ((ICPPASTFunctionDeclarator) dtor).getParameters(); - for (ICPPASTParameterDeclaration p : params) - guide.addParameterDeclaration(p); - guide.setVarArgs(((ICPPASTFunctionDeclarator) dtor).takesVarArgs()); - IASTTypeId nameSpecifier = ((ICPPASTFunctionDeclarator) dtor).getTrailingReturnType(); - IASTDeclSpecifier guideDeclSpec = nameSpecifier.getDeclSpecifier(); - if (guideDeclSpec instanceof ICPPASTNamedTypeSpecifier) { - IASTName n = ((ICPPASTNamedTypeSpecifier) guideDeclSpec).getName(); - if (n instanceof ICPPASTTemplateId) { - guide.setSimpleTemplateId((ICPPASTTemplateId) n); - } else { - throwBacktrack(dtor); - } - } else { - throwBacktrack(dtor); - } - setRange(guide, firstOffset, endOffset); - return guide; - } - } - // no function body final boolean isAmbiguous = altDeclSpec != null && altDtor != null && declarators.length == 1; @@ -3605,8 +3579,8 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { throwBacktrack(LA(1)); attributes = CollectionUtils.merge(attributes, __attribute_decl_seq(true, false)); break; - case IGCCToken.t__declspec: // __declspec precedes the identifier - if (identifier != null || !supportDeclspecSpecifiers) + case IGCCToken.t__declspec: + if (!supportDeclspecSpecifiers) throwBacktrack(LA(1)); attributes = CollectionUtils.merge(attributes, __attribute_decl_seq(false, true)); break; @@ -4013,20 +3987,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { } } - //Check if it's a possible C++17 deduction guide - if (dtor instanceof ICPPASTFunctionDeclarator) { - ICPPASTFunctionDeclarator possibleGuide = (ICPPASTFunctionDeclarator) dtor; - IASTTypeId returnType = possibleGuide.getTrailingReturnType(); - if (returnType != null) { - IASTDeclSpecifier declSpec = returnType.getDeclSpecifier(); - if (declSpec instanceof ICPPASTNamedTypeSpecifier) { - IASTName n = ((ICPPASTNamedTypeSpecifier) declSpec).getName(); - if (n instanceof ICPPASTTemplateId) - return; - } - } - } - ASTNode node = (ASTNode) dtor; throwBacktrack(node.getOffset(), node.getLength()); } @@ -4799,7 +4759,44 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { int endOffset = last.getEndOffset(); final ICPPASTFunctionDeclarator fc = getNodeFactory().newFunctionDeclarator(null); - endOffset = parameterList(startOffset, endOffset, fc); + ICPPASTParameterDeclaration pd = null; + paramLoop: while (true) { + switch (LT(1)) { + case IToken.tRPAREN: + case IToken.tEOC: + endOffset = consume().getEndOffset(); + break paramLoop; + case IToken.tELLIPSIS: + consume(); + endOffset = consume(IToken.tRPAREN).getEndOffset(); + fc.setVarArgs(true); + break paramLoop; + case IToken.tCOMMA: + if (pd == null) + throwBacktrack(LA(1)); + endOffset = consume().getEndOffset(); + pd = null; + break; + default: + if (pd != null) + throwBacktrack(startOffset, endOffset - startOffset); + + pd = parameterDeclaration(); + fc.addParameterDeclaration(pd); + endOffset = calculateEndOffset(pd); + break; + } + } + // Handle ambiguity between parameter pack and varargs. + if (pd != null) { + ICPPASTDeclarator dtor = pd.getDeclarator(); + if (dtor != null && !(dtor instanceof IASTAmbiguousDeclarator)) { + if (dtor.declaresParameterPack() && dtor.getNestedDeclarator() == null && dtor.getInitializer() == null + && dtor.getName().getSimpleID().length == 0) { + ((IASTAmbiguityParent) fc).replace(pd, new CPPASTAmbiguousParameterDeclaration(pd)); + } + } + } // Consume any number of __attribute__ tokens after the parameters List<IASTAttributeSpecifier> attributes = __attribute_decl_seq(supportAttributeSpecifiers, false); @@ -4915,58 +4912,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { } /** - * Parse a paramter list - * @param start Start offset - * @param end End offset - * @param owner The list owner - * @return The end offset after parsing - * @throws EndOfFileException - * @throws BacktrackException - */ - private int parameterList(int start, int end, ICPPASTParameterListOwner owner) - throws EndOfFileException, BacktrackException { - ICPPASTParameterDeclaration pd = null; - paramLoop: while (true) { - switch (LT(1)) { - case IToken.tRPAREN: - case IToken.tEOC: - end = consume().getEndOffset(); - break paramLoop; - case IToken.tELLIPSIS: - consume(); - end = consume(IToken.tRPAREN).getEndOffset(); - owner.setVarArgs(true); - break paramLoop; - case IToken.tCOMMA: - if (pd == null) - throwBacktrack(LA(1)); - end = consume().getEndOffset(); - pd = null; - break; - default: - if (pd != null) - throwBacktrack(start, end - start); - - pd = parameterDeclaration(); - owner.addParameterDeclaration(pd); - end = calculateEndOffset(pd); - break; - } - } - // Handle ambiguity between parameter pack and varargs. - if (pd != null) { - ICPPASTDeclarator dtor = pd.getDeclarator(); - if (dtor != null && !(dtor instanceof IASTAmbiguousDeclarator)) { - if (dtor.declaresParameterPack() && dtor.getNestedDeclarator() == null && dtor.getInitializer() == null - && dtor.getName().getSimpleID().length == 0) { - ((IASTAmbiguityParent) owner).replace(pd, new CPPASTAmbiguousParameterDeclaration(pd)); - } - } - } - return end; - } - - /** * Parse an array declarator starting at the square bracket. */ private ICPPASTArrayDeclarator arrayDeclarator(DeclarationOptions option) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/InstantiationContext.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/InstantiationContext.java index 61b889c2838..fb9063fb7d3 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/InstantiationContext.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/InstantiationContext.java @@ -30,6 +30,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTypeSpecialization; */ public final class InstantiationContext { private CPPTemplateParameterMap parameterMap; + private boolean forDeduction = false; private int packOffset; private final ICPPSpecialization contextSpecialization; private boolean expandPack; @@ -79,6 +80,15 @@ public final class InstantiationContext { } /** + * Create an InstantiationContext for a template parameter map, for use template argument deduction. + */ + public static InstantiationContext forDeduction(ICPPTemplateParameterMap parameterMap) { + InstantiationContext result = new InstantiationContext(parameterMap); + result.forDeduction = true; + return result; + } + + /** * Returns the mapping of template parameters to arguments, possibly {@code null} if the context doesn't * contain it. */ @@ -87,6 +97,13 @@ public final class InstantiationContext { } /** + * Returns whether the InstantiationContext was created during template argument deduction. + */ + public boolean isForDeduction() { + return forDeduction; + } + + /** * Adds a parameter mapping. */ public void addToParameterMap(ICPPTemplateParameter par, ICPPTemplateArgument arg) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java index 77ddf8d212b..45f8fb677b5 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java @@ -299,14 +299,14 @@ public class CPPSemantics { // that are not reachable via includes from the file containing the name. // Generally this is not allowed, but certain consumers, such as IncludeOrganizer, // need it (since the whole point of IncludeOrganizer is to find missing headers). - private static final ThreadLocal<Boolean> fAllowPromiscuousBindingResolution = new ThreadLocal<Boolean>() { + private static final ThreadLocal<Boolean> fAllowPromiscuousBindingResolution = new ThreadLocal<>() { @Override protected Boolean initialValue() { return false; } }; - private static final ThreadLocal<Deque<IASTNode>> fLookupPoints = new ThreadLocal<Deque<IASTNode>>() { + private static final ThreadLocal<Deque<IASTNode>> fLookupPoints = new ThreadLocal<>() { @Override protected Deque<IASTNode> initialValue() { return new ArrayDeque<>(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java index 96e1d2c47d4..ba0378e9f23 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java @@ -239,13 +239,13 @@ public class CPPTemplates { // Infrastructure to protect against rogue template metaprograms that don't terminate. private static final int TEMPLATE_INSTANTIATION_DEPTH_LIMIT = 128; - private static final ThreadLocal<Integer> fTemplateInstantiationDepth = new ThreadLocal<Integer>() { + private static final ThreadLocal<Integer> fTemplateInstantiationDepth = new ThreadLocal<>() { @Override protected Integer initialValue() { return 0; } }; - private static final ThreadLocal<Set<TypeInstantiationRequest>> instantiationsInProgress = new ThreadLocal<Set<TypeInstantiationRequest>>() { + private static final ThreadLocal<Set<TypeInstantiationRequest>> instantiationsInProgress = new ThreadLocal<>() { @Override protected Set<TypeInstantiationRequest> initialValue() { return new HashSet<>(); @@ -1717,12 +1717,7 @@ public class CPPTemplates { if (type instanceof ICPPUnaryTypeTransformation) { ICPPUnaryTypeTransformation typeTransformation = (ICPPUnaryTypeTransformation) type; IType operand = instantiateType(typeTransformation.getOperand(), context); - switch (typeTransformation.getOperator()) { - case underlying_type: - return TypeTraits.underlyingType(operand); - default: - return null; // shouldn't happen - } + return SemanticUtil.applyTypeTransformation(typeTransformation.getOperator(), operand); } if (type instanceof CPPClosureType) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java index 813e5a568c6..6393d9cf453 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java @@ -117,7 +117,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorInitializer; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclarator; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeductionGuide; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTEnumerationSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExplicitTemplateInstantiation; @@ -237,7 +236,6 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateNonTypeArgument; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateParameterMap; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateTypeArgument; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTypedef; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnaryTypeTransformation; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownTypeScope; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVariable; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVariableTemplate; @@ -281,7 +279,7 @@ public class CPPVisitor extends ASTQueries { // Thread-local set of declarators for which auto types are being created. // Used to prevent infinite recursion while processing invalid self-referencing // auto-type declarations. - private static final ThreadLocal<Set<IASTDeclarator>> autoTypeDeclarators = new ThreadLocal<Set<IASTDeclarator>>() { + private static final ThreadLocal<Set<IASTDeclarator>> autoTypeDeclarators = new ThreadLocal<>() { @Override protected Set<IASTDeclarator> initialValue() { return new HashSet<>(); @@ -860,9 +858,6 @@ public class CPPVisitor extends ASTQueries { return null; } else if (parent instanceof ICPPASTTemplateDeclaration) { return CPPTemplates.createBinding(param); - } else if (parent instanceof ICPPASTDeductionGuide) { - ICPPASTDeductionGuide guide = (ICPPASTDeductionGuide) parent; - return new CPPParameter(name, findParameterIndex(param, guide.getParameters())); } return new ProblemBinding(name, IProblemBinding.SEMANTIC_INVALID_TYPE); } @@ -2797,7 +2792,12 @@ public class CPPVisitor extends ASTQueries { name = ((IASTEnumerationSpecifier) declSpec).getName(); } else if (declSpec instanceof ICPPASTTypeTransformationSpecifier) { ICPPASTTypeTransformationSpecifier spec = (ICPPASTTypeTransformationSpecifier) declSpec; - return new CPPUnaryTypeTransformation(spec.getOperator(), createType(spec.getOperand())); + IType type = SemanticUtil.applyTypeTransformation(spec.getOperator(), createType(spec.getOperand())); + if (type != null) + return type; + + return ProblemType.UNRESOLVED_NAME; + } else if (declSpec instanceof ICPPASTSimpleDeclSpecifier) { ICPPASTSimpleDeclSpecifier spec = (ICPPASTSimpleDeclSpecifier) declSpec; // Check for decltype(expr) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/Conversions.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/Conversions.java index b4858bbd4b4..fb3d3e4157f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/Conversions.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/Conversions.java @@ -30,6 +30,7 @@ import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUti import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getNestedType; import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.isVoidType; +import java.math.BigInteger; import java.util.Collections; import org.eclipse.cdt.core.dom.ast.DOMException; @@ -60,6 +61,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance; import org.eclipse.cdt.core.parser.util.CharArrayUtils; import org.eclipse.cdt.internal.core.dom.parser.ArithmeticConversion; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; +import org.eclipse.cdt.internal.core.dom.parser.SizeofCalculator; +import org.eclipse.cdt.internal.core.dom.parser.SizeofCalculator.SizeAndAlignment; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerToMemberType; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerType; @@ -1168,9 +1171,13 @@ public class Conversions { if (basicType.getKind() == Kind.eNullPtr) return true; - Long val = basicType.getAssociatedNumericalValue(); - if (val != null && val == 0) { - return true; + // Starting from C++11, the value is required to be a literal. This means pre-C++11 parsing will not be correct here. + // But we don't currently have a way to check the C++ version here and in semantics code in general. + if (basicType.getKind() == Kind.eInt && basicType.isFromLiteral()) { + Long val = basicType.getAssociatedNumericalValue(); + if (val != null && val == 0) { + return true; + } } } return false; @@ -1322,4 +1329,99 @@ public class Conversions { private static boolean isNullPtr(IType t1) { return t1 instanceof IBasicType && ((IBasicType) t1).getKind() == Kind.eNullPtr; } + + /** + * Narrow a numeric value to the range of a specified type. + * @param num the value to narrow (may be null) + * @param toType the type to narrow to + * @return a number representing the narrowed value, or null + */ + public static Number narrowNumberValue(Number num, IType toType) { + if (num == null) + return null; + + if (toType instanceof IBasicType) { + IBasicType basicType = (IBasicType) toType; + IBasicType.Kind basicTypeKind = basicType.getKind(); + switch (basicTypeKind) { + case eFloat: + if (num instanceof Float) + return num; + return Float.valueOf(num.floatValue()); + case eDouble: + if (num instanceof Double) + return num; + return Double.valueOf(num.doubleValue()); + case eInt: + SizeAndAlignment sizeToType = SizeofCalculator.getSizeAndAlignment(toType); + if (sizeToType == null) + return null; + // Note in the following we don't check type.isSigned() since that checks for the + // explicit presence of the "signed" modifier. So instead check !type.isUnsigned(). + if (sizeToType.size <= 8) { + // First, mask the value to the correct size + // Note that we take the longValue here which may be negative even though the + // original value is positive; the masking here should still be correct and we + // should ultimately end up with the correct narrowed value, regardless. + long longVal = num.longValue(); + long maskVal = 0xFFFFFFFFFFFFFFFFL; + long signBit = 0x8000000000000000L; + // Calculate a mask to reduce the size of the value to the target width: + maskVal >>>= (8 - sizeToType.size) * 8; + signBit >>>= (8 - sizeToType.size) * 8; + if (!basicType.isUnsigned() && (longVal & signBit) != 0) { + // We need to extend the sign bit. + long signBits = ~maskVal; + longVal |= signBits; + } else { + longVal &= maskVal; + } + + // The Java type used to store the numerical value is independent of the associated + // C type, but we go with a smaller type (Integer) where possible. For 4 bytes + // (signed) or less than 4 bytes (signed or not) we can use Integer. For 8 bytes + // (signed) or less than 8 bytes (signed or not) we can use Long. Any larger and we + // resort to BigInteger. + if (longVal >= 0 && longVal <= Integer.MAX_VALUE) { + return Integer.valueOf((int) longVal); + } + if (!basicType.isUnsigned() && longVal >= Integer.MIN_VALUE && longVal <= Integer.MAX_VALUE) { + return Integer.valueOf((int) longVal); + } + + if (!basicType.isUnsigned() || longVal > 0) { + return Long.valueOf(longVal); + } + + BigInteger biVal = BigInteger.valueOf(longVal); + // 2**64 = 18446744073709551616 + biVal = biVal.add(new BigInteger("18446744073709551616")); //$NON-NLS-1$ + return biVal; + } + // TODO handle larger int sizes? + return null; + case eChar: + // TODO don't assume signed char + if (num instanceof Byte) + return num; + return Byte.valueOf(num.byteValue()); + case eChar16: + int intVal = num.intValue(); + int maskedVal = intVal & 0xFFFF; + if (maskedVal == intVal && num instanceof Integer) + return num; + return Integer.valueOf(maskedVal); + case eChar32: + long longVal = num.longValue(); + long maskedVal32 = longVal & 0xFFFFFFFFL; + if (maskedVal32 == longVal && (num instanceof Integer || num instanceof Long)) + return num; + return Long.valueOf(maskedVal32); + default: + return null; + } + } + + return null; + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinary.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinary.java index 464e389ed49..8cfda662951 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinary.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinary.java @@ -151,6 +151,11 @@ public class EvalBinary extends CPPDependentEvaluation { } } } + + if (fType instanceof CPPBasicType) { + fType = ((CPPBasicType) fType).clone(~CPPBasicType.FROM_LITERAL); + } + return fType; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinaryTypeId.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinaryTypeId.java index 21aff0403ca..dc0d2369b94 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinaryTypeId.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinaryTypeId.java @@ -80,6 +80,7 @@ public class EvalBinaryTypeId extends CPPDependentEvaluation { switch (fOperator) { case __is_base_of: case __is_trivially_assignable: + case __is_same: return CPPBasicType.BOOLEAN; } return ProblemType.UNKNOWN_FOR_EXPRESSION; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalComma.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalComma.java index bc49e2cd3d0..aa8c24ce186 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalComma.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalComma.java @@ -28,6 +28,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap; import org.eclipse.cdt.internal.core.dom.parser.DependentValue; import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer; import org.eclipse.cdt.internal.core.dom.parser.IntegralValue; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation; import org.eclipse.cdt.internal.core.dom.parser.cpp.InstantiationContext; import org.eclipse.core.runtime.CoreException; @@ -145,6 +146,9 @@ public class EvalComma extends CPPDependentEvaluation { public IType getType() { if (fType == null) { fType = computeType(); + if (fType instanceof CPPBasicType) { + fType = ((CPPBasicType) fType).clone(~CPPBasicType.FROM_LITERAL); + } } return fType; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalConditional.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalConditional.java index 3af16b1d397..49cc3df4639 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalConditional.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalConditional.java @@ -39,6 +39,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer; import org.eclipse.cdt.internal.core.dom.parser.IntegralValue; import org.eclipse.cdt.internal.core.dom.parser.ProblemType; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPArithmeticConversion; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPReferenceType; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownType; @@ -180,6 +181,14 @@ public class EvalConditional extends CPPDependentEvaluation { if (fValueCategory != null) return; + evaluateInternal(); + + if (fType instanceof CPPBasicType) { + fType = ((CPPBasicType) fType).clone(~CPPBasicType.FROM_LITERAL); + } + } + + private void evaluateInternal() { fValueCategory = PRVALUE; final ICPPEvaluation positive = fPositive == null ? fCondition : fPositive; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUtil.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUtil.java index 3e668dce2ef..e41c71d1ca8 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUtil.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUtil.java @@ -39,7 +39,7 @@ public class EvalUtil { * The set of ICPPVariable objects for which initial value computation is in progress on each thread. * This is used to guard against recursion during initial value computation. */ - private static final ThreadLocal<Set<ICPPVariable>> fInitialValueInProgress = new ThreadLocal<Set<ICPPVariable>>() { + private static final ThreadLocal<Set<ICPPVariable>> fInitialValueInProgress = new ThreadLocal<>() { @Override protected Set<ICPPVariable> initialValue() { return new HashSet<>(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/ExecBuiltin.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/ExecBuiltin.java new file mode 100644 index 00000000000..86e6aab7ae2 --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/ExecBuiltin.java @@ -0,0 +1,195 @@ +/******************************************************************************* +* Copyright (c) 2022 Davin McCall 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: +* Davin McCall - initial API and implementation +*******************************************************************************/ +package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; + +import org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory; +import org.eclipse.cdt.core.dom.ast.IBasicType.Kind; +import org.eclipse.cdt.core.dom.ast.IType; +import org.eclipse.cdt.core.dom.ast.IValue; +import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer; +import org.eclipse.cdt.internal.core.dom.parser.IntegralValue; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBuiltinParameter; +import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation; +import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation.ConstexprEvaluationContext; +import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPExecution; +import org.eclipse.cdt.internal.core.dom.parser.cpp.InstantiationContext; +import org.eclipse.core.runtime.CoreException; + +/** + * Constexpr-evaluation for compiler builtin functions. + */ +public class ExecBuiltin implements ICPPExecution { + public final static short BUILTIN_FFS = 0, BUILTIN_FFSL = 1, BUILTIN_FFSLL = 2, BUILTIN_CTZ = 3, BUILTIN_CTZL = 4, + BUILTIN_CTZLL = 5, BUILTIN_POPCOUNT = 6, BUILTIN_POPCOUNTL = 7, BUILTIN_POPCOUNTLL = 8, BUILTIN_PARITY = 9, + BUILTIN_PARITYL = 10, BUILTIN_PARITYLL = 11, BUILTIN_ABS = 12, BUILTIN_LABS = 13, BUILTIN_LLABS = 14; + + private static IType intType = new CPPBasicType(Kind.eInt, 0); + private static IType longType = new CPPBasicType(Kind.eInt, CPPBasicType.IS_LONG); + private static IType longlongType = new CPPBasicType(Kind.eInt, CPPBasicType.IS_LONG_LONG); + + private short funcId; + + public ExecBuiltin(short funcId) { + this.funcId = funcId; + } + + @Override + public ICPPExecution instantiate(InstantiationContext context, int maxDepth) { + return this; + } + + @Override + public ICPPExecution executeForFunctionCall(ActivationRecord record, ConstexprEvaluationContext context) { + + switch (funcId) { + case BUILTIN_FFS: + return executeBuiltinFfs(record, context, intType); + case BUILTIN_FFSL: + return executeBuiltinFfs(record, context, longType); + case BUILTIN_FFSLL: + return executeBuiltinFfs(record, context, longlongType); + case BUILTIN_CTZ: + return executeBuiltinCtz(record, context, intType); + case BUILTIN_CTZL: + return executeBuiltinCtz(record, context, longType); + case BUILTIN_CTZLL: + return executeBuiltinCtz(record, context, longlongType); + case BUILTIN_POPCOUNT: + return executeBuiltinPopcount(record, context, intType); + case BUILTIN_POPCOUNTL: + return executeBuiltinPopcount(record, context, longType); + case BUILTIN_POPCOUNTLL: + return executeBuiltinPopcount(record, context, longlongType); + case BUILTIN_PARITY: + return executeBuiltinParity(record, context, intType); + case BUILTIN_PARITYL: + return executeBuiltinParity(record, context, longType); + case BUILTIN_PARITYLL: + return executeBuiltinParity(record, context, longlongType); + case BUILTIN_ABS: + return executeBuiltinAbs(record, context, intType); + case BUILTIN_LABS: + return executeBuiltinAbs(record, context, longType); + case BUILTIN_LLABS: + return executeBuiltinAbs(record, context, longlongType); + } + return null; + } + + /* + * Return an execution representing __builtin_ffs or __builtin_ctz + */ + private ICPPExecution executeBuiltinFfsCtz(ActivationRecord record, ConstexprEvaluationContext context, + boolean isCtz, IType argType) { + ICPPEvaluation arg0 = record.getVariable(new CPPBuiltinParameter(null, 0)); + + IValue argValue = arg0.getValue(); + Number numberVal = argValue.numberValue(); + numberVal = Conversions.narrowNumberValue(numberVal, argType); + if (numberVal == null) + return null; + + // __builtin_ffs returns 0 if arg is 0, or 1+count where count is the number of trailing 0 bits + // __builtin_ctz is undefined if arg is 0, or returns count + long arg = numberVal.longValue(); + if (arg == 0) { + if (isCtz) { + return null; + } else { + return new ExecReturn(new EvalFixed(intType, ValueCategory.PRVALUE, IntegralValue.create(0))); + } + } + int count = 0; + while ((arg & 1) == 0) { + arg >>= 1; + count++; + } + int increment = isCtz ? 0 : 1; + return new ExecReturn(new EvalFixed(intType, ValueCategory.PRVALUE, IntegralValue.create(count + increment))); + } + + private ICPPExecution executeBuiltinFfs(ActivationRecord record, ConstexprEvaluationContext context, + IType argType) { + return executeBuiltinFfsCtz(record, context, false /* ffs */, argType); + } + + private ICPPExecution executeBuiltinCtz(ActivationRecord record, ConstexprEvaluationContext context, + IType argType) { + return executeBuiltinFfsCtz(record, context, true /* ctz */, argType); + } + + /* + * Return an execution representing __builtin_popcount + */ + private ICPPExecution executeBuiltinPopcountParity(ActivationRecord record, ConstexprEvaluationContext context, + boolean isParity, IType argType) { + ICPPEvaluation arg0 = record.getVariable(new CPPBuiltinParameter(null, 0)); + + IValue argValue = arg0.getValue(); + Number numberVal = argValue.numberValue(); + numberVal = Conversions.narrowNumberValue(numberVal, argType); + if (numberVal == null) + return null; + + long arg = numberVal.longValue(); + int count = 0; + while (arg != 0) { + if ((arg & 1) != 0) + count++; + arg >>>= 1; + } + if (isParity) { + count = count & 1; + } + return new ExecReturn(new EvalFixed(intType, ValueCategory.PRVALUE, IntegralValue.create(count))); + } + + private ICPPExecution executeBuiltinPopcount(ActivationRecord record, ConstexprEvaluationContext context, + IType argType) { + return executeBuiltinPopcountParity(record, context, false, argType); + } + + private ICPPExecution executeBuiltinParity(ActivationRecord record, ConstexprEvaluationContext context, + IType argType) { + return executeBuiltinPopcountParity(record, context, true, argType); + } + + private ICPPExecution executeBuiltinAbs(ActivationRecord record, ConstexprEvaluationContext context, + IType argType) { + ICPPEvaluation arg0 = record.getVariable(new CPPBuiltinParameter(null, 0)); + + IValue argValue = arg0.getValue(); + Number argNumber = argValue.numberValue(); + argNumber = Conversions.narrowNumberValue(argNumber, argType); + if (argNumber == null) + return null; + + long arg = argNumber.longValue(); + long result = Math.abs(arg); + + return new ExecReturn(new EvalFixed(argType, ValueCategory.PRVALUE, IntegralValue.create(result))); + } + + @Override + public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException { + buffer.putShort(ITypeMarshalBuffer.EXEC_BUILTIN); + buffer.putShort(funcId); + } + + public static ICPPExecution unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException { + short funcId = buffer.getShort(); + return new ExecBuiltin(funcId); + } +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java index f84d285bad6..ebf6c6d1b86 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java @@ -68,6 +68,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPUnaryTypeTransformation; import org.eclipse.cdt.core.index.IIndexBinding; import org.eclipse.cdt.core.parser.Keywords; import org.eclipse.cdt.core.parser.util.ArrayUtil; @@ -945,4 +946,13 @@ public class SemanticUtil { } return result; } + + public static IType applyTypeTransformation(ICPPUnaryTypeTransformation.Operator operator, IType type) { + switch (operator) { + case underlying_type: + return TypeTraits.underlyingType(type); + default: + return null; // shouldn't happen + } + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TemplateArgumentDeduction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TemplateArgumentDeduction.java index 1ceb1694fc9..5a9f4ab9059 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TemplateArgumentDeduction.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TemplateArgumentDeduction.java @@ -135,7 +135,7 @@ public class TemplateArgumentDeduction { break; } - par = CPPTemplates.instantiateType(par, new InstantiationContext(map)); + par = CPPTemplates.instantiateType(par, InstantiationContext.forDeduction(map)); if (!SemanticUtil.isValidType(par)) return false; @@ -352,7 +352,7 @@ public class TemplateArgumentDeduction { return null; IType par = template.getType(); - InstantiationContext context = new InstantiationContext(map); + InstantiationContext context = InstantiationContext.forDeduction(map); par = CPPTemplates.instantiateType(par, context); if (!SemanticUtil.isValidType(par)) return null; @@ -399,7 +399,7 @@ public class TemplateArgumentDeduction { return null; } - InstantiationContext context = new InstantiationContext(map); + InstantiationContext context = InstantiationContext.forDeduction(map); for (int i = 0; i < length; i++) { if (result[i] == null) { final ICPPTemplateParameter tpar = tmplParams[i]; @@ -427,7 +427,7 @@ public class TemplateArgumentDeduction { return null; IType a = SemanticUtil.getSimplifiedType(ftype); - InstantiationContext context = new InstantiationContext(map); + InstantiationContext context = InstantiationContext.forDeduction(map); IType p = CPPTemplates.instantiateType(template.getType(), context); if (!SemanticUtil.isValidType(p)) return null; @@ -572,25 +572,45 @@ public class TemplateArgumentDeduction { return true; } - private static int deduceForPartialOrdering(IType par, IType arg, TemplateArgumentDeduction deduct) + private static int deduceForPartialOrdering(IType parOrig, IType argOrig, TemplateArgumentDeduction deduct) throws DOMException { - par = getNestedType(par, TDEF); - arg = getNestedType(arg, TDEF); + IType parNested = getNestedType(parOrig, TDEF); + IType argNested = getNestedType(argOrig, TDEF); boolean isMoreCVQualified = false; - if (par instanceof ICPPReferenceType && arg instanceof ICPPReferenceType) { - par = getNestedType(par, REF | TDEF); - arg = getNestedType(arg, REF | TDEF); - CVQualifier cvp = getCVQualifier(par); - CVQualifier cva = getCVQualifier(arg); + boolean preferForLValueRef = false; + if (parNested instanceof ICPPReferenceType && argNested instanceof ICPPReferenceType) { + preferForLValueRef = compareRValueRValueTemplateFunctions(parNested, argNested); + parNested = getNestedType(parNested, REF | TDEF); + argNested = getNestedType(argNested, REF | TDEF); + CVQualifier cvp = getCVQualifier(parNested); + CVQualifier cva = getCVQualifier(argNested); isMoreCVQualified = cva.isMoreQualifiedThan(cvp); } - par = getNestedType(par, TDEF | REF | ALLCVQ); - arg = getNestedType(arg, TDEF | REF | ALLCVQ); + parNested = getNestedType(parNested, TDEF | REF | ALLCVQ); + argNested = getNestedType(argNested, TDEF | REF | ALLCVQ); - if (!deduct.fromType(par, arg, false, false)) + if (!deduct.fromType(parNested, argNested, false, false)) return -1; - return isMoreCVQualified ? 1 : 0; + return (isMoreCVQualified || preferForLValueRef) ? 1 : 0; + } + + private static boolean compareRValueRValueTemplateFunctions(final IType f1, final IType f2) { + ICPPReferenceType fstTp = (ICPPReferenceType) f1; + ICPPReferenceType sndTp = (ICPPReferenceType) f2; + + boolean fstRv = fstTp.isRValueReference(); + boolean sndRv = sndTp.isRValueReference(); + + if (fstRv != sndRv) { + return fstRv; + } + + return false; + } + + private static boolean isReferenceType(IType fstSpecP) { + return ICPPReferenceType.class.isAssignableFrom(fstSpecP.getClass()); } /** @@ -759,7 +779,7 @@ public class TemplateArgumentDeduction { private static boolean verifyDeduction(ICPPTemplateParameter[] pars, CPPTemplateParameterMap tpMap, boolean useDefaults) { - InstantiationContext context = new InstantiationContext(tpMap); + InstantiationContext context = InstantiationContext.forDeduction(tpMap); for (ICPPTemplateParameter tpar : pars) { if (tpar.isParameterPack()) { ICPPTemplateArgument[] deducedArgs = tpMap.getPackExpansion(tpar); @@ -1022,7 +1042,7 @@ public class TemplateArgumentDeduction { return true; // An unknown type may match anything. // Verify that the resolved binding matches the argument type. - InstantiationContext context = new InstantiationContext(fDeducedArgs); + InstantiationContext context = InstantiationContext.forDeduction(fDeducedArgs); IBinding binding = CPPTemplates.resolveUnknown((ICPPUnknownBinding) p, context); if (binding instanceof ICPPUnknownBinding) return true; // An unknown type may match anything. diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TypeInstantiationRequest.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TypeInstantiationRequest.java index 96d652981f5..4e2cb16f80b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TypeInstantiationRequest.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TypeInstantiationRequest.java @@ -21,6 +21,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTypeSpecialization; import org.eclipse.cdt.core.parser.util.CharArrayUtils; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateParameterMap; import org.eclipse.cdt.internal.core.dom.parser.cpp.InstantiationContext; import org.eclipse.core.runtime.CoreException; @@ -36,7 +37,15 @@ public class TypeInstantiationRequest { public TypeInstantiationRequest(IType type, InstantiationContext context) { this.type = type; - this.parameterMap = context.getParameterMap(); + /* + * If the InstantiationContext was created during template argument deduction, its parameter map + * can be modified later in the deduction process. Since the TypeInstantiationRequest is used + * as a key in various caches, we don't want the map changing after constructing this object, + * so clone the map is such cases. + */ + this.parameterMap = context.isForDeduction() + ? new CPPTemplateParameterMap((CPPTemplateParameterMap) context.getParameterMap()) + : context.getParameterMap(); this.packOffset = context.getPackOffset(); this.contextTypeSpecialization = context.getContextTypeSpecialization(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassSpecialization.java index 37f0da7e435..ab8380c065e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassSpecialization.java @@ -45,7 +45,7 @@ import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory; public class CompositeCPPClassSpecialization extends CompositeCPPClassType implements ICPPClassSpecialization { private ObjectMap specializationMap; - private final ThreadLocal<Set<IBinding>> fInProgress = new ThreadLocal<Set<IBinding>>() { + private final ThreadLocal<Set<IBinding>> fInProgress = new ThreadLocal<>() { @Override protected Set<IBinding> initialValue() { return new HashSet<>(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ParserMessages.properties b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ParserMessages.properties index b867ea44e76..bc9e25aeab0 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ParserMessages.properties +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ParserMessages.properties @@ -30,6 +30,7 @@ ScannerProblemFactory.error.preproc.macroPasting=Invalid use of macro pasting in ScannerProblemFactory.error.preproc.missingRParen=missing '')'' in parameter list of macro: {0} ScannerProblemFactory.error.preproc.invalidVaArgs=__VA_ARGS__ can only appear in the expansion of a variadic macro\u0020 ScannerProblemFactory.error.preproc.multipleUserDefinedLiteralSuffixesOnStringLiteral=Multiple user-defined suffixes found when concatenating string literals +ScannerProblemFactory.error.preproc.invalidUsageOutsidePreprocDirective="{0}" can only appear in a preprocessor directive ScannerProblemFactory.error.scanner.invalidEscapeChar=Invalid escape character encountered\u0020 ScannerProblemFactory.error.scanner.unboundedString=Unbounded string encountered\u0020 diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/CPreprocessor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/CPreprocessor.java index c6f17142c50..4a8762f0af7 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/CPreprocessor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/CPreprocessor.java @@ -92,6 +92,8 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { public static final int tNOSPACE = IToken.FIRST_RESERVED_PREPROCESSOR + 4; public static final int tMACRO_PARAMETER = IToken.FIRST_RESERVED_PREPROCESSOR + 5; public static final int t__HAS_FEATURE = IToken.FIRST_RESERVED_PREPROCESSOR + 6; + public static final int t__HAS_INCLUDE = IToken.FIRST_RESERVED_PREPROCESSOR + 7; + public static final int t__HAS_INCLUDE_NEXT = IToken.FIRST_RESERVED_PREPROCESSOR + 8; private static final int ORIGIN_PREPROCESSOR_DIRECTIVE = OffsetLimitReachedException.ORIGIN_PREPROCESSOR_DIRECTIVE; private static final int ORIGIN_INACTIVE_CODE = OffsetLimitReachedException.ORIGIN_INACTIVE_CODE; @@ -177,13 +179,19 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { T checkFile(String path, boolean isHeuristicMatch, IncludeSearchPathElement onPath); } - final private IIncludeFileTester<InternalFileContent> createCodeReaderTester = new IIncludeFileTester<InternalFileContent>() { + final private IIncludeFileTester<InternalFileContent> createCodeReaderTester = new IIncludeFileTester<>() { @Override public InternalFileContent checkFile(String path, boolean isHeuristicMatch, IncludeSearchPathElement onPath) { final InternalFileContent fc; IFileNomination once = fFileContentProvider.isIncludedWithPragmaOnceSemantics(path); if (once != null) { - fc = new InternalFileContent(path, InclusionKind.SKIP_FILE); + ISignificantMacros significantMacros = ISignificantMacros.NONE; + try { + significantMacros = once.getSignificantMacros(); + } catch (CoreException e) { + CCorePlugin.log(e); + } + fc = new InternalFileContent(path, InclusionKind.SKIP_PRAGMA_ONCE_FILE, significantMacros); } else { fc = fFileContentProvider.getContentForInclusion(path, fMacroDictionaryFacade); } @@ -205,7 +213,7 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { } } - final private IIncludeFileTester<IncludeResolution> createPathTester = new IIncludeFileTester<IncludeResolution>() { + final private IIncludeFileTester<IncludeResolution> createPathTester = new IIncludeFileTester<>() { @Override public IncludeResolution checkFile(String path, boolean isHeuristicMatch, IncludeSearchPathElement onPath) { if (fFileContentProvider.getInclusionExists(path)) { @@ -1323,6 +1331,11 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { } + InternalFileContent findInclusion(final String includeDirective, final boolean quoteInclude, + final boolean includeNext) { + return findInclusion(includeDirective, quoteInclude, includeNext, getCurrentFilename(), createCodeReaderTester); + } + private <T> T findInclusion(final String includeDirective, final boolean quoteInclude, final boolean includeNext, final String currentFile, final IIncludeFileTester<T> tester) { T reader = null; @@ -1783,11 +1796,19 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { case SKIP_FILE: // Already included or fast parsing mode. break; + + case SKIP_PRAGMA_ONCE_FILE: + fCurrentContext.addSignificantMacros(fi.getSignificantMacros()); + break; } if (stmt == null) { // Found in index or skipped. stmt = fLocationMap.encounterPoundInclude(poundOffset, nameOffsets[0], nameOffsets[1], condEndOffset, headerName, path, userInclude, active, isHeuristic, nominationDelegate); + if (fi.getKind() == InclusionKind.SKIP_PRAGMA_ONCE_FILE) { + stmt.setSignificantMacros(fi.getSignificantMacros()); + stmt.setPragamOnceSemantics(true); + } } // In a pragma once context store loaded versions of this non-pragma-once include if (pragmaOnceContext && loadedVerisons != null && !loadedVerisons.isEmpty()) { @@ -1805,10 +1826,11 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { for (FileVersion version : fi.getNonPragmaOnceVersions()) { fFileContentProvider.addLoadedVersions(version.fPath, Integer.MAX_VALUE, version.fSigMacros); } + fLocationMap.skippedFile(fLocationMap.getSequenceNumberForOffset(offset), fi); } - private char[] extractHeaderName(final char[] image, final char startDelim, final char endDelim, int[] offsets) { + char[] extractHeaderName(final char[] image, final char startDelim, final char endDelim, int[] offsets) { char[] headerName; int start = 0; int length = image.length; @@ -2124,9 +2146,6 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { * If applicable the macro is expanded and the resulting tokens are put onto a new context. * @param identifier the token where macro expansion may occur. * @param lexer the input for the expansion. - * @param stopAtNewline whether or not tokens to be read are limited to the current line. - * @param isPPCondition whether the expansion is inside of a preprocessor condition. This - * implies a specific handling for the defined token. */ private boolean expandMacro(final Token identifier, Lexer lexer, int options, boolean withinExpansion) throws OffsetLimitReachedException { @@ -2141,7 +2160,24 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { identifier.setType(t__HAS_FEATURE); return false; } + if (CharArrayUtils.equals(name, Keywords.c__HAS_INCLUDE)) { + identifier.setType(t__HAS_INCLUDE); + return false; + } + if (CharArrayUtils.equals(name, Keywords.c__HAS_INCLUDE_NEXT)) { + identifier.setType(t__HAS_INCLUDE_NEXT); + return false; + } } + + // These should not expand as macros and are not allowed outside #if, #ifdef + if (CharArrayUtils.equals(name, Keywords.c__HAS_INCLUDE) + || CharArrayUtils.equals(name, Keywords.c__HAS_INCLUDE_NEXT)) { + handleProblem(IProblem.PREPROCESSOR_INVALID_USE_OUTSIDE_PREPROCESSOR_DIRECTIVE, name, + identifier.getOffset(), identifier.getEndOffset()); + return false; + } + PreprocessorMacro macro = fMacroDictionary.get(name); if (macro == null) { if (reportSignificant && (options & IGNORE_UNDEFINED_SIGNIFICANT_MACROS) == 0) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ExpressionEvaluator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ExpressionEvaluator.java index 405010c737a..8e589416f21 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ExpressionEvaluator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ExpressionEvaluator.java @@ -265,6 +265,10 @@ public class ExpressionEvaluator { return handleDefined(); case CPreprocessor.t__HAS_FEATURE: return handleHasFeature(); + case CPreprocessor.t__HAS_INCLUDE: + return handleHasInclude(false); + case CPreprocessor.t__HAS_INCLUDE_NEXT: + return handleHasInclude(true); case IToken.tLPAREN: consume(); long r1 = expression(); @@ -350,6 +354,51 @@ public class ExpressionEvaluator { return supported ? 1 : 0; } + private long handleHasInclude(boolean isIncludeNext) throws EvalException { + consume(); // '__has_include' + if (LA() != IToken.tLPAREN) { + throw new EvalException(IProblem.SCANNER_EXPRESSION_SYNTAX_ERROR, null); + } + consume(); // opening parenthesis + + // We don't have a tSYSTEM_HEADER_NAME or tQUOTED_HEADER_NAME token type here, these only get created when + // executing an include directive. In the case of a tSTRING, we only have to extract the header name from the + // quotes (extractHeaderName) but for system header, we have to reassemble the string by concatenating the + // tokens. + // A possibly more elegant solution could be to generate tSYSTEM_HEADER_NAME or tQUOTED_HEADER_NAME (during + // internalFetchToken?) but this is more ambitious and intrusive (more refactoring), especially considering + // various cases like macro expansion. + String headerName; + boolean quoteInclude = false; + if (LA() == IToken.tLT) { + headerName = ""; //$NON-NLS-1$ + while (fTokens.getType() != IToken.tGT) { + if (fTokens.getType() == IToken.tEND_OF_INPUT) { + throw new EvalException(IProblem.SCANNER_UNBOUNDED_STRING, null); + } + headerName += fTokens.getImage(); + consume(); + } + consume(); + headerName += ">"; //$NON-NLS-1$ + headerName = new String(fPreprocessor.extractHeaderName(headerName.toCharArray(), '<', '>', new int[2])); + } else if (LA() == IToken.tSTRING) { + quoteInclude = true; + headerName = new String(fPreprocessor.extractHeaderName(fTokens.getCharImage(), '"', '"', new int[2])); + consume(); + } else { + throw new EvalException(IProblem.SCANNER_EXPRESSION_SYNTAX_ERROR, null); + } + + if (LA() != IToken.tRPAREN) { + throw new EvalException(IProblem.SCANNER_MISSING_R_PAREN, null); + } + consume(); // closing parenthesis + + boolean includePathExists = fPreprocessor.findInclusion(headerName, quoteInclude, isIncludeNext) != null; + return includePathExists ? 1 : 0; + } + private int LA() { return fTokens.getType(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/InternalFileContent.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/InternalFileContent.java index 0d78aa1dc89..e5889f72936 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/InternalFileContent.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/InternalFileContent.java @@ -33,6 +33,11 @@ public class InternalFileContent extends FileContent { */ SKIP_FILE, /** + * Instruct the preprocessor to skip this inclusion because it has pragma + * once semantic and has already been include for current translation unit. + */ + SKIP_PRAGMA_ONCE_FILE, + /** * The file and its dependents are indexed, required information is read * from there. */ @@ -67,6 +72,7 @@ public class InternalFileContent extends FileContent { private final long fTimestamp; private final long fFileSize; private final long fReadTime; + private final ISignificantMacros fSignificantMacros; /** * For skipping include files. @@ -88,6 +94,33 @@ public class InternalFileContent extends FileContent { fTimestamp = NULL_TIMESTAMP; fFileSize = NULL_FILE_SIZE; fReadTime = 0; + fSignificantMacros = null; + } + + /** + * For skipping include files that have pragma once semantic and have already been include + * in the translation unit. Only the significant macros need to be forwarded to includer. + * @param fileLocation the location of the file. + * @param kind must be {@link InclusionKind#SKIP_FILE}. + * @param significantMacros The significant macros this file. + * @throws IllegalArgumentException if fileLocation is <code>null</code> or the kind value is illegal for + * this constructor. + */ + public InternalFileContent(String fileLocation, InclusionKind kind, ISignificantMacros significantMacros) + throws IllegalArgumentException { + if (fileLocation == null || kind != InclusionKind.SKIP_PRAGMA_ONCE_FILE) { + throw new IllegalArgumentException(); + } + fKind = kind; + fFileLocation = fileLocation; + fMacroDefinitions = null; + fUsingDirectives = null; + fSource = null; + fNonPragmaOnceFiles = null; + fTimestamp = NULL_TIMESTAMP; + fFileSize = NULL_FILE_SIZE; + fReadTime = 0; + fSignificantMacros = significantMacros; } /** @@ -111,6 +144,7 @@ public class InternalFileContent extends FileContent { fTimestamp = timestamp; fFileSize = fileSize; fReadTime = fileReadTime; + fSignificantMacros = null; } /** @@ -133,6 +167,7 @@ public class InternalFileContent extends FileContent { fTimestamp = NULL_TIMESTAMP; fFileSize = NULL_FILE_SIZE; fReadTime = 0; + fSignificantMacros = null; } /** @@ -154,6 +189,7 @@ public class InternalFileContent extends FileContent { fTimestamp = NULL_TIMESTAMP; fFileSize = NULL_FILE_SIZE; fReadTime = 0; + fSignificantMacros = null; } /** @@ -274,4 +310,11 @@ public class InternalFileContent extends FileContent { public String toString() { return getSource().toString(); } + + public ISignificantMacros getSignificantMacros() { + if (fKind != InclusionKind.SKIP_PRAGMA_ONCE_FILE) { + throw new IllegalArgumentException(); + } + return fSignificantMacros; + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/MacroExpander.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/MacroExpander.java index a292c8bd945..04a7e57bb2e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/MacroExpander.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/MacroExpander.java @@ -376,6 +376,12 @@ public class MacroExpander { t.setType(CPreprocessor.t__HAS_FEATURE); result.append(t); protect = true; + } else if (protectIntrinsics && Arrays.equals(image, Keywords.c__HAS_INCLUDE)) { + t.setType(CPreprocessor.t__HAS_INCLUDE); + result.append(t); + } else if (protectIntrinsics && Arrays.equals(image, Keywords.c__HAS_INCLUDE_NEXT)) { + t.setType(CPreprocessor.t__HAS_INCLUDE_NEXT); + result.append(t); } else if (macro == null || (macro.isFunctionStyle() && !input.findLParenthesis())) { // Tricky: Don't mark function-style macros if you don't find the left parenthesis if (fReportMacros != null) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/SignificantMacros.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/SignificantMacros.java index 4d9e8a807b8..80e55a89f46 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/SignificantMacros.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/SignificantMacros.java @@ -33,7 +33,7 @@ import org.eclipse.cdt.core.parser.util.CharArrayUtils; public class SignificantMacros implements ISignificantMacros { public static final char[] DEFINED = { 0 }; public static final char[] UNDEFINED = { 1 }; - private static final Comparator<char[]> SORTER = new Comparator<char[]>() { + private static final Comparator<char[]> SORTER = new Comparator<>() { @Override public int compare(char[] s1, char[] s2) { return CharArrayUtils.compare(s1, s2); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/util/Profiler.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/util/Profiler.java index 5dd2cdafa0d..eb55a4e6cb5 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/util/Profiler.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/util/Profiler.java @@ -137,7 +137,7 @@ public class Profiler { Profiler profiler = threadProfiler.get(); if (profiler != null) { List<Map.Entry<String, Timer>> list = new ArrayList<>(profiler.timers.entrySet()); - Comparator<Map.Entry<String, Timer>> c = new Comparator<Map.Entry<String, Timer>>() { + Comparator<Map.Entry<String, Timer>> c = new Comparator<>() { @Override public int compare(Entry<String, Timer> o1, Entry<String, Timer> o2) { long diff = o2.getValue().getElapsedTime() - o1.getValue().getElapsedTime(); @@ -153,7 +153,7 @@ public class Profiler { if (!profiler.counters.isEmpty()) { List<Map.Entry<String, int[]>> keyList = new ArrayList<>(profiler.counters.entrySet()); - Comparator<Map.Entry<String, int[]>> c2 = new Comparator<Map.Entry<String, int[]>>() { + Comparator<Map.Entry<String, int[]>> c2 = new Comparator<>() { @Override public int compare(Entry<String, int[]> o1, Entry<String, int[]> o2) { return o2.getValue()[0] - o1.getValue()[0]; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/CModelListener.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/CModelListener.java index 5b750f5d232..364b6519edb 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/CModelListener.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/CModelListener.java @@ -42,7 +42,7 @@ public class CModelListener implements IElementChangedListener, IResourceChangeL public static boolean sSuppressUpdateOfLastRecentlyUsed = false; private PDOMManager fManager; - private final LinkedHashMap<ITranslationUnit, ITranslationUnit> fLRUs = new LinkedHashMap<ITranslationUnit, ITranslationUnit>( + private final LinkedHashMap<ITranslationUnit, ITranslationUnit> fLRUs = new LinkedHashMap<>( UPDATE_LR_CHANGED_FILES_COUNT, 0.75f, true) { @Override protected boolean removeEldestEntry(Map.Entry<ITranslationUnit, ITranslationUnit> eldest) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java index b7153a85968..4cff50e8adb 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java @@ -308,10 +308,13 @@ public class PDOM extends PlatformObject implements IPDOM { * 217.0 - Added nodiscard class/struct information, bug 534420 * 218.0 - Added nodiscard enums information, bug 534420 * 219.0 - Fix enums nodiscard information in the index from 8 byte to 1 byte, bug 534420 + * + * CDT 10.4 development + * 220.0 - Changed marshalling of CPPBasicType to store new "from literal" flag, bug 573764 */ - private static final int MIN_SUPPORTED_VERSION = version(219, 0); - private static final int MAX_SUPPORTED_VERSION = version(219, Short.MAX_VALUE); - private static final int DEFAULT_VERSION = version(219, 0); + private static final int MIN_SUPPORTED_VERSION = version(220, 0); + private static final int MAX_SUPPORTED_VERSION = version(220, Short.MAX_VALUE); + private static final int DEFAULT_VERSION = version(220, 0); private static int version(int major, int minor) { return (major << 16) + minor; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMLinkage.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMLinkage.java index 170f025f470..42615e71cc4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMLinkage.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMLinkage.java @@ -87,7 +87,7 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage * The set of types currently being loaded from the index on each thread, represented as record numbers. * This is used to guard against infinite recursion while loading types. */ - private static final ThreadLocal<Set<Long>> fLoadTypeInProgress = new ThreadLocal<Set<Long>>() { + private static final ThreadLocal<Set<Long>> fLoadTypeInProgress = new ThreadLocal<>() { @Override protected Set<Long> initialValue() { return new HashSet<>(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassSpecialization.java index 88e5ea11808..9e9364d6c56 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassSpecialization.java @@ -76,7 +76,7 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization private volatile ICPPClassScope fScope; private ObjectMap specializationMap; // Obtained from the synchronized PDOM cache. - private final ThreadLocal<Set<IBinding>> fInProgress = new ThreadLocal<Set<IBinding>>() { + private final ThreadLocal<Set<IBinding>> fInProgress = new ThreadLocal<>() { @Override protected Set<IBinding> initialValue() { return new HashSet<>(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java index 9b683b08a2e..991f3ef73eb 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java @@ -143,6 +143,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalTypeId; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalUnary; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalUnaryTypeID; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExecBreak; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExecBuiltin; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExecCase; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExecCompoundStatement; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExecConstructorChain; @@ -1771,6 +1772,8 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { return ExecConstructorChain.unmarshal(firstBytes, buffer); case ITypeMarshalBuffer.EXEC_INCOMPLETE: return ExecIncomplete.unmarshal(firstBytes, buffer); + case ITypeMarshalBuffer.EXEC_BUILTIN: + return ExecBuiltin.unmarshal(firstBytes, buffer); } throw new CoreException(CCorePlugin.createStatus("Cannot unmarshal an execution, first bytes=" + firstBytes)); //$NON-NLS-1$ } diff --git a/core/org.eclipse.cdt.core/plugin.properties b/core/org.eclipse.cdt.core/plugin.properties index 4de10e9378a..8cf6be710bb 100755..100644 --- a/core/org.eclipse.cdt.core/plugin.properties +++ b/core/org.eclipse.cdt.core/plugin.properties @@ -57,6 +57,8 @@ CDTGNUCErrorParser.regex.ReportedOnlyOnce=(.*?):(\\d+):(\\d+:)? .*\\(Each undecl CDTGNUCErrorParser.regex.ForEachFunctionItAppearsIn=(.*?):(\\d+):(\\d+:)? .*for each function it appears in.\\).* 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 .*) @@ -72,6 +74,7 @@ CDTGNULinkerErrorParser.regex.InFunction=(.*?):?(\\(\\.[^\\s+]+\\+.*\\))?:\\s*(I CDTGNULinkerErrorParser.regex.WarningDangerousFunction=(.*?):(\\d+):(\\d+:)? ([Ww]arning:)?\\s*(the use of [`'"](.*)['"] is dangerous, better use [`'"](.*)['"].*) CDTGNULinkerErrorParser.regex.TextWarning=(.*?):?\\(\\.[^\\s+]+\\+.*\\): [Ww]arning:? (.*) CDTGNULinkerErrorParser.regex.TextError=(.*?):?\\(\\.[^\\s+]+\\+.*\\): (.*) +CDTGNULinkerErrorParser.regex.ldInfo=(.*[/\\\\])?ld(\\.exe)?: ((mode|Removing unused section) .*) CDTGNULinkerErrorParser.regex.ldWarning=(.*[/\\\\])?ld(\\.exe)?: [Ww]arning:? (.*) CDTGNULinkerErrorParser.regex.ldError=(.*[/\\\\])?ld(\\.exe)?: (.*) diff --git a/core/org.eclipse.cdt.core/plugin.xml b/core/org.eclipse.cdt.core/plugin.xml index 2ebf769eb26..8e1bcb7822c 100644 --- a/core/org.eclipse.cdt.core/plugin.xml +++ b/core/org.eclipse.cdt.core/plugin.xml @@ -194,6 +194,22 @@ <pattern description-expr="$5" eat-processed-line="true" file-expr="$1" line-expr="$2" regex="%CDTGNULinkerErrorParser.regex.WarningDangerousFunction" severity="Warning" variable-expr="$6"/> <pattern description-expr="$4" eat-processed-line="true" file-expr="$1" line-expr="$2" regex="%CDTGNUCErrorParser.regex.InstantiatedFromHere" severity="Info"/> <pattern + description-expr="$4" + eat-processed-line="true" + file-expr="$1" + line-expr="$2" + regex="%CDTGNUCErrorParser.regex.SkippingInstantiationContexts" + 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" @@ -257,6 +273,13 @@ eat-processed-line="true" file-expr="" line-expr="" + regex="%CDTGNULinkerErrorParser.regex.ldInfo" + severity="Info"/> + <pattern + description-expr="$3" + eat-processed-line="true" + file-expr="" + line-expr="" regex="%CDTGNULinkerErrorParser.regex.ldWarning" severity="Warning"/> <pattern diff --git a/core/org.eclipse.cdt.core/schema/templates.exsd b/core/org.eclipse.cdt.core/schema/templates.exsd index 082ffd555ed..347820e49cc 100644 --- a/core/org.eclipse.cdt.core/schema/templates.exsd +++ b/core/org.eclipse.cdt.core/schema/templates.exsd @@ -102,7 +102,7 @@ It's no longer manditory since templates are no longer organized by project <attribute name="filterPattern" type="string"> <annotation> <documentation> - filterPattern is a java.util.regex.Pattern format string which is used to match against build configuration ids. This is an optional attribute, if absent will all configurations will match. + filterPattern is a java.util.regex.Pattern format string which is used to match against language identifiers. This is an optional attribute, if absent all languages will match. </documentation> </annotation> </attribute> diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java index acecfbc1e78..cdf0d2f204f 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java @@ -1009,8 +1009,8 @@ public class CCorePlugin extends Plugin { /** * Method convertProjectFromCtoCC converts a C Project to a C++ Project The - * newProject MUST, not be null, already have a C Nature && must NOT already - * have a C++ Nature + * newProject MUST, not be null, already have a C Nature && must + * NOT already have a C++ Nature * * @param projectHandle * @param monitor @@ -1455,7 +1455,7 @@ public class CCorePlugin extends Plugin { * set call after that the description communicates directly to * the Build System i.e. the implementer of the * org.eclipse.cdt.core.CConfigurationDataProvider extension This - * ensures the Core<->Build System settings integrity. + * ensures the Core<->Build System settings integrity. * * @return {@link ICProjectDescription} or null if the project does not * contain the CDT data associated with it. diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CommandLauncher.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CommandLauncher.java index 0c3d27310e2..ed4c45059d7 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CommandLauncher.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CommandLauncher.java @@ -134,9 +134,6 @@ public class CommandLauncher implements ICommandLauncher { if (pos < 0) pos = envStr.length(); String key = envStr.substring(0, pos); - if (Platform.getOS().equals(Platform.OS_WIN32)) { - key = key.toUpperCase(); - } String value = envStr.substring(pos + 1); fEnvironment.put(key, value); } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CommandLauncherManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CommandLauncherManager.java index ef4d8459987..538c7f3fe4d 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CommandLauncherManager.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CommandLauncherManager.java @@ -334,6 +334,17 @@ public class CommandLauncherManager { return includePaths; } + /** + * @since 7.0 + */ + public boolean checkIfIncludesChanged(ICBuildConfiguration config) { + ICommandLauncherFactory factory = getBestFactory(config); + if (factory != null && factory instanceof ICommandLauncherFactory3) { + return ((ICommandLauncherFactory3) factory).checkIfIncludesChanged(config); + } + return false; + } + public void setLanguageSettingEntries(IProject project, List<? extends ICLanguageSettingEntry> entries) { ICommandLauncherFactory factory = getBestFactory(project); if (factory != null) { diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ICDescriptorManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ICDescriptorManager.java index 6f5a9a52f6b..2922dbf2338 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ICDescriptorManager.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ICDescriptorManager.java @@ -21,7 +21,7 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; /** - * @deprecated replace with {@link ICProjectDescriptionManager} & {@link ICProjectDescription} + * @deprecated replace with {@link ICProjectDescriptionManager} & {@link ICProjectDescription} * @noreference This interface is not intended to be referenced by clients. */ @Deprecated diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ICExtensionReference.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ICExtensionReference.java index 9e46f73feea..15f9b5c2cff 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ICExtensionReference.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ICExtensionReference.java @@ -98,8 +98,8 @@ public interface ICExtensionReference { * * <pre> * <view> - *     <verticalHint>top</verticalHint> - *     <horizontalHint>left</horizontalHint> + * <verticalHint>top</verticalHint> + * <horizontalHint>left</horizontalHint> * </view> * </pre> * diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ICommandLauncherFactory3.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ICommandLauncherFactory3.java new file mode 100644 index 00000000000..692494ada97 --- /dev/null +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ICommandLauncherFactory3.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2020 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 + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat Inc. - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.core; + +import org.eclipse.cdt.core.build.ICBuildConfiguration; + +/** + * @since 7.0 + * + */ +public interface ICommandLauncherFactory3 { + + /** + * Check if any copied header files have changed. This applies when using + * Flatpak which needs to copy the host's header files to the workspace. + * + * @param cfg - C Build configuration to check for + * @return true if headers have been removed/changed since last copy, false otherwise + */ + public boolean checkIfIncludesChanged(ICBuildConfiguration cfg); + +} diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ISourceFinder.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ISourceFinder.java index b2f6a296e98..41659fa11ac 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ISourceFinder.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ISourceFinder.java @@ -30,8 +30,8 @@ import org.eclipse.core.runtime.IAdaptable; * <p> * CDT has: * <ul> - * <li>A global (common) source locator. Its containers are defined via Window > Preferences > C/C++ > Debug > - * Source Lookup Path + * <li>A global (common) source locator. Its containers are defined via Window > Preferences > + * C/C++ > Debug > Source Lookup Path * <li>Launch configuration source locators. The containers of such a locator are defined via the 'Source' tab * in a CDT launch configuration. The common source containers are automatically added to this locator. * <li>Launch source locators. Typically, a launch's locator is the one defined in the launch configuration 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 7fde565b580..039e1a4518b 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2015, 2019 QNX Software Systems and others. + * Copyright (c) 2015, 2022 QNX Software Systems and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -10,16 +10,10 @@ *******************************************************************************/ package org.eclipse.cdt.core.build; -import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; -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,15 +22,17 @@ 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 java.util.stream.Collectors; import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.CommandLauncherManager; +import org.eclipse.cdt.core.ICommandLauncher; import org.eclipse.cdt.core.IConsoleParser; import org.eclipse.cdt.core.IConsoleParser2; import org.eclipse.cdt.core.IMarkerGenerator; @@ -60,12 +56,14 @@ 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.BuildRunnerHelper; +import org.eclipse.cdt.internal.core.ConsoleOutputSniffer; 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; @@ -91,12 +89,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 @@ -123,6 +115,8 @@ public abstract class CBuildConfiguration extends PlatformObject implements ICBu private final Map<IResource, List<IScannerInfoChangeListener>> scannerInfoListeners = new HashMap<>(); private ScannerInfoCache scannerInfoCache; + private ICommandLauncher launcher; + protected CBuildConfiguration(IBuildConfiguration config, String name) throws CoreException { this.config = config; this.name = name; @@ -495,20 +489,38 @@ public abstract class CBuildConfiguration extends PlatformObject implements ICBu .write(String.format(Messages.CBuildConfiguration_CommandNotFound, commands.get(0))); return null; } - commands.set(0, commandPath.toString()); + IPath cmd = new org.eclipse.core.runtime.Path(commandPath.toString()); + List<String> args = commands.subList(1, commands.size()); + + // check if includes have been removed/refreshed and scanner info refresh is needed + boolean needRefresh = CommandLauncherManager.getInstance().checkIfIncludesChanged(this); + IToolChain t = getToolChain(); + if (t != null) { + t.setProperty(NEED_REFRESH, Boolean.valueOf(needRefresh).toString()); + } - ProcessBuilder processBuilder = new ProcessBuilder(commands).directory(buildDirectory.toFile()); - // Override environment variables - Map<String, String> environment = processBuilder.environment(); + // Generate environment block before launching process + launcher = CommandLauncherManager.getInstance().getCommandLauncher(this); + Properties envProps = launcher.getEnvironment(); + HashMap<String, String> environment = envProps.entrySet().stream() + .collect(Collectors.toMap(e -> String.valueOf(e.getKey()), e -> String.valueOf(e.getValue()), + (prev, next) -> next, HashMap::new)); for (IEnvironmentVariable envVar : envVars) { environment.put(envVar.getName(), envVar.getValue()); } setBuildEnvironment(environment); - process = processBuilder.start(); + launcher.setProject(getProject()); + process = launcher.execute(cmd, args.toArray(new String[0]), BuildRunnerHelper.envMapToEnvp(environment), + buildDirectory, monitor); } return process; } + /** + * @return The exit code of the build process. + * + * @deprecated use {@link #watchProcess(IConsole, IProgressMonitor)} or {@link #watchProcess(IConsoleParser[], IProgressMonitor)} instead + */ @Deprecated protected int watchProcess(Process process, IConsoleParser[] consoleParsers, IConsole console) throws CoreException { @@ -520,110 +532,42 @@ public abstract class CBuildConfiguration extends PlatformObject implements ICBu } /** + * @return The exit code of the build process. * @since 6.4 + * + * @deprecated use {@link #watchProcess(IConsole, IProgressMonitor)} instead and pass in a monitor */ + @Deprecated protected int watchProcess(Process process, IConsole console) throws CoreException { - Thread t1 = new ReaderThread(process.getInputStream(), console.getOutputStream()); - t1.start(); - Thread t2 = new ReaderThread(process.getErrorStream(), console.getErrorStream()); - t2.start(); - try { - int rc = process.waitFor(); - // Allow reader threads the chance to process all output to console - while (t1.isAlive()) { - Thread.sleep(100); - } - while (t2.isAlive()) { - Thread.sleep(100); - } - return rc; - } catch (InterruptedException e) { - CCorePlugin.log(e); - return -1; - } + return watchProcess(console, new NullProgressMonitor()); } /** + * @return The exit code of the build process. + * @since 7.5 + */ + protected int watchProcess(IConsole console, IProgressMonitor monitor) throws CoreException { + return launcher.waitAndRead(console.getInfoStream(), console.getErrorStream(), monitor); + } + + /** + * @return The exit code of the build process. * @since 6.4 + * + * @deprecated use {@link #watchProcess(IConsoleParser[], IProgressMonitor)} instead and pass in a monitor */ + @Deprecated protected int watchProcess(Process process, IConsoleParser[] consoleParsers) throws CoreException { - Thread t1 = new ReaderThread(this, process.getInputStream(), consoleParsers); - t1.start(); - Thread t2 = new ReaderThread(this, process.getErrorStream(), consoleParsers); - t2.start(); - try { - int rc = process.waitFor(); - // Allow reader threads the chance to process all output to console - while (t1.isAlive()) { - Thread.sleep(100); - } - while (t2.isAlive()) { - Thread.sleep(100); - } - return rc; - } catch (InterruptedException e) { - CCorePlugin.log(e); - return -1; - } + return watchProcess(consoleParsers, new NullProgressMonitor()); } - private static class ReaderThread extends Thread { - CBuildConfiguration config; - private final BufferedReader in; - private final IConsoleParser[] consoleParsers; - private final PrintStream out; - - public ReaderThread(CBuildConfiguration config, InputStream in, IConsoleParser[] consoleParsers) { - this.config = config; - this.in = new BufferedReader(new InputStreamReader(in)); - this.out = null; - this.consoleParsers = consoleParsers; - } - - public ReaderThread(InputStream in, OutputStream out) { - this.in = new BufferedReader(new InputStreamReader(in)); - this.out = new PrintStream(out); - this.consoleParsers = null; - this.config = null; - } - - @Override - public void run() { - List<Job> jobList = new ArrayList<>(); - try { - for (String line = in.readLine(); line != null; line = in.readLine()) { - if (consoleParsers != null) { - for (IConsoleParser consoleParser : consoleParsers) { - // Synchronize to avoid interleaving of lines - synchronized (consoleParser) { - // if we have an IConsoleParser2, use the processLine method that - // takes a job list (Container Build support) - if (consoleParser instanceof IConsoleParser2) { - ((IConsoleParser2) consoleParser).processLine(line, jobList); - } else { - consoleParser.processLine(line); - } - } - } - } - if (out != null) { - out.println(line); - } - } - for (Job j : jobList) { - try { - j.join(); - } catch (InterruptedException e) { - // ignore - } - } - if (config != null) { - config.shutdown(); - } - } catch (IOException e) { - CCorePlugin.log(e); - } - } + /** + * @return The exit code of the build process. + * @since 7.5 + */ + protected int watchProcess(IConsoleParser[] consoleParsers, IProgressMonitor monitor) throws CoreException { + ConsoleOutputSniffer sniffer = new ConsoleOutputSniffer(consoleParsers); + return launcher.waitAndRead(sniffer.getOutputStream(), sniffer.getErrorStream(), monitor); } private File getScannerInfoCacheFile() { @@ -631,63 +575,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 */ @@ -697,15 +584,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(); @@ -713,6 +599,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 */ @@ -728,7 +622,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); } @@ -779,7 +673,24 @@ public abstract class CBuildConfiguration extends PlatformObject implements ICBu synchronized (scannerInfoLock) { info = scannerInfoCache.getScannerInfo(resource); } - if (info == null || info.getIncludePaths().length == 0) { + // Following is a kludge to fix Bug 579668 whereby sometimes a timing + // bug occurs and scanner info for a project that specifies a container target + // has not initialized the include paths correctly to point to copied includes + // from the image target. We check to see if org.eclipse.cdt.docker.launcher is + // found in the include paths which is the .plugin directory where we copy headers + // to in the .metadata folder. + boolean needsFixing = false; + if (info != null && info.getIncludePaths().length > 0 && toolChain != null + && toolChain.getId().startsWith("gcc-img-sha")) { //$NON-NLS-1$ + needsFixing = true; + for (String includePath : info.getIncludePaths()) { + if (includePath.contains("org.eclipse.cdt.docker.launcher")) { //$NON-NLS-1$ + needsFixing = false; + break; + } + } + } + if (info == null || info.getIncludePaths().length == 0 || needsFixing) { ICElement celement = CCorePlugin.getDefault().getCoreModel().create(resource); if (celement instanceof ITranslationUnit) { try { @@ -894,11 +805,9 @@ public abstract class CBuildConfiguration extends PlatformObject implements ICBu boolean needScannerRefresh = false; - if (toolChain instanceof IToolChain2) { - String needRefresh = toolChain.getProperty(NEED_REFRESH); - if ("true".equals(needRefresh)) { //$NON-NLS-1$ - needScannerRefresh = true; - } + String needRefresh = toolChain.getProperty(NEED_REFRESH); + if ("true".equals(needRefresh)) { //$NON-NLS-1$ + needScannerRefresh = true; } for (IResource resource : resources) { @@ -1024,11 +933,9 @@ public abstract class CBuildConfiguration extends PlatformObject implements ICBu boolean needScannerRefresh = false; - if (toolChain instanceof IToolChain2) { - String needRefresh = toolChain.getProperty(NEED_REFRESH); - if ("true".equals(needRefresh)) { //$NON-NLS-1$ - needScannerRefresh = true; - } + String needRefresh = toolChain.getProperty(NEED_REFRESH); + if ("true".equals(needRefresh)) { //$NON-NLS-1$ + needScannerRefresh = true; } for (IResource resource : resources) { diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/StandardBuildConfiguration.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/StandardBuildConfiguration.java index d10351cb41a..9f0d72803c0 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/StandardBuildConfiguration.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/StandardBuildConfiguration.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2016 QNX Software Systems and others. + * Copyright (c) 2016, 2022 QNX Software Systems and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -267,7 +267,7 @@ public class StandardBuildConfiguration extends CBuildConfiguration { } IConsoleParser[] consoleParsers = new IConsoleParser[] { epm, this }; - watchProcess(p, consoleParsers); + watchProcess(consoleParsers, monitor); project.refreshLocal(IResource.DEPTH_INFINITE, monitor); @@ -326,7 +326,7 @@ public class StandardBuildConfiguration extends CBuildConfiguration { return; } - watchProcess(p, console); + watchProcess(console, monitor); outStream.write(Messages.CBuildConfiguration_BuildComplete); diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/cdtvariables/ICdtVariableManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/cdtvariables/ICdtVariableManager.java index dac29b6c897..734bd2d3726 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/cdtvariables/ICdtVariableManager.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/cdtvariables/ICdtVariableManager.java @@ -58,7 +58,7 @@ public interface ICdtVariableManager { /** * * converts StringList value into String of the following format: - * "<value_1>< listDelimiter ><value_2>< listDelimiter > ... <value_n>" + * "<value_1>< listDelimiter ><value_2>< listDelimiter > ... <value_n>" */ public String convertStringListToString(String value[], String listDelimiter); @@ -70,7 +70,7 @@ public interface ICdtVariableManager { * expanded to. If null the BuildMacroException is thrown in case the string to be resolved * references inexistent macros * @param listDelimiter if not null, StringList macros are expanded as - * "<value_1>< listDelimiter ><value_2>< listDelimiter > ... <value_n>" + * "<value_1>< listDelimiter ><value_2>< listDelimiter > ... <value_n>" * otherwise the BuildMacroException is thrown in case the string to be resolved references * string-list macros */ diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/envvar/IEnvironmentVariable.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/envvar/IEnvironmentVariable.java index 68ff1545f50..99447f9d12f 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/envvar/IEnvironmentVariable.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/envvar/IEnvironmentVariable.java @@ -50,9 +50,9 @@ public interface IEnvironmentVariable { * If the variable already exists and contains some value the new * value will be calculated in the following way: * For the "prepend" operation: - * <New value> = <the value from the getValue() method><delimiter><Old value> + * <New value> = <the value from the getValue() method><delimiter><Old value> * For the "append" operation: - * <New value> = <Old value><delimiter><the value from the getValue() method> + * <New value> = <Old value><delimiter><the value from the getValue() method> * * The Environment Variable Provider will also remove the duplicates of "sub-values" * in the resulting value. diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/envvar/IEnvironmentVariableManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/envvar/IEnvironmentVariableManager.java index ef559b3c099..935c723a90f 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/envvar/IEnvironmentVariableManager.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/envvar/IEnvironmentVariableManager.java @@ -101,11 +101,5 @@ public interface IEnvironmentVariableManager { */ public String getDefaultDelimiter(); - /** - * @return true if the OS supports case sensitive variables (Unix-like systems) or false - * if it does not (Win32 systems) - */ - public boolean isVariableCaseSensitive(); - public IContributedEnvironment getContributedEnvironment(); } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/formatter/DefaultCodeFormatterConstants.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/formatter/DefaultCodeFormatterConstants.java index e2f3b9c0bcc..e7bed19c143 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/formatter/DefaultCodeFormatterConstants.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/formatter/DefaultCodeFormatterConstants.java @@ -1624,32 +1624,6 @@ public class DefaultCodeFormatterConstants { + ".formatter.insert_space_before_lambda_return"; //$NON-NLS-1$ /** * <pre> - * FORMATTER / Option to insert a space after deduction guide arrow - * - option id: "org.eclipse.cdt.core.formatter.insert_space_after_deduction_guide_arrow" - * - possible values: { INSERT, DO_NOT_INSERT } - * - default: INSERT - * </pre> - * @see CCorePlugin#INSERT - * @see CCorePlugin#DO_NOT_INSERT - * @since 7.0 - */ - public static final String FORMATTER_INSERT_SPACE_AFTER_DEDUCTION_GUIDE_ARROW = CCorePlugin.PLUGIN_ID - + ".formatter.insert_space_after_deduction_guide_arrow"; //$NON-NLS-1$ - /** - * <pre> - * FORMATTER / Option to insert a space before deduction guide arrow - * - option id: "org.eclipse.cdt.core.formatter.insert_space_before_deduction_guide_arrow" - * - possible values: { INSERT, DO_NOT_INSERT } - * - default: INSERT - * </pre> - * @see CCorePlugin#INSERT - * @see CCorePlugin#DO_NOT_INSERT - * @since 7.0 - */ - public static final String FORMATTER_INSERT_SPACE_BEFORE_DEDUCTION_GUIDE_ARROW = CCorePlugin.PLUGIN_ID - + ".formatter.insert_space_before_deduction_guide_arrow"; //$NON-NLS-1$ - /** - * <pre> * FORMATTER / Option to insert a space before an assignment operator * - option id: "org.eclipse.cdt.core.formatter.insert_space_before_assignment_operator" * - possible values: { INSERT, DO_NOT_INSERT } @@ -2893,9 +2867,9 @@ public class DefaultCodeFormatterConstants { } /** - * Returns the K&R formatter settings + * Returns the K&R formatter settings * - * @return the K&R settings + * @return the K&R settings */ public static Map<String, String> getKandRSettings() { return DefaultCodeFormatterOptions.getKandRSettings().getMap(); diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/formatter/DefaultCodeFormatterOptions.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/formatter/DefaultCodeFormatterOptions.java index 4a54656a378..33378fde3e6 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/formatter/DefaultCodeFormatterOptions.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/formatter/DefaultCodeFormatterOptions.java @@ -224,14 +224,6 @@ public class DefaultCodeFormatterOptions { * @since 6.8 */ public boolean insert_space_before_lambda_return; - /** - * @since 7.0 - */ - public boolean insert_space_after_deduction_guide_arrow; - /** - * @since 7.0 - */ - public boolean insert_space_before_deduction_guide_arrow; public boolean insert_space_before_assignment_operator; public boolean insert_space_before_binary_operator; public boolean insert_space_before_closing_angle_bracket_in_template_arguments; @@ -638,10 +630,6 @@ public class DefaultCodeFormatterOptions { this.insert_space_after_lambda_return ? CCorePlugin.INSERT : CCorePlugin.DO_NOT_INSERT); options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_LAMBDA_RETURN, this.insert_space_before_lambda_return ? CCorePlugin.INSERT : CCorePlugin.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_DEDUCTION_GUIDE_ARROW, - this.insert_space_after_deduction_guide_arrow ? CCorePlugin.INSERT : CCorePlugin.DO_NOT_INSERT); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_DEDUCTION_GUIDE_ARROW, - this.insert_space_before_deduction_guide_arrow ? CCorePlugin.INSERT : CCorePlugin.DO_NOT_INSERT); options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ASSIGNMENT_OPERATOR, this.insert_space_before_assignment_operator ? CCorePlugin.INSERT : CCorePlugin.DO_NOT_INSERT); options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_BINARY_OPERATOR, @@ -1768,18 +1756,6 @@ public class DefaultCodeFormatterOptions { if (insertSpaceBeforeLambdaReturnOption != null) { this.insert_space_before_lambda_return = CCorePlugin.INSERT.equals(insertSpaceBeforeLambdaReturnOption); } - final Object insertSpaceAfterDeductionGuideOption = settings - .get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_DEDUCTION_GUIDE_ARROW); - if (insertSpaceAfterDeductionGuideOption != null) { - this.insert_space_after_deduction_guide_arrow = CCorePlugin.INSERT - .equals(insertSpaceAfterDeductionGuideOption); - } - final Object insertSpaceBeforeDeductionGuideOption = settings - .get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_DEDUCTION_GUIDE_ARROW); - if (insertSpaceBeforeDeductionGuideOption != null) { - this.insert_space_before_deduction_guide_arrow = CCorePlugin.INSERT - .equals(insertSpaceBeforeDeductionGuideOption); - } final Object insertSpaceBeforeAssignmentOperatorOption = settings .get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ASSIGNMENT_OPERATOR); if (insertSpaceBeforeAssignmentOperatorOption != null) { @@ -2462,8 +2438,6 @@ public class DefaultCodeFormatterOptions { this.insert_space_after_unary_operator = false; this.insert_space_after_lambda_return = true; this.insert_space_before_lambda_return = true; - this.insert_space_after_deduction_guide_arrow = true; - this.insert_space_before_deduction_guide_arrow = true; this.insert_space_before_assignment_operator = true; this.insert_space_before_binary_operator = true; this.insert_space_before_closing_angle_bracket_in_template_arguments = false; @@ -2555,7 +2529,7 @@ public class DefaultCodeFormatterOptions { } /** - * Configure K&R style. + * Configure K&R style. * <p>Example:</p> * <pre> * namespace foospace { diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/formatter/IndentManipulation.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/formatter/IndentManipulation.java index 4a6c3d17e29..2af58f14418 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/formatter/IndentManipulation.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/formatter/IndentManipulation.java @@ -176,7 +176,7 @@ public final class IndentManipulation { /** * Removes the given number of indentation units from a given line. If the line * has less than the given indent, all the available indentation is removed. - * If <code>indentsToRemove <= 0</code> the line is returned. + * If <code>indentsToRemove <= 0</code> the line is returned. * * @param line the line to trim * @param tabWidth the width of one tab in space equivalents diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/IPathEntryVariableManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/IPathEntryVariableManager.java index 24b78f8302e..b24812532d8 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/IPathEntryVariableManager.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/IPathEntryVariableManager.java @@ -115,13 +115,13 @@ public interface IPathEntryVariableManager { * <li>BACKUP = /tmp/backup</li> * </ul> * <p>The following paths would be resolved as: - * <p>c:/bin => c:/bin</p> - * <p>c:${TEMP} => c:/temp</p> - * <p>/TEMP => /TEMP</p> - * <p>${TEMP}/foo => /temp/foo</p> - * <p>${BACKUP} => /tmp/backup</p> - * <p>${BACKUP}/bar.txt => /tmp/backup/bar.txt</p> - * <p>SOMEPATH/foo => SOMEPATH/foo</p></p> + * <p>c:/bin => c:/bin</p> + * <p>c:${TEMP} => c:/temp</p> + * <p>/TEMP => /TEMP</p> + * <p>${TEMP}/foo => /temp/foo</p> + * <p>${BACKUP} => /tmp/backup</p> + * <p>${BACKUP}/bar.txt => /tmp/backup/bar.txt</p> + * <p>SOMEPATH/foo => SOMEPATH/foo</p></p> * * @param path the path to be resolved * @return the resolved path or <code>null</code> diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/CdtMacroSupplier.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/CdtMacroSupplier.java index 4ea7a17fb4c..cc454f227a3 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/CdtMacroSupplier.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/CdtMacroSupplier.java @@ -18,10 +18,10 @@ import org.eclipse.cdt.core.cdtvariables.CdtVariable; import org.eclipse.cdt.core.cdtvariables.ICdtVariable; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICProjectDescription; -import org.eclipse.core.runtime.Platform; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.Platform; import org.osgi.framework.Bundle; /** diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/EnvVarCollector.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/EnvVarCollector.java index 2f894f82837..75288d1e690 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/EnvVarCollector.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/EnvVarCollector.java @@ -51,13 +51,10 @@ public class EnvVarCollector { ICoreEnvironmentVariableSupplier supplier) { if (vars == null) return; - boolean isCaseInsensitive = !EnvironmentVariableManager.getDefault().isVariableCaseSensitive(); for (int i = 0; i < vars.length; i++) { IEnvironmentVariable var = vars[i]; if (var != null) { String name = var.getName(); - if (isCaseInsensitive) - name = name.toUpperCase(); boolean noCheck = false; @@ -108,10 +105,6 @@ public class EnvVarCollector { public EnvVarDescriptor getVariable(String name) { if (fMap == null) return null; - - if (!EnvironmentVariableManager.getDefault().isVariableCaseSensitive()) - name = name.toUpperCase(); - return fMap.get(name); } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/EnvironmentVariableManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/EnvironmentVariableManager.java index 11712ff7e5e..23d5b6e2e1f 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/EnvironmentVariableManager.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/EnvironmentVariableManager.java @@ -365,11 +365,6 @@ public class EnvironmentVariableManager implements IEnvironmentVariableManager { return isWin32() ? DELIMITER_WIN32 : DELIMITER_UNIX; } - @Override - public boolean isVariableCaseSensitive() { - return !isWin32(); - } - public ICoreEnvironmentVariableSupplier[] getSuppliers(Object level) { IEnvironmentContextInfo info = getContextInfo(level); if (info != null) diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/resources/LocationAdapter.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/resources/LocationAdapter.java index 31f2387dc53..57150aadca8 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/resources/LocationAdapter.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/resources/LocationAdapter.java @@ -35,7 +35,7 @@ abstract class LocationAdapter<T> { public abstract T getLocation(IFile file); - public static final LocationAdapter<IPath> PATH = new LocationAdapter<IPath>() { + public static final LocationAdapter<IPath> PATH = new LocationAdapter<>() { @Override public String extractName(IPath location) { String name = location.lastSegment(); @@ -61,7 +61,7 @@ abstract class LocationAdapter<T> { } }; - public static final LocationAdapter<URI> URI = new LocationAdapter<URI>() { + public static final LocationAdapter<URI> URI = new LocationAdapter<>() { @Override public String extractName(URI location) { String path = location.getPath(); 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.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java index c32706a779e..7eee8ee0cf5 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java @@ -122,7 +122,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorInitializer; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDecltypeSpecifier; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeductionGuide; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeleteExpression; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDesignatedInitializer; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDesignator; @@ -730,8 +729,6 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor, return visit((IASTFunctionDefinition) node); } else if (node instanceof IASTSimpleDeclaration) { return visit((IASTSimpleDeclaration) node); - } else if (node instanceof ICPPASTDeductionGuide) { - return visit((ICPPASTDeductionGuide) node); } else if (node instanceof IASTASMDeclaration) { return visit((IASTASMDeclaration) node); } else if (node instanceof ICPPASTVisibilityLabel) { @@ -2031,26 +2028,6 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor, return PROCESS_SKIP; } - private int visit(ICPPASTDeductionGuide node) { - node.getTemplateName().accept(this); - final List<IASTParameterDeclaration> parameters = Arrays.asList(node.getParameters()); - Runnable tailFormatter = new TrailingSemicolonFormatter(node); - final ListOptions options = new ListOptions(preferences.alignment_for_declarator_list); - options.fSpaceAfterSeparator = preferences.insert_space_after_comma_in_declarator_list; - options.fSpaceBeforeSeparator = preferences.insert_space_before_comma_in_declarator_list; - formatList(parameters, options, true, false, null); - - if (peekNextToken() == Token.tARROW) { - scribe.printNextToken(Token.tARROW, preferences.insert_space_before_deduction_guide_arrow); - if (preferences.insert_space_after_deduction_guide_arrow) { - scribe.space(); - } - } - node.getSimpleTemplateId().accept(this); - tailFormatter.run(); - return PROCESS_SKIP; - } - private int visit(IASTSimpleDeclaration node) { if (node instanceof ICPPASTStructuredBindingDeclaration) { return visit((ICPPASTStructuredBindingDeclaration) node); @@ -4955,15 +4932,15 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor, * Collect source positions of no-format sections in the given translation unit. * * @param translationUnit the {@link IASTTranslationUnit}, may be <code>null</code> - * @return a {@link List} of {@link Position}s + * @return a modifiable {@link List} of {@link Position}s */ private List<InactivePosition> collectNoFormatCodePositions(IASTTranslationUnit translationUnit) { if (translationUnit == null || !this.preferences.use_fomatter_comment_tag) { - return Collections.emptyList(); + return new ArrayList<>(); } String fileName = translationUnit.getFilePath(); if (fileName == null) { - return Collections.emptyList(); + return new ArrayList<>(); } List<InactivePosition> positions = new ArrayList<>(); int inactiveCodeStart = -1; diff --git a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateCore.java b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateCore.java index 002853bda88..f6d321a2b60 100644 --- a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateCore.java +++ b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateCore.java @@ -46,7 +46,7 @@ public class TemplateCore { private static Map<TemplateInfo, TemplateCore> templateCache = new HashMap<>(); - public static final Comparator<TemplateCore> TEMPLATE_ID_CASE_INSENSITIVE_COMPARATOR = new Comparator<TemplateCore>() { + public static final Comparator<TemplateCore> TEMPLATE_ID_CASE_INSENSITIVE_COMPARATOR = new Comparator<>() { @Override public int compare(TemplateCore t1, TemplateCore t2) { return String.CASE_INSENSITIVE_ORDER.compare(t1.getTemplateId(), t2.getTemplateId()); diff --git a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/processes/CreateResourceIdentifier.java b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/processes/CreateResourceIdentifier.java index 9610fb333de..a82a236481d 100644 --- a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/processes/CreateResourceIdentifier.java +++ b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/processes/CreateResourceIdentifier.java @@ -22,7 +22,7 @@ import org.eclipse.core.runtime.IProgressMonitor; /** * Creates a template macro value that can be used as a pseudo-unique resource identifier. * It is based on the name of the application and is in the form of four capital letters. - * e.g. Helloworld => HELL + * e.g. Helloworld => HELL */ public class CreateResourceIdentifier extends ProcessRunner { diff --git a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/processes/SetEnvironmentVariable.java b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/processes/SetEnvironmentVariable.java index 6054a2d8124..90e63841108 100644 --- a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/processes/SetEnvironmentVariable.java +++ b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/processes/SetEnvironmentVariable.java @@ -36,15 +36,15 @@ import org.eclipse.core.runtime.IProgressMonitor; * A template process for setting an environment variable in all of the new project's * build configurations. E.g., * <pre> - * <process type="org.eclipse.cdt.core.SetEnvironmentVariable"> - * <simple name="projectName" value="$(projectName)"/> - * <complex-array name="variables"> - * <element> - * <simple name="name" value="QMAKE"/> - * <simple name="value" value="$(qmake)"/> - * </element> - * </complex-array> - * </process> + * <process type="org.eclipse.cdt.core.SetEnvironmentVariable"> + * <simple name="projectName" value="$(projectName)"/> + * <complex-array name="variables"> + * <element> + * <simple name="name" value="QMAKE"/> + * <simple name="value" value="$(qmake)"/> + * </element> + * </complex-array> + * </process> * </pre> * This will create an environment variable called "QMAKE" and will set the value to * be the value entered in a field (called qmake) in the New Project wizard. diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/XmlUtil.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/XmlUtil.java index 691319fe9e6..5dda1e8c309 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/XmlUtil.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/XmlUtil.java @@ -53,7 +53,7 @@ import org.w3c.dom.NodeList; public class XmlUtil { private static final String ENCODING_UTF_8 = "UTF-8"; //$NON-NLS-1$ private static final String EOL_XML = "\n"; //$NON-NLS-1$ - private static final String DEFAULT_IDENT = "\t"; //$NON-NLS-1$ + private static final String DEFAULT_INDENT = "\t"; //$NON-NLS-1$ private static String LINE_SEPARATOR = System.getProperty("line.separator"); //$NON-NLS-1$ /** @@ -133,10 +133,15 @@ public class XmlUtil { * to pretty print XML. This method prepares DOM {@code Document} for the transformer * to be pretty printed, i.e. providing proper indentations for enclosed tags. * + * Note, while this was originally a workaround, the user community of CDT + * has come to expect the format of the .cproject file and others to be + * unchanging, therefore CDT always uses this and does not attempt + * to format with the Transformer. + * * @param doc - DOM document to be pretty printed */ public static void prettyFormat(Document doc) { - prettyFormat(doc, DEFAULT_IDENT); + prettyFormat(doc, DEFAULT_INDENT); } /** @@ -144,14 +149,19 @@ public class XmlUtil { * to pretty print XML. This method prepares DOM {@code Document} for the transformer * to be pretty printed, i.e. providing proper indentations for enclosed tags. * + * Note, while this was originally a workaround, the user community of CDT + * has come to expect the format of the .cproject file and others to be + * unchanging, therefore CDT always uses this and does not attempt + * to format with the Transformer. + * * @param doc - DOM document to be pretty printed - * @param ident - custom indentation as a string of white spaces + * @param indent - custom indentation as a string of white spaces */ - public static void prettyFormat(Document doc, String ident) { + public static void prettyFormat(Document doc, String indent) { doc.normalize(); Element documentElement = doc.getDocumentElement(); if (documentElement != null) { - prettyFormat(documentElement, "", ident); //$NON-NLS-1$ + prettyFormat(documentElement, "", indent); //$NON-NLS-1$ } } @@ -159,17 +169,17 @@ public class XmlUtil { * The method inserts end-of-line+indentation Text nodes where indentation is necessary. * * @param node - node to be pretty formatted - * @param identLevel - initial indentation level of the node - * @param ident - additional indentation inside the node + * @param indentLevel - initial indentation level of the node + * @param indent - additional indentation inside the node */ - private static void prettyFormat(Node node, String identLevel, String ident) { + private static void prettyFormat(Node node, String indentLevel, String indent) { NodeList nodelist = node.getChildNodes(); int iStart = 0; Node item = nodelist.item(0); if (item != null) { short type = item.getNodeType(); if (type == Node.ELEMENT_NODE || type == Node.COMMENT_NODE) { - Node newChild = node.getOwnerDocument().createTextNode(EOL_XML + identLevel + ident); + Node newChild = node.getOwnerDocument().createTextNode(EOL_XML + indentLevel + indent); node.insertBefore(newChild, item); iStart = 1; } @@ -180,25 +190,25 @@ public class XmlUtil { short type = item.getNodeType(); if (type == Node.TEXT_NODE && item.getNodeValue().trim().length() == 0) { if (i + 1 < nodelist.getLength()) { - item.setNodeValue(EOL_XML + identLevel + ident); + item.setNodeValue(EOL_XML + indentLevel + indent); } else { - item.setNodeValue(EOL_XML + identLevel); + item.setNodeValue(EOL_XML + indentLevel); } } else if (type == Node.ELEMENT_NODE) { - prettyFormat(item, identLevel + ident, ident); + prettyFormat(item, indentLevel + indent, indent); if (i + 1 < nodelist.getLength()) { Node nextItem = nodelist.item(i + 1); if (nextItem != null) { short nextType = nextItem.getNodeType(); if (nextType == Node.ELEMENT_NODE || nextType == Node.COMMENT_NODE) { - Node newChild = node.getOwnerDocument().createTextNode(EOL_XML + identLevel + ident); + Node newChild = node.getOwnerDocument().createTextNode(EOL_XML + indentLevel + indent); node.insertBefore(newChild, nextItem); i++; continue; } } } else { - Node newChild = node.getOwnerDocument().createTextNode(EOL_XML + identLevel); + Node newChild = node.getOwnerDocument().createTextNode(EOL_XML + indentLevel); node.appendChild(newChild); i++; continue; @@ -275,22 +285,40 @@ public class XmlUtil { * * @param doc - DOM Document to serialize. * @param uriLocation - URI of the file. + * + * @throws IOException in case of problems with file I/O + * @throws TransformerException in case of problems with XML output + */ + public static void serializeXml(Document doc, URI uriLocation) + throws IOException, TransformerException, CoreException { + serializeXmlInternal(doc, uriLocation, null); + } + + /** + * Serialize XML Document into a file.<br/> + * Note: clients should synchronize access to this method. + * + * @param doc - DOM Document to serialize. + * @param uriLocation - URI of the file. * @param lineSeparator - line separator. + * Note: This will serialize in pretty format * * @throws IOException in case of problems with file I/O * @throws TransformerException in case of problems with XML output */ public static void serializeXml(Document doc, URI uriLocation, String lineSeparator) throws IOException, TransformerException, CoreException { - XmlUtil.prettyFormat(doc); + serializeXmlInternal(doc, uriLocation, lineSeparator); + } + private static void serializeXmlInternal(Document doc, URI uriLocation, String lineSeparator) + throws IOException, TransformerException, CoreException { java.io.File storeFile = new java.io.File(uriLocation); if (!storeFile.exists()) { storeFile.createNewFile(); } - String utfString = new String(toByteArray(doc), ENCODING_UTF_8); - utfString = XmlUtil.replaceLineSeparatorInternal(utfString, lineSeparator); + String utfString = lineSeparator != null ? toString(doc, lineSeparator) : toString(doc); FileOutputStream output = getFileOutputStreamWorkaround(storeFile); output.write(utfString.getBytes(ENCODING_UTF_8)); @@ -340,14 +368,13 @@ public class XmlUtil { * @throws CoreException if something goes wrong. */ private static byte[] toByteArray(Document doc) throws CoreException { - XmlUtil.prettyFormat(doc); - try { ByteArrayOutputStream stream = new ByteArrayOutputStream(); Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$ transformer.setOutputProperty(OutputKeys.ENCODING, ENCODING_UTF_8); - transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$ + // Indentation is done with XmlUtil.prettyFormat(doc). + transformer.setOutputProperty(OutputKeys.INDENT, "no"); //$NON-NLS-1$ DOMSource source = new DOMSource(doc); StreamResult result = new StreamResult(stream); transformer.transform(source, result); @@ -376,6 +403,30 @@ public class XmlUtil { } /** + * <b>Do not use outside of CDT.</b> + * + * This method is used to workaround changing implementations of {@link javax.xml.transform.Transformer} + * to maintain the same file content for CDT users. See {@link #prettyFormat(Document)} and Bug 565628 + * + * This method inserts a newline between the <?... xml ... ?> and first tag in the document + * + * @noreference This method is not intended to be referenced by clients. + * This is an internal method which ideally should be made private. + */ + public static String insertNewlineAfterXMLVersionTag(String string, String lineSeparator) { + if (string == null) { + return null; + } + + int indexOf = string.indexOf("?><"); //$NON-NLS-1$ + if (indexOf < 0 || string.length() < indexOf + 2) { + return string; + } + + return string.substring(0, indexOf + 2) + lineSeparator + string.substring(indexOf + 2); + } + + /** * Serialize XML Document into a workspace file.<br/> * Note: clients should synchronize access to this method. * @@ -384,12 +435,9 @@ public class XmlUtil { * @throws CoreException if something goes wrong. */ public static void serializeXml(Document doc, IFile file) throws CoreException { - XmlUtil.prettyFormat(doc); - try { - String utfString = new String(toByteArray(doc), ENCODING_UTF_8); String lineSeparator = Util.getLineSeparator(file); - utfString = XmlUtil.replaceLineSeparatorInternal(utfString, lineSeparator); + String utfString = toString(doc, lineSeparator); byte[] newContents = utfString.getBytes(ENCODING_UTF_8); InputStream input = new ByteArrayInputStream(newContents); @@ -429,12 +477,36 @@ public class XmlUtil { /** * Serialize XML Document into a string. + * Note: This will return a non-pretty formatted string * * @param doc - DOM Document to serialize. * @return XML as a String. * @throws CoreException if something goes wrong. */ public static String toString(Document doc) throws CoreException { - return new String(toByteArray(doc)); + try { + return new String(toByteArray(doc), ENCODING_UTF_8); + } catch (UnsupportedEncodingException e) { + throw new CoreException(CCorePlugin.createStatus(Messages.XmlUtil_InternalErrorSerializing, e)); + } + } + + /** + * Serialize XML Document into a pretty formatted string. + * Note: This will return a pretty formatted string + * + * @param doc - DOM Document to serialize. + * @param lineSeparator - line separator + * @return XML as a pretty formatted String. + * @throws CoreException if something goes wrong. + */ + public static String toString(Document doc, String lineSeparator) throws CoreException { + XmlUtil.prettyFormat(doc); + + String utfString = toString(doc); + utfString = XmlUtil.replaceLineSeparatorInternal(utfString, lineSeparator); + utfString = XmlUtil.insertNewlineAfterXMLVersionTag(utfString, lineSeparator); + + return utfString; } } diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/AR.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/AR.java index b7ddf28feb8..5cdc825377d 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/AR.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/AR.java @@ -30,13 +30,18 @@ import org.eclipse.cdt.core.CCorePlugin; * class operations. * @see ARHeader */ -public class AR { +public class AR implements AutoCloseable { protected String filename; protected ERandomAccessFile efile; protected long strtbl_pos = -1; private ARHeader[] headers; + @Override + public void close() { + dispose(); + } + public void dispose() { try { if (efile != null) { @@ -197,11 +202,10 @@ public class AR { efile.seek(obj_offset); efile.read(temp); } else { - efile = new ERandomAccessFile(filename, "r"); //$NON-NLS-1$ - efile.seek(obj_offset); - efile.read(temp); - efile.close(); - efile = null; + try (ERandomAccessFile tempfile = new ERandomAccessFile(filename, "r")) { //$NON-NLS-1$ + tempfile.seek(obj_offset); + tempfile.read(temp); + } } return temp; } diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/CommandLineUtil.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/CommandLineUtil.java index bac39b20cb6..5d91d7faa10 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/CommandLineUtil.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/CommandLineUtil.java @@ -50,11 +50,11 @@ public class CommandLineUtil { * Parsing arguments in a shell style. i.e. * * <pre> - * ["a b c" d] -> [[a b c],[d]] - * [a d] -> [[a],[d]] - * ['"quoted"'] -> [["quoted"]] - * [\\ \" \a] -> [[\],["],[a]] - * ["str\\str\a"] -> [[str\str\a]] + * ["a b c" d] -> [[a b c],[d]] + * [a d] -> [[a],[d]] + * ['"quoted"'] -> [["quoted"]] + * [\\ \" \a] -> [[\],["],[a]] + * ["str\\str\a"] -> [[str\str\a]] * </pre> * * @param line @@ -166,11 +166,11 @@ public class CommandLineUtil { * Parsing arguments in a cmd style. i.e. * * <pre> - * ["a b c" d] -> [[a b c],[d]] - * [a d] -> [[a],[d]] - * ['"quoted"'] -> [['quoted']] - * [\\ \" \a] -> [[\\],["],[\a]] - * ["str\\str\a"] -> [[str\\str\a]] + * ["a b c" d] -> [[a b c],[d]] + * [a d] -> [[a],[d]] + * ['"quoted"'] -> [['quoted']] + * [\\ \" \a] -> [[\\],["],[\a]] + * ["str\\str\a"] -> [[str\\str\a]] * </pre> * * @param line diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/cdtvariables/CdtVariableResolver.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/cdtvariables/CdtVariableResolver.java index 6c720512b5d..2138b69dfd1 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/cdtvariables/CdtVariableResolver.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/cdtvariables/CdtVariableResolver.java @@ -62,21 +62,14 @@ public class CdtVariableResolver { private static final String EMPTY_STRING = ""; //$NON-NLS-1$ public static final String VARIABLE_PREFIX = "${"; //$NON-NLS-1$ - private static final String VARIABLE_PREFIX_MASKED = "$\1"; //$NON-NLS-1$ public static final char VARIABLE_SUFFIX = '}'; - private static final char VARIABLE_SUFFIX_MASKED = '\2'; - public static final char VARIABLE_ESCAPE_CHAR = '\\'; - private static final char VARIABLE_ESCAPE_CHAR_MASKED = '\3'; - - // Regular expression fragments private static final String RE_VPREFIX = "\\$\\{"; //$NON-NLS-1$ private static final String RE_VSUFFIX = "\\}"; //$NON-NLS-1$ private static final String RE_VNAME = "[^${}]*"; //$NON-NLS-1$ - private static final String RE_BSLASH = "[\\\\]"; // *one* backslash //$NON-NLS-1$ /** * Converts list of strings to one string using given string as delimiter, - * i.e -> "string1:string2:string3" + * i.e -> "string1:string2:string3" * * @param value - list of strings to convert. * @param listDelimiter - delimiter. @@ -99,8 +92,11 @@ public class CdtVariableResolver { /** * Resolves macros of kind ${Macro} in the given string by calling the macro substitutor * for each macro reference found. Macros can be inside one another like - * ${workspace_loc:/${ProjName}/} but resolved just once. No recursive or concatenated - * macro names are allowed. It is possible to prevent macro from expanding using backslash \$. + * ${workspace_loc:/${ProjName}/} but resolved just once. No recursive + * macro names are allowed. + * It is not possible to prevent macros from expanding. + * For historical reasons (See Bug 571472), macros that are multi-line according to + * {@link Pattern}'s Line Terminators are not expanded. * * @param string - macro expression. * @param substitutor - macro resolution provider to retrieve macro values. @@ -112,44 +108,42 @@ public class CdtVariableResolver { if (string == null) { return EMPTY_STRING; } + // Bug 571472 to match historical behaviour, don't substitute multi-line strings + for (char ch : string.toCharArray()) { + if (ch == '\n' || ch == '\r' || (ch | 1) == '\u2029' || ch == '\u0085') { + return string; + } + } - final Pattern pattern = Pattern - .compile(".*?(" + RE_BSLASH + "*)(" + RE_VPREFIX + "(" + RE_VNAME + ")" + RE_VSUFFIX + ").*"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ + final Pattern pattern = Pattern.compile("(\\$\\{([^${}]*)\\})"); //$NON-NLS-1$ + final String VARIABLE_PREFIX_MASKED = "$\1"; //$NON-NLS-1$ + final char VARIABLE_SUFFIX_MASKED = '\2'; StringBuilder buffer = new StringBuilder(string); int limit = string.length(); - for (Matcher matcher = pattern.matcher(buffer); matcher.matches(); matcher = pattern.matcher(buffer)) { - String bSlashes = matcher.group(1); - String macro = matcher.group(2); - String name = matcher.group(3); + Matcher matcher = pattern.matcher(buffer); + while (matcher.find()) { + String name = matcher.group(2); String resolved = name.length() > 0 ? substitutor.resolveToString(name) : EMPTY_STRING; if (resolved == null) { throw new CdtVariableException(ICdtVariableStatus.TYPE_MACRO_UNDEFINED, null, string, name); } - if (limit-- < 0) { - // to prevent incidental looping - throw new CdtVariableException(ICdtVariableStatus.TYPE_ERROR, name, matcher.group(0), resolved); - } - int nBSlashes = bSlashes.length(); - if ((nBSlashes & 1) == 1) { - // if odd number of backslashes in front of "${...}" do not expand macro - resolved = macro; + if (limit-- < 0) { + // to prevent incidental endless looping + throw new CdtVariableException(ICdtVariableStatus.TYPE_ERROR, name, string, resolved); } // Only one expansion is allowed, so hide any text interfering with macro syntax resolved = resolved.replace(VARIABLE_PREFIX, VARIABLE_PREFIX_MASKED); resolved = resolved.replace(VARIABLE_SUFFIX, VARIABLE_SUFFIX_MASKED); - buffer.replace(matcher.start(2), matcher.end(2), resolved); - // collapse and hide backslashes \\\\${Macro} -> \\MacroValue or \\\\\${Macro} -> \\${Macro} - buffer.replace(matcher.start(1), matcher.end(1), - bSlashes.substring(0, nBSlashes / 2).replace(VARIABLE_ESCAPE_CHAR, VARIABLE_ESCAPE_CHAR_MASKED)); + + buffer.replace(matcher.start(1), matcher.end(1), resolved); + matcher = pattern.matcher(buffer); } String result = buffer.toString(); - // take hidden data back result = result.replace(VARIABLE_PREFIX_MASKED, VARIABLE_PREFIX); result = result.replace(VARIABLE_SUFFIX_MASKED, VARIABLE_SUFFIX); - result = result.replace(VARIABLE_ESCAPE_CHAR_MASKED, VARIABLE_ESCAPE_CHAR); return result; } diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/Exe.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/Exe.java index 784128ee734..85205e19620 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/Exe.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/Exe.java @@ -18,11 +18,12 @@ import java.io.RandomAccessFile; import org.eclipse.cdt.core.CCorePlugin; -public class Exe { +public class Exe implements AutoCloseable { public static final String NL = System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$ protected RandomAccessFile rfile; ExeHeader ehdr; + private String file; static public class ExeHeader { @@ -160,12 +161,13 @@ public class Exe { @Override public String toString() { StringBuilder buffer = new StringBuilder(); - buffer.append(rfile).append(NL); + buffer.append(file).append(NL); buffer.append(ehdr); return buffer.toString(); } public Exe(String file) throws IOException { + this.file = file; rfile = new RandomAccessFile(file, "r"); //$NON-NLS-1$ try { ehdr = new ExeHeader(rfile); @@ -176,6 +178,15 @@ public class Exe { } } + @Override + public void close() throws Exception { + if (rfile != null) { + rfile.close(); + rfile = null; + ehdr = null; + } + } + public static void main(String[] args) { try { Exe exe = new Exe(args[0]); diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/PE.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/PE.java index 0cdf8a67d3c..f9e3c00c689 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/PE.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/PE.java @@ -73,7 +73,7 @@ import org.eclipse.cdt.utils.debug.stabs.StabsReader; * This class is planned for removal in next major release. */ @Deprecated -public class PE { +public class PE implements AutoCloseable { public static final String NL = System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$ RandomAccessFile rfile; @@ -573,10 +573,14 @@ public class PE { } public static Attribute getAttribute(String file) throws IOException { - PE pe = new PE(file); - Attribute attrib = pe.getAttribute(); - pe.dispose(); - return attrib; + try (PE pe = new PE(file)) { + return pe.getAttribute(); + } + } + + @Override + public void close() throws IOException { + dispose(); } public void dispose() throws IOException { diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/PE64.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/PE64.java index 6585605a7cf..5e4d8a4ba17 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/PE64.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/PE64.java @@ -68,7 +68,7 @@ import org.eclipse.cdt.utils.debug.stabs.StabsReader; * </pre> * @since 6.9 */ -public class PE64 { +public class PE64 implements AutoCloseable { public static final String NL = System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$ RandomAccessFile rfile; @@ -667,10 +667,14 @@ public class PE64 { } public static Attribute getAttribute(String file) throws IOException { - PE64 pe = new PE64(file); - Attribute attrib = pe.getAttribute(); - pe.dispose(); - return attrib; + try (PE64 pe = new PE64(file)) { + return pe.getAttribute(); + } + } + + @Override + public void close() throws IOException { + dispose(); } public void dispose() throws IOException { diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/PEArchive.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/PEArchive.java index 226ee4d8cd5..33a26f029ae 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/PEArchive.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/PEArchive.java @@ -30,13 +30,18 @@ import org.eclipse.cdt.core.CCorePlugin; * @see ARHeader */ @Deprecated -public class PEArchive { +public class PEArchive implements AutoCloseable { protected String filename; protected RandomAccessFile rfile; protected long strtbl_pos = -1; private ARHeader[] headers; + @Override + public void close() { + dispose(); + } + public void dispose() { try { if (rfile != null) { diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/PEBinaryArchive.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/PEBinaryArchive.java index b1dad7903bb..8d833997de2 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/PEBinaryArchive.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/PEBinaryArchive.java @@ -35,7 +35,9 @@ public class PEBinaryArchive extends BinaryFile implements IBinaryArchive { public PEBinaryArchive(PEParser parser, IPath path) throws IOException { super(parser, path, IBinaryFile.ARCHIVE); - new AR(path.toOSString()).dispose(); // check file type + try (AR ar = new AR(path.toOSString())) { + // create the object just to check file type + } children = new ArrayList<>(5); } diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/PEBinaryArchive64.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/PEBinaryArchive64.java index d4aa241357e..c37b4774506 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/PEBinaryArchive64.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/PEBinaryArchive64.java @@ -34,7 +34,9 @@ public class PEBinaryArchive64 extends BinaryFile implements IBinaryArchive { public PEBinaryArchive64(PEParser64 parser, IPath path) throws IOException { super(parser, path, IBinaryFile.ARCHIVE); - new AR(path.toOSString()).dispose(); // check file type + try (AR ar = new AR(path.toOSString())) { + // create the object just to check file type + } children = new ArrayList<>(5); } diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/PEBinaryObject.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/PEBinaryObject.java index 516c7de1f4d..9f7fd4e81fc 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/PEBinaryObject.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/PEBinaryObject.java @@ -123,33 +123,21 @@ public class PEBinaryObject extends BinaryObjectAdapter { } protected void loadAll() throws IOException { - PE pe = null; - try { - pe = getPE(); + try (PE pe = getPE()) { loadInfo(pe); loadSymbols(pe); - } finally { - if (pe != null) { - pe.dispose(); - } } } protected void loadInfo() throws IOException { - PE pe = null; - try { - pe = getPE(); + try (PE pe = getPE()) { loadInfo(pe); - } finally { - if (pe != null) { - pe.dispose(); - } } } protected void loadInfo(PE pe) throws IOException { info = new BinaryObjectInfo(); - PE.Attribute attribute = getPE().getAttribute(); + PE.Attribute attribute = pe.getAttribute(); info.isLittleEndian = attribute.isLittleEndian(); info.hasDebug = attribute.hasDebug(); info.cpu = attribute.getCPU(); diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/PEBinaryObject64.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/PEBinaryObject64.java index e9ea46dd712..849f36e355b 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/PEBinaryObject64.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/PEBinaryObject64.java @@ -125,33 +125,21 @@ public class PEBinaryObject64 extends BinaryObjectAdapter { } protected void loadAll() throws IOException { - PE64 pe = null; - try { - pe = getPE(); + try (PE64 pe = getPE()) { loadInfo(pe); loadSymbols(pe); - } finally { - if (pe != null) { - pe.dispose(); - } } } protected void loadInfo() throws IOException { - PE64 pe = null; - try { - pe = getPE(); + try (PE64 pe = getPE()) { loadInfo(pe); - } finally { - if (pe != null) { - pe.dispose(); - } } } protected void loadInfo(PE64 pe) throws IOException { info = new BinaryObjectInfo(); - PE64.Attribute attribute = getPE().getAttribute(); + PE64.Attribute attribute = pe.getAttribute(); info.isLittleEndian = attribute.isLittleEndian(); info.hasDebug = attribute.hasDebug(); info.cpu = attribute.getCPU(); diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/debug/dwarf/Dwarf.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/debug/dwarf/Dwarf.java index 01a2f54ffe1..132d8e026ca 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/debug/dwarf/Dwarf.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/debug/dwarf/Dwarf.java @@ -186,9 +186,9 @@ public class Dwarf { boolean printEnabled = true; public Dwarf(String file) throws IOException { - Elf exe = new Elf(file); - init(exe); - exe.dispose(); + try (Elf exe = new Elf(file)) { + init(exe); + } } public Dwarf(Elf exe) throws IOException { @@ -238,8 +238,9 @@ public class Dwarf { } if (debugFile.exists()) { // if the debug file exists from above, open it and get the section info from it - Elf debugInfo = new Elf(debugFile.getCanonicalPath()); - sections = debugInfo.getSections(); + try (Elf debugInfo = new Elf(debugFile.getCanonicalPath())) { + sections = debugInfo.getSections(); + } debugInfoPath = new Path(debugFile.getCanonicalPath()); } } @@ -264,17 +265,17 @@ public class Dwarf { } File altFile = altPath.toFile(); if (altFile.exists()) { - Elf altInfo = new Elf(altFile.getCanonicalPath()); - Elf.Section[] altSections = altInfo.getSections(); - for (Section altSection : altSections) { - String altName = altSection.toString(); - for (String element : DWARF_ALT_SCNNAMES) { - if (altName.equals(element)) { - try { - dwarfAltSections.put(element, altSection.mapSectionData()); - } catch (Exception e) { - e.printStackTrace(); - CCorePlugin.log(e); + try (Elf altInfo = new Elf(altFile.getCanonicalPath())) { + Elf.Section[] altSections = altInfo.getSections(); + for (Section altSection : altSections) { + String altName = altSection.toString(); + for (String element : DWARF_ALT_SCNNAMES) { + if (altName.equals(element)) { + try { + dwarfAltSections.put(element, altSection.mapSectionData()); + } catch (Exception e) { + CCorePlugin.log(e); + } } } } diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/debug/dwarf/DwarfReader.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/debug/dwarf/DwarfReader.java index 16a390b96eb..20564a52723 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/debug/dwarf/DwarfReader.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/debug/dwarf/DwarfReader.java @@ -28,8 +28,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import javax.xml.bind.DatatypeConverter; - import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.ICompileOptionsFinder; import org.eclipse.cdt.core.ISymbolReader; @@ -127,15 +125,16 @@ public class DwarfReader extends Dwarf implements ISymbolReader, ICompileOptions } // The build-id location is taken by converting the binary bytes to hex string. // The first byte is used as a directory specifier (e.g. 51/a4578fe2). - String bName = DatatypeConverter.printHexBinary(byteArray).toLowerCase(); + String bName = printHexBinary(byteArray).toLowerCase(); buildId = bName.substring(0, 2) + "/" + bName.substring(2) + ".debug"; //$NON-NLS-1$ //$NON-NLS-2$ // The build-id file should be in the special directory /usr/lib/debug/.build-id IPath buildIdPath = new Path("/usr/lib/debug/.build-id").append(buildId); //$NON-NLS-1$ File buildIdFile = buildIdPath.toFile(); if (buildIdFile.exists()) { // if the debug file exists from above, open it and get the section info from it - Elf debugInfo = new Elf(buildIdFile.getCanonicalPath()); - sections = debugInfo.getSections(); + try (Elf debugInfo = new Elf(buildIdFile.getCanonicalPath())) { + sections = debugInfo.getSections(); + } have_build_id = true; debugInfoPath = new Path(buildIdFile.getCanonicalPath()).removeLastSegments(1); break; @@ -185,8 +184,9 @@ public class DwarfReader extends Dwarf implements ISymbolReader, ICompileOptions } if (debugFile.exists()) { // if the debug file exists from above, open it and get the section info from it - Elf debugInfo = new Elf(debugFile.getCanonicalPath()); - sections = debugInfo.getSections(); + try (Elf debugInfo = new Elf(debugFile.getCanonicalPath())) { + sections = debugInfo.getSections(); + } debugInfoPath = new Path(debugFile.getCanonicalPath()).removeLastSegments(1); } } @@ -215,17 +215,17 @@ public class DwarfReader extends Dwarf implements ISymbolReader, ICompileOptions } File altFile = altPath.toFile(); if (altFile.exists()) { - Elf altInfo = new Elf(altFile.getCanonicalPath()); - Elf.Section[] altSections = altInfo.getSections(); - for (Section altSection : altSections) { - String altName = altSection.toString(); - for (String element : DWARF_ALT_SectionsToParse) { - if (altName.equals(element)) { - try { - dwarfAltSections.put(element, altSection.mapSectionData()); - } catch (Exception e) { - e.printStackTrace(); - CCorePlugin.log(e); + try (Elf altInfo = new Elf(altFile.getCanonicalPath())) { + Elf.Section[] altSections = altInfo.getSections(); + for (Section altSection : altSections) { + String altName = altSection.toString(); + for (String element : DWARF_ALT_SectionsToParse) { + if (altName.equals(element)) { + try { + dwarfAltSections.put(element, altSection.mapSectionData()); + } catch (Exception e) { + CCorePlugin.log(e); + } } } } @@ -286,6 +286,13 @@ public class DwarfReader extends Dwarf implements ISymbolReader, ICompileOptions m_parsed = false; } + private static String printHexBinary(byte[] byteArray) { + StringBuilder sb = new StringBuilder(byteArray.length * 2); + for (byte b : byteArray) + sb.append(String.format("%02x", b)); //$NON-NLS-1$ + return sb.toString(); + } + /* * Parse line table data of a compilation unit to get names of all source files * that contribute to the compilation unit. @@ -296,7 +303,11 @@ public class DwarfReader extends Dwarf implements ISymbolReader, ICompileOptions ByteBuffer data = dwarfSections.get(DWARF_DEBUG_LINE); if (data != null) { try { - data.position(cuStmtList); + try { + data.position(cuStmtList); + } catch (IllegalArgumentException e) { + throw new IOException(CCorePlugin.getResourceString("Util.exception.noData")); //$NON-NLS-1$ + } /* Read line table header: * @@ -382,7 +393,7 @@ public class DwarfReader extends Dwarf implements ISymbolReader, ICompileOptions leb128 = read_unsigned_leb128(data); } } catch (IOException e) { - e.printStackTrace(); + CCorePlugin.log("Failed to parse part of dwarf header", e); //$NON-NLS-1$ } } } diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/debug/stabs/Stabs.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/debug/stabs/Stabs.java index c99897e1bb8..69ecba5cc61 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/debug/stabs/Stabs.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/debug/stabs/Stabs.java @@ -68,14 +68,12 @@ public class Stabs { // we support Elf and PE executable formats. try Elf // and then PE. - try { - Elf exe = new Elf(file); + try (Elf exe = new Elf(file)) { init(exe); - exe.dispose(); } catch (IOException e) { - PE exe = new PE(file); - init(exe); - exe.dispose(); + try (PE exe = new PE(file)) { + init(exe); + } } } diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/debug/tools/DebugAddr2line.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/debug/tools/DebugAddr2line.java index 3c24e1c8a7b..52dd8642b78 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/debug/tools/DebugAddr2line.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/debug/tools/DebugAddr2line.java @@ -31,9 +31,9 @@ public class DebugAddr2line { DebugSymsRequestor symreq; public DebugAddr2line(String file) throws IOException { - Elf elf = new Elf(file); - init(elf); - elf.dispose(); + try (Elf elf = new Elf(file)) { + init(elf); + } } public DebugAddr2line(Elf elf) throws IOException { diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/debug/tools/DebugDump.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/debug/tools/DebugDump.java index 071f4073c94..7fae54ef2c8 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/debug/tools/DebugDump.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/debug/tools/DebugDump.java @@ -46,9 +46,9 @@ public class DebugDump implements IDebugEntryRequestor { } void parse(String file) throws IOException { - Elf elf = new Elf(file); - parse(elf); - elf.dispose(); + try (Elf elf = new Elf(file)) { + parse(elf); + } } void parse(Elf elf) throws IOException { diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/AR.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/AR.java index bb37c2db604..bb88792ac09 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/AR.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/AR.java @@ -31,13 +31,18 @@ import org.eclipse.cdt.utils.ERandomAccessFile; * @see ARHeader */ @Deprecated -public class AR { +public class AR implements AutoCloseable { protected String filename; protected ERandomAccessFile efile; protected long strtbl_pos = -1; private ARHeader[] headers; + @Override + public void close() { + dispose(); + } + public void dispose() { try { if (efile != null) { @@ -207,11 +212,10 @@ public class AR { efile.seek(elf_offset); efile.read(temp); } else { - efile = new ERandomAccessFile(filename, "r"); //$NON-NLS-1$ - efile.seek(elf_offset); - efile.read(temp); - efile.close(); - efile = null; + try (ERandomAccessFile tempfile = new ERandomAccessFile(filename, "r")) { //$NON-NLS-1$ + tempfile.seek(elf_offset); + tempfile.read(temp); + } } return temp; } @@ -237,6 +241,7 @@ public class AR { String hdr = efile.readLine(); if (hdr == null || hdr.compareTo("!<arch>") != 0) { //$NON-NLS-1$ efile.close(); + efile = null; throw new IOException(CCorePlugin.getResourceString("Util.exception.invalidArchive")); //$NON-NLS-1$ } } diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/Elf.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/Elf.java index ba8d81773f9..9e3090e2a8d 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/Elf.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/Elf.java @@ -41,7 +41,7 @@ import org.eclipse.cdt.utils.Addr64Factory; import org.eclipse.cdt.utils.ERandomAccessFile; import org.eclipse.cdt.utils.debug.dwarf.DwarfReader; -public class Elf { +public class Elf implements AutoCloseable { public static final int ELF32_ADDR_SIZE = 4; public static final int ELF32_OFF_SIZE = 4; public static final int ELF64_ADDR_SIZE = 8; @@ -956,21 +956,20 @@ public class Elf { } public static Attribute getAttributes(String file) throws IOException { - Elf elf = new Elf(file); - Attribute attrib = elf.getAttributes(); - elf.dispose(); - return attrib; + try (Elf elf = new Elf(file)) { + Attribute attrib = elf.getAttributes(); + return attrib; + } } public static Attribute getAttributes(byte[] array) throws IOException { + try (Elf emptyElf = new Elf()) { + emptyElf.ehdr = emptyElf.new ELFhdr(array); + emptyElf.sections = new Elf.Section[0]; + Attribute attrib = emptyElf.getAttributes(); - Elf emptyElf = new Elf(); - emptyElf.ehdr = emptyElf.new ELFhdr(array); - emptyElf.sections = new Elf.Section[0]; - Attribute attrib = emptyElf.getAttributes(); - emptyElf.dispose(); - - return attrib; + return attrib; + } } public static boolean isElfHeader(byte[] e_ident) { @@ -978,6 +977,11 @@ public class Elf { && e_ident[ELFhdr.EI_MAG1] == 'E' && e_ident[ELFhdr.EI_MAG2] == 'L' && e_ident[ELFhdr.EI_MAG3] == 'F'; } + @Override + public void close() { + dispose(); + } + public void dispose() { try { if (efile != null) { @@ -1025,6 +1029,9 @@ public class Elf { return slist.toArray(new Section[0]); } + /** + * @throws ElfClassNoneException if {@link ELFhdr#ELFCLASSNONE} header is read + */ public Section[] getSections() throws IOException { if (sections == null) { if (ehdr.e_shoff == 0) { @@ -1059,7 +1066,7 @@ public class Elf { break; case ELFhdr.ELFCLASSNONE: default: - throw new IOException("Unknown ELF class " + ehdr.e_ident[ELFhdr.EI_CLASS]); //$NON-NLS-1$ + throw new ElfClassNoneException("Unknown ELF class " + ehdr.e_ident[ELFhdr.EI_CLASS]); //$NON-NLS-1$ } sections[i].sh_link = efile.readIntE(); @@ -1077,7 +1084,7 @@ public class Elf { break; case ELFhdr.ELFCLASSNONE: default: - throw new IOException("Unknown ELF class " + ehdr.e_ident[ELFhdr.EI_CLASS]); //$NON-NLS-1$ + throw new ElfClassNoneException("Unknown ELF class " + ehdr.e_ident[ELFhdr.EI_CLASS]); //$NON-NLS-1$ } } } @@ -1312,4 +1319,16 @@ public class Elf { } return result; } + + /** + * Exception indicating that {@link ELFhdr#ELFCLASSNONE} header is read. + * + * @since 7.2 + */ + public static class ElfClassNoneException extends IOException { + + ElfClassNoneException(String message) { + super(message); + } + } } diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/ElfHelper.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/ElfHelper.java index b5063ff16df..7ce48e1f3bf 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/ElfHelper.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/ElfHelper.java @@ -26,7 +26,7 @@ import org.eclipse.cdt.utils.elf.Elf.Symbol; * * @see Elf */ -public class ElfHelper { +public class ElfHelper implements AutoCloseable { private Elf elf; private Elf.Symbol[] dynsyms; @@ -34,6 +34,11 @@ public class ElfHelper { private Elf.Section[] sections; private Elf.Dynamic[] dynamics; + @Override + public void close() { + dispose(); + } + public void dispose() { if (elf != null) { elf.dispose(); diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/parser/ElfBinaryArchive.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/parser/ElfBinaryArchive.java index cb308cbb3bf..a4affdd11c3 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/parser/ElfBinaryArchive.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/parser/ElfBinaryArchive.java @@ -32,9 +32,11 @@ public class ElfBinaryArchive extends BinaryFile implements IBinaryArchive { private ArrayList<IBinaryObject> children; - public ElfBinaryArchive(IBinaryParser parser, IPath p) throws IOException { - super(parser, p, IBinaryFile.ARCHIVE); - new AR(p.toOSString()).dispose(); // check file type + public ElfBinaryArchive(IBinaryParser parser, IPath path) throws IOException { + super(parser, path, IBinaryFile.ARCHIVE); + try (AR ar = new AR(path.toOSString())) { + // create the object just to check file type + } children = new ArrayList<>(5); } diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/parser/ElfBinaryObject.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/parser/ElfBinaryObject.java index 83f98d52085..1edf66298ce 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/parser/ElfBinaryObject.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/parser/ElfBinaryObject.java @@ -111,27 +111,15 @@ public class ElfBinaryObject extends BinaryObjectAdapter { } protected void loadAll() throws IOException { - ElfHelper helper = null; - try { - helper = getElfHelper(); + try (ElfHelper helper = getElfHelper()) { loadInfo(helper); loadSymbols(helper); - } finally { - if (helper != null) { - helper.dispose(); - } } } protected void loadInfo() throws IOException { - ElfHelper helper = null; - try { - helper = getElfHelper(); + try (ElfHelper helper = getElfHelper()) { loadInfo(helper); - } finally { - if (helper != null) { - helper.dispose(); - } } } diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/parser/ElfParser.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/parser/ElfParser.java index a6b8c563dc1..0e4da98b046 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/parser/ElfParser.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/parser/ElfParser.java @@ -29,6 +29,7 @@ import org.eclipse.cdt.utils.AR; import org.eclipse.cdt.utils.elf.Elf; import org.eclipse.cdt.utils.elf.Elf.Attribute; import org.eclipse.cdt.utils.elf.Elf.ELFhdr; +import org.eclipse.cdt.utils.elf.Elf.ElfClassNoneException; import org.eclipse.cdt.utils.elf.Elf.PHdr; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; @@ -177,18 +178,15 @@ public class ElfParser extends AbstractCExtension implements IBinaryParser { try { /* No PHdr.PT_INTERP found in the hints meaning we need to read the file itself */ return Arrays.stream(getPHdrs(path)).anyMatch(phdr -> phdr.p_type == PHdr.PT_INTERP); - } catch (IOException e) { + } catch (ElfClassNoneException e) { CCorePlugin.log(e); } return false; } private static PHdr[] getPHdrs(IPath path) throws IOException { - Elf elf = new Elf(path.toOSString()); - try { + try (Elf elf = new Elf(path.toOSString())) { return elf.getPHdrs(); - } finally { - elf.dispose(); } } } diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/envvar/EnvVarOperationProcessor.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/envvar/EnvVarOperationProcessor.java index 1d283d5f299..bbeab8a042c 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/envvar/EnvVarOperationProcessor.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/envvar/EnvVarOperationProcessor.java @@ -19,7 +19,6 @@ import java.util.List; import org.eclipse.cdt.core.envvar.EnvironmentVariable; import org.eclipse.cdt.core.envvar.IEnvironmentVariable; -import org.eclipse.cdt.internal.core.envvar.EnvironmentVariableManager; /** * This is an utility class that implements environment variable operations @@ -225,7 +224,6 @@ public class EnvVarOperationProcessor { /** * normalizes the variable name. That is: removes prepended and appended spaces - * and converts the name to upper-case for Win32 systems * @return the normalized name or <code>null</code> in case the name is not valid */ static public String normalizeName(String name) { @@ -233,8 +231,6 @@ public class EnvVarOperationProcessor { return null; if ("".equals(name = name.trim())) //$NON-NLS-1$ return null; - if (!EnvironmentVariableManager.getDefault().isVariableCaseSensitive()) - name = name.toUpperCase(); return name; } diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/envvar/StorableEnvironment.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/envvar/StorableEnvironment.java index ba45db85862..41f0c55a140 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/envvar/StorableEnvironment.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/envvar/StorableEnvironment.java @@ -20,7 +20,6 @@ import java.util.Map; import org.eclipse.cdt.core.envvar.IEnvironmentVariable; import org.eclipse.cdt.core.settings.model.ICStorageElement; -import org.eclipse.cdt.internal.core.envvar.EnvironmentVariableManager; import org.eclipse.cdt.internal.core.settings.model.ExceptionFactory; import org.eclipse.cdt.utils.envvar.StorableEnvironmentLoader.ISerializeInfo; @@ -315,8 +314,6 @@ public class StorableEnvironment { String getNameForMap(String name) { if (name == null || (name = name.trim()).length() == 0) return null; - if (!EnvironmentVariableManager.getDefault().isVariableCaseSensitive()) - return name.toUpperCase(); return name; } diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/macho/AR.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/macho/AR.java index cc7ebb714f8..9eb8dbc2cf7 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/macho/AR.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/macho/AR.java @@ -29,13 +29,18 @@ import org.eclipse.cdt.core.CCorePlugin; * class operations. * @see ARHeader */ -public class AR { +public class AR implements AutoCloseable { protected String filename; protected ERandomAccessFile efile; protected long strtbl_pos = -1; private ARHeader[] headers; + @Override + public void close() { + dispose(); + } + public void dispose() { try { if (efile != null) { diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/macho/parser/MachOBinaryArchive.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/macho/parser/MachOBinaryArchive.java index 4fd1b1686bb..e06d73de0a4 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/macho/parser/MachOBinaryArchive.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/macho/parser/MachOBinaryArchive.java @@ -35,7 +35,9 @@ public class MachOBinaryArchive extends BinaryFile implements IBinaryArchive { public MachOBinaryArchive(IBinaryParser parser, IPath p) throws IOException { super(parser, p, IBinaryFile.ARCHIVE); - new AR(p.toOSString()).dispose(); // check file type + try (AR ar = new AR(p.toOSString())) { + // create the object just to check file type + } children = new ArrayList<>(5); } diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/macho/parser/MachOBinaryArchive64.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/macho/parser/MachOBinaryArchive64.java index 8de3bf3cec9..3a09e1b258f 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/macho/parser/MachOBinaryArchive64.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/macho/parser/MachOBinaryArchive64.java @@ -33,7 +33,10 @@ public class MachOBinaryArchive64 extends BinaryFile implements IBinaryArchive { public MachOBinaryArchive64(IBinaryParser parser, IPath p) throws IOException { super(parser, p, IBinaryFile.ARCHIVE); - new AR(p.toOSString()).dispose(); // check file type + try (AR ar = new AR(p.toOSString())) { + // create the object just to check file type + + } children = new ArrayList<>(5); } diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/som/AR.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/som/AR.java index 4499a1c88fa..1bbe85f8ade 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/som/AR.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/som/AR.java @@ -26,7 +26,7 @@ import org.eclipse.cdt.utils.coff.ReadMemoryAccess; * * @author vhirsl */ -public class AR { +public class AR implements AutoCloseable { public static final String NL = System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$ protected String filename; @@ -190,6 +190,11 @@ public class AR { lstHeader = new LSTHeader(); } + @Override + public void close() { + dispose(); + } + public void dispose() { try { if (file != null) { diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/som/parser/SOMBinaryArchive.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/som/parser/SOMBinaryArchive.java index f75fd043283..18cebb87dfe 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/som/parser/SOMBinaryArchive.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/som/parser/SOMBinaryArchive.java @@ -39,7 +39,9 @@ public class SOMBinaryArchive extends BinaryFile implements IBinaryArchive { */ public SOMBinaryArchive(IBinaryParser parser, IPath path) throws IOException { super(parser, path, IBinaryFile.ARCHIVE); - new AR(path.toOSString()).dispose(); // check file type + try (AR ar = new AR(path.toOSString())) { + // create the object just to check file type + } children = new ArrayList<>(5); } diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/xcoff/AR.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/xcoff/AR.java index aea7534e873..43abe364888 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/xcoff/AR.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/xcoff/AR.java @@ -30,7 +30,7 @@ import org.eclipse.cdt.core.CCorePlugin; * * @author vhirsl */ -public class AR { +public class AR implements AutoCloseable { protected String filename; private RandomAccessFile file; private ARHeader header; @@ -105,6 +105,11 @@ public class AR { } } + @Override + public void close() { + dispose(); + } + public void dispose() { try { if (file != null) { @@ -365,4 +370,5 @@ public class AR { e.printStackTrace(); } } + } diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/xcoff/parser/XCOFFBinaryArchive.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/xcoff/parser/XCOFFBinaryArchive.java index a425cde72cf..d0cdf5f7299 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/xcoff/parser/XCOFFBinaryArchive.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/xcoff/parser/XCOFFBinaryArchive.java @@ -39,7 +39,9 @@ public class XCOFFBinaryArchive extends BinaryFile implements IBinaryArchive { */ public XCOFFBinaryArchive(IBinaryParser parser, IPath path) throws IOException { super(parser, path, IBinaryFile.ARCHIVE); - new AR(path.toOSString()).dispose(); // check file type + try (AR ar = new AR(path.toOSString())) { + // create the object just to check file type + } children = new ArrayList<>(5); } diff --git a/core/org.eclipse.cdt.ui.tests/.classpath b/core/org.eclipse.cdt.ui.tests/.classpath index b4784f4c94f..1f63a20029a 100644 --- a/core/org.eclipse.cdt.ui.tests/.classpath +++ b/core/org.eclipse.cdt.ui.tests/.classpath @@ -1,8 +1,16 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> - <classpathentry kind="src" path="src"/> - <classpathentry kind="src" path="ui"/> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="src" path="src"> + <attributes> + <attribute name="test" value="true"/> + </attributes> + </classpathentry> + <classpathentry kind="src" path="ui"> + <attributes> + <attribute name="test" value="true"/> + </attributes> + </classpathentry> <classpathentry kind="output" path="bin"/> </classpath> diff --git a/core/org.eclipse.cdt.ui.tests/.settings/org.eclipse.core.resources.prefs b/core/org.eclipse.cdt.ui.tests/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 00000000000..99f26c0203a --- /dev/null +++ b/core/org.eclipse.cdt.ui.tests/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/<project>=UTF-8 diff --git a/core/org.eclipse.cdt.ui.tests/.settings/org.eclipse.jdt.core.prefs b/core/org.eclipse.cdt.ui.tests/.settings/org.eclipse.jdt.core.prefs index ad05599159f..5b1c443114d 100644 --- a/core/org.eclipse.cdt.ui.tests/.settings/org.eclipse.jdt.core.prefs +++ b/core/org.eclipse.cdt.ui.tests/.settings/org.eclipse.jdt.core.prefs @@ -30,9 +30,9 @@ org.eclipse.jdt.core.compiler.annotation.nullable.secondary= org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.methodParameters=generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.compliance=11 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -49,6 +49,7 @@ org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled org.eclipse.jdt.core.compiler.problem.discouragedReference=ignore org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning @@ -107,6 +108,7 @@ org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=igno org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled @@ -144,13 +146,14 @@ org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=ignore org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.release=disabled -org.eclipse.jdt.core.compiler.source=1.8 +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=11 org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns=false org.eclipse.jdt.core.formatter.align_with_spaces=false +org.eclipse.jdt.core.formatter.alignment_for_additive_operator=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 @@ -158,21 +161,24 @@ org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_c org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_assignment=0 -org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_bitwise_operator=16 org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 org.eclipse.jdt.core.formatter.alignment_for_compact_loops=16 org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 org.eclipse.jdt.core.formatter.alignment_for_enum_constants=16 org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0 +org.eclipse.jdt.core.formatter.alignment_for_logical_operator=16 org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 org.eclipse.jdt.core.formatter.alignment_for_module_statements=16 org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_multiplicative_operator=16 org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_string_concatenation=16 org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 @@ -264,11 +270,12 @@ org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_after_additive_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_bitwise_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert @@ -299,6 +306,8 @@ org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_after_logical_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_multiplicative_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert @@ -323,13 +332,17 @@ org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_relational_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert +org.eclipse.jdt.core.formatter.insert_space_after_shift_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_string_concatenation=insert org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_additive_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_bitwise_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert @@ -377,6 +390,8 @@ org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do no org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_before_logical_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_multiplicative_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert @@ -413,9 +428,12 @@ org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not inser org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_relational_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_shift_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_string_concatenation=insert org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert @@ -454,10 +472,14 @@ org.eclipse.jdt.core.formatter.tabulation.char=tab org.eclipse.jdt.core.formatter.tabulation.size=4 org.eclipse.jdt.core.formatter.use_on_off_tags=true org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false +org.eclipse.jdt.core.formatter.wrap_before_additive_operator=true org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false -org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true +org.eclipse.jdt.core.formatter.wrap_before_bitwise_operator=true org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true +org.eclipse.jdt.core.formatter.wrap_before_logical_operator=true +org.eclipse.jdt.core.formatter.wrap_before_multiplicative_operator=true org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true +org.eclipse.jdt.core.formatter.wrap_before_string_concatenation=true org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true org.eclipse.jdt.core.incompatibleJDKLevel=ignore org.eclipse.jdt.core.incompleteClasspath=error diff --git a/core/org.eclipse.cdt.ui.tests/.settings/org.eclipse.jdt.ui.prefs b/core/org.eclipse.cdt.ui.tests/.settings/org.eclipse.jdt.ui.prefs index e44576346c4..d35ba9b5231 100644 --- a/core/org.eclipse.cdt.ui.tests/.settings/org.eclipse.jdt.ui.prefs +++ b/core/org.eclipse.cdt.ui.tests/.settings/org.eclipse.jdt.ui.prefs @@ -1,3 +1,4 @@ +cleanup.add_all=false cleanup.add_default_serial_version_id=true cleanup.add_generated_serial_version_id=false cleanup.add_missing_annotations=true @@ -11,25 +12,72 @@ cleanup.always_use_blocks=true cleanup.always_use_parentheses_in_expressions=false cleanup.always_use_this_for_non_static_field_access=false cleanup.always_use_this_for_non_static_method_access=false +cleanup.array_with_curly=false +cleanup.arrays_fill=false +cleanup.bitwise_conditional_expression=false +cleanup.boolean_literal=false +cleanup.boolean_value_rather_than_comparison=false +cleanup.break_loop=false +cleanup.collection_cloning=false +cleanup.comparing_on_criteria=false +cleanup.comparison_statement=false +cleanup.controlflow_merge=false cleanup.convert_functional_interfaces=false cleanup.convert_to_enhanced_for_loop=false +cleanup.convert_to_enhanced_for_loop_if_loop_var_used=true +cleanup.convert_to_switch_expressions=false cleanup.correct_indentation=false +cleanup.do_while_rather_than_while=true +cleanup.double_negation=false +cleanup.else_if=false +cleanup.embedded_if=false +cleanup.evaluate_nullable=false +cleanup.extract_increment=false cleanup.format_source_code=true cleanup.format_source_code_changes_only=false +cleanup.hash=false +cleanup.if_condition=false cleanup.insert_inferred_type_arguments=false +cleanup.instanceof=false +cleanup.instanceof_keyword=false +cleanup.invert_equals=false +cleanup.join=false +cleanup.lazy_logical_operator=false cleanup.make_local_variable_final=true cleanup.make_parameters_final=false cleanup.make_private_fields_final=true cleanup.make_type_abstract_if_missing_method=false cleanup.make_variable_declarations_final=false +cleanup.map_cloning=false +cleanup.merge_conditional_blocks=false +cleanup.multi_catch=false cleanup.never_use_blocks=false cleanup.never_use_parentheses_in_expressions=true +cleanup.no_string_creation=false +cleanup.no_super=false +cleanup.number_suffix=false +cleanup.objects_equals=false +cleanup.one_if_rather_than_duplicate_blocks_that_fall_through=false +cleanup.operand_factorization=false cleanup.organize_imports=true +cleanup.overridden_assignment=false +cleanup.plain_replacement=false +cleanup.precompile_regex=false +cleanup.primitive_comparison=false +cleanup.primitive_parsing=false +cleanup.primitive_rather_than_wrapper=false +cleanup.primitive_serialization=false +cleanup.pull_out_if_from_if_else=false +cleanup.pull_up_assignment=false +cleanup.push_down_negation=false cleanup.qualify_static_field_accesses_with_declaring_class=false cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true cleanup.qualify_static_member_accesses_with_declaring_class=false cleanup.qualify_static_method_accesses_with_declaring_class=false +cleanup.reduce_indentation=false +cleanup.redundant_comparator=false +cleanup.redundant_falling_through_block_end=false cleanup.remove_private_constructors=true cleanup.remove_redundant_modifiers=false cleanup.remove_redundant_semicolons=true @@ -37,25 +85,57 @@ cleanup.remove_redundant_type_arguments=true cleanup.remove_trailing_whitespaces=true cleanup.remove_trailing_whitespaces_all=true cleanup.remove_trailing_whitespaces_ignore_empty=false +cleanup.remove_unnecessary_array_creation=false cleanup.remove_unnecessary_casts=true cleanup.remove_unnecessary_nls_tags=false cleanup.remove_unused_imports=true cleanup.remove_unused_local_variables=false +cleanup.remove_unused_method_parameters=false cleanup.remove_unused_private_fields=true cleanup.remove_unused_private_members=false cleanup.remove_unused_private_methods=true cleanup.remove_unused_private_types=true +cleanup.return_expression=false +cleanup.simplify_lambda_expression_and_method_ref=false +cleanup.single_used_field=false cleanup.sort_members=false cleanup.sort_members_all=false +cleanup.standard_comparison=false +cleanup.static_inner_class=false +cleanup.strictly_equal_or_different=false +cleanup.stringbuffer_to_stringbuilder=false +cleanup.stringbuilder=false +cleanup.stringbuilder_for_local_vars=true +cleanup.stringconcat_to_textblock=false +cleanup.substring=false +cleanup.switch=false +cleanup.system_property=false +cleanup.system_property_boolean=false +cleanup.system_property_file_encoding=false +cleanup.system_property_file_separator=false +cleanup.system_property_line_separator=false +cleanup.system_property_path_separator=false +cleanup.ternary_operator=false +cleanup.try_with_resource=false +cleanup.unlooped_while=false +cleanup.unreachable_block=false cleanup.use_anonymous_class_creation=false +cleanup.use_autoboxing=false cleanup.use_blocks=false cleanup.use_blocks_only_for_return_and_throw=false +cleanup.use_directly_map_method=false cleanup.use_lambda=true cleanup.use_parentheses_in_expressions=false +cleanup.use_string_is_blank=false cleanup.use_this_for_non_static_field_access=false cleanup.use_this_for_non_static_field_access_only_if_necessary=true cleanup.use_this_for_non_static_method_access=false cleanup.use_this_for_non_static_method_access_only_if_necessary=true +cleanup.use_unboxing=false +cleanup.use_var=false +cleanup.useless_continue=false +cleanup.useless_return=false +cleanup.valueof_rather_than_instantiation=false cleanup_profile=_CDT cleanup_settings_version=2 eclipse.preferences.version=1 diff --git a/core/org.eclipse.cdt.ui.tests/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.ui.tests/META-INF/MANIFEST.MF index ca3185b6887..79c3b898b97 100644 --- a/core/org.eclipse.cdt.ui.tests/META-INF/MANIFEST.MF +++ b/core/org.eclipse.cdt.ui.tests/META-INF/MANIFEST.MF @@ -1,6 +1,6 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 -Bundle-Name: org.eclipse.cdt.ui.tests +Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.cdt.ui.tests; singleton:=true Bundle-Version: 5.5.300.qualifier Bundle-Activator: org.eclipse.cdt.ui.testplugin.CTestPlugin @@ -40,8 +40,9 @@ Require-Bundle: org.eclipse.jface.text, org.eclipse.osgi, org.eclipse.e4.core.contexts;bundle-version="[1.8.300,2.0.0)", org.mockito, - org.hamcrest + org.hamcrest.core, + org.hamcrest.library Bundle-ActivationPolicy: lazy -Bundle-Vendor: Eclipse CDT -Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Bundle-Vendor: %providerName +Bundle-RequiredExecutionEnvironment: JavaSE-11 Automatic-Module-Name: org.eclipse.cdt.ui.tests diff --git a/core/org.eclipse.cdt.ui.tests/about.html b/core/org.eclipse.cdt.ui.tests/about.html index 164f781a8fd..b3134865230 100644 --- a/core/org.eclipse.cdt.ui.tests/about.html +++ b/core/org.eclipse.cdt.ui.tests/about.html @@ -1,10 +1,11 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> + <head> -<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> -<title>About</title> + <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> + <title>About</title> </head> + <body lang="EN-US"> <h2>About This Content</h2> @@ -16,7 +17,7 @@ ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 ("EPL"). A copy of the EPL is - available at <a href="http://www.eclipse.org/legal/epl-2.0">http://www.eclipse.org/legal/epl-2.0</a>. + available at <a href="https://www.eclipse.org/legal/epl-2.0">https://www.eclipse.org/legal/epl-2.0</a>. For purposes of the EPL, "Program" will mean the Content. </p> @@ -29,8 +30,9 @@ license exists, contact the Redistributor. Unless otherwise indicated below, the terms and conditions of the EPL still apply to any source code in the Content and such source code may be obtained at <a - href="http://www.eclipse.org/">http://www.eclipse.org</a>. + href="https://www.eclipse.org/">https://www.eclipse.org</a>. </p> </body> + </html>
\ No newline at end of file diff --git a/core/org.eclipse.cdt.ui.tests/plugin.properties b/core/org.eclipse.cdt.ui.tests/plugin.properties index 539b3adfb34..b436c948a08 100644 --- a/core/org.eclipse.cdt.ui.tests/plugin.properties +++ b/core/org.eclipse.cdt.ui.tests/plugin.properties @@ -11,6 +11,10 @@ # Contributors: # Sergey Prigogin (Google) - initial implementation ############################################################################### + +pluginName = org.eclipse.cdt.ui.tests +providerName = Eclipse CDT + category.CodeReduction=C++ Code Reduction command.RemoveFunctionBodies.name=Remove Function Bodies command.RemoveFunctionBodies.label=Remove &Function Bodies diff --git a/core/org.eclipse.cdt.ui.tests/pom.xml b/core/org.eclipse.cdt.ui.tests/pom.xml index 94715a5ff14..e46cdd1f946 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.0.0-SNAPSHOT</version> + <version>10.7.0-SNAPSHOT</version> <relativePath>../../pom.xml</relativePath> </parent> @@ -66,9 +76,14 @@ <useUIThread>true</useUIThread> <argLine>${tycho.testArgLine} ${base.ui.test.vmargs} ${extra.vmargs.indexer.timeout} ${extra.vmargs.displayhelper.timeoutmultipler}</argLine> <appArgLine>-pluginCustomization ${basedir}/../../disable_intro_in_tests.ini</appArgLine> - <includes> - <include>**/AutomatedSuite.*</include> - </includes> + <excludes> + <!-- The default Excludes omits nested static classes, this reenables them. + See org.eclipse.cdt.core.parser.tests.ast2.cxx14.constexpr.ArrayTests.NonIndexingTests + for an example of a test that would not be run otherwise. + For reference, the default exclude is "**/*$*" + --> + <exclude></exclude> + </excludes> </configuration> </plugin> <plugin> diff --git a/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/reducer/RemoveUnusedDeclarationsRefactoring.java b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/reducer/RemoveUnusedDeclarationsRefactoring.java index 9f6382f6c8a..a054be77ed4 100644 --- a/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/reducer/RemoveUnusedDeclarationsRefactoring.java +++ b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/reducer/RemoveUnusedDeclarationsRefactoring.java @@ -563,7 +563,7 @@ public class RemoveUnusedDeclarationsRefactoring extends CRefactoring { * in the reverse order. */ private static class SortedNodeSet<T extends IASTNode> extends TreeSet<T> { - private static final Comparator<IASTNode> COMPARATOR = new Comparator<IASTNode>() { + private static final Comparator<IASTNode> COMPARATOR = new Comparator<>() { @Override public int compare(IASTNode node1, IASTNode node2) { int c = Integer.compare(ASTNodes.offset(node1), ASTNodes.offset(node2)); diff --git a/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/templateengine/AllTemplateEngineTests.java b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/templateengine/AllTemplateEngineTestSuite.java index c22995845be..134283bc2da 100644 --- a/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/templateengine/AllTemplateEngineTests.java +++ b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/templateengine/AllTemplateEngineTestSuite.java @@ -29,5 +29,5 @@ import org.junit.runners.Suite; TestProcesses.class, TestTemplateEngineBugs.class, }) -public class AllTemplateEngineTests { +public class AllTemplateEngineTestSuite { } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/AnnotationTestCase.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/AnnotationTestCase.java index 499e76b365d..b77e1fff701 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/AnnotationTestCase.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/AnnotationTestCase.java @@ -36,7 +36,7 @@ import org.eclipse.ui.PartInitException; * default is "src". To make it read comment from java class, you need to * include this source directory (with test java files) into the build bundle. */ -public class AnnotationTestCase extends UITestCaseWithProject { +public abstract class AnnotationTestCase extends UITestCaseWithProject { private IAnnotationModel fAnnotationModel; private Object fAnnotationModelLockObject; protected Annotation[] annotations; diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/AutomatedSuite.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/AutomatedSuite.java index bf6dbdccc28..cb98bc2b6c2 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/AutomatedSuite.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/AutomatedSuite.java @@ -40,7 +40,7 @@ import org.junit.runners.Suite; org.eclipse.cdt.ui.tests.wizards.classwizard.ClassWizardTestSuite.class, org.eclipse.cdt.ui.tests.wizards.settingswizards.SettingsWizardTestSuite.class, org.eclipse.cdt.ui.tests.misc.MiscTestSuite.class, org.eclipse.cdt.ui.tests.editor.EditorTestSuite.class, - org.eclipse.cdt.ui.tests.templateengine.AllTemplateEngineTests.class, + org.eclipse.cdt.ui.tests.templateengine.AllTemplateEngineTestSuite.class, }) public class AutomatedSuite { diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/BaseUITestCase.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/BaseUITestCase.java index 8de614ba976..5fec6d0cd01 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/BaseUITestCase.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/BaseUITestCase.java @@ -54,7 +54,7 @@ import org.eclipse.ui.WorkbenchException; import org.eclipse.ui.handlers.IHandlerService; import org.eclipse.ui.internal.WorkbenchPartReference; -public class BaseUITestCase extends BaseTestCase { +public abstract class BaseUITestCase extends BaseTestCase { public BaseUITestCase() { super(); } @@ -98,6 +98,11 @@ public class BaseUITestCase extends BaseTestCase { /** * Reads multiple sections in comments from the source of the given class. + * + * Trailing whitespace can be removed by editor/clean-up actions. To enforce whitespace + * at end of line, use ${whitspace_eol}, which will be removed, but cause the + * whitespace to the left of it to be preserved. + * * @since 4.0 */ public StringBuilder[] getContentsForTest(int sections) throws IOException { diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/UITestCaseWithProject.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/UITestCaseWithProject.java index e2b01844a5c..15db270316e 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/UITestCaseWithProject.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/UITestCaseWithProject.java @@ -27,6 +27,7 @@ import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.testplugin.CProjectHelper; import org.eclipse.cdt.core.testplugin.FileManager; +import org.eclipse.cdt.core.testplugin.util.ModelJoiner; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBaseTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBaseTest.java index 426e3a21ffa..ca064a720ae 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBaseTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBaseTest.java @@ -37,7 +37,7 @@ import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.ide.IDE; -public class CallHierarchyBaseTest extends BaseUITestCase { +public abstract class CallHierarchyBaseTest extends BaseUITestCase { private static int sProjectCounter = 0; protected ICProject fCProject; diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBugs.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBugsTest.java index f3399fc7344..fd21f0300e0 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBugs.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBugsTest.java @@ -27,14 +27,14 @@ import org.eclipse.ui.IWorkbenchWindow; import junit.framework.Test; -public class CallHierarchyBugs extends CallHierarchyBaseTest { +public class CallHierarchyBugsTest extends CallHierarchyBaseTest { - public CallHierarchyBugs(String name) { + public CallHierarchyBugsTest(String name) { super(name); } public static Test suite() { - return suite(CallHierarchyBugs.class); + return suite(CallHierarchyBugsTest.class); } @Override diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyTestSuite.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyTestSuite.java index 9f029d3830d..cafe8c47931 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyTestSuite.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyTestSuite.java @@ -21,7 +21,7 @@ import org.junit.runners.Suite; @RunWith(Suite.class) @Suite.SuiteClasses({ BasicCallHierarchyTest.class, BasicCppCallHierarchyTest.class, InitializersInCallHierarchyTest.class, CppCallHierarchyTest.class, CallHierarchyAcrossProjectsTest.class, - CallHierarchyBugs.class, }) + CallHierarchyBugsTest.class, }) public class CallHierarchyTestSuite { } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/includebrowser/BasicIncludeBrowserTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/includebrowser/BasicIncludeBrowserTest.java index 231a76af2db..f21ca23eaf7 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/includebrowser/BasicIncludeBrowserTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/includebrowser/BasicIncludeBrowserTest.java @@ -16,7 +16,10 @@ package org.eclipse.cdt.ui.tests.includebrowser; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.IPDOMManager; +import org.eclipse.cdt.core.model.CoreModel; +import org.eclipse.cdt.core.model.ICContainer; import org.eclipse.cdt.core.model.ICProject; +import org.eclipse.cdt.core.model.IPathEntry; import org.eclipse.cdt.core.testplugin.CProjectHelper; import org.eclipse.cdt.core.testplugin.TestScannerProvider; import org.eclipse.core.resources.IFile; @@ -104,4 +107,39 @@ public class BasicIncludeBrowserTest extends IncludeBrowserBaseTest { CProjectHelper.delete(op); } } + + // // source + // #include "user.h" + public void testInclusionOutsideSourceFolder() throws Exception { + ICProject cproject = CProjectHelper.createCCProject("__ibTest_outside_src__", "bin", + IPDOMManager.ID_FAST_INDEXER); + try { + ICContainer srcFolder = CProjectHelper.addCContainer(cproject, "src"); + IPathEntry newEntry = CoreModel.newSourceEntry(srcFolder.getPath()); + + IPathEntry[] entries = new IPathEntry[] { CoreModel.newSourceEntry(srcFolder.getPath()) }; + cproject.setRawPathEntries(entries, null); + + StringBuilder[] contents = getContentsForTest(1); + IProject project = cproject.getProject(); + IFile user = createFile(project, "user.h", ""); + IFile source = createFile(srcFolder.getResource(), "source.cpp", contents[0].toString()); + CCorePlugin.getIndexManager().reindex(cproject); + waitForIndexer(cproject); + + openIncludeBrowser(source); + Tree tree = getIBTree(); + TreeItem node = checkTreeNode(tree, 0, "source.cpp"); + checkTreeNode(tree, 0, 0, "user.h"); + assertEquals(1, node.getItemCount()); + + // The tree has to be reversed + openIncludeBrowser(user, true); + checkTreeNode(tree, 0, "user.h"); + checkTreeNode(tree, 0, 0, "source.cpp"); + + } finally { + CProjectHelper.delete(cproject); + } + } } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/includebrowser/IncludeBrowserBaseTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/includebrowser/IncludeBrowserBaseTest.java index 5bcec9942b7..e8a7dc243e0 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/includebrowser/IncludeBrowserBaseTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/includebrowser/IncludeBrowserBaseTest.java @@ -13,13 +13,15 @@ *******************************************************************************/ package org.eclipse.cdt.ui.tests.includebrowser; +import java.util.Optional; + import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.IPDOMManager; import org.eclipse.cdt.core.index.IIndex; -import org.eclipse.cdt.core.model.CoreModelUtil; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.testplugin.CProjectHelper; +import org.eclipse.cdt.internal.ui.includebrowser.IBConversions; import org.eclipse.cdt.internal.ui.includebrowser.IBViewPart; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.tests.BaseUITestCase; @@ -31,7 +33,7 @@ import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; -public class IncludeBrowserBaseTest extends BaseUITestCase { +public abstract class IncludeBrowserBaseTest extends BaseUITestCase { protected static IProgressMonitor NPM = new NullProgressMonitor(); private ICProject fCProject; @@ -77,13 +79,13 @@ public class IncludeBrowserBaseTest extends BaseUITestCase { } private IBViewPart doOpenIncludeBrowser(IFile file) throws PartInitException { - ITranslationUnit tu = CoreModelUtil.findTranslationUnit(file); - if (tu == null) { + Optional<ITranslationUnit> tu = IBConversions.fileToTU(file); + if (tu.isEmpty()) { fail(file.getFullPath().toString() + " is no translation unit!"); } IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); IBViewPart result = (IBViewPart) page.showView(CUIPlugin.ID_INCLUDE_BROWSER); - result.setInput(tu); + result.setInput(tu.get()); return result; } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/outline/BasicOutlineTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/outline/BasicOutlineTest.java index 0f8e75ff4d4..84ab282c953 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/outline/BasicOutlineTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/outline/BasicOutlineTest.java @@ -110,6 +110,27 @@ public class BasicOutlineTest extends BaseUITestCase { checkTreeNode(tree, 4, "main(int, char**) : int"); } + //#include "user.h" + //#include <system.h> + //#define MACRO + //int main(int argc, char** argv) {} + //#define MACRO2() + public void testOutlineContentOrder() throws Exception { + StringBuilder[] contents = getContentsForTest(1); + IProject project = getProject().getProject(); + IFile source = createFile(project, "source.cpp", contents[0].toString()); + waitForIndexer(project, source); + + final IViewPart outline = activateView(IPageLayout.ID_OUTLINE); + openEditor(source); + + Tree tree = checkTreeNode(outline, 0, "user.h").getParent(); + checkTreeNode(tree, 1, "system.h"); + checkTreeNode(tree, 2, "MACRO"); + checkTreeNode(tree, 3, "main(int, char**) : int"); + checkTreeNode(tree, 4, "MACRO2()"); + } + //class Foo { // static int field; // void bar(); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/RefactoringTestSuite.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/RefactoringTestSuite.java index c8a5731f2a5..e5eaf9070fb 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/RefactoringTestSuite.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/RefactoringTestSuite.java @@ -25,7 +25,14 @@ import org.eclipse.cdt.ui.tests.refactoring.hidemethod.HideMethodRefactoringTest import org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest; import org.eclipse.cdt.ui.tests.refactoring.includes.IncludesTestSuite; import org.eclipse.cdt.ui.tests.refactoring.overridemethods.OverrideMethodsRefactoringTest; +import org.eclipse.cdt.ui.tests.refactoring.rename.RenameFunctionTests; +import org.eclipse.cdt.ui.tests.refactoring.rename.RenameMacroTests; import org.eclipse.cdt.ui.tests.refactoring.rename.RenameRegressionTests; +import org.eclipse.cdt.ui.tests.refactoring.rename.RenameTemplatesTests; +import org.eclipse.cdt.ui.tests.refactoring.rename.RenameTypeTests; +import org.eclipse.cdt.ui.tests.refactoring.rename.RenameVariableTests; +import org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleNodeHelperTest; +import org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringCTest; import org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest; import org.eclipse.cdt.ui.tests.refactoring.utils.UtilTestSuite; import org.junit.runner.RunWith; @@ -38,7 +45,9 @@ import org.junit.runners.Suite; @Suite.SuiteClasses({ UtilTestSuite.class, RenameRegressionTests.class, ExtractFunctionRefactoringTest.class, ExtractConstantRefactoringTest.class, HideMethodRefactoringTest.class, GenerateGettersAndSettersTest.class, ImplementMethodRefactoringTest.class, ExtractLocalVariableRefactoringTest.class, ToggleRefactoringTest.class, - IncludesTestSuite.class, OverrideMethodsRefactoringTest.class + ToggleRefactoringCTest.class, ToggleNodeHelperTest.class, IncludesTestSuite.class, + OverrideMethodsRefactoringTest.class, RenameVariableTests.class, RenameFunctionTests.class, + RenameTypeTests.class, RenameMacroTests.class, RenameTemplatesTests.class }) public class RefactoringTestSuite { diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/implementmethod/ImplementMethodRefactoringTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/implementmethod/ImplementMethodRefactoringTest.java index 036cd077ab4..036cd077ab4 100755..100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/implementmethod/ImplementMethodRefactoringTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/implementmethod/ImplementMethodRefactoringTest.java diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/overridemethods/OverrideMethodsRefactoringTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/overridemethods/OverrideMethodsRefactoringTest.java index dff120aa23e..dff120aa23e 100755..100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/overridemethods/OverrideMethodsRefactoringTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/overridemethods/OverrideMethodsRefactoringTest.java diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RefactoringTests.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RefactoringTests.java index 3fd7d917ba3..f6d51d3d3ab 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RefactoringTests.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RefactoringTests.java @@ -35,7 +35,7 @@ import org.eclipse.text.edits.TextEditGroup; /** * @author markus.schorn@windriver.com */ -public class RefactoringTests extends BaseTestFramework { +public abstract class RefactoringTests extends BaseTestFramework { private int fBufferSize; public RefactoringTests() { diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameFunctionTests.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameFunctionTests.java index 2ac8439cf6a..799f09345c1 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameFunctionTests.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameFunctionTests.java @@ -36,7 +36,7 @@ public class RenameFunctionTests extends RenameTestBase { TestSuite suite = new TestSuite(RenameFunctionTests.class); if (cleanup) { - suite.addTest(new RefactoringTests("cleanupProject")); + suite.addTest(new RenameFunctionTests("cleanupProject")); } return suite; } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameMacroTests.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameMacroTests.java index 1ad9b31e956..60178611c36 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameMacroTests.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameMacroTests.java @@ -34,7 +34,7 @@ public class RenameMacroTests extends RenameTestBase { public static Test suite(boolean cleanup) { TestSuite suite = new TestSuite(RenameMacroTests.class); if (cleanup) { - suite.addTest(new RefactoringTests("cleanupProject")); + suite.addTest(new RenameMacroTests("cleanupProject")); } return suite; } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameRegressionTests.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameRegressionTests.java index f8a84ae072d..beebc655b1b 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameRegressionTests.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameRegressionTests.java @@ -17,7 +17,7 @@ package org.eclipse.cdt.ui.tests.refactoring.rename; import java.io.StringWriter; import org.eclipse.cdt.core.dom.ast.IBinding; -import org.eclipse.cdt.core.tests.FailingTest; +import org.eclipse.cdt.core.tests.FailingTester; import org.eclipse.core.resources.IFile; import org.eclipse.ltk.core.refactoring.Change; import org.eclipse.ltk.core.refactoring.RefactoringStatus; @@ -42,15 +42,10 @@ public class RenameRegressionTests extends RenameTestBase { public static Test suite(boolean cleanup) { TestSuite innerSuite = new TestSuite(RenameRegressionTests.class); - innerSuite.addTest(new FailingTest(new RenameRegressionTests("_testMethod_35_72726"), 72726)); + innerSuite.addTest(new FailingTester(new RenameRegressionTests("_testMethod_35_72726"), 72726)); TestSuite suite = new TestSuite("RenameRegressionTests"); suite.addTest(innerSuite); - suite.addTest(RenameVariableTests.suite(false)); - suite.addTest(RenameFunctionTests.suite(false)); - suite.addTest(RenameTypeTests.suite(false)); - suite.addTest(RenameMacroTests.suite(false)); - suite.addTest(RenameTemplatesTests.suite(false)); if (cleanup) suite.addTest(new RenameRegressionTests("cleanupProject")); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameTemplatesTests.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameTemplatesTests.java index b9de816dd6f..a3ddb45ce41 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameTemplatesTests.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameTemplatesTests.java @@ -38,7 +38,7 @@ public class RenameTemplatesTests extends RenameTestBase { public static Test suite(boolean cleanup) { TestSuite suite = new TestSuite(RenameTemplatesTests.class); if (cleanup) { - suite.addTest(new RefactoringTests("cleanupProject")); + suite.addTest(new RenameTemplatesTests("cleanupProject")); } return suite; } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameTypeTests.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameTypeTests.java index ac8c0a61b44..da473fdd68d 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameTypeTests.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameTypeTests.java @@ -39,7 +39,7 @@ public class RenameTypeTests extends RenameTestBase { public static Test suite(boolean cleanup) { TestSuite suite = new TestSuite(RenameTypeTests.class); if (cleanup) { - suite.addTest(new RefactoringTests("cleanupProject")); + suite.addTest(new RenameTypeTests("cleanupProject")); } return suite; } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameVariableTests.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameVariableTests.java index abc294c4ab3..baad1a7ade4 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameVariableTests.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameVariableTests.java @@ -39,7 +39,7 @@ public class RenameVariableTests extends RenameTestBase { TestSuite suite = new TestSuite(RenameVariableTests.class); if (cleanup) { - suite.addTest(new RefactoringTests("cleanupProject")); + suite.addTest(new RenameVariableTests("cleanupProject")); } return suite; } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/togglefunction/ToggleRefactoringTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/togglefunction/ToggleRefactoringTest.java index 3a0c764b337..60f9601c569 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/togglefunction/ToggleRefactoringTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/togglefunction/ToggleRefactoringTest.java @@ -40,8 +40,6 @@ public class ToggleRefactoringTest extends RefactoringTestBase { public static Test suite() { TestSuite suite = suite(ToggleRefactoringTest.class); - suite.addTestSuite(ToggleRefactoringCTest.class); - suite.addTestSuite(ToggleNodeHelperTest.class); return suite; } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/utils/CorrectCaseTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/utils/CorrectCaseTest.java deleted file mode 100644 index a0da59f0730..00000000000 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/utils/CorrectCaseTest.java +++ /dev/null @@ -1,89 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik - * Rapperswil, University of applied sciences 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: - * Institute for Software - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.ui.tests.refactoring.utils; - -import org.eclipse.cdt.internal.ui.refactoring.utils.IdentifierHelper; -import org.eclipse.cdt.internal.ui.refactoring.utils.IdentifierResult; - -import junit.framework.TestCase; - -/** - * @author Thomas Corbat - * - */ -public class CorrectCaseTest extends TestCase { - - public CorrectCaseTest() { - super("Check Correct Identifier"); //$NON-NLS-1$ - } - - @Override - public void runTest() { - IdentifierResult result; - - result = IdentifierHelper.checkIdentifierName("A"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.VALID == result.getResult()); - - result = IdentifierHelper.checkIdentifierName("Z"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.VALID == result.getResult()); - - result = IdentifierHelper.checkIdentifierName("a"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.VALID == result.getResult()); - - result = IdentifierHelper.checkIdentifierName("z"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.VALID == result.getResult()); - - result = IdentifierHelper.checkIdentifierName("_"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.VALID == result.getResult()); - - result = IdentifierHelper.checkIdentifierName("_A"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.VALID == result.getResult()); - - result = IdentifierHelper.checkIdentifierName("_Z"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.VALID == result.getResult()); - - result = IdentifierHelper.checkIdentifierName("_a"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.VALID == result.getResult()); - - result = IdentifierHelper.checkIdentifierName("_z"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.VALID == result.getResult()); - - result = IdentifierHelper.checkIdentifierName("__"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.VALID == result.getResult()); - - result = IdentifierHelper.checkIdentifierName("_0"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.VALID == result.getResult()); - - result = IdentifierHelper.checkIdentifierName("_9"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.VALID == result.getResult()); - - result = IdentifierHelper.checkIdentifierName("Aaaa"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.VALID == result.getResult()); - - result = IdentifierHelper.checkIdentifierName("Zaaa"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.VALID == result.getResult()); - - result = IdentifierHelper.checkIdentifierName("aaaa"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.VALID == result.getResult()); - - result = IdentifierHelper.checkIdentifierName("zaaa"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.VALID == result.getResult()); - - result = IdentifierHelper.checkIdentifierName("_aaa"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.VALID == result.getResult()); - - } - -} diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/utils/DigitFirstCaseTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/utils/DigitFirstCaseTest.java deleted file mode 100644 index 76a02587091..00000000000 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/utils/DigitFirstCaseTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik - * Rapperswil, University of applied sciences 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: - * Institute for Software - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.ui.tests.refactoring.utils; - -import org.eclipse.cdt.internal.ui.refactoring.utils.IdentifierHelper; -import org.eclipse.cdt.internal.ui.refactoring.utils.IdentifierResult; - -import junit.framework.TestCase; - -/** - * @author Thomas Corbat - * - */ -public class DigitFirstCaseTest extends TestCase { - - public DigitFirstCaseTest() { - super("Check Digit First Identifier"); //$NON-NLS-1$ - } - - @Override - public void runTest() { - IdentifierResult result; - - result = IdentifierHelper.checkIdentifierName("0"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.DIGIT_FIRST == result.getResult()); - - result = IdentifierHelper.checkIdentifierName("9"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.DIGIT_FIRST == result.getResult()); - - result = IdentifierHelper.checkIdentifierName("0a"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.DIGIT_FIRST == result.getResult()); - - result = IdentifierHelper.checkIdentifierName("99"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.DIGIT_FIRST == result.getResult()); - - } - -} diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/utils/EmptyCaseTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/utils/EmptyCaseTest.java deleted file mode 100644 index 438034ece1e..00000000000 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/utils/EmptyCaseTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik - * Rapperswil, University of applied sciences 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: - * Institute for Software - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.ui.tests.refactoring.utils; - -import org.eclipse.cdt.internal.ui.refactoring.utils.IdentifierHelper; -import org.eclipse.cdt.internal.ui.refactoring.utils.IdentifierResult; - -import junit.framework.TestCase; - -/** - * @author Thomas Corbat - * - */ -public class EmptyCaseTest extends TestCase { - - public EmptyCaseTest() { - super("Check Empty Identifier"); //$NON-NLS-1$ - } - - @Override - public void runTest() { - IdentifierResult result; - - result = IdentifierHelper.checkIdentifierName(""); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.EMPTY == result.getResult()); - - } - -} diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/utils/IdentifierHelperTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/utils/IdentifierHelperTest.java index baa7f968081..d1d4c1bcd15 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/utils/IdentifierHelperTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/utils/IdentifierHelperTest.java @@ -11,28 +11,247 @@ * * Contributors: * Institute for Software - initial API and implementation + * Martin Weber *******************************************************************************/ package org.eclipse.cdt.ui.tests.refactoring.utils; -import junit.framework.Test; -import junit.framework.TestSuite; +import org.eclipse.cdt.internal.ui.refactoring.utils.IdentifierHelper; +import org.eclipse.cdt.internal.ui.refactoring.utils.IdentifierResult; + +import junit.framework.TestCase; /** * @author Thomas Corbat + * @author Martin Weber */ -public class IdentifierHelperTest extends TestSuite { +public class IdentifierHelperTest extends TestCase { + + public void testCorrectIdentifierCase() { + IdentifierResult result; + + result = IdentifierHelper.checkIdentifierName("A"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.VALID == result.getResult()); + + result = IdentifierHelper.checkIdentifierName("Z"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.VALID == result.getResult()); + + result = IdentifierHelper.checkIdentifierName("a"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.VALID == result.getResult()); + + result = IdentifierHelper.checkIdentifierName("z"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.VALID == result.getResult()); + + result = IdentifierHelper.checkIdentifierName("_"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.VALID == result.getResult()); + + result = IdentifierHelper.checkIdentifierName("_A"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.VALID == result.getResult()); + + result = IdentifierHelper.checkIdentifierName("_Z"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.VALID == result.getResult()); + + result = IdentifierHelper.checkIdentifierName("_a"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.VALID == result.getResult()); + + result = IdentifierHelper.checkIdentifierName("_z"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.VALID == result.getResult()); + + result = IdentifierHelper.checkIdentifierName("__"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.VALID == result.getResult()); + + result = IdentifierHelper.checkIdentifierName("_0"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.VALID == result.getResult()); + + result = IdentifierHelper.checkIdentifierName("_9"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.VALID == result.getResult()); + + result = IdentifierHelper.checkIdentifierName("Aaaa"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.VALID == result.getResult()); + + result = IdentifierHelper.checkIdentifierName("Zaaa"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.VALID == result.getResult()); + + result = IdentifierHelper.checkIdentifierName("aaaa"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.VALID == result.getResult()); - public IdentifierHelperTest() { - super("Identifier Helper Test"); //$NON-NLS-1$ + result = IdentifierHelper.checkIdentifierName("zaaa"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.VALID == result.getResult()); + + result = IdentifierHelper.checkIdentifierName("_aaa"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.VALID == result.getResult()); } - public static Test suite() { - TestSuite suite = new TestSuite("Test for Identifier Helper"); //$NON-NLS-1$ - suite.addTest(new CorrectCaseTest()); - suite.addTest(new DigitFirstCaseTest()); - suite.addTest(new EmptyCaseTest()); - suite.addTest(new IllegalCharCaseTest()); - suite.addTest(new KeywordCaseTest()); - return suite; + public void testDigitFirst() { + IdentifierResult result; + + result = IdentifierHelper.checkIdentifierName("0"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.DIGIT_FIRST == result.getResult()); + + result = IdentifierHelper.checkIdentifierName("9"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.DIGIT_FIRST == result.getResult()); + + result = IdentifierHelper.checkIdentifierName("0a"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.DIGIT_FIRST == result.getResult()); + + result = IdentifierHelper.checkIdentifierName("99"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.DIGIT_FIRST == result.getResult()); + } + + public void testEmpty() { + IdentifierResult result; + + result = IdentifierHelper.checkIdentifierName(""); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.EMPTY == result.getResult()); + } + + public void testIllegalChar() { + IdentifierResult result; + + result = IdentifierHelper.checkIdentifierName("a~"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.ILLEGAL_CHARACTER == result.getResult()); + + result = IdentifierHelper.checkIdentifierName("a%"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.ILLEGAL_CHARACTER == result.getResult()); + + result = IdentifierHelper.checkIdentifierName("a!"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.ILLEGAL_CHARACTER == result.getResult()); + + result = IdentifierHelper.checkIdentifierName("{}"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.ILLEGAL_CHARACTER == result.getResult()); + } + + public void testKeyword() { + IdentifierResult result; + + result = IdentifierHelper.checkIdentifierName("using"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("bitand"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("for"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("const_cast"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("namespace"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("break"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("static_cast"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("false"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("volatile"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("template"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("else"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("dynamic_cast"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("static"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("or"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("not_eq"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("class"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("enum"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("typedef"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("restrict"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("and"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("reinterpret_cast"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("not"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("default"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("explicit"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("sizeof"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("auto"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("case"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("this"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("try"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("friend"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("asm"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("virtual"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("const"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("or_eq"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("catch"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("switch"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("goto"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("while"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("private"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("throw"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("protected"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("struct"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("if"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("extern"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("union"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("typeid"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("noexcept"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("inline"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("compl"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("delete"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("do"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("xor"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("export"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("bitor"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("return"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("true"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("operator"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("register"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("new"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("and_eq"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("typename"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("continue"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("mutable"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("xor_eq"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); + result = IdentifierHelper.checkIdentifierName("public"); //$NON-NLS-1$ + assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); } } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/utils/IllegalCharCaseTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/utils/IllegalCharCaseTest.java deleted file mode 100644 index 149df185185..00000000000 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/utils/IllegalCharCaseTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik - * Rapperswil, University of applied sciences 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: - * Institute for Software - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.ui.tests.refactoring.utils; - -import org.eclipse.cdt.internal.ui.refactoring.utils.IdentifierHelper; -import org.eclipse.cdt.internal.ui.refactoring.utils.IdentifierResult; - -import junit.framework.TestCase; - -/** - * @author Thomas Corbat - * - */ -public class IllegalCharCaseTest extends TestCase { - - public IllegalCharCaseTest() { - super("Check Illegal Character Identifier"); //$NON-NLS-1$ - } - - @Override - public void runTest() { - IdentifierResult result; - - result = IdentifierHelper.checkIdentifierName("a~"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.ILLEGAL_CHARACTER == result.getResult()); - - result = IdentifierHelper.checkIdentifierName("a%"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.ILLEGAL_CHARACTER == result.getResult()); - - result = IdentifierHelper.checkIdentifierName("a!"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.ILLEGAL_CHARACTER == result.getResult()); - - result = IdentifierHelper.checkIdentifierName("{}"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.ILLEGAL_CHARACTER == result.getResult()); - - } - -} diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/utils/KeywordCaseTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/utils/KeywordCaseTest.java deleted file mode 100644 index eb8ae854b4e..00000000000 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/utils/KeywordCaseTest.java +++ /dev/null @@ -1,166 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik - * Rapperswil, University of applied sciences 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: - * Institute for Software - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.ui.tests.refactoring.utils; - -import org.eclipse.cdt.internal.ui.refactoring.utils.IdentifierHelper; -import org.eclipse.cdt.internal.ui.refactoring.utils.IdentifierResult; - -import junit.framework.TestCase; - -/** - * @author Thomas Corbat - */ -public class KeywordCaseTest extends TestCase { - - public KeywordCaseTest() { - super("Check Keyword Identifier"); //$NON-NLS-1$ - } - - @Override - public void runTest() { - IdentifierResult result; - - result = IdentifierHelper.checkIdentifierName("using"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("bitand"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("for"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("const_cast"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("namespace"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("break"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("static_cast"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("false"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("volatile"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("template"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("else"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("dynamic_cast"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("static"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("or"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("not_eq"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("class"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("enum"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("typedef"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("restrict"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("and"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("reinterpret_cast"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("not"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("default"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("explicit"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("sizeof"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("auto"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("case"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("this"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("try"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("friend"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("asm"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("virtual"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("const"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("or_eq"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("catch"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("switch"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("goto"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("while"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("private"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("throw"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("protected"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("struct"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("if"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("extern"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("union"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("typeid"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("noexcept"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("inline"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("compl"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("delete"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("do"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("xor"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("export"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("bitor"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("return"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("true"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("operator"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("register"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("new"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("and_eq"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("typename"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("continue"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("mutable"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("xor_eq"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - result = IdentifierHelper.checkIdentifierName("public"); //$NON-NLS-1$ - assertTrue(result.getMessage(), IdentifierResult.KEYWORD == result.getResult()); - } -} diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/utils/UtilTestSuite.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/utils/UtilTestSuite.java index db0abd60ff2..74e50f24d8b 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/utils/UtilTestSuite.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/utils/UtilTestSuite.java @@ -25,7 +25,7 @@ public class UtilTestSuite extends TestSuite { public static Test suite() throws Exception { UtilTestSuite suite = new UtilTestSuite(); - suite.addTest(IdentifierHelperTest.suite()); + suite.addTestSuite(IdentifierHelperTest.class); suite.addTestSuite(DefinitionFinderTest.class); suite.addTestSuite(PseudoNameGeneratorTest.class); suite.addTestSuite(NameComposerTest.class); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/AbstractAutoEditTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/AbstractAutoEditTest.java index 9b2bdd678fc..6b66495b109 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/AbstractAutoEditTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/AbstractAutoEditTest.java @@ -33,7 +33,7 @@ import org.eclipse.jface.text.TextUtilities; /** * IAutoEditStrategy related tests */ -public class AbstractAutoEditTest extends BaseTestCase { +public abstract class AbstractAutoEditTest extends BaseTestCase { protected AbstractAutoEditTest(String name) { super(name); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/BreakIteratorTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/BreakIteratorTest.java index fe8d4fb992e..194a363d875 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/BreakIteratorTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/BreakIteratorTest.java @@ -19,7 +19,7 @@ import java.text.BreakIterator; import junit.framework.TestCase; -public class BreakIteratorTest extends TestCase { +public abstract class BreakIteratorTest extends TestCase { protected BreakIterator fBreakIterator; diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java index 459aab7aa09..d5a7504ae16 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java @@ -4735,43 +4735,6 @@ public class CodeFormatterTest extends BaseUITestCase { assertFormatterResult(); } - //template<class T> - //struct U; - //U()->U<int>; - - //template<class T> - //struct U; - //U() -> U<int>; - public void testDeductionGuide() throws Exception { - assertFormatterResult(); - } - - //template<class T> - //struct U; - //template<class C> - //U(C)->U<C>; - - //template<class T> - //struct U; - //template<class C> - //U(C) -> U<C>; - public void testDeductionGuideTemplate() throws Exception { - assertFormatterResult(); - } - - //template<class T> - //struct U; - //template<class C> - //explicit U(C)->U<C>; - - //template<class T> - //struct U; - //template<class C> - //explicit U(C) -> U<C>; - public void testDeductionGuideExplicit() throws Exception { - assertFormatterResult(); - } - //int main() { // auto f = [&](){ // }; @@ -4840,4 +4803,18 @@ public class CodeFormatterTest extends BaseUITestCase { public void testLambdaWithoutParens_Bug564273() throws Exception { assertFormatterResult(); } + + //#ifdef AAA + //#define BBB + //#endif + + //#ifdef AAA + //#define BBB + //#endif + public void testCodeFormatterTagsOff_Bug579261() throws Exception { + // Tests that when there is an inactive block of code that code formatter doesn't fail when + // tags are disabled + fOptions.put(DefaultCodeFormatterConstants.FORMATTER_USE_COMMENT_TAG, DefaultCodeFormatterConstants.FALSE); + assertFormatterResult(); + } } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/DefaultCCommentAutoEditStrategyTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/DefaultCCommentAutoEditStrategyTest.java index 00d57b8daf4..4bc0534a7f9 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/DefaultCCommentAutoEditStrategyTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/DefaultCCommentAutoEditStrategyTest.java @@ -166,13 +166,13 @@ public class DefaultCCommentAutoEditStrategyTest extends AbstractAutoEditTest { // class A { // /* X - // }; + // }; ${whitespace_eol} // class A { - // /* + // /* ${whitespace_eol} // * X // */ - // }; + // }; ${whitespace_eol} public void testInsertNewLine5() { assertNewLineBehaviour(); } @@ -336,7 +336,7 @@ public class DefaultCCommentAutoEditStrategyTest extends AbstractAutoEditTest { // X // /* - // + // ${whitespace_eol} // X public void testInsertNewLine17() { assertNewLineBehaviour(); @@ -347,7 +347,7 @@ public class DefaultCCommentAutoEditStrategyTest extends AbstractAutoEditTest { // */ // /* - // + // ${whitespace_eol} // X // */ public void testInsertNewLine18() { @@ -460,7 +460,10 @@ public class DefaultCCommentAutoEditStrategyTest extends AbstractAutoEditTest { // }; // } // } - public void _testFollowingDeclaration5() { + //XXX: This test was unexpectedly succeeding - with no previous commentary about + // what this test was or why it failed I have no idea why it is now passing + // Therefore I changed visibility to private so it would be ignored. + private void IGNORE_testFollowingDeclaration5() { assertDeclarationFollowingX( "namespace n2 {\n void foo() {}\n void bar(int x) {}\n class C {\n int y;\n void baz(int x) {}\n };\n }"); } @@ -527,7 +530,7 @@ public class DefaultCCommentAutoEditStrategyTest extends AbstractAutoEditTest { // public: // X // STATIC void D::foo(int x) { - // + // ${whitespace_eol} // } // }; public void testFollowingDeclaration13() throws CoreException { diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/TextTestSuite.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/TextTestSuite.java index de37cda157a..c66b9324643 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/TextTestSuite.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/TextTestSuite.java @@ -33,7 +33,7 @@ import org.junit.runners.Suite; // smart edit tests AlignConstActionTest.class, CAutoIndentTest.class, CHeuristicScannerTest.class, BracketInserterTest.class, IndentActionTest.class, FormatActionTest.class, ShiftActionTest.class, CodeFormatterTest.class, - CIndenterTest.class, TemplateFormatterTest.class, + CIndenterTest.class, TemplateFormatterTest.class, DefaultCCommentAutoEditStrategyTest.class, // Break iterator tests. CBreakIteratorTest.class, CWordIteratorTest.class, @@ -61,6 +61,11 @@ import org.junit.runners.Suite; AddBlockCommentTest.class, RemoveBlockCommentTest.class, SortLinesTest.class, // add include - AddIncludeTest.class, }) + AddIncludeTest.class, + + // other tests + OverrideIndicatorTest.class, + +}) public class TextTestSuite { } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist/CompletionProposalComputerPreferenceParserTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist/CompletionProposalComputerPreferenceParserTest.java new file mode 100644 index 00000000000..7afe5feff54 --- /dev/null +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist/CompletionProposalComputerPreferenceParserTest.java @@ -0,0 +1,81 @@ +/******************************************************************************* + * Copyright (c) 2020 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.ui.tests.text.contentassist; + +import static java.util.Arrays.asList; +import static org.eclipse.cdt.internal.ui.text.contentassist.CompletionProposalComputerPreferenceParser.parseCategoryOrder; +import static org.eclipse.cdt.internal.ui.text.contentassist.CompletionProposalComputerPreferenceParser.parseExcludedCategories; +import static org.junit.Assert.assertEquals; + +import java.text.ParseException; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.junit.Test; + +public class CompletionProposalComputerPreferenceParserTest { + + @Test + public void testParseExcludedCategories() throws ParseException { + assertEquals(asSet(), parseExcludedCategories("\0")); + assertEquals(asSet(), parseExcludedCategories("\0\0")); + assertEquals(asSet("cat1"), parseExcludedCategories("cat1\0")); + assertEquals(asSet("cat1", "cat2"), parseExcludedCategories("cat1\0cat2")); + assertEquals(asSet("cat1"), parseExcludedCategories("cat1${0x0}")); + assertEquals(asSet("cat1", "cat2"), parseExcludedCategories("cat1${0x0}cat2")); + assertEquals(asSet("cat1"), parseExcludedCategories("cat1$$$${0x0}")); + assertEquals(asSet("cat1", "cat2"), parseExcludedCategories("cat1$$$${0x0}cat2")); + assertEquals(asSet("cat1", "cat2", "cat3", "cat4"), + parseExcludedCategories("cat1$$$${0x0}cat2${0x0}cat3\0cat4\0")); + } + + @Test + public void testParseCategoryOrder() throws ParseException { + assertEquals(asMap("cat1", 1), parseCategoryOrder("cat1:1\0")); + assertEquals(asMap("cat1", 1000), parseCategoryOrder("cat1:1000\0\0")); + assertEquals(asMap("cat1", 1000, "cat2", 2000), parseCategoryOrder("cat1:1000\0cat2:2000")); + assertEquals(asMap("cat1", 1), parseCategoryOrder("cat1:1${0x0}")); + assertEquals(asMap("cat1", 1000, "cat2", 2000), parseCategoryOrder("cat1:1000${0x0}cat2:2000")); + assertEquals(asMap("cat1", 1), parseCategoryOrder("cat1:1$$$$${0x0}")); + assertEquals(asMap("cat1", 1000, "cat2", 2000), parseCategoryOrder("cat1:1000$$$$${0x0}cat2:2000")); + assertEquals(asMap("cat1", 1000, "cat2", 2000, "cat3", 3000, "cat4", 4000), + parseCategoryOrder("cat1:1000$$$$${0x0}cat2:2000${0x0}cat3:3000\0cat4:4000\0")); + } + + @Test(expected = ParseException.class) + public void testParseIntFailsGracefully1() throws ParseException { + assertEquals(asMap(), parseCategoryOrder("cat1:this is not a number\0")); + } + + @Test(expected = ParseException.class) + public void testParseIntFailsGracefully2() throws ParseException { + assertEquals(asMap(), parseCategoryOrder("cat1 missing number\0")); + } + + @Test(expected = ParseException.class) + public void testParseIntFailsGracefully3() throws ParseException { + assertEquals(asMap(), parseCategoryOrder("cat1:0:extra field\0")); + } + + private Set<String> asSet(String... elem) { + return new HashSet<>(asList(elem)); + } + + private Map<String, Integer> asMap(Object... elem) { + HashMap<String, Integer> map = new HashMap<>(); + for (int i = 0; i < elem.length; i += 2) { + map.put((String) elem[i + 0], (Integer) elem[i + 1]); + } + return map; + } +} diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist/ContentAssistTestSuite.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist/ContentAssistTestSuite.java index c95b6f6fb69..290d67c52a4 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist/ContentAssistTestSuite.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist/ContentAssistTestSuite.java @@ -22,6 +22,8 @@ import org.junit.runners.Suite; ContentAssistTests.class, + CompletionProposalComputerPreferenceParserTest.class, + }) public class ContentAssistTestSuite { } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/AbstractContentAssistTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/AbstractContentAssistTest.java index cb051436426..ba66e60b3d4 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/AbstractContentAssistTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/AbstractContentAssistTest.java @@ -182,7 +182,9 @@ public abstract class AbstractContentAssistTest extends BaseUITestCase { ContentAssistResult r = invokeContentAssist(offset, length, isCompletion, isTemplate, filterResults); - String[] resultStrings = toStringArray(r.results, compareType); + List<String> resultStringList = new ArrayList<>(Arrays.asList(toStringArray(r.results, compareType))); + resultStringList.removeIf(string -> string != null && string.contains(".settings")); + String[] resultStrings = resultStringList.toArray(String[]::new); if (!checkOrder) { Arrays.sort(expected); Arrays.sort(resultStrings); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_AnonymousTypes.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/AnonymousTypes_CompletionTest.java index fffac1f3050..731351015a0 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_AnonymousTypes.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/AnonymousTypes_CompletionTest.java @@ -19,7 +19,7 @@ import junit.framework.TestSuite; /** * Test that anonymous types are not returned as possibilities. */ -public class CompletionTest_AnonymousTypes extends CompletionProposalsBaseTest { +public class AnonymousTypes_CompletionTest extends CompletionProposalsBaseTest { private final String fileName = "CompletionTestStart40.cpp"; private final String fileFullPath = "resources/contentassist/" + fileName; private final String headerFileName = "CompletionTestStart40.h"; @@ -27,15 +27,15 @@ public class CompletionTest_AnonymousTypes extends CompletionProposalsBaseTest { private final String expectedPrefix = ""; private final String[] expectedResults = { "notAnonymousEnum", "notAnonymousClass", "xOtherClass" }; - public CompletionTest_AnonymousTypes(String name) { + public AnonymousTypes_CompletionTest(String name) { super(name); // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=174809 // setExpectFailure(174809); } public static Test suite() { - TestSuite suite = new TestSuite(CompletionTest_AnonymousTypes.class.getName()); - suite.addTest(new CompletionTest_AnonymousTypes("testCompletionProposals")); + TestSuite suite = new TestSuite(AnonymousTypes_CompletionTest.class.getName()); + suite.addTest(new AnonymousTypes_CompletionTest("testCompletionProposals")); return suite; } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ArgumentType_Prefix2.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/ArgumentType_Prefix2_CompletionTest.java index 0e282d49fe3..2828bc1279a 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ArgumentType_Prefix2.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/ArgumentType_Prefix2_CompletionTest.java @@ -23,7 +23,7 @@ import junit.framework.TestSuite; * Bug#50642 : Wrong completion kind when declaring an argument type * */ -public class CompletionTest_ArgumentType_Prefix2 extends CompletionProposalsBaseTest { +public class ArgumentType_Prefix2_CompletionTest extends CompletionProposalsBaseTest { private final String fileName = "CompletionTestStart18.cpp"; private final String fileFullPath = "resources/contentassist/" + fileName; private final String headerFileName = "CompletionTestStart.h"; @@ -32,15 +32,15 @@ public class CompletionTest_ArgumentType_Prefix2 extends CompletionProposalsBase private final String[] expectedResults = { "aClass", "anotherClass", "aNamespace", "anEnumeration", "AStruct", "AMacro(x)" }; - public CompletionTest_ArgumentType_Prefix2(String name) { + public ArgumentType_Prefix2_CompletionTest(String name) { super(name); // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=109724 // setExpectFailure(109724); } public static Test suite() { - TestSuite suite = new TestSuite(CompletionTest_ArgumentType_Prefix2.class.getName()); - suite.addTest(new CompletionTest_ArgumentType_Prefix2("testCompletionProposals")); + TestSuite suite = new TestSuite(ArgumentType_Prefix2_CompletionTest.class.getName()); + suite.addTest(new ArgumentType_Prefix2_CompletionTest("testCompletionProposals")); return suite; } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ArgumentType_Prefix.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/ArgumentType_Prefix_CompletionTest.java index 2e9eef55695..af74a840684 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ArgumentType_Prefix.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/ArgumentType_Prefix_CompletionTest.java @@ -23,7 +23,7 @@ import junit.framework.TestSuite; * Bug#50642 : Wrong completion kind when declaring an argument type * */ -public class CompletionTest_ArgumentType_Prefix extends CompletionProposalsBaseTest { +public class ArgumentType_Prefix_CompletionTest extends CompletionProposalsBaseTest { private final String fileName = "CompletionTestStart16.cpp"; private final String fileFullPath = "resources/contentassist/" + fileName; private final String headerFileName = "CompletionTestStart.h"; @@ -32,15 +32,15 @@ public class CompletionTest_ArgumentType_Prefix extends CompletionProposalsBaseT private final String[] expectedResults = { "aClass", "anotherClass", "aNamespace", "anEnumeration", "AStruct", "AMacro(x)" }; - public CompletionTest_ArgumentType_Prefix(String name) { + public ArgumentType_Prefix_CompletionTest(String name) { super(name); // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=109724 // setExpectFailure(109724); } public static Test suite() { - TestSuite suite = new TestSuite(CompletionTest_ArgumentType_Prefix.class.getName()); - suite.addTest(new CompletionTest_ArgumentType_Prefix("testCompletionProposals")); + TestSuite suite = new TestSuite(ArgumentType_Prefix_CompletionTest.class.getName()); + suite.addTest(new ArgumentType_Prefix_CompletionTest("testCompletionProposals")); return suite; } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ClassReference_NoPrefix.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/ClassReference_NoPrefix_CompletionTest.java index 4940fd139f1..fa846e18dab 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ClassReference_NoPrefix.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/ClassReference_NoPrefix_CompletionTest.java @@ -24,7 +24,7 @@ import junit.framework.TestSuite; * https://bugs.eclipse.org/bugs/show_bug.cgi?id=50621 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=169860 */ -public class CompletionTest_ClassReference_NoPrefix extends CompletionProposalsBaseTest { +public class ClassReference_NoPrefix_CompletionTest extends CompletionProposalsBaseTest { private final String fileName = "CompletionTestStart21.h"; private final String fileFullPath = "resources/contentassist/" + fileName; private final String headerFileName = "CompletionTestStart.h"; @@ -32,13 +32,13 @@ public class CompletionTest_ClassReference_NoPrefix extends CompletionProposalsB private final String expectedPrefix = ""; private final String[] expectedResults = { "aClass", "anotherClass", "xOtherClass", "AStruct", "XStruct" }; - public CompletionTest_ClassReference_NoPrefix(String name) { + public ClassReference_NoPrefix_CompletionTest(String name) { super(name); } public static Test suite() { - TestSuite suite = new TestSuite(CompletionTest_ClassReference_NoPrefix.class.getName()); - suite.addTest(new CompletionTest_ClassReference_NoPrefix("testCompletionProposals")); + TestSuite suite = new TestSuite(ClassReference_NoPrefix_CompletionTest.class.getName()); + suite.addTest(new ClassReference_NoPrefix_CompletionTest("testCompletionProposals")); return suite; } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ClassReference_Prefix.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/ClassReference_Prefix_CompletionTest.java index 644dd7d8611..bc29d192e70 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ClassReference_Prefix.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/ClassReference_Prefix_CompletionTest.java @@ -24,7 +24,7 @@ import junit.framework.TestSuite; * https://bugs.eclipse.org/bugs/show_bug.cgi?id=50621 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=169860 */ -public class CompletionTest_ClassReference_Prefix extends CompletionProposalsBaseTest { +public class ClassReference_Prefix_CompletionTest extends CompletionProposalsBaseTest { private final String fileName = "CompletionTestStart20.h"; private final String fileFullPath = "resources/contentassist/" + fileName; private final String headerFileName = "CompletionTestStart.h"; @@ -32,13 +32,13 @@ public class CompletionTest_ClassReference_Prefix extends CompletionProposalsBas private final String expectedPrefix = "a"; private final String[] expectedResults = { "aClass", "anotherClass", "AStruct" }; - public CompletionTest_ClassReference_Prefix(String name) { + public ClassReference_Prefix_CompletionTest(String name) { super(name); } public static Test suite() { - TestSuite suite = new TestSuite(CompletionTest_ClassReference_Prefix.class.getName()); - suite.addTest(new CompletionTest_ClassReference_Prefix("testCompletionProposals")); + TestSuite suite = new TestSuite(ClassReference_Prefix_CompletionTest.class.getName()); + suite.addTest(new ClassReference_Prefix_CompletionTest("testCompletionProposals")); return suite; } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ConstructorReference.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/ConstructorReference_CompletionTest.java index c3bf4516360..a5417b0804e 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ConstructorReference.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/ConstructorReference_CompletionTest.java @@ -23,7 +23,7 @@ import junit.framework.TestSuite; * Bug# * */ -public class CompletionTest_ConstructorReference extends CompletionProposalsBaseTest { +public class ConstructorReference_CompletionTest extends CompletionProposalsBaseTest { private final String fileName = "CompletionTestStart35.cpp"; private final String fileFullPath = "resources/contentassist/" + fileName; @@ -34,15 +34,15 @@ public class CompletionTest_ConstructorReference extends CompletionProposalsBase // missing proposals: "xOtherClass(char*)", "xOtherClass(int)" }; - public CompletionTest_ConstructorReference(String name) { + public ConstructorReference_CompletionTest(String name) { super(name); // unknown failure setExpectFailure(77777); } public static Test suite() { - TestSuite suite = new TestSuite(CompletionTest_ConstructorReference.class.getName()); - suite.addTest(new CompletionTest_ConstructorReference("testCompletionProposals")); + TestSuite suite = new TestSuite(ConstructorReference_CompletionTest.class.getName()); + suite.addTest(new ConstructorReference_CompletionTest("testCompletionProposals")); return suite; } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/ContentAssist2TestSuite.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/ContentAssist2TestSuite.java index ec655b4140c..71f20875d4d 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/ContentAssist2TestSuite.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/ContentAssist2TestSuite.java @@ -26,33 +26,77 @@ import org.junit.runners.Suite; @RunWith(Suite.class) @Suite.SuiteClasses({ - CompletionTest_AnonymousTypes.class, CompletionTest_ArgumentType_Prefix.class, - CompletionTest_ArgumentType_Prefix2.class, CompletionTest_ClassReference_NoPrefix.class, - CompletionTest_ClassReference_Prefix.class, CompletionTest_ConstructorReference.class, - CompletionTest_ExceptionReference_NoPrefix.class, CompletionTest_ExceptionReference_Prefix.class, - CompletionTest_FieldType_NoPrefix.class, CompletionTest_FieldType_NoPrefix2.class, - CompletionTest_FieldType_Prefix.class, CompletionTest_FunctionReference_Prefix.class, - CompletionTest_MacroRef_NoPrefix.class, CompletionTest_MacroRef_Prefix.class, - CompletionTest_MemberReference_Arrow_NoPrefix.class, CompletionTest_MemberReference_Arrow_NoPrefix2.class, - CompletionTest_MemberReference_Arrow_NoPrefix3.class, CompletionTest_MemberReference_Arrow_Prefix.class, - CompletionTest_MemberReference_Arrow_Prefix2.class, CompletionTest_MemberReference_Dot_NoPrefix.class, - CompletionTest_MemberReference_Dot_Prefix.class, CompletionTest_NamespaceRef_NoPrefix.class, - CompletionTest_NamespaceRef_Prefix.class, CompletionTest_NewTypeReference_NoPrefix.class, - CompletionTest_NewTypeReference_Prefix.class, CompletionTest_ScopedReference_NonCodeScope.class, - CompletionTest_ScopedReference_NoPrefix.class, CompletionTest_ScopedReference_Prefix.class, - CompletionTest_SingleName_Method_NoPrefix.class, CompletionTest_SingleName_Method_Prefix.class, - CompletionTest_SingleName_NoPrefix.class, CompletionTest_SingleName_Prefix.class, - CompletionTest_SingleName_Prefix2.class, CompletionTest_TypeDef_NoPrefix.class, - CompletionTest_TypeDef_Prefix.class, CompletionTest_TypeRef_NoPrefix.class, CompletionTest_TypeRef_Prefix.class, - CompletionTest_VariableType_NestedPrefix.class, CompletionTest_VariableType_NoPrefix.class, - CompletionTest_VariableType_Prefix.class, - - CompletionTests.class, HelpProposalTests.class, CompletionTests_PlainC.class, ParameterHintTests.class, - CPPParameterGuessingTests.class, CParameterGuessingTests.class, - - ShowCamelCasePreferenceTest.class, - - TemplateProposalTest.class, + AnonymousTypes_CompletionTest.class, // + ArgumentType_Prefix_CompletionTest.class, // + + ArgumentType_Prefix2_CompletionTest.class, // + ClassReference_NoPrefix_CompletionTest.class, // + + ClassReference_Prefix_CompletionTest.class, // + ConstructorReference_CompletionTest.class, // + + ExceptionReference_NoPrefix_CompletionTest.class, // + ExceptionReference_Prefix_CompletionTest.class, // + + FieldType_NoPrefix_CompletionTest.class, // + FieldType_NoPrefix2_CompletionTest.class, // + + FieldType_Prefix_CompletionTest.class, // + FunctionReference_Prefix_CompletionTest.class, // + + MacroRef_NoPrefix_CompletionTest.class, // + MacroRef_Prefix_CompletionTest.class, // + + MemberReference_Arrow_NoPrefix_CompletionTest.class, // + MemberReference_Arrow_NoPrefix2_CompletionTest.class, // + + MemberReference_Arrow_NoPrefix3_CompletionTest.class, // + MemberReference_Arrow_Prefix_CompletionTest.class, // + + MemberReference_Arrow_Prefix2_CompletionTest.class, // + MemberReference_Dot_NoPrefix_CompletionTest.class, // + + MemberReference_Dot_Prefix_CompletionTest.class, // + NamespaceRef_NoPrefix_CompletionTest.class, // + + NamespaceRef_Prefix_CompletionTest.class, // + NewTypeReference_NoPrefix_CompletionTest.class, // + + NewTypeReference_Prefix_CompletionTest.class, // + ScopedReference_NonCodeScope_CompletionTest.class, // + + ScopedReference_NoPrefix_CompletionTest.class, // + ScopedReference_Prefix_CompletionTest.class, // + + SingleName_Method_NoPrefix_CompletionTest.class, // + SingleName_Method_Prefix_CompletionTest.class, // + + SingleName_NoPrefix_CompletionTest.class, // + SingleName_Prefix_CompletionTest.class, // + + SingleName_Prefix2_CompletionTest.class, // + TypeDef_NoPrefix_CompletionTest.class, // + + TypeDef_Prefix_CompletionTest.class, // + TypeRef_NoPrefix_CompletionTest.class, // + TypeRef_Prefix_CompletionTest.class, // + + VariableType_NestedPrefix_CompletionTest.class, // + VariableType_NoPrefix_CompletionTest.class, // + + VariableType_Prefix_CompletionTest.class, // + + CompletionTests.class, // + HelpProposalTests.class, // + PlainC_CompletionTests.class, // + ParameterHintTests.class, // + + CPPParameterGuessingTests.class, // + CParameterGuessingTests.class, // + + ShowCamelCasePreferenceTest.class, // + + TemplateProposalTest.class, // }) public class ContentAssist2TestSuite { diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ExceptionReference_NoPrefix.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/ExceptionReference_NoPrefix_CompletionTest.java index 4d6375a45ab..abedb4a9271 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ExceptionReference_NoPrefix.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/ExceptionReference_NoPrefix_CompletionTest.java @@ -24,7 +24,7 @@ import junit.framework.TestSuite; * Bug#50640 : Wrong completion kind when expecting an exception * */ -public class CompletionTest_ExceptionReference_NoPrefix extends CompletionProposalsBaseTest { +public class ExceptionReference_NoPrefix_CompletionTest extends CompletionProposalsBaseTest { private final String fileName = "CompletionTestStart23.cpp"; private final String fileFullPath = "resources/contentassist/" + fileName; @@ -34,14 +34,14 @@ public class CompletionTest_ExceptionReference_NoPrefix extends CompletionPropos private final String[] expectedResults = { "AStruct", "XStruct", "aClass", "aNamespace", "anEnumeration", "anotherClass", "xEnumeration", "xNamespace", "xOtherClass" }; - public CompletionTest_ExceptionReference_NoPrefix(String name) { + public ExceptionReference_NoPrefix_CompletionTest(String name) { super(name); // https://bugs.eclipse.org/bugs/show_bug.cgi?id=169860 } public static Test suite() { - TestSuite suite = new TestSuite(CompletionTest_ExceptionReference_NoPrefix.class.getName()); - suite.addTest(new CompletionTest_ExceptionReference_NoPrefix("testCompletionProposals")); + TestSuite suite = new TestSuite(ExceptionReference_NoPrefix_CompletionTest.class.getName()); + suite.addTest(new ExceptionReference_NoPrefix_CompletionTest("testCompletionProposals")); return suite; } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ExceptionReference_Prefix.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/ExceptionReference_Prefix_CompletionTest.java index 4da2de2c6bc..8f3b06c7ef2 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ExceptionReference_Prefix.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/ExceptionReference_Prefix_CompletionTest.java @@ -23,7 +23,7 @@ import junit.framework.TestSuite; * Bug#50640 : Wrong completion kind when expecting an exception * */ -public class CompletionTest_ExceptionReference_Prefix extends CompletionProposalsBaseTest { +public class ExceptionReference_Prefix_CompletionTest extends CompletionProposalsBaseTest { private final String fileName = "CompletionTestStart22.cpp"; private final String fileFullPath = "resources/contentassist/" + fileName; @@ -33,15 +33,15 @@ public class CompletionTest_ExceptionReference_Prefix extends CompletionProposal private final String[] expectedResults = { "aClass", "anotherClass", "aNamespace", "anEnumeration", "AStruct", "AMacro(x)" }; - public CompletionTest_ExceptionReference_Prefix(String name) { + public ExceptionReference_Prefix_CompletionTest(String name) { super(name); // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=109724 // setExpectFailure(109724); } public static Test suite() { - TestSuite suite = new TestSuite(CompletionTest_ExceptionReference_Prefix.class.getName()); - suite.addTest(new CompletionTest_ExceptionReference_Prefix("testCompletionProposals")); + TestSuite suite = new TestSuite(ExceptionReference_Prefix_CompletionTest.class.getName()); + suite.addTest(new ExceptionReference_Prefix_CompletionTest("testCompletionProposals")); return suite; } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_FieldType_NoPrefix2.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/FieldType_NoPrefix2_CompletionTest.java index fac9b47c408..ce800dbfd0e 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_FieldType_NoPrefix2.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/FieldType_NoPrefix2_CompletionTest.java @@ -24,7 +24,7 @@ import junit.framework.TestSuite; * Bug#50344 :Wrong completion in Class scope if before the first declaration * */ -public class CompletionTest_FieldType_NoPrefix2 extends CompletionProposalsBaseTest { +public class FieldType_NoPrefix2_CompletionTest extends CompletionProposalsBaseTest { private final String fileName = "CompletionTestStart13.h"; private final String fileFullPath = "resources/contentassist/" + fileName; @@ -34,14 +34,14 @@ public class CompletionTest_FieldType_NoPrefix2 extends CompletionProposalsBaseT private final String[] expectedResults = { "AStruct", "XStruct", "aClass", "aNamespace", "aThirdClass", "anEnumeration", "anotherClass", "xEnumeration", "xNamespace", "xOtherClass" }; - public CompletionTest_FieldType_NoPrefix2(String name) { + public FieldType_NoPrefix2_CompletionTest(String name) { super(name); // https://bugs.eclipse.org/bugs/show_bug.cgi?id=169860 } public static Test suite() { - TestSuite suite = new TestSuite(CompletionTest_FieldType_NoPrefix2.class.getName()); - suite.addTest(new CompletionTest_FieldType_NoPrefix2("testCompletionProposals")); + TestSuite suite = new TestSuite(FieldType_NoPrefix2_CompletionTest.class.getName()); + suite.addTest(new FieldType_NoPrefix2_CompletionTest("testCompletionProposals")); return suite; } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_FieldType_NoPrefix.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/FieldType_NoPrefix_CompletionTest.java index 44d087f8dc8..a81766c74d9 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_FieldType_NoPrefix.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/FieldType_NoPrefix_CompletionTest.java @@ -23,7 +23,7 @@ import junit.framework.TestSuite; * Testing Field_Type, with NO prefix * */ -public class CompletionTest_FieldType_NoPrefix extends CompletionProposalsBaseTest { +public class FieldType_NoPrefix_CompletionTest extends CompletionProposalsBaseTest { private final String fileName = "CompletionTestStart12.h"; private final String fileFullPath = "resources/contentassist/" + fileName; private final String headerFileName = "CompletionTestStart.h"; @@ -32,14 +32,14 @@ public class CompletionTest_FieldType_NoPrefix extends CompletionProposalsBaseTe private final String[] expectedResults = { "AStruct", "XStruct", "aClass", "aNamespace", "aThirdClass", "anEnumeration", "anotherClass", "xEnumeration", "xNamespace", "xOtherClass" }; - public CompletionTest_FieldType_NoPrefix(String name) { + public FieldType_NoPrefix_CompletionTest(String name) { super(name); // https://bugs.eclipse.org/bugs/show_bug.cgi?id=169860 } public static Test suite() { - TestSuite suite = new TestSuite(CompletionTest_FieldType_NoPrefix.class.getName()); - suite.addTest(new CompletionTest_FieldType_NoPrefix("testCompletionProposals")); + TestSuite suite = new TestSuite(FieldType_NoPrefix_CompletionTest.class.getName()); + suite.addTest(new FieldType_NoPrefix_CompletionTest("testCompletionProposals")); return suite; } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_FieldType_Prefix.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/FieldType_Prefix_CompletionTest.java index a3e427ba813..f215c198c4f 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_FieldType_Prefix.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/FieldType_Prefix_CompletionTest.java @@ -22,7 +22,7 @@ import junit.framework.TestSuite; * Testing Field_Type completion kind , with a prefix * */ -public class CompletionTest_FieldType_Prefix extends CompletionProposalsBaseTest { +public class FieldType_Prefix_CompletionTest extends CompletionProposalsBaseTest { private final String fileName = "CompletionTestStart4.h"; private final String fileFullPath = "resources/contentassist/" + fileName; private final String headerFileName = "CompletionTestStart.h"; @@ -31,15 +31,15 @@ public class CompletionTest_FieldType_Prefix extends CompletionProposalsBaseTest private final String[] expectedResults = { "aClass", "anotherClass", "aThirdClass", "aNamespace", "anEnumeration", "AStruct", "AMacro(x)" }; - public CompletionTest_FieldType_Prefix(String name) { + public FieldType_Prefix_CompletionTest(String name) { super(name); // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=109724 // setExpectFailure(109724); } public static Test suite() { - TestSuite suite = new TestSuite(CompletionTest_FieldType_Prefix.class.getName()); - suite.addTest(new CompletionTest_FieldType_Prefix("testCompletionProposals")); + TestSuite suite = new TestSuite(FieldType_Prefix_CompletionTest.class.getName()); + suite.addTest(new FieldType_Prefix_CompletionTest("testCompletionProposals")); return suite; } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_FunctionReference_Prefix.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/FunctionReference_Prefix_CompletionTest.java index 052e02a4b68..7468f5bd5c1 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_FunctionReference_Prefix.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/FunctionReference_Prefix_CompletionTest.java @@ -23,7 +23,7 @@ import junit.framework.TestSuite; * Bug# * */ -public class CompletionTest_FunctionReference_Prefix extends CompletionProposalsBaseTest { +public class FunctionReference_Prefix_CompletionTest extends CompletionProposalsBaseTest { private final String fileName = "CompletionTestStart36.cpp"; private final String fileFullPath = "resources/contentassist/" + fileName; private final String headerFileName = "CompletionTestStart.h"; @@ -33,15 +33,15 @@ public class CompletionTest_FunctionReference_Prefix extends CompletionProposals "xAClassMethod(int x) : void", "xFunction(void) : bool", "xOtherFunction(void) : void", "xNamespace", "xOtherClass", "xFirstEnum", "xSecondEnum", "xThirdEnum", "xEnumeration", "XMacro(x, y)", "XStruct" }; - public CompletionTest_FunctionReference_Prefix(String name) { + public FunctionReference_Prefix_CompletionTest(String name) { super(name); // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=109724 //setExpectFailure(109724); } public static Test suite() { - TestSuite suite = new TestSuite(CompletionTest_FunctionReference_Prefix.class.getName()); - suite.addTest(new CompletionTest_FunctionReference_Prefix("testCompletionProposals")); + TestSuite suite = new TestSuite(FunctionReference_Prefix_CompletionTest.class.getName()); + suite.addTest(new FunctionReference_Prefix_CompletionTest("testCompletionProposals")); return suite; } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_MacroRef_NoPrefix.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/MacroRef_NoPrefix_CompletionTest.java index 9074534d853..dbfacb38ef6 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_MacroRef_NoPrefix.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/MacroRef_NoPrefix_CompletionTest.java @@ -23,7 +23,7 @@ import junit.framework.TestSuite; * Bug#50487 :Wrong completion kind and prefix after "#ifdef" * */ -public class CompletionTest_MacroRef_NoPrefix extends CompletionProposalsBaseTest { +public class MacroRef_NoPrefix_CompletionTest extends CompletionProposalsBaseTest { private final String fileName = "CompletionTestStart26.cpp"; private final String fileFullPath = "resources/contentassist/" + fileName; @@ -33,15 +33,16 @@ public class CompletionTest_MacroRef_NoPrefix extends CompletionProposalsBaseTes private final String[] expectedResults = { "AMacro(x)", "DEBUG", "XMacro(x, y)", "__CDT_PARSER__", "__COUNTER__", "__DATE__", "__FILE__", "__LINE__", "__STDC__", "__TIME__", "__builtin_va_arg(ap, type)", "__builtin_offsetof(T, m)", "__builtin_types_compatible_p(x, y)", "__complex__", "__cplusplus", - "__extension__", "__imag__", "__null", "__offsetof__(x)", "__real__", "__stdcall", "__thread", }; + "__extension__", "__has_include", "__has_include_next", "__imag__", "__null", "__offsetof__(x)", "__real__", + "__stdcall", "__thread", }; - public CompletionTest_MacroRef_NoPrefix(String name) { + public MacroRef_NoPrefix_CompletionTest(String name) { super(name); } public static Test suite() { - TestSuite suite = new TestSuite(CompletionTest_MacroRef_NoPrefix.class.getName()); - suite.addTest(new CompletionTest_MacroRef_NoPrefix("testCompletionProposals")); + TestSuite suite = new TestSuite(MacroRef_NoPrefix_CompletionTest.class.getName()); + suite.addTest(new MacroRef_NoPrefix_CompletionTest("testCompletionProposals")); return suite; } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_MacroRef_Prefix.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/MacroRef_Prefix_CompletionTest.java index ebee868217c..bef8ab0f53b 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_MacroRef_Prefix.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/MacroRef_Prefix_CompletionTest.java @@ -23,7 +23,7 @@ import junit.framework.TestSuite; * Bug#50487 :Wrong completion kind and prefix after "#ifdef" * */ -public class CompletionTest_MacroRef_Prefix extends CompletionProposalsBaseTest { +public class MacroRef_Prefix_CompletionTest extends CompletionProposalsBaseTest { private final String fileName = "CompletionTestStart27.cpp"; private final String fileFullPath = "resources/contentassist/" + fileName; @@ -32,13 +32,13 @@ public class CompletionTest_MacroRef_Prefix extends CompletionProposalsBaseTest private final String expectedPrefix = "D"; private final String[] expectedResults = { "DEBUG" }; - public CompletionTest_MacroRef_Prefix(String name) { + public MacroRef_Prefix_CompletionTest(String name) { super(name); } public static Test suite() { - TestSuite suite = new TestSuite(CompletionTest_MacroRef_Prefix.class.getName()); - suite.addTest(new CompletionTest_MacroRef_Prefix("testCompletionProposals")); + TestSuite suite = new TestSuite(MacroRef_Prefix_CompletionTest.class.getName()); + suite.addTest(new MacroRef_Prefix_CompletionTest("testCompletionProposals")); return suite; } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_MemberReference_Arrow_NoPrefix2.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/MemberReference_Arrow_NoPrefix2_CompletionTest.java index e945e423df6..462a7e34f9d 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_MemberReference_Arrow_NoPrefix2.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/MemberReference_Arrow_NoPrefix2_CompletionTest.java @@ -19,7 +19,7 @@ import junit.framework.TestSuite; /** * Test operator is followed during member reference */ -public class CompletionTest_MemberReference_Arrow_NoPrefix2 extends CompletionProposalsBaseTest { +public class MemberReference_Arrow_NoPrefix2_CompletionTest extends CompletionProposalsBaseTest { private final String fileName = "CompletionTestStart41.cpp"; private final String fileFullPath = "resources/contentassist/" + fileName; private final String headerFileName = "CompletionTestStart41.h"; @@ -27,13 +27,13 @@ public class CompletionTest_MemberReference_Arrow_NoPrefix2 extends CompletionPr private final String expectedPrefix = ""; private final String[] expectedResults = { "A", "foo(void) : void", "operator ->(void) : B *" }; - public CompletionTest_MemberReference_Arrow_NoPrefix2(String name) { + public MemberReference_Arrow_NoPrefix2_CompletionTest(String name) { super(name); } public static Test suite() { - TestSuite suite = new TestSuite(CompletionTest_MemberReference_Arrow_NoPrefix2.class.getName()); - suite.addTest(new CompletionTest_MemberReference_Arrow_NoPrefix2("testCompletionProposals")); + TestSuite suite = new TestSuite(MemberReference_Arrow_NoPrefix2_CompletionTest.class.getName()); + suite.addTest(new MemberReference_Arrow_NoPrefix2_CompletionTest("testCompletionProposals")); return suite; } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_MemberReference_Arrow_NoPrefix3.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/MemberReference_Arrow_NoPrefix3_CompletionTest.java index e765efb2aa4..f354e6c5c88 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_MemberReference_Arrow_NoPrefix3.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/MemberReference_Arrow_NoPrefix3_CompletionTest.java @@ -19,7 +19,7 @@ import junit.framework.TestSuite; /** * Testing operator is not followed on pointer to class with overloaded operator -> */ -public class CompletionTest_MemberReference_Arrow_NoPrefix3 extends CompletionProposalsBaseTest { +public class MemberReference_Arrow_NoPrefix3_CompletionTest extends CompletionProposalsBaseTest { private final String fileName = "CompletionTestStart42.cpp"; private final String fileFullPath = "resources/contentassist/" + fileName; private final String headerFileName = "CompletionTestStart41.h"; @@ -27,13 +27,13 @@ public class CompletionTest_MemberReference_Arrow_NoPrefix3 extends CompletionPr private final String expectedPrefix = ""; private final String[] expectedResults = { "B", "bar(void) : void" }; - public CompletionTest_MemberReference_Arrow_NoPrefix3(String name) { + public MemberReference_Arrow_NoPrefix3_CompletionTest(String name) { super(name); } public static Test suite() { - TestSuite suite = new TestSuite(CompletionTest_MemberReference_Arrow_NoPrefix3.class.getName()); - suite.addTest(new CompletionTest_MemberReference_Arrow_NoPrefix3("testCompletionProposals")); + TestSuite suite = new TestSuite(MemberReference_Arrow_NoPrefix3_CompletionTest.class.getName()); + suite.addTest(new MemberReference_Arrow_NoPrefix3_CompletionTest("testCompletionProposals")); return suite; } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_MemberReference_Arrow_NoPrefix.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/MemberReference_Arrow_NoPrefix_CompletionTest.java index 8260b99e90b..eec1ac2b2fa 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_MemberReference_Arrow_NoPrefix.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/MemberReference_Arrow_NoPrefix_CompletionTest.java @@ -24,7 +24,7 @@ import junit.framework.TestSuite; * */ -public class CompletionTest_MemberReference_Arrow_NoPrefix extends CompletionProposalsBaseTest { +public class MemberReference_Arrow_NoPrefix_CompletionTest extends CompletionProposalsBaseTest { private final String fileName = "CompletionTestStart10.cpp"; private final String fileFullPath = "resources/contentassist/" + fileName; private final String headerFileName = "CompletionTestStart.h"; @@ -34,13 +34,13 @@ public class CompletionTest_MemberReference_Arrow_NoPrefix extends CompletionPro "xAClassMethod(int x) : void", "aClass" // aClass is valid }; - public CompletionTest_MemberReference_Arrow_NoPrefix(String name) { + public MemberReference_Arrow_NoPrefix_CompletionTest(String name) { super(name); } public static Test suite() { - TestSuite suite = new TestSuite(CompletionTest_MemberReference_Arrow_NoPrefix.class.getName()); - suite.addTest(new CompletionTest_MemberReference_Arrow_NoPrefix("testCompletionProposals")); + TestSuite suite = new TestSuite(MemberReference_Arrow_NoPrefix_CompletionTest.class.getName()); + suite.addTest(new MemberReference_Arrow_NoPrefix_CompletionTest("testCompletionProposals")); return suite; } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_MemberReference_Arrow_Prefix2.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/MemberReference_Arrow_Prefix2_CompletionTest.java index dd93aa5c490..40dd4315e9a 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_MemberReference_Arrow_Prefix2.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/MemberReference_Arrow_Prefix2_CompletionTest.java @@ -23,7 +23,7 @@ import junit.framework.TestSuite; * Complex Context: Function return value: foo()->a(CTRL+SPACE) * */ -public class CompletionTest_MemberReference_Arrow_Prefix2 extends CompletionProposalsBaseTest { +public class MemberReference_Arrow_Prefix2_CompletionTest extends CompletionProposalsBaseTest { private final String fileName = "CompletionTestStart7.cpp"; private final String fileFullPath = "resources/contentassist/" + fileName; private final String headerFileName = "CompletionTestStart.h"; @@ -32,13 +32,13 @@ public class CompletionTest_MemberReference_Arrow_Prefix2 extends CompletionProp private final String[] expectedResults = { "aClass", // aClass is valid "aField : int", "aMethod(void) : int" }; - public CompletionTest_MemberReference_Arrow_Prefix2(String name) { + public MemberReference_Arrow_Prefix2_CompletionTest(String name) { super(name); } public static Test suite() { - TestSuite suite = new TestSuite(CompletionTest_MemberReference_Arrow_Prefix2.class.getName()); - suite.addTest(new CompletionTest_MemberReference_Arrow_Prefix2("testCompletionProposals")); + TestSuite suite = new TestSuite(MemberReference_Arrow_Prefix2_CompletionTest.class.getName()); + suite.addTest(new MemberReference_Arrow_Prefix2_CompletionTest("testCompletionProposals")); return suite; } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_MemberReference_Arrow_Prefix.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/MemberReference_Arrow_Prefix_CompletionTest.java index 132717f23cd..5acd64dd3f7 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_MemberReference_Arrow_Prefix.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/MemberReference_Arrow_Prefix_CompletionTest.java @@ -23,7 +23,7 @@ import junit.framework.TestSuite; * After an -> * */ -public class CompletionTest_MemberReference_Arrow_Prefix extends CompletionProposalsBaseTest { +public class MemberReference_Arrow_Prefix_CompletionTest extends CompletionProposalsBaseTest { private final String fileName = "CompletionTestStart6.cpp"; private final String fileFullPath = "resources/contentassist/" + fileName; private final String headerFileName = "CompletionTestStart.h"; @@ -32,13 +32,13 @@ public class CompletionTest_MemberReference_Arrow_Prefix extends CompletionPropo private final String[] expectedResults = { "aField : int", "aMethod(void) : int", "aClass" // aClass is valid }; - public CompletionTest_MemberReference_Arrow_Prefix(String name) { + public MemberReference_Arrow_Prefix_CompletionTest(String name) { super(name); } public static Test suite() { - TestSuite suite = new TestSuite(CompletionTest_MemberReference_Arrow_Prefix.class.getName()); - suite.addTest(new CompletionTest_MemberReference_Arrow_Prefix("testCompletionProposals")); + TestSuite suite = new TestSuite(MemberReference_Arrow_Prefix_CompletionTest.class.getName()); + suite.addTest(new MemberReference_Arrow_Prefix_CompletionTest("testCompletionProposals")); return suite; } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_MemberReference_Dot_NoPrefix.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/MemberReference_Dot_NoPrefix_CompletionTest.java index 83b6f4ddc31..057907a2a7d 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_MemberReference_Dot_NoPrefix.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/MemberReference_Dot_NoPrefix_CompletionTest.java @@ -23,7 +23,7 @@ import junit.framework.TestSuite; * After a . * */ -public class CompletionTest_MemberReference_Dot_NoPrefix extends CompletionProposalsBaseTest { +public class MemberReference_Dot_NoPrefix_CompletionTest extends CompletionProposalsBaseTest { private final String fileName = "CompletionTestStart9.cpp"; private final String fileFullPath = "resources/contentassist/" + fileName; private final String headerFileName = "CompletionTestStart.h"; @@ -33,13 +33,13 @@ public class CompletionTest_MemberReference_Dot_NoPrefix extends CompletionPropo "xAClassMethod(int x) : void", "aClass" // aClass is valid }; - public CompletionTest_MemberReference_Dot_NoPrefix(String name) { + public MemberReference_Dot_NoPrefix_CompletionTest(String name) { super(name); } public static Test suite() { - TestSuite suite = new TestSuite(CompletionTest_MemberReference_Dot_NoPrefix.class.getName()); - suite.addTest(new CompletionTest_MemberReference_Dot_NoPrefix("testCompletionProposals")); + TestSuite suite = new TestSuite(MemberReference_Dot_NoPrefix_CompletionTest.class.getName()); + suite.addTest(new MemberReference_Dot_NoPrefix_CompletionTest("testCompletionProposals")); return suite; } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_MemberReference_Dot_Prefix.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/MemberReference_Dot_Prefix_CompletionTest.java index 061d0be3f6a..fa91ebda70c 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_MemberReference_Dot_Prefix.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/MemberReference_Dot_Prefix_CompletionTest.java @@ -23,7 +23,7 @@ import junit.framework.TestSuite; * After a . * */ -public class CompletionTest_MemberReference_Dot_Prefix extends CompletionProposalsBaseTest { +public class MemberReference_Dot_Prefix_CompletionTest extends CompletionProposalsBaseTest { private final String fileName = "CompletionTestStart2.cpp"; private final String fileFullPath = "resources/contentassist/" + fileName; private final String headerFileName = "CompletionTestStart.h"; @@ -32,13 +32,13 @@ public class CompletionTest_MemberReference_Dot_Prefix extends CompletionProposa private final String[] expectedResults = { "aField : int", "aMethod(void) : int", "aClass" // aClass is valid }; - public CompletionTest_MemberReference_Dot_Prefix(String name) { + public MemberReference_Dot_Prefix_CompletionTest(String name) { super(name); } public static Test suite() { - TestSuite suite = new TestSuite(CompletionTest_MemberReference_Dot_Prefix.class.getName()); - suite.addTest(new CompletionTest_MemberReference_Dot_Prefix("testCompletionProposals")); + TestSuite suite = new TestSuite(MemberReference_Dot_Prefix_CompletionTest.class.getName()); + suite.addTest(new MemberReference_Dot_Prefix_CompletionTest("testCompletionProposals")); return suite; } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_NamespaceRef_NoPrefix.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/NamespaceRef_NoPrefix_CompletionTest.java index f113a72f7b6..f1b4d3e835f 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_NamespaceRef_NoPrefix.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/NamespaceRef_NoPrefix_CompletionTest.java @@ -23,7 +23,7 @@ import junit.framework.TestSuite; * Testing Namespace_Reference, with no prefix * Bug#50471 : Wrong completion kind after the "using" keyword */ -public class CompletionTest_NamespaceRef_NoPrefix extends CompletionProposalsBaseTest { +public class NamespaceRef_NoPrefix_CompletionTest extends CompletionProposalsBaseTest { private final String fileName = "CompletionTestStart32.cpp"; private final String fileFullPath = "resources/contentassist/" + fileName; private final String headerFileName = "CompletionTestStart.h"; @@ -31,14 +31,14 @@ public class CompletionTest_NamespaceRef_NoPrefix extends CompletionProposalsBas private final String expectedPrefix = ""; private final String[] expectedResults = { "aNamespace", "xNamespace" }; - public CompletionTest_NamespaceRef_NoPrefix(String name) { + public NamespaceRef_NoPrefix_CompletionTest(String name) { super(name); // https://bugs.eclipse.org/bugs/show_bug.cgi?id=169860 } public static Test suite() { - TestSuite suite = new TestSuite(CompletionTest_NamespaceRef_NoPrefix.class.getName()); - suite.addTest(new CompletionTest_NamespaceRef_NoPrefix("testCompletionProposals")); + TestSuite suite = new TestSuite(NamespaceRef_NoPrefix_CompletionTest.class.getName()); + suite.addTest(new NamespaceRef_NoPrefix_CompletionTest("testCompletionProposals")); return suite; } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_NamespaceRef_Prefix.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/NamespaceRef_Prefix_CompletionTest.java index bb256a7a19c..64873e61241 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_NamespaceRef_Prefix.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/NamespaceRef_Prefix_CompletionTest.java @@ -24,7 +24,7 @@ import junit.framework.TestSuite; * Bug#50471 : Wrong completion kind after the "using" keyword * */ -public class CompletionTest_NamespaceRef_Prefix extends CompletionProposalsBaseTest { +public class NamespaceRef_Prefix_CompletionTest extends CompletionProposalsBaseTest { private final String fileName = "CompletionTestStart33.cpp"; private final String fileFullPath = "resources/contentassist/" + fileName; @@ -33,14 +33,14 @@ public class CompletionTest_NamespaceRef_Prefix extends CompletionProposalsBaseT private final String expectedPrefix = "a"; private final String[] expectedResults = { "aNamespace" }; - public CompletionTest_NamespaceRef_Prefix(String name) { + public NamespaceRef_Prefix_CompletionTest(String name) { super(name); // https://bugs.eclipse.org/bugs/show_bug.cgi?id=169860 } public static Test suite() { - TestSuite suite = new TestSuite(CompletionTest_NamespaceRef_Prefix.class.getName()); - suite.addTest(new CompletionTest_NamespaceRef_Prefix("testCompletionProposals")); + TestSuite suite = new TestSuite(NamespaceRef_Prefix_CompletionTest.class.getName()); + suite.addTest(new NamespaceRef_Prefix_CompletionTest("testCompletionProposals")); return suite; } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_NewTypeReference_NoPrefix.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/NewTypeReference_NoPrefix_CompletionTest.java index 053a00c7221..14c5af268f0 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_NewTypeReference_NoPrefix.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/NewTypeReference_NoPrefix_CompletionTest.java @@ -23,7 +23,7 @@ import junit.framework.TestSuite; * Bug#50711 : Wrong completion kind in a new expression * */ -public class CompletionTest_NewTypeReference_NoPrefix extends CompletionProposalsBaseTest { +public class NewTypeReference_NoPrefix_CompletionTest extends CompletionProposalsBaseTest { private final String fileName = "CompletionTestStart29.cpp"; private final String fileFullPath = "resources/contentassist/" + fileName; @@ -35,13 +35,13 @@ public class CompletionTest_NewTypeReference_NoPrefix extends CompletionProposal // enums may not be desired, but valid "anEnumeration", "xEnumeration" }; - public CompletionTest_NewTypeReference_NoPrefix(String name) { + public NewTypeReference_NoPrefix_CompletionTest(String name) { super(name); } public static Test suite() { - TestSuite suite = new TestSuite(CompletionTest_NewTypeReference_NoPrefix.class.getName()); - suite.addTest(new CompletionTest_NewTypeReference_NoPrefix("testCompletionProposals")); + TestSuite suite = new TestSuite(NewTypeReference_NoPrefix_CompletionTest.class.getName()); + suite.addTest(new NewTypeReference_NoPrefix_CompletionTest("testCompletionProposals")); return suite; } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_NewTypeReference_Prefix.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/NewTypeReference_Prefix_CompletionTest.java index 992f9cffff5..24c1d2748e7 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_NewTypeReference_Prefix.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/NewTypeReference_Prefix_CompletionTest.java @@ -23,7 +23,7 @@ import junit.framework.TestSuite; * Bug#50711 : Wrong completion kind in a new expression * */ -public class CompletionTest_NewTypeReference_Prefix extends CompletionProposalsBaseTest { +public class NewTypeReference_Prefix_CompletionTest extends CompletionProposalsBaseTest { private final String fileName = "CompletionTestStart28.cpp"; private final String fileFullPath = "resources/contentassist/" + fileName; @@ -33,13 +33,13 @@ public class CompletionTest_NewTypeReference_Prefix extends CompletionProposalsB private final String[] expectedResults = { "aClass", "anotherClass", "aNamespace", "AStruct", "anEnumeration", "AMacro(x)" }; - public CompletionTest_NewTypeReference_Prefix(String name) { + public NewTypeReference_Prefix_CompletionTest(String name) { super(name); } public static Test suite() { - TestSuite suite = new TestSuite(CompletionTest_NewTypeReference_Prefix.class.getName()); - suite.addTest(new CompletionTest_NewTypeReference_Prefix("testCompletionProposals")); + TestSuite suite = new TestSuite(NewTypeReference_Prefix_CompletionTest.class.getName()); + suite.addTest(new NewTypeReference_Prefix_CompletionTest("testCompletionProposals")); return suite; } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTests_PlainC.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/PlainC_CompletionTests.java index 9150aee571c..2a9f61a5d5e 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTests_PlainC.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/PlainC_CompletionTests.java @@ -29,7 +29,7 @@ import junit.framework.Test; * * @since 4.0 */ -public class CompletionTests_PlainC extends AbstractContentAssistTest { +public class PlainC_CompletionTests extends AbstractContentAssistTest { private static final String HEADER_FILE_NAME = "CompletionTest.h"; private static final String SOURCE_FILE_NAME = "CompletionTest.c"; @@ -156,13 +156,13 @@ public class CompletionTests_PlainC extends AbstractContentAssistTest { // } gStruct; public static Test suite() { - return BaseTestCase.suite(CompletionTests_PlainC.class, "_"); + return BaseTestCase.suite(PlainC_CompletionTests.class, "_"); } /** * @param name */ - public CompletionTests_PlainC(String name) { + public PlainC_CompletionTests(String name) { super(name, false); } @@ -343,8 +343,8 @@ public class CompletionTests_PlainC extends AbstractContentAssistTest { final String[] expected = { "AMacro(x)", "DEBUG", "XMacro(x, y)", "__CDT_PARSER__", "__COUNTER__", "__DATE__", "__FILE__", "__LINE__", "__STDC_HOSTED__", "__STDC_VERSION__", "__STDC__", "__TIME__", "__builtin_va_arg(ap, type)", "__builtin_offsetof(T, m)", "__builtin_types_compatible_p(x, y)", - "__complex__", "__extension__", "__imag__", "__null", "__offsetof__(x)", "__real__", "__stdcall", - "__thread", }; + "__complex__", "__extension__", "__has_include", "__has_include_next", "__imag__", "__null", + "__offsetof__(x)", "__real__", "__stdcall", "__thread", }; assertCompletionResults(expected); } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ScopedReference_NoPrefix.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/ScopedReference_NoPrefix_CompletionTest.java index 81fc90f3d3e..c9d1982b383 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ScopedReference_NoPrefix.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/ScopedReference_NoPrefix_CompletionTest.java @@ -23,7 +23,7 @@ import junit.framework.TestSuite; * Bug#50152: Wrong context sent after a "::" * */ -public class CompletionTest_ScopedReference_NoPrefix extends CompletionProposalsBaseTest { +public class ScopedReference_NoPrefix_CompletionTest extends CompletionProposalsBaseTest { private final String fileName = "CompletionTestStart30.cpp"; private final String fileFullPath = "resources/contentassist/" + fileName; @@ -32,13 +32,13 @@ public class CompletionTest_ScopedReference_NoPrefix extends CompletionProposals private final String expectedPrefix = ""; private final String[] expectedResults = { "aNamespaceFunction(void) : void" }; - public CompletionTest_ScopedReference_NoPrefix(String name) { + public ScopedReference_NoPrefix_CompletionTest(String name) { super(name); } public static Test suite() { - TestSuite suite = new TestSuite(CompletionTest_ScopedReference_NoPrefix.class.getName()); - suite.addTest(new CompletionTest_ScopedReference_NoPrefix("testCompletionProposals")); + TestSuite suite = new TestSuite(ScopedReference_NoPrefix_CompletionTest.class.getName()); + suite.addTest(new ScopedReference_NoPrefix_CompletionTest("testCompletionProposals")); return suite; } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ScopedReference_NonCodeScope.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/ScopedReference_NonCodeScope_CompletionTest.java index a1b05c08af3..9b8a3c20367 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ScopedReference_NonCodeScope.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/ScopedReference_NonCodeScope_CompletionTest.java @@ -23,7 +23,7 @@ import junit.framework.TestSuite; * Bug#50152: Wrong context sent after a "::" * */ -public class CompletionTest_ScopedReference_NonCodeScope extends CompletionProposalsBaseTest { +public class ScopedReference_NonCodeScope_CompletionTest extends CompletionProposalsBaseTest { private final String fileName = "CompletionTestStart39.cpp"; private final String fileFullPath = "resources/contentassist/" + fileName; @@ -32,13 +32,13 @@ public class CompletionTest_ScopedReference_NonCodeScope extends CompletionPropo private final String expectedPrefix = ""; private final String[] expectedResults = { "Foo(void)", "bar(void) : void", "fum(void) : void", "x : int" }; - public CompletionTest_ScopedReference_NonCodeScope(String name) { + public ScopedReference_NonCodeScope_CompletionTest(String name) { super(name); } public static Test suite() { - TestSuite suite = new TestSuite(CompletionTest_ScopedReference_NonCodeScope.class.getName()); - suite.addTest(new CompletionTest_ScopedReference_NonCodeScope("testCompletionProposals")); + TestSuite suite = new TestSuite(ScopedReference_NonCodeScope_CompletionTest.class.getName()); + suite.addTest(new ScopedReference_NonCodeScope_CompletionTest("testCompletionProposals")); return suite; } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ScopedReference_Prefix.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/ScopedReference_Prefix_CompletionTest.java index d6c2db7ee6a..8e6c399f2b8 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ScopedReference_Prefix.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/ScopedReference_Prefix_CompletionTest.java @@ -23,7 +23,7 @@ import junit.framework.TestSuite; * Bug#50152: Wrong context sent after a "::" * */ -public class CompletionTest_ScopedReference_Prefix extends CompletionProposalsBaseTest { +public class ScopedReference_Prefix_CompletionTest extends CompletionProposalsBaseTest { private final String fileName = "CompletionTestStart31.cpp"; private final String fileFullPath = "resources/contentassist/" + fileName; @@ -32,13 +32,13 @@ public class CompletionTest_ScopedReference_Prefix extends CompletionProposalsBa private final String expectedPrefix = "a"; private final String[] expectedResults = { "aNamespaceFunction(void) : void" }; - public CompletionTest_ScopedReference_Prefix(String name) { + public ScopedReference_Prefix_CompletionTest(String name) { super(name); } public static Test suite() { - TestSuite suite = new TestSuite(CompletionTest_ScopedReference_Prefix.class.getName()); - suite.addTest(new CompletionTest_ScopedReference_Prefix("testCompletionProposals")); + TestSuite suite = new TestSuite(ScopedReference_Prefix_CompletionTest.class.getName()); + suite.addTest(new ScopedReference_Prefix_CompletionTest("testCompletionProposals")); return suite; } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_SingleName_Method_NoPrefix.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/SingleName_Method_NoPrefix_CompletionTest.java index 3bac5ff20e6..77bf8f268cf 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_SingleName_Method_NoPrefix.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/SingleName_Method_NoPrefix_CompletionTest.java @@ -23,7 +23,7 @@ import junit.framework.TestSuite; * Lookup.THIS * */ -public class CompletionTest_SingleName_Method_NoPrefix extends CompletionProposalsBaseTest { +public class SingleName_Method_NoPrefix_CompletionTest extends CompletionProposalsBaseTest { private final String fileName = "CompletionTestStart5.cpp"; private final String fileFullPath = "resources/contentassist/" + fileName; private final String headerFileName = "CompletionTestStart.h"; @@ -39,7 +39,7 @@ public class CompletionTest_SingleName_Method_NoPrefix extends CompletionProposa // "operator =(const anotherClass &) anotherClass &", }; - public CompletionTest_SingleName_Method_NoPrefix(String name) { + public SingleName_Method_NoPrefix_CompletionTest(String name) { super(name); // operators should not be proposed // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=172304 @@ -47,8 +47,8 @@ public class CompletionTest_SingleName_Method_NoPrefix extends CompletionProposa } public static Test suite() { - TestSuite suite = new TestSuite(CompletionTest_SingleName_Method_NoPrefix.class.getName()); - suite.addTest(new CompletionTest_SingleName_Method_NoPrefix("testCompletionProposals")); + TestSuite suite = new TestSuite(SingleName_Method_NoPrefix_CompletionTest.class.getName()); + suite.addTest(new SingleName_Method_NoPrefix_CompletionTest("testCompletionProposals")); return suite; } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_SingleName_Method_Prefix.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/SingleName_Method_Prefix_CompletionTest.java index 780fa3220a6..fde3ae6a096 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_SingleName_Method_Prefix.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/SingleName_Method_Prefix_CompletionTest.java @@ -22,7 +22,7 @@ import junit.framework.TestSuite; * Testing statement start completion kind, with a prefix * */ -public class CompletionTest_SingleName_Method_Prefix extends CompletionProposalsBaseTest { +public class SingleName_Method_Prefix_CompletionTest extends CompletionProposalsBaseTest { private final String fileName = "CompletionTestStart1.cpp"; private final String fileFullPath = "resources/contentassist/" + fileName; @@ -34,13 +34,13 @@ public class CompletionTest_SingleName_Method_Prefix extends CompletionProposals "anotherClass(const anotherClass &)", "anotherClass(void)", "aNamespace", "anEnumeration", "aFirstEnum", "aSecondEnum", "aThirdEnum", "AStruct", "AMacro(x)" }; - public CompletionTest_SingleName_Method_Prefix(String name) { + public SingleName_Method_Prefix_CompletionTest(String name) { super(name); } public static Test suite() { - TestSuite suite = new TestSuite(CompletionTest_SingleName_Method_Prefix.class.getName()); - suite.addTest(new CompletionTest_SingleName_Method_Prefix("testCompletionProposals")); + TestSuite suite = new TestSuite(SingleName_Method_Prefix_CompletionTest.class.getName()); + suite.addTest(new SingleName_Method_Prefix_CompletionTest("testCompletionProposals")); return suite; } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_SingleName_NoPrefix.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/SingleName_NoPrefix_CompletionTest.java index 4031c5bed5b..0273b252b7f 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_SingleName_NoPrefix.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/SingleName_NoPrefix_CompletionTest.java @@ -22,7 +22,7 @@ import junit.framework.TestSuite; * Testing Single name reference, with prefix * */ -public class CompletionTest_SingleName_NoPrefix extends CompletionProposalsBaseTest { +public class SingleName_NoPrefix_CompletionTest extends CompletionProposalsBaseTest { private final String fileName = "CompletionTestStart15.cpp"; private final String fileFullPath = "resources/contentassist/" + fileName; private final String headerFileName = "CompletionTestStart.h"; @@ -36,13 +36,13 @@ public class CompletionTest_SingleName_NoPrefix extends CompletionProposalsBaseT // note: macros are omitted intentionally }; - public CompletionTest_SingleName_NoPrefix(String name) { + public SingleName_NoPrefix_CompletionTest(String name) { super(name); } public static Test suite() { - TestSuite suite = new TestSuite(CompletionTest_SingleName_NoPrefix.class.getName()); - suite.addTest(new CompletionTest_SingleName_NoPrefix("testCompletionProposals")); + TestSuite suite = new TestSuite(SingleName_NoPrefix_CompletionTest.class.getName()); + suite.addTest(new SingleName_NoPrefix_CompletionTest("testCompletionProposals")); return suite; } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_SingleName_Prefix2.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/SingleName_Prefix2_CompletionTest.java index 895cda610c1..ec4b07f0ec2 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_SingleName_Prefix2.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/SingleName_Prefix2_CompletionTest.java @@ -22,7 +22,7 @@ import junit.framework.TestSuite; * Testing Single name reference, with prefix * */ -public class CompletionTest_SingleName_Prefix2 extends CompletionProposalsBaseTest { +public class SingleName_Prefix2_CompletionTest extends CompletionProposalsBaseTest { private final String fileName = "CompletionTestStart14.cpp"; private final String fileFullPath = "resources/contentassist/" + fileName; private final String headerFileName = "CompletionTestStart.h"; @@ -32,15 +32,15 @@ public class CompletionTest_SingleName_Prefix2 extends CompletionProposalsBaseTe "anotherFunction(void) : void", "aClass", "anotherClass", "aNamespace", "anEnumeration", "aFirstEnum", "aSecondEnum", "aThirdEnum", "AMacro(x)", "AStruct" }; - public CompletionTest_SingleName_Prefix2(String name) { + public SingleName_Prefix2_CompletionTest(String name) { super(name); // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=109724 //setExpectFailure(109724); } public static Test suite() { - TestSuite suite = new TestSuite(CompletionTest_SingleName_Prefix2.class.getName()); - suite.addTest(new CompletionTest_SingleName_Prefix2("testCompletionProposals")); + TestSuite suite = new TestSuite(SingleName_Prefix2_CompletionTest.class.getName()); + suite.addTest(new SingleName_Prefix2_CompletionTest("testCompletionProposals")); return suite; } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_SingleName_Prefix.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/SingleName_Prefix_CompletionTest.java index 4c7eff0dddd..71bfc640d51 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_SingleName_Prefix.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/SingleName_Prefix_CompletionTest.java @@ -22,7 +22,7 @@ import junit.framework.TestSuite; * Testing Single name reference, Macro lookups * */ -public class CompletionTest_SingleName_Prefix extends CompletionProposalsBaseTest { +public class SingleName_Prefix_CompletionTest extends CompletionProposalsBaseTest { private final String fileName = "CompletionTestStart8.cpp"; private final String fileFullPath = "resources/contentassist/" + fileName; private final String headerFileName = "CompletionTestStart.h"; @@ -32,14 +32,14 @@ public class CompletionTest_SingleName_Prefix extends CompletionProposalsBaseTes // missing results "AMacro(x)" }; - public CompletionTest_SingleName_Prefix(String name) { + public SingleName_Prefix_CompletionTest(String name) { super(name); // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=171708 } public static Test suite() { - TestSuite suite = new TestSuite(CompletionTest_SingleName_Prefix.class.getName()); - suite.addTest(new CompletionTest_SingleName_Prefix("testCompletionProposals")); + TestSuite suite = new TestSuite(SingleName_Prefix_CompletionTest.class.getName()); + suite.addTest(new SingleName_Prefix_CompletionTest("testCompletionProposals")); return suite; } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_TypeDef_NoPrefix.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/TypeDef_NoPrefix_CompletionTest.java index e2f678a2b54..7ad3d422ff1 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_TypeDef_NoPrefix.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/TypeDef_NoPrefix_CompletionTest.java @@ -23,7 +23,7 @@ import junit.framework.TestSuite; * Bug#52948 * */ -public class CompletionTest_TypeDef_NoPrefix extends CompletionProposalsBaseTest { +public class TypeDef_NoPrefix_CompletionTest extends CompletionProposalsBaseTest { private final String fileName = "CompletionTestStart37.cpp"; private final String fileFullPath = "resources/contentassist/" + fileName; @@ -32,13 +32,13 @@ public class CompletionTest_TypeDef_NoPrefix extends CompletionProposalsBaseTest private final String expectedPrefix = "m"; private final String[] expectedResults = { "myType" }; - public CompletionTest_TypeDef_NoPrefix(String name) { + public TypeDef_NoPrefix_CompletionTest(String name) { super(name); } public static Test suite() { - TestSuite suite = new TestSuite(CompletionTest_TypeDef_NoPrefix.class.getName()); - suite.addTest(new CompletionTest_TypeDef_NoPrefix("testCompletionProposals")); + TestSuite suite = new TestSuite(TypeDef_NoPrefix_CompletionTest.class.getName()); + suite.addTest(new TypeDef_NoPrefix_CompletionTest("testCompletionProposals")); return suite; } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_TypeDef_Prefix.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/TypeDef_Prefix_CompletionTest.java index 0a6713addce..37f2f7f168e 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_TypeDef_Prefix.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/TypeDef_Prefix_CompletionTest.java @@ -23,7 +23,7 @@ import junit.framework.TestSuite; * Bug#52948 * */ -public class CompletionTest_TypeDef_Prefix extends CompletionProposalsBaseTest { +public class TypeDef_Prefix_CompletionTest extends CompletionProposalsBaseTest { private final String fileName = "CompletionTestStart37.cpp"; private final String fileFullPath = "resources/contentassist/" + fileName; @@ -32,13 +32,13 @@ public class CompletionTest_TypeDef_Prefix extends CompletionProposalsBaseTest { private final String expectedPrefix = "m"; private final String[] expectedResults = { "myType" }; - public CompletionTest_TypeDef_Prefix(String name) { + public TypeDef_Prefix_CompletionTest(String name) { super(name); } public static Test suite() { - TestSuite suite = new TestSuite(CompletionTest_TypeDef_Prefix.class.getName()); - suite.addTest(new CompletionTest_TypeDef_Prefix("testCompletionProposals")); + TestSuite suite = new TestSuite(TypeDef_Prefix_CompletionTest.class.getName()); + suite.addTest(new TypeDef_Prefix_CompletionTest("testCompletionProposals")); return suite; } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_TypeRef_NoPrefix.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/TypeRef_NoPrefix_CompletionTest.java index 70386bf401d..3723ba1b929 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_TypeRef_NoPrefix.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/TypeRef_NoPrefix_CompletionTest.java @@ -24,7 +24,7 @@ import junit.framework.TestSuite; * Bug#50471 : Wrong completion kind after the "using" keyword * */ -public class CompletionTest_TypeRef_NoPrefix extends CompletionProposalsBaseTest { +public class TypeRef_NoPrefix_CompletionTest extends CompletionProposalsBaseTest { private final String fileName = "CompletionTestStart24.cpp"; private final String fileFullPath = "resources/contentassist/" + fileName; @@ -33,14 +33,14 @@ public class CompletionTest_TypeRef_NoPrefix extends CompletionProposalsBaseTest private final String expectedPrefix = ""; private final String[] expectedResults = { "aNamespace", "xNamespace" }; - public CompletionTest_TypeRef_NoPrefix(String name) { + public TypeRef_NoPrefix_CompletionTest(String name) { super(name); // https://bugs.eclipse.org/bugs/show_bug.cgi?id=169860 } public static Test suite() { - TestSuite suite = new TestSuite(CompletionTest_TypeRef_NoPrefix.class.getName()); - suite.addTest(new CompletionTest_TypeRef_NoPrefix("testCompletionProposals")); + TestSuite suite = new TestSuite(TypeRef_NoPrefix_CompletionTest.class.getName()); + suite.addTest(new TypeRef_NoPrefix_CompletionTest("testCompletionProposals")); return suite; } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_TypeRef_Prefix.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/TypeRef_Prefix_CompletionTest.java index 31c897c9962..8d11e7530f5 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_TypeRef_Prefix.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/TypeRef_Prefix_CompletionTest.java @@ -24,7 +24,7 @@ import junit.framework.TestSuite; * Bug#50471 : Wrong completion kind after the "using" keyword * */ -public class CompletionTest_TypeRef_Prefix extends CompletionProposalsBaseTest { +public class TypeRef_Prefix_CompletionTest extends CompletionProposalsBaseTest { private final String fileName = "CompletionTestStart25.cpp"; private final String fileFullPath = "resources/contentassist/" + fileName; @@ -33,14 +33,14 @@ public class CompletionTest_TypeRef_Prefix extends CompletionProposalsBaseTest { private final String expectedPrefix = "a"; private final String[] expectedResults = { "aNamespace" }; - public CompletionTest_TypeRef_Prefix(String name) { + public TypeRef_Prefix_CompletionTest(String name) { super(name); // https://bugs.eclipse.org/bugs/show_bug.cgi?id=169860 } public static Test suite() { - TestSuite suite = new TestSuite(CompletionTest_TypeRef_Prefix.class.getName()); - suite.addTest(new CompletionTest_TypeRef_Prefix("testCompletionProposals")); + TestSuite suite = new TestSuite(TypeRef_Prefix_CompletionTest.class.getName()); + suite.addTest(new TypeRef_Prefix_CompletionTest("testCompletionProposals")); return suite; } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_VariableType_NestedPrefix.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/VariableType_NestedPrefix_CompletionTest.java index 69d726d67ef..e416fb097cd 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_VariableType_NestedPrefix.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/VariableType_NestedPrefix_CompletionTest.java @@ -23,7 +23,7 @@ import junit.framework.TestSuite; * Bug#50152: Wrong context sent after a "::" * */ -public class CompletionTest_VariableType_NestedPrefix extends CompletionProposalsBaseTest { +public class VariableType_NestedPrefix_CompletionTest extends CompletionProposalsBaseTest { private final String fileName = "CompletionTestStart38.cpp"; private final String fileFullPath = "resources/contentassist/" + fileName; @@ -32,13 +32,13 @@ public class CompletionTest_VariableType_NestedPrefix extends CompletionProposal private final String expectedPrefix = ""; private final String[] expectedResults = { "Foo(void)", "bar(void) : void", "fum(void) : void", "DEF", "x : int" }; - public CompletionTest_VariableType_NestedPrefix(String name) { + public VariableType_NestedPrefix_CompletionTest(String name) { super(name); } public static Test suite() { - TestSuite suite = new TestSuite(CompletionTest_VariableType_NestedPrefix.class.getName()); - suite.addTest(new CompletionTest_VariableType_NestedPrefix("testCompletionProposals")); + TestSuite suite = new TestSuite(VariableType_NestedPrefix_CompletionTest.class.getName()); + suite.addTest(new VariableType_NestedPrefix_CompletionTest("testCompletionProposals")); return suite; } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_VariableType_NoPrefix.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/VariableType_NoPrefix_CompletionTest.java index 61c8d72e4ad..59726b2d0e0 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_VariableType_NoPrefix.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/VariableType_NoPrefix_CompletionTest.java @@ -23,7 +23,7 @@ import junit.framework.TestSuite; * Testing Variable_type, with NO prefix * */ -public class CompletionTest_VariableType_NoPrefix extends CompletionProposalsBaseTest { +public class VariableType_NoPrefix_CompletionTest extends CompletionProposalsBaseTest { private final String fileName = "CompletionTestStart11.cpp"; private final String fileFullPath = "resources/contentassist/" + fileName; private final String headerFileName = "CompletionTestStart.h"; @@ -32,14 +32,14 @@ public class CompletionTest_VariableType_NoPrefix extends CompletionProposalsBas private final String[] expectedResults = { "aClass", "anotherClass", "aNamespace", "anEnumeration", "AStruct", "xOtherClass", "xNamespace", "xEnumeration", "XStruct", }; - public CompletionTest_VariableType_NoPrefix(String name) { + public VariableType_NoPrefix_CompletionTest(String name) { super(name); // https://bugs.eclipse.org/bugs/show_bug.cgi?id=169860 } public static Test suite() { - TestSuite suite = new TestSuite(CompletionTest_VariableType_NoPrefix.class.getName()); - suite.addTest(new CompletionTest_VariableType_NoPrefix("testCompletionProposals")); + TestSuite suite = new TestSuite(VariableType_NoPrefix_CompletionTest.class.getName()); + suite.addTest(new VariableType_NoPrefix_CompletionTest("testCompletionProposals")); return suite; } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_VariableType_Prefix.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/VariableType_Prefix_CompletionTest.java index d91768d4bdc..08c18e7ebac 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_VariableType_Prefix.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/VariableType_Prefix_CompletionTest.java @@ -22,7 +22,7 @@ import junit.framework.TestSuite; * Testing Variable_type completion kind, with a prefix * */ -public class CompletionTest_VariableType_Prefix extends CompletionProposalsBaseTest { +public class VariableType_Prefix_CompletionTest extends CompletionProposalsBaseTest { private final String fileName = "CompletionTestStart3.cpp"; private final String fileFullPath = "resources/contentassist/" + fileName; private final String headerFileName = "CompletionTestStart.h"; @@ -31,15 +31,15 @@ public class CompletionTest_VariableType_Prefix extends CompletionProposalsBaseT private final String[] expectedResults = { "aClass", "anotherClass", "aNamespace", "anEnumeration", "AStruct", "AMacro(x)" }; - public CompletionTest_VariableType_Prefix(String name) { + public VariableType_Prefix_CompletionTest(String name) { super(name); // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=109724 // setExpectFailure(109724); } public static Test suite() { - TestSuite suite = new TestSuite(CompletionTest_VariableType_Prefix.class.getName()); - suite.addTest(new CompletionTest_VariableType_Prefix("testCompletionProposals")); + TestSuite suite = new TestSuite(VariableType_Prefix_CompletionTest.class.getName()); + suite.addTest(new VariableType_Prefix_CompletionTest("testCompletionProposals")); return suite; } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsIndexer.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionIndexerTests.java index a66e622f1de..af240ce66f7 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsIndexer.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionIndexerTests.java @@ -42,17 +42,17 @@ import junit.framework.Test; /** * Test Ctrl-F3/F3 with the DOM Indexer for a C++ project. */ -public class CPPSelectionTestsIndexer extends BaseSelectionTestsIndexer { +public class CPPSelectionIndexerTests extends BaseSelectionTestsIndexer { protected String sourceIndexerID; protected IIndex index; - public CPPSelectionTestsIndexer(String name) { + public CPPSelectionIndexerTests(String name) { super(name); sourceIndexerID = IPDOMManager.ID_FAST_INDEXER; } public static Test suite() { - return suite(CPPSelectionTestsIndexer.class); + return suite(CPPSelectionIndexerTests.class); } @Override @@ -84,7 +84,7 @@ public class CPPSelectionTestsIndexer extends BaseSelectionTestsIndexer { protected StringBuilder[] getContents(int sections) throws IOException { return TestSourceReader.getContentsForTest(CTestPlugin.getDefault().getBundle(), "ui", - CPPSelectionTestsIndexer.class, getName(), sections); + CPPSelectionIndexerTests.class, getName(), sections); } private void assertNode(String name, int offset, IASTNode node) { diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsNoIndexer.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionNoIndexerTests.java index 6a96df10ae4..2557b6322a6 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsNoIndexer.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionNoIndexerTests.java @@ -62,7 +62,7 @@ import junit.framework.TestSuite; * * @author dsteffle */ -public class CPPSelectionTestsNoIndexer extends BaseSelectionTests { +public class CPPSelectionNoIndexerTests extends BaseSelectionTests { private static final String INDEX_FILE_ID = "2946365241"; //$NON-NLS-1$ static NullProgressMonitor monitor; static IWorkspace workspace; @@ -100,20 +100,20 @@ public class CPPSelectionTestsNoIndexer extends BaseSelectionTests { fileManager = new FileManager(); } - public CPPSelectionTestsNoIndexer() { + public CPPSelectionNoIndexerTests() { super(); } /** * @param name */ - public CPPSelectionTestsNoIndexer(String name) { + public CPPSelectionNoIndexerTests(String name) { super(name); } public static Test suite() { - TestSuite suite = suite(CPPSelectionTestsNoIndexer.class, "_"); - suite.addTest(new CPPSelectionTestsNoIndexer("cleanupProject")); //$NON-NLS-1$ + TestSuite suite = suite(CPPSelectionNoIndexerTests.class, "_"); + suite.addTest(new CPPSelectionNoIndexerTests("cleanupProject")); //$NON-NLS-1$ return suite; } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionTestsIndexer.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionIndexerTests.java index e0884819704..b78a540e9f8 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionTestsIndexer.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionIndexerTests.java @@ -35,17 +35,17 @@ import org.eclipse.ui.part.FileEditorInput; import junit.framework.Test; -public class CSelectionTestsIndexer extends BaseSelectionTestsIndexer { +public class CSelectionIndexerTests extends BaseSelectionTestsIndexer { private String sourceIndexerID; private IIndex index; - public CSelectionTestsIndexer(String name) { + public CSelectionIndexerTests(String name) { super(name); sourceIndexerID = IPDOMManager.ID_FAST_INDEXER; } public static Test suite() { - return suite(CSelectionTestsIndexer.class); + return suite(CSelectionIndexerTests.class); } @Override @@ -74,7 +74,7 @@ public class CSelectionTestsIndexer extends BaseSelectionTestsIndexer { protected StringBuilder[] getContents(int sections) throws IOException { return TestSourceReader.getContentsForTest(CTestPlugin.getDefault().getBundle(), "ui", - CSelectionTestsIndexer.class, getName(), sections); + CSelectionIndexerTests.class, getName(), sections); } private void assertNode(String name, int offset, IASTNode node) { diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionTestsNoIndexer.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionNoIndexerTests.java index b033d9b95fd..f8928828f08 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionTestsNoIndexer.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionNoIndexerTests.java @@ -48,7 +48,7 @@ import junit.framework.TestSuite; * * @author dsteffle */ -public class CSelectionTestsNoIndexer extends BaseSelectionTests { +public class CSelectionNoIndexerTests extends BaseSelectionTests { private static final String INDEX_FILE_ID = "2324852323"; //$NON-NLS-1$ static NullProgressMonitor monitor; @@ -80,20 +80,20 @@ public class CSelectionTestsNoIndexer extends BaseSelectionTests { fileManager = new FileManager(); } - public CSelectionTestsNoIndexer() { + public CSelectionNoIndexerTests() { super(); } /** * @param name */ - public CSelectionTestsNoIndexer(String name) { + public CSelectionNoIndexerTests(String name) { super(name); } public static Test suite() { - TestSuite suite = new TestSuite(CSelectionTestsNoIndexer.class); - suite.addTest(new CSelectionTestsNoIndexer("cleanupProject")); //$NON-NLS-1$ + TestSuite suite = new TestSuite(CSelectionNoIndexerTests.class); + suite.addTest(new CSelectionNoIndexerTests("cleanupProject")); //$NON-NLS-1$ return suite; } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/SelectionTestSuite.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/SelectionTestSuite.java index f31c354d7d3..80e0dc63b26 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/SelectionTestSuite.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/SelectionTestSuite.java @@ -22,8 +22,8 @@ import org.junit.runners.Suite; @Suite.SuiteClasses({ // selection tests - ResolveBindingTests.class, CPPSelectionTestsNoIndexer.class, CSelectionTestsNoIndexer.class, - CPPSelectionTestsIndexer.class, CSelectionTestsIndexer.class, + ResolveBindingTests.class, CPPSelectionNoIndexerTests.class, CSelectionNoIndexerTests.class, + CPPSelectionIndexerTests.class, CSelectionIndexerTests.class, }) public class SelectionTestSuite { diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/TypeHierarchyBaseTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/TypeHierarchyBaseTest.java index 4ea405784c8..4d371314f8f 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/TypeHierarchyBaseTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/TypeHierarchyBaseTest.java @@ -43,7 +43,7 @@ import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.ide.IDE; -public class TypeHierarchyBaseTest extends BaseUITestCase { +public abstract class TypeHierarchyBaseTest extends BaseUITestCase { protected ICProject fCProject; protected IIndex fIndex; diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/wizards/settingswizards/SettingsImportExportTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/wizards/settingswizards/SettingsImportExportTest.java index 98ac5c52884..37b899de98f 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/wizards/settingswizards/SettingsImportExportTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/wizards/settingswizards/SettingsImportExportTest.java @@ -48,7 +48,10 @@ public class SettingsImportExportTest extends BaseUITestCase { new CMacroEntry("smac", "blah", 0) }; private static ICLanguageSettingEntry[] EXPORTED_INCLUDES = new ICLanguageSettingEntry[] { - new CIncludePathEntry("/path/to/somewhere", 0), new CIncludePathEntry("/blah/blah/blah", 0), + // There is a multi-byte character at the end of this first string. When this test + // was run without the fix for Bug 577074 and -Dfile.encoding that would cause the + // character to be corrupted (e.g. windows-1252) + new CIncludePathEntry("/path/to/somewhere¢", 0), new CIncludePathEntry("/blah/blah/blah", 0), new CIncludePathEntry("pantera/is/awesome", 0) }; public SettingsImportExportTest() { diff --git a/core/org.eclipse.cdt.ui/.classpath b/core/org.eclipse.cdt.ui/.classpath index 9500e6b71bd..49e8e2e29d3 100644 --- a/core/org.eclipse.cdt.ui/.classpath +++ b/core/org.eclipse.cdt.ui/.classpath @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="src" path="src"/> <classpathentry kind="src" path="utils.ui"/> <classpathentry kind="src" path="browser"/> <classpathentry kind="src" path="templateengine"/> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> - <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="output" path="bin"/> </classpath> diff --git a/core/org.eclipse.cdt.ui/.settings/.api_filters b/core/org.eclipse.cdt.ui/.settings/.api_filters new file mode 100644 index 00000000000..a4dd20fd5bf --- /dev/null +++ b/core/org.eclipse.cdt.ui/.settings/.api_filters @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<component id="org.eclipse.cdt.ui" version="2"> + <resource path="src/org/eclipse/cdt/ui/wizards/CDTCommonProjectWizard.java" type="org.eclipse.cdt.ui.wizards.CDTCommonProjectWizard"> + <filter comment="Squash over zealous warning from PDE. See Bug 558477" id="576725006"> + <message_arguments> + <message_argument value="ICDTCommonProjectWizard"/> + <message_argument value="CDTCommonProjectWizard"/> + </message_arguments> + </filter> + </resource> +</component> diff --git a/core/org.eclipse.cdt.ui/.settings/org.eclipse.core.resources.prefs b/core/org.eclipse.cdt.ui/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 00000000000..99f26c0203a --- /dev/null +++ b/core/org.eclipse.cdt.ui/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/<project>=UTF-8 diff --git a/core/org.eclipse.cdt.ui/.settings/org.eclipse.jdt.core.prefs b/core/org.eclipse.cdt.ui/.settings/org.eclipse.jdt.core.prefs index 2b6ecff8a01..e3a8104f9ca 100644 --- a/core/org.eclipse.cdt.ui/.settings/org.eclipse.jdt.core.prefs +++ b/core/org.eclipse.cdt.ui/.settings/org.eclipse.jdt.core.prefs @@ -30,9 +30,9 @@ org.eclipse.jdt.core.compiler.annotation.nullable.secondary= org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.methodParameters=generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.compliance=11 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -49,6 +49,7 @@ org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled org.eclipse.jdt.core.compiler.problem.discouragedReference=warning org.eclipse.jdt.core.compiler.problem.emptyStatement=warning +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning @@ -107,6 +108,7 @@ org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=igno org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled @@ -144,13 +146,14 @@ org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.release=disabled -org.eclipse.jdt.core.compiler.source=1.8 +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=11 org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns=false org.eclipse.jdt.core.formatter.align_with_spaces=false +org.eclipse.jdt.core.formatter.alignment_for_additive_operator=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 @@ -158,21 +161,24 @@ org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_c org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_assignment=0 -org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_bitwise_operator=16 org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 org.eclipse.jdt.core.formatter.alignment_for_compact_loops=16 org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 org.eclipse.jdt.core.formatter.alignment_for_enum_constants=16 org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0 +org.eclipse.jdt.core.formatter.alignment_for_logical_operator=16 org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 org.eclipse.jdt.core.formatter.alignment_for_module_statements=16 org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_multiplicative_operator=16 org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_string_concatenation=16 org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 @@ -264,11 +270,12 @@ org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_after_additive_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_bitwise_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert @@ -299,6 +306,8 @@ org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_after_logical_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_multiplicative_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert @@ -323,13 +332,17 @@ org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_relational_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert +org.eclipse.jdt.core.formatter.insert_space_after_shift_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_string_concatenation=insert org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_additive_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_bitwise_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert @@ -377,6 +390,8 @@ org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do no org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_before_logical_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_multiplicative_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert @@ -413,9 +428,12 @@ org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not inser org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_relational_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_shift_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_string_concatenation=insert org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert @@ -454,10 +472,14 @@ org.eclipse.jdt.core.formatter.tabulation.char=tab org.eclipse.jdt.core.formatter.tabulation.size=4 org.eclipse.jdt.core.formatter.use_on_off_tags=true org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false +org.eclipse.jdt.core.formatter.wrap_before_additive_operator=true org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false -org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true +org.eclipse.jdt.core.formatter.wrap_before_bitwise_operator=true org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true +org.eclipse.jdt.core.formatter.wrap_before_logical_operator=true +org.eclipse.jdt.core.formatter.wrap_before_multiplicative_operator=true org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true +org.eclipse.jdt.core.formatter.wrap_before_string_concatenation=true org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true org.eclipse.jdt.core.incompatibleJDKLevel=ignore org.eclipse.jdt.core.incompleteClasspath=error diff --git a/core/org.eclipse.cdt.ui/.settings/org.eclipse.jdt.ui.prefs b/core/org.eclipse.cdt.ui/.settings/org.eclipse.jdt.ui.prefs index e44576346c4..d35ba9b5231 100644 --- a/core/org.eclipse.cdt.ui/.settings/org.eclipse.jdt.ui.prefs +++ b/core/org.eclipse.cdt.ui/.settings/org.eclipse.jdt.ui.prefs @@ -1,3 +1,4 @@ +cleanup.add_all=false cleanup.add_default_serial_version_id=true cleanup.add_generated_serial_version_id=false cleanup.add_missing_annotations=true @@ -11,25 +12,72 @@ cleanup.always_use_blocks=true cleanup.always_use_parentheses_in_expressions=false cleanup.always_use_this_for_non_static_field_access=false cleanup.always_use_this_for_non_static_method_access=false +cleanup.array_with_curly=false +cleanup.arrays_fill=false +cleanup.bitwise_conditional_expression=false +cleanup.boolean_literal=false +cleanup.boolean_value_rather_than_comparison=false +cleanup.break_loop=false +cleanup.collection_cloning=false +cleanup.comparing_on_criteria=false +cleanup.comparison_statement=false +cleanup.controlflow_merge=false cleanup.convert_functional_interfaces=false cleanup.convert_to_enhanced_for_loop=false +cleanup.convert_to_enhanced_for_loop_if_loop_var_used=true +cleanup.convert_to_switch_expressions=false cleanup.correct_indentation=false +cleanup.do_while_rather_than_while=true +cleanup.double_negation=false +cleanup.else_if=false +cleanup.embedded_if=false +cleanup.evaluate_nullable=false +cleanup.extract_increment=false cleanup.format_source_code=true cleanup.format_source_code_changes_only=false +cleanup.hash=false +cleanup.if_condition=false cleanup.insert_inferred_type_arguments=false +cleanup.instanceof=false +cleanup.instanceof_keyword=false +cleanup.invert_equals=false +cleanup.join=false +cleanup.lazy_logical_operator=false cleanup.make_local_variable_final=true cleanup.make_parameters_final=false cleanup.make_private_fields_final=true cleanup.make_type_abstract_if_missing_method=false cleanup.make_variable_declarations_final=false +cleanup.map_cloning=false +cleanup.merge_conditional_blocks=false +cleanup.multi_catch=false cleanup.never_use_blocks=false cleanup.never_use_parentheses_in_expressions=true +cleanup.no_string_creation=false +cleanup.no_super=false +cleanup.number_suffix=false +cleanup.objects_equals=false +cleanup.one_if_rather_than_duplicate_blocks_that_fall_through=false +cleanup.operand_factorization=false cleanup.organize_imports=true +cleanup.overridden_assignment=false +cleanup.plain_replacement=false +cleanup.precompile_regex=false +cleanup.primitive_comparison=false +cleanup.primitive_parsing=false +cleanup.primitive_rather_than_wrapper=false +cleanup.primitive_serialization=false +cleanup.pull_out_if_from_if_else=false +cleanup.pull_up_assignment=false +cleanup.push_down_negation=false cleanup.qualify_static_field_accesses_with_declaring_class=false cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true cleanup.qualify_static_member_accesses_with_declaring_class=false cleanup.qualify_static_method_accesses_with_declaring_class=false +cleanup.reduce_indentation=false +cleanup.redundant_comparator=false +cleanup.redundant_falling_through_block_end=false cleanup.remove_private_constructors=true cleanup.remove_redundant_modifiers=false cleanup.remove_redundant_semicolons=true @@ -37,25 +85,57 @@ cleanup.remove_redundant_type_arguments=true cleanup.remove_trailing_whitespaces=true cleanup.remove_trailing_whitespaces_all=true cleanup.remove_trailing_whitespaces_ignore_empty=false +cleanup.remove_unnecessary_array_creation=false cleanup.remove_unnecessary_casts=true cleanup.remove_unnecessary_nls_tags=false cleanup.remove_unused_imports=true cleanup.remove_unused_local_variables=false +cleanup.remove_unused_method_parameters=false cleanup.remove_unused_private_fields=true cleanup.remove_unused_private_members=false cleanup.remove_unused_private_methods=true cleanup.remove_unused_private_types=true +cleanup.return_expression=false +cleanup.simplify_lambda_expression_and_method_ref=false +cleanup.single_used_field=false cleanup.sort_members=false cleanup.sort_members_all=false +cleanup.standard_comparison=false +cleanup.static_inner_class=false +cleanup.strictly_equal_or_different=false +cleanup.stringbuffer_to_stringbuilder=false +cleanup.stringbuilder=false +cleanup.stringbuilder_for_local_vars=true +cleanup.stringconcat_to_textblock=false +cleanup.substring=false +cleanup.switch=false +cleanup.system_property=false +cleanup.system_property_boolean=false +cleanup.system_property_file_encoding=false +cleanup.system_property_file_separator=false +cleanup.system_property_line_separator=false +cleanup.system_property_path_separator=false +cleanup.ternary_operator=false +cleanup.try_with_resource=false +cleanup.unlooped_while=false +cleanup.unreachable_block=false cleanup.use_anonymous_class_creation=false +cleanup.use_autoboxing=false cleanup.use_blocks=false cleanup.use_blocks_only_for_return_and_throw=false +cleanup.use_directly_map_method=false cleanup.use_lambda=true cleanup.use_parentheses_in_expressions=false +cleanup.use_string_is_blank=false cleanup.use_this_for_non_static_field_access=false cleanup.use_this_for_non_static_field_access_only_if_necessary=true cleanup.use_this_for_non_static_method_access=false cleanup.use_this_for_non_static_method_access_only_if_necessary=true +cleanup.use_unboxing=false +cleanup.use_var=false +cleanup.useless_continue=false +cleanup.useless_return=false +cleanup.valueof_rather_than_instantiation=false cleanup_profile=_CDT cleanup_settings_version=2 eclipse.preferences.version=1 diff --git a/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF index a062a2414fa..8f4cd6a062a 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.0.0.qualifier +Bundle-Version: 7.3.300.qualifier Bundle-Activator: org.eclipse.cdt.ui.CUIPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin @@ -102,30 +102,30 @@ Export-Package: org.eclipse.cdt.internal.corext;x-internal:=true, org.eclipse.cdt.ui.wizards, org.eclipse.cdt.ui.wizards.conversion, org.eclipse.cdt.utils.ui.controls -Require-Bundle: org.eclipse.cdt.core;bundle-version="[7.0.0,8.0.0)", - org.eclipse.compare;bundle-version="[3.7.700,4.0.0)", - org.eclipse.core.expressions;bundle-version="[3.6.500,4.0.0)", - org.eclipse.core.filesystem;bundle-version="[1.7.500,2.0.0)", - org.eclipse.core.resources;bundle-version="[3.13.500,4.0.0)", - org.eclipse.core.runtime;bundle-version="[3.16.0,4.0.0)", - org.eclipse.core.variables;bundle-version="[3.4.600,4.0.0)", - org.eclipse.e4.core.contexts;bundle-version="[1.8.300,2.0.0)", - org.eclipse.help;bundle-version="[3.8.500,4.0.0)", - org.eclipse.jface.text;bundle-version="[3.15.300,4.0.0)", - org.eclipse.ltk.core.refactoring;bundle-version="[3.11.0,4.0.0)", - org.eclipse.ltk.ui.refactoring;bundle-version="[3.10.0,4.0.0)", - org.eclipse.search;bundle-version="[3.11.700,4.0.0)", - org.eclipse.ui;bundle-version="[3.114.0,4.0.0)", - org.eclipse.ui.console;bundle-version="[3.8.600,4.0.0)", - org.eclipse.ui.editors;bundle-version="[3.12.0,4.0.0)", - org.eclipse.ui.forms;bundle-version="[3.8.100,4.0.0)", - org.eclipse.ui.ide;bundle-version="[3.16.0,4.0.0)", - org.eclipse.ui.navigator;bundle-version="[3.9.0,4.0.0)", - org.eclipse.ui.navigator.resources;bundle-version="[3.7.0,4.0.0)", - org.eclipse.ui.views;bundle-version="[3.10.0,4.0.0)", - org.eclipse.ui.workbench.texteditor;bundle-version="[3.13.0,4.0.0)", +Require-Bundle: org.eclipse.cdt.core;bundle-version="[7.3.0,8.0.0)", + org.eclipse.compare;bundle-version="[3.8.200,4.0.0)", + org.eclipse.core.expressions;bundle-version="[3.8.100,4.0.0)", + org.eclipse.core.filesystem;bundle-version="[1.9.200,2.0.0)", + org.eclipse.core.resources;bundle-version="[3.16.0,4.0.0)", + org.eclipse.core.runtime;bundle-version="[3.24.0,4.0.0)", + org.eclipse.core.variables;bundle-version="[3.5.100,4.0.0)", + org.eclipse.e4.core.contexts;bundle-version="[1.9.100,2.0.0)", + org.eclipse.help;bundle-version="[3.9.100,4.0.0)", + org.eclipse.jface.text;bundle-version="[3.19.0,4.0.0)", + org.eclipse.ltk.core.refactoring;bundle-version="[3.12.100,4.0.0)", + org.eclipse.ltk.ui.refactoring;bundle-version="[3.12.0,4.0.0)", + org.eclipse.search;bundle-version="[3.14.0,4.0.0)", + org.eclipse.ui;bundle-version="[3.200.0,4.0.0)", + org.eclipse.ui.console;bundle-version="[3.11.100,4.0.0)", + org.eclipse.ui.editors;bundle-version="[3.14.300,4.0.0)", + org.eclipse.ui.forms;bundle-version="[3.11.300,4.0.0)", + org.eclipse.ui.ide;bundle-version="[3.18.400,4.0.0)", + org.eclipse.ui.navigator;bundle-version="[3.10.200,4.0.0)", + org.eclipse.ui.navigator.resources;bundle-version="[3.8.300,4.0.0)", + org.eclipse.ui.views;bundle-version="[3.11.100,4.0.0)", + org.eclipse.ui.workbench.texteditor;bundle-version="[3.16.300,4.0.0)", org.eclipse.e4.ui.css.swt.theme, - org.eclipse.tools.templates.ui;bundle-version="[1.1.1,2.0.0)" + org.eclipse.tools.templates.ui;bundle-version="[1.2.200,2.0.0)" Bundle-ActivationPolicy: lazy -Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Bundle-RequiredExecutionEnvironment: JavaSE-11 Automatic-Module-Name: org.eclipse.cdt.ui diff --git a/core/org.eclipse.cdt.ui/about.html b/core/org.eclipse.cdt.ui/about.html index 164f781a8fd..b3134865230 100644 --- a/core/org.eclipse.cdt.ui/about.html +++ b/core/org.eclipse.cdt.ui/about.html @@ -1,10 +1,11 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> + <head> -<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> -<title>About</title> + <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> + <title>About</title> </head> + <body lang="EN-US"> <h2>About This Content</h2> @@ -16,7 +17,7 @@ ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the Eclipse Public License Version 2.0 ("EPL"). A copy of the EPL is - available at <a href="http://www.eclipse.org/legal/epl-2.0">http://www.eclipse.org/legal/epl-2.0</a>. + available at <a href="https://www.eclipse.org/legal/epl-2.0">https://www.eclipse.org/legal/epl-2.0</a>. For purposes of the EPL, "Program" will mean the Content. </p> @@ -29,8 +30,9 @@ license exists, contact the Redistributor. Unless otherwise indicated below, the terms and conditions of the EPL still apply to any source code in the Content and such source code may be obtained at <a - href="http://www.eclipse.org/">http://www.eclipse.org</a>. + href="https://www.eclipse.org/">https://www.eclipse.org</a>. </p> </body> + </html>
\ No newline at end of file diff --git a/core/org.eclipse.cdt.ui/css/e4-dark_cdt.css b/core/org.eclipse.cdt.ui/css/e4-dark_cdt.css index e23aa9085e3..2faf713501a 100644 --- a/core/org.eclipse.cdt.ui/css/e4-dark_cdt.css +++ b/core/org.eclipse.cdt.ui/css/e4-dark_cdt.css @@ -75,5 +75,30 @@ IEclipsePreferences#org-eclipse-cdt-ui:org-eclipse-cdt-ui { "semanticHighlighting.typedef.enabled=true" "semanticHighlighting.typedef.bold=true" "semanticHighlighting.typeParameter.color=191,164,164" - "semanticHighlighting.typeParameter.enabled=true" + "semanticHighlighting.typeParameter.enabled=true" + "buildConsoleInfoStreamColor=18,144,195" + "buildConsoleOutputStreamColor=200,200,200" + "buildConsoleErrorStreamColor=255,0,0" + "buildConsoleBackgroundColor=47,47,47" + "buildConsoleProblemBackgroundColor=130,6,12" + "buildConsoleProblemWarningBackgroundColor=150,88,11" + "buildConsoleProblemInfoBackgroundColor=48,64,254" + "buildConsoleProblemHighlightedColor=255,0,0" + "inactiveCodeColor=30,30,30" +} + + +IEclipsePreferences#org-eclipse-ui-editors:org-eclipse-cdt-ui { /* pseudo attribute added to allow contributions without replacing this node, see Bug 466075 */ + preferences: + "org.eclipse.cdt.ui.occurrenceIndicationColor=27,98,145" + "org.eclipse.cdt.ui.writeOccurrenceIndicationColor=27,98,145" + "org.eclipse.cdt.ui.overrideIndicatorColor=27,98,145" +} + + +IEclipsePreferences#org-eclipse-ui-workbench:org-eclipse-cdt-ui { /* pseudo attribute added to allow contributions without replacing this node, see Bug 466075 */ + preferences: + "org.eclipse.cdt.ui.ColoredLabels.writeaccess_highlight=255,128,128" + "org.eclipse.cdt.ui.outline.mark.textcolor=115,129,133" + "org.eclipse.cdt.ui.outline.mark.dividercolor=80,80,80" } diff --git a/core/org.eclipse.cdt.ui/icons/dlcl16/outline_mark.png b/core/org.eclipse.cdt.ui/icons/dlcl16/outline_mark.png Binary files differnew file mode 100644 index 00000000000..14a9e25681f --- /dev/null +++ b/core/org.eclipse.cdt.ui/icons/dlcl16/outline_mark.png diff --git a/core/org.eclipse.cdt.ui/icons/dlcl16/outline_mark@2x.png b/core/org.eclipse.cdt.ui/icons/dlcl16/outline_mark@2x.png Binary files differnew file mode 100644 index 00000000000..3d4065a94a9 --- /dev/null +++ b/core/org.eclipse.cdt.ui/icons/dlcl16/outline_mark@2x.png diff --git a/core/org.eclipse.cdt.ui/icons/elcl16/bring_console_to_top_on_build.png b/core/org.eclipse.cdt.ui/icons/elcl16/bring_console_to_top_on_build.png Binary files differnew file mode 100644 index 00000000000..6b381bf6bf1 --- /dev/null +++ b/core/org.eclipse.cdt.ui/icons/elcl16/bring_console_to_top_on_build.png diff --git a/core/org.eclipse.cdt.ui/icons/elcl16/bring_console_to_top_on_build@2x.png b/core/org.eclipse.cdt.ui/icons/elcl16/bring_console_to_top_on_build@2x.png Binary files differnew file mode 100644 index 00000000000..d42ee7f7b91 --- /dev/null +++ b/core/org.eclipse.cdt.ui/icons/elcl16/bring_console_to_top_on_build@2x.png diff --git a/core/org.eclipse.cdt.ui/icons/elcl16/outline_mark.png b/core/org.eclipse.cdt.ui/icons/elcl16/outline_mark.png Binary files differnew file mode 100644 index 00000000000..14a9e25681f --- /dev/null +++ b/core/org.eclipse.cdt.ui/icons/elcl16/outline_mark.png diff --git a/core/org.eclipse.cdt.ui/icons/elcl16/outline_mark@2x.png b/core/org.eclipse.cdt.ui/icons/elcl16/outline_mark@2x.png Binary files differnew file mode 100644 index 00000000000..3d4065a94a9 --- /dev/null +++ b/core/org.eclipse.cdt.ui/icons/elcl16/outline_mark@2x.png diff --git a/core/org.eclipse.cdt.ui/icons/obj16/asm_resource_obj.gif b/core/org.eclipse.cdt.ui/icons/obj16/asm_resource_obj.gif Binary files differindex 4f1043c0c19..7f639f05bbc 100644 --- a/core/org.eclipse.cdt.ui/icons/obj16/asm_resource_obj.gif +++ b/core/org.eclipse.cdt.ui/icons/obj16/asm_resource_obj.gif diff --git a/core/org.eclipse.cdt.ui/icons/obj16/ch_resource_obj.gif b/core/org.eclipse.cdt.ui/icons/obj16/ch_resource_obj.gif Binary files differindex 33161cec92e..733cd5daa5d 100644 --- a/core/org.eclipse.cdt.ui/icons/obj16/ch_resource_obj.gif +++ b/core/org.eclipse.cdt.ui/icons/obj16/ch_resource_obj.gif diff --git a/core/org.eclipse.cdt.ui/icons/obj16/hfolder_quote_obj.gif b/core/org.eclipse.cdt.ui/icons/obj16/hfolder_quote_obj.gif Binary files differindex 90f9be3eafa..fc26dc471c3 100644 --- a/core/org.eclipse.cdt.ui/icons/obj16/hfolder_quote_obj.gif +++ b/core/org.eclipse.cdt.ui/icons/obj16/hfolder_quote_obj.gif diff --git a/core/org.eclipse.cdt.ui/icons/obj16/outline_mark.png b/core/org.eclipse.cdt.ui/icons/obj16/outline_mark.png Binary files differnew file mode 100644 index 00000000000..14a9e25681f --- /dev/null +++ b/core/org.eclipse.cdt.ui/icons/obj16/outline_mark.png diff --git a/core/org.eclipse.cdt.ui/icons/obj16/outline_mark@2x.png b/core/org.eclipse.cdt.ui/icons/obj16/outline_mark@2x.png Binary files differnew file mode 100644 index 00000000000..3d4065a94a9 --- /dev/null +++ b/core/org.eclipse.cdt.ui/icons/obj16/outline_mark@2x.png diff --git a/core/org.eclipse.cdt.ui/icons/obj16/structfo_obj.gif b/core/org.eclipse.cdt.ui/icons/obj16/structfo_obj.gif Binary files differindex bdbc77e8180..0b52c73af69 100644 --- a/core/org.eclipse.cdt.ui/icons/obj16/structfo_obj.gif +++ b/core/org.eclipse.cdt.ui/icons/obj16/structfo_obj.gif diff --git a/core/org.eclipse.cdt.ui/icons/obj16/typedeffo_obj.gif b/core/org.eclipse.cdt.ui/icons/obj16/typedeffo_obj.gif Binary files differindex f6b2d56066c..1706434c909 100644 --- a/core/org.eclipse.cdt.ui/icons/obj16/typedeffo_obj.gif +++ b/core/org.eclipse.cdt.ui/icons/obj16/typedeffo_obj.gif diff --git a/core/org.eclipse.cdt.ui/icons/obj16/unionfo_obj.gif b/core/org.eclipse.cdt.ui/icons/obj16/unionfo_obj.gif Binary files differindex 8f3bc264298..aa2cdf4fc17 100644 --- a/core/org.eclipse.cdt.ui/icons/obj16/unionfo_obj.gif +++ b/core/org.eclipse.cdt.ui/icons/obj16/unionfo_obj.gif diff --git a/core/org.eclipse.cdt.ui/plugin.properties b/core/org.eclipse.cdt.ui/plugin.properties index 9aac275b99c..e2d94044163 100644 --- a/core/org.eclipse.cdt.ui/plugin.properties +++ b/core/org.eclipse.cdt.ui/plugin.properties @@ -396,6 +396,15 @@ CEditorFontDefinition.description = The C/C++ editor text font is used by C/C++ CPresentation.label= C/C++ CEditorPresentation.label= Editor +## C Outline Fonts +COutlinePresentation.label= Outline +COutline.mark.font.label= C/C++ Outline Mark/Region Text Font +COutline.mark.font.description= The C/C++ Outline Mark/Region Text font is used by C/C++ outlines for highlighted elements by #pragma mark or #pragma region +COutline.mark.textcolor.label=C/C++ Outline Mark/Region Text Color +COutline.mark.textcolor.description=The C/C++ Outline Mark/Region Text color is used by C/C++ outlines for highlighted elements by #pragma mark or #pragma region +COutline.mark.dividercolor.label=C/C++ Outline Mark/Region Divider Color +COutline.mark.dividercolor.description=The C/C++ Outline Mark/Region Divider color is used by C/C++ outlines for dividing lines around elements highlighted by #pragma mark or #pragma region + CDTIndexerMarker.label= C/C++ Indexer Markers @@ -496,6 +505,8 @@ SearchUnresolvedIncludes.name=Search for Unresolved Includes SearchUnresolvedIncludes.label=Search for Unresolved &Includes CreateParserLog.name=Create Parser Log File CreateParserLog.label=Create Parser &Log File +wsselection.command.name=Manage Working Sets +ManageConfigs.command.name=Manage Build Configurations indexerPage.name = Indexer Page proposalFilter.name = Code Completion Proposal Filter diff --git a/core/org.eclipse.cdt.ui/plugin.xml b/core/org.eclipse.cdt.ui/plugin.xml index ee0a5873c7d..bf3837a4f81 100644 --- a/core/org.eclipse.cdt.ui/plugin.xml +++ b/core/org.eclipse.cdt.ui/plugin.xml @@ -9,7 +9,7 @@ <extension-point id="foldingStructureProviders" name="%foldingStructureProvidersExtensionPoint" schema="schema/foldingStructureProviders.exsd"/> <extension-point id="cPropertyTab" name="%cPropertyTabName" schema="schema/cPropertyTab.exsd"/> <extension-point id="CDTWizard" name="%CDTWizard" schema="schema/CDTWizard.exsd"/> - + <!-- =========================================================================== --> <!-- Extension point: org.eclipse.cdt.ui.textHovers --> <!-- Extension Implementation: must implement org.eclipse.jface.text.ITextHover --> @@ -153,7 +153,7 @@ targetId="org.eclipse.cdt.ui.CView" name="%ForwardDeclarationFilter.label" enabled="true" - description="%ForwardDeclarationFilter.description" + description="%ForwardDeclarationFilter.description" class="org.eclipse.cdt.internal.ui.filters.ForwardDeclarationFilter" id="org.eclipse.cdt.internal.ui.CView.ForwardDeclarationFilter"> </filter> @@ -186,7 +186,7 @@ targetId="org.eclipse.cdt.ui.COutlinePage" name="%ForwardDeclarationFilter.label" enabled="false" - description="%ForwardDeclarationFilter.description" + description="%ForwardDeclarationFilter.description" class="org.eclipse.cdt.internal.ui.filters.ForwardDeclarationFilter" id="org.eclipse.cdt.ui.COutlinePage.ForwardDeclarationFilter"> </filter> @@ -255,7 +255,7 @@ id="org.eclipse.cdt.ui.AnnotationHover"> </hover> </extension> - + <extension point="org.eclipse.ui.perspectives"> <perspective @@ -574,6 +574,40 @@ %CEditorFontDefinition.description </description> </fontDefinition> + <themeElementCategory + id="org.eclipse.cdt.ui.COutline.presentation" + label="%COutlinePresentation.label" + parentId="org.eclipse.cdt.ui.presentation"> + </themeElementCategory> + <fontDefinition + categoryId="org.eclipse.cdt.ui.COutline.presentation" + defaultsTo="org.eclipse.jface.bannerfont" + id="org.eclipse.cdt.ui.outline.mark.textfont" + label="%COutline.mark.font.label"> + <description> + %COutline.mark.font.description + </description> + </fontDefinition> + <colorDefinition + id="org.eclipse.cdt.ui.outline.mark.textcolor" + categoryId="org.eclipse.cdt.ui.COutline.presentation" + isEditable="true" + label="%COutline.mark.textcolor.label" + value="80,80,80"> + <description> + %COutline.mark.textcolor.description + </description> + </colorDefinition> + <colorDefinition + categoryId="org.eclipse.cdt.ui.COutline.presentation" + id="org.eclipse.cdt.ui.outline.mark.dividercolor" + isEditable="true" + label="%COutline.mark.dividercolor.label" + value="200,200,200"> + <description> + %COutline.mark.dividercolor.description + </description> + </colorDefinition> <fontDefinition label="%BuildConsoleFontDefinition.label" defaultsTo="org.eclipse.jface.textfont" @@ -895,13 +929,13 @@ id="org.eclipse.cdt.ui.overloadedOperatorHighlighting" isEditable="false" label="%Dummy.label" - value="200, 100, 0"> + value="200, 100, 0"> </colorDefinition> <colorDefinition id="org.eclipse.cdt.ui.variablePassedByNonConstReferenceHighlighting" isEditable="false" label="%Dummy.label" - value="200, 100, 150"> + value="200, 100, 150"> </colorDefinition> <theme id="org.eclipse.ui.ide.systemDefault"> @@ -1354,13 +1388,13 @@ id="org.eclipse.cdt.ui.codeformatter"/> <keyword label="%preferenceKeywords.todo" - id="org.eclipse.cdt.ui.todo"/> + id="org.eclipse.cdt.ui.todo"/> <keyword label="%preferenceKeywords.ceditor" - id="org.eclipse.cdt.ui.ceditor"/> + id="org.eclipse.cdt.ui.ceditor"/> <keyword label="%preferenceKeywords.contentassist" - id="org.eclipse.cdt.ui.contentassist"/> + id="org.eclipse.cdt.ui.contentassist"/> <keyword label="%preferenceKeywords.hover" id="org.eclipse.cdt.ui.hover"/> @@ -1372,7 +1406,7 @@ id="org.eclipse.cdt.ui.scalability"/> <keyword label="%preferenceKeywords.syntaxcoloring" - id="org.eclipse.cdt.ui.syntaxcoloring"/> + id="org.eclipse.cdt.ui.syntaxcoloring"/> <keyword label="%preferenceKeywords.templates" id="org.eclipse.cdt.ui.templates"/> @@ -1520,14 +1554,14 @@ </menu> </objectContribution> <!-- project explorer shows IProjects, we need to handle this --> - <objectContribution + <objectContribution id="org.eclipse.cdt.ui.cproject.in.explorer.contrib" objectClass="org.eclipse.core.resources.IProject"> <visibility> <objectState name="projectNature" value="org.eclipse.cdt.core.cnature"/> - </visibility> + </visibility> <action class="org.eclipse.cdt.internal.ui.actions.UpdateUnresolvedIncludesAction" definitionId="org.eclipse.cdt.ui.menu.updateUnresolvedIncludes" @@ -1610,7 +1644,7 @@ label="%QuickFix.label" menubarPath="additions" tooltip="%QuickFix.tooltip"> - </action> + </action> </viewerContribution> <viewerContribution targetID="#ASMEditorRulerContext" @@ -1645,7 +1679,7 @@ name="type" value="org.eclipse.cdt.core.problem"/> </objectContribution> - + <objectContribution adaptable="true" id="org.eclipse.cdt.ui.buildConfigContribution" @@ -1683,7 +1717,7 @@ </menu> </objectContribution> </extension> - + <extension point="org.eclipse.compare.structureCreators"> <structureCreator @@ -1751,6 +1785,47 @@ </menu> </menuContribution> <menuContribution + locationURI="menu:org.eclipse.cdt.ui.prjmenu?before=manage"> + <menu + id="org.eclipse.cdt.ui.workingSets.changeBuildConfigMenu" + label="%BuildConfigMenuAction.label" + tooltip="%BuildConfigAction.tooltip"> + <visibleWhen> + <with + variable="activeContexts"> + <iterate + ifEmpty="false" + operator="or"> + <equals + value="org.eclipse.cdt.ui.buildConfigActionSet"> + </equals> + </iterate> + </with> + </visibleWhen> + <dynamic + class="org.eclipse.cdt.internal.ui.workingsets.ChangeBuildConfigContribution" + id="org.eclipse.cdt.ui.changeBuildConfig"> + </dynamic> + </menu> + <command + commandId="org.eclipse.cdt.ui.menu.manage.configs.command" + label="%ManageConfigAction.label" + style="push"> + <visibleWhen> + <with + variable="activeContexts"> + <iterate + ifEmpty="false" + operator="or"> + <equals + value="org.eclipse.cdt.ui.buildConfigActionSet"> + </equals> + </iterate> + </with> + </visibleWhen> + </command> + </menuContribution> + <menuContribution locationURI="menu:org.eclipse.cdt.ui.prjmenu?before=wrksets"> <menu id="org.eclipse.cdt.ui.workingSets.buildMenu" @@ -1792,6 +1867,23 @@ id="org.eclipse.cdt.ui.activateWorkingSetConfigs"> </dynamic> </menu> + <command + commandId="org.eclipse.cdt.ui.menu.wsselection.command" + label="%wsselection" + style="push"> + <visibleWhen> + <with + variable="activeContexts"> + <iterate + ifEmpty="false" + operator="or"> + <equals + value="org.eclipse.cdt.ui.buildConfigActionSet"> + </equals> + </iterate> + </with> + </visibleWhen> + </command> </menuContribution> </extension> <extension @@ -1814,7 +1906,7 @@ <separator name="typeGroup3"/> <separator name="historyGroup"> - </separator> + </separator> </menu> <!-- reorg group --> <action @@ -1929,7 +2021,7 @@ menubarPath="org.eclipse.jdt.ui.source.menu/generateGroup" id="org.eclipse.cdt.ui.actions.GettersAndSetters" retarget="true"> - </action> + </action> <action definitionId="org.eclipse.cdt.ui.refactor.implement.method" label="%Refactoring.implementMethod.label" @@ -2163,28 +2255,6 @@ style="pulldown" toolbarPath="org.eclipse.ui.workbench.file/build.group" tooltip="%BuildConfigAction.tooltip2"/> - <action - class="org.eclipse.cdt.ui.actions.ManageConfigsAction" - enablesFor="+" - id="org.eclipse.cdt.ui.manageConfigsAction2" - label="%ManageConfigAction.label" - menubarPath="project/org.eclipse.cdt.ui.prjmenu/manage" - /> - <action - class="org.eclipse.cdt.ui.actions.ChangeBuildConfigMenuAction" - enablesFor="+" - id="org.eclipse.cdt.ui.buildConfigMenuAction" - label="%BuildConfigMenuAction.label" - menubarPath="project/org.eclipse.cdt.ui.prjmenu/manage" - style="pulldown" - tooltip="%BuildConfigAction.tooltip"/> - <action - class="org.eclipse.cdt.ui.actions.WorkingSetConfigAction" - id="org.eclipse.cdt.ui.wsselection" - label="%wsselection" - menubarPath="project/org.eclipse.cdt.ui.prjmenu/wrksets" - style="push" - /> </actionSet> <actionSet label="%CElementCreationActionSet.label" @@ -2289,26 +2359,26 @@ description="%asmEditor.description" id="org.eclipse.cdt.ui.asmEditorScope"> </context> - <context - name="%cViewScope.name" - description="%cViewScope.description" - id="org.eclipse.cdt.ui.cViewScope" + <context + name="%cViewScope.name" + description="%cViewScope.description" + id="org.eclipse.cdt.ui.cViewScope" parentId="org.eclipse.ui.contexts.window" /> <context - name="%macroExpansionHoverScope.name" - description="%macroExpansionHoverScope.description" - id="org.eclipse.cdt.ui.macroExpansionHoverScope" + name="%macroExpansionHoverScope.name" + description="%macroExpansionHoverScope.description" + id="org.eclipse.cdt.ui.macroExpansionHoverScope" parentId="org.eclipse.ui.contexts.dialogAndWindow" /> </extension> <extension point="org.eclipse.ui.bindings"> - + <!-- win32: M1=CTRL, M2=SHIFT, M3=ALT, M4=- carbon: M1=COMMAND, M2=SHIFT, M3=ALT, M4=CTRL --> - -<!-- edit --> + +<!-- edit --> <key sequence="M2+M3+ARROW_UP" contextId="org.eclipse.cdt.ui.cEditorScope" @@ -2330,56 +2400,56 @@ commandId="org.eclipse.cdt.ui.edit.text.c.select.last" schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/> <key - platform="carbon" + platform="carbon" sequence="M2+M3+ARROW_UP" contextId="org.eclipse.cdt.ui.cEditorScope" commandId="" schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/> <key - platform="carbon" + platform="carbon" sequence="M2+M3+ARROW_RIGHT" contextId="org.eclipse.cdt.ui.cEditorScope" commandId="" schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/> <key - platform="carbon" + platform="carbon" sequence="M2+M3+ARROW_LEFT" contextId="org.eclipse.cdt.ui.cEditorScope" commandId="" schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/> <key - platform="carbon" + platform="carbon" sequence="M2+M3+ARROW_DOWN" contextId="org.eclipse.cdt.ui.cEditorScope" commandId="" schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/> <key - platform="carbon" + platform="carbon" sequence="CTRL+SHIFT+PAGE_UP" contextId="org.eclipse.cdt.ui.cEditorScope" commandId="org.eclipse.cdt.ui.edit.text.c.select.enclosing" schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/> <key - platform="carbon" + platform="carbon" sequence="CTRL+SHIFT+END" contextId="org.eclipse.cdt.ui.cEditorScope" commandId="org.eclipse.cdt.ui.edit.text.c.select.next" schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/> <key - platform="carbon" + platform="carbon" sequence="CTRL+SHIFT+HOME" contextId="org.eclipse.cdt.ui.cEditorScope" commandId="org.eclipse.cdt.ui.edit.text.c.select.previous" schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/> <key - platform="carbon" + platform="carbon" sequence="CTRL+SHIFT+PAGE_DOWN" contextId="org.eclipse.cdt.ui.cEditorScope" commandId="org.eclipse.cdt.ui.edit.text.c.select.last" - schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/> + schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/> + - <key sequence="M2+M3+S" commandId="org.eclipse.cdt.ui.edit.text.c.source.quickMenu" @@ -2401,12 +2471,12 @@ sequence="M1+M2+F" schemeId="org.eclipse.ui.defaultAcceleratorConfiguration" contextId="org.eclipse.cdt.ui.cEditorScope" - commandId="org.eclipse.cdt.ui.edit.text.c.format"/> + commandId="org.eclipse.cdt.ui.edit.text.c.format"/> <key sequence="M2+TAB" schemeId="org.eclipse.ui.defaultAcceleratorConfiguration" contextId="org.eclipse.cdt.ui.cEditorScope" - commandId="org.eclipse.ui.edit.text.shiftLeft"/> + commandId="org.eclipse.ui.edit.text.shiftLeft"/> <key sequence="M1+M2+C" schemeId="org.eclipse.ui.defaultAcceleratorConfiguration" @@ -2436,7 +2506,7 @@ sequence="M1+M2+\" contextId="org.eclipse.cdt.ui.cEditorScope" commandId="org.eclipse.cdt.ui.edit.text.c.remove.block.comment" - schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/> + schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/> <key sequence="M1+I" contextId="org.eclipse.cdt.ui.cEditorScope" @@ -2451,7 +2521,7 @@ sequence="M2+M3+Z" contextId="org.eclipse.cdt.ui.cEditorScope" commandId="org.eclipse.cdt.ui.edit.text.c.surround.with.quickMenu" - schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/> + schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/> <key platform="carbon" sequence="M2+M3+Z" @@ -2462,7 +2532,7 @@ sequence="COMMAND+ALT+Z" contextId="org.eclipse.cdt.ui.cEditorScope" commandId="org.eclipse.cdt.ui.edit.text.c.surround.with.quickMenu" - schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/> + schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/> <key sequence="M1+M3+H" contextId="org.eclipse.cdt.ui.cEditorScope" @@ -2806,14 +2876,14 @@ <!-- MICROSOFT VISUAL STUDIO KEY SHORTCUTS --> <!-- =================================================================================== --> <!-- C/C++ Source Keys --> - + <!-- MSVS Edit.GoToDefinition --> <key sequence="F12" commandId="org.eclipse.cdt.ui.edit.opendecl" contextId="org.eclipse.cdt.ui.cEditorScope" schemeId="org.eclipse.cdt.ui.visualstudio"/> - + <!-- Edit Keys --> <key @@ -2821,7 +2891,7 @@ commandId="org.eclipse.ui.edit.findNext" contextId="org.eclipse.ui.textEditorScope" schemeId="org.eclipse.cdt.ui.visualstudio"/> - + <key sequence="M2+F3" commandId="org.eclipse.ui.edit.findPrevious" @@ -2839,29 +2909,29 @@ commandId="org.eclipse.search.ui.openSearchDialog" schemeId="org.eclipse.cdt.ui.visualstudio"/> - <!-- File Keys --> + <!-- File Keys --> <!-- Help Keys --> <!-- MakeFile Source Keys --> - + <!-- Navigate Keys --> <key - sequence="M1+F2" + sequence="M1+F2" commandId="org.eclipse.ui.edit.addBookmark" schemeId="org.eclipse.cdt.ui.visualstudio"/> <key - sequence="M2+F2" + sequence="M2+F2" commandId="org.eclipse.cdt.ui.edit.text.c.goto.next.bookmark" contextId="org.eclipse.cdt.ui.cEditorScope" schemeId="org.eclipse.cdt.ui.visualstudio"/> <key - sequence="M1+G" + sequence="M1+G" commandId="org.eclipse.ui.edit.text.goto.line" schemeId="org.eclipse.cdt.ui.visualstudio"/> - + <!-- Project Keys --> - + <!-- MSVS RebuildSolution --> <!-- THERE IS CURRENTLY NO REBUILD <key @@ -2869,39 +2939,39 @@ commandId="org.eclipse.ui.project.rebuildProject" schemeId="org.eclipse.cdt.ui.visualstudio"/> --> - <!-- MSVS NewProject --> + <!-- MSVS NewProject --> <key sequence="M1+M2+N" commandId="org.eclipse.ui.newWizard" schemeId="org.eclipse.cdt.ui.visualstudio"/> - - <!-- Run/Debug Keys --> + + <!-- Run/Debug Keys --> <!-- MSVS Start --> <key sequence="M1+F5" commandId="org.eclipse.debug.ui.commands.RunLast" schemeId="org.eclipse.cdt.ui.visualstudio"/> - + <!-- MSVS StartWithoutDebugging --> <key sequence="F5" commandId="org.eclipse.debug.ui.commands.DebugLast" schemeId="org.eclipse.cdt.ui.visualstudio"/> - + <!-- MSVS StepInto --> <key sequence="F11" commandId="org.eclipse.debug.ui.commands.StepInto" contextId="org.eclipse.debug.ui.debugging" schemeId="org.eclipse.cdt.ui.visualstudio"/> - + <!-- MSVS StepOver --> <key sequence="F10" commandId="org.eclipse.debug.ui.commands.StepOver" contextId="org.eclipse.debug.ui.debugging" schemeId="org.eclipse.cdt.ui.visualstudio"/> - + <!-- MSVS StepReturn --> <key sequence="M2+F11" @@ -2919,13 +2989,13 @@ sequence="F9" commandId="org.eclipse.debug.ui.commands.ToggleBreakpoint" schemeId="org.eclipse.cdt.ui.visualstudio"/> - + <!-- MSVS RunToCursor --> <key sequence="M1+F10" commandId="org.eclipse.debug.ui.commands.RunToLine" schemeId="org.eclipse.cdt.ui.visualstudio"/> - + <!-- MSVS Breakpoints --> <key commandId="org.eclipse.ui.views.showView" @@ -2939,24 +3009,24 @@ <!-- Search Keys --> <!-- Text Editing Keys --> - - <key + + <key sequence="M1+ARROW_LEFT" commandId="org.eclipse.ui.edit.text.goto.wordPrevious" contextId="org.eclipse.ui.textEditorScope" schemeId="org.eclipse.cdt.ui.visualstudio"/> - + <key sequence="M1+ARROW_RIGHT" commandId="org.eclipse.ui.edit.text.goto.wordNext" contextId="org.eclipse.ui.textEditorScope" schemeId="org.eclipse.cdt.ui.visualstudio"/> - + <!-- View Keys --> <!-- Views Keys --> <!-- Window Keys --> - - <!-- MSVC Window NextDocumentWindow --> + + <!-- MSVC Window NextDocumentWindow --> <key sequence="M1+TAB" commandId="org.eclipse.ui.window.nextEditor" @@ -2967,7 +3037,7 @@ sequence="M1+M2+TAB" commandId="org.eclipse.ui.window.previousEditor" schemeId="org.eclipse.cdt.ui.visualstudio"/> - + </extension> <extension point="org.eclipse.ui.commands"> @@ -3207,7 +3277,7 @@ name="%refactoringExtractLocalVariable.label"/> <command categoryId="org.eclipse.cdt.ui.category.refactoring" - id="org.eclipse.cdt.ui.refactor.hide.method" + id="org.eclipse.cdt.ui.refactor.hide.method" name="%refactoringHideMethod.label"/> <command name="%ActionDefinition.renameElement.name" @@ -3303,33 +3373,33 @@ <extension point="org.eclipse.ui.actionSetPartAssociations"> - <actionSetPartAssociation + <actionSetPartAssociation targetID="org.eclipse.cdt.ui.SearchActionSet"> <part id="org.eclipse.cdt.ui.CView"/> <part id="org.eclipse.cdt.ui.editor.CEditor"/> <part id="org.eclipse.search.SearchResultView"/> </actionSetPartAssociation> - <actionSetPartAssociation + <actionSetPartAssociation targetID="org.eclipse.cdt.ui.CodingActionSet"> <part id="org.eclipse.cdt.ui.editor.CEditor"/> <part id="org.eclipse.cdt.ui.CView"/> </actionSetPartAssociation> - <actionSetPartAssociation + <actionSetPartAssociation targetID="org.eclipse.cdt.ui.OpenActionSet"> <part id="org.eclipse.cdt.ui.editor.CEditor"/> </actionSetPartAssociation> - <actionSetPartAssociation + <actionSetPartAssociation targetID="org.eclipse.cdt.ui.NavigationActionSet"> <part id="org.eclipse.cdt.ui.editor.CEditor"/> </actionSetPartAssociation> <actionSetPartAssociation targetID="org.eclipse.ui.edit.text.actionSet.annotationNavigation"> <part id="org.eclipse.cdt.ui.editor.CEditor"/> - </actionSetPartAssociation> + </actionSetPartAssociation> <actionSetPartAssociation targetID="org.eclipse.cdt.ui.text.c.actionSet.presentation"> <part id="org.eclipse.cdt.ui.editor.CEditor"/> - </actionSetPartAssociation> + </actionSetPartAssociation> </extension> <extension point="org.eclipse.cdt.ui.BinaryParserPage"> @@ -3480,7 +3550,7 @@ id="org.eclipse.cdt.ui.pdomSearchViewPage" searchResultClass="org.eclipse.cdt.internal.ui.search.CSearchResult"/> </extension> - + <extension point="org.eclipse.ui.propertyPages"> <page @@ -3491,19 +3561,19 @@ <filter name="projectNature" value="org.eclipse.cdt.core.cnature"> - </filter> + </filter> <enabledWhen> <or> <adapt type="org.eclipse.core.resources.IProject"/> - + <instanceof value="org.eclipse.core.resources.IFolder"/> <instanceof value="org.eclipse.cdt.core.model.ICContainer"/> <instanceof value="org.eclipse.core.resources.IFile"/> <instanceof value="org.eclipse.cdt.core.model.ITranslationUnit"/> - </or> + </or> </enabledWhen> - </page> + </page> <page name="%CDTIndexerProperty.name" @@ -3514,7 +3584,7 @@ <adapt type="org.eclipse.core.resources.IProject"> <test property="org.eclipse.core.resources.projectNature" value="org.eclipse.cdt.core.cnature"/> - </adapt> + </adapt> </enabledWhen> </page> <page @@ -3526,7 +3596,7 @@ <adapt type="org.eclipse.core.resources.IProject"> <test property="org.eclipse.core.resources.projectNature" value="org.eclipse.cdt.core.cnature"/> - </adapt> + </adapt> </enabledWhen> </page> <page @@ -3538,7 +3608,7 @@ <adapt type="org.eclipse.core.resources.IProject"> <test property="org.eclipse.core.resources.projectNature" value="org.eclipse.cdt.core.cnature"/> - </adapt> + </adapt> </enabledWhen> </page> <page @@ -3550,7 +3620,7 @@ <adapt type="org.eclipse.core.resources.IProject"> <test property="org.eclipse.core.resources.projectNature" value="org.eclipse.cdt.core.cnature"/> - </adapt> + </adapt> </enabledWhen> </page> <page @@ -3578,7 +3648,7 @@ <adapt type="org.eclipse.core.resources.IProject"> <test property="org.eclipse.core.resources.projectNature" value="org.eclipse.cdt.core.cnature"/> - </adapt> + </adapt> </enabledWhen> </page> <page @@ -3672,7 +3742,7 @@ point="org.eclipse.core.runtime.preferences"> <initializer class="org.eclipse.cdt.ui.CUIPreferenceInitializer"/> </extension> - + <!-- Default folding --> <extension point= "org.eclipse.cdt.ui.foldingStructureProviders"> @@ -3787,7 +3857,7 @@ <partition type="__c_preprocessor"/> </completionProposalComputer> </extension> - + <extension id="KeywordCompletionProposalComputer" point="org.eclipse.cdt.ui.completionProposalComputer"> @@ -3802,7 +3872,7 @@ <extension point="org.eclipse.cdt.ui.completionProposalComputer" id="TemplateCompletionProposalComputer"> - <completionProposalComputer + <completionProposalComputer class="org.eclipse.cdt.internal.ui.text.contentassist.TemplateCompletionProposalComputer" categoryId="org.eclipse.cdt.ui.templateProposalCategory"> <partition type="__dftl_partition_content_type"/> @@ -3835,7 +3905,7 @@ <partition type="__c_preprocessor"/> </completionProposalComputer> </extension> - + <!-- the parameterized content assist action and keybindings for our contributed computers --> <extension point="org.eclipse.ui.commands"> @@ -3916,7 +3986,7 @@ overrides="org.eclipse.ui.navigator.resources.OpenActions"> <enablement> <or> - <instanceof value="org.eclipse.cdt.core.model.ICElement" /> + <instanceof value="org.eclipse.cdt.core.model.ICElement" /> <and> <instanceof value="org.eclipse.core.resources.IProject"/> <test property="org.eclipse.core.resources.projectNature" @@ -3931,7 +4001,7 @@ id="org.eclipse.cdt.ui.navigator.actions.build"> <enablement> <or> - <instanceof value="org.eclipse.cdt.core.model.ICElement" /> + <instanceof value="org.eclipse.cdt.core.model.ICElement" /> <and> <instanceof value="org.eclipse.core.resources.IProject"/> <test property="org.eclipse.core.resources.projectNature" @@ -3980,7 +4050,7 @@ overrides="org.eclipse.ui.navigator.resources.actions.RefactorActions"> <enablement> <or> - <instanceof value="org.eclipse.cdt.core.model.ICElement" /> + <instanceof value="org.eclipse.cdt.core.model.ICElement" /> <and> <instanceof value="org.eclipse.core.resources.IResource" /> <test property="org.eclipse.core.resources.projectNature" @@ -4001,7 +4071,7 @@ value="org.eclipse.cdt.ui.CPerspective"> </equals> </with> - <instanceof value="org.eclipse.cdt.core.model.ICElement" /> + <instanceof value="org.eclipse.cdt.core.model.ICElement" /> <and> <instanceof value="org.eclipse.core.resources.IProject"/> <test property="org.eclipse.core.resources.projectNature" @@ -4017,7 +4087,7 @@ wizardId="org.eclipse.cdt.ui.wizards.NewSourceFileCreationWizard"> <enablement> <or> - <instanceof value="org.eclipse.cdt.core.model.ICElement" /> + <instanceof value="org.eclipse.cdt.core.model.ICElement" /> <and> <instanceof value="org.eclipse.core.resources.IProject"/> <test property="org.eclipse.core.resources.projectNature" @@ -4033,7 +4103,7 @@ wizardId="org.eclipse.cdt.ui.wizards.NewHeaderFileCreationWizard"> <enablement> <or> - <instanceof value="org.eclipse.cdt.core.model.ICElement" /> + <instanceof value="org.eclipse.cdt.core.model.ICElement" /> <and> <instanceof value="org.eclipse.core.resources.IProject"/> <test property="org.eclipse.core.resources.projectNature" @@ -4049,7 +4119,7 @@ wizardId="org.eclipse.cdt.ui.wizards.NewSourceFolderCreationWizard"> <enablement> <or> - <instanceof value="org.eclipse.cdt.core.model.ICElement" /> + <instanceof value="org.eclipse.cdt.core.model.ICElement" /> <and> <instanceof value="org.eclipse.core.resources.IContainer"/> <test property="org.eclipse.core.resources.projectNature" @@ -4065,7 +4135,7 @@ wizardId="org.eclipse.cdt.ui.wizards.NewClassCreationWizard"> <enablement> <or> - <instanceof value="org.eclipse.cdt.core.model.ICElement" /> + <instanceof value="org.eclipse.cdt.core.model.ICElement" /> <and> <instanceof value="org.eclipse.core.resources.IProject"/> <test property="org.eclipse.core.resources.projectNature" @@ -4080,7 +4150,7 @@ wizardId="org.eclipse.cdt.ui.wizards.NewFileCreationWizard"> <enablement> <or> - <instanceof value="org.eclipse.cdt.core.model.ICElement" /> + <instanceof value="org.eclipse.cdt.core.model.ICElement" /> <and> <instanceof value="org.eclipse.core.resources.IContainer"/> <test property="org.eclipse.core.resources.projectNature" @@ -4174,7 +4244,7 @@ </selectionEnablement> </linkHelper> </extension> - + <extension point="org.eclipse.ui.navigator.viewer"> <viewerContentBinding viewerId="org.eclipse.ui.navigator.ProjectExplorer"> @@ -4221,8 +4291,20 @@ namespace="org.eclipse.cdt.ui" properties="hasCProjects" type="org.eclipse.ui.IWorkingSet"/> + <propertyTester + class="org.eclipse.cdt.internal.ui.workingsets.NonEmptyWorkingSetPropertyTester" + id="org.eclipse.cdt.ui.nonEmptyWorkingSetPropertyTester" + namespace="org.eclipse.cdt.ui" + properties="hasNonEmptyWorkingSet" + type="java.lang.Object"/> + <propertyTester + class="org.eclipse.cdt.internal.ui.workingsets.HasManagedCdtProjectSelection" + id="org.eclipse.cdt.ui.hasManagedCdtProjectSelection" + namespace="org.eclipse.cdt.ui" + properties="hasManagedCdtProjectSelection" + type="java.util.Collection"/> </extension> - + <extension point="org.eclipse.ui.exportWizards"> <category @@ -4302,7 +4384,7 @@ id="org.eclipse.cdt.ui.provider1"> </provider> </extension> - + <extension point="org.eclipse.cdt.ui.DocCommentOwner"> <owner @@ -4493,7 +4575,7 @@ <enabledWhen> <adapt type="org.eclipse.ui.IWorkingSet"> <test property="org.eclipse.cdt.ui.hasCProjects"/> - </adapt> + </adapt> </enabledWhen> </page> </extension> @@ -4578,7 +4660,7 @@ <handler class="org.eclipse.ui.internal.handlers.WidgetMethodHandler:undo" commandId="org.eclipse.ui.edit.undo"> - <activeWhen> + <activeWhen> <with variable="activeFocusControlId"> <equals value="org.eclipse.cdt.ui.FileListControl"/> </with> @@ -4587,7 +4669,7 @@ <handler class="org.eclipse.ui.internal.handlers.WidgetMethodHandler:redo" commandId="org.eclipse.ui.edit.redo"> - <activeWhen> + <activeWhen> <with variable="activeFocusControlId"> <equals value="org.eclipse.cdt.ui.FileListControl"/> </with> @@ -4596,7 +4678,7 @@ <handler class="org.eclipse.ui.internal.handlers.WidgetMethodHandler:delete" commandId="org.eclipse.ui.edit.delete"> - <activeWhen> + <activeWhen> <with variable="activeFocusControlId"> <equals value="org.eclipse.cdt.ui.FileListControl"/> </with> @@ -4693,6 +4775,16 @@ categoryId="org.eclipse.ui.category.project" id="org.eclipse.cdt.ui.menu.createParserLog"> </command> + <command + name="%wsselection.command.name" + categoryId="org.eclipse.ui.category.project" + id="org.eclipse.cdt.ui.menu.wsselection.command"> + </command> + <command + name="%ManageConfigs.command.name" + categoryId="org.eclipse.ui.category.project" + id="org.eclipse.cdt.ui.menu.manage.configs.command"> + </command> </extension> <extension point="org.eclipse.ui.handlers"> @@ -4720,6 +4812,24 @@ class="org.eclipse.cdt.internal.ui.actions.CreateParserLogHandler" commandId="org.eclipse.cdt.ui.menu.createParserLog"> </handler> + <handler + class="org.eclipse.cdt.internal.ui.actions.WorkingSetConfigHandler" + commandId="org.eclipse.cdt.ui.menu.wsselection.command"> + <enabledWhen> + <test + property="org.eclipse.cdt.ui.hasNonEmptyWorkingSet"> + </test> + </enabledWhen> + </handler> + <handler + class="org.eclipse.cdt.internal.ui.actions.ManageConfigsHandler" + commandId="org.eclipse.cdt.ui.menu.manage.configs.command"> + <enabledWhen> + <test + property="org.eclipse.cdt.ui.hasManagedCdtProjectSelection"> + </test> + </enabledWhen> + </handler> </extension> <extension point="org.eclipse.ui.menus"> @@ -4921,7 +5031,7 @@ <key name="content_assist_parameters_background"/> <key name="content_assist_parameters_foreground"/> <key name="sourceHoverBackgroundColor"/> - <key name="sourceHoverBackgroundColor.SystemDefault"/> + <key name="sourceHoverBackgroundColor.SystemDefault"/> <key name="org.eclipse.cdt.ui.editors.textfont"/> <key name="org.eclipse.cdt.ui.editor.showSegments"/> <key name="CEditor.ShowTemporaryProblem"/> @@ -4992,7 +5102,7 @@ </entry> </mapping> <description> - %transfer.EditorBehavior.description + %transfer.EditorBehavior.description </description> </transfer> <transfer @@ -5020,7 +5130,7 @@ </entry> </mapping> <description> - %transfer.CodeStyle.description + %transfer.CodeStyle.description </description> </transfer> 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/corext/fix/LinkedProposalModel.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/fix/LinkedProposalModel.java index 087be3a3a59..b15588d664c 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/fix/LinkedProposalModel.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/fix/LinkedProposalModel.java @@ -49,7 +49,7 @@ public class LinkedProposalModel { public Iterator<LinkedProposalPositionGroup> getPositionGroupIterator() { if (fPositionGroups == null) { - return new Iterator<LinkedProposalPositionGroup>() { + return new Iterator<>() { @Override public boolean hasNext() { return false; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BaseCElementContentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BaseCElementContentProvider.java index cc92fdd0203..c088f2bfece 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BaseCElementContentProvider.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BaseCElementContentProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2015 IBM Corporation and others. + * Copyright (c) 2005, 2021 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -15,10 +15,14 @@ package org.eclipse.cdt.internal.ui; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.HashMap; +import java.util.LinkedList; import java.util.List; +import java.util.ListIterator; import java.util.Map; +import java.util.function.BooleanSupplier; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.model.CModelException; @@ -37,10 +41,12 @@ import org.eclipse.cdt.core.model.IMacro; import org.eclipse.cdt.core.model.IMember; import org.eclipse.cdt.core.model.INamespace; import org.eclipse.cdt.core.model.IParent; +import org.eclipse.cdt.core.model.IPragma; import org.eclipse.cdt.core.model.ISourceReference; import org.eclipse.cdt.core.model.ISourceRoot; import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.model.IWorkingCopy; +import org.eclipse.cdt.internal.ui.cview.DividerLine; import org.eclipse.cdt.ui.CDTUITools; import org.eclipse.cdt.ui.CElementGrouping; import org.eclipse.cdt.ui.IncludesGrouping; @@ -50,6 +56,7 @@ import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.Viewer; @@ -85,14 +92,29 @@ public class BaseCElementContentProvider implements ITreeContentProvider { protected boolean fNamespacesGrouping = false; protected boolean fMemberGrouping = false; protected boolean fMacroGrouping = false; + protected boolean fProvidePragmaMarks = false; + + private BooleanSupplier fIsSorted; public BaseCElementContentProvider() { - this(false, false); + this(false, false, false, () -> false); } - public BaseCElementContentProvider(boolean provideMembers, boolean provideWorkingCopy) { + /** + * + * @param provideMembers + * @param provideWorkingCopy + * @param providePragmaMarks Include {@link PragmaMark} and its {@link DividerLine}s + * @param isSorted is a non-<code>null</code> supplier that returns true if the content is sorted, this is used + * to remove {@link DividerLine}s when sorted + */ + public BaseCElementContentProvider(boolean provideMembers, boolean provideWorkingCopy, boolean providePragmaMarks, + BooleanSupplier isSorted) { + Assert.isNotNull(isSorted); fProvideMembers = provideMembers; fProvideWorkingCopy = provideWorkingCopy; + fProvidePragmaMarks = providePragmaMarks; + fIsSorted = isSorted; } /** @@ -187,6 +209,21 @@ public class BaseCElementContentProvider implements ITreeContentProvider { fMacroGrouping = enable; } + /** + * @return whether hiding pragma mark is enabled + */ + public boolean isHidePragmaMarkEnabled() { + return !fProvidePragmaMarks; + } + + /** + * Enable/disable hiding pragma mark + * @param enable + */ + public void setHidePragmaMark(boolean enable) { + fProvidePragmaMarks = !enable; + } + /* (non-Cdoc) * Method declared on IContentProvider. */ @@ -452,6 +489,7 @@ public class BaseCElementContentProvider implements ITreeContentProvider { protected Object[] getTranslationUnitChildren(ITranslationUnit unit) throws CModelException { Object[] children = unit.getChildren(); + children = filterAndTransformPragmas(children); if (fIncludesGrouping) { boolean hasInclude = false; ArrayList<Object> list = new ArrayList<>(children.length); @@ -538,6 +576,42 @@ public class BaseCElementContentProvider implements ITreeContentProvider { return children; } + /** + * Filter and transform pragma elements in the list + * @param children the list of objects + * @return a new list of objects + */ + private Object[] filterAndTransformPragmas(Object[] children) { + List<Object> list = new LinkedList<>(Arrays.asList(children)); + boolean isSorted = fIsSorted.getAsBoolean(); + for (ListIterator<Object> iterator = list.listIterator(); iterator.hasNext();) { + Object object = iterator.next(); + if (object instanceof IPragma) { + IPragma pragma = (IPragma) object; + // remove the pragma + iterator.remove(); + if (!fProvidePragmaMarks) { + continue; + } + + pragma.getPragmaMarkInfo().ifPresent(info -> { + if (!isSorted && info.isDividerBeforeMark()) { + iterator.add(new DividerLine(pragma)); + } + if (!info.getMarkName().isEmpty()) { + // Add the pragma back in if the mark has something to display + iterator.add(pragma); + } + if (!isSorted && info.isDividerAfterMark()) { + iterator.add(new DividerLine(pragma)); + } + }); + } + } + + return list.toArray(); + } + protected Object[] getNamespaceChildren(IParent element) throws CModelException { Object[] children = element.getChildren(); if (fMemberGrouping) { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java index a69660fcbd9..85e1a497857 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java @@ -378,6 +378,7 @@ public class CPluginImages { public static final String IMG_MENU_SHIFT_LEFT = NAME_PREFIX + "shift_l_edit.gif"; //$NON-NLS-1$ public static final String IMG_MENU_OPEN_INCLUDE = NAME_PREFIX + "open_include.gif"; //$NON-NLS-1$ public static final String IMG_MENU_GROUP_INCLUDE = NAME_PREFIX + "group_include.gif"; //$NON-NLS-1$ + public static final String IMG_MENU_HIDE_PRAGMA_MARKS = NAME_PREFIX + "outline_mark.png"; //$NON-NLS-1$ public static final String IMG_MENU_SEGMENT_EDIT = NAME_PREFIX + "segment_edit.gif"; //$NON-NLS-1$ public static final String IMG_MENU_CODE_ASSIST = NAME_PREFIX + "metharg_obj.gif"; //$NON-NLS-1$ public static final String IMG_MENU_COLLAPSE_ALL = NAME_PREFIX + "collapseall.png"; //$NON-NLS-1$ diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.java index 862faf82193..8617f1b40cd 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.java @@ -111,6 +111,9 @@ public class ActionMessages extends NLS { public static String CopyQualifiedNameAction_ActionName; public static String CopyQualifiedNameAction_ErrorTitle; public static String CopyQualifiedNameAction_NoElementToQualify; + public static String HidePragmaMarks_label; + public static String HidePragmaMarks_tooltip; + public static String HidePragmaMarks_description; static { // Initialize resource bundle. diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.properties index baeddfc01b3..60f94783464 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.properties +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.properties @@ -77,6 +77,10 @@ MacroGroupingAction_label= Group Macros MacroGroupingAction_tooltip= Group macro definitions MacroGroupingAction_description= Group macro definitions +HidePragmaMarks_label=Hide Dividers +HidePragmaMarks_tooltip=Hide Dividers (#pragma mark or #pragma region/endregion) +HidePragmaMarks_description=Hide Dividers (#pragma mark or #pragma region/endregion) + COutlineInformationControl_viewMenu_sort_label=Sort ChangeBuildConfigMenuAction_title=Sorry diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CreateParserLogAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CreateParserLogAction.java index 7f2cd706952..da57db0f6db 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CreateParserLogAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CreateParserLogAction.java @@ -131,7 +131,7 @@ public class CreateParserLogAction implements IObjectActionDelegate { } } - private static final Comparator<String> COMP_INSENSITIVE = new Comparator<String>() { + private static final Comparator<String> COMP_INSENSITIVE = new Comparator<>() { @Override public int compare(String o1, String o2) { return o1.toUpperCase().compareTo(o2.toUpperCase()); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ManageConfigsHandler.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ManageConfigsHandler.java new file mode 100644 index 00000000000..0e6598f7789 --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ManageConfigsHandler.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2020 Simeon Andreev 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: + * Simeon Andreev - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.ui.actions; + +import org.eclipse.cdt.ui.newui.IConfigManager; +import org.eclipse.cdt.ui.newui.ManageConfigSelector; +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.resources.IProject; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.ui.handlers.HandlerUtil; + +/** + * Handler for command which lets to manage (add/remove etc.) build configurations of the project. + */ +public class ManageConfigsHandler extends AbstractHandler { + + public static final String COMMAND_ID = "org.eclipse.cdt.ui.menu.wsselection.command"; //$NON-NLS-1$ + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + IStructuredSelection selection = HandlerUtil.getCurrentStructuredSelection(event); + if (!selection.isEmpty()) { + IProject[] obs = ManageConfigSelector.getProjects(selection.toArray()); + IConfigManager cm = ManageConfigSelector.getManager(obs); + if (cm != null && obs != null) { + cm.manage(obs, true); + } + } + return null; + } +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/WorkingSetConfigHandler.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/WorkingSetConfigHandler.java new file mode 100644 index 00000000000..18ad18ace82 --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/WorkingSetConfigHandler.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright (c) 2020 Simeon Andreev 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: + * Simeon Andreev - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.ui.actions; + +import org.eclipse.cdt.internal.ui.workingsets.WorkingSetConfigurationDialog; +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.IWorkingSet; +import org.eclipse.ui.IWorkingSetManager; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.handlers.HandlerUtil; + +public class WorkingSetConfigHandler extends AbstractHandler { + + public static final String COMMAND_ID = "org.eclipse.cdt.ui.menu.manage.configs.command"; //$NON-NLS-1$ + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + boolean enabled = hasNonEmptyWorksets(); + if (enabled) { + IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event); + new WorkingSetConfigurationDialog(window.getShell()).open(); + } + return null; + } + + private boolean hasNonEmptyWorksets() { + IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager(); + IWorkingSet[] workingSets = workingSetManager.getWorkingSets(); + if (workingSets != null) { + for (IWorkingSet workingSet : workingSets) { + if (!workingSet.isEmpty()) { + return true; + } + } + } + return false; + } + +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BringToTopOnBuild.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BringToTopOnBuild.java new file mode 100644 index 00000000000..046d5f6f985 --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BringToTopOnBuild.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2020, Simeon Andreev 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: + * Simeon Andreev - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.cdt.internal.ui.buildconsole; + +import org.eclipse.cdt.internal.ui.preferences.BuildConsolePreferencePage; +import org.eclipse.cdt.ui.CDTSharedImages; +import org.eclipse.cdt.ui.CUIPlugin; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.preference.IPreferenceStore; + +/** + * Set whether to show the build console on activity. + */ +public class BringToTopOnBuild extends Action { + + public BringToTopOnBuild() { + super(ConsoleMessages.BringToTopOnBuild); + propertyChange(); + setToolTipText(ConsoleMessages.BringToTopOnBuild); + setImageDescriptor(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_BRING_CONSOLE_TO_TOP_ON_BUILD)); + } + + @Override + public void run() { + super.run(); + boolean isSet = isChecked(); + IPreferenceStore store = CUIPlugin.getDefault().getPreferenceStore(); + store.setValue(BuildConsolePreferencePage.PREF_CONSOLE_ON_TOP, isSet); + } + + public void propertyChange() { + boolean isChecked = BuildConsolePreferencePage.isConsoleOnTop(); + setChecked(isChecked); + } + +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleManager.java index c456e9f212c..9e1dc20db17 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleManager.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleManager.java @@ -20,6 +20,7 @@ import java.net.URI; import java.net.URL; import java.util.HashMap; import java.util.Map; +import java.util.concurrent.atomic.AtomicBoolean; import org.eclipse.cdt.core.resources.IConsole; import org.eclipse.cdt.internal.core.LocalProjectScope; @@ -45,6 +46,7 @@ import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IDocumentPartitioner; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; +import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.widgets.Display; @@ -55,6 +57,7 @@ import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PartInitException; import org.eclipse.ui.console.ConsolePlugin; import org.eclipse.ui.console.IConsoleConstants; +import org.eclipse.ui.console.IConsoleListener; import org.eclipse.ui.console.IConsoleView; import org.osgi.service.prefs.Preferences; @@ -114,10 +117,14 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang private IProject fLastProject; + private IConsoleListener fConsoleListener; + private final AtomicBoolean fWasClosed; + /** * Default constructor. */ public BuildConsoleManager() { + fWasClosed = new AtomicBoolean(false); } /** @@ -158,13 +165,14 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang // console page.activate(activePart); } - if (bringToTop && shouldBringToTop(consoleView)) { + boolean shouldBringToTop = shouldBringToTop(consoleView); + if (bringToTop && shouldBringToTop) { page.bringToTop(consoleView); } if (consoleView instanceof IConsoleView) { if (BuildConsole.getCurrentPage() == null) ((IConsoleView) consoleView).display(fConsole); - else + else if (shouldBringToTop) ((IConsoleView) consoleView).display(BuildConsole.getCurrentPage().getConsole()); } } @@ -221,6 +229,7 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang problemInfoBackgroundColor.dispose(); problemHighlightedColor.dispose(); } + ConsolePlugin.getDefault().getConsoleManager().removeConsoleListener(fConsoleListener); ConsolePlugin.getDefault().getConsoleManager() .removeConsoles(new org.eclipse.ui.console.IConsole[] { fConsole }); CUIPlugin.getWorkspace().removeResourceChangeListener(this); @@ -275,12 +284,26 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang errorStream = new BuildConsoleStreamDecorator(); fName = name; fContextMenuId = contextId; + fConsoleListener = new IConsoleListener() { + @Override + public void consolesAdded(org.eclipse.ui.console.IConsole[] consoles) { + // don't care + } + + @Override + public void consolesRemoved(org.eclipse.ui.console.IConsole[] consoles) { + for (org.eclipse.ui.console.IConsole console : consoles) { + if (console == fConsole) { + fWasClosed.set(true); + } + } + } + }; + ConsolePlugin.getDefault().getConsoleManager().addConsoleListener(fConsoleListener); runUI(() -> { - // add console to the Console view fConsole = createBuildConsole(fName, fContextMenuId, iconUrl); - ConsolePlugin.getDefault().getConsoleManager() - .addConsoles(new org.eclipse.ui.console.IConsole[] { fConsole }); + addConsole(); infoStream.setConsole(fConsole); infoColor = createColor(CUIPlugin.getStandardDisplay(), @@ -310,6 +333,20 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang CUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this); } + public void reinitaliazeIfNecessary() { + if (!(this instanceof GlobalBuildConsoleManager)) { + GlobalBuildConsoleManager.staticReinitaliazeIfNecessary(); + } + if (fWasClosed.getAndSet(false)) { + addConsole(); + } + } + + private void addConsole() { + // add console to the Console view + ConsolePlugin.getDefault().getConsoleManager().addConsoles(new org.eclipse.ui.console.IConsole[] { fConsole }); + } + @Override public void propertyChange(PropertyChangeEvent event) { String property = event.getProperty(); @@ -373,7 +410,12 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang if (v == null) return; Display display = Display.getDefault(); - display.asyncExec(() -> v.getTextWidget().redraw()); + display.asyncExec(() -> { + StyledText widget = v.getTextWidget(); + if (widget != null && !widget.isDisposed()) { + widget.redraw(); + } + }); } public IBuildConsoleStreamDecorator getStreamDecorator(int type) throws CoreException { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePage.java index f7de34b83dc..7294300c5c7 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePage.java @@ -83,6 +83,7 @@ import org.eclipse.ui.actions.ActionFactory; import org.eclipse.ui.console.IConsoleConstants; import org.eclipse.ui.console.IConsoleView; import org.eclipse.ui.console.actions.ClearOutputAction; +import org.eclipse.ui.console.actions.CloseConsoleAction; import org.eclipse.ui.console.actions.TextViewerAction; import org.eclipse.ui.console.actions.TextViewerGotoLineAction; import org.eclipse.ui.ide.IDE; @@ -122,7 +123,9 @@ public class BuildConsolePage extends Page private NextErrorAction fNextErrorAction; private PreviousErrorAction fPreviousErrorAction; private ShowErrorAction fShowErrorAction; + private CloseConsoleAction fCloseConsoleAction; private WrapLinesAction fWrapAction; + private BringToTopOnBuild fBringToTopOnBuild; /** * @param view @@ -256,11 +259,15 @@ public class BuildConsolePage extends Page setTabs(CUIPlugin.getDefault().getPreferenceStore() .getInt(BuildConsolePreferencePage.PREF_BUILDCONSOLE_TAB_WIDTH)); } else if (IConsoleConstants.P_BACKGROUND_COLOR.equals(property)) { - fViewer.getTextWidget().setBackground(fConsole.getBackground()); + if (fViewer != null && fViewer.getTextWidget() != null && fConsole != null) { + fViewer.getTextWidget().setBackground(fConsole.getBackground()); + } } else if (property.equals(BuildConsolePreferencePage.PREF_BUILDCONSOLE_WRAP_LINES) || property.equals(BuildConsolePreferencePage.PREF_BUILDCONSOLE_LINES) || property.equals(BuildConsolePreferencePage.PREF_BUILDCONSOLE_WRAP_LINES_MAX)) { fWrapAction.propertyChange(); + } else if (property.equals(BuildConsolePreferencePage.PREF_CONSOLE_ON_TOP)) { + fBringToTopOnBuild.propertyChange(); } } @@ -272,6 +279,8 @@ public class BuildConsolePage extends Page fNextErrorAction = new NextErrorAction(this); fPreviousErrorAction = new PreviousErrorAction(this); fShowErrorAction = new ShowErrorAction(this); + fBringToTopOnBuild = new BringToTopOnBuild(); + fCloseConsoleAction = new CloseConsoleAction(this.fConsole); fSaveLogAction = new CopyBuildLogAction(this); getViewer().setAutoScroll(!fIsLocked); @@ -332,6 +341,9 @@ public class BuildConsolePage extends Page mgr.appendToGroup(IConsoleConstants.OUTPUT_GROUP, fScrollLockAction); mgr.appendToGroup(IConsoleConstants.OUTPUT_GROUP, fWrapAction); mgr.appendToGroup(IConsoleConstants.OUTPUT_GROUP, fClearOutputAction); + mgr.appendToGroup(IConsoleConstants.OUTPUT_GROUP, fBringToTopOnBuild); + mgr.appendToGroup(IConsoleConstants.LAUNCH_GROUP, fCloseConsoleAction); + mgr.appendToGroup(IConsoleConstants.LAUNCH_GROUP, new Separator()); } protected BuildConsoleViewer getViewer() { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ConsoleMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ConsoleMessages.java index 4d8f1570019..8fc3eaaf1ad 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ConsoleMessages.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ConsoleMessages.java @@ -49,6 +49,7 @@ public final class ConsoleMessages extends NLS { public static String CopyLog_UnableToAccess; public static String CopyLog_UnavailableLog; public static String WrapLinesAction_WrapLines; + public static String BringToTopOnBuild; static { NLS.initializeMessages(BUNDLE_NAME, ConsoleMessages.class); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ConsoleMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ConsoleMessages.properties index 9dc8cd7c03b..2e848515039 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ConsoleMessages.properties +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ConsoleMessages.properties @@ -26,11 +26,11 @@ BuildConsolePage_Select__All_Ctrl_A_12=Select &All@Ctrl+A BuildConsolePage_Select_All=Select All CBuildConsole_Console_Must_Be_Started_First=Build Console must be started with a specific project before being used. -CopyLog_ActionTooltip=Copy Build Log +CopyLog_ActionTooltip=Save build log to file CopyLog_BuildNotLogged=No build was logged. Build the project or/and check the Logging page in project properties. CopyLog_ChooseDestination=Choose Log File Destination -CopyLog_ErrorCopyingFile=Error Copying a File -CopyLog_ErrorWhileCopyingLog=Error while copying working log file:\u0020 +CopyLog_ErrorCopyingFile=Error Saving File +CopyLog_ErrorWhileCopyingLog=Error while saving working log file:\u0020 CopyLog_InvalidDestination=Destination is not valid:\u0020 CopyLog_LogFileIsNotAvailable=Working log file is not available. CopyLog_UnableToAccess=Unable to access build log at\u0020 @@ -42,3 +42,4 @@ NextErrorAction_Tooltip=Next Error PreviousErrorAction_Tooltip=Previous Error\u0020 ShowErrorAction_Tooltip=Show Error In Editor WrapLinesAction_WrapLines=Wrap Lines +BringToTopOnBuild=Bring console to top when building diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/CopyBuildLogAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/CopyBuildLogAction.java index a66c17f9695..e576db8b085 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/CopyBuildLogAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/CopyBuildLogAction.java @@ -80,7 +80,8 @@ public class CopyBuildLogAction extends Action { } // open file dialog - FileDialog dialog = new FileDialog(shell, SWT.NONE); + FileDialog dialog = new FileDialog(shell, SWT.SAVE); + dialog.setOverwrite(true); dialog.setText(ConsoleMessages.CopyLog_ChooseDestination); String destLocation = dialog.open(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/GlobalBuildConsoleManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/GlobalBuildConsoleManager.java index 6f526dd9221..785779f2948 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/GlobalBuildConsoleManager.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/GlobalBuildConsoleManager.java @@ -82,6 +82,10 @@ public class GlobalBuildConsoleManager extends BuildConsoleManager { getInstance(); } + static void staticReinitaliazeIfNecessary() { + getInstance().reinitaliazeIfNecessary(); + } + /** * Stop the console and deallocate resources allocated during {@link #startup()} */ diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryListAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryListAction.java index 298d3af4b6b..b1542e510d9 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryListAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryListAction.java @@ -51,7 +51,7 @@ public class CHHistoryListAction extends Action { setTitle(CHMessages.CHHistoryListAction_HistoryDialog_title); String[] buttonLabels = new String[] { CHMessages.CHHistoryListAction_Remove_label, }; - IListAdapter<ICElement> adapter = new IListAdapter<ICElement>() { + IListAdapter<ICElement> adapter = new IListAdapter<>() { @Override public void customButtonPressed(ListDialogField<ICElement> field, int index) { doCustomButtonPressed(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHReferenceInfo.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHReferenceInfo.java index b1f22241918..84ae89a9b55 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHReferenceInfo.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHReferenceInfo.java @@ -16,7 +16,7 @@ package org.eclipse.cdt.internal.ui.callhierarchy; import java.util.Comparator; public class CHReferenceInfo { - public static final Comparator<CHReferenceInfo> COMPARE_OFFSET = new Comparator<CHReferenceInfo>() { + public static final Comparator<CHReferenceInfo> COMPARE_OFFSET = new Comparator<>() { @Override public int compare(CHReferenceInfo r1, CHReferenceInfo r2) { return r1.fOffset - r2.fOffset; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/DividerLine.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/DividerLine.java new file mode 100644 index 00000000000..5352dbac6d8 --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/DividerLine.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * 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.ui.cview; + +import org.eclipse.cdt.core.model.ISourceReference; +import org.eclipse.cdt.internal.ui.viewsupport.DecoratingCOutlineLabelProvider; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.ui.model.IWorkbenchAdapter; +import org.eclipse.ui.model.WorkbenchAdapter; + +public class DividerLine extends WorkbenchAdapter implements IAdaptable { + + private ISourceReference element; + + public DividerLine(ISourceReference element) { + this.element = element; + } + + @Override + public <T> T getAdapter(Class<T> adapter) { + if (adapter == IWorkbenchAdapter.class) { + return adapter.cast(this); + } + if (adapter == ISourceReference.class) { + return adapter.cast(element); + } + return null; + } + + /** + * When owner draw is not enabled ( General > Appearance > Use mixed fonts and colors for labels.) + * the custom draw in {@link DecoratingCOutlineLabelProvider} is not used and therefore the + * entry uses the getLabel value to fill the entry. + * @see DecoratingCOutlineLabelProvider + */ + @Override + public String getLabel(Object object) { + return "-".repeat(20); //$NON-NLS-1$ + } +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathIncludeSymbolEntryPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathIncludeSymbolEntryPage.java index 5800b757a28..d74d0851717 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathIncludeSymbolEntryPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathIncludeSymbolEntryPage.java @@ -171,7 +171,7 @@ public class CPathIncludeSymbolEntryPage extends CPathIncludeSymbolEntryBasePage super(CPathEntryMessages.IncludeSymbolEntryPage_title); fContext = context; IncludeSymbolAdapter adapter = new IncludeSymbolAdapter(); - fIncludeSymPathsList = new TreeListDialogField<CPElementGroup>(adapter, buttonLabel, + fIncludeSymPathsList = new TreeListDialogField<>(adapter, buttonLabel, new CPElementLabelProvider(true, false)) { @Override diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathIncludeSymbolEntryPerFilePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathIncludeSymbolEntryPerFilePage.java index e7f851ce9fa..d8196638481 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathIncludeSymbolEntryPerFilePage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathIncludeSymbolEntryPerFilePage.java @@ -218,7 +218,7 @@ public class CPathIncludeSymbolEntryPerFilePage extends CPathIncludeSymbolEntryB super(CPathEntryMessages.IncludeSymbolEntryPage_title); fContext = context; IncludeSymbolAdapter adapter = new IncludeSymbolAdapter(); - fIncludeSymPathsList = new TreeListDialogField<CPElementGroup>(adapter, buttonLabel, + fIncludeSymPathsList = new TreeListDialogField<>(adapter, buttonLabel, new CPElementLabelProvider(true, false)) { @Override diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/AbstractCModelOutlinePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/AbstractCModelOutlinePage.java index 93d0ffcca12..10f31d86dd8 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/AbstractCModelOutlinePage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/AbstractCModelOutlinePage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2015 IBM Corporation and others. + * Copyright (c) 2005, 2021 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -37,7 +37,7 @@ import org.eclipse.cdt.internal.ui.util.ProblemTreeViewer; import org.eclipse.cdt.internal.ui.viewsupport.AppearanceAwareLabelProvider; import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels; import org.eclipse.cdt.internal.ui.viewsupport.CUILabelProvider; -import org.eclipse.cdt.internal.ui.viewsupport.DecoratingCLabelProvider; +import org.eclipse.cdt.internal.ui.viewsupport.DecoratingCOutlineLabelProvider; import org.eclipse.cdt.ui.CDTSharedImages; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.IncludesGrouping; @@ -52,6 +52,7 @@ import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.action.Separator; import org.eclipse.jface.commands.ActionHandler; +import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.text.ITextSelection; import org.eclipse.jface.util.LocalSelectionTransfer; import org.eclipse.jface.util.PropertyChangeEvent; @@ -60,6 +61,7 @@ import org.eclipse.jface.viewers.IDoubleClickListener; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.LabelProviderChangedEvent; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TreeViewer; @@ -108,14 +110,18 @@ public abstract class AbstractCModelOutlinePage extends Page public COutlineLabelProvider(long textFlags, int imageFlags) { super(textFlags, imageFlags); + JFaceResources.getFontRegistry().addListener(this); PreferenceConstants.getPreferenceStore().addPropertyChangeListener(this); + PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry().addListener(this); fSimpleName = PreferenceConstants.getPreferenceStore() .getBoolean(PreferenceConstants.OUTLINE_GROUP_MEMBERS); } @Override public void dispose() { + JFaceResources.getFontRegistry().removeListener(this); PreferenceConstants.getPreferenceStore().removePropertyChangeListener(this); + PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry().removeListener(this); super.dispose(); } @@ -138,6 +144,15 @@ public abstract class AbstractCModelOutlinePage extends Page .getBoolean(PreferenceConstants.OUTLINE_GROUP_MEMBERS); } } + if (PreferenceConstants.OUTLINE_MARK_TEXT_FONT.equals(event.getProperty())) { + fireLabelProviderChanged(new LabelProviderChangedEvent(this)); + } + if (PreferenceConstants.OUTLINE_MARK_TEXT_COLOR.equals(event.getProperty())) { + fireLabelProviderChanged(new LabelProviderChangedEvent(this)); + } + if (PreferenceConstants.OUTLINE_MARK_DIVIDER_COLOR.equals(event.getProperty())) { + fireLabelProviderChanged(new LabelProviderChangedEvent(this)); + } } } @@ -240,6 +255,29 @@ public abstract class AbstractCModelOutlinePage extends Page } } + protected static class HidePragmaMarkAction extends Action { + + public HidePragmaMarkAction(AbstractCModelOutlinePage outlinePage) { + super(ActionMessages.HidePragmaMarks_label); + setDescription(ActionMessages.HidePragmaMarks_description); + setToolTipText(ActionMessages.HidePragmaMarks_tooltip); + CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, CPluginImages.IMG_MENU_HIDE_PRAGMA_MARKS); + + boolean enabled = isHidePragmaMarkEnabled(); + setChecked(enabled); + } + + @Override + public void run() { + PreferenceConstants.getPreferenceStore().setValue(PreferenceConstants.OUTLINE_HIDE_PRAGMA_MARK, + isChecked()); + } + + public boolean isHidePragmaMarkEnabled() { + return PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.OUTLINE_HIDE_PRAGMA_MARK); + } + } + /** * This action toggles whether this C Outline page links * its selection to the active editor. @@ -454,7 +492,7 @@ public abstract class AbstractCModelOutlinePage extends Page protected ProblemTreeViewer createTreeViewer(Composite parent) { ProblemTreeViewer treeViewer = new OutlineTreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); treeViewer.setContentProvider(createContentProvider(treeViewer)); - treeViewer.setLabelProvider(new DecoratingCLabelProvider(createLabelProvider(), true)); + treeViewer.setLabelProvider(new DecoratingCOutlineLabelProvider(createLabelProvider())); treeViewer.setAutoExpandLevel(3); treeViewer.setUseHashlookup(true); treeViewer.addSelectionChangedListener(this); @@ -604,6 +642,8 @@ public abstract class AbstractCModelOutlinePage extends Page fToggleLinkingAction = new ToggleLinkingAction(); menu.add(fToggleLinkingAction); + menu.add(new Separator("dividers.layout")); //$NON-NLS-1$ + menu.add(new HidePragmaMarkAction(this)); menu.add(new Separator("group.layout")); //$NON-NLS-1$ menu.add(new IncludeGroupingAction(this)); menu.add(new MacroGroupingAction(this)); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CContentOutlinerProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CContentOutlinerProvider.java index 9da4664ef72..8bf77fb379b 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CContentOutlinerProvider.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CContentOutlinerProvider.java @@ -71,13 +71,18 @@ public class CContentOutlinerProvider extends BaseCElementContentProvider { * Tree viewer. */ public CContentOutlinerProvider(TreeViewer viewer, IWorkbenchPartSite site) { - super(true, true); + super(true, true, true, () -> isSorted(viewer)); treeViewer = viewer; final IPreferenceStore store = PreferenceConstants.getPreferenceStore(); setIncludesGrouping(store.getBoolean(PreferenceConstants.OUTLINE_GROUP_INCLUDES)); setNamespacesGrouping(store.getBoolean(PreferenceConstants.OUTLINE_GROUP_NAMESPACES)); setMemberGrouping(store.getBoolean(PreferenceConstants.OUTLINE_GROUP_MEMBERS)); setMacroGrouping(store.getBoolean(PreferenceConstants.OUTLINE_GROUP_MACROS)); + setHidePragmaMark(store.getBoolean(PreferenceConstants.OUTLINE_HIDE_PRAGMA_MARK)); + } + + private static boolean isSorted(TreeViewer viewer) { + return viewer != null && viewer.getComparator() != null; } /** @@ -376,6 +381,15 @@ public class CContentOutlinerProvider extends BaseCElementContentProvider { contentUpdated(); } } + } else if (prop.equals(PreferenceConstants.OUTLINE_HIDE_PRAGMA_MARK)) { + Object newValue = event.getNewValue(); + if (newValue instanceof Boolean) { + boolean value = ((Boolean) newValue).booleanValue(); + if (isHidePragmaMarkEnabled() != value) { + setHidePragmaMark(value); + contentUpdated(); + } + } } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/CustomFiltersDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/CustomFiltersDialog.java index 9739122f81f..38279163d44 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/CustomFiltersDialog.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/CustomFiltersDialog.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2016 IBM Corporation and others. + * Copyright (c) 2000, 2021 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -37,8 +37,8 @@ import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.swt.SWT; -import org.eclipse.swt.accessibility.AccessibleAdapter; -import org.eclipse.swt.accessibility.AccessibleEvent; +import org.eclipse.swt.accessibility.ACC; +import org.eclipse.swt.accessibility.AccessibleListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; @@ -133,11 +133,18 @@ public class CustomFiltersDialog extends SelectionDialog { fUserDefinedPatterns.setLayoutData(data); String patterns = convertToString(fPatterns, SEPARATOR); fUserDefinedPatterns.setText(patterns); - + fUserDefinedPatterns.setToolTipText(FilterMessages.CustomFiltersDialog_patternInfo); // Info text final Label info = new Label(group, SWT.LEFT); info.setText(FilterMessages.CustomFiltersDialog_patternInfo); + // add the info text as a description to the pattern field + fUserDefinedPatterns.getAccessible().addAccessibleListener(AccessibleListener.getNameAdapter(e -> { + if (e.childID == ACC.CHILDID_SELF && (e.result == null || e.result.trim().isEmpty())) { + e.result = FilterMessages.CustomFiltersDialog_patternInfo; + } + })); + // Enabling / disabling of pattern group fEnableUserDefinedPatterns.setSelection(fEnablePatterns); fUserDefinedPatterns.setEnabled(fEnablePatterns); @@ -183,12 +190,11 @@ public class CustomFiltersDialog extends SelectionDialog { if (initialSelection != null && !initialSelection.isEmpty()) checkInitialSelections(); - fCheckBoxList.getTable().getAccessible().addAccessibleListener(new AccessibleAdapter() { - @Override - public void getName(AccessibleEvent e) { + fCheckBoxList.getTable().getAccessible().addAccessibleListener(AccessibleListener.getNameAdapter(e -> { + if (e.childID == ACC.CHILDID_SELF && (e.result == null || e.result.trim().isEmpty())) { e.result = FilterMessages.CustomFiltersDialog_filterList_label; } - }); + })); fCheckBoxList.getTable().setToolTipText(FilterMessages.CustomFiltersDialog_filterList_label); // Description diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBConversions.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBConversions.java index c5db6d3a0d2..b0d75d1ae82 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBConversions.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBConversions.java @@ -15,10 +15,14 @@ package org.eclipse.cdt.internal.ui.includebrowser; import java.util.ArrayList; import java.util.Iterator; +import java.util.Optional; import org.eclipse.cdt.core.model.CModelException; +import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.CoreModelUtil; +import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ITranslationUnit; +import org.eclipse.cdt.internal.core.model.TranslationUnit; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.IAdaptable; @@ -75,12 +79,31 @@ public class IBConversions { return StructuredSelection.EMPTY; } + /** + * Returns an optional ITranslationUnit for the given IFile. + * The ITranslationUnit can be outside a source folder. + */ + public static Optional<ITranslationUnit> fileToTU(IFile file) { + ITranslationUnit tu = CoreModelUtil.findTranslationUnit(file); + if (tu == null) { + // Handle header not under a source folder + ICProject cproject = CoreModel.getDefault().create(file.getProject()); + if (cproject != null) { + String contentTypeId = CoreModel.getRegistedContentTypeId(file.getProject(), file.getName()); + if (contentTypeId != null) { + tu = new TranslationUnit(cproject, file, contentTypeId); + } + } + } + return Optional.ofNullable(tu); + } + public static ITranslationUnit objectToTU(Object object) { if (object instanceof ITranslationUnit) { return (ITranslationUnit) object; } if (object instanceof IFile) { - return CoreModelUtil.findTranslationUnit((IFile) object); + return fileToTU((IFile) object).orElse(null); } if (object instanceof IAdaptable) { IAdaptable adaptable = (IAdaptable) object; @@ -90,7 +113,7 @@ public class IBConversions { } IFile file = adaptable.getAdapter(IFile.class); if (file != null) { - return CoreModelUtil.findTranslationUnit(file); + return fileToTU(file).orElse(null); } ILocationProvider locProvider = adaptable.getAdapter(ILocationProvider.class); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBDropTargetListener.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBDropTargetListener.java index d816aa88af2..70e9bff0d4b 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBDropTargetListener.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBDropTargetListener.java @@ -15,8 +15,8 @@ package org.eclipse.cdt.internal.ui.includebrowser; import java.util.Iterator; +import java.util.Optional; -import org.eclipse.cdt.core.model.CoreModelUtil; import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.internal.core.resources.ResourceLookup; import org.eclipse.core.resources.IFile; @@ -125,7 +125,7 @@ public class IBDropTargetListener implements DropTargetListener { String[] filePaths = (String[]) o; for (int i = 0; i < filePaths.length; i++) { String filePath = filePaths[i]; - ITranslationUnit tu = findTranslationUnit( + ITranslationUnit tu = extractFirstTranslationUnit( ResourceLookup.findFilesForLocation(Path.fromOSString(filePath))); if (tu != null) { return tu; @@ -134,18 +134,18 @@ public class IBDropTargetListener implements DropTargetListener { return null; } if (o instanceof IResource[]) { - return findTranslationUnit((IResource[]) o); + return extractFirstTranslationUnit((IResource[]) o); } return null; } - private ITranslationUnit findTranslationUnit(IResource[] files) { + private ITranslationUnit extractFirstTranslationUnit(IResource[] files) { for (int i = 0; i < files.length; i++) { IResource resource = files[i]; if (resource.getType() == IResource.FILE) { - ITranslationUnit tu = CoreModelUtil.findTranslationUnit((IFile) resource); - if (tu != null) { - return tu; + Optional<ITranslationUnit> tu = IBConversions.fileToTU((IFile) resource); + if (tu.isPresent()) { + return tu.get(); } } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBHistoryListAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBHistoryListAction.java index fdb0fcc5b9e..8136b813cc6 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBHistoryListAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBHistoryListAction.java @@ -52,7 +52,7 @@ public class IBHistoryListAction extends Action { setTitle(IBMessages.IBHistoryListAction_HistoryDialog_title); String[] buttonLabels = new String[] { IBMessages.IBHistoryListAction_Remove_label, }; - IListAdapter<ITranslationUnit> adapter = new IListAdapter<ITranslationUnit>() { + IListAdapter<ITranslationUnit> adapter = new IListAdapter<>() { @Override public void customButtonPressed(ListDialogField<ITranslationUnit> field, int index) { doCustomButtonPressed(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsEntriesTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsEntriesTab.java index d1641995898..029214af4d5 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsEntriesTab.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsEntriesTab.java @@ -390,7 +390,9 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab { @Override public void treeExpanded(TreeEvent e) { treeEntries.getDisplay().asyncExec(() -> { - treeCol.pack(); + if (!treeCol.isDisposed()) { + treeCol.pack(); + } }); } }); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AppearancePreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AppearancePreferencePage.java index 23a90c5f6bf..56bc31a791a 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AppearancePreferencePage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AppearancePreferencePage.java @@ -56,6 +56,7 @@ public class AppearancePreferencePage extends PreferencePage implements IWorkben private SelectionButtonDialogField fOutlineGroupMacros; private SelectionButtonDialogField fShowSourceRootsAtTopOfProject; private SelectionButtonDialogField fCViewSortOrderOfExcludedFiles; + private SelectionButtonDialogField fOutlineHidePragmaMarks; public AppearancePreferencePage() { setPreferenceStore(PreferenceConstants.getPreferenceStore()); @@ -102,6 +103,10 @@ public class AppearancePreferencePage extends PreferencePage implements IWorkben fOutlineGroupMacros.setDialogFieldListener(listener); fOutlineGroupMacros.setLabelText(PreferencesMessages.AppearancePreferencePage_outlineGroupMacros_label); + fOutlineHidePragmaMarks = new SelectionButtonDialogField(SWT.CHECK); + fOutlineHidePragmaMarks.setDialogFieldListener(listener); + fOutlineHidePragmaMarks.setLabelText(PreferencesMessages.AppearancePreferencePage_HidePragmaMarks_label); + fCViewGroupMacros = new SelectionButtonDialogField(SWT.CHECK); fCViewGroupMacros.setDialogFieldListener(listener); fCViewGroupMacros.setLabelText(PreferencesMessages.AppearancePreferencePage_cviewGroupMacros_label); @@ -123,6 +128,7 @@ public class AppearancePreferencePage extends PreferencePage implements IWorkben fOutlineGroupNamespaces.setSelection(prefs.getBoolean(PreferenceConstants.OUTLINE_GROUP_NAMESPACES)); fOutlineGroupMembers.setSelection(prefs.getBoolean(PreferenceConstants.OUTLINE_GROUP_MEMBERS)); fOutlineGroupMacros.setSelection(prefs.getBoolean(PreferenceConstants.OUTLINE_GROUP_MACROS)); + fOutlineHidePragmaMarks.setSelection(prefs.getBoolean(PreferenceConstants.OUTLINE_HIDE_PRAGMA_MARK)); boolean showSourceRootsAtTopOfProject = CCorePlugin.showSourceRootsAtTopOfProject(); fShowSourceRootsAtTopOfProject.setSelection(showSourceRootsAtTopOfProject); fCViewSortOrderOfExcludedFiles.setSelection(prefs.getBoolean(PreferenceConstants.SORT_ORDER_OF_EXCLUDED_FILES)); @@ -159,6 +165,7 @@ public class AppearancePreferencePage extends PreferencePage implements IWorkben fOutlineGroupMembers.doFillIntoGrid(result, nColumns); fCViewGroupMacros.doFillIntoGrid(result, nColumns); fOutlineGroupMacros.doFillIntoGrid(result, nColumns); + fOutlineHidePragmaMarks.doFillIntoGrid(result, nColumns); new Separator().doFillIntoGrid(result, nColumns); @@ -216,6 +223,7 @@ public class AppearancePreferencePage extends PreferencePage implements IWorkben prefs.setValue(PreferenceConstants.OUTLINE_GROUP_NAMESPACES, fOutlineGroupNamespaces.isSelected()); prefs.setValue(PreferenceConstants.OUTLINE_GROUP_MEMBERS, fOutlineGroupMembers.isSelected()); prefs.setValue(PreferenceConstants.OUTLINE_GROUP_MACROS, fOutlineGroupMacros.isSelected()); + prefs.setValue(PreferenceConstants.OUTLINE_HIDE_PRAGMA_MARK, fOutlineHidePragmaMarks.isSelected()); prefs.setValue(PreferenceConstants.SORT_ORDER_OF_EXCLUDED_FILES, fCViewSortOrderOfExcludedFiles.isSelected()); try { InstanceScope.INSTANCE.getNode(CUIPlugin.PLUGIN_ID).flush(); @@ -244,6 +252,7 @@ public class AppearancePreferencePage extends PreferencePage implements IWorkben fOutlineGroupNamespaces.setSelection(prefs.getDefaultBoolean(PreferenceConstants.OUTLINE_GROUP_NAMESPACES)); fOutlineGroupMembers.setSelection(prefs.getDefaultBoolean(PreferenceConstants.OUTLINE_GROUP_MEMBERS)); fOutlineGroupMacros.setSelection(prefs.getDefaultBoolean(PreferenceConstants.OUTLINE_GROUP_MACROS)); + fOutlineHidePragmaMarks.setSelection(prefs.getDefaultBoolean(PreferenceConstants.OUTLINE_HIDE_PRAGMA_MARK)); boolean showSourceRootsPref = DefaultScope.INSTANCE.getNode(CCorePlugin.PLUGIN_ID) .getBoolean(CCorePreferenceConstants.SHOW_SOURCE_ROOTS_AT_TOP_LEVEL_OF_PROJECT, true); fShowSourceRootsAtTopOfProject.setSelection(showSourceRootsPref); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/BuildConsolePreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/BuildConsolePreferencePage.java index 6bafb40db9a..4b6caa74dc0 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/BuildConsolePreferencePage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/BuildConsolePreferencePage.java @@ -35,7 +35,7 @@ import org.eclipse.ui.PlatformUI; public class BuildConsolePreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { private static final String PREF_CLEAR_CONSOLE = "clearConsole"; //$NON-NLS-1$ - private static final String PREF_CONSOLE_ON_TOP = "consoleOnTop"; //$NON-NLS-1$ + public static final String PREF_CONSOLE_ON_TOP = "consoleOnTop"; //$NON-NLS-1$ private static final String PREF_AUTO_OPEN_CONSOLE = "autoOpenConsole"; //$NON-NLS-1$ public static final String PREF_BUILDCONSOLE_WRAP_LINES = "buildConsoleWrapLines"; //$NON-NLS-1$ /** diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigurationBlock.java index a162968943e..56edb67e541 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigurationBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigurationBlock.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2020 IBM Corporation and others. + * Copyright (c) 2000, 2021 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -56,6 +56,8 @@ import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerComparator; import org.eclipse.swt.SWT; +import org.eclipse.swt.accessibility.ACC; +import org.eclipse.swt.accessibility.AccessibleListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; @@ -647,6 +649,12 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock { gd.widthHint = maxWidth; fListViewer.getControl().setLayoutData(gd); + // add the coloring element label text as the name for the list viewer + fListViewer.getControl().getAccessible().addAccessibleListener(AccessibleListener.getNameAdapter(e -> { + if (e.childID == ACC.CHILDID_SELF && (e.result == null || e.result.trim().isEmpty())) { + e.result = PreferencesMessages.CEditorColoringConfigurationBlock_coloring_element; + } + })); Composite stylesComposite = new Composite(editorComposite, SWT.NONE); layout = new GridLayout(); @@ -711,6 +719,12 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock { gd.widthHint = convertWidthInCharsToPixels(20); gd.heightHint = convertHeightInCharsToPixels(5); previewer.setLayoutData(gd); + // add the preview label text as the name to the previewer + previewer.getAccessible().addAccessibleListener(AccessibleListener.getNameAdapter(e -> { + if (e.childID == ACC.CHILDID_SELF && (e.result == null || e.result.trim().isEmpty())) { + e.result = PreferencesMessages.CEditorColoringConfigurationBlock_preview; + } + })); fListViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CTemplatePreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CTemplatePreferencePage.java index 7788b63ba9f..91b70fbcbcc 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CTemplatePreferencePage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CTemplatePreferencePage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2002, 2010 QNX Software Systems and others. + * Copyright (c) 2002, 2021 QNX Software Systems and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -11,6 +11,7 @@ * Contributors: * QNX Software Systems - Initial API and implementation * Wind River Systems, Inc. - Bug fixes + * IBM Corporation - Bug fixes *******************************************************************************/ package org.eclipse.cdt.internal.ui.preferences; @@ -33,8 +34,8 @@ import org.eclipse.jface.text.templates.ContextTypeRegistry; import org.eclipse.jface.text.templates.Template; import org.eclipse.jface.window.Window; import org.eclipse.swt.SWT; -import org.eclipse.swt.accessibility.AccessibleAdapter; -import org.eclipse.swt.accessibility.AccessibleEvent; +import org.eclipse.swt.accessibility.ACC; +import org.eclipse.swt.accessibility.AccessibleListener; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Composite; @@ -112,6 +113,25 @@ public class CTemplatePreferencePage extends TemplatePreferencePage { } /* + * @see PreferencePage#createContents(Composite) + */ + @Override + protected Control createContents(Composite ancestor) { + Control control = super.createContents(ancestor); + //must occur after contents created + if (getTableViewer() == null) { + String description = getDescription(); + //same description as used in PreferencePage.createDescriptionLabel(Composite parent) + getTableViewer().getControl().getAccessible().addAccessibleListener(AccessibleListener.getNameAdapter(e -> { + if (e.childID == ACC.CHILDID_SELF && (e.result == null || e.result.trim().isEmpty())) { + e.result = description; + } + })); + } + return control; + } + + /* * @see org.eclipse.ui.texteditor.templates.TemplatePreferencePage#getFormatterPreferenceKey() */ @Override @@ -157,12 +177,9 @@ public class CTemplatePreferencePage extends TemplatePreferencePage { data.heightHint = convertHeightInCharsToPixels(5); control.setLayoutData(data); - control.getAccessible().addAccessibleListener(new AccessibleAdapter() { - @Override - public void getName(AccessibleEvent e) { - e.result = PreferencesMessages.TemplatePreferencePage_Viewer_preview; - } - }); + control.getAccessible().addAccessibleListener(AccessibleListener.getNameAdapter(e -> { + e.result = PreferencesMessages.TemplatePreferencePage_Viewer_preview; + })); CSourcePreviewerUpdater.registerPreviewer(viewer, configuration, CUIPlugin.getDefault().getCombinedPreferenceStore()); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeAssistAdvancedConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeAssistAdvancedConfigurationBlock.java index 86927a8c57f..5649396e724 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeAssistAdvancedConfigurationBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeAssistAdvancedConfigurationBlock.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2016 IBM Corporation and others. + * Copyright (c) 2005, 2021 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -14,6 +14,7 @@ *******************************************************************************/ package org.eclipse.cdt.internal.ui.preferences; +import java.text.ParseException; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -21,10 +22,12 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Set; import org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener; import org.eclipse.cdt.internal.ui.dialogs.StatusInfo; import org.eclipse.cdt.internal.ui.text.contentassist.CompletionProposalCategory; +import org.eclipse.cdt.internal.ui.text.contentassist.CompletionProposalComputerPreferenceParser; import org.eclipse.cdt.internal.ui.text.contentassist.CompletionProposalComputerRegistry; import org.eclipse.cdt.internal.ui.util.Messages; import org.eclipse.cdt.internal.ui.util.SWTUtil; @@ -53,6 +56,9 @@ import org.eclipse.jface.viewers.ITableLabelProvider; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.ViewerComparator; import org.eclipse.swt.SWT; +import org.eclipse.swt.accessibility.ACC; +import org.eclipse.swt.accessibility.AccessibleListener; +import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.graphics.GC; @@ -152,7 +158,7 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo } } - private final Comparator<ModelElement> fCategoryComparator = new Comparator<ModelElement>() { + private final Comparator<ModelElement> fCategoryComparator = new Comparator<>() { @Override public int compare(ModelElement o1, ModelElement o2) { return o1.getRank() - o2.getRank(); @@ -230,22 +236,25 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo } private boolean readInclusionPreference(CompletionProposalCategory cat) { - String[] ids = getTokens(getValue(PREF_EXCLUDED_CATEGORIES), SEPARATOR); - for (String id : ids) { - if (id.equals(cat.getId())) - return false; + String value = getValue(PREF_EXCLUDED_CATEGORIES); + try { + Set<String> parseExcludedCategories = CompletionProposalComputerPreferenceParser + .parseExcludedCategories(value); + return !parseExcludedCategories.contains(cat.getId()); + } catch (ParseException e) { + return true; } - return true; } private int readOrderPreference(CompletionProposalCategory cat) { - String[] sortOrderIds = getTokens(getValue(PREF_CATEGORY_ORDER), SEPARATOR); - for (String sortOrderId : sortOrderIds) { - String[] idAndRank = getTokens(sortOrderId, COLON); - if (idAndRank[0].equals(cat.getId())) - return Integer.parseInt(idAndRank[1]); + String categoryOrderPref = getValue(PREF_CATEGORY_ORDER); + try { + Map<String, Integer> parseCategoryOrder = CompletionProposalComputerPreferenceParser + .parseCategoryOrder(categoryOrderPref); + return parseCategoryOrder.getOrDefault(cat.getId(), LIMIT + 1); + } catch (ParseException e) { + return LIMIT + 1; } - return LIMIT + 1; } public void update() { @@ -413,6 +422,21 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo textField.setToolTipText(toolTip); } + private StyledText createAccessibleLabelUsingStyledText(Composite composite, int style, String value) { + StyledText styledTextWidget = new StyledText(composite, SWT.SINGLE | SWT.NONE); + styledTextWidget.setText(value); + styledTextWidget.setEditable(false); + styledTextWidget.setCaret(null); + styledTextWidget.setBackground(composite.getBackground()); + styledTextWidget.setToolTipText(value); + styledTextWidget.getAccessible().addAccessibleListener(AccessibleListener.getNameAdapter(e -> { + if (e.childID == ACC.CHILDID_SELF && (e.result == null || e.result.trim().isEmpty())) { + e.result = value; + } + })); + return styledTextWidget; + } + private void createDefaultLabel(Composite composite, int h_span) { final ICommandService commandSvc = PlatformUI.getWorkbench().getAdapter(ICommandService.class); final Command command = commandSvc.getCommand(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS); @@ -424,16 +448,16 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo PixelConverter pixelConverter = new PixelConverter(composite); int width = pixelConverter.convertWidthInCharsToPixels(40); - Label label = new Label(composite, SWT.NONE | SWT.WRAP); - label.setText(Messages.format(PreferencesMessages.CodeAssistAdvancedConfigurationBlock_page_description, - new Object[] { key })); + StyledText pageDescription = createAccessibleLabelUsingStyledText(composite, SWT.NONE | SWT.WRAP, + Messages.format(PreferencesMessages.CodeAssistAdvancedConfigurationBlock_page_description, + new Object[] { key })); GridData gd = new GridData(GridData.FILL, GridData.FILL, true, false, h_span, 1); gd.widthHint = width; - label.setLayoutData(gd); + pageDescription.setLayoutData(gd); createFiller(composite, h_span); - label = new Label(composite, SWT.NONE | SWT.WRAP); + Label label = new Label(composite, SWT.NONE | SWT.WRAP); label.setText(PreferencesMessages.CodeAssistAdvancedConfigurationBlock_default_table_description); gd = new GridData(GridData.FILL, GridData.FILL, true, false, h_span, 1); gd.widthHint = width; @@ -465,6 +489,12 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo } }); + fDefaultViewer.getControl().getAccessible().addAccessibleListener(AccessibleListener.getNameAdapter(e -> { + if (e.childID == ACC.CHILDID_SELF && (e.result == null || e.result.trim().isEmpty())) { + e.result = PreferencesMessages.CodeAssistAdvancedConfigurationBlock_default_table_description; + } + })); + fDefaultViewer.setContentProvider(ArrayContentProvider.getInstance()); DefaultTableLabelProvider labelProvider = new DefaultTableLabelProvider(); @@ -567,6 +597,12 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo } }); + fSeparateViewer.getControl().getAccessible().addAccessibleListener(AccessibleListener.getNameAdapter(e -> { + if (e.childID == ACC.CHILDID_SELF && (e.result == null || e.result.trim().isEmpty())) { + e.result = PreferencesMessages.CodeAssistAdvancedConfigurationBlock_separate_table_description; + } + })); + table.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/HeaderSubstitutionMapEditDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/HeaderSubstitutionMapEditDialog.java index ea7a495068b..385b8173bff 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/HeaderSubstitutionMapEditDialog.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/HeaderSubstitutionMapEditDialog.java @@ -80,7 +80,7 @@ public class HeaderSubstitutionMapEditDialog extends ResizableStatusDialog { private static final String UTF_8 = "UTF-8"; //$NON-NLS-1$ private static final String TAG_HEADER_SUBSTITUTION_MAP = "header_substitution_map"; //$NON-NLS-1$ private static final Collator COLLATOR = Collator.getInstance(); - private static final Comparator<HeaderSubstitutionRule> SOURCE_COMPARATOR = new Comparator<HeaderSubstitutionRule>() { + private static final Comparator<HeaderSubstitutionRule> SOURCE_COMPARATOR = new Comparator<>() { @Override public int compare(HeaderSubstitutionRule r1, HeaderSubstitutionRule r2) { return COLLATOR.compare(r1.getSource(), r2.getSource()); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IndexerStrategyBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IndexerStrategyBlock.java index a076dafdb8f..3f7b8894bba 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IndexerStrategyBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IndexerStrategyBlock.java @@ -18,6 +18,7 @@ import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager; import org.eclipse.cdt.core.settings.model.ICProjectDescriptionPreferences; import org.eclipse.cdt.core.settings.model.ICProjectDescriptionWorkspacePreferences; import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences; +import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionPreferences; import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage; import org.eclipse.cdt.ui.dialogs.ICOptionContainer; import org.eclipse.cdt.utils.ui.controls.ControlFactory; @@ -143,8 +144,10 @@ public class IndexerStrategyBlock extends AbstractCOptionPage { public void performDefaults() { initUpdatePolicy(IndexerPreferences.getDefaultUpdatePolicy()); if (fUseActiveBuildButton != null) { - fUseActiveBuildButton.setSelection(false); - fUseFixedBuildConfig.setSelection(true); + boolean defaultUseActive = CProjectDescriptionPreferences + .getDefaultRelations() == ICProjectDescriptionPreferences.CONFIGS_LINK_SETTINGS_AND_ACTIVE; + fUseActiveBuildButton.setSelection(defaultUseActive); + fUseFixedBuildConfig.setSelection(!defaultUseActive); } updateEnablement(); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/NameStyleBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/NameStyleBlock.java index 769d3b1030a..7f2d7e14be0 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/NameStyleBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/NameStyleBlock.java @@ -160,53 +160,50 @@ public class NameStyleBlock extends OptionsConfigurationBlock { Category codeCategory = new Category(PreferencesMessages.NameStyleBlock_code_node); new Category(PreferencesMessages.NameStyleBlock_constant_node, PreferencesMessages.NameStyleBlock_constant_node_description, EXAMPLE_CONSTANT_NAME, codeCategory) - .setCapitalizationKey(KEY_CONSTANT_CAPITALIZATION) - .setWordDelimiterKey(KEY_CONSTANT_WORD_DELIMITER).setPrefixKey(KEY_CONSTANT_PREFIX) - .setSuffixKey(KEY_CONSTANT_SUFFIX).setNameValidator(IDENTIFIER_VALIDATOR); + .setCapitalizationKey(KEY_CONSTANT_CAPITALIZATION).setWordDelimiterKey(KEY_CONSTANT_WORD_DELIMITER) + .setPrefixKey(KEY_CONSTANT_PREFIX).setSuffixKey(KEY_CONSTANT_SUFFIX) + .setNameValidator(IDENTIFIER_VALIDATOR); new Category(PreferencesMessages.NameStyleBlock_variable_node, PreferencesMessages.NameStyleBlock_variable_node_description, EXAMPLE_VARIABLE_NAME, codeCategory) - .setCapitalizationKey(KEY_VARIABLE_CAPITALIZATION) - .setWordDelimiterKey(KEY_VARIABLE_WORD_DELIMITER).setPrefixKey(KEY_VARIABLE_PREFIX) - .setSuffixKey(KEY_VARIABLE_SUFFIX).setNameValidator(IDENTIFIER_VALIDATOR); + .setCapitalizationKey(KEY_VARIABLE_CAPITALIZATION).setWordDelimiterKey(KEY_VARIABLE_WORD_DELIMITER) + .setPrefixKey(KEY_VARIABLE_PREFIX).setSuffixKey(KEY_VARIABLE_SUFFIX) + .setNameValidator(IDENTIFIER_VALIDATOR); Category fieldCategory = new Category(PreferencesMessages.NameStyleBlock_field_node, PreferencesMessages.NameStyleBlock_field_node_description, EXAMPLE_FIELD_NAME, codeCategory) - .setCapitalizationKey(KEY_FIELD_CAPITALIZATION).setWordDelimiterKey(KEY_FIELD_WORD_DELIMITER) - .setPrefixKey(KEY_FIELD_PREFIX).setSuffixKey(KEY_FIELD_SUFFIX) - .setNameValidator(IDENTIFIER_VALIDATOR); + .setCapitalizationKey(KEY_FIELD_CAPITALIZATION).setWordDelimiterKey(KEY_FIELD_WORD_DELIMITER) + .setPrefixKey(KEY_FIELD_PREFIX).setSuffixKey(KEY_FIELD_SUFFIX).setNameValidator(IDENTIFIER_VALIDATOR); new Category(PreferencesMessages.NameStyleBlock_method_node, PreferencesMessages.NameStyleBlock_method_node_description, EXAMPLE_METHOD_NAME, codeCategory) - .setCapitalizationKey(KEY_METHOD_CAPITALIZATION).setWordDelimiterKey(KEY_METHOD_WORD_DELIMITER) - .setPrefixKey(KEY_METHOD_PREFIX).setSuffixKey(KEY_METHOD_SUFFIX) - .setNameValidator(IDENTIFIER_VALIDATOR); + .setCapitalizationKey(KEY_METHOD_CAPITALIZATION).setWordDelimiterKey(KEY_METHOD_WORD_DELIMITER) + .setPrefixKey(KEY_METHOD_PREFIX).setSuffixKey(KEY_METHOD_SUFFIX).setNameValidator(IDENTIFIER_VALIDATOR); new Category(PreferencesMessages.NameStyleBlock_getter_node, PreferencesMessages.NameStyleBlock_getter_node_description, EXAMPLE_FIELD_NAME, codeCategory) - .setCapitalizationKey(KEY_GETTER_CAPITALIZATION).setWordDelimiterKey(KEY_GETTER_WORD_DELIMITER) - .setPrefixKey(KEY_GETTER_PREFIX).setAlternativePrefixKey(KEY_GETTER_PREFIX_FOR_BOOLEAN) - .setSuffixKey(KEY_GETTER_SUFFIX).setSeedNameGenerator(fieldCategory) - .setNameValidator(IDENTIFIER_VALIDATOR).setTrimFieldName(true); + .setCapitalizationKey(KEY_GETTER_CAPITALIZATION).setWordDelimiterKey(KEY_GETTER_WORD_DELIMITER) + .setPrefixKey(KEY_GETTER_PREFIX).setAlternativePrefixKey(KEY_GETTER_PREFIX_FOR_BOOLEAN) + .setSuffixKey(KEY_GETTER_SUFFIX).setSeedNameGenerator(fieldCategory) + .setNameValidator(IDENTIFIER_VALIDATOR).setTrimFieldName(true); new Category(PreferencesMessages.NameStyleBlock_setter_node, PreferencesMessages.NameStyleBlock_setter_node_description, EXAMPLE_FIELD_NAME, codeCategory) - .setCapitalizationKey(KEY_SETTER_CAPITALIZATION).setWordDelimiterKey(KEY_SETTER_WORD_DELIMITER) - .setPrefixKey(KEY_SETTER_PREFIX).setSuffixKey(KEY_SETTER_SUFFIX) - .setSeedNameGenerator(fieldCategory).setNameValidator(IDENTIFIER_VALIDATOR) - .setTrimFieldName(true); + .setCapitalizationKey(KEY_SETTER_CAPITALIZATION).setWordDelimiterKey(KEY_SETTER_WORD_DELIMITER) + .setPrefixKey(KEY_SETTER_PREFIX).setSuffixKey(KEY_SETTER_SUFFIX).setSeedNameGenerator(fieldCategory) + .setNameValidator(IDENTIFIER_VALIDATOR).setTrimFieldName(true); new IncludeGuardCategory(codeCategory); Category fileCategory = new Category(PreferencesMessages.NameStyleBlock_files_node); new Category(PreferencesMessages.NameStyleBlock_cpp_header_node, PreferencesMessages.NameStyleBlock_cpp_header_node_description, EXAMPLE_CLASS_NAME, fileCategory) - .setCapitalizationKey(KEY_CPP_HEADER_CAPITALIZATION) - .setWordDelimiterKey(KEY_CPP_HEADER_WORD_DELIMITER).setPrefixKey(KEY_CPP_HEADER_PREFIX) - .setSuffixKey(KEY_CPP_HEADER_SUFFIX).setNameValidator(FILENAME_VALIDATOR); + .setCapitalizationKey(KEY_CPP_HEADER_CAPITALIZATION).setWordDelimiterKey(KEY_CPP_HEADER_WORD_DELIMITER) + .setPrefixKey(KEY_CPP_HEADER_PREFIX).setSuffixKey(KEY_CPP_HEADER_SUFFIX) + .setNameValidator(FILENAME_VALIDATOR); new Category(PreferencesMessages.NameStyleBlock_cpp_source_node, PreferencesMessages.NameStyleBlock_cpp_source_node_description, EXAMPLE_CLASS_NAME, fileCategory) - .setCapitalizationKey(KEY_CPP_SOURCE_CAPITALIZATION) - .setWordDelimiterKey(KEY_CPP_SOURCE_WORD_DELIMITER).setPrefixKey(KEY_CPP_SOURCE_PREFIX) - .setSuffixKey(KEY_CPP_SOURCE_SUFFIX).setNameValidator(FILENAME_VALIDATOR); + .setCapitalizationKey(KEY_CPP_SOURCE_CAPITALIZATION).setWordDelimiterKey(KEY_CPP_SOURCE_WORD_DELIMITER) + .setPrefixKey(KEY_CPP_SOURCE_PREFIX).setSuffixKey(KEY_CPP_SOURCE_SUFFIX) + .setNameValidator(FILENAME_VALIDATOR); new Category(PreferencesMessages.NameStyleBlock_cpp_test_node, PreferencesMessages.NameStyleBlock_cpp_test_node_description, EXAMPLE_CLASS_NAME, fileCategory) - .setCapitalizationKey(KEY_CPP_TEST_CAPITALIZATION) - .setWordDelimiterKey(KEY_CPP_TEST_WORD_DELIMITER).setPrefixKey(KEY_CPP_TEST_PREFIX) - .setSuffixKey(KEY_CPP_TEST_SUFFIX).setNameValidator(FILENAME_VALIDATOR); + .setCapitalizationKey(KEY_CPP_TEST_CAPITALIZATION).setWordDelimiterKey(KEY_CPP_TEST_WORD_DELIMITER) + .setPrefixKey(KEY_CPP_TEST_PREFIX).setSuffixKey(KEY_CPP_TEST_SUFFIX) + .setNameValidator(FILENAME_VALIDATOR); return new Category[] { codeCategory, fileCategory }; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.java index 4298052a36c..a0e29530635 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.java @@ -155,6 +155,7 @@ public final class PreferencesMessages extends NLS { public static String AppearancePreferencePage_outlineGroupMethods_label; public static String AppearancePreferencePage_outlineGroupNamespaces_label; public static String AppearancePreferencePage_outlineGroupMacros_label; + public static String AppearancePreferencePage_HidePragmaMarks_label; public static String AppearancePreferencePage_note; public static String AppearancePreferencePage_preferenceOnlyForNewViews; public static String AppearancePreferencePage_showSourceRootsAtTopOfProject_label; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.properties index 7a42b567672..c765c083b50 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.properties +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.properties @@ -188,6 +188,7 @@ AppearancePreferencePage_outlineGroupNamespaces_label= Group namespaces in the O AppearancePreferencePage_note=Note: AppearancePreferencePage_preferenceOnlyForNewViews=These two preferences do not affect open views AppearancePreferencePage_outlineGroupMacros_label=Group macro definitions in the Outline view +AppearancePreferencePage_HidePragmaMarks_label=Hide Dividers (#pragma mark or #pragma region/endregion) in the Outline view AppearancePreferencePage_showSourceRootsAtTopOfProject_label=Show source roots at top of project #Build Logging diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TabConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TabConfigurationBlock.java index 2760aeba143..9336285ed56 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TabConfigurationBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TabConfigurationBlock.java @@ -24,14 +24,14 @@ import org.eclipse.core.runtime.Status; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.layout.PixelConverter; import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.CTabFolder; +import org.eclipse.swt.custom.CTabItem; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.TabFolder; -import org.eclipse.swt.widgets.TabItem; import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer; /** @@ -75,12 +75,12 @@ public class TabConfigurationBlock extends OptionsConfigurationBlock { @Override protected Control createContents(Composite parent) { PixelConverter pixelConverter = new PixelConverter(parent); - final TabFolder folder = new TabFolder(parent, SWT.NONE); + final CTabFolder folder = new CTabFolder(parent, SWT.NONE); folder.setLayout(new TabFolderLayout()); folder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); for (int i = 0; i < fTabs.length; i++) { - TabItem item = new TabItem(folder, SWT.NONE); + CTabItem item = new CTabItem(folder, SWT.NONE); item.setText(fTabLabels[i]); Composite composite = new Composite(folder, SWT.NONE); FillLayout layout = new FillLayout(); @@ -91,6 +91,7 @@ public class TabConfigurationBlock extends OptionsConfigurationBlock { item.setData(fTabs[i]); fTabs[i].createContents(composite); } + folder.setSelection(0); Dialog.applyDialogFont(folder); folder.addSelectionListener(new SelectionListener() { @Override diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterMessages.java index 82737ec5982..7deb8d1086b 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterMessages.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterMessages.java @@ -212,10 +212,6 @@ final class FormatterMessages extends NLS { public static String WhiteSpaceOptions_structured_binding_before_comma_in_name_list; public static String WhiteSpaceOptions_structured_binding_after_comma_in_name_list; public static String WhiteSpaceOptions_structured_binding_before_name_list_closing_bracket; - public static String WhiteSpaceTabPage_deduction_guide_declarations; - public static String WhiteSpaceTabPage_deduction_guide_before_arrow; - public static String WhiteSpaceTabPage_deduction_guide_after_arrow; - public static String WhiteSpaceOptions_deduction_guide_arrow_operator; // public static String WhiteSpaceOptions_before_ellipsis; // public static String WhiteSpaceOptions_after_ellipsis; // public static String WhiteSpaceOptions_return_with_parenthesized_expression; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterMessages.properties index 94d45b8107f..6921dc869ed 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterMessages.properties +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterMessages.properties @@ -34,10 +34,6 @@ WhiteSpaceTabPage_lambda_expressions=Lambda expressions WhiteSpaceTabPage_lambda_before_return=before return arrow WhiteSpaceTabPage_lambda_after_return=after return arrow -WhiteSpaceTabPage_deduction_guide_declarations=Deduction guide -WhiteSpaceTabPage_deduction_guide_before_arrow=before arrow -WhiteSpaceTabPage_deduction_guide_after_arrow=after arrow - WhiteSpaceTabPage_classes=Types WhiteSpaceTabPage_classes_before_opening_brace_of_a_class=before opening brace of a class WhiteSpaceTabPage_classes_before_colon_of_base_clause=before colon of base clause @@ -150,7 +146,6 @@ WhiteSpaceOptions_unary_operator=Unary operator WhiteSpaceOptions_prefix_operator=Prefix operator WhiteSpaceOptions_postfix_operator=Postfix operator WhiteSpaceOptions_lambda_arrow_operator=Lambda arrow operator -WhiteSpaceOptions_deduction_guide_arrow_operator=Deduction guide arrow operator WhiteSpaceOptions_pointer=Pointer WhiteSpaceOptions_before_pointer=Before pointer diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ModifyDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ModifyDialog.java index 6b17b472355..cb4506e91da 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ModifyDialog.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ModifyDialog.java @@ -42,6 +42,8 @@ import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.dialogs.StatusDialog; import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.CTabFolder; +import org.eclipse.swt.custom.CTabItem; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.graphics.Point; @@ -54,8 +56,6 @@ import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.FileDialog; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.TabFolder; -import org.eclipse.swt.widgets.TabItem; public abstract class ModifyDialog extends StatusDialog implements IModifyDialogTabPage.IModificationListener { @@ -88,7 +88,7 @@ public abstract class ModifyDialog extends StatusDialog implements IModifyDialog private final Map<String, String> fWorkingValues; private final List<IModifyDialogTabPage> fTabPages; private final IDialogSettings fDialogSettings; - private TabFolder fTabFolder; + private CTabFolder fTabFolder; private final ProfileManager fProfileManager; private Button fApplyButton; private Button fSaveButton; @@ -137,7 +137,7 @@ public abstract class ModifyDialog extends StatusDialog implements IModifyDialog if (!fNewProfile) { fTabFolder.setSelection(lastFocusNr); - ((IModifyDialogTabPage) fTabFolder.getSelection()[0].getData()).setInitialFocus(); + ((IModifyDialogTabPage) fTabFolder.getSelection().getData()).setInitialFocus(); } } @@ -165,11 +165,14 @@ public abstract class ModifyDialog extends StatusDialog implements IModifyDialog fSaveButton = createButton(nameComposite, SAVE_BUTTON_ID, FormatterMessages.ModifyDialog_Export_Button, false); - fTabFolder = new TabFolder(composite, SWT.NONE); + fTabFolder = new CTabFolder(composite, SWT.NONE); fTabFolder.setFont(composite.getFont()); fTabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); addPages(fWorkingValues); + if (fTabFolder.getSelection() == null) { + fTabFolder.setSelection(0); + } applyDialogFont(composite); @@ -180,7 +183,7 @@ public abstract class ModifyDialog extends StatusDialog implements IModifyDialog @Override public void widgetSelected(SelectionEvent e) { - final TabItem tabItem = (TabItem) e.item; + final CTabItem tabItem = (CTabItem) e.item; final IModifyDialogTabPage page = (IModifyDialogTabPage) tabItem.getData(); // page.fSashForm.setWeights(); fDialogSettings.put(fKeyLastFocus, fTabPages.indexOf(page)); @@ -330,7 +333,7 @@ public abstract class ModifyDialog extends StatusDialog implements IModifyDialog } protected final void addTabPage(String title, IModifyDialogTabPage tabPage) { - final TabItem tabItem = new TabItem(fTabFolder, SWT.NONE); + final CTabItem tabItem = new CTabItem(fTabFolder, SWT.NONE); applyDialogFont(tabItem.getControl()); tabItem.setText(title); tabItem.setData(tabPage); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/WhiteSpaceOptions.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/WhiteSpaceOptions.java index 78116c21743..95e938b5ff6 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/WhiteSpaceOptions.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/WhiteSpaceOptions.java @@ -183,9 +183,6 @@ public final class WhiteSpaceOptions { private final PreviewSnippet LAMBDA_PREVIEW = new PreviewSnippet(CodeFormatter.K_CLASS_BODY_DECLARATIONS, "void foo() { auto f = []()->int{return 0;};}"); //$NON-NLS-1$ - private final PreviewSnippet DEDUCTION_GUIDE_PREVIEW = new PreviewSnippet(CodeFormatter.K_CLASS_BODY_DECLARATIONS, - "template<typename T> struct U;\ntemplate<typename C>\nU(C) -> U<C>;"); //$NON-NLS-1$ - private final PreviewSnippet INITIALIZER_LIST_PREVIEW = new PreviewSnippet(CodeFormatter.K_STATEMENTS, "int array[]= {1, 2, 3};"); //$NON-NLS-1$ @@ -481,7 +478,6 @@ public final class WhiteSpaceOptions { createLinkageTree(workingValues, declarations); // createConstructorTree(workingValues, declarations); createLambdaDeclTree(workingValues, declarations); - createDeductionDeclTree(workingValues, declarations); createMethodDeclTree(workingValues, declarations); createExceptionSpecificationTree(workingValues, declarations); createLabelTree(workingValues, declarations); @@ -610,9 +606,6 @@ public final class WhiteSpaceOptions { DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_POSTFIX_OPERATOR, OPERATOR_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_lambda_arrow_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_LAMBDA_RETURN, LAMBDA_PREVIEW); - createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_deduction_guide_arrow_operator, - DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_DEDUCTION_GUIDE_ARROW, - DEDUCTION_GUIDE_PREVIEW); } private void createBeforeClosingBracketTree(Map<String, String> workingValues, final InnerNode parent) { @@ -859,9 +852,6 @@ public final class WhiteSpaceOptions { DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_POSTFIX_OPERATOR, OPERATOR_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_lambda_arrow_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_LAMBDA_RETURN, LAMBDA_PREVIEW); - createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_deduction_guide_arrow_operator, - DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_DEDUCTION_GUIDE_ARROW, - DEDUCTION_GUIDE_PREVIEW); } private void createAfterOpenBracketTree(Map<String, String> workingValues, final InnerNode parent) { @@ -1014,19 +1004,6 @@ public final class WhiteSpaceOptions { return root; } - private InnerNode createDeductionDeclTree(Map<String, String> workingValues, InnerNode parent) { - final InnerNode root = new InnerNode(parent, workingValues, - FormatterMessages.WhiteSpaceTabPage_deduction_guide_declarations); - - createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_deduction_guide_before_arrow, - DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_DEDUCTION_GUIDE_ARROW, - DEDUCTION_GUIDE_PREVIEW); - createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_deduction_guide_after_arrow, - DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_DEDUCTION_GUIDE_ARROW, - DEDUCTION_GUIDE_PREVIEW); - return root; - } - private InnerNode createLambdaDeclTree(Map<String, String> workingValues, InnerNode parent) { final InnerNode root = new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_lambda_expressions); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodRefactoring.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodRefactoring.java index e3338e918de..e3338e918de 100755..100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodRefactoring.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodRefactoring.java diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringMatchStore.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringMatchStore.java index 1354b6a8f6c..0078b977827 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringMatchStore.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringMatchStore.java @@ -34,7 +34,7 @@ public class CRefactoringMatchStore { private Comparator<CRefactoringMatch> fOffsetComparator; public CRefactoringMatchStore() { - fOffsetComparator = new Comparator<CRefactoringMatch>() { + fOffsetComparator = new Comparator<>() { @Override public int compare(CRefactoringMatch o1, CRefactoringMatch o2) { return o1.getOffset() - o2.getOffset(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/TextSearchWrapper.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/TextSearchWrapper.java index b490d065351..f6d90648a9b 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/TextSearchWrapper.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/TextSearchWrapper.java @@ -310,7 +310,7 @@ public class TextSearchWrapper { } } - final static Comparator<int[]> COMPARE_FIRST_INTEGER = new Comparator<int[]>() { + final static Comparator<int[]> COMPARE_FIRST_INTEGER = new Comparator<>() { @Override public int compare(int[] o1, int[] o2) { return (o1)[0] - (o2)[0]; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/NodeHelper.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/NodeHelper.java index ea6968654b1..ea6968654b1 100755..100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/NodeHelper.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/NodeHelper.java diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/COutlineInformationControl.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/COutlineInformationControl.java index 464924753d1..23e9404c5a0 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/COutlineInformationControl.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/COutlineInformationControl.java @@ -23,7 +23,7 @@ import org.eclipse.cdt.internal.ui.editor.LexicalSortingAction; import org.eclipse.cdt.internal.ui.util.ProblemTreeViewer; import org.eclipse.cdt.internal.ui.viewsupport.AppearanceAwareLabelProvider; import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels; -import org.eclipse.cdt.internal.ui.viewsupport.DecoratingCLabelProvider; +import org.eclipse.cdt.internal.ui.viewsupport.DecoratingCOutlineLabelProvider; import org.eclipse.cdt.ui.PreferenceConstants; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.Separator; @@ -84,7 +84,7 @@ public class COutlineInformationControl extends AbstractInformationControl { if (PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.OUTLINE_GROUP_MEMBERS)) textFlags = textFlags | CElementLabels.M_SIMPLE_NAME | CElementLabels.F_SIMPLE_NAME; treeViewer.setLabelProvider( - new DecoratingCLabelProvider(new AppearanceAwareLabelProvider(textFlags, IMAGE_FLAGS), true)); + new DecoratingCOutlineLabelProvider(new AppearanceAwareLabelProvider(textFlags, IMAGE_FLAGS))); treeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS); return treeViewer; } 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/text/contentassist/CContentAssistInvocationContext.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CContentAssistInvocationContext.java index 50f0609adcc..2d6555195ef 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CContentAssistInvocationContext.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CContentAssistInvocationContext.java @@ -74,7 +74,7 @@ public class CContentAssistInvocationContext extends ContentAssistInvocationCont // may need a corresponding adjustment, and this stores the adjusted offset. private int fAdjustedParseOffset = -1; - private Lazy<Integer> fContextInfoPosition = new Lazy<Integer>() { + private Lazy<Integer> fContextInfoPosition = new Lazy<>() { @Override protected Integer calculateValue() { return guessContextInformationPosition(); @@ -83,7 +83,7 @@ public class CContentAssistInvocationContext extends ContentAssistInvocationCont private final Lazy<ITranslationUnit> fTU; - private final Lazy<Integer> fParseOffset = new Lazy<Integer>() { + private final Lazy<Integer> fParseOffset = new Lazy<>() { @Override protected Integer calculateValue() { int result = doCalculate(); @@ -196,7 +196,7 @@ public class CContentAssistInvocationContext extends ContentAssistInvocationCont return null; } - private final Lazy<IASTCompletionNode> fCN = new Lazy<IASTCompletionNode>() { + private final Lazy<IASTCompletionNode> fCN = new Lazy<>() { @Override protected IASTCompletionNode calculateValue() { int offset = getParseOffset(); @@ -253,7 +253,7 @@ public class CContentAssistInvocationContext extends ContentAssistInvocationCont } }; - private final Lazy<Boolean> afterOpeningAngleBracket = new Lazy<Boolean>() { + private final Lazy<Boolean> afterOpeningAngleBracket = new Lazy<>() { @Override protected Boolean calculateValue() { final int parseOffset = getParseOffset(); @@ -264,7 +264,7 @@ public class CContentAssistInvocationContext extends ContentAssistInvocationCont } }; - private final Lazy<Boolean> afterOpeningParenthesisOrBrace = new Lazy<Boolean>() { + private final Lazy<Boolean> afterOpeningParenthesisOrBrace = new Lazy<>() { @Override protected Boolean calculateValue() { final int invocationOffset = getInvocationOffset(); @@ -295,7 +295,7 @@ public class CContentAssistInvocationContext extends ContentAssistInvocationCont } }; - private final Lazy<Boolean> inUsingDeclaration = new Lazy<Boolean>() { + private final Lazy<Boolean> inUsingDeclaration = new Lazy<>() { /** * Checks whether the invocation offset is inside a using-declaration. * @@ -331,7 +331,7 @@ public class CContentAssistInvocationContext extends ContentAssistInvocationCont } }; - private final Lazy<Boolean> followedBySemicolon = new Lazy<Boolean>() { + private final Lazy<Boolean> followedBySemicolon = new Lazy<>() { @Override protected Boolean calculateValue() { final IDocument doc = getDocument(); @@ -342,7 +342,7 @@ public class CContentAssistInvocationContext extends ContentAssistInvocationCont } }; - private final Lazy<Boolean> followedByOpeningParen = new Lazy<Boolean>() { + private final Lazy<Boolean> followedByOpeningParen = new Lazy<>() { @Override protected Boolean calculateValue() { final IDocument doc = getDocument(); @@ -353,7 +353,7 @@ public class CContentAssistInvocationContext extends ContentAssistInvocationCont } }; - private final Lazy<String> functionParameterDelimiter = new Lazy<String>() { + private final Lazy<String> functionParameterDelimiter = new Lazy<>() { @Override protected String calculateValue() { String propertyKey = DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_DECLARATION_PARAMETERS; @@ -362,7 +362,7 @@ public class CContentAssistInvocationContext extends ContentAssistInvocationCont } }; - private final Lazy<String> templateParameterDelimiter = new Lazy<String>() { + private final Lazy<String> templateParameterDelimiter = new Lazy<>() { @Override protected String calculateValue() { String propertyKey = DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_TEMPLATE_PARAMETERS; @@ -387,7 +387,7 @@ public class CContentAssistInvocationContext extends ContentAssistInvocationCont fIsCompletion = isCompletion; fIsContextInformationStyle = !isCompletion; fIsAutoActivated = isAutoActivated; - fTU = new Lazy<ITranslationUnit>() { + fTU = new Lazy<>() { @Override protected ITranslationUnit calculateValue() { return CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(fEditor.getEditorInput()); @@ -402,7 +402,7 @@ public class CContentAssistInvocationContext extends ContentAssistInvocationCont */ public CContentAssistInvocationContext(final ITranslationUnit unit, boolean isCompletion) { super(); - fTU = new Lazy<ITranslationUnit>() { + fTU = new Lazy<>() { @Override protected ITranslationUnit calculateValue() { return unit; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionProposalComputerPreferenceParser.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionProposalComputerPreferenceParser.java new file mode 100644 index 00000000000..428baf98a6c --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionProposalComputerPreferenceParser.java @@ -0,0 +1,78 @@ +/******************************************************************************* + * Copyright (c) 2020 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.ui.text.contentassist; + +import java.text.ParseException; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.eclipse.cdt.ui.PreferenceConstants; + +/** + * Parses the Completion Proposal Computer Preferences. + * <p> + * See org.eclipse.cdt.internal.ui.preferences.CodeAssistAdvancedConfigurationBlock.PreferenceModel + * for the write side of the preferences. + */ +public class CompletionProposalComputerPreferenceParser { + /** + * Parses the {@link PreferenceConstants#CODEASSIST_EXCLUDED_CATEGORIES} value and + * converts to a set of categories that are excluded. + * @param preferenceValue as stored in {@link PreferenceConstants#CODEASSIST_EXCLUDED_CATEGORIES} + * @return set of excluded categories + * @throws ParseException if the value cannot be parsed + */ + public static Set<String> parseExcludedCategories(String preferenceValue) throws ParseException { + Set<String> disabled = new HashSet<>(); + String[] disabledArray = splitOnNulls(preferenceValue); + disabled.addAll(Arrays.asList(disabledArray)); + return disabled; + } + + /** + * Parses the {@link PreferenceConstants#CODEASSIST_CATEGORY_ORDER} value and + * converts to a map of category ids to sort rank number + * @param preferenceValue as stored in {@link PreferenceConstants#CODEASSIST_CATEGORY_ORDER} + * @return map of category id to rank order + * @throws ParseException if the value cannot be parsed + */ + public static Map<String, Integer> parseCategoryOrder(String preferenceValue) throws ParseException { + Map<String, Integer> ordered = new HashMap<>(); + String[] orderedArray = splitOnNulls(preferenceValue); + for (String entry : orderedArray) { + String[] idRank = entry.split(":"); //$NON-NLS-1$ + if (idRank.length != 2) { + throw new ParseException(entry, 0); + } + String id = idRank[0]; + int rank; + try { + rank = Integer.parseInt(idRank[1]); + } catch (NumberFormatException e) { + throw new ParseException(entry, 0); + } + ordered.put(id, Integer.valueOf(rank)); + } + return ordered; + } + + /** + * See Bug 558809. Oomph seems to have failed at times to encode/decode nul character '\0' + * from the format it is stored in Oomph setup files. We can have ${0x0} instead of \0, infact + * there can be multiple $, so $$$$${0x0} is a valid split too. + */ + private static String[] splitOnNulls(String preference) { + return preference.split("\\000|(\\$+\\{0x0\\})"); //$NON-NLS-1$ + } +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionProposalComputerRegistry.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionProposalComputerRegistry.java index 12c66d662e1..33843a56842 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionProposalComputerRegistry.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionProposalComputerRegistry.java @@ -14,6 +14,7 @@ *******************************************************************************/ package org.eclipse.cdt.internal.ui.text.contentassist; +import java.text.ParseException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -24,7 +25,6 @@ import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.StringTokenizer; import org.eclipse.cdt.internal.ui.util.Messages; import org.eclipse.cdt.ui.CUIPlugin; @@ -272,19 +272,19 @@ public final class CompletionProposalComputerRegistry { private List<CompletionProposalCategory> getCategories(List<IConfigurationElement> elements) { IPreferenceStore store = CUIPlugin.getDefault().getPreferenceStore(); - String preference = store.getString(PreferenceConstants.CODEASSIST_EXCLUDED_CATEGORIES); - Set<String> disabled = new HashSet<>(); - StringTokenizer tok = new StringTokenizer(preference, "\0"); //$NON-NLS-1$ - while (tok.hasMoreTokens()) - disabled.add(tok.nextToken()); - Map<String, Integer> ordered = new HashMap<>(); - preference = store.getString(PreferenceConstants.CODEASSIST_CATEGORY_ORDER); - tok = new StringTokenizer(preference, "\0"); //$NON-NLS-1$ - while (tok.hasMoreTokens()) { - StringTokenizer inner = new StringTokenizer(tok.nextToken(), ":"); //$NON-NLS-1$ - String id = inner.nextToken(); - int rank = Integer.parseInt(inner.nextToken()); - ordered.put(id, Integer.valueOf(rank)); + Set<String> disabled = Collections.emptySet(); + Map<String, Integer> ordered = Collections.emptyMap(); + boolean parseFailed = false; + try { + disabled = CompletionProposalComputerPreferenceParser + .parseExcludedCategories(store.getString(PreferenceConstants.CODEASSIST_EXCLUDED_CATEGORIES)); + ordered = CompletionProposalComputerPreferenceParser + .parseCategoryOrder(store.getString(PreferenceConstants.CODEASSIST_CATEGORY_ORDER)); + } catch (ParseException e) { + // Failed to parse user setting, clear all settings + // and display error message to user allowing them to + // reset on first use + parseFailed = true; } List<CompletionProposalCategory> categories = new ArrayList<>(); @@ -296,13 +296,20 @@ public final class CompletionProposalComputerRegistry { CompletionProposalCategory category = new CompletionProposalCategory(element, this); categories.add(category); - category.setIncluded(!disabled.contains(category.getId())); - Integer rank = ordered.get(category.getId()); - if (rank != null) { - int r = rank.intValue(); - boolean separate = r < 0xffff; - category.setSeparateCommand(separate); - category.setSortOrder(r); + if (parseFailed) { + // When parse has failed we do the same thing as if the user had disabled + // off ever proposal category. This causes a pop-up on first completion + // attempt with the option of resetting defaults + category.setIncluded(false); + } else { + category.setIncluded(!disabled.contains(category.getId())); + Integer rank = ordered.get(category.getId()); + if (rank != null) { + int r = rank.intValue(); + boolean separate = r < 0xffff; + category.setSeparateCommand(separate); + category.setSortOrder(r); + } } } } catch (CoreException x) { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistProcessor.java index f21a081ec23..b3117214923 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistProcessor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistProcessor.java @@ -92,7 +92,7 @@ public class ContentAssistProcessor implements IContentAssistProcessor { */ private static final String PREF_WARN_ABOUT_EMPTY_ASSIST_CATEGORY = "EmptyDefaultAssistCategory"; //$NON-NLS-1$ - private static final Comparator<CompletionProposalCategory> ORDER_COMPARATOR = new Comparator<CompletionProposalCategory>() { + private static final Comparator<CompletionProposalCategory> ORDER_COMPARATOR = new Comparator<>() { @Override public int compare(CompletionProposalCategory d1, CompletionProposalCategory d2) { return d1.getSortOrder() - d2.getSortOrder(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CSelectAnnotationRulerAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CSelectAnnotationRulerAction.java index 3ae0660a9f4..e1df83dc445 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CSelectAnnotationRulerAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CSelectAnnotationRulerAction.java @@ -51,7 +51,7 @@ public class CSelectAnnotationRulerAction extends SelectMarkerRulerAction { private ResourceBundle fBundle; // Annotations at the ruler's current line of activity, keyed by their presentation layer, // in decreasing order (i.e. top to bottom). - private static Comparator<Integer> decreasingOrder = new Comparator<Integer>() { + private static Comparator<Integer> decreasingOrder = new Comparator<>() { @Override public int compare(Integer a, Integer b) { return b - a; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/ProjectMap.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/ProjectMap.java index 3cb15089465..7d5181fb1b5 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/ProjectMap.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/ProjectMap.java @@ -142,6 +142,9 @@ class ProjectMap { */ public void save() throws CoreException { ICProjectDescription pd = CCorePlugin.getDefault().getProjectDescription(fProject, true); + if (pd == null) { + return; + } // remove current associations ICStorageElement data = pd.getStorage(ATTRVAL_STORAGEID, true); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingStructureProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingStructureProvider.java index 8e826eb549a..c1d416f8706 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingStructureProvider.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingStructureProvider.java @@ -1312,7 +1312,7 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi } } - Comparator<Tuple> comparator = new Comparator<Tuple>() { + Comparator<Tuple> comparator = new Comparator<>() { @Override public int compare(Tuple t1, Tuple t2) { return t1.position.getOffset() - t2.position.getOffset(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateVariableProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateVariableProcessor.java index bbf956e0aaf..ac21585835c 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateVariableProcessor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateVariableProcessor.java @@ -30,7 +30,7 @@ import org.eclipse.jface.text.templates.TemplateVariableResolver; public class TemplateVariableProcessor implements IContentAssistProcessor { - private static Comparator<TemplateVariableProposal> fgTemplateVariableProposalComparator = new Comparator<TemplateVariableProposal>() { + private static Comparator<TemplateVariableProposal> fgTemplateVariableProposalComparator = new Comparator<>() { @Override public int compare(TemplateVariableProposal arg0, TemplateVariableProposal arg1) { return arg0.getDisplayString().compareTo(arg1.getDisplayString()); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryListAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryListAction.java index 4a45321a7a4..c519861c770 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryListAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryListAction.java @@ -51,7 +51,7 @@ public class THHistoryListAction extends Action { setTitle(Messages.THHistoryListAction_HistoryList_title); String[] buttonLabels = new String[] { Messages.THHistoryListAction_Remove, }; - IListAdapter<ICElement> adapter = new IListAdapter<ICElement>() { + IListAdapter<ICElement> adapter = new IListAdapter<>() { @Override public void customButtonPressed(ListDialogField<ICElement> field, int index) { doCustomButtonPressed(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementImageProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementImageProvider.java index bc4bbcabd1e..50b5a652a75 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementImageProvider.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementImageProvider.java @@ -18,6 +18,7 @@ package org.eclipse.cdt.internal.ui.viewsupport; import java.util.HashMap; import java.util.Map; +import java.util.Optional; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.model.CModelException; @@ -36,6 +37,8 @@ import org.eclipse.cdt.core.model.IInclude; import org.eclipse.cdt.core.model.IIncludeReference; import org.eclipse.cdt.core.model.ILibraryReference; import org.eclipse.cdt.core.model.IMethodDeclaration; +import org.eclipse.cdt.core.model.IPragma; +import org.eclipse.cdt.core.model.IPragma.PragmaMarkInfo; import org.eclipse.cdt.core.model.ISourceReference; import org.eclipse.cdt.core.model.ISourceRoot; import org.eclipse.cdt.core.model.ITemplate; @@ -484,6 +487,15 @@ public class CElementImageProvider { case ICElement.C_USING: return getUsingImageDescriptor(); + case ICElement.C_PRAGMA: + IPragma pragma = (IPragma) celement; + Optional<PragmaMarkInfo> pragmaMarkInfo = pragma.getPragmaMarkInfo(); + if (pragmaMarkInfo.isPresent()) { + return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OUTLINE_MARK); + } else { + return null; + } + default: return getImageDescriptor(type); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementLabelComposer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementLabelComposer.java index 27a5712453b..555d85ab0f5 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementLabelComposer.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementLabelComposer.java @@ -16,6 +16,8 @@ *******************************************************************************/ package org.eclipse.cdt.internal.ui.viewsupport; +import java.util.Optional; + import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.IBinary; @@ -27,6 +29,8 @@ import org.eclipse.cdt.core.model.IFunctionDeclaration; import org.eclipse.cdt.core.model.IInheritance; import org.eclipse.cdt.core.model.IMacro; import org.eclipse.cdt.core.model.IMethodDeclaration; +import org.eclipse.cdt.core.model.IPragma; +import org.eclipse.cdt.core.model.IPragma.PragmaMarkInfo; import org.eclipse.cdt.core.model.ISourceRoot; import org.eclipse.cdt.core.model.ITemplate; import org.eclipse.cdt.core.model.ITranslationUnit; @@ -35,12 +39,18 @@ import org.eclipse.cdt.core.model.IVariableDeclaration; import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility; import org.eclipse.cdt.internal.core.model.CoreModelMessages; import org.eclipse.cdt.ui.CUIPlugin; +import org.eclipse.cdt.ui.PreferenceConstants; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; +import org.eclipse.jface.resource.ColorRegistry; +import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.viewers.StyledString; import org.eclipse.jface.viewers.StyledString.Styler; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.TextStyle; +import org.eclipse.ui.PlatformUI; // Most parts of this file were previously located in CElementLabels. // FlexibleBuffer and sub-types are taken from JDTs JavaElementLabelComposer. @@ -214,6 +224,9 @@ public class CElementLabelComposer { case ICElement.C_MACRO: appendMacroLabel((IMacro) element, flags); break; + case ICElement.C_PRAGMA: + appendPragmaLabel((IPragma) element, flags); + break; case ICElement.C_METHOD: case ICElement.C_METHOD_DECLARATION: case ICElement.C_TEMPLATE_METHOD: @@ -313,6 +326,45 @@ public class CElementLabelComposer { } /** + * Appends the label for a pragma definition to a StringBuilder. + * @param pragma a pragma + * @param flags {@link CElementLabels#MF_POST_FILE_QUALIFIED}, or 0. + */ + public void appendPragmaLabel(IPragma pragma, long flags) { + Optional<PragmaMarkInfo> pragmaMarkInfo = pragma.getPragmaMarkInfo(); + String display = pragmaMarkInfo.map(PragmaMarkInfo::getMarkName).orElseGet(() -> pragma.getElementName()); + int displayOffset = fBuffer.length(); + fBuffer.append(display); + if (pragmaMarkInfo.isPresent()) { + if (getFlag(flags, CElementLabels.COLORIZE)) { + Styler styler = new Styler() { + @Override + public void applyStyles(TextStyle textStyle) { + textStyle.font = JFaceResources.getFont(PreferenceConstants.OUTLINE_MARK_TEXT_FONT); + ColorRegistry colorRegistry = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme() + .getColorRegistry(); + textStyle.foreground = new Color( + colorRegistry.getRGB(PreferenceConstants.OUTLINE_MARK_TEXT_COLOR)); + } + }; + fBuffer.setStyle(displayOffset, fBuffer.length() - displayOffset, styler); + } + } + + if (getFlag(flags, CElementLabels.MF_POST_FILE_QUALIFIED)) { + IPath path = pragma.getPath(); + if (path != null) { + int offset = fBuffer.length(); + fBuffer.append(CElementLabels.CONCAT_STRING); + fBuffer.append(path.toString()); + if (getFlag(flags, CElementLabels.COLORIZE)) { + fBuffer.setStyle(offset, fBuffer.length() - offset, QUALIFIER_STYLE); + } + } + } + } + + /** * Appends the label for a method declaration to a StringBuilder. * @param method a method declaration * @param flags any of the M_* flags, and {@link CElementLabels#MF_POST_FILE_QUALIFIED} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementLabels.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementLabels.java index 25c9e07cd09..91fbb93be45 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementLabels.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementLabels.java @@ -323,11 +323,11 @@ public class CElementLabels { } /** - * Returns the label for a Java element with the flags as defined by this class. + * Returns the label for a C element with the flags as defined by this class. * * @param element the element to render * @param flags the rendering flags - * @return the label of the Java element + * @return the label of the C element */ public static String getElementLabel(ICElement element, long flags) { StringBuilder result = new StringBuilder(); @@ -336,11 +336,11 @@ public class CElementLabels { } /** - * Returns the styled label for a Java element with the flags as defined by this class. + * Returns the styled label for a C element with the flags as defined by this class. * * @param element the element to render * @param flags the rendering flags - * @return the label of the Java element + * @return the label of the C element * */ public static StyledString getStyledElementLabel(ICElement element, long flags) { @@ -350,7 +350,7 @@ public class CElementLabels { } /** - * Returns the label for a Java element with the flags as defined by this class. + * Returns the label for a C element with the flags as defined by this class. * * @param element the element to render * @param flags the rendering flags @@ -361,7 +361,7 @@ public class CElementLabels { } /** - * Returns the styled label for a Java element with the flags as defined by this class. + * Returns the styled label for a C element with the flags as defined by this class. * * @param element the element to render * @param flags the rendering flags diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/DecoratingCOutlineLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/DecoratingCOutlineLabelProvider.java new file mode 100644 index 00000000000..95825d28109 --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/DecoratingCOutlineLabelProvider.java @@ -0,0 +1,77 @@ +/******************************************************************************* + * 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.ui.viewsupport; + +import org.eclipse.cdt.internal.ui.cview.DividerLine; +import org.eclipse.cdt.ui.PreferenceConstants; +import org.eclipse.jface.resource.ColorRegistry; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.widgets.Event; +import org.eclipse.ui.PlatformUI; + +/** + * Specialization of the C label provider that allows drawing divider lines used + * in Outline view and information control + */ +public class DecoratingCOutlineLabelProvider extends DecoratingCLabelProvider { + + private static final int MAXIMUM_REASONABLE_WIDTH = 4000; + + public DecoratingCOutlineLabelProvider(CUILabelProvider labelProvider) { + super(labelProvider, true); + } + + @Override + protected void measure(Event event, Object element) { + if (!isOwnerDrawEnabled()) + return; + if (element instanceof DividerLine) { + GC gc = event.gc; + if (gc == null) { + // If there is no gc (can this happen?) default to a reasonably wide measurement + event.width = MAXIMUM_REASONABLE_WIDTH; + } else { + // Use the clipping area of the event to know how wide the tree control + // is so that we can make a line exactly the right size. + // This has the side effect the tree can never become narrower than this + // width as the width of the tree is in part based on the width of its + // widest item. Therefore if the view becomes smaller, a horizontal + // scroll bar is created + // We use a max of MAXIMUM_REASONABLE_WIDTH here to ensure that we don't + // end up in a loop that the item asks for a wider width, so the tree gets wider, etc. + Rectangle clipping = gc.getClipping(); + event.width = Math.min(clipping.width - event.x, MAXIMUM_REASONABLE_WIDTH); + } + } else { + super.measure(event, element); + } + } + + @Override + protected void paint(Event event, Object element) { + if (!isOwnerDrawEnabled()) + return; + if (element instanceof DividerLine) { + int y = event.y + event.height / 2; + ColorRegistry colorRegistry = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme() + .getColorRegistry(); + event.gc.setForeground(new Color(colorRegistry.getRGB(PreferenceConstants.OUTLINE_MARK_DIVIDER_COLOR))); + // draw a line as wide as possible, we can't use event.width here as that doesn't take into account + // our declared width in measure. On Windows this is clipped to the size we measured above, but + // on GTK and macOS this is clipped to the containing tree control. + event.gc.drawLine(0, y, event.x + MAXIMUM_REASONABLE_WIDTH, y); + } else { + super.paint(event, element); + } + } +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/SelectionListenerWithASTManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/SelectionListenerWithASTManager.java index 91552f75bbd..6c00ecba7a4 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/SelectionListenerWithASTManager.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/SelectionListenerWithASTManager.java @@ -35,6 +35,7 @@ import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.ui.ISelectionListener; +import org.eclipse.ui.PlatformUI; import org.eclipse.ui.texteditor.ITextEditor; /** @@ -134,7 +135,7 @@ public class SelectionListenerWithASTManager { // Try to acquire the lock while (!monitor.isCanceled() && !fJobLock.acquire(10)) { } - if (!monitor.isCanceled() && isSelectionValid(selection)) { + if (!monitor.isCanceled() && isSelectionValid(selection) && PlatformUI.isWorkbenchRunning()) { return calculateASTandInform(workingCopy, selection, monitor); } } catch (InterruptedException e) { 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/internal/ui/wizards/settingswizards/IncludePathsSettingsProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/IncludePathsSettingsProcessor.java index 1df9bd7106e..1c3e926e6e9 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/IncludePathsSettingsProcessor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/IncludePathsSettingsProcessor.java @@ -76,7 +76,6 @@ public class IncludePathsSettingsProcessor extends SettingsProcessor { content.startElement(NONE, NONE, INCLUDE_PATH_ELEMENT, attrib); content.characters(value, 0, value.length); content.endElement(NONE, NONE, INCLUDE_PATH_ELEMENT); - newline(content); } catch (SAXException e) { throw new SettingsImportExportException(e); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/MacroSettingsProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/MacroSettingsProcessor.java index 5dd69f82ab8..3b799b48197 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/MacroSettingsProcessor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/MacroSettingsProcessor.java @@ -74,7 +74,6 @@ public class MacroSettingsProcessor extends SettingsProcessor { try { content.startElement(NONE, NONE, MACRO_ELEMENT, null); - newline(content); content.startElement(NONE, NONE, NAME_ELEMENT, null); content.characters(name, 0, name.length); @@ -83,10 +82,8 @@ public class MacroSettingsProcessor extends SettingsProcessor { content.startElement(NONE, NONE, VALUE_ELEMENT, null); content.characters(value, 0, value.length); content.endElement(NONE, NONE, VALUE_ELEMENT); - newline(content); content.endElement(NONE, NONE, MACRO_ELEMENT); - newline(content); } catch (SAXException e) { throw new SettingsImportExportException(e); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsExportStrategy.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsExportStrategy.java index ebecc5c3d45..72f9fde5d06 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsExportStrategy.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsExportStrategy.java @@ -13,9 +13,8 @@ *******************************************************************************/ package org.eclipse.cdt.internal.ui.wizards.settingswizards; -import java.io.FileWriter; +import java.io.FileOutputStream; import java.io.IOException; -import java.io.Writer; import java.net.URI; import java.util.List; @@ -34,7 +33,6 @@ import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.core.filesystem.URIUtil; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; -import org.xml.sax.ContentHandler; import org.xml.sax.SAXException; import org.xml.sax.helpers.AttributesImpl; @@ -82,12 +80,12 @@ public class ProjectSettingsExportStrategy implements IProjectSettingsWizardPage // do nothing } - private Writer getWriter(IProjectSettingsWizardPage page) throws IOException { + private FileOutputStream getFileOutputStream(IProjectSettingsWizardPage page) throws IOException { IPath path = new Path(page.getDestinationFilePath()); if (!IProjectSettingsWizardPage.FILENAME_EXTENSION.equals(path.getFileExtension())) path.addFileExtension(IProjectSettingsWizardPage.FILENAME_EXTENSION); - return new FileWriter(path.toFile()); + return new FileOutputStream(path.toFile()); } /** @@ -107,22 +105,24 @@ public class ProjectSettingsExportStrategy implements IProjectSettingsWizardPage } // gets a writer for the file that was selected by the user - Writer writer; + FileOutputStream outputStream; try { - writer = getWriter(page); + outputStream = getFileOutputStream(page); } catch (IOException e) { page.showErrorDialog(Messages.ProjectSettingsExportStrategy_fileOpenError, Messages.ProjectSettingsExportStrategy_couldNotOpen); return false; } - // stream the results to the writer as text - handler.setResult(new StreamResult(writer)); - // write out the XML header Transformer transformer = handler.getTransformer(); - transformer.setOutputProperty(OutputKeys.ENCODING, "ISO-8859-1"); //$NON-NLS-1$ + transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); //$NON-NLS-1$ transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$ + transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); //$NON-NLS-1$ //$NON-NLS-2$ + transformer.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, "yes"); //$NON-NLS-1$ + + // stream the results to the writer as text + handler.setResult(new StreamResult(outputStream)); List<ISettingsProcessor> exporters = page.getSelectedSettingsProcessors(); @@ -134,27 +134,21 @@ public class ProjectSettingsExportStrategy implements IProjectSettingsWizardPage AttributesImpl attributes = new AttributesImpl(); handler.startDocument(); - newline(handler); handler.startElement(NONE, NONE, ROOT_ELEMENT, null); - newline(handler); for (ISettingsProcessor exporter : exporters) { attributes.clear(); attributes.addAttribute(NONE, NONE, SECTION_NAME_ATTRIBUTE, CDATA, exporter.getSectionName()); handler.startElement(NONE, NONE, SECTION_ELEMENT, attributes); - newline(handler); // each exporter is responsible for writing out its own section of the file exporter.writeSectionXML(projectRoot, handler); handler.endElement(NONE, NONE, SECTION_ELEMENT); - newline(handler); } handler.endElement(NONE, NONE, ROOT_ELEMENT); - newline(handler); handler.endDocument(); - newline(handler); result = true; } catch (SAXException e) { @@ -175,11 +169,4 @@ public class ProjectSettingsExportStrategy implements IProjectSettingsWizardPage return result; } - /** - * Outputs a newline (\n) to the given ContentHandler. - */ - private static void newline(ContentHandler handler) throws SAXException { - handler.ignorableWhitespace("\n".toCharArray(), 0, 1); //$NON-NLS-1$ - } - } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/SettingsProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/SettingsProcessor.java index 0ce07081dea..3dfb4119226 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/SettingsProcessor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/SettingsProcessor.java @@ -37,6 +37,7 @@ public abstract class SettingsProcessor implements ISettingsProcessor { protected static final String NONE = ""; //$NON-NLS-1$ protected static final String CDATA = "CDATA"; //$NON-NLS-1$ + protected static final String ID_ATTRIBUTE = "id"; //$NON-NLS-1$ protected static final String NAME_ATTRIBUTE = "name"; //$NON-NLS-1$ protected static final String LANGUAGE_ELEMENT = "language"; //$NON-NLS-1$ @@ -51,13 +52,6 @@ public abstract class SettingsProcessor implements ISettingsProcessor { protected abstract void readSettings(ICLanguageSetting setting, Element language) throws SettingsImportExportException; - /** - * Outputs a newline (\n) to the given ContentHandler. - */ - protected static void newline(ContentHandler handler) throws SAXException { - handler.ignorableWhitespace("\n".toCharArray(), 0, 1); //$NON-NLS-1$ - } - @Override public void writeSectionXML(ICFolderDescription projectRoot, ContentHandler content) throws SettingsImportExportException { @@ -66,12 +60,14 @@ public abstract class SettingsProcessor implements ISettingsProcessor { try { for (ICLanguageSetting language : languages) { - //TODO for some reason language.getLanguageId() is returning null + String languageId = language.getLanguageId(); String languageName = language.getName(); attributes.clear(); + if (languageId != null) { + attributes.addAttribute(NONE, NONE, ID_ATTRIBUTE, CDATA, languageId); + } attributes.addAttribute(NONE, NONE, NAME_ATTRIBUTE, CDATA, languageName); content.startElement(NONE, NONE, LANGUAGE_ELEMENT, attributes); - newline(content); ICLanguageSettingEntry[] settings = language.getSettingEntries(getSettingsType()); @@ -81,9 +77,7 @@ public abstract class SettingsProcessor implements ISettingsProcessor { } } - newline(content); content.endElement(NONE, NONE, LANGUAGE_ELEMENT); - newline(content); } } catch (SAXException e) { @@ -95,15 +89,21 @@ public abstract class SettingsProcessor implements ISettingsProcessor { public void readSectionXML(ICFolderDescription projectRoot, Element section) throws SettingsImportExportException { ICLanguageSetting[] languageSettings = projectRoot.getLanguageSettings(); + Map<String, ICLanguageSetting> languageIdMap = new HashMap<>(); Map<String, ICLanguageSetting> languageMap = new HashMap<>(); for (ICLanguageSetting language : languageSettings) { + languageIdMap.put(language.getLanguageId(), language); languageMap.put(language.getName(), language); } List<Element> elements = XMLUtils.extractChildElements(section, LANGUAGE_ELEMENT); // throws SettingsImportExportException for (Element languageElement : elements) { - String languageName = languageElement.getAttribute(NAME_ATTRIBUTE); - ICLanguageSetting setting = languageMap.get(languageName); + String languageId = languageElement.getAttribute(ID_ATTRIBUTE); + ICLanguageSetting setting = languageIdMap.get(languageId); + if (setting == null) { + String languageName = languageElement.getAttribute(NAME_ATTRIBUTE); + setting = languageMap.get(languageName); + } if (setting != null) readSettings(setting, languageElement); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/AbstractWorkingSetConfigsContribution.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/AbstractWorkingSetConfigsContribution.java index e8ddb79e824..27a8ba4b190 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/AbstractWorkingSetConfigsContribution.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/AbstractWorkingSetConfigsContribution.java @@ -38,7 +38,7 @@ abstract class AbstractWorkingSetConfigsContribution extends CompoundContributio private IWorkingSetProxy workingSet; - private Comparator<IWorkingSetConfiguration> configOrdering = new Comparator<IWorkingSetConfiguration>() { + private Comparator<IWorkingSetConfiguration> configOrdering = new Comparator<>() { private Collator collator = Collator.getInstance(); @Override diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/ChangeBuildConfigContribution.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/ChangeBuildConfigContribution.java new file mode 100644 index 00000000000..0f6a572690a --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/ChangeBuildConfigContribution.java @@ -0,0 +1,298 @@ +/******************************************************************************* + * Copyright (c) 2020 Simeon Andreev 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: + * Simeon Andreev - initial API and implementation + *******************************************************************************/ + +package org.eclipse.cdt.internal.ui.workingsets; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.SortedSet; +import java.util.TreeSet; + +import org.eclipse.cdt.core.model.CoreModel; +import org.eclipse.cdt.core.model.ICElement; +import org.eclipse.cdt.core.model.ICProject; +import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; +import org.eclipse.cdt.core.settings.model.ICProjectDescription; +import org.eclipse.cdt.internal.ui.cview.IncludeRefContainer; +import org.eclipse.cdt.internal.ui.cview.IncludeReferenceProxy; +import org.eclipse.cdt.ui.CUIPlugin; +import org.eclipse.cdt.ui.actions.ChangeConfigAction; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.jface.action.ActionContributionItem; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.action.IContributionItem; +import org.eclipse.jface.text.ITextSelection; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IViewPart; +import org.eclipse.ui.IViewReference; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.actions.CompoundContributionItem; + +/** + * A dynamic contribution of items to change the build configuration of selected projects. + * + */ +public class ChangeBuildConfigContribution extends CompoundContributionItem { + + @Override + protected IContributionItem[] getContributionItems() { + HashSet<IProject> projects = findProjects(); + + SortedSet<String> configNames = new TreeSet<>(); + String sCurrentConfig = null; + boolean bCurrentConfig = true; + for (IProject prj : projects) { + ICConfigurationDescription[] cfgDescs = getCfgs(prj); + + String sActiveConfig = null; + // Store names and detect active configuration + for (ICConfigurationDescription cfgDesc : cfgDescs) { + String s = cfgDesc.getName(); + if (!configNames.contains(s)) + configNames.add(s); + if (cfgDesc.isActive()) + sActiveConfig = s; + } + + // Check whether all projects have the same active configuration + if (bCurrentConfig) { + if (sCurrentConfig == null) + sCurrentConfig = sActiveConfig; + else { + if (!sCurrentConfig.equals(sActiveConfig)) + bCurrentConfig = false; + } + } + } + + List<ActionContributionItem> actions = new ArrayList<>(); + int accel = 0; + for (String sName : configNames) { + String sDesc = null; + boolean commonName = true; + boolean commonDesc = true; + boolean firstProj = true; + for (IProject prj : projects) { + ICConfigurationDescription[] cfgDescs = getCfgs(prj); + int i = 0; + for (; i < cfgDescs.length; i++) { + if (cfgDescs[i].getName().equals(sName)) { + String sNewDesc = cfgDescs[i].getDescription(); + if (sNewDesc != null && sNewDesc.length() == 0) { + sNewDesc = null; + } + if (commonDesc) { + if (firstProj) { + sDesc = sNewDesc; + firstProj = false; + } else if (sNewDesc == null && sDesc != null + || sNewDesc != null && !sNewDesc.equals(sDesc)) { + commonDesc = false; + } + } + break; + } + } + if (i == cfgDescs.length) { + commonName = false; + break; + } + } + if (commonName) { + StringBuffer builder = new StringBuffer(sName); + if (commonDesc) { + if (sDesc != null) { + builder.append(" ("); //$NON-NLS-1$ + builder.append(sDesc); + builder.append(")"); //$NON-NLS-1$ + } + } else { + builder.append(" (...)"); //$NON-NLS-1$ + } + + IAction action = new ChangeConfigAction(projects, sName, builder.toString(), accel + 1); + if (bCurrentConfig && sCurrentConfig != null && sCurrentConfig.equals(sName)) { + action.setChecked(true); + } + ActionContributionItem item = new ActionContributionItem(action); + actions.add(item); + accel++; + } + } + return actions.toArray(new IContributionItem[0]); + } + + private static HashSet<IProject> findProjects() { + HashSet<IProject> fProjects = new LinkedHashSet<>(); + ISelection selection = CUIPlugin.getActivePage().getSelection(); + boolean badObject = addProjectsFromSelection(selection, fProjects); + + if (badObject || fProjects.isEmpty()) { + // Check for lone CDT project in workspace + IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects(); + if (projects != null && projects.length == 1) { + IProject project = projects[0]; + if (CoreModel.getDefault().isNewStyleProject(project) && (getCfgs(project).length > 0)) { + fProjects.add(project); + } + } + + // Check the three supported views + IWorkbenchPage page = CUIPlugin.getActivePage(); + int viewCount = 0; + if (page != null) { + IViewReference theViewRef = null; + IViewReference viewRef = null; + + theViewRef = page.findViewReference("org.eclipse.cdt.ui.CView"); //$NON-NLS-1$ + viewCount += (theViewRef != null) ? 1 : 0; + + viewRef = page.findViewReference("org.eclipse.ui.navigator.ProjectExplorer"); //$NON-NLS-1$ + viewCount += (viewRef != null) ? 1 : 0; + theViewRef = (theViewRef == null) ? viewRef : theViewRef; + + viewRef = page.findViewReference("org.eclipse.ui.views.ResourceNavigator"); //$NON-NLS-1$ + viewCount += (viewRef != null) ? 1 : 0; + theViewRef = (theViewRef == null) ? viewRef : theViewRef; + + if (theViewRef != null && viewCount == 1) { + IViewPart view = theViewRef.getView(false); + if (view != null) { + ISelection cdtSelection = view.getSite().getSelectionProvider().getSelection(); + if (cdtSelection != null) { + if (!cdtSelection.isEmpty()) { + if (!cdtSelection.equals(selection)) { + addProjectsFromSelection(cdtSelection, fProjects); + } + } + } + } + } + } + } + return fProjects; + } + + private static boolean addProjectsFromSelection(ISelection selection, HashSet<IProject> fProjects) { + boolean badObject = false; + if (selection != null) { + if (selection instanceof IStructuredSelection) { + if (selection.isEmpty()) { + // could be a form editor or something. try to get the project from the active part + IWorkbenchPage page = CUIPlugin.getActivePage(); + if (page != null) { + IWorkbenchPart part = page.getActivePart(); + if (part != null) { + Object o = part.getAdapter(IResource.class); + if (o != null && o instanceof IResource) { + fProjects.add(((IResource) o).getProject()); + } + } + } + } + Iterator<?> iter = ((IStructuredSelection) selection).iterator(); + while (iter.hasNext()) { + Object selItem = iter.next(); + IProject project = null; + if (selItem instanceof ICElement) { + ICProject cproject = ((ICElement) selItem).getCProject(); + if (cproject != null) + project = cproject.getProject(); + } else if (selItem instanceof IResource) { + project = ((IResource) selItem).getProject(); + } else if (selItem instanceof IncludeRefContainer) { + ICProject fCProject = ((IncludeRefContainer) selItem).getCProject(); + if (fCProject != null) + project = fCProject.getProject(); + } else if (selItem instanceof IncludeReferenceProxy) { + IncludeRefContainer irc = ((IncludeReferenceProxy) selItem).getIncludeRefContainer(); + if (irc != null) { + ICProject fCProject = irc.getCProject(); + if (fCProject != null) + project = fCProject.getProject(); + } + } else if (selItem instanceof IAdaptable) { + Object adapter = ((IAdaptable) selItem).getAdapter(IProject.class); + if (adapter != null && adapter instanceof IProject) { + project = (IProject) adapter; + } + } + // Check whether the project is CDT project + if (project != null) { + if (!CoreModel.getDefault().isNewStyleProject(project)) + project = null; + else { + ICConfigurationDescription[] tmp = getCfgs(project); + if (tmp.length == 0) + project = null; + } + } + if (project != null) { + fProjects.add(project); + } else { + badObject = true; + break; + } + } + } else if (selection instanceof ITextSelection) { + // If a text selection check the selected part to see if we can find + // an editor part that we can adapt to a resource and then + // back to a project. + IWorkbenchWindow window = CUIPlugin.getActiveWorkbenchWindow(); + if (window != null) { + IWorkbenchPage page = window.getActivePage(); + if (page != null) { + IWorkbenchPart part = page.getActivePart(); + if (part instanceof IEditorPart) { + IEditorPart epart = (IEditorPart) part; + IResource resource = epart.getEditorInput().getAdapter(IResource.class); + if (resource != null) { + IProject project = resource.getProject(); + badObject = !(project != null && CoreModel.getDefault().isNewStyleProject(project)); + + if (!badObject) { + fProjects.add(project); + } + } + } + } + } + + } + } + return badObject; + } + + private static ICConfigurationDescription[] getCfgs(IProject prj) { + ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(prj, false); + if (prjd != null) { + ICConfigurationDescription[] cfgs = prjd.getConfigurations(); + if (cfgs != null) { + return cfgs; + } + } + + return new ICConfigurationDescription[0]; + } +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/HasManagedCdtProjectSelection.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/HasManagedCdtProjectSelection.java new file mode 100644 index 00000000000..cc1f4800539 --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/HasManagedCdtProjectSelection.java @@ -0,0 +1,50 @@ +/******************************************************************************* + * Copyright (c) 2020 Simeon Andreev 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: + * Simeon Andreev - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.ui.workingsets; + +import java.util.Collection; + +import org.eclipse.cdt.ui.newui.ManageConfigSelector; +import org.eclipse.core.expressions.PropertyTester; +import org.eclipse.core.resources.IProject; + +/** + * Property tester for the enablement of the command handled by {@link org.eclipse.cdt.internal.ui.actions.ManageConfigsHandler}. + * Will evaluate {@code true} if the current selection is a managed CDT project, contains a managed CDT project, or belongs to a managed CDT project. + */ +public class HasManagedCdtProjectSelection extends PropertyTester { + + private static final String PROPERTY_HAS_MANAGED_CDT_PROJECT_SELECTION = "hasManagedCdtProjectSelection"; //$NON-NLS-1$ + + @Override + public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { + if (PROPERTY_HAS_MANAGED_CDT_PROJECT_SELECTION.equals(property)) { + boolean hasNonEmptyWorksets = hasManagedCdtProjectSelection(receiver); + return hasNonEmptyWorksets; + } + return false; + } + + private static boolean hasManagedCdtProjectSelection(Object receiver) { + if (receiver instanceof Collection) { + Collection<?> selection = (Collection<?>) receiver; + if (!selection.isEmpty()) { + IProject[] obs = ManageConfigSelector.getProjects(selection.toArray()); + return ManageConfigSelector.getManager(obs) != null; + } + } + return false; + } + +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/NonEmptyWorkingSetPropertyTester.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/NonEmptyWorkingSetPropertyTester.java new file mode 100644 index 00000000000..2944480388d --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/NonEmptyWorkingSetPropertyTester.java @@ -0,0 +1,50 @@ +/******************************************************************************* + * Copyright (c) 2020 Simeon Andreev 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: + * Simeon Andreev - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.ui.workingsets; + +import org.eclipse.core.expressions.PropertyTester; +import org.eclipse.ui.IWorkingSet; +import org.eclipse.ui.IWorkingSetManager; +import org.eclipse.ui.PlatformUI; + +/** + * Property tester for the enablement of the command handled by {@link org.eclipse.cdt.internal.ui.actions.WorkingSetConfigHandler}. + * Will evaluate {@code true} if there is a non-empty working set in the workspace. + */ +public class NonEmptyWorkingSetPropertyTester extends PropertyTester { + + private static final String PROPERTY_HAS_NON_EMPTY_WORKING_SET = "hasNonEmptyWorkingSet"; //$NON-NLS-1$ + + @Override + public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { + if (PROPERTY_HAS_NON_EMPTY_WORKING_SET.equals(property)) { + boolean hasNonEmptyWorksets = hasNonEmptyWorksets(); + return hasNonEmptyWorksets; + } + return false; + } + + private static boolean hasNonEmptyWorksets() { + IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager(); + IWorkingSet[] workingSets = workingSetManager.getWorkingSets(); + if (workingSets != null) { + for (IWorkingSet workingSet : workingSets) { + if (!workingSet.isEmpty()) { + return true; + } + } + } + return false; + } +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CDTSharedImages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CDTSharedImages.java index b6f535dcaff..08180632a8c 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CDTSharedImages.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CDTSharedImages.java @@ -120,6 +120,8 @@ public class CDTSharedImages { public static final String IMG_OBJS_USER = "icons/obj16/person-me.gif"; //$NON-NLS-1$ /** @since 5.6 */ public static final String IMG_OBJS_WRAP_LINE = "icons/elcl16/wrap_lines.png"; //$NON-NLS-1$ + /** @since 7.1 */ + public static final String IMG_OBJS_BRING_CONSOLE_TO_TOP_ON_BUILD = "icons/elcl16/bring_console_to_top_on_build.png"; //$NON-NLS-1$ public static final String IMG_OBJS_CDT_TESTING = "icons/obj16/flask.png"; //$NON-NLS-1$ public static final String IMG_OBJS_NLS_NEVER_TRANSLATE = "icons/obj16/never_translate.gif"; //$NON-NLS-1$ @@ -212,6 +214,9 @@ public class CDTSharedImages { public static final String IMG_VIEW_PIN_ACTION_B = "icons/obj16/toolbar_pinned_b.gif"; //$NON-NLS-1$ public static final String IMG_VIEW_PIN_ACTION_MULTI = "icons/obj16/toolbar_pinned_multi.gif"; //$NON-NLS-1$ + /** @since 7.3*/ + public static final String IMG_OUTLINE_MARK = "icons/obj16/outline_mark.png"; //$NON-NLS-1$ + private static SharedImagesFactory imagesFactory = new SharedImagesFactory(CUIPlugin.getDefault()); /** diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementContentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementContentProvider.java index 979f4f92984..6e567e6df84 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementContentProvider.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementContentProvider.java @@ -97,7 +97,7 @@ public class CElementContentProvider extends BaseCElementContentProvider * Creates a new content provider for C elements. */ public CElementContentProvider(boolean provideMembers, boolean provideWorkingCopy) { - super(provideMembers, provideWorkingCopy); + super(provideMembers, provideWorkingCopy, false, () -> false); } @Override diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java index 286741006d1..e666403002b 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java @@ -560,6 +560,7 @@ public class CUIPlugin extends AbstractUIPlugin { fBuildConsoleManagers.put(contextId, manager); manager.startup(name, contextId, iconUrl); } + manager.reinitaliazeIfNecessary(); return manager; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java index 42d615b7390..25ad5dd52e0 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java @@ -561,6 +561,24 @@ public class PreferenceConstants { public final static String EDITOR_TEXT_FONT = "org.eclipse.cdt.ui.editors.textfont"; //$NON-NLS-1$ /** + * The symbolic font name for the C/C++ outline pragma mark or pragma region text font. + * @since 7.3 + */ + public final static String OUTLINE_MARK_TEXT_FONT = "org.eclipse.cdt.ui.outline.mark.textfont"; //$NON-NLS-1$ + + /** + * The color preference for the C/C++ outline pragma mark or pragma region text font color. + * @since 7.3 + */ + public final static String OUTLINE_MARK_TEXT_COLOR = "org.eclipse.cdt.ui.outline.mark.textcolor"; //$NON-NLS-1$ + + /** + * The color preference for the C/C++ outline pragma mark or pragma region divider color. + * @since 7.3 + */ + public final static String OUTLINE_MARK_DIVIDER_COLOR = "org.eclipse.cdt.ui.outline.mark.dividercolor"; //$NON-NLS-1$ + + /** * A named preference that controls whether the cview's selection is linked to the active * editor. * <p> @@ -767,6 +785,14 @@ public class PreferenceConstants { public static final String OUTLINE_LINK_TO_EDITOR = "org.eclipse.cdt.ui.outline.linktoeditor"; //$NON-NLS-1$ /** + * A named preference that controls whether the Outline view should hide pragma mark directives. + * <p> + * Value is of type {@code Boolean}. + * @since 7.3 + */ + public static final String OUTLINE_HIDE_PRAGMA_MARK = "org.eclipse.cdt.ui.outline.hidePragmaMark"; //$NON-NLS-1$ + + /** * A named preference that controls whether include directives should be grouped in * the C/C++ Projects view and the Project Explorer view. * <p> diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigMenuAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigMenuAction.java index 06b6fea382e..aae36101f0d 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigMenuAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigMenuAction.java @@ -30,7 +30,10 @@ import org.eclipse.ui.IWorkbenchWindowPulldownDelegate2; /** * Action which changes active build configuration of the current project + * + * @deprecated Replaced with menu contribution {@link org.eclipse.cdt.internal.ui.workingsets.ChangeBuildConfigContribution}. */ +@Deprecated(forRemoval = true) public class ChangeBuildConfigMenuAction extends ChangeBuildConfigActionBase implements IWorkbenchWindowPulldownDelegate2 { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ManageConfigsAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ManageConfigsAction.java index 2027fd369fa..0a09b297c1c 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ManageConfigsAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ManageConfigsAction.java @@ -28,7 +28,10 @@ import org.eclipse.ui.IWorkbenchWindowPulldownDelegate2; /** * Action which lets to manage (add/remove etc.) build configurations of the project. + * + * @deprecated Replaced with a command and handler {@link org.eclipse.cdt.internal.ui.actions.ManageConfigsHandler}. */ +@Deprecated(forRemoval = true) public class ManageConfigsAction implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate { IProject[] obs = null; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/WorkingSetConfigAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/WorkingSetConfigAction.java index d238c84c8d3..df549077886 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/WorkingSetConfigAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/WorkingSetConfigAction.java @@ -27,7 +27,9 @@ import org.eclipse.ui.IWorkingSetManager; import org.eclipse.ui.PlatformUI; /** + * @deprecated Replaced with a command and handler {@link org.eclipse.cdt.internal.ui.actions.WorkingSetConfigHandler}. */ +@Deprecated(forRemoval = true) public class WorkingSetConfigAction implements IWorkbenchWindowActionDelegate, IPropertyChangeListener { private static final IWorkingSetManager wsm = PlatformUI.getWorkbench().getWorkingSetManager(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/BinaryParserBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/BinaryParserBlock.java index 768c24923ec..5f4a0b12ef6 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/BinaryParserBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/BinaryParserBlock.java @@ -115,7 +115,7 @@ public class BinaryParserBlock extends AbstractBinaryParserPage { String[] buttonLabels = new String[] { CUIMessages.BinaryParserBlock_button_up, CUIMessages.BinaryParserBlock_button_down }; - IListAdapter<BinaryParserConfiguration> listAdapter = new IListAdapter<BinaryParserConfiguration>() { + IListAdapter<BinaryParserConfiguration> listAdapter = new IListAdapter<>() { @Override public void customButtonPressed(ListDialogField<BinaryParserConfiguration> field, int index) { @@ -131,8 +131,7 @@ public class BinaryParserBlock extends AbstractBinaryParserPage { } }; - binaryList = new CheckedListDialogField<BinaryParserConfiguration>(listAdapter, buttonLabels, - new BinaryParserLabelProvider()) { + binaryList = new CheckedListDialogField<>(listAdapter, buttonLabels, new BinaryParserLabelProvider()) { @Override protected int getListStyle() { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DocCommentOwnerBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DocCommentOwnerBlock.java index 06f0a29f756..154bb79face 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DocCommentOwnerBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DocCommentOwnerBlock.java @@ -16,6 +16,7 @@ package org.eclipse.cdt.ui.dialogs; import org.eclipse.cdt.doxygen.core.DoxygenPreferences; +import org.eclipse.cdt.internal.core.CCoreInternals; import org.eclipse.cdt.internal.ui.dialogs.DocCommentOwnerArea; import org.eclipse.cdt.internal.ui.text.doctools.DocCommentOwnerManager; import org.eclipse.cdt.ui.text.doctools.IDocCommentOwner; @@ -120,6 +121,7 @@ public class DocCommentOwnerBlock extends AbstractCOptionPage { fManager.setCommentOwner(project, newOwner, true); } docCommentOwnerArea.apply(doxygenPreferences.projectStorage(project)); + CCoreInternals.savePreferences(project, true); } public IProject getProject() { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/TabFolderOptionBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/TabFolderOptionBlock.java index d0c51fc63ac..d564a8c2473 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/TabFolderOptionBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/TabFolderOptionBlock.java @@ -25,6 +25,8 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.SubMonitor; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.CTabFolder; +import org.eclipse.swt.custom.CTabItem; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.graphics.Image; @@ -33,7 +35,6 @@ import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.TabFolder; import org.eclipse.swt.widgets.TabItem; public abstract class TabFolderOptionBlock { @@ -49,7 +50,7 @@ public abstract class TabFolderOptionBlock { protected ICOptionContainer fParent; private ICOptionPage fCurrentPage; - private TabFolder fFolder; + private CTabFolder fFolder; public TabFolderOptionBlock(boolean showMessageArea) { bShowMessageArea = showMessageArea; @@ -116,7 +117,7 @@ public abstract class TabFolderOptionBlock { } protected void createFolder(Composite parent) { - fFolder = new TabFolder(parent, SWT.NONE); + fFolder = new CTabFolder(parent, SWT.NONE); fFolder.setLayoutData(new GridData(GridData.FILL_BOTH)); fFolder.setLayout(new TabFolderLayout()); @@ -133,7 +134,7 @@ public abstract class TabFolderOptionBlock { } protected void addTab(ICOptionPage tab) { - TabItem item = new TabItem(fFolder, SWT.NONE); + CTabItem item = new CTabItem(fFolder, SWT.NONE); item.setText(tab.getTitle()); Image img = tab.getImage(); if (img != null) @@ -143,6 +144,9 @@ public abstract class TabFolderOptionBlock { tab.createControl(item.getParent()); item.setControl(tab.getControl()); addOptionPage(tab); + if (fFolder.getSelection() == null) { + fFolder.setSelection(item); + } } abstract protected void addTabs(); 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/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPage.java index 8de06a776fd..cbb6e1d1055 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPage.java @@ -21,7 +21,6 @@ package org.eclipse.cdt.ui.newui; import java.io.File; import java.lang.reflect.InvocationTargetException; -import java.net.URL; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -151,7 +150,7 @@ public abstract class AbstractPage extends PropertyPage implements IPreferencePa private static final String PREF_ASK_REINDEX = "askReindex"; //$NON-NLS-1$ - private Map<URL, Image> loadedIcons = new HashMap<>(); + private List<Image> loadedIcons = new ArrayList<>(); private static Map<Class<? extends AbstractPage>, Class<? extends ICPropertyTab>> recentTabs = new HashMap<>(); private final Image IMG_WARN = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_REFACTORING_WARNING); @@ -168,20 +167,60 @@ public abstract class AbstractPage extends PropertyPage implements IPreferencePa /* * Bookeeping variables */ + /** + * @deprecated This field was never meant to be API. This field will be made private. + */ + @Deprecated(forRemoval = true) protected boolean noContentOnPage = false; + /** + * @deprecated This field was never meant to be API. This field will be made private. + */ + @Deprecated(forRemoval = true) protected boolean displayedConfig = false; + /** + * @deprecated This field was never meant to be API. This field will be made private. + */ + @Deprecated(forRemoval = true) protected IResource internalElement = null; + /** + * @deprecated This field was never meant to be API. This field will be made private. + */ + @Deprecated(forRemoval = true) protected boolean isProject = false; + /** + * @deprecated This field was never meant to be API. This field will be made private. + */ + @Deprecated(forRemoval = true) protected boolean isFolder = false; + /** + * @deprecated This field was never meant to be API. This field will be made private. + */ + @Deprecated(forRemoval = true) protected boolean isFile = false; // tabs + /** + * @deprecated This field was never meant to be API. This field will be made private. + */ + @Deprecated(forRemoval = true) protected TabFolder folder; + /** + * @deprecated This field was never meant to be API. This field will be made private. + */ + @Deprecated(forRemoval = true) protected ArrayList<InternalTab> itabs = new ArrayList<>(); + /** + * @deprecated This field was never meant to be API. This field will be made private. + */ + @Deprecated(forRemoval = true) protected ICPropertyTab currentTab; private static boolean isNewOpening = true; + /** + * @deprecated This class was never meant to be API. This class will be made private. + */ + @Deprecated(forRemoval = true) protected class InternalTab { Composite comp; String text; @@ -567,7 +606,7 @@ public abstract class AbstractPage extends PropertyPage implements IPreferencePa * which do not share ICProjectDescription instance. * But some changes may be saved wrong if they are affected * by data from another property pages (Discovery options etc). - + * * To enable 2nd mode, just create the following file: * <workspace>/.metadata/.plugins/org.eclipse.cdt.ui/apply_mode */ @@ -1052,7 +1091,7 @@ public abstract class AbstractPage extends PropertyPage implements IPreferencePa if (displayedConfig) forEach(ICPropertyTab.DISPOSE); // Dispose any loaded images - for (Image img : loadedIcons.values()) + for (Image img : loadedIcons) img.dispose(); loadedIcons.clear(); @@ -1196,7 +1235,6 @@ public abstract class AbstractPage extends PropertyPage implements IPreferencePa private Image getIcon(IConfigurationElement config) { ImageDescriptor idesc = null; - URL url = null; String iconName = config.getAttribute(IMAGE_NAME); if (iconName != null) { idesc = ResourceLocator.imageDescriptorFromBundle( @@ -1206,7 +1244,7 @@ public abstract class AbstractPage extends PropertyPage implements IPreferencePa if (idesc == null) return null; Image img = idesc.createImage(); - loadedIcons.put(url, img); + loadedIcons.add(img); return img; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CLocationTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CLocationTab.java index 79569eba077..fc74fdf3f4d 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CLocationTab.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CLocationTab.java @@ -19,6 +19,7 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Optional; import java.util.Set; import org.eclipse.cdt.core.model.ICProject; @@ -45,6 +46,8 @@ import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerFilter; import org.eclipse.jface.window.Window; import org.eclipse.swt.SWT; +import org.eclipse.swt.events.MouseAdapter; +import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.graphics.Image; @@ -144,6 +147,15 @@ public abstract class CLocationTab extends AbstractCPropertyTab { updateButtons(); } }); + tree.getTree().addMouseListener(new MouseAdapter() { + @Override + public void mouseDoubleClick(MouseEvent e) { + TreeItem[] sel = tree.getTree().getSelection(); + Optional<_Entry> entry = getSelectedEntry(sel); + if (entry.isPresent()) + handleEditEntry(entry.get()); + } + }); initButtons(new String[] { Messages.CLocationTab_4, Messages.CLocationTab_5, Messages.CLocationTab_6, Messages.CLocationTab_7 }, 150); @@ -237,25 +249,9 @@ public abstract class CLocationTab extends AbstractCPropertyTab { break; // edit filter case 2: - if (sel.length == 0) - return; - Object data = sel[0].getData(); - _Entry entry = null; - if (data instanceof _Entry) - entry = (_Entry) data; - else if (data instanceof _Filter) - entry = ((_Filter) data).entry; - else - return; - ExPatternDialog dialog = new ExPatternDialog(usercomp.getShell(), entry.ent.getExclusionPatterns(), - entry.getPath(), page.getProject()); - if (dialog.open() == Window.OK) { - IPath[] ps = dialog.getExclusionPattern(); - IPath path = entry.getPath(); - boolean isWsp = entry.ent.isValueWorkspacePath(); - entry.ent = newEntry(path, ps, isWsp); - saveData(); - } + Optional<_Entry> entry = getSelectedEntry(sel); + if (entry.isPresent()) + handleEditEntry(entry.get()); break; case 3: if (sel.length == 0) @@ -271,6 +267,31 @@ public abstract class CLocationTab extends AbstractCPropertyTab { } } + private void handleEditEntry(_Entry entry) { + ExPatternDialog dialog = new ExPatternDialog(usercomp.getShell(), entry.ent.getExclusionPatterns(), + entry.getPath(), page.getProject()); + if (dialog.open() == Window.OK) { + IPath[] ps = dialog.getExclusionPattern(); + IPath path = entry.getPath(); + boolean isWsp = entry.ent.isValueWorkspacePath(); + entry.ent = newEntry(path, ps, isWsp); + saveData(); + } + } + + private Optional<_Entry> getSelectedEntry(TreeItem[] sel) { + if (sel.length == 0) + return Optional.empty(); + Object data = sel[0].getData(); + _Entry entry = null; + if (data instanceof _Entry) + entry = (_Entry) data; + else if (data instanceof _Filter) + entry = ((_Filter) data).entry; + + return Optional.ofNullable(entry); + } + private void saveData() { ICExclusionPatternPathEntry[] p = new ICExclusionPatternPathEntry[src.size()]; Iterator<_Entry> it = src.iterator(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/CSourceViewerConfiguration.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/CSourceViewerConfiguration.java index 92bcd24665b..d9ca015a9a4 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/CSourceViewerConfiguration.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/CSourceViewerConfiguration.java @@ -497,14 +497,18 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration { public IAutoEditStrategy[] getAutoEditStrategies(ISourceViewer sourceViewer, String contentType) { String partitioning = getConfiguredDocumentPartitioning(sourceViewer); - IDocCommentOwner owner = DocCommentOwnerManager.getInstance().getCommentOwner(getProject()); - IAutoEditStrategy single = owner.getSinglelineConfiguration().createAutoEditStrategy(); - IAutoEditStrategy multi = owner.getMultilineConfiguration().createAutoEditStrategy(); + IProject project = getProject(); + ICProject cProject = getCProject(); + IDocCommentOwner owner = DocCommentOwnerManager.getInstance().getCommentOwner(project); + ICProject projectDefiningOwnership = project != null + && DocCommentOwnerManager.getInstance().projectDefinesOwnership(project) ? cProject : null; + IAutoEditStrategy single = owner.getSinglelineConfiguration().createAutoEditStrategy(projectDefiningOwnership); + IAutoEditStrategy multi = owner.getMultilineConfiguration().createAutoEditStrategy(projectDefiningOwnership); IAutoEditStrategy[] NONE = new IAutoEditStrategy[0]; if (ICPartitions.C_MULTI_LINE_COMMENT.equals(contentType)) - return new IAutoEditStrategy[] { new DefaultMultilineCommentAutoEditStrategy(getCProject()) }; + return new IAutoEditStrategy[] { new DefaultMultilineCommentAutoEditStrategy(cProject) }; if (ICPartitions.C_SINGLE_LINE_DOC_COMMENT.equals(contentType)) return single != null ? new IAutoEditStrategy[] { single } : NONE; else if (ICPartitions.C_MULTI_LINE_DOC_COMMENT.equals(contentType)) @@ -512,9 +516,9 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration { else if (ICPartitions.C_STRING.equals(contentType)) return new IAutoEditStrategy[] { /*new SmartSemicolonAutoEditStrategy(partitioning),*/ new CStringAutoIndentStrategy(partitioning, - getCProject()) }; + cProject) }; else - return new IAutoEditStrategy[] { new CAutoIndentStrategy(partitioning, getCProject()) }; + return new IAutoEditStrategy[] { new CAutoIndentStrategy(partitioning, cProject) }; } /** diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/IDocCommentViewerConfiguration.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/IDocCommentViewerConfiguration.java index 4573777d129..b7a61ffd27d 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/IDocCommentViewerConfiguration.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/IDocCommentViewerConfiguration.java @@ -13,6 +13,7 @@ *******************************************************************************/ package org.eclipse.cdt.ui.text.doctools; +import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.ui.text.ICPartitions; import org.eclipse.cdt.ui.text.ICTokenScanner; import org.eclipse.cdt.ui.text.ITokenStoreFactory; @@ -50,6 +51,17 @@ public interface IDocCommentViewerConfiguration { IAutoEditStrategy createAutoEditStrategy(); /** + * @return an auto edit strategy suitable for the appropriate comment region. This auto edit + * strategy is project-aware and might be affected by project-specific options. May return null + * in the case where no auto-edit-strategy is required. + * + * @since 7.3 + */ + default IAutoEditStrategy createAutoEditStrategy(ICProject project) { + return createAutoEditStrategy(); + } + + /** * @return a double click strategy suitable for the associated comment-region. May return null in * the case where no double-click-strategy is required. */ diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenMultilineAutoEditStrategy.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenMultilineAutoEditStrategy.java index 40329ff19f9..ffded8a48d4 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenMultilineAutoEditStrategy.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenMultilineAutoEditStrategy.java @@ -48,6 +48,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypeId; +import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.parser.IToken; import org.eclipse.cdt.doxygen.DoxygenOptions; import org.eclipse.cdt.doxygen.core.DoxygenConfiguration; @@ -110,12 +111,20 @@ public class DoxygenMultilineAutoEditStrategy extends DefaultMultilineCommentAut private final DoxygenConfiguration doxygenConfiguration; - public DoxygenMultilineAutoEditStrategy() { + /** + * @since 7.3 + */ + public DoxygenMultilineAutoEditStrategy(ICProject project) { + super(project); doxygenConfiguration = EclipseContextFactory .getServiceContext(FrameworkUtil.getBundle(getClass()).getBundleContext()) .get(DoxygenConfiguration.class); } + public DoxygenMultilineAutoEditStrategy() { + this(null); + } + private void refreshPreferences() { Optional<IProject> project = getProject(); DoxygenOptions options = project.isPresent() ? doxygenConfiguration.projectOptions(project.get()) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenMultilineConfiguration.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenMultilineConfiguration.java index 77e107b52d3..11de9055565 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenMultilineConfiguration.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenMultilineConfiguration.java @@ -13,6 +13,7 @@ *******************************************************************************/ package org.eclipse.cdt.ui.text.doctools.doxygen; +import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.PreferenceConstants; import org.eclipse.cdt.ui.text.doctools.IDocCommentViewerConfiguration; @@ -54,7 +55,15 @@ public class DoxygenMultilineConfiguration extends AbstractGenericTagDocCommentV */ @Override public IAutoEditStrategy createAutoEditStrategy() { - return new DoxygenMultilineAutoEditStrategy(); + return createAutoEditStrategy(null); + } + + /** + * @since 7.3 + */ + @Override + public IAutoEditStrategy createAutoEditStrategy(ICProject project) { + return new DoxygenMultilineAutoEditStrategy(project); } /* diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenSingleAutoEditStrategy.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenSingleAutoEditStrategy.java index 35f2e521c37..facb5c42482 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenSingleAutoEditStrategy.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenSingleAutoEditStrategy.java @@ -18,6 +18,7 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclaration; import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTNodeSelector; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; +import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.ui.text.ICPartitions; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.DocumentCommand; @@ -42,7 +43,15 @@ public class DoxygenSingleAutoEditStrategy extends DoxygenMultilineAutoEditStrat private static final String EXCL_COMMENT = "//!"; //$NON-NLS-1$ private static String fgDefaultLineDelim = "\n"; //$NON-NLS-1$ + /** + * @since 7.3 + */ + public DoxygenSingleAutoEditStrategy(ICProject project) { + super(project); + } + public DoxygenSingleAutoEditStrategy() { + this(null); } /** diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenSingleConfiguration.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenSingleConfiguration.java index d1c647067ee..be825afb9c0 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenSingleConfiguration.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenSingleConfiguration.java @@ -13,6 +13,7 @@ *******************************************************************************/ package org.eclipse.cdt.ui.text.doctools.doxygen; +import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.PreferenceConstants; import org.eclipse.cdt.ui.text.doctools.IDocCommentViewerConfiguration; @@ -53,7 +54,15 @@ public class DoxygenSingleConfiguration extends AbstractGenericTagDocCommentView */ @Override public IAutoEditStrategy createAutoEditStrategy() { - return new DoxygenSingleAutoEditStrategy(); + return createAutoEditStrategy(null); + } + + /** + * @since 7.3 + */ + @Override + public IAutoEditStrategy createAutoEditStrategy(ICProject project) { + return new DoxygenSingleAutoEditStrategy(project); } /* diff --git a/core/org.eclipse.cdt.ui/utils.ui/org/eclipse/cdt/utils/ui/controls/ControlFactory.java b/core/org.eclipse.cdt.ui/utils.ui/org/eclipse/cdt/utils/ui/controls/ControlFactory.java index 0870906a18f..7a0e3bbd770 100644 --- a/core/org.eclipse.cdt.ui/utils.ui/org/eclipse/cdt/utils/ui/controls/ControlFactory.java +++ b/core/org.eclipse.cdt.ui/utils.ui/org/eclipse/cdt/utils/ui/controls/ControlFactory.java @@ -277,7 +277,6 @@ public class ControlFactory { button.setText(label); GridData data = new GridData(); button.setLayoutData(data); - button.setBackground(group.getBackground()); button.setForeground(group.getForeground()); return button; } @@ -296,7 +295,6 @@ public class ControlFactory { button.setText(label); GridData data = new GridData(); button.setLayoutData(data); - button.setBackground(group.getBackground()); button.setForeground(group.getForeground()); return button; } diff --git a/core/pom.xml b/core/pom.xml index 71a2681c7c5..dff64a08a39 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.0.0-SNAPSHOT</version> + <version>10.7.0-SNAPSHOT</version> </parent> <artifactId>org.eclipse.cdt-parent</artifactId> |