diff options
Diffstat (limited to 'core')
172 files changed, 14217 insertions, 14217 deletions
diff --git a/core/org.eclipse.cdt.core.linux/library/SpawnerInputStream.h b/core/org.eclipse.cdt.core.linux/library/SpawnerInputStream.h index 3b32d2b2806..ecf8f8c6a78 100644 --- a/core/org.eclipse.cdt.core.linux/library/SpawnerInputStream.h +++ b/core/org.eclipse.cdt.core.linux/library/SpawnerInputStream.h @@ -1,32 +1,32 @@ -/* 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
+/* 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 index f835947e060..444d71c698c 100644 --- a/core/org.eclipse.cdt.core.linux/library/SpawnerOutputStream.h +++ b/core/org.eclipse.cdt.core.linux/library/SpawnerOutputStream.h @@ -1,29 +1,29 @@ -/* 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
+/* 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/exec0.h b/core/org.eclipse.cdt.core.linux/library/exec0.h index 3033ec1a5ab..bdc56dafa75 100644 --- a/core/org.eclipse.cdt.core.linux/library/exec0.h +++ b/core/org.eclipse.cdt.core.linux/library/exec0.h @@ -1,29 +1,29 @@ -/*******************************************************************************
- * Copyright (c) 2002, 2010 QNX Software Systems 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:
- * QNX Software Systems - initial API and implementation
- * Wind River Systems, Inc.
- * Mikhail Zabaluev (Nokia) - bug 82744
- *******************************************************************************/
-#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);
+/******************************************************************************* + * Copyright (c) 2002, 2010 QNX Software Systems 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: + * QNX Software Systems - initial API and implementation + * Wind River Systems, Inc. + * Mikhail Zabaluev (Nokia) - bug 82744 + *******************************************************************************/ +#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.linux/library/exec_pty.c b/core/org.eclipse.cdt.core.linux/library/exec_pty.c index dd68615f0e5..752f545a988 100644 --- a/core/org.eclipse.cdt.core.linux/library/exec_pty.c +++ b/core/org.eclipse.cdt.core.linux/library/exec_pty.c @@ -1,186 +1,186 @@ -/*******************************************************************************
- * Copyright (c) 2004, 2010 QNX Software Systems 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:
- * 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
+/******************************************************************************* + * Copyright (c) 2004, 2010 QNX Software Systems 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: + * 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 index ced7b744daa..0d68dd13c0a 100644 --- a/core/org.eclipse.cdt.core.linux/library/exec_unix.c +++ b/core/org.eclipse.cdt.core.linux/library/exec_unix.c @@ -1,158 +1,158 @@ -/*******************************************************************************
- * Copyright (c) 2002, 2010 QNX Software Systems 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:
- * 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;
-}
+/******************************************************************************* + * Copyright (c) 2002, 2010 QNX Software Systems 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: + * 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 index 8540b826287..e42d6c23944 100644 --- a/core/org.eclipse.cdt.core.linux/library/io.c +++ b/core/org.eclipse.cdt.core.linux/library/io.c @@ -1,114 +1,114 @@ -/*******************************************************************************
- * Copyright (c) 2002, 2006 QNX Software Systems 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:
- * 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);
-}
+/******************************************************************************* + * Copyright (c) 2002, 2006 QNX Software Systems 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: + * 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/spawner.c b/core/org.eclipse.cdt.core.linux/library/spawner.c index 67b12b05b80..217349b439d 100644 --- a/core/org.eclipse.cdt.core.linux/library/spawner.c +++ b/core/org.eclipse.cdt.core.linux/library/spawner.c @@ -1,302 +1,302 @@ -/*******************************************************************************
- * Copyright (c) 2002, 2010 QNX Software Systems 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:
- * 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);
-}
+/******************************************************************************* + * Copyright (c) 2002, 2010 QNX Software Systems 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: + * 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/plugin.properties b/core/org.eclipse.cdt.core.linux/plugin.properties index 6c8e47ac7e1..8895eaa75ee 100644 --- a/core/org.eclipse.cdt.core.linux/plugin.properties +++ b/core/org.eclipse.cdt.core.linux/plugin.properties @@ -1,2 +1,2 @@ -fragmentName.linux=C/C++ Development Tools Core for Linux
-providerName=Eclipse CDT
+fragmentName.linux=C/C++ Development Tools Core for Linux +providerName=Eclipse CDT diff --git a/core/org.eclipse.cdt.core.macosx/library/exec_pty.c b/core/org.eclipse.cdt.core.macosx/library/exec_pty.c index dd68615f0e5..752f545a988 100644 --- a/core/org.eclipse.cdt.core.macosx/library/exec_pty.c +++ b/core/org.eclipse.cdt.core.macosx/library/exec_pty.c @@ -1,186 +1,186 @@ -/*******************************************************************************
- * Copyright (c) 2004, 2010 QNX Software Systems 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:
- * 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
+/******************************************************************************* + * Copyright (c) 2004, 2010 QNX Software Systems 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: + * 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/plugin.properties b/core/org.eclipse.cdt.core.macosx/plugin.properties index dda4771c596..3ea2577f208 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
-providerName=Eclipse CDT
+fragmentName.linux=C/C++ Development Tools Core for Mac OS X +providerName=Eclipse CDT diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/tests/filesystem/ram/MemoryEFSExtensionProvider.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/tests/filesystem/ram/MemoryEFSExtensionProvider.java index 17039f287f6..0fde6d42f70 100644 --- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/tests/filesystem/ram/MemoryEFSExtensionProvider.java +++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/tests/filesystem/ram/MemoryEFSExtensionProvider.java @@ -1,33 +1,33 @@ -/*******************************************************************************
- * Copyright (c) 2010, 2012 Andrew Gvozdev 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:
- * Andrew Gvozdev - initial API and implementation
+/******************************************************************************* + * Copyright (c) 2010, 2012 Andrew Gvozdev 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: + * Andrew Gvozdev - initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.core.internal.tests.filesystem.ram;
-
-import java.net.URI;
-
-import org.eclipse.cdt.core.EFSExtensionProvider;
-
-/**
- * Test stub to test EFSExtensionProvider mappings.
- *
- */
-public class MemoryEFSExtensionProvider extends EFSExtensionProvider {
-
- public String getMappedPath(URI locationURI) {
-
- String path = locationURI.getPath();
- if (path.contains("/BeingMappedFrom/Folder")) {
- return path.replaceFirst("/BeingMappedFrom/Folder", "/LocallyMappedTo/Folder");
- }
-
- return super.getMappedPath(locationURI);
- }
-
-}
+package org.eclipse.cdt.core.internal.tests.filesystem.ram; + +import java.net.URI; + +import org.eclipse.cdt.core.EFSExtensionProvider; + +/** + * Test stub to test EFSExtensionProvider mappings. + * + */ +public class MemoryEFSExtensionProvider extends EFSExtensionProvider { + + public String getMappedPath(URI locationURI) { + + String path = locationURI.getPath(); + if (path.contains("/BeingMappedFrom/Folder")) { + return path.replaceFirst("/BeingMappedFrom/Folder", "/LocallyMappedTo/Folder"); + } + + return super.getMappedPath(locationURI); + } + +} diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsProviderReferencedProjectsTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsProviderReferencedProjectsTests.java index 7613f726fdb..a7c5811518d 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsProviderReferencedProjectsTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsProviderReferencedProjectsTests.java @@ -1,302 +1,302 @@ -/*******************************************************************************
- * Copyright (c) 2013 Andrew Gvozdev 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:
- * Andrew Gvozdev - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.core.language.settings.providers;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import junit.framework.TestSuite;
-
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.settings.model.CIncludePathEntry;
-import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
-import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
-import org.eclipse.cdt.core.settings.model.ICProjectDescription;
-import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
-import org.eclipse.cdt.core.settings.model.ICSettingEntry;
-import org.eclipse.cdt.core.settings.model.util.CDataUtil;
-import org.eclipse.cdt.core.testplugin.ResourceHelper;
-import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
-import org.eclipse.cdt.internal.core.language.settings.providers.ReferencedProjectsLanguageSettingsProvider;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-
-/**
- * Test cases testing ReferencedProjectsLanguageSettingsProvider functionality
- */
-public class LanguageSettingsProviderReferencedProjectsTests extends BaseTestCase {
- /**
- * Constructor.
- * @param name - name of the test.
- */
- public LanguageSettingsProviderReferencedProjectsTests(String name) {
- super(name);
-
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown(); // includes ResourceHelper cleanup
- }
-
- /**
- * @return - new TestSuite.
- */
- public static TestSuite suite() {
- return new TestSuite(LanguageSettingsProviderReferencedProjectsTests.class);
- }
-
- /**
- * main function of the class.
- *
- * @param args - arguments
- */
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
-
- /**
- * Helper method to fetch configuration descriptions.
- */
- private ICConfigurationDescription[] getConfigurationDescriptions(IProject project) {
- CoreModel coreModel = CoreModel.getDefault();
- ICProjectDescriptionManager mngr = coreModel.getProjectDescriptionManager();
- // project description
- ICProjectDescription projectDescription = mngr.getProjectDescription(project, false);
- assertNotNull(projectDescription);
- assertEquals(1, projectDescription.getConfigurations().length);
- // configuration description
- ICConfigurationDescription[] cfgDescriptions = projectDescription.getConfigurations();
- return cfgDescriptions;
- }
-
- /**
- * Helper method to set reference project.
- */
- private void setReference(IProject project, final IProject projectReferenced) throws CoreException {
- {
- CoreModel coreModel = CoreModel.getDefault();
- ICProjectDescriptionManager mngr = coreModel.getProjectDescriptionManager();
- // project description
- ICProjectDescription projectDescription = mngr.getProjectDescription(project);
- assertNotNull(projectDescription);
- assertEquals(1, projectDescription.getConfigurations().length);
- // configuration description
- ICConfigurationDescription[] cfgDescriptions = projectDescription.getConfigurations();
- ICConfigurationDescription cfgDescription = cfgDescriptions[0];
-
- final ICConfigurationDescription cfgDescriptionReferenced = getConfigurationDescriptions(projectReferenced)[0];
- cfgDescription.setReferenceInfo(new HashMap<String, String>() {{ put(projectReferenced.getName(), cfgDescriptionReferenced.getId()); }});
- coreModel.setProjectDescription(project, projectDescription);
- }
-
- {
- // doublecheck that it's set as expected
- ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project);
- ICConfigurationDescription cfgDescription = cfgDescriptions[0];
- Map<String,String> refs = cfgDescription.getReferenceInfo();
- assertEquals(1, refs.size());
- Set<String> referencedProjectsNames = new LinkedHashSet<String>(refs.keySet());
- assertEquals(projectReferenced.getName(), referencedProjectsNames.toArray()[0]);
- }
-
- }
-
- /**
- * Test that null arguments don't crash the provider.
- */
- public void testNulls() throws Exception {
- ILanguageSettingsProvider provider = LanguageSettingsManager.getWorkspaceProvider(ReferencedProjectsLanguageSettingsProvider.ID);
- assertNotNull(provider);
- List<ICLanguageSettingEntry> entries = provider.getSettingEntries(null, null, null);
- assertEquals(null, entries);
- }
-
- /**
- * Test main functionality of ReferencedProjectsLanguageSettingsProvider.
- */
- public void testReferencedProjectProvider() throws Exception {
- // Create model project and accompanied descriptions
- String projectName = getName();
- IProject project = ResourceHelper.createCDTProjectWithConfig(projectName);
- IProject nonReferencedProject = ResourceHelper.createCDTProjectWithConfig(projectName+"-non-referenced");
- IProject referencedProject = ResourceHelper.createCDTProjectWithConfig(projectName+"-referenced");
- setReference(project, referencedProject);
-
- // get cfgDescription
- ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project);
- ICConfigurationDescription cfgDescription = cfgDescriptions[0];
-
- {
- // double-check that provider for referenced projects is set in the configuration
- ILanguageSettingsProvider refProjectsProvider = LanguageSettingsManager.getWorkspaceProvider(ReferencedProjectsLanguageSettingsProvider.ID);
- assertNotNull(refProjectsProvider);
- List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
- assertTrue(providers.contains(refProjectsProvider));
- }
-
- // Check that no setting entries are set initially
- {
- List<ICLanguageSettingEntry> entries = LanguageSettingsManager.getSettingEntriesByKind(cfgDescription, project, null, ICSettingEntry.ALL);
- assertEquals(0, entries.size());
- }
-
- // Add an entry into a non-referenced project
- CIncludePathEntry nonRefEntry = CDataUtil.createCIncludePathEntry("non-referenced-exported", ICSettingEntry.EXPORTED);
- {
- ICConfigurationDescription[] nonRefCfgDescriptions = getConfigurationDescriptions(nonReferencedProject);
- ICConfigurationDescription nonRefCfgDescription = nonRefCfgDescriptions[0];
- List<ILanguageSettingsProvider> providersNonRef = ((ILanguageSettingsProvidersKeeper) nonRefCfgDescription).getLanguageSettingProviders();
- // get user provider which is the first one
- ILanguageSettingsProvider userProviderNonRef = providersNonRef.get(0);
- assertEquals(ScannerDiscoveryLegacySupport.USER_LANGUAGE_SETTINGS_PROVIDER_ID, userProviderNonRef.getId());
- assertTrue(userProviderNonRef instanceof LanguageSettingsGenericProvider);
- // add sample entries
- ArrayList<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
- entries.add(nonRefEntry);
- ((LanguageSettingsGenericProvider) userProviderNonRef).setSettingEntries(null, null, null, entries);
- }
- // Confirm that that does not add entries to the main project
- {
- List<ICLanguageSettingEntry> entries = LanguageSettingsManager.getSettingEntriesByKind(cfgDescription, project, null, ICSettingEntry.ALL);
- assertEquals(0, entries.size());
- }
-
- CIncludePathEntry refEntry = CDataUtil.createCIncludePathEntry("referenced-exported", ICSettingEntry.EXPORTED);
- // Add entries into a referenced project
- {
- ICConfigurationDescription[] refCfgDescriptions = getConfigurationDescriptions(referencedProject);
- ICConfigurationDescription refCfgDescription = refCfgDescriptions[0];
- List<ILanguageSettingsProvider> providersRef = ((ILanguageSettingsProvidersKeeper) refCfgDescription).getLanguageSettingProviders();
- // get user provider which is the first one
- ILanguageSettingsProvider userProviderRef = providersRef.get(0);
- assertEquals(ScannerDiscoveryLegacySupport.USER_LANGUAGE_SETTINGS_PROVIDER_ID, userProviderRef.getId());
- assertTrue(userProviderRef instanceof LanguageSettingsGenericProvider);
- // add sample entries
- ArrayList<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
- CIncludePathEntry refEntryNotExported = CDataUtil.createCIncludePathEntry("referenced-not-exported", 0);
- entries.add(refEntry);
- entries.add(refEntryNotExported);
- ((LanguageSettingsGenericProvider) userProviderRef).setSettingEntries(null, null, null, entries);
- List<ICLanguageSettingEntry> entriesActual = LanguageSettingsManager.getSettingEntriesByKind(refCfgDescription, project, null, ICSettingEntry.ALL);
- assertEquals(entries, entriesActual);
- }
- // Check that the new entries from referenced project made it to the main project
- {
- List<ICLanguageSettingEntry> entries = LanguageSettingsManager.getSettingEntriesByKind(cfgDescription, project, null, ICSettingEntry.ALL);
- assertEquals(CDataUtil.createCIncludePathEntry(refEntry.getName(), 0), entries.get(0));
- assertEquals(1, entries.size());
- }
- }
-
- /**
- * Test case when projects reference each other recursively.
- */
- public void testRecursiveReferences() throws Exception {
- // Create model projects that reference each other
- String projectName = getName();
- IProject projectA = ResourceHelper.createCDTProjectWithConfig(projectName + "-A");
- IProject projectB = ResourceHelper.createCDTProjectWithConfig(projectName + "-B");
- setReference(projectA, projectB);
- setReference(projectB, projectA);
-
- {
- // get cfgDescriptions to work with
- ICConfigurationDescription[] cfgDescriptionsA = getConfigurationDescriptions(projectA);
- ICConfigurationDescription cfgDescriptionA = cfgDescriptionsA[0];
- ICConfigurationDescription[] cfgDescriptionsB = getConfigurationDescriptions(projectB);
- ICConfigurationDescription cfgDescriptionB = cfgDescriptionsB[0];
- // double-check that provider for referenced projects is set in the configurations
- ILanguageSettingsProvider refProjectsProvider = LanguageSettingsManager.getWorkspaceProvider(ReferencedProjectsLanguageSettingsProvider.ID);
- assertNotNull(refProjectsProvider);
- List<ILanguageSettingsProvider> providersA = ((ILanguageSettingsProvidersKeeper) cfgDescriptionA).getLanguageSettingProviders();
- assertTrue(providersA.contains(refProjectsProvider));
- List<ILanguageSettingsProvider> providersB = ((ILanguageSettingsProvidersKeeper) cfgDescriptionB).getLanguageSettingProviders();
- assertTrue(providersB.contains(refProjectsProvider));
-
- // Check that no setting entries are set initially
- List<ICLanguageSettingEntry> entriesA = LanguageSettingsManager.getSettingEntriesByKind(cfgDescriptionA, projectA, null, ICSettingEntry.ALL);
- assertEquals(0, entriesA.size());
- List<ICLanguageSettingEntry> entriesB = LanguageSettingsManager.getSettingEntriesByKind(cfgDescriptionA, projectB, null, ICSettingEntry.ALL);
- assertEquals(0, entriesB.size());
- }
-
- CIncludePathEntry entryExportedA = CDataUtil.createCIncludePathEntry("referenced-exported-A", ICSettingEntry.EXPORTED);
- CIncludePathEntry entryNotExportedA = CDataUtil.createCIncludePathEntry("referenced-not-exported-A", 0);
- // Add entries into a project A
- {
- ICConfigurationDescription[] refCfgDescriptions = getConfigurationDescriptions(projectA);
- ICConfigurationDescription refCfgDescription = refCfgDescriptions[0];
- List<ILanguageSettingsProvider> providersRef = ((ILanguageSettingsProvidersKeeper) refCfgDescription).getLanguageSettingProviders();
- // get user provider which is the first one
- ILanguageSettingsProvider userProviderRef = providersRef.get(0);
- assertEquals(ScannerDiscoveryLegacySupport.USER_LANGUAGE_SETTINGS_PROVIDER_ID, userProviderRef.getId());
- assertTrue(userProviderRef instanceof LanguageSettingsGenericProvider);
- // add sample entries
- ArrayList<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
- entries.add(entryExportedA);
- entries.add(entryNotExportedA);
- ((LanguageSettingsGenericProvider) userProviderRef).setSettingEntries(null, null, null, entries);
- }
-
- CIncludePathEntry entryExportedB = CDataUtil.createCIncludePathEntry("referenced-exported-B", ICSettingEntry.EXPORTED);
- CIncludePathEntry entryNotExportedB = CDataUtil.createCIncludePathEntry("referenced-not-exported-B", 0);
- // Add entries into a project B
- {
- ICConfigurationDescription[] refCfgDescriptions = getConfigurationDescriptions(projectB);
- ICConfigurationDescription refCfgDescription = refCfgDescriptions[0];
- List<ILanguageSettingsProvider> providersRef = ((ILanguageSettingsProvidersKeeper) refCfgDescription).getLanguageSettingProviders();
- // get user provider which is the first one
- ILanguageSettingsProvider userProviderRef = providersRef.get(0);
- assertEquals(ScannerDiscoveryLegacySupport.USER_LANGUAGE_SETTINGS_PROVIDER_ID, userProviderRef.getId());
- assertTrue(userProviderRef instanceof LanguageSettingsGenericProvider);
- // add sample entries
- ArrayList<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
- entries.add(entryExportedB);
- entries.add(entryNotExportedB);
- ((LanguageSettingsGenericProvider) userProviderRef).setSettingEntries(null, null, null, entries);
- }
-
- // Check that the new entries from projectB made it to projectA
- {
- ICConfigurationDescription[] cfgDescriptionsA = getConfigurationDescriptions(projectA);
- ICConfigurationDescription cfgDescriptionA = cfgDescriptionsA[0];
- List<ICLanguageSettingEntry> entries = LanguageSettingsManager.getSettingEntriesByKind(cfgDescriptionA, projectA, null, ICSettingEntry.ALL);
- assertEquals(entryExportedA, entries.get(0));
- assertEquals(entryNotExportedA, entries.get(1));
- assertEquals(CDataUtil.createCIncludePathEntry(entryExportedB.getName(), 0), entries.get(2));
- assertEquals(3, entries.size());
- }
- // Check that the new entries from projectA made it to projectB
- {
- ICConfigurationDescription[] cfgDescriptionsB = getConfigurationDescriptions(projectB);
- ICConfigurationDescription cfgDescriptionB = cfgDescriptionsB[0];
- List<ICLanguageSettingEntry> entries = LanguageSettingsManager.getSettingEntriesByKind(cfgDescriptionB, projectB, null, ICSettingEntry.ALL);
- assertEquals(entryExportedB, entries.get(0));
- assertEquals(entryNotExportedB, entries.get(1));
- assertEquals(CDataUtil.createCIncludePathEntry(entryExportedA.getName(), 0), entries.get(2));
- assertEquals(3, entries.size());
- }
-
- // Hopefully it gets here without stack overflow
- }
-
-}
+/******************************************************************************* + * Copyright (c) 2013 Andrew Gvozdev 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: + * Andrew Gvozdev - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.cdt.core.language.settings.providers; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import junit.framework.TestSuite; + +import org.eclipse.cdt.core.model.CoreModel; +import org.eclipse.cdt.core.settings.model.CIncludePathEntry; +import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; +import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; +import org.eclipse.cdt.core.settings.model.ICProjectDescription; +import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager; +import org.eclipse.cdt.core.settings.model.ICSettingEntry; +import org.eclipse.cdt.core.settings.model.util.CDataUtil; +import org.eclipse.cdt.core.testplugin.ResourceHelper; +import org.eclipse.cdt.core.testplugin.util.BaseTestCase; +import org.eclipse.cdt.internal.core.language.settings.providers.ReferencedProjectsLanguageSettingsProvider; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; + +/** + * Test cases testing ReferencedProjectsLanguageSettingsProvider functionality + */ +public class LanguageSettingsProviderReferencedProjectsTests extends BaseTestCase { + /** + * Constructor. + * @param name - name of the test. + */ + public LanguageSettingsProviderReferencedProjectsTests(String name) { + super(name); + + } + + @Override + protected void setUp() throws Exception { + super.setUp(); + } + + @Override + protected void tearDown() throws Exception { + super.tearDown(); // includes ResourceHelper cleanup + } + + /** + * @return - new TestSuite. + */ + public static TestSuite suite() { + return new TestSuite(LanguageSettingsProviderReferencedProjectsTests.class); + } + + /** + * main function of the class. + * + * @param args - arguments + */ + public static void main(String[] args) { + junit.textui.TestRunner.run(suite()); + } + + /** + * Helper method to fetch configuration descriptions. + */ + private ICConfigurationDescription[] getConfigurationDescriptions(IProject project) { + CoreModel coreModel = CoreModel.getDefault(); + ICProjectDescriptionManager mngr = coreModel.getProjectDescriptionManager(); + // project description + ICProjectDescription projectDescription = mngr.getProjectDescription(project, false); + assertNotNull(projectDescription); + assertEquals(1, projectDescription.getConfigurations().length); + // configuration description + ICConfigurationDescription[] cfgDescriptions = projectDescription.getConfigurations(); + return cfgDescriptions; + } + + /** + * Helper method to set reference project. + */ + private void setReference(IProject project, final IProject projectReferenced) throws CoreException { + { + CoreModel coreModel = CoreModel.getDefault(); + ICProjectDescriptionManager mngr = coreModel.getProjectDescriptionManager(); + // project description + ICProjectDescription projectDescription = mngr.getProjectDescription(project); + assertNotNull(projectDescription); + assertEquals(1, projectDescription.getConfigurations().length); + // configuration description + ICConfigurationDescription[] cfgDescriptions = projectDescription.getConfigurations(); + ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + + final ICConfigurationDescription cfgDescriptionReferenced = getConfigurationDescriptions(projectReferenced)[0]; + cfgDescription.setReferenceInfo(new HashMap<String, String>() {{ put(projectReferenced.getName(), cfgDescriptionReferenced.getId()); }}); + coreModel.setProjectDescription(project, projectDescription); + } + + { + // doublecheck that it's set as expected + ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project); + ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + Map<String,String> refs = cfgDescription.getReferenceInfo(); + assertEquals(1, refs.size()); + Set<String> referencedProjectsNames = new LinkedHashSet<String>(refs.keySet()); + assertEquals(projectReferenced.getName(), referencedProjectsNames.toArray()[0]); + } + + } + + /** + * Test that null arguments don't crash the provider. + */ + public void testNulls() throws Exception { + ILanguageSettingsProvider provider = LanguageSettingsManager.getWorkspaceProvider(ReferencedProjectsLanguageSettingsProvider.ID); + assertNotNull(provider); + List<ICLanguageSettingEntry> entries = provider.getSettingEntries(null, null, null); + assertEquals(null, entries); + } + + /** + * Test main functionality of ReferencedProjectsLanguageSettingsProvider. + */ + public void testReferencedProjectProvider() throws Exception { + // Create model project and accompanied descriptions + String projectName = getName(); + IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); + IProject nonReferencedProject = ResourceHelper.createCDTProjectWithConfig(projectName+"-non-referenced"); + IProject referencedProject = ResourceHelper.createCDTProjectWithConfig(projectName+"-referenced"); + setReference(project, referencedProject); + + // get cfgDescription + ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project); + ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + + { + // double-check that provider for referenced projects is set in the configuration + ILanguageSettingsProvider refProjectsProvider = LanguageSettingsManager.getWorkspaceProvider(ReferencedProjectsLanguageSettingsProvider.ID); + assertNotNull(refProjectsProvider); + List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + assertTrue(providers.contains(refProjectsProvider)); + } + + // Check that no setting entries are set initially + { + List<ICLanguageSettingEntry> entries = LanguageSettingsManager.getSettingEntriesByKind(cfgDescription, project, null, ICSettingEntry.ALL); + assertEquals(0, entries.size()); + } + + // Add an entry into a non-referenced project + CIncludePathEntry nonRefEntry = CDataUtil.createCIncludePathEntry("non-referenced-exported", ICSettingEntry.EXPORTED); + { + ICConfigurationDescription[] nonRefCfgDescriptions = getConfigurationDescriptions(nonReferencedProject); + ICConfigurationDescription nonRefCfgDescription = nonRefCfgDescriptions[0]; + List<ILanguageSettingsProvider> providersNonRef = ((ILanguageSettingsProvidersKeeper) nonRefCfgDescription).getLanguageSettingProviders(); + // get user provider which is the first one + ILanguageSettingsProvider userProviderNonRef = providersNonRef.get(0); + assertEquals(ScannerDiscoveryLegacySupport.USER_LANGUAGE_SETTINGS_PROVIDER_ID, userProviderNonRef.getId()); + assertTrue(userProviderNonRef instanceof LanguageSettingsGenericProvider); + // add sample entries + ArrayList<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>(); + entries.add(nonRefEntry); + ((LanguageSettingsGenericProvider) userProviderNonRef).setSettingEntries(null, null, null, entries); + } + // Confirm that that does not add entries to the main project + { + List<ICLanguageSettingEntry> entries = LanguageSettingsManager.getSettingEntriesByKind(cfgDescription, project, null, ICSettingEntry.ALL); + assertEquals(0, entries.size()); + } + + CIncludePathEntry refEntry = CDataUtil.createCIncludePathEntry("referenced-exported", ICSettingEntry.EXPORTED); + // Add entries into a referenced project + { + ICConfigurationDescription[] refCfgDescriptions = getConfigurationDescriptions(referencedProject); + ICConfigurationDescription refCfgDescription = refCfgDescriptions[0]; + List<ILanguageSettingsProvider> providersRef = ((ILanguageSettingsProvidersKeeper) refCfgDescription).getLanguageSettingProviders(); + // get user provider which is the first one + ILanguageSettingsProvider userProviderRef = providersRef.get(0); + assertEquals(ScannerDiscoveryLegacySupport.USER_LANGUAGE_SETTINGS_PROVIDER_ID, userProviderRef.getId()); + assertTrue(userProviderRef instanceof LanguageSettingsGenericProvider); + // add sample entries + ArrayList<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>(); + CIncludePathEntry refEntryNotExported = CDataUtil.createCIncludePathEntry("referenced-not-exported", 0); + entries.add(refEntry); + entries.add(refEntryNotExported); + ((LanguageSettingsGenericProvider) userProviderRef).setSettingEntries(null, null, null, entries); + List<ICLanguageSettingEntry> entriesActual = LanguageSettingsManager.getSettingEntriesByKind(refCfgDescription, project, null, ICSettingEntry.ALL); + assertEquals(entries, entriesActual); + } + // Check that the new entries from referenced project made it to the main project + { + List<ICLanguageSettingEntry> entries = LanguageSettingsManager.getSettingEntriesByKind(cfgDescription, project, null, ICSettingEntry.ALL); + assertEquals(CDataUtil.createCIncludePathEntry(refEntry.getName(), 0), entries.get(0)); + assertEquals(1, entries.size()); + } + } + + /** + * Test case when projects reference each other recursively. + */ + public void testRecursiveReferences() throws Exception { + // Create model projects that reference each other + String projectName = getName(); + IProject projectA = ResourceHelper.createCDTProjectWithConfig(projectName + "-A"); + IProject projectB = ResourceHelper.createCDTProjectWithConfig(projectName + "-B"); + setReference(projectA, projectB); + setReference(projectB, projectA); + + { + // get cfgDescriptions to work with + ICConfigurationDescription[] cfgDescriptionsA = getConfigurationDescriptions(projectA); + ICConfigurationDescription cfgDescriptionA = cfgDescriptionsA[0]; + ICConfigurationDescription[] cfgDescriptionsB = getConfigurationDescriptions(projectB); + ICConfigurationDescription cfgDescriptionB = cfgDescriptionsB[0]; + // double-check that provider for referenced projects is set in the configurations + ILanguageSettingsProvider refProjectsProvider = LanguageSettingsManager.getWorkspaceProvider(ReferencedProjectsLanguageSettingsProvider.ID); + assertNotNull(refProjectsProvider); + List<ILanguageSettingsProvider> providersA = ((ILanguageSettingsProvidersKeeper) cfgDescriptionA).getLanguageSettingProviders(); + assertTrue(providersA.contains(refProjectsProvider)); + List<ILanguageSettingsProvider> providersB = ((ILanguageSettingsProvidersKeeper) cfgDescriptionB).getLanguageSettingProviders(); + assertTrue(providersB.contains(refProjectsProvider)); + + // Check that no setting entries are set initially + List<ICLanguageSettingEntry> entriesA = LanguageSettingsManager.getSettingEntriesByKind(cfgDescriptionA, projectA, null, ICSettingEntry.ALL); + assertEquals(0, entriesA.size()); + List<ICLanguageSettingEntry> entriesB = LanguageSettingsManager.getSettingEntriesByKind(cfgDescriptionA, projectB, null, ICSettingEntry.ALL); + assertEquals(0, entriesB.size()); + } + + CIncludePathEntry entryExportedA = CDataUtil.createCIncludePathEntry("referenced-exported-A", ICSettingEntry.EXPORTED); + CIncludePathEntry entryNotExportedA = CDataUtil.createCIncludePathEntry("referenced-not-exported-A", 0); + // Add entries into a project A + { + ICConfigurationDescription[] refCfgDescriptions = getConfigurationDescriptions(projectA); + ICConfigurationDescription refCfgDescription = refCfgDescriptions[0]; + List<ILanguageSettingsProvider> providersRef = ((ILanguageSettingsProvidersKeeper) refCfgDescription).getLanguageSettingProviders(); + // get user provider which is the first one + ILanguageSettingsProvider userProviderRef = providersRef.get(0); + assertEquals(ScannerDiscoveryLegacySupport.USER_LANGUAGE_SETTINGS_PROVIDER_ID, userProviderRef.getId()); + assertTrue(userProviderRef instanceof LanguageSettingsGenericProvider); + // add sample entries + ArrayList<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>(); + entries.add(entryExportedA); + entries.add(entryNotExportedA); + ((LanguageSettingsGenericProvider) userProviderRef).setSettingEntries(null, null, null, entries); + } + + CIncludePathEntry entryExportedB = CDataUtil.createCIncludePathEntry("referenced-exported-B", ICSettingEntry.EXPORTED); + CIncludePathEntry entryNotExportedB = CDataUtil.createCIncludePathEntry("referenced-not-exported-B", 0); + // Add entries into a project B + { + ICConfigurationDescription[] refCfgDescriptions = getConfigurationDescriptions(projectB); + ICConfigurationDescription refCfgDescription = refCfgDescriptions[0]; + List<ILanguageSettingsProvider> providersRef = ((ILanguageSettingsProvidersKeeper) refCfgDescription).getLanguageSettingProviders(); + // get user provider which is the first one + ILanguageSettingsProvider userProviderRef = providersRef.get(0); + assertEquals(ScannerDiscoveryLegacySupport.USER_LANGUAGE_SETTINGS_PROVIDER_ID, userProviderRef.getId()); + assertTrue(userProviderRef instanceof LanguageSettingsGenericProvider); + // add sample entries + ArrayList<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>(); + entries.add(entryExportedB); + entries.add(entryNotExportedB); + ((LanguageSettingsGenericProvider) userProviderRef).setSettingEntries(null, null, null, entries); + } + + // Check that the new entries from projectB made it to projectA + { + ICConfigurationDescription[] cfgDescriptionsA = getConfigurationDescriptions(projectA); + ICConfigurationDescription cfgDescriptionA = cfgDescriptionsA[0]; + List<ICLanguageSettingEntry> entries = LanguageSettingsManager.getSettingEntriesByKind(cfgDescriptionA, projectA, null, ICSettingEntry.ALL); + assertEquals(entryExportedA, entries.get(0)); + assertEquals(entryNotExportedA, entries.get(1)); + assertEquals(CDataUtil.createCIncludePathEntry(entryExportedB.getName(), 0), entries.get(2)); + assertEquals(3, entries.size()); + } + // Check that the new entries from projectA made it to projectB + { + ICConfigurationDescription[] cfgDescriptionsB = getConfigurationDescriptions(projectB); + ICConfigurationDescription cfgDescriptionB = cfgDescriptionsB[0]; + List<ICLanguageSettingEntry> entries = LanguageSettingsManager.getSettingEntriesByKind(cfgDescriptionB, projectB, null, ICSettingEntry.ALL); + assertEquals(entryExportedB, entries.get(0)); + assertEquals(entryNotExportedB, entries.get(1)); + assertEquals(CDataUtil.createCIncludePathEntry(entryExportedA.getName(), 0), entries.get(2)); + assertEquals(3, entries.size()); + } + + // Hopefully it gets here without stack overflow + } + +} diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsScannerInfoProviderTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsScannerInfoProviderTests.java index 72ee4c50cfe..9d9bce06f51 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsScannerInfoProviderTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsScannerInfoProviderTests.java @@ -1,958 +1,958 @@ -/*******************************************************************************
- * Copyright (c) 2009, 2012 Andrew Gvozdev 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:
- * Andrew Gvozdev - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.core.language.settings.providers;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import junit.framework.TestSuite;
-
-import org.eclipse.cdt.core.model.ILanguage;
-import org.eclipse.cdt.core.model.LanguageManager;
-import org.eclipse.cdt.core.parser.ExtendedScannerInfo;
-import org.eclipse.cdt.core.settings.model.CIncludeFileEntry;
-import org.eclipse.cdt.core.settings.model.CIncludePathEntry;
-import org.eclipse.cdt.core.settings.model.CMacroEntry;
-import org.eclipse.cdt.core.settings.model.CMacroFileEntry;
-import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
-import org.eclipse.cdt.core.settings.model.ICFolderDescription;
-import org.eclipse.cdt.core.settings.model.ICLanguageSetting;
-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.core.testplugin.ResourceHelper;
-import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
-import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsScannerInfoProvider;
-import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
-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.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-
-/**
- * Test cases testing LanguageSettingsProvider functionality
- */
-public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase {
- private static final IFile FAKE_FILE = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path("/project/path0"));
- private static final String PROVIDER_ID = "test.provider.id";
- private static final String PROVIDER_ID_2 = "test.provider.id.2";
- private static final String PROVIDER_NAME = "test.provider.name";
-
- // constants for getProjectDescription()
- private static final boolean READ_ONLY = false;
- private static final boolean WRITEABLE = true;
-
- private class MockProvider extends LanguageSettingsBaseProvider implements ILanguageSettingsProvider {
- private final List<ICLanguageSettingEntry> entries;
-
- public MockProvider(String id, String name, List<ICLanguageSettingEntry> entries) {
- super(id, name);
- this.entries = entries;
- }
-
- @Override
- public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) {
- return entries;
- }
- }
-
- /**
- * Constructor.
- * @param name - name of the test.
- */
- public LanguageSettingsScannerInfoProviderTests(String name) {
- super(name);
-
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown(); // includes ResourceHelper cleanup
- }
-
- /**
- * @return - new TestSuite.
- */
- public static TestSuite suite() {
- return new TestSuite(LanguageSettingsScannerInfoProviderTests.class);
- }
-
- /**
- * main function of the class.
- *
- * @param args - arguments
- */
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
-
- /**
- * Sets build working directory for DefaultSettingConfiguration being tested.
- */
- private void setBuilderCWD(IProject project, IPath buildCWD) throws CoreException {
- CProjectDescriptionManager manager = CProjectDescriptionManager.getInstance();
- {
- ICProjectDescription prjDescription = manager.getProjectDescription(project, WRITEABLE);
- assertNotNull(prjDescription);
- ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
- assertNotNull(cfgDescription);
-
- cfgDescription.getBuildSetting().setBuilderCWD(buildCWD);
- manager.setProjectDescription(project, prjDescription);
- // doublecheck builderCWD
- IPath actualBuildCWD = cfgDescription.getBuildSetting().getBuilderCWD();
- assertEquals(buildCWD, actualBuildCWD);
- }
- {
- // triplecheck builderCWD for different project/configuration descriptions
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, READ_ONLY);
- assertNotNull(prjDescription);
- ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
- assertNotNull(cfgDescription);
-
- }
- }
-
- /**
- * Test cases when some objects are null.
- */
- public void testNulls() throws Exception {
- {
- // Handle project==null
- IResource root = ResourcesPlugin.getWorkspace().getRoot();
- assertNull(root.getProject());
-
- LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
- ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(root);
- assertEquals(0, info.getIncludePaths().length);
- assertEquals(0, info.getDefinedSymbols().size());
- assertEquals(0, info.getIncludeFiles().length);
- assertEquals(0, info.getMacroFiles().length);
- assertEquals(0, info.getLocalIncludePath().length);
- }
-
- {
- // Handle prjDescription==null
- IProject project = FAKE_FILE.getProject();
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, READ_ONLY);
- assertNull(prjDescription);
-
- LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
- ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(FAKE_FILE);
- assertEquals(0, info.getIncludePaths().length);
- assertEquals(0, info.getDefinedSymbols().size());
- assertEquals(0, info.getIncludeFiles().length);
- assertEquals(0, info.getMacroFiles().length);
- assertEquals(0, info.getLocalIncludePath().length);
- }
-
- {
- // Handle language==null
- LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
- IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
- IFile file = ResourceHelper.createFile(project, "file");
-
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, READ_ONLY);
- assertNotNull(prjDescription);
- ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
- assertNotNull(cfgDescription);
- ILanguage language = LanguageManager.getInstance().getLanguageForFile(file, cfgDescription);
- assertNull(language);
-
- // AG FIXME - temporarily ignore the entry in the log
- setExpectedNumberOfLoggedNonOKStatusObjects(1);
-
- ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file);
- assertEquals(0, info.getIncludePaths().length);
- assertEquals(0, info.getDefinedSymbols().size());
- assertEquals(0, info.getIncludeFiles().length);
- assertEquals(0, info.getMacroFiles().length);
- assertEquals(0, info.getLocalIncludePath().length);
- }
- }
-
- /**
- * Test empty scanner info.
- */
- public void testEmpty() throws Exception {
- LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
- IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
- IFile file = ResourceHelper.createFile(project, "file.c");
-
- // confirm that language==null
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, READ_ONLY);
- assertNotNull(prjDescription);
- ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
- assertNotNull(cfgDescription);
- ILanguage language = LanguageManager.getInstance().getLanguageForFile(file, cfgDescription);
- assertNotNull(language);
-
- // test that the info is empty
- ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file);
- assertEquals(0, info.getIncludePaths().length);
- assertEquals(0, info.getDefinedSymbols().size());
- assertEquals(0, info.getIncludeFiles().length);
- assertEquals(0, info.getMacroFiles().length);
- assertEquals(0, info.getLocalIncludePath().length);
- }
-
- /**
- * Test regular cases.
- */
- public void testRegular() throws Exception {
- // create a project
- IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
- assertNotNull(prjDescription);
- ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
- assertNotNull(cfgDescription);
- assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
-
- // sample file
- IFile file = ResourceHelper.createFile(project, "file.c");
-
- // sanity test of language
- ILanguage language = LanguageManager.getInstance().getLanguageForFile(file, cfgDescription);
- assertNotNull(language);
-
- // contribute the entries
- IFolder includeFolder = ResourceHelper.createFolder(project, "/include-path");
- IFolder includeLocalFolder = ResourceHelper.createFolder(project, "/local-include-path");
- IFile macroFile = ResourceHelper.createFile(project, "macro-file");
- IFile includeFile = ResourceHelper.createFile(project, "include-file");
-
- CIncludePathEntry includePathEntry = new CIncludePathEntry(includeFolder, 0);
- CIncludePathEntry includeLocalPathEntry = new CIncludePathEntry(includeLocalFolder, ICSettingEntry.LOCAL); // #include "..."
- CMacroEntry macroEntry = new CMacroEntry("MACRO", "value",0);
- CIncludeFileEntry includeFileEntry = new CIncludeFileEntry(includeFile, 0);
- CMacroFileEntry macroFileEntry = new CMacroFileEntry(macroFile, 0);
-
- List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
- entries.add(includePathEntry);
- entries.add(includeLocalPathEntry);
- entries.add(macroEntry);
- entries.add(includeFileEntry);
- entries.add(macroFileEntry);
-
- // add provider to the configuration
- ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries);
- List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
- providers.add(provider);
- ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
-
- // set project description
- CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription);
-
- // test that the scannerInfoProvider gets the entries
- LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
- ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file);
- String[] actualIncludePaths = info.getIncludePaths();
- Map<String, String> actualDefinedSymbols = info.getDefinedSymbols();
- String[] actualIncludeFiles = info.getIncludeFiles();
- String[] actualMacroFiles = info.getMacroFiles();
- String[] actualLocalIncludePath = info.getLocalIncludePath();
- // include paths
- assertEquals(includeFolder.getLocation(), new Path(actualIncludePaths[0]));
- assertEquals(1, actualIncludePaths.length);
- // macros
- assertEquals(macroEntry.getValue(), actualDefinedSymbols.get(macroEntry.getName()));
- assertEquals(1, actualDefinedSymbols.size());
- // include file
- assertEquals(includeFile.getLocation(), new Path(actualIncludeFiles[0]));
- assertEquals(1, actualIncludeFiles.length);
- // macro file
- assertEquals(macroFile.getLocation(), new Path(actualMacroFiles[0]));
- assertEquals(1, actualMacroFiles.length);
- // local include files
- assertEquals(includeLocalFolder.getLocation(), new Path(actualLocalIncludePath[0]));
- assertEquals(1, actualLocalIncludePath.length);
- }
-
- /**
- * Test "local" flag (#include "...").
- */
- public void testLocal() throws Exception {
- // create a project
- IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
- assertNotNull(prjDescription);
- ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
- assertNotNull(cfgDescription);
- assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
-
- // sample file
- IFile file = ResourceHelper.createFile(project, "file.c");
-
- // contribute the entries
- IFolder incFolder = ResourceHelper.createFolder(project, "include");
- IFolder incFolder2 = ResourceHelper.createFolder(project, "include2");
- CIncludePathEntry includePathEntry = new CIncludePathEntry(incFolder, 0);
- CIncludePathEntry includeLocalPathEntry = new CIncludePathEntry(incFolder, ICSettingEntry.LOCAL); // #include "..."
- CIncludePathEntry includeLocalPathEntry2 = new CIncludePathEntry(incFolder2, ICSettingEntry.LOCAL); // #include "..."
- CIncludePathEntry includePathEntry2 = new CIncludePathEntry(incFolder2, 0);
-
- List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
- entries.add(includePathEntry);
- entries.add(includeLocalPathEntry);
- // reverse order for incPath2
- entries.add(includeLocalPathEntry2);
- entries.add(includePathEntry2);
-
- // add provider to the configuration
- ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries);
- List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
- providers.add(provider);
- ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
-
- // set project description
- CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription);
-
- // test that the scannerInfoProvider gets the entries
- LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
- ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file);
- String[] actualIncludePaths = info.getIncludePaths();
- String[] actualLocalIncludePath = info.getLocalIncludePath();
- // include paths
- assertEquals(incFolder.getLocation(), new Path(actualIncludePaths[0]));
- assertEquals(incFolder2.getLocation(), new Path(actualIncludePaths[1]));
- assertEquals(2, actualIncludePaths.length);
- // local include files
- assertEquals(incFolder.getLocation(), new Path(actualLocalIncludePath[0]));
- assertEquals(incFolder2.getLocation(), new Path(actualLocalIncludePath[1]));
- assertEquals(2, actualLocalIncludePath.length);
- }
-
- /**
- * Test Mac frameworks.
- */
- public void testFramework() throws Exception {
- // create a project
- IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
- assertNotNull(prjDescription);
- ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
- assertNotNull(cfgDescription);
- assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
-
- // sample file
- IFile file = ResourceHelper.createFile(project, "file.c");
-
- // contribute the entries
- IFolder frameworkFolder = ResourceHelper.createFolder(project, "Fmwk");
- CIncludePathEntry frameworkPathEntry = new CIncludePathEntry(frameworkFolder, ICSettingEntry.FRAMEWORKS_MAC);
-
- List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
- entries.add(frameworkPathEntry);
-
- // add provider to the configuration
- ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries);
- List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
- providers.add(provider);
- ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
-
- // set project description
- CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription);
-
- // test that the scannerInfoProvider gets the entries
- LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
- ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file);
- String[] actualIncludePaths = info.getIncludePaths();
- // include paths
- assertEquals(frameworkFolder.getLocation().append("/__framework__.framework/Headers/__header__"),
- new Path(actualIncludePaths[0]));
- assertEquals(frameworkFolder.getLocation().append("/__framework__.framework/PrivateHeaders/__header__"),
- new Path(actualIncludePaths[1]));
- assertEquals(2, actualIncludePaths.length);
- }
-
- /**
- * Test duplicate entries.
- */
- public void testDuplicate() throws Exception {
- // create a project
- IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
- assertNotNull(prjDescription);
- ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
- assertNotNull(cfgDescription);
- assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
-
- // sample file
- IFile file = ResourceHelper.createFile(project, "file.c");
-
- // contribute the entries
- IFolder incFolder = ResourceHelper.createFolder(project, "include");
- CIncludePathEntry includePathEntry = new CIncludePathEntry(incFolder, 0);
- CIncludePathEntry includeLocalPathEntry = new CIncludePathEntry(incFolder, ICSettingEntry.LOCAL); // #include "..."
- CIncludePathEntry includePathEntry2 = new CIncludePathEntry(incFolder, 0);
- CIncludePathEntry includeLocalPathEntry2 = new CIncludePathEntry(incFolder, ICSettingEntry.LOCAL); // #include "..."
-
- List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
- entries.add(includePathEntry);
- entries.add(includeLocalPathEntry);
- entries.add(includePathEntry2);
- entries.add(includeLocalPathEntry2);
-
- // add provider to the configuration
- ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries);
- List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
- providers.add(provider);
- ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
-
- // set project description
- CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription);
-
- // test that the scannerInfoProvider gets the entries
- LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
- ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file);
- String[] actualIncludePaths = info.getIncludePaths();
- String[] actualLocalIncludePath = info.getLocalIncludePath();
- // include paths
- assertEquals(incFolder.getLocation(), new Path(actualIncludePaths[0]));
- assertEquals(1, actualIncludePaths.length);
- // local include files
- assertEquals(incFolder.getLocation(), new Path(actualLocalIncludePath[0]));
- assertEquals(1, actualLocalIncludePath.length);
- }
-
- /**
- * Test include path managed by eclipse as a workspace path.
- */
- public void testWorkspacePath() throws Exception {
- // create a project
- IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
- assertNotNull(prjDescription);
- ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
- assertNotNull(cfgDescription);
- assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
-
- // create sample file
- IFile file = ResourceHelper.createFile(project, "file.c");
- // eclipse-managed folder in workspace
- IFolder incWorkspace_1 = ResourceHelper.createFolder(project, "include_1");
- IPath incWorkspaceLocation_1 = incWorkspace_1.getLocation();
- IFolder incWorkspace_2 = ResourceHelper.createFolder(project, "include_2");
- IPath incWorkspacePath_2 = incWorkspace_2.getFullPath();
- IPath incWorkspaceLocation_2 = incWorkspace_2.getLocation();
- IFolder incWorkspace_3 = ResourceHelper.createFolder(project, "include_3");
- // "relative" should make no difference for VALUE_WORKSPACE_PATH
- IPath incWorkspaceRelativePath_3 = incWorkspace_3.getFullPath().makeRelative();
- IPath incWorkspaceLocation_3 = incWorkspace_3.getLocation();
- // not having "RESOLVED" should make no difference for well formed path
- IFolder incWorkspace_4 = ResourceHelper.createFolder(project, "include_4");
- IPath incWorkspacePathNoResolved_4 = incWorkspace_4.getFullPath();
- IPath incWorkspaceLocation_4 = incWorkspace_4.getLocation();
- // folder defined by absolute path on the filesystem
- IPath incFilesystem = ResourceHelper.createWorkspaceFolder("includeFilesystem");
-
- // contribute the entries
- CIncludePathEntry incWorkspaceEntry_1 = new CIncludePathEntry(incWorkspace_1, 0);
- CIncludePathEntry incWorkspaceEntry_2 = new CIncludePathEntry(incWorkspacePath_2, ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED);
- CIncludePathEntry incWorkspaceEntry_3 = new CIncludePathEntry(incWorkspaceRelativePath_3, ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED);
- CIncludePathEntry incWorkspaceEntry_4 = new CIncludePathEntry(incWorkspacePathNoResolved_4, ICSettingEntry.VALUE_WORKSPACE_PATH);
- CIncludePathEntry incFilesystemEntry = new CIncludePathEntry(incFilesystem, 0);
-
- List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
- entries.add(incWorkspaceEntry_1);
- entries.add(incWorkspaceEntry_2);
- entries.add(incWorkspaceEntry_3);
- entries.add(incWorkspaceEntry_4);
- entries.add(incFilesystemEntry);
-
- // add provider to the configuration
- ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries);
- List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
- providers.add(provider);
- ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
-
- // set project description
- CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription);
-
- // test the entries received from the scannerInfoProvider
- LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
- ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file);
- String[] actualIncludePaths = info.getIncludePaths();
-
- assertEquals(incWorkspaceLocation_1, new Path(actualIncludePaths[0]));
- assertEquals(incWorkspaceLocation_2, new Path(actualIncludePaths[1]));
- assertEquals(incWorkspaceLocation_3, new Path(actualIncludePaths[2]));
- assertEquals(incWorkspaceLocation_4, new Path(actualIncludePaths[3]));
- assertEquals(incFilesystem, new Path(actualIncludePaths[4]));
- assertEquals(5, actualIncludePaths.length);
-
- }
-
- /**
- * Confirm that device letter is prepended on filesystems that support that.
- */
- public void testFilesystemPathNoDriveLetter() throws Exception {
- // create a project
- IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
- // change drive on build working directory
- String buildCwdDevice = project.getLocation().getDevice();
-
-// // Test manually with a device which is different from project location device (path should exist)
-// IPath buildCWD = new Path("D:/build/path");
-// String buildCwdDevice = buildCWD.getDevice();
-
- // get project/configuration descriptions
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
- assertNotNull(prjDescription);
- ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
- assertNotNull(cfgDescription);
- assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
-
- // create sample file
- IFile file = ResourceHelper.createFile(project, "file.c");
-
- // contribute the entries
- // no-drive-letter folder defined by absolute path on the filesystem
- IPath incFilesystem = ResourceHelper.createWorkspaceFolder("includeFilesystem").setDevice(null);
- CIncludePathEntry incFilesystemEntry = new CIncludePathEntry(incFilesystem, 0);
- List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
- entries.add(incFilesystemEntry);
-
- // add provider to the configuration
- ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries);
- List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
- providers.add(provider);
- ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
-
- // set project description
- CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription);
-
- // test the entries received from the scannerInfoProvider
- LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
- ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file);
- String[] actualIncludePaths = info.getIncludePaths();
-
- IPath expectedInclude = incFilesystem.setDevice(buildCwdDevice);
- assertEquals(expectedInclude, new Path(actualIncludePaths[0]));
- assertEquals(1, actualIncludePaths.length);
- }
-
- /**
- * Test relative paths.
- */
- public void testRelativePath() throws Exception {
- // create a project
- String prjName = getName();
- IProject project = ResourceHelper.createCDTProjectWithConfig(prjName);
- String relativePath = "include";
- IFolder buildFolder = ResourceHelper.createFolder(project, "buildDir");
- IFolder relativeFolder = ResourceHelper.createFolder(project, "buildDir/"+relativePath);
- IFolder relativeFolderProjName = ResourceHelper.createFolder(project, "buildDir/"+prjName);
- String markedResolved = "-MarkedResolved";
- IFolder relativeFolderProjNameResolved = ResourceHelper.createFolder(project, "buildDir/" + prjName+markedResolved);
- IPath buildCWD=buildFolder.getLocation();
- setBuilderCWD(project, buildCWD);
-
- // get project/configuration descriptions
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
- assertNotNull(prjDescription);
- ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
- assertNotNull(cfgDescription);
- assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
-
- // create sample file
- IFile file = ResourceHelper.createFile(project, "file.c");
-
- // contribute the entries
- CIncludePathEntry incRelativeEntry = new CIncludePathEntry(new Path(relativePath), 0);
- CIncludePathEntry incProjNameEntry = new CIncludePathEntry(new Path("${ProjName}"), 0);
- CIncludePathEntry incProjNameMarkedResolvedEntry = new CIncludePathEntry(new Path("${ProjName}"+markedResolved), ICSettingEntry.RESOLVED);
- List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
- entries.add(incRelativeEntry);
- entries.add(incProjNameEntry);
- entries.add(incProjNameMarkedResolvedEntry);
-
- // add provider to the configuration
- ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries);
- List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
- providers.add(provider);
- ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
-
- // set project description
- CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription);
-
- // test the entries received from the scannerInfoProvider
- LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
- ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file);
- String[] actualIncludePaths = info.getIncludePaths();
-
- // pair of entries, one from build dir another relative path
- assertEquals(relativeFolder.getLocation(), new Path(actualIncludePaths[0]));
- assertEquals(new Path(relativePath), new Path(actualIncludePaths[1]));
-
- // pair of entries, one resolved from build dir another expanded relative path
- assertEquals(relativeFolderProjName.getLocation(), new Path(actualIncludePaths[2]));
- assertEquals(new Path(prjName), new Path(actualIncludePaths[3]));
-
- // if marked RESOLVED only that path stays
- assertEquals(new Path("${ProjName}"+markedResolved), new Path(actualIncludePaths[4]));
-
- assertEquals(5, actualIncludePaths.length);
- }
-
- /**
- * Test relative paths - some combinations of dot paths.
- */
- public void testRelativePathWithDots() throws Exception {
- // create a project
- IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
- // set build CWD
- IFolder buildFolder = ResourceHelper.createFolder(project, "buildDir");
- IPath buildCWD=buildFolder.getLocation();
- setBuilderCWD(project, buildCWD);
-
- // define a few variations of paths
- String relativePath_dot = ".";
- String relativePath_dot_slash = "./";
- String relativePath_dot_slash_path = "./include";
- IFolder relativeFolder_dot_slash_path = ResourceHelper.createFolder(project, "buildDir/include");
- String relativePath_dotdot = "..";
- String relativePath_dotdot_slash = "../";
- String relativePath_dotdot_slash_path = "../include";
- IFolder relativeFolder_dotdot_slash_path = ResourceHelper.createFolder(project, "include");
- String locationPath_dotdot_path = buildCWD.toString()+"/../include2";
- IFolder incFolder_dotdot_slash_path = ResourceHelper.createFolder(project, "include2"); // "/ProjPath/buildDir/../include2"
-
- // get project/configuration descriptions
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
- assertNotNull(prjDescription);
- ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
- assertNotNull(cfgDescription);
- assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
-
- // create sample file
- IFile file = ResourceHelper.createFile(project, "file.c");
-
- // contribute the entries
- CIncludePathEntry incRelativeEntry_dot = new CIncludePathEntry(new Path(relativePath_dot), 0);
- CIncludePathEntry incRelativeEntry_dot_slash_path = new CIncludePathEntry(new Path(relativePath_dot_slash_path), 0);
- CIncludePathEntry incRelativeEntry_dotdot = new CIncludePathEntry(new Path(relativePath_dotdot), 0);
- CIncludePathEntry incRelativeEntry_dotdot_slash_path = new CIncludePathEntry(new Path(relativePath_dotdot_slash_path), 0);
- CIncludePathEntry incEntry_dotdot_path = new CIncludePathEntry(locationPath_dotdot_path, 0);
- // use LOCAL flag not to clash with plain dot entries
- CIncludePathEntry incRelativeEntry_dotdot_slash = new CIncludePathEntry(new Path(relativePath_dotdot_slash), ICSettingEntry.LOCAL);
- CIncludePathEntry incRelativeEntry_dot_slash = new CIncludePathEntry(new Path(relativePath_dot_slash), ICSettingEntry.LOCAL);
-
- List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
- entries.add(incRelativeEntry_dot);
- entries.add(incRelativeEntry_dot_slash);
- entries.add(incRelativeEntry_dot_slash_path);
- entries.add(incRelativeEntry_dotdot);
- entries.add(incRelativeEntry_dotdot_slash);
- entries.add(incRelativeEntry_dotdot_slash_path);
- entries.add(incEntry_dotdot_path);
-
- // add provider to the configuration
- ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries);
- List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
- providers.add(provider);
- ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
-
- // set project description
- CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription);
-
- // test the entries received from the scannerInfoProvider
- LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
- ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file);
- String[] actualIncludePaths = info.getIncludePaths();
- String[] actualLocalIncludePaths = info.getLocalIncludePath();
-
- IPath expectedLocation_dot = buildFolder.getLocation();
- IPath expectedLocation_dot_slash = buildFolder.getLocation();
- IPath expectedLocation_dot_slash_path = relativeFolder_dot_slash_path.getLocation();
- IPath expectedLocation_dotdot = project.getLocation();
- IPath expectedLocation_dotdot_slash = project.getLocation();
- IPath expectedLocation_dotdot_slash_path = relativeFolder_dotdot_slash_path.getLocation();
-
- assertEquals(expectedLocation_dot, new Path(actualIncludePaths[0]));
- assertEquals(".", actualIncludePaths[1]);
- assertEquals(expectedLocation_dot_slash_path, new Path(actualIncludePaths[2]));
- assertEquals(new Path(relativePath_dot_slash_path), new Path(actualIncludePaths[3]));
-
- assertEquals(expectedLocation_dotdot, new Path(actualIncludePaths[4]));
- assertEquals("..", actualIncludePaths[5]);
- assertEquals(expectedLocation_dotdot_slash_path, new Path(actualIncludePaths[6]));
- assertEquals(new Path(relativePath_dotdot_slash_path), new Path(actualIncludePaths[7]));
- assertTrue(actualIncludePaths[7].startsWith(".."));
- assertEquals(new Path(locationPath_dotdot_path), new Path(actualIncludePaths[8]));
- assertTrue(actualIncludePaths[8].contains(".."));
- assertEquals(9, actualIncludePaths.length);
-
- assertEquals(expectedLocation_dot_slash, new Path(actualLocalIncludePaths[0]));
- assertEquals(new Path(relativePath_dot_slash), new Path(actualLocalIncludePaths[1]));
- assertTrue(actualLocalIncludePaths[1].startsWith("."));
- assertEquals(expectedLocation_dotdot_slash, new Path(actualLocalIncludePaths[2]));
- assertEquals(new Path(relativePath_dotdot_slash), new Path(actualLocalIncludePaths[3]));
- assertTrue(actualLocalIncludePaths[3].startsWith(".."));
- assertEquals(4, actualLocalIncludePaths.length);
- }
-
- /**
- * Test if build/environment variables are expanded
- */
- public void testEnvironmentVars() throws Exception {
- // create a project
- IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
- IFolder folder = ResourceHelper.createFolder(project, "Folder");
- String envPathStr = "${ProjDirPath}/Folder";
-
- // get project/configuration descriptions
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
- assertNotNull(prjDescription);
- ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
- assertNotNull(cfgDescription);
- assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
-
- // create sample file
- IFile file = ResourceHelper.createFile(project, "file.c");
-
- // contribute the entries
- CIncludePathEntry incRelativeEntry = new CIncludePathEntry(envPathStr, 0);
- List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
- entries.add(incRelativeEntry);
-
- // add provider to the configuration
- ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries);
- List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
- providers.add(provider);
- ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
-
- // set project description
- CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription);
-
- // test the entries received from the scannerInfoProvider
- LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
- ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file);
- String[] actualIncludePaths = info.getIncludePaths();
-
- IPath expectedLocation = folder.getLocation();
- assertEquals(expectedLocation, new Path(actualIncludePaths[0]));
- assertEquals(1, actualIncludePaths.length);
- }
-
- /**
- * Test from parent folder's entries.
- */
- public void testParentFolder() throws Exception {
- class MockProviderForResource extends LanguageSettingsBaseProvider implements ILanguageSettingsProvider {
- private IResource rc;
- private final List<ICLanguageSettingEntry> entries;
-
- public MockProviderForResource(IResource rc, List<ICLanguageSettingEntry> entries) {
- this.rc = rc;
- this.entries = entries;
- }
-
- @Override
- public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) {
- if (this.rc.equals(rc))
- return entries;
- return null;
- }
- }
-
- // create a project
- IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
- assertNotNull(prjDescription);
- ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
- assertNotNull(cfgDescription);
- assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
-
- // sample file
- IFolder parentFolder = ResourceHelper.createFolder(project, "ParentFolder");
- IFile file = ResourceHelper.createFile(project, "ParentFolder/file.c");
-
- // contribute the entries
- IFolder incFolder = ResourceHelper.createFolder(project, "include");
- CIncludePathEntry includePathEntry = new CIncludePathEntry(incFolder, 0);
-
- List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
- entries.add(includePathEntry);
-
- // add provider for parent folder
- ILanguageSettingsProvider provider = new MockProviderForResource(parentFolder, entries);
- assertNull(provider.getSettingEntries(cfgDescription, file, null));
- assertEquals(includePathEntry, provider.getSettingEntries(cfgDescription, parentFolder, null).get(0));
-
- List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
- providers.add(provider);
- ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
-
- // set project description
- CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription);
-
- // test that the scannerInfoProvider gets the entries for
- LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
- ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file);
- String[] actualIncludePaths = info.getIncludePaths();
- // include paths
- assertEquals(incFolder.getLocation(), new Path(actualIncludePaths[0]));
- assertEquals(1, actualIncludePaths.length);
- }
-
- /**
- * Test resolved paths.
- */
- public void testResolvedPath() throws Exception {
- // create a project
- IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
- IFolder folder = ResourceHelper.createFolder(project, "Folder");
- String envPathStr = "${ProjDirPath}/Folder";
-
- // get project/configuration descriptions
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
- assertNotNull(prjDescription);
- ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
- assertNotNull(cfgDescription);
- assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
-
- // create sample file
- IFile file = ResourceHelper.createFile(project, "file.c");
-
- // contribute the entries
- CIncludePathEntry incRelativeEntry = new CIncludePathEntry(envPathStr, ICSettingEntry.RESOLVED);
- List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
- entries.add(incRelativeEntry);
-
- // add provider to the configuration
- ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries);
- List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
- providers.add(provider);
- ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
-
- // set project description
- CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription);
-
- // test the entries received from the scannerInfoProvider
- LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
- ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file);
- String[] actualIncludePaths = info.getIncludePaths();
-
- // test that RESOLVED entries are not modified
- IPath expectedLocation = new Path(envPathStr);
- assertEquals(expectedLocation, new Path(actualIncludePaths[0]));
- assertEquals(1, actualIncludePaths.length);
- }
-
- /**
- * Get languages for the folder.
- */
- private List<String> getLanguages(IFolder folder, ICConfigurationDescription cfgDescription) {
- IPath rcPath = folder.getProjectRelativePath();
- ICFolderDescription rcDes = (ICFolderDescription) cfgDescription.getResourceDescription(rcPath, false);
- ICLanguageSetting[] langSettings = rcDes.getLanguageSettings();
- assertNotNull(langSettings);
-
- List<String> languageIds = new ArrayList<String>();
- for (ICLanguageSetting ls : langSettings) {
- String langId = ls.getLanguageId();
- if (langId!=null && !languageIds.contains(langId)) {
- languageIds.add(langId);
- }
- }
- return languageIds;
- }
-
- /**
- * Test composition of 2 languages.
- */
- public void testResourceLanguages() throws Exception {
- class MockProviderLang extends LanguageSettingsBaseProvider implements ILanguageSettingsProvider {
- private final String langId;
- private final List<ICLanguageSettingEntry> entries;
-
- public MockProviderLang(String id, String name, String langId, List<ICLanguageSettingEntry> entries) {
- super(id, name);
- this.langId = langId;
- this.entries = entries;
- }
-
- @Override
- public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) {
- if (langId==null || langId.equals(languageId))
- return entries;
- return new ArrayList<ICLanguageSettingEntry>();
- }
- }
-
- // create a project
- IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
- IFolder folder = ResourceHelper.createFolder(project, "Folder");
-
- IFolder incFolderA = ResourceHelper.createFolder(project, "includeA");
- IFolder incFolderB = ResourceHelper.createFolder(project, "includeB");
- IFolder incFolderC = ResourceHelper.createFolder(project, "includeC");
-
- // get project/configuration descriptions
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
- assertNotNull(prjDescription);
- ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
- assertNotNull(cfgDescription);
- assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
-
- // find 2 languages applicable to the folder
- List<String> languageIds = getLanguages(folder, cfgDescription);
- assertTrue(languageIds.size() >= 2);
- String langId1 = languageIds.get(0);
- String langId2 = languageIds.get(1);
-
- // define overlapping entries
- CIncludePathEntry incEntryA = new CIncludePathEntry(incFolderA, 0);
- CIncludePathEntry incEntryB = new CIncludePathEntry(incFolderB, 0);
- CIncludePathEntry incEntryC = new CIncludePathEntry(incFolderC, 0);
- List<ICLanguageSettingEntry> entries1 = new ArrayList<ICLanguageSettingEntry>();
- entries1.add(incEntryA);
- entries1.add(incEntryB);
- List<ICLanguageSettingEntry> entries2 = new ArrayList<ICLanguageSettingEntry>();
- entries2.add(incEntryC);
- entries2.add(incEntryB);
-
- // add providers to the configuration
- ILanguageSettingsProvider provider1 = new MockProviderLang(PROVIDER_ID, PROVIDER_NAME, langId1, entries1);
- ILanguageSettingsProvider provider2 = new MockProviderLang(PROVIDER_ID_2, PROVIDER_NAME, langId2, entries2);
- List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
- providers.add(provider1);
- providers.add(provider2);
- ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
-
- // set project description
- CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription);
-
- // test the entries received from the scannerInfoProvider
- LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
- ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(folder);
- String[] actualIncludePaths = info.getIncludePaths();
-
- // Test that the result is the union of entries
- assertEquals(incFolderA.getLocation(), new Path(actualIncludePaths[0]));
- assertEquals(incFolderB.getLocation(), new Path(actualIncludePaths[1]));
- assertEquals(incFolderC.getLocation(), new Path(actualIncludePaths[2]));
- assertEquals(3, actualIncludePaths.length);
- }
-
-}
+/******************************************************************************* + * Copyright (c) 2009, 2012 Andrew Gvozdev 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: + * Andrew Gvozdev - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.cdt.core.language.settings.providers; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import junit.framework.TestSuite; + +import org.eclipse.cdt.core.model.ILanguage; +import org.eclipse.cdt.core.model.LanguageManager; +import org.eclipse.cdt.core.parser.ExtendedScannerInfo; +import org.eclipse.cdt.core.settings.model.CIncludeFileEntry; +import org.eclipse.cdt.core.settings.model.CIncludePathEntry; +import org.eclipse.cdt.core.settings.model.CMacroEntry; +import org.eclipse.cdt.core.settings.model.CMacroFileEntry; +import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; +import org.eclipse.cdt.core.settings.model.ICFolderDescription; +import org.eclipse.cdt.core.settings.model.ICLanguageSetting; +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.core.testplugin.ResourceHelper; +import org.eclipse.cdt.core.testplugin.util.BaseTestCase; +import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsScannerInfoProvider; +import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager; +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.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; + +/** + * Test cases testing LanguageSettingsProvider functionality + */ +public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { + private static final IFile FAKE_FILE = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path("/project/path0")); + private static final String PROVIDER_ID = "test.provider.id"; + private static final String PROVIDER_ID_2 = "test.provider.id.2"; + private static final String PROVIDER_NAME = "test.provider.name"; + + // constants for getProjectDescription() + private static final boolean READ_ONLY = false; + private static final boolean WRITEABLE = true; + + private class MockProvider extends LanguageSettingsBaseProvider implements ILanguageSettingsProvider { + private final List<ICLanguageSettingEntry> entries; + + public MockProvider(String id, String name, List<ICLanguageSettingEntry> entries) { + super(id, name); + this.entries = entries; + } + + @Override + public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) { + return entries; + } + } + + /** + * Constructor. + * @param name - name of the test. + */ + public LanguageSettingsScannerInfoProviderTests(String name) { + super(name); + + } + + @Override + protected void setUp() throws Exception { + super.setUp(); + } + + @Override + protected void tearDown() throws Exception { + super.tearDown(); // includes ResourceHelper cleanup + } + + /** + * @return - new TestSuite. + */ + public static TestSuite suite() { + return new TestSuite(LanguageSettingsScannerInfoProviderTests.class); + } + + /** + * main function of the class. + * + * @param args - arguments + */ + public static void main(String[] args) { + junit.textui.TestRunner.run(suite()); + } + + /** + * Sets build working directory for DefaultSettingConfiguration being tested. + */ + private void setBuilderCWD(IProject project, IPath buildCWD) throws CoreException { + CProjectDescriptionManager manager = CProjectDescriptionManager.getInstance(); + { + ICProjectDescription prjDescription = manager.getProjectDescription(project, WRITEABLE); + assertNotNull(prjDescription); + ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration(); + assertNotNull(cfgDescription); + + cfgDescription.getBuildSetting().setBuilderCWD(buildCWD); + manager.setProjectDescription(project, prjDescription); + // doublecheck builderCWD + IPath actualBuildCWD = cfgDescription.getBuildSetting().getBuilderCWD(); + assertEquals(buildCWD, actualBuildCWD); + } + { + // triplecheck builderCWD for different project/configuration descriptions + ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, READ_ONLY); + assertNotNull(prjDescription); + ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration(); + assertNotNull(cfgDescription); + + } + } + + /** + * Test cases when some objects are null. + */ + public void testNulls() throws Exception { + { + // Handle project==null + IResource root = ResourcesPlugin.getWorkspace().getRoot(); + assertNull(root.getProject()); + + LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider(); + ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(root); + assertEquals(0, info.getIncludePaths().length); + assertEquals(0, info.getDefinedSymbols().size()); + assertEquals(0, info.getIncludeFiles().length); + assertEquals(0, info.getMacroFiles().length); + assertEquals(0, info.getLocalIncludePath().length); + } + + { + // Handle prjDescription==null + IProject project = FAKE_FILE.getProject(); + ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, READ_ONLY); + assertNull(prjDescription); + + LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider(); + ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(FAKE_FILE); + assertEquals(0, info.getIncludePaths().length); + assertEquals(0, info.getDefinedSymbols().size()); + assertEquals(0, info.getIncludeFiles().length); + assertEquals(0, info.getMacroFiles().length); + assertEquals(0, info.getLocalIncludePath().length); + } + + { + // Handle language==null + LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider(); + IProject project = ResourceHelper.createCDTProjectWithConfig(getName()); + IFile file = ResourceHelper.createFile(project, "file"); + + ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, READ_ONLY); + assertNotNull(prjDescription); + ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration(); + assertNotNull(cfgDescription); + ILanguage language = LanguageManager.getInstance().getLanguageForFile(file, cfgDescription); + assertNull(language); + + // AG FIXME - temporarily ignore the entry in the log + setExpectedNumberOfLoggedNonOKStatusObjects(1); + + ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file); + assertEquals(0, info.getIncludePaths().length); + assertEquals(0, info.getDefinedSymbols().size()); + assertEquals(0, info.getIncludeFiles().length); + assertEquals(0, info.getMacroFiles().length); + assertEquals(0, info.getLocalIncludePath().length); + } + } + + /** + * Test empty scanner info. + */ + public void testEmpty() throws Exception { + LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider(); + IProject project = ResourceHelper.createCDTProjectWithConfig(getName()); + IFile file = ResourceHelper.createFile(project, "file.c"); + + // confirm that language==null + ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, READ_ONLY); + assertNotNull(prjDescription); + ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration(); + assertNotNull(cfgDescription); + ILanguage language = LanguageManager.getInstance().getLanguageForFile(file, cfgDescription); + assertNotNull(language); + + // test that the info is empty + ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file); + assertEquals(0, info.getIncludePaths().length); + assertEquals(0, info.getDefinedSymbols().size()); + assertEquals(0, info.getIncludeFiles().length); + assertEquals(0, info.getMacroFiles().length); + assertEquals(0, info.getLocalIncludePath().length); + } + + /** + * Test regular cases. + */ + public void testRegular() throws Exception { + // create a project + IProject project = ResourceHelper.createCDTProjectWithConfig(getName()); + ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE); + assertNotNull(prjDescription); + ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration(); + assertNotNull(cfgDescription); + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); + + // sample file + IFile file = ResourceHelper.createFile(project, "file.c"); + + // sanity test of language + ILanguage language = LanguageManager.getInstance().getLanguageForFile(file, cfgDescription); + assertNotNull(language); + + // contribute the entries + IFolder includeFolder = ResourceHelper.createFolder(project, "/include-path"); + IFolder includeLocalFolder = ResourceHelper.createFolder(project, "/local-include-path"); + IFile macroFile = ResourceHelper.createFile(project, "macro-file"); + IFile includeFile = ResourceHelper.createFile(project, "include-file"); + + CIncludePathEntry includePathEntry = new CIncludePathEntry(includeFolder, 0); + CIncludePathEntry includeLocalPathEntry = new CIncludePathEntry(includeLocalFolder, ICSettingEntry.LOCAL); // #include "..." + CMacroEntry macroEntry = new CMacroEntry("MACRO", "value",0); + CIncludeFileEntry includeFileEntry = new CIncludeFileEntry(includeFile, 0); + CMacroFileEntry macroFileEntry = new CMacroFileEntry(macroFile, 0); + + List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>(); + entries.add(includePathEntry); + entries.add(includeLocalPathEntry); + entries.add(macroEntry); + entries.add(includeFileEntry); + entries.add(macroFileEntry); + + // add provider to the configuration + ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries); + List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>(); + providers.add(provider); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); + + // set project description + CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription); + + // test that the scannerInfoProvider gets the entries + LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider(); + ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file); + String[] actualIncludePaths = info.getIncludePaths(); + Map<String, String> actualDefinedSymbols = info.getDefinedSymbols(); + String[] actualIncludeFiles = info.getIncludeFiles(); + String[] actualMacroFiles = info.getMacroFiles(); + String[] actualLocalIncludePath = info.getLocalIncludePath(); + // include paths + assertEquals(includeFolder.getLocation(), new Path(actualIncludePaths[0])); + assertEquals(1, actualIncludePaths.length); + // macros + assertEquals(macroEntry.getValue(), actualDefinedSymbols.get(macroEntry.getName())); + assertEquals(1, actualDefinedSymbols.size()); + // include file + assertEquals(includeFile.getLocation(), new Path(actualIncludeFiles[0])); + assertEquals(1, actualIncludeFiles.length); + // macro file + assertEquals(macroFile.getLocation(), new Path(actualMacroFiles[0])); + assertEquals(1, actualMacroFiles.length); + // local include files + assertEquals(includeLocalFolder.getLocation(), new Path(actualLocalIncludePath[0])); + assertEquals(1, actualLocalIncludePath.length); + } + + /** + * Test "local" flag (#include "..."). + */ + public void testLocal() throws Exception { + // create a project + IProject project = ResourceHelper.createCDTProjectWithConfig(getName()); + ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE); + assertNotNull(prjDescription); + ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration(); + assertNotNull(cfgDescription); + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); + + // sample file + IFile file = ResourceHelper.createFile(project, "file.c"); + + // contribute the entries + IFolder incFolder = ResourceHelper.createFolder(project, "include"); + IFolder incFolder2 = ResourceHelper.createFolder(project, "include2"); + CIncludePathEntry includePathEntry = new CIncludePathEntry(incFolder, 0); + CIncludePathEntry includeLocalPathEntry = new CIncludePathEntry(incFolder, ICSettingEntry.LOCAL); // #include "..." + CIncludePathEntry includeLocalPathEntry2 = new CIncludePathEntry(incFolder2, ICSettingEntry.LOCAL); // #include "..." + CIncludePathEntry includePathEntry2 = new CIncludePathEntry(incFolder2, 0); + + List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>(); + entries.add(includePathEntry); + entries.add(includeLocalPathEntry); + // reverse order for incPath2 + entries.add(includeLocalPathEntry2); + entries.add(includePathEntry2); + + // add provider to the configuration + ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries); + List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>(); + providers.add(provider); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); + + // set project description + CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription); + + // test that the scannerInfoProvider gets the entries + LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider(); + ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file); + String[] actualIncludePaths = info.getIncludePaths(); + String[] actualLocalIncludePath = info.getLocalIncludePath(); + // include paths + assertEquals(incFolder.getLocation(), new Path(actualIncludePaths[0])); + assertEquals(incFolder2.getLocation(), new Path(actualIncludePaths[1])); + assertEquals(2, actualIncludePaths.length); + // local include files + assertEquals(incFolder.getLocation(), new Path(actualLocalIncludePath[0])); + assertEquals(incFolder2.getLocation(), new Path(actualLocalIncludePath[1])); + assertEquals(2, actualLocalIncludePath.length); + } + + /** + * Test Mac frameworks. + */ + public void testFramework() throws Exception { + // create a project + IProject project = ResourceHelper.createCDTProjectWithConfig(getName()); + ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE); + assertNotNull(prjDescription); + ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration(); + assertNotNull(cfgDescription); + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); + + // sample file + IFile file = ResourceHelper.createFile(project, "file.c"); + + // contribute the entries + IFolder frameworkFolder = ResourceHelper.createFolder(project, "Fmwk"); + CIncludePathEntry frameworkPathEntry = new CIncludePathEntry(frameworkFolder, ICSettingEntry.FRAMEWORKS_MAC); + + List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>(); + entries.add(frameworkPathEntry); + + // add provider to the configuration + ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries); + List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>(); + providers.add(provider); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); + + // set project description + CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription); + + // test that the scannerInfoProvider gets the entries + LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider(); + ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file); + String[] actualIncludePaths = info.getIncludePaths(); + // include paths + assertEquals(frameworkFolder.getLocation().append("/__framework__.framework/Headers/__header__"), + new Path(actualIncludePaths[0])); + assertEquals(frameworkFolder.getLocation().append("/__framework__.framework/PrivateHeaders/__header__"), + new Path(actualIncludePaths[1])); + assertEquals(2, actualIncludePaths.length); + } + + /** + * Test duplicate entries. + */ + public void testDuplicate() throws Exception { + // create a project + IProject project = ResourceHelper.createCDTProjectWithConfig(getName()); + ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE); + assertNotNull(prjDescription); + ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration(); + assertNotNull(cfgDescription); + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); + + // sample file + IFile file = ResourceHelper.createFile(project, "file.c"); + + // contribute the entries + IFolder incFolder = ResourceHelper.createFolder(project, "include"); + CIncludePathEntry includePathEntry = new CIncludePathEntry(incFolder, 0); + CIncludePathEntry includeLocalPathEntry = new CIncludePathEntry(incFolder, ICSettingEntry.LOCAL); // #include "..." + CIncludePathEntry includePathEntry2 = new CIncludePathEntry(incFolder, 0); + CIncludePathEntry includeLocalPathEntry2 = new CIncludePathEntry(incFolder, ICSettingEntry.LOCAL); // #include "..." + + List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>(); + entries.add(includePathEntry); + entries.add(includeLocalPathEntry); + entries.add(includePathEntry2); + entries.add(includeLocalPathEntry2); + + // add provider to the configuration + ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries); + List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>(); + providers.add(provider); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); + + // set project description + CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription); + + // test that the scannerInfoProvider gets the entries + LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider(); + ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file); + String[] actualIncludePaths = info.getIncludePaths(); + String[] actualLocalIncludePath = info.getLocalIncludePath(); + // include paths + assertEquals(incFolder.getLocation(), new Path(actualIncludePaths[0])); + assertEquals(1, actualIncludePaths.length); + // local include files + assertEquals(incFolder.getLocation(), new Path(actualLocalIncludePath[0])); + assertEquals(1, actualLocalIncludePath.length); + } + + /** + * Test include path managed by eclipse as a workspace path. + */ + public void testWorkspacePath() throws Exception { + // create a project + IProject project = ResourceHelper.createCDTProjectWithConfig(getName()); + ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE); + assertNotNull(prjDescription); + ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration(); + assertNotNull(cfgDescription); + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); + + // create sample file + IFile file = ResourceHelper.createFile(project, "file.c"); + // eclipse-managed folder in workspace + IFolder incWorkspace_1 = ResourceHelper.createFolder(project, "include_1"); + IPath incWorkspaceLocation_1 = incWorkspace_1.getLocation(); + IFolder incWorkspace_2 = ResourceHelper.createFolder(project, "include_2"); + IPath incWorkspacePath_2 = incWorkspace_2.getFullPath(); + IPath incWorkspaceLocation_2 = incWorkspace_2.getLocation(); + IFolder incWorkspace_3 = ResourceHelper.createFolder(project, "include_3"); + // "relative" should make no difference for VALUE_WORKSPACE_PATH + IPath incWorkspaceRelativePath_3 = incWorkspace_3.getFullPath().makeRelative(); + IPath incWorkspaceLocation_3 = incWorkspace_3.getLocation(); + // not having "RESOLVED" should make no difference for well formed path + IFolder incWorkspace_4 = ResourceHelper.createFolder(project, "include_4"); + IPath incWorkspacePathNoResolved_4 = incWorkspace_4.getFullPath(); + IPath incWorkspaceLocation_4 = incWorkspace_4.getLocation(); + // folder defined by absolute path on the filesystem + IPath incFilesystem = ResourceHelper.createWorkspaceFolder("includeFilesystem"); + + // contribute the entries + CIncludePathEntry incWorkspaceEntry_1 = new CIncludePathEntry(incWorkspace_1, 0); + CIncludePathEntry incWorkspaceEntry_2 = new CIncludePathEntry(incWorkspacePath_2, ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED); + CIncludePathEntry incWorkspaceEntry_3 = new CIncludePathEntry(incWorkspaceRelativePath_3, ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED); + CIncludePathEntry incWorkspaceEntry_4 = new CIncludePathEntry(incWorkspacePathNoResolved_4, ICSettingEntry.VALUE_WORKSPACE_PATH); + CIncludePathEntry incFilesystemEntry = new CIncludePathEntry(incFilesystem, 0); + + List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>(); + entries.add(incWorkspaceEntry_1); + entries.add(incWorkspaceEntry_2); + entries.add(incWorkspaceEntry_3); + entries.add(incWorkspaceEntry_4); + entries.add(incFilesystemEntry); + + // add provider to the configuration + ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries); + List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>(); + providers.add(provider); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); + + // set project description + CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription); + + // test the entries received from the scannerInfoProvider + LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider(); + ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file); + String[] actualIncludePaths = info.getIncludePaths(); + + assertEquals(incWorkspaceLocation_1, new Path(actualIncludePaths[0])); + assertEquals(incWorkspaceLocation_2, new Path(actualIncludePaths[1])); + assertEquals(incWorkspaceLocation_3, new Path(actualIncludePaths[2])); + assertEquals(incWorkspaceLocation_4, new Path(actualIncludePaths[3])); + assertEquals(incFilesystem, new Path(actualIncludePaths[4])); + assertEquals(5, actualIncludePaths.length); + + } + + /** + * Confirm that device letter is prepended on filesystems that support that. + */ + public void testFilesystemPathNoDriveLetter() throws Exception { + // create a project + IProject project = ResourceHelper.createCDTProjectWithConfig(getName()); + // change drive on build working directory + String buildCwdDevice = project.getLocation().getDevice(); + +// // Test manually with a device which is different from project location device (path should exist) +// IPath buildCWD = new Path("D:/build/path"); +// String buildCwdDevice = buildCWD.getDevice(); + + // get project/configuration descriptions + ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE); + assertNotNull(prjDescription); + ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration(); + assertNotNull(cfgDescription); + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); + + // create sample file + IFile file = ResourceHelper.createFile(project, "file.c"); + + // contribute the entries + // no-drive-letter folder defined by absolute path on the filesystem + IPath incFilesystem = ResourceHelper.createWorkspaceFolder("includeFilesystem").setDevice(null); + CIncludePathEntry incFilesystemEntry = new CIncludePathEntry(incFilesystem, 0); + List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>(); + entries.add(incFilesystemEntry); + + // add provider to the configuration + ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries); + List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>(); + providers.add(provider); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); + + // set project description + CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription); + + // test the entries received from the scannerInfoProvider + LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider(); + ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file); + String[] actualIncludePaths = info.getIncludePaths(); + + IPath expectedInclude = incFilesystem.setDevice(buildCwdDevice); + assertEquals(expectedInclude, new Path(actualIncludePaths[0])); + assertEquals(1, actualIncludePaths.length); + } + + /** + * Test relative paths. + */ + public void testRelativePath() throws Exception { + // create a project + String prjName = getName(); + IProject project = ResourceHelper.createCDTProjectWithConfig(prjName); + String relativePath = "include"; + IFolder buildFolder = ResourceHelper.createFolder(project, "buildDir"); + IFolder relativeFolder = ResourceHelper.createFolder(project, "buildDir/"+relativePath); + IFolder relativeFolderProjName = ResourceHelper.createFolder(project, "buildDir/"+prjName); + String markedResolved = "-MarkedResolved"; + IFolder relativeFolderProjNameResolved = ResourceHelper.createFolder(project, "buildDir/" + prjName+markedResolved); + IPath buildCWD=buildFolder.getLocation(); + setBuilderCWD(project, buildCWD); + + // get project/configuration descriptions + ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE); + assertNotNull(prjDescription); + ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration(); + assertNotNull(cfgDescription); + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); + + // create sample file + IFile file = ResourceHelper.createFile(project, "file.c"); + + // contribute the entries + CIncludePathEntry incRelativeEntry = new CIncludePathEntry(new Path(relativePath), 0); + CIncludePathEntry incProjNameEntry = new CIncludePathEntry(new Path("${ProjName}"), 0); + CIncludePathEntry incProjNameMarkedResolvedEntry = new CIncludePathEntry(new Path("${ProjName}"+markedResolved), ICSettingEntry.RESOLVED); + List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>(); + entries.add(incRelativeEntry); + entries.add(incProjNameEntry); + entries.add(incProjNameMarkedResolvedEntry); + + // add provider to the configuration + ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries); + List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>(); + providers.add(provider); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); + + // set project description + CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription); + + // test the entries received from the scannerInfoProvider + LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider(); + ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file); + String[] actualIncludePaths = info.getIncludePaths(); + + // pair of entries, one from build dir another relative path + assertEquals(relativeFolder.getLocation(), new Path(actualIncludePaths[0])); + assertEquals(new Path(relativePath), new Path(actualIncludePaths[1])); + + // pair of entries, one resolved from build dir another expanded relative path + assertEquals(relativeFolderProjName.getLocation(), new Path(actualIncludePaths[2])); + assertEquals(new Path(prjName), new Path(actualIncludePaths[3])); + + // if marked RESOLVED only that path stays + assertEquals(new Path("${ProjName}"+markedResolved), new Path(actualIncludePaths[4])); + + assertEquals(5, actualIncludePaths.length); + } + + /** + * Test relative paths - some combinations of dot paths. + */ + public void testRelativePathWithDots() throws Exception { + // create a project + IProject project = ResourceHelper.createCDTProjectWithConfig(getName()); + // set build CWD + IFolder buildFolder = ResourceHelper.createFolder(project, "buildDir"); + IPath buildCWD=buildFolder.getLocation(); + setBuilderCWD(project, buildCWD); + + // define a few variations of paths + String relativePath_dot = "."; + String relativePath_dot_slash = "./"; + String relativePath_dot_slash_path = "./include"; + IFolder relativeFolder_dot_slash_path = ResourceHelper.createFolder(project, "buildDir/include"); + String relativePath_dotdot = ".."; + String relativePath_dotdot_slash = "../"; + String relativePath_dotdot_slash_path = "../include"; + IFolder relativeFolder_dotdot_slash_path = ResourceHelper.createFolder(project, "include"); + String locationPath_dotdot_path = buildCWD.toString()+"/../include2"; + IFolder incFolder_dotdot_slash_path = ResourceHelper.createFolder(project, "include2"); // "/ProjPath/buildDir/../include2" + + // get project/configuration descriptions + ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE); + assertNotNull(prjDescription); + ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration(); + assertNotNull(cfgDescription); + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); + + // create sample file + IFile file = ResourceHelper.createFile(project, "file.c"); + + // contribute the entries + CIncludePathEntry incRelativeEntry_dot = new CIncludePathEntry(new Path(relativePath_dot), 0); + CIncludePathEntry incRelativeEntry_dot_slash_path = new CIncludePathEntry(new Path(relativePath_dot_slash_path), 0); + CIncludePathEntry incRelativeEntry_dotdot = new CIncludePathEntry(new Path(relativePath_dotdot), 0); + CIncludePathEntry incRelativeEntry_dotdot_slash_path = new CIncludePathEntry(new Path(relativePath_dotdot_slash_path), 0); + CIncludePathEntry incEntry_dotdot_path = new CIncludePathEntry(locationPath_dotdot_path, 0); + // use LOCAL flag not to clash with plain dot entries + CIncludePathEntry incRelativeEntry_dotdot_slash = new CIncludePathEntry(new Path(relativePath_dotdot_slash), ICSettingEntry.LOCAL); + CIncludePathEntry incRelativeEntry_dot_slash = new CIncludePathEntry(new Path(relativePath_dot_slash), ICSettingEntry.LOCAL); + + List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>(); + entries.add(incRelativeEntry_dot); + entries.add(incRelativeEntry_dot_slash); + entries.add(incRelativeEntry_dot_slash_path); + entries.add(incRelativeEntry_dotdot); + entries.add(incRelativeEntry_dotdot_slash); + entries.add(incRelativeEntry_dotdot_slash_path); + entries.add(incEntry_dotdot_path); + + // add provider to the configuration + ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries); + List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>(); + providers.add(provider); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); + + // set project description + CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription); + + // test the entries received from the scannerInfoProvider + LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider(); + ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file); + String[] actualIncludePaths = info.getIncludePaths(); + String[] actualLocalIncludePaths = info.getLocalIncludePath(); + + IPath expectedLocation_dot = buildFolder.getLocation(); + IPath expectedLocation_dot_slash = buildFolder.getLocation(); + IPath expectedLocation_dot_slash_path = relativeFolder_dot_slash_path.getLocation(); + IPath expectedLocation_dotdot = project.getLocation(); + IPath expectedLocation_dotdot_slash = project.getLocation(); + IPath expectedLocation_dotdot_slash_path = relativeFolder_dotdot_slash_path.getLocation(); + + assertEquals(expectedLocation_dot, new Path(actualIncludePaths[0])); + assertEquals(".", actualIncludePaths[1]); + assertEquals(expectedLocation_dot_slash_path, new Path(actualIncludePaths[2])); + assertEquals(new Path(relativePath_dot_slash_path), new Path(actualIncludePaths[3])); + + assertEquals(expectedLocation_dotdot, new Path(actualIncludePaths[4])); + assertEquals("..", actualIncludePaths[5]); + assertEquals(expectedLocation_dotdot_slash_path, new Path(actualIncludePaths[6])); + assertEquals(new Path(relativePath_dotdot_slash_path), new Path(actualIncludePaths[7])); + assertTrue(actualIncludePaths[7].startsWith("..")); + assertEquals(new Path(locationPath_dotdot_path), new Path(actualIncludePaths[8])); + assertTrue(actualIncludePaths[8].contains("..")); + assertEquals(9, actualIncludePaths.length); + + assertEquals(expectedLocation_dot_slash, new Path(actualLocalIncludePaths[0])); + assertEquals(new Path(relativePath_dot_slash), new Path(actualLocalIncludePaths[1])); + assertTrue(actualLocalIncludePaths[1].startsWith(".")); + assertEquals(expectedLocation_dotdot_slash, new Path(actualLocalIncludePaths[2])); + assertEquals(new Path(relativePath_dotdot_slash), new Path(actualLocalIncludePaths[3])); + assertTrue(actualLocalIncludePaths[3].startsWith("..")); + assertEquals(4, actualLocalIncludePaths.length); + } + + /** + * Test if build/environment variables are expanded + */ + public void testEnvironmentVars() throws Exception { + // create a project + IProject project = ResourceHelper.createCDTProjectWithConfig(getName()); + IFolder folder = ResourceHelper.createFolder(project, "Folder"); + String envPathStr = "${ProjDirPath}/Folder"; + + // get project/configuration descriptions + ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE); + assertNotNull(prjDescription); + ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration(); + assertNotNull(cfgDescription); + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); + + // create sample file + IFile file = ResourceHelper.createFile(project, "file.c"); + + // contribute the entries + CIncludePathEntry incRelativeEntry = new CIncludePathEntry(envPathStr, 0); + List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>(); + entries.add(incRelativeEntry); + + // add provider to the configuration + ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries); + List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>(); + providers.add(provider); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); + + // set project description + CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription); + + // test the entries received from the scannerInfoProvider + LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider(); + ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file); + String[] actualIncludePaths = info.getIncludePaths(); + + IPath expectedLocation = folder.getLocation(); + assertEquals(expectedLocation, new Path(actualIncludePaths[0])); + assertEquals(1, actualIncludePaths.length); + } + + /** + * Test from parent folder's entries. + */ + public void testParentFolder() throws Exception { + class MockProviderForResource extends LanguageSettingsBaseProvider implements ILanguageSettingsProvider { + private IResource rc; + private final List<ICLanguageSettingEntry> entries; + + public MockProviderForResource(IResource rc, List<ICLanguageSettingEntry> entries) { + this.rc = rc; + this.entries = entries; + } + + @Override + public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) { + if (this.rc.equals(rc)) + return entries; + return null; + } + } + + // create a project + IProject project = ResourceHelper.createCDTProjectWithConfig(getName()); + ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE); + assertNotNull(prjDescription); + ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration(); + assertNotNull(cfgDescription); + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); + + // sample file + IFolder parentFolder = ResourceHelper.createFolder(project, "ParentFolder"); + IFile file = ResourceHelper.createFile(project, "ParentFolder/file.c"); + + // contribute the entries + IFolder incFolder = ResourceHelper.createFolder(project, "include"); + CIncludePathEntry includePathEntry = new CIncludePathEntry(incFolder, 0); + + List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>(); + entries.add(includePathEntry); + + // add provider for parent folder + ILanguageSettingsProvider provider = new MockProviderForResource(parentFolder, entries); + assertNull(provider.getSettingEntries(cfgDescription, file, null)); + assertEquals(includePathEntry, provider.getSettingEntries(cfgDescription, parentFolder, null).get(0)); + + List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>(); + providers.add(provider); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); + + // set project description + CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription); + + // test that the scannerInfoProvider gets the entries for + LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider(); + ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file); + String[] actualIncludePaths = info.getIncludePaths(); + // include paths + assertEquals(incFolder.getLocation(), new Path(actualIncludePaths[0])); + assertEquals(1, actualIncludePaths.length); + } + + /** + * Test resolved paths. + */ + public void testResolvedPath() throws Exception { + // create a project + IProject project = ResourceHelper.createCDTProjectWithConfig(getName()); + IFolder folder = ResourceHelper.createFolder(project, "Folder"); + String envPathStr = "${ProjDirPath}/Folder"; + + // get project/configuration descriptions + ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE); + assertNotNull(prjDescription); + ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration(); + assertNotNull(cfgDescription); + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); + + // create sample file + IFile file = ResourceHelper.createFile(project, "file.c"); + + // contribute the entries + CIncludePathEntry incRelativeEntry = new CIncludePathEntry(envPathStr, ICSettingEntry.RESOLVED); + List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>(); + entries.add(incRelativeEntry); + + // add provider to the configuration + ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries); + List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>(); + providers.add(provider); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); + + // set project description + CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription); + + // test the entries received from the scannerInfoProvider + LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider(); + ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file); + String[] actualIncludePaths = info.getIncludePaths(); + + // test that RESOLVED entries are not modified + IPath expectedLocation = new Path(envPathStr); + assertEquals(expectedLocation, new Path(actualIncludePaths[0])); + assertEquals(1, actualIncludePaths.length); + } + + /** + * Get languages for the folder. + */ + private List<String> getLanguages(IFolder folder, ICConfigurationDescription cfgDescription) { + IPath rcPath = folder.getProjectRelativePath(); + ICFolderDescription rcDes = (ICFolderDescription) cfgDescription.getResourceDescription(rcPath, false); + ICLanguageSetting[] langSettings = rcDes.getLanguageSettings(); + assertNotNull(langSettings); + + List<String> languageIds = new ArrayList<String>(); + for (ICLanguageSetting ls : langSettings) { + String langId = ls.getLanguageId(); + if (langId!=null && !languageIds.contains(langId)) { + languageIds.add(langId); + } + } + return languageIds; + } + + /** + * Test composition of 2 languages. + */ + public void testResourceLanguages() throws Exception { + class MockProviderLang extends LanguageSettingsBaseProvider implements ILanguageSettingsProvider { + private final String langId; + private final List<ICLanguageSettingEntry> entries; + + public MockProviderLang(String id, String name, String langId, List<ICLanguageSettingEntry> entries) { + super(id, name); + this.langId = langId; + this.entries = entries; + } + + @Override + public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) { + if (langId==null || langId.equals(languageId)) + return entries; + return new ArrayList<ICLanguageSettingEntry>(); + } + } + + // create a project + IProject project = ResourceHelper.createCDTProjectWithConfig(getName()); + IFolder folder = ResourceHelper.createFolder(project, "Folder"); + + IFolder incFolderA = ResourceHelper.createFolder(project, "includeA"); + IFolder incFolderB = ResourceHelper.createFolder(project, "includeB"); + IFolder incFolderC = ResourceHelper.createFolder(project, "includeC"); + + // get project/configuration descriptions + ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE); + assertNotNull(prjDescription); + ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration(); + assertNotNull(cfgDescription); + assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); + + // find 2 languages applicable to the folder + List<String> languageIds = getLanguages(folder, cfgDescription); + assertTrue(languageIds.size() >= 2); + String langId1 = languageIds.get(0); + String langId2 = languageIds.get(1); + + // define overlapping entries + CIncludePathEntry incEntryA = new CIncludePathEntry(incFolderA, 0); + CIncludePathEntry incEntryB = new CIncludePathEntry(incFolderB, 0); + CIncludePathEntry incEntryC = new CIncludePathEntry(incFolderC, 0); + List<ICLanguageSettingEntry> entries1 = new ArrayList<ICLanguageSettingEntry>(); + entries1.add(incEntryA); + entries1.add(incEntryB); + List<ICLanguageSettingEntry> entries2 = new ArrayList<ICLanguageSettingEntry>(); + entries2.add(incEntryC); + entries2.add(incEntryB); + + // add providers to the configuration + ILanguageSettingsProvider provider1 = new MockProviderLang(PROVIDER_ID, PROVIDER_NAME, langId1, entries1); + ILanguageSettingsProvider provider2 = new MockProviderLang(PROVIDER_ID_2, PROVIDER_NAME, langId2, entries2); + List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>(); + providers.add(provider1); + providers.add(provider2); + ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); + + // set project description + CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription); + + // test the entries received from the scannerInfoProvider + LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider(); + ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(folder); + String[] actualIncludePaths = info.getIncludePaths(); + + // Test that the result is the union of entries + assertEquals(incFolderA.getLocation(), new Path(actualIncludePaths[0])); + assertEquals(incFolderB.getLocation(), new Path(actualIncludePaths[1])); + assertEquals(incFolderC.getLocation(), new Path(actualIncludePaths[2])); + assertEquals(3, actualIncludePaths.length); + } + +} diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/MockListenerRegisterer.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/MockListenerRegisterer.java index c39835629ec..d6887eb6e0a 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/MockListenerRegisterer.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/MockListenerRegisterer.java @@ -1,104 +1,104 @@ -/*******************************************************************************
- * Copyright (c) 2011, 2012 Andrew Gvozdev 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:
- * Andrew Gvozdev - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.core.language.settings.providers;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
-import org.eclipse.core.runtime.Assert;
-
-/**
- * Mock Language Settings Provider that keeps count how many times it has been registered.
- */
-public class MockListenerRegisterer extends LanguageSettingsSerializableProvider implements ILanguageSettingsEditableProvider, ICListenerAgent {
- private static MockListenerManager mockListenerManager = new MockListenerManager();
-
- private static class MockListenerManager {
- private class ListenerCount {
- private MockListenerRegisterer listener;
- private int count;
- public ListenerCount(MockListenerRegisterer l, int cnt) {
- listener = l;
- count = cnt;
- }
- }
- private List<ListenerCount> register = new ArrayList<ListenerCount>();
-
- public void registerListener(MockListenerRegisterer listener) {
- for (ListenerCount lc : register) {
- if (lc.listener == listener) {
- lc.count++;
- return;
- }
- }
-
- register.add(new ListenerCount(listener, 1));
- }
-
- public void unregisterListener(MockListenerRegisterer listener) {
- for (ListenerCount lc : register) {
- if (lc.listener == listener) {
- lc.count--;
- Assert.isTrue(lc.count>=0);
- return;
- }
- }
-
- // attempt to unregister non-registered listener
- Assert.isTrue(false);
- }
-
- /**
- * Note that that count includes all listeners with that id.
- */
- public int getCount(String id) {
- int count = 0;
-
- for (ListenerCount lc : register) {
- if (lc.listener.getId().equals(id)) {
- count = count + lc.count;
- }
- }
-
- return count;
- }
- }
-
- public MockListenerRegisterer() {
- super();
- }
- public MockListenerRegisterer(String id, String name) {
- super(id, name);
- }
- @Override
- public void registerListener(ICConfigurationDescription cfgDescription) {
- mockListenerManager.registerListener(this);
- }
-
- @Override
- public void unregisterListener() {
- mockListenerManager.unregisterListener(this);
- }
- @Override
- public MockListenerRegisterer cloneShallow() throws CloneNotSupportedException {
- return (MockListenerRegisterer) super.cloneShallow();
- }
- @Override
- public MockListenerRegisterer clone() throws CloneNotSupportedException {
- return (MockListenerRegisterer) super.clone();
- }
-
- public static int getCount(String id) {
- return mockListenerManager.getCount(id);
- }
+/******************************************************************************* + * Copyright (c) 2011, 2012 Andrew Gvozdev 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: + * Andrew Gvozdev - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.cdt.core.language.settings.providers; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; +import org.eclipse.core.runtime.Assert; + +/** + * Mock Language Settings Provider that keeps count how many times it has been registered. + */ +public class MockListenerRegisterer extends LanguageSettingsSerializableProvider implements ILanguageSettingsEditableProvider, ICListenerAgent { + private static MockListenerManager mockListenerManager = new MockListenerManager(); + + private static class MockListenerManager { + private class ListenerCount { + private MockListenerRegisterer listener; + private int count; + public ListenerCount(MockListenerRegisterer l, int cnt) { + listener = l; + count = cnt; + } + } + private List<ListenerCount> register = new ArrayList<ListenerCount>(); + + public void registerListener(MockListenerRegisterer listener) { + for (ListenerCount lc : register) { + if (lc.listener == listener) { + lc.count++; + return; + } + } + + register.add(new ListenerCount(listener, 1)); + } + + public void unregisterListener(MockListenerRegisterer listener) { + for (ListenerCount lc : register) { + if (lc.listener == listener) { + lc.count--; + Assert.isTrue(lc.count>=0); + return; + } + } + + // attempt to unregister non-registered listener + Assert.isTrue(false); + } + + /** + * Note that that count includes all listeners with that id. + */ + public int getCount(String id) { + int count = 0; + + for (ListenerCount lc : register) { + if (lc.listener.getId().equals(id)) { + count = count + lc.count; + } + } + + return count; + } + } + + public MockListenerRegisterer() { + super(); + } + public MockListenerRegisterer(String id, String name) { + super(id, name); + } + @Override + public void registerListener(ICConfigurationDescription cfgDescription) { + mockListenerManager.registerListener(this); + } + + @Override + public void unregisterListener() { + mockListenerManager.unregisterListener(this); + } + @Override + public MockListenerRegisterer cloneShallow() throws CloneNotSupportedException { + return (MockListenerRegisterer) super.cloneShallow(); + } + @Override + public MockListenerRegisterer clone() throws CloneNotSupportedException { + return (MockListenerRegisterer) super.clone(); + } + + public static int getCount(String id) { + return mockListenerManager.getCount(id); + } }
\ No newline at end of file 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 df422c6e855..d9736eff1d3 100644 --- a/core/org.eclipse.cdt.core.tests/resources/cfiles/CModelElementsTestStart.h +++ b/core/org.eclipse.cdt.core.tests/resources/cfiles/CModelElementsTestStart.h @@ -1,146 +1,146 @@ -// include
-#include "included.h"
-
-// macro
-#define PRINT(string,msg) printf(string, msg)
-
-//namespace
-namespace MyPackage
-{
- // check class
- // class
- class Hello
- {
- // protected visibility
- protected:
- // field
- int x;
- // method
- inline void setX(int X)
- {
- x = X;
- };
- // check nested pachage
- // nested namespace
- namespace MyNestedPackage {
- // check parent nested class
- // nested class
- class Y
- { // public visibility
- public:
- // constructor
- Y();
- // virtual destructor
- virtual ~Y();
- };
- // check derived nested class
- // derived class
- class X : public Y {
- // private visibility
- private:
- // private field
- B b;
-
- public:
- // constructor chain
- X(int x) : Y(x) {
- cout << "In consturctor\n";
- }
- // method declaration
- int doNothing();
- };
- }
- };
-
- // check enums
- // enum without name
- enum {
- first = 1,
- second,
- third
- }
- ;
- // enum with name
- enum MyEnum {
- f,
- s,
- t };
-
- // check variables
- // variable
- int v;
- // unsigned long variable
- unsigned long vuLong;
- // unsigned short variable
- unsigned short vuShort;
-
- // check variable declarations
- // variable declaration
- extern int evar;
- // function pointer
- static void * (*orig_malloc_hook)(const char *file, int line, size_t size);
-
- // check functions
- // simple function declaration
- void foo();
- // function declaration with parameters
- char* foo(int& x,
- char**y);
- // simple function definition
- void boo(){
- int g = 0;
- };
- // check Structs
- // struct
- struct MyStruct{
- int sint;
- };
- // typedef and elaborated types
- typedef struct MyStruct myStruct;
- // typedef
- typedef struct{
- int ss;
- } myTypedef;
- // unions
- union U{
- int U1;
- };
-
-
- // check templates
- // template function
- template<class A, typename B=C>
- A aTemplatedFunction( B bInstance );
- // template method
- class enclosing {
- // public visibility
- public:
- template<class A, typename B=C>
- A aTemplatedMethod( B bInstance );
- };
- // template class
- template<class T, typename Tibor = junk>
- class myarray { /* */ };
- // template struct
- template<class T, typename Tibor = junk>
- struct mystruct { /* */ };
- // template variable
-// template <bool __threads, int __inst>
-// char* default_alloc_template<__threads, __inst>::_S_start_free = 0;
-};
- // check arrays
- // arrays
- int myArray [5][];
- int main(int argc, char * argv[])
- {
- }
-
-// https://bugs.eclipse.org/bugs/show_bug.cgi?id=180815
-struct bug180815 {
- int i,j;
-} bug180815_var0, bug180815_var1;
-
-// https://bugs.eclipse.org/bugs/show_bug.cgi?id=352350
-namespace {
- int bug352350;
+// include +#include "included.h" + +// macro +#define PRINT(string,msg) printf(string, msg) + +//namespace +namespace MyPackage +{ + // check class + // class + class Hello + { + // protected visibility + protected: + // field + int x; + // method + inline void setX(int X) + { + x = X; + }; + // check nested pachage + // nested namespace + namespace MyNestedPackage { + // check parent nested class + // nested class + class Y + { // public visibility + public: + // constructor + Y(); + // virtual destructor + virtual ~Y(); + }; + // check derived nested class + // derived class + class X : public Y { + // private visibility + private: + // private field + B b; + + public: + // constructor chain + X(int x) : Y(x) { + cout << "In consturctor\n"; + } + // method declaration + int doNothing(); + }; + } + }; + + // check enums + // enum without name + enum { + first = 1, + second, + third + } + ; + // enum with name + enum MyEnum { + f, + s, + t }; + + // check variables + // variable + int v; + // unsigned long variable + unsigned long vuLong; + // unsigned short variable + unsigned short vuShort; + + // check variable declarations + // variable declaration + extern int evar; + // function pointer + static void * (*orig_malloc_hook)(const char *file, int line, size_t size); + + // check functions + // simple function declaration + void foo(); + // function declaration with parameters + char* foo(int& x, + char**y); + // simple function definition + void boo(){ + int g = 0; + }; + // check Structs + // struct + struct MyStruct{ + int sint; + }; + // typedef and elaborated types + typedef struct MyStruct myStruct; + // typedef + typedef struct{ + int ss; + } myTypedef; + // unions + union U{ + int U1; + }; + + + // check templates + // template function + template<class A, typename B=C> + A aTemplatedFunction( B bInstance ); + // template method + class enclosing { + // public visibility + public: + template<class A, typename B=C> + A aTemplatedMethod( B bInstance ); + }; + // template class + template<class T, typename Tibor = junk> + class myarray { /* */ }; + // template struct + template<class T, typename Tibor = junk> + struct mystruct { /* */ }; + // template variable +// template <bool __threads, int __inst> +// char* default_alloc_template<__threads, __inst>::_S_start_free = 0; +}; + // check arrays + // arrays + int myArray [5][]; + int main(int argc, char * argv[]) + { + } + +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=180815 +struct bug180815 { + int i,j; +} bug180815_var0, bug180815_var1; + +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=352350 +namespace { + int bug352350; }
\ No newline at end of file diff --git a/core/org.eclipse.cdt.core.tests/resources/cfiles/TranslationUnits.c b/core/org.eclipse.cdt.core.tests/resources/cfiles/TranslationUnits.c index e258b183e56..2f7b355860a 100644 --- a/core/org.eclipse.cdt.core.tests/resources/cfiles/TranslationUnits.c +++ b/core/org.eclipse.cdt.core.tests/resources/cfiles/TranslationUnits.c @@ -1,70 +1,70 @@ -/*
- * (c) Copyright QNX Software Systems Ltd. 2002, 2003.
- * All Rights Reserved.
+/* + * (c) Copyright QNX Software Systems Ltd. 2002, 2003. + * All Rights Reserved. */ -/********
- * This is a sample C file that will be used in testing the TranslationUnit
- * class. It has a specific structure that will be looked for within the
- * test case.
- * This file is only ment to contain various C elements, and may not compile
- * into a running application (but should be valid C)
- */
-
-#include <stdio.h>
-#include <unistd.h>
-
-/* A function prototype */
-int func2p(void);
-
-/* A global variable */
-int globalvar;
-
-/* A enumeration */
-enum myenum {ENUM_A=1, ENUM_B=2, ENUM_C=3, ENUM_D=4};
-
-/* A structure. This also includes a typedef around the strcture def
- * which at the time of writing was not picked up.
- */
-typedef struct mystruct {
- int a;
- char b;
- long c;
-} mystruct_t;
-
-/* A union */
-union myunion {
- int x;
- char y;
- long z;
-};
-
-/* A typedef */
-typedef struct mystruct mytype;
-
-
-/* A couple functions */
-
-void * func1(void)
-{
- return(NULL);
-}
-
-
-int func2(void)
-{
- return(0);
-}
-
-int main(int argc, char ** argv)
-{
- int var1;
- printf("Hello world\n");
-}
-
-
-void func3()
-{
- printf("This is not really here\n");
-}
-
-
+/******** + * This is a sample C file that will be used in testing the TranslationUnit + * class. It has a specific structure that will be looked for within the + * test case. + * This file is only ment to contain various C elements, and may not compile + * into a running application (but should be valid C) + */ + +#include <stdio.h> +#include <unistd.h> + +/* A function prototype */ +int func2p(void); + +/* A global variable */ +int globalvar; + +/* A enumeration */ +enum myenum {ENUM_A=1, ENUM_B=2, ENUM_C=3, ENUM_D=4}; + +/* A structure. This also includes a typedef around the strcture def + * which at the time of writing was not picked up. + */ +typedef struct mystruct { + int a; + char b; + long c; +} mystruct_t; + +/* A union */ +union myunion { + int x; + char y; + long z; +}; + +/* A typedef */ +typedef struct mystruct mytype; + + +/* A couple functions */ + +void * func1(void) +{ + return(NULL); +} + + +int func2(void) +{ + return(0); +} + +int main(int argc, char ** argv) +{ + int var1; + printf("Hello world\n"); +} + + +void func3() +{ + printf("This is not really here\n"); +} + + diff --git a/core/org.eclipse.cdt.core.tests/resources/cfiles/included.h b/core/org.eclipse.cdt.core.tests/resources/cfiles/included.h index b5b6d36ac65..53eae6898ac 100644 --- a/core/org.eclipse.cdt.core.tests/resources/cfiles/included.h +++ b/core/org.eclipse.cdt.core.tests/resources/cfiles/included.h @@ -1,10 +1,10 @@ -#define size_t int
-class A;
-
-class B;
-
-class C;
-
-class T;
-
-class junk;
+#define size_t int +class A; + +class B; + +class C; + +class T; + +class junk; diff --git a/core/org.eclipse.cdt.core.tests/resources/cmodel/DeclaratorsTests.cpp b/core/org.eclipse.cdt.core.tests/resources/cmodel/DeclaratorsTests.cpp index f0d2c7e98c7..94df40c6076 100644 --- a/core/org.eclipse.cdt.core.tests/resources/cmodel/DeclaratorsTests.cpp +++ b/core/org.eclipse.cdt.core.tests/resources/cmodel/DeclaratorsTests.cpp @@ -1,24 +1,24 @@ -void decl_0001(char);
-void (decl_0002)(char);
-void ((decl_0003))(char);
-
-void *decl_0004(char);
-void (*decl_0005)(char);
-void (*(decl_0006))(char);
-void ((*decl_0007))(char);
-
-typedef void decl_0011(char);
-typedef void (decl_0012)(char);
-typedef void ((decl_0013))(char);
-
-typedef void *decl_0014(char);
-typedef void (*decl_0015)(char);
-typedef void (*(decl_0016))(char);
-typedef void ((*decl_0017))(char);
-
-typedef void decl_0021(char);
-void (*decl_0022)(char);
-void (*(*decl_0023(int a)))(char) { return &decl_0021; }
-void (*(*(*((decl_0024)))(int))(float))(char);
-
-int (*decl_0031)(char(*yyy)(bool));
+void decl_0001(char); +void (decl_0002)(char); +void ((decl_0003))(char); + +void *decl_0004(char); +void (*decl_0005)(char); +void (*(decl_0006))(char); +void ((*decl_0007))(char); + +typedef void decl_0011(char); +typedef void (decl_0012)(char); +typedef void ((decl_0013))(char); + +typedef void *decl_0014(char); +typedef void (*decl_0015)(char); +typedef void (*(decl_0016))(char); +typedef void ((*decl_0017))(char); + +typedef void decl_0021(char); +void (*decl_0022)(char); +void (*(*decl_0023(int a)))(char) { return &decl_0021; } +void (*(*(*((decl_0024)))(int))(float))(char); + +int (*decl_0031)(char(*yyy)(bool)); diff --git a/core/org.eclipse.cdt.core.tests/resources/cmodel/IIncludeTest.h b/core/org.eclipse.cdt.core.tests/resources/cmodel/IIncludeTest.h index 04b6e419a44..872c9f3d811 100644 --- a/core/org.eclipse.cdt.core.tests/resources/cmodel/IIncludeTest.h +++ b/core/org.eclipse.cdt.core.tests/resources/cmodel/IIncludeTest.h @@ -1,42 +1,42 @@ -// include
-#include <stdio.h>
-#include "whatever.h"
-#include <src/slash.h>
-#include <src\backslash.h>
-#include "Program Files/space.h"
-#include "../up1dir.h"
-#include "./samedir.h"
-#include "different_extension1.hpp"
-#include "different_extension2.hh"
-#include "different_extension3.x"
-#include <no_extension>
-# include "whitespace_after_hash"
- #include "whitespace_before_hash"
-
-// failure cases:
-#include garbage
-#include "resync_after_bad_parse_1"
-#include
-#include "resync_after_bad_parse_2"
-#include "one" "two" "three"
-#include "resync_after_bad_parse_3"
-
-// from the Spec:
-
-// from [C, 6.10.p8]
-// should fail
-#define EMPTY
-EMPTY #include "invalid.h"
-
-// from [C, 6.10.2.p8]:
-// should equal #include "myInclude1.h"
-#define MYINCFILE "myInclude1.h"
-#include MYINCFILE
-
-// from [C, 6.10.3.5.p6]:
-// should equal #include "vers2.h"
-#define INCFILE(x) vers ## x
-#define xstr(x) str(x)
-#define str(x) #x
-#include xstr(INCFILE(2).h)
-
+// include +#include <stdio.h> +#include "whatever.h" +#include <src/slash.h> +#include <src\backslash.h> +#include "Program Files/space.h" +#include "../up1dir.h" +#include "./samedir.h" +#include "different_extension1.hpp" +#include "different_extension2.hh" +#include "different_extension3.x" +#include <no_extension> +# include "whitespace_after_hash" + #include "whitespace_before_hash" + +// failure cases: +#include garbage +#include "resync_after_bad_parse_1" +#include +#include "resync_after_bad_parse_2" +#include "one" "two" "three" +#include "resync_after_bad_parse_3" + +// from the Spec: + +// from [C, 6.10.p8] +// should fail +#define EMPTY +EMPTY #include "invalid.h" + +// from [C, 6.10.2.p8]: +// should equal #include "myInclude1.h" +#define MYINCFILE "myInclude1.h" +#include MYINCFILE + +// from [C, 6.10.3.5.p6]: +// should equal #include "vers2.h" +#define INCFILE(x) vers ## x +#define xstr(x) str(x) +#define str(x) #x +#include xstr(INCFILE(2).h) + diff --git a/core/org.eclipse.cdt.core.tests/resources/cmodel/IMacroTest.h b/core/org.eclipse.cdt.core.tests/resources/cmodel/IMacroTest.h index a5bf320efab..34fdd295164 100644 --- a/core/org.eclipse.cdt.core.tests/resources/cmodel/IMacroTest.h +++ b/core/org.eclipse.cdt.core.tests/resources/cmodel/IMacroTest.h @@ -1,4 +1,4 @@ -// macro
-#define SINGLETON
-#define NUMBER 1
-#define PRINT(string,msg) printf(string, msg)
+// macro +#define SINGLETON +#define NUMBER 1 +#define PRINT(string,msg) printf(string, msg) diff --git a/core/org.eclipse.cdt.core.tests/resources/cmodel/ITemplate.cpp b/core/org.eclipse.cdt.core.tests/resources/cmodel/ITemplate.cpp index 9874a1f3fd4..a180890fd5a 100644 --- a/core/org.eclipse.cdt.core.tests/resources/cmodel/ITemplate.cpp +++ b/core/org.eclipse.cdt.core.tests/resources/cmodel/ITemplate.cpp @@ -1,72 +1,72 @@ -class Key;
-class Value;
-class SortAlgorithm;
-class DefaultSort;
-class T;
-class X;
-class Y;
-class Bar;
-class Foo {
- template<class Bar> void fum(int i);
-};
-
-// TEMPLATE_STRUCT
-template<class Key, class Value, class SortAlgorithm=DefaultSort>
-struct Map
-{
- Key* keys;
- Value* values;
- SortAlgorithm* sortAlgorithm;
- Map();
-};
-
-// TEMPLATE_CLASS
-template<class T> class nonVector {
- private:
- T* head;
-
- public:
- nonVector() { head =new T(); }
- int length() { return 1; }
- const T& first();
-};
-
-// TEMPLATE_UNION
-template<class X, class Y, int size=16>
-union ArrayOverlay {
- public:
- X x[size];
- Y y[size];
-
- static int<X,Y> numArrays;
-};
-
-
-// TEMPLATE_METHODS
-class TemplateContainer {
- // these are in an enclosing class
- template<class Bar> void fum(int i);
- template<int> void scrum(void) {};
-};
-
-// TEMPLATE_FUNCTION
-template<class T> const T& nonVector<T>::first() const
-{
- return *head;
-}
-
-template<class X> bool IsGreaterThan(X,X);
-
-template<class Bar> void Foo::fum(int i) {}
-
-// TEMPLATE_VARIABLES
-template <bool threads, int inst> char* default_alloc_template<threads, inst>::S_start_free = 0;
-
-// an instantiation, not a template:
-complex<float> cf(0,0);
-//template<class Language, class CharacterSet, class SortAlgorithm<CharacterSet> >
-//Dictionary* TheSpellCheckDictionary;
-
-int success;
-
-
+class Key; +class Value; +class SortAlgorithm; +class DefaultSort; +class T; +class X; +class Y; +class Bar; +class Foo { + template<class Bar> void fum(int i); +}; + +// TEMPLATE_STRUCT +template<class Key, class Value, class SortAlgorithm=DefaultSort> +struct Map +{ + Key* keys; + Value* values; + SortAlgorithm* sortAlgorithm; + Map(); +}; + +// TEMPLATE_CLASS +template<class T> class nonVector { + private: + T* head; + + public: + nonVector() { head =new T(); } + int length() { return 1; } + const T& first(); +}; + +// TEMPLATE_UNION +template<class X, class Y, int size=16> +union ArrayOverlay { + public: + X x[size]; + Y y[size]; + + static int<X,Y> numArrays; +}; + + +// TEMPLATE_METHODS +class TemplateContainer { + // these are in an enclosing class + template<class Bar> void fum(int i); + template<int> void scrum(void) {}; +}; + +// TEMPLATE_FUNCTION +template<class T> const T& nonVector<T>::first() const +{ + return *head; +} + +template<class X> bool IsGreaterThan(X,X); + +template<class Bar> void Foo::fum(int i) {} + +// TEMPLATE_VARIABLES +template <bool threads, int inst> char* default_alloc_template<threads, inst>::S_start_free = 0; + +// an instantiation, not a template: +complex<float> cf(0,0); +//template<class Language, class CharacterSet, class SortAlgorithm<CharacterSet> > +//Dictionary* TheSpellCheckDictionary; + +int success; + + diff --git a/core/org.eclipse.cdt.core.tests/resources/dependency/DepTest.cpp b/core/org.eclipse.cdt.core.tests/resources/dependency/DepTest.cpp index 828a3aca6cf..4dbb7f4f9b3 100644 --- a/core/org.eclipse.cdt.core.tests/resources/dependency/DepTest.cpp +++ b/core/org.eclipse.cdt.core.tests/resources/dependency/DepTest.cpp @@ -1,8 +1,8 @@ -#include "DepTest.h"
-#include "d.h"
-
-DepTest::DepTest()
-{};
-DepTest::~DepTest()
-{};
-
+#include "DepTest.h" +#include "d.h" + +DepTest::DepTest() +{}; +DepTest::~DepTest() +{}; + diff --git a/core/org.eclipse.cdt.core.tests/resources/dependency/DepTest.h b/core/org.eclipse.cdt.core.tests/resources/dependency/DepTest.h index c008086c156..376c76f4891 100644 --- a/core/org.eclipse.cdt.core.tests/resources/dependency/DepTest.h +++ b/core/org.eclipse.cdt.core.tests/resources/dependency/DepTest.h @@ -1,8 +1,8 @@ -#include "Inc1.h"
-#include "a.h"
-class DepTest{
-public:
-
- DepTest();
- ~DepTest();
-};
+#include "Inc1.h" +#include "a.h" +class DepTest{ +public: + + DepTest(); + ~DepTest(); +}; diff --git a/core/org.eclipse.cdt.core.tests/resources/dependency/DepTest2.cpp b/core/org.eclipse.cdt.core.tests/resources/dependency/DepTest2.cpp index 6f3000e6df3..55014b84d54 100644 --- a/core/org.eclipse.cdt.core.tests/resources/dependency/DepTest2.cpp +++ b/core/org.eclipse.cdt.core.tests/resources/dependency/DepTest2.cpp @@ -1,8 +1,8 @@ -#include "DepTest2.h"
-#include "d.h"
-
-DepTest2::DepTest2()
-{};
-DepTest2::~DepTest2()
-{};
-
+#include "DepTest2.h" +#include "d.h" + +DepTest2::DepTest2() +{}; +DepTest2::~DepTest2() +{}; + diff --git a/core/org.eclipse.cdt.core.tests/resources/dependency/DepTest2.h b/core/org.eclipse.cdt.core.tests/resources/dependency/DepTest2.h index 6f084a69b11..e3a8946e84e 100644 --- a/core/org.eclipse.cdt.core.tests/resources/dependency/DepTest2.h +++ b/core/org.eclipse.cdt.core.tests/resources/dependency/DepTest2.h @@ -1,8 +1,8 @@ -#include "d.h"
-
-class DepTest2{
-public:
-
- DepTest2();
- ~DepTest2();
-};
+#include "d.h" + +class DepTest2{ +public: + + DepTest2(); + ~DepTest2(); +}; diff --git a/core/org.eclipse.cdt.core.tests/resources/dependency/DepTest3.cpp b/core/org.eclipse.cdt.core.tests/resources/dependency/DepTest3.cpp index cc0d9ba24ee..e3e0086c56c 100644 --- a/core/org.eclipse.cdt.core.tests/resources/dependency/DepTest3.cpp +++ b/core/org.eclipse.cdt.core.tests/resources/dependency/DepTest3.cpp @@ -1,7 +1,7 @@ -#include "DepTest3.h"
-
-DepTest3::DepTest3()
-{};
-DepTest3::~DepTest3()
-{};
-
+#include "DepTest3.h" + +DepTest3::DepTest3() +{}; +DepTest3::~DepTest3() +{}; + diff --git a/core/org.eclipse.cdt.core.tests/resources/dependency/DepTest3.h b/core/org.eclipse.cdt.core.tests/resources/dependency/DepTest3.h index b4b47ce40e4..1390e03a3cd 100644 --- a/core/org.eclipse.cdt.core.tests/resources/dependency/DepTest3.h +++ b/core/org.eclipse.cdt.core.tests/resources/dependency/DepTest3.h @@ -1,8 +1,8 @@ -#include "a.h"
-
-class DepTest3{
-public:
-
- DepTest3();
- ~DepTest3();
-};
+#include "a.h" + +class DepTest3{ +public: + + DepTest3(); + ~DepTest3(); +}; diff --git a/core/org.eclipse.cdt.core.tests/resources/dependency/Inc1.h b/core/org.eclipse.cdt.core.tests/resources/dependency/Inc1.h index 7bfbe592caa..71ea5574504 100644 --- a/core/org.eclipse.cdt.core.tests/resources/dependency/Inc1.h +++ b/core/org.eclipse.cdt.core.tests/resources/dependency/Inc1.h @@ -1,8 +1,8 @@ -#include "c.h"
-
-class X
-{
- public:
- X(){};
- ~X(){};
+#include "c.h" + +class X +{ + public: + X(){}; + ~X(){}; };
\ No newline at end of file diff --git a/core/org.eclipse.cdt.core.tests/resources/dependency/a.h b/core/org.eclipse.cdt.core.tests/resources/dependency/a.h index 3c66f940fc1..ac18143ef8d 100644 --- a/core/org.eclipse.cdt.core.tests/resources/dependency/a.h +++ b/core/org.eclipse.cdt.core.tests/resources/dependency/a.h @@ -1,8 +1,8 @@ -#include "c.h"
-
-class Z
-{
- public:
- Z(){};
- ~Z(){};
+#include "c.h" + +class Z +{ + public: + Z(){}; + ~Z(){}; };
\ No newline at end of file diff --git a/core/org.eclipse.cdt.core.tests/resources/dependency/c.h b/core/org.eclipse.cdt.core.tests/resources/dependency/c.h index bc82542a695..5c9fd01d7b2 100644 --- a/core/org.eclipse.cdt.core.tests/resources/dependency/c.h +++ b/core/org.eclipse.cdt.core.tests/resources/dependency/c.h @@ -1,6 +1,6 @@ -class Y
-{
- public:
- Y(){};
- ~Y(){};
+class Y +{ + public: + Y(){}; + ~Y(){}; };
\ No newline at end of file diff --git a/core/org.eclipse.cdt.core.tests/resources/dependency/d.h b/core/org.eclipse.cdt.core.tests/resources/dependency/d.h index 8dcf01a87d2..9f800e81d90 100644 --- a/core/org.eclipse.cdt.core.tests/resources/dependency/d.h +++ b/core/org.eclipse.cdt.core.tests/resources/dependency/d.h @@ -1,6 +1,6 @@ -class d
-{
- public:
- d(){};
- ~d(){};
+class d +{ + public: + d(){}; + ~d(){}; };
\ No newline at end of file diff --git a/core/org.eclipse.cdt.core.tests/resources/indexer/DocumentManager.cpp b/core/org.eclipse.cdt.core.tests/resources/indexer/DocumentManager.cpp index 5fb91b9ce50..155edfb47bd 100644 --- a/core/org.eclipse.cdt.core.tests/resources/indexer/DocumentManager.cpp +++ b/core/org.eclipse.cdt.core.tests/resources/indexer/DocumentManager.cpp @@ -1,25 +1,25 @@ -//#include "StdAfx.h"
-#include "DocumentManager.h"
-
-CDocumentManager::CDocumentManager(void)
-{
-}
-
-CDocumentManager::~CDocumentManager(void)
-{
-}
-
-void CDocumentManager::addToControlMap(UINT threadID, IUnknown * theControl)
-{
- _controlMap.insert(MUL2IUnk_Pair(threadID,theControl));
-}
-
-void CDocumentManager::getControl(ULONG threadID, IUnknown ** theControl)
-{
- if (_controlMap.find(threadID) != _controlMap.end())
- {
- theControl = &_controlMap[threadID];
- }
-
-
-}
+//#include "StdAfx.h" +#include "DocumentManager.h" + +CDocumentManager::CDocumentManager(void) +{ +} + +CDocumentManager::~CDocumentManager(void) +{ +} + +void CDocumentManager::addToControlMap(UINT threadID, IUnknown * theControl) +{ + _controlMap.insert(MUL2IUnk_Pair(threadID,theControl)); +} + +void CDocumentManager::getControl(ULONG threadID, IUnknown ** theControl) +{ + if (_controlMap.find(threadID) != _controlMap.end()) + { + theControl = &_controlMap[threadID]; + } + + +} diff --git a/core/org.eclipse.cdt.core.tests/resources/indexer/extramail.cpp b/core/org.eclipse.cdt.core.tests/resources/indexer/extramail.cpp index da47fd6b304..766afa6a80e 100644 --- a/core/org.eclipse.cdt.core.tests/resources/indexer/extramail.cpp +++ b/core/org.eclipse.cdt.core.tests/resources/indexer/extramail.cpp @@ -1,112 +1,112 @@ -#include <iostream.h>
-#include <stdlib.h>
-#include <alloc.h>
-#include <iomanip.h>
-
-#define PRINT(a,b) cout<<(a)<<(b)
-#define CASE break;case
-#define MAX(a,b) (((a)>(b))?(a):(b))
-
-typedef int int32;
-
-static void doSomething();
-
-namespace Z{
- int x;
- namespace X{
- namespace Y{
- enum test{cool,hi,bye,why};
- class Mail
- {
- public:
- Mail(){}
- virtual void print()=0; //Pure Virtual Function, forces redefinition
- protected:
- float postage;
- char *type;
- friend ostream& operator << (ostream& os, Mail *m);
- };
-
- class postcard : public Mail
- {
- public:
- postcard(): Mail(){postage = 0.20; type = "Postcard";}
- void print(){cout << type << ": $" << setiosflags(ios::fixed)
- <<setprecision(2) << postage <<endl;}
- };
-
- class first_class : public Mail
- {
- public:
- first_class() : Mail(){postage = 0.32; type = "First Class";}
- void print(){cout << type << ": $" <<setiosflags(ios::fixed)
- << setprecision(2) << postage <<endl;}
-
- };
-
- class Unknown : public postcard, first_class // ??? Multiple Inheritance
- {
- public:
- Unknown(): postcard(), first_class()
- {
- postcard::postage = 1.50; // MUST disambiguate
- postcard::type = "Unknown";
- }
- void print(){cout << postcard::type << ": $" <<setiosflags(ios::fixed)
- <<setprecision(2)<<postcard::postage <<endl;}
- };
-
- class container
- {
- private:
- Mail **array;
- int index;
- int sz;
- public:
- container(){array = 0;}
- ~container(){
- for(int x = 0; x <sz; x++)
- delete array[x];
- free(array);
- }
- int size() {return sz;}
- Mail* operator[](int index);
- Mail* operator = (Mail* mail);
- };
-
- main()
- {
- container PO_Box;
- PO_Box = new postcard;
- PO_Box = new first_class;
- PO_Box = new parcel_Post;
- //PO_Box = new Unknown;
- //one way of printing information
- for(int x =0; x <3; x++){
- PO_Box[x]->print();
- }
- //Overloaded <<
- for(int x =0; x <PO_Box.size(); x++){
- cout << PO_Box[x];
- }
- }
-
- ostream& operator << (ostream &os, Mail *m)
- {
- os <<setiosflags(ios::fixed) << setprecision(2)<< m->type
- << ": $" << m->postage <<endl;
-
- return os;
- }
- Mail* container::operator[](int index) {return array[index];}
- Mail* container::operator = (Mail* mail)
- {
- int size = sizeof(Mail*) * (++sz);
- int temp = sz -1;
- array = (Mail**)realloc(array, size);
- array[temp] = mail;
- return 0;
- }
- }
- }
-}
+#include <iostream.h> +#include <stdlib.h> +#include <alloc.h> +#include <iomanip.h> + +#define PRINT(a,b) cout<<(a)<<(b) +#define CASE break;case +#define MAX(a,b) (((a)>(b))?(a):(b)) + +typedef int int32; + +static void doSomething(); + +namespace Z{ + int x; + namespace X{ + namespace Y{ + enum test{cool,hi,bye,why}; + class Mail + { + public: + Mail(){} + virtual void print()=0; //Pure Virtual Function, forces redefinition + protected: + float postage; + char *type; + friend ostream& operator << (ostream& os, Mail *m); + }; + + class postcard : public Mail + { + public: + postcard(): Mail(){postage = 0.20; type = "Postcard";} + void print(){cout << type << ": $" << setiosflags(ios::fixed) + <<setprecision(2) << postage <<endl;} + }; + + class first_class : public Mail + { + public: + first_class() : Mail(){postage = 0.32; type = "First Class";} + void print(){cout << type << ": $" <<setiosflags(ios::fixed) + << setprecision(2) << postage <<endl;} + + }; + + class Unknown : public postcard, first_class // ??? Multiple Inheritance + { + public: + Unknown(): postcard(), first_class() + { + postcard::postage = 1.50; // MUST disambiguate + postcard::type = "Unknown"; + } + void print(){cout << postcard::type << ": $" <<setiosflags(ios::fixed) + <<setprecision(2)<<postcard::postage <<endl;} + }; + + class container + { + private: + Mail **array; + int index; + int sz; + public: + container(){array = 0;} + ~container(){ + for(int x = 0; x <sz; x++) + delete array[x]; + free(array); + } + int size() {return sz;} + Mail* operator[](int index); + Mail* operator = (Mail* mail); + }; + + main() + { + container PO_Box; + PO_Box = new postcard; + PO_Box = new first_class; + PO_Box = new parcel_Post; + //PO_Box = new Unknown; + //one way of printing information + for(int x =0; x <3; x++){ + PO_Box[x]->print(); + } + //Overloaded << + for(int x =0; x <PO_Box.size(); x++){ + cout << PO_Box[x]; + } + } + + ostream& operator << (ostream &os, Mail *m) + { + os <<setiosflags(ios::fixed) << setprecision(2)<< m->type + << ": $" << m->postage <<endl; + + return os; + } + Mail* container::operator[](int index) {return array[index];} + Mail* container::operator = (Mail* mail) + { + int size = sizeof(Mail*) * (++sz); + int temp = sz -1; + array = (Mail**)realloc(array, size); + array[temp] = mail; + return 0; + } + } + } +} diff --git a/core/org.eclipse.cdt.core.tests/resources/indexer/reftest.cpp b/core/org.eclipse.cdt.core.tests/resources/indexer/reftest.cpp index 8f65972886d..0c908b274ce 100644 --- a/core/org.eclipse.cdt.core.tests/resources/indexer/reftest.cpp +++ b/core/org.eclipse.cdt.core.tests/resources/indexer/reftest.cpp @@ -1,22 +1,22 @@ -namespace A
-{
- class ForwardA;
- ForwardA * tmp;
- int something(void);
- namespace B
- {
- enum e1{dude1,dude2};
- int x;
- class C
- { static int y = 5;
- static int bar(void);
- };
- }
-}
-using namespace A::B;
-using A::B::x;
-using A::B::C;
-using A::B::C::y;
-using A::B::C::bar;
-using A::something;
+namespace A +{ + class ForwardA; + ForwardA * tmp; + int something(void); + namespace B + { + enum e1{dude1,dude2}; + int x; + class C + { static int y = 5; + static int bar(void); + }; + } +} +using namespace A::B; +using A::B::x; +using A::B::C; +using A::B::C::y; +using A::B::C::bar; +using A::something; using A::B::e1;
\ No newline at end of file diff --git a/core/org.eclipse.cdt.core.tests/resources/parser/AutomatedTest/defaultC/Simple.c b/core/org.eclipse.cdt.core.tests/resources/parser/AutomatedTest/defaultC/Simple.c index e7d2a2e016f..16bc625fe55 100644 --- a/core/org.eclipse.cdt.core.tests/resources/parser/AutomatedTest/defaultC/Simple.c +++ b/core/org.eclipse.cdt.core.tests/resources/parser/AutomatedTest/defaultC/Simple.c @@ -1,43 +1,43 @@ -#include <Simple.h>
-
-const SimpleStruct simpleStruct =
-{
- 1
- , "mySimple"
- , 0.1232
-};
-
-#define SIZEOF( A, B ) sizeof( A.B )
-
-const OtherStruct array[] =
-{
- {
-#if FOO
- "foo"
-#else
- "bar"
-#endif
- , SIZEOF( simpleStruct, num )
- , &t_int
- , 0
- }
- , {
- "name"
- , SIZEOF( simpleStruct, floatnum )
- , &t_float
- , 1
- }
-};
-
-
-void SimpleStruct_construct( struct SimpleStruct * const this )
-{
- this->num = 1;
- this->name = "boo";
- this->floatNum = 1.5;
-}
-
-int ConnectParams_doSomething( const struct SimpleStruct * const this )
-{
- return 1;
-}
+#include <Simple.h> + +const SimpleStruct simpleStruct = +{ + 1 + , "mySimple" + , 0.1232 +}; + +#define SIZEOF( A, B ) sizeof( A.B ) + +const OtherStruct array[] = +{ + { +#if FOO + "foo" +#else + "bar" +#endif + , SIZEOF( simpleStruct, num ) + , &t_int + , 0 + } + , { + "name" + , SIZEOF( simpleStruct, floatnum ) + , &t_float + , 1 + } +}; + + +void SimpleStruct_construct( struct SimpleStruct * const this ) +{ + this->num = 1; + this->name = "boo"; + this->floatNum = 1.5; +} + +int ConnectParams_doSomething( const struct SimpleStruct * const this ) +{ + return 1; +} diff --git a/core/org.eclipse.cdt.core.tests/resources/parser/AutomatedTest/defaultC/Simple.h b/core/org.eclipse.cdt.core.tests/resources/parser/AutomatedTest/defaultC/Simple.h index 96e8ef0a741..b5012c10f5b 100644 --- a/core/org.eclipse.cdt.core.tests/resources/parser/AutomatedTest/defaultC/Simple.h +++ b/core/org.eclipse.cdt.core.tests/resources/parser/AutomatedTest/defaultC/Simple.h @@ -1,17 +1,17 @@ -#ifndef SIMPLE_H
-#define SIMPLE_H
-
-struct SimpleStruct
-{
- int num;
- char name[ ];
- float floatNum;
-};
-
-
-void SimpleStruct_construct( struct SimpleStruct * const this );
-
-int SimpleStruct_doSomething( const struct SimpleStruct * const this );
-
-#endif /* SIMPLE_H */
-
+#ifndef SIMPLE_H +#define SIMPLE_H + +struct SimpleStruct +{ + int num; + char name[ ]; + float floatNum; +}; + + +void SimpleStruct_construct( struct SimpleStruct * const this ); + +int SimpleStruct_doSomething( const struct SimpleStruct * const this ); + +#endif /* SIMPLE_H */ + diff --git a/core/org.eclipse.cdt.core.tests/resources/parser/AutomatedTest/defaultCpp/Simple.cpp b/core/org.eclipse.cdt.core.tests/resources/parser/AutomatedTest/defaultCpp/Simple.cpp index 4b4055ade2d..471f78e6c91 100644 --- a/core/org.eclipse.cdt.core.tests/resources/parser/AutomatedTest/defaultCpp/Simple.cpp +++ b/core/org.eclipse.cdt.core.tests/resources/parser/AutomatedTest/defaultCpp/Simple.cpp @@ -1,37 +1,37 @@ -#include <Simple.h>
-
-#include <iostream>
-
-#define NULL (void *)0
-
-SimpleClass::SimpleClass( void )
-{
- init( NULL );
-}
-
-SimpleClass::~SimpleClass( void )
-{
-}
-
-SimpleClass::SimpleClass( const SimpleClass & arg )
-{
- //TODO: copy constructor
-}
-
-SimpleClass & SimpleClass::operator=( const SimpleClass & arg )
-{
- if( this != &arg )
- {
- }
- return *this;
-}
-
-
-void SimpleClass::init( void * foo)
-{
-}
-
-InnerStruct & SimpleClass::getInner( void )
-{
- return inner;
-}
+#include <Simple.h> + +#include <iostream> + +#define NULL (void *)0 + +SimpleClass::SimpleClass( void ) +{ + init( NULL ); +} + +SimpleClass::~SimpleClass( void ) +{ +} + +SimpleClass::SimpleClass( const SimpleClass & arg ) +{ + //TODO: copy constructor +} + +SimpleClass & SimpleClass::operator=( const SimpleClass & arg ) +{ + if( this != &arg ) + { + } + return *this; +} + + +void SimpleClass::init( void * foo) +{ +} + +InnerStruct & SimpleClass::getInner( void ) +{ + return inner; +} diff --git a/core/org.eclipse.cdt.core.tests/resources/parser/AutomatedTest/defaultCpp/Simple.h b/core/org.eclipse.cdt.core.tests/resources/parser/AutomatedTest/defaultCpp/Simple.h index e22c5eefbd0..b385fcd46ff 100644 --- a/core/org.eclipse.cdt.core.tests/resources/parser/AutomatedTest/defaultCpp/Simple.h +++ b/core/org.eclipse.cdt.core.tests/resources/parser/AutomatedTest/defaultCpp/Simple.h @@ -1,32 +1,32 @@ -#ifndef SIMPLE_H
-#define SIMPLE_H
-
-class OtherClass;
-
-class SimpleClass
-{
-public:
- SimpleClass( void );
- SimpleClass( const SimpleClass & arg );
-
- virtual ~SimpleClass( void );
-
- SimpleClass & operator=( const SimpleClass & arg );
-
-private:
- struct InnerStruct
- {
- inline InnerStruct( int a ){ _a = a; }
- inline ~InnerStruct( void ){}
- unsigned int _a;
- };
-
- InnerStruct inner;
-
- void init( void * );
-
-public:
- InnerStruct & getInner( void );
-};
-
-#endif /* SIMPLE_H */
+#ifndef SIMPLE_H +#define SIMPLE_H + +class OtherClass; + +class SimpleClass +{ +public: + SimpleClass( void ); + SimpleClass( const SimpleClass & arg ); + + virtual ~SimpleClass( void ); + + SimpleClass & operator=( const SimpleClass & arg ); + +private: + struct InnerStruct + { + inline InnerStruct( int a ){ _a = a; } + inline ~InnerStruct( void ){} + unsigned int _a; + }; + + InnerStruct inner; + + void init( void * ); + +public: + InnerStruct & getInner( void ); +}; + +#endif /* SIMPLE_H */ diff --git a/core/org.eclipse.cdt.core.tests/resources/parser/LineNumberTest.h b/core/org.eclipse.cdt.core.tests/resources/parser/LineNumberTest.h index 16b506364f0..6660b4e9898 100644 --- a/core/org.eclipse.cdt.core.tests/resources/parser/LineNumberTest.h +++ b/core/org.eclipse.cdt.core.tests/resources/parser/LineNumberTest.h @@ -1,43 +1,43 @@ -// inclusion begins and ends on line 2
-#include <stdio.h>
-
-// simple macro begins and ends on line 5; ANOTHER on line 6
-#define SIMPLE_MACRO simple
-#define ANOTHER
-// namespace begins on line 7, ends on line 22
-namespace MyPackage{
- // class specification begins on line 10, ends on line 21
- class Hello{
- protected:
- // simple declaration begins and ends on line 13
- int x;
- // simple declaration begins and ends on line 15
- void setX(int X);
- public:
- // simple declaration begins on line 18 and ends on line 20
- Hello( void ) : x
- ( 5 ) {
- }
- };
-}
-
-// simple declaration begins on line 25 and ends on line 27
-int *
- y =
- 0;
-
-// complex macro begins on line 30 and ends on line 31
-#define COMPLEX_MACRO 33 \
- + 44
-
-// template declaration begins on line 34 and ends on line 35
-template <class A >
- A createA( void );
-
-// enumeration begins on line 38 and ends on line 43
-enum {
- one, // enumerator begins and ends on line 39
- two, // enumerator begins and ends on line 40
- three // enumerator begins on line 41, ends on line 42
- = 4
+// inclusion begins and ends on line 2 +#include <stdio.h> + +// simple macro begins and ends on line 5; ANOTHER on line 6 +#define SIMPLE_MACRO simple +#define ANOTHER +// namespace begins on line 7, ends on line 22 +namespace MyPackage{ + // class specification begins on line 10, ends on line 21 + class Hello{ + protected: + // simple declaration begins and ends on line 13 + int x; + // simple declaration begins and ends on line 15 + void setX(int X); + public: + // simple declaration begins on line 18 and ends on line 20 + Hello( void ) : x + ( 5 ) { + } + }; +} + +// simple declaration begins on line 25 and ends on line 27 +int * + y = + 0; + +// complex macro begins on line 30 and ends on line 31 +#define COMPLEX_MACRO 33 \ + + 44 + +// template declaration begins on line 34 and ends on line 35 +template <class A > + A createA( void ); + +// enumeration begins on line 38 and ends on line 43 +enum { + one, // enumerator begins and ends on line 39 + two, // enumerator begins and ends on line 40 + three // enumerator begins on line 41, ends on line 42 + = 4 };
\ No newline at end of file diff --git a/core/org.eclipse.cdt.core.tests/resources/search/classDecl.cpp b/core/org.eclipse.cdt.core.tests/resources/search/classDecl.cpp index f2fa14f0168..94a7173c70e 100644 --- a/core/org.eclipse.cdt.core.tests/resources/search/classDecl.cpp +++ b/core/org.eclipse.cdt.core.tests/resources/search/classDecl.cpp @@ -1,102 +1,102 @@ -#include "include.h"
-
-#define FOO bar
-
-class Heal{};
-
-class A {
- A() {}
- ~A(){}
- class B {
- void f( A );
- void f( A & );
- void f( A* );
- void f( int &, const char [], A ** );
- };
-};
-
-namespace NS {
- namespace NS2{
- struct a{};
- }
- class B: public A {
- public:
- struct AA {};
- enum e {
- One,
- Two,
- Three
- };
-
- void f(){
- using namespace NS2;
- a aStruct;
- }
-
-
-
- AA anotherStruct;
- };
- union u{ } ;
-}
-
-namespace NS3{
- class C : public NS::B {
- e eE = One;
- };
-}
-
-A::B b1;
-
-typedef NS::B NS_B;
-NS_B b2;
-
-union u{
-};
-
-class AClassForFoo {};
-
-AClassForFoo foo( AClassForFoo ){
- AClassForFoo b;
- return b;
-}
-
-Head * Head::operator *= ( int index ){
- return array[ index ];
-}
-
-Head * Head::operator += ( int index ){
- return array[ index ];
-}
-
-extern int externalInt;
-extern int externalIntWithInitializer = 2;
-extern "C" int externCInt;
-extern "C" int externCIntWithInitializer = 3;
-
-void forwardFunction() { }
-void normalFunction() { }
-
-void DeclsAndDefns::forwardMethod(){ }
-
-int DeclsAndDefns::staticField = 5;
-
-
-namespace bug68235{
- struct xTag {
- int x;
- };
- typedef xTag xType;
-
- typedef struct yTag {
- int x;
- } yType;
-
- class C1{
- public:
- xType x;
- yType y;
- C1();
- ~C1();
- };
+#include "include.h" + +#define FOO bar + +class Heal{}; + +class A { + A() {} + ~A(){} + class B { + void f( A ); + void f( A & ); + void f( A* ); + void f( int &, const char [], A ** ); + }; +}; + +namespace NS { + namespace NS2{ + struct a{}; + } + class B: public A { + public: + struct AA {}; + enum e { + One, + Two, + Three + }; + + void f(){ + using namespace NS2; + a aStruct; + } + + + + AA anotherStruct; + }; + union u{ } ; +} + +namespace NS3{ + class C : public NS::B { + e eE = One; + }; +} + +A::B b1; + +typedef NS::B NS_B; +NS_B b2; + +union u{ +}; + +class AClassForFoo {}; + +AClassForFoo foo( AClassForFoo ){ + AClassForFoo b; + return b; +} + +Head * Head::operator *= ( int index ){ + return array[ index ]; +} + +Head * Head::operator += ( int index ){ + return array[ index ]; +} + +extern int externalInt; +extern int externalIntWithInitializer = 2; +extern "C" int externCInt; +extern "C" int externCIntWithInitializer = 3; + +void forwardFunction() { } +void normalFunction() { } + +void DeclsAndDefns::forwardMethod(){ } + +int DeclsAndDefns::staticField = 5; + + +namespace bug68235{ + struct xTag { + int x; + }; + typedef xTag xType; + + typedef struct yTag { + int x; + } yType; + + class C1{ + public: + xType x; + yType y; + C1(); + ~C1(); + }; }
\ No newline at end of file diff --git a/core/org.eclipse.cdt.core.tests/resources/search/include.h b/core/org.eclipse.cdt.core.tests/resources/search/include.h index f9c3d75956e..bb0b00ad594 100644 --- a/core/org.eclipse.cdt.core.tests/resources/search/include.h +++ b/core/org.eclipse.cdt.core.tests/resources/search/include.h @@ -1,36 +1,36 @@ -#ifndef INCLUDE_H
-#define INCLUDE_H
-
-class Head {
- Head ** array;
-
- Head * operator *= ( int index );
- Head * operator * ( int index ){ return array[ index ]; }
- Head * operator += ( int index );
-
- operator const short & ();
- operator short ();
- operator short int ();
-
-};
-
-class DeclsAndDefns{
- static int staticField;
- int nonStaticField;
-
- void forwardMethod();
- void inlineMethod() {}
-};
-
-void forwardFunction();
-
-
-class Direction{
- void turn();
- void turn(int);
- void turnAgain(void);
-};
-class Right : public Direction {
- void turn() { }
-};
+#ifndef INCLUDE_H +#define INCLUDE_H + +class Head { + Head ** array; + + Head * operator *= ( int index ); + Head * operator * ( int index ){ return array[ index ]; } + Head * operator += ( int index ); + + operator const short & (); + operator short (); + operator short int (); + +}; + +class DeclsAndDefns{ + static int staticField; + int nonStaticField; + + void forwardMethod(); + void inlineMethod() {} +}; + +void forwardFunction(); + + +class Direction{ + void turn(); + void turn(int); + void turnAgain(void); +}; +class Right : public Direction { + void turn() { } +}; #endif
\ No newline at end of file diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/CModelMock.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/CModelMock.java index db644fd1d62..8483e7d1163 100644 --- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/CModelMock.java +++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/CModelMock.java @@ -1,496 +1,496 @@ -/*******************************************************************************
- * Copyright (c) 2010, 2012 Andrew Gvozdev 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:
- * Andrew Gvozdev - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.core.testplugin;
-
-import java.util.Map;
-
-import org.eclipse.cdt.core.cdtvariables.ICdtVariablesContributor;
-import org.eclipse.cdt.core.settings.model.CConfigurationStatus;
-import org.eclipse.cdt.core.settings.model.ICBuildSetting;
-import org.eclipse.cdt.core.settings.model.ICConfigExtensionReference;
-import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
-import org.eclipse.cdt.core.settings.model.ICExternalSetting;
-import org.eclipse.cdt.core.settings.model.ICFileDescription;
-import org.eclipse.cdt.core.settings.model.ICFolderDescription;
-import org.eclipse.cdt.core.settings.model.ICLanguageSetting;
-import org.eclipse.cdt.core.settings.model.ICProjectDescription;
-import org.eclipse.cdt.core.settings.model.ICResourceDescription;
-import org.eclipse.cdt.core.settings.model.ICSettingContainer;
-import org.eclipse.cdt.core.settings.model.ICSettingEntry;
-import org.eclipse.cdt.core.settings.model.ICSettingObject;
-import org.eclipse.cdt.core.settings.model.ICSourceEntry;
-import org.eclipse.cdt.core.settings.model.ICStorageElement;
-import org.eclipse.cdt.core.settings.model.ICTargetPlatformSetting;
-import org.eclipse.cdt.core.settings.model.WriteAccessException;
-import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.QualifiedName;
-
-/**
- * Collection of mock classes for testing
- */
-public class CModelMock {
- /**
- * Dummy implementation of ICProjectDescription for testing.
- * Feel free to override the methods you are interested to mock.
- */
- public static class DummyCProjectDescription implements ICProjectDescription {
-
- @Override
- public ICSettingObject[] getChildSettings() {
- return null;
- }
-
- @Override
- public String getId() {
- return null;
- }
-
- @Override
- public String getName() {
- return null;
- }
-
- @Override
- public int getType() {
- return 0;
- }
-
- @Override
- public boolean isValid() {
- return false;
- }
-
- @Override
- public ICConfigurationDescription getConfiguration() {
- return null;
- }
-
- @Override
- public ICSettingContainer getParent() {
- return null;
- }
-
- @Override
- public boolean isReadOnly() {
- return false;
- }
-
- @Override
- public ICStorageElement getStorage(String id, boolean create)
- throws CoreException {
- return null;
- }
-
- @Override
- public void removeStorage(String id) throws CoreException {
- }
-
- @Override
- public ICStorageElement importStorage(String id, ICStorageElement el)
- throws UnsupportedOperationException, CoreException {
- return null;
- }
-
- @Override
- public void setReadOnly(boolean readOnly, boolean keepModify) {
- }
-
- @Override
- public int getConfigurationRelations() {
- return 0;
- }
-
- @Override
- public void setConfigurationRelations(int status) {
- }
-
- @Override
- public void useDefaultConfigurationRelations() {
- }
-
- @Override
- public boolean isDefaultConfigurationRelations() {
- return false;
- }
-
- @Override
- public ICConfigurationDescription[] getConfigurations() {
- return null;
- }
-
- @Override
- public ICConfigurationDescription getActiveConfiguration() {
- return null;
- }
-
- @Override
- public void setActiveConfiguration(ICConfigurationDescription cfg)
- throws WriteAccessException {
- }
-
- @Override
- public ICConfigurationDescription createConfiguration(String id,
- String name, ICConfigurationDescription base)
- throws CoreException, WriteAccessException {
- return null;
- }
-
- @Override
- public ICConfigurationDescription createConfiguration(
- String buildSystemId, CConfigurationData data)
- throws CoreException, WriteAccessException {
- return null;
- }
-
- @Override
- public ICConfigurationDescription getConfigurationByName(String name) {
- return null;
- }
-
- @Override
- public ICConfigurationDescription getConfigurationById(String id) {
- return null;
- }
-
- @Override
- public void removeConfiguration(String name)
- throws WriteAccessException {
- }
-
- @Override
- public void removeConfiguration(ICConfigurationDescription cfg)
- throws WriteAccessException {
- }
-
- @Override
- public IProject getProject() {
- return null;
- }
-
- @Override
- public boolean isModified() {
- return false;
- }
-
- @Override
- public Object getSessionProperty(QualifiedName name) {
- return null;
- }
-
- @Override
- public void setSessionProperty(QualifiedName name, Object value) {
-
- }
-
- @Override
- public ICConfigurationDescription getDefaultSettingConfiguration() {
- return null;
- }
-
- @Override
- public void setDefaultSettingConfiguration(
- ICConfigurationDescription cfg) {
- }
-
- @Override
- public boolean isCdtProjectCreating() {
- return false;
- }
-
- @Override
- public void setCdtProjectCreated() {
- }
-
- }
-
- /**
- * Dummy implementation of ICConfigurationDescription for testing.
- * Feel free to override the methods you are interested to mock.
- */
- public static class DummyCConfigurationDescription implements ICConfigurationDescription {
- private String id;
- private ICProjectDescription projectDescription;
-
- public DummyCConfigurationDescription(String id) {
- this.id = id;
- this.projectDescription = new DummyCProjectDescription();
- }
-
- @Override
- public ICSettingObject[] getChildSettings() {
- return null;
- }
-
- @Override
- public String getId() {
- return id;
- }
-
- @Override
- public String getName() {
- return null;
- }
-
- @Override
- public int getType() {
- return 0;
- }
-
- @Override
- public boolean isValid() {
- return false;
- }
-
- @Override
- public ICConfigurationDescription getConfiguration() {
- return null;
- }
-
- @Override
- public ICSettingContainer getParent() {
- return null;
- }
-
- @Override
- public boolean isReadOnly() {
- return false;
- }
-
- @Override
- public ICStorageElement getStorage(String id, boolean create)
- throws CoreException {
- return null;
- }
-
- @Override
- public void removeStorage(String id) throws CoreException {
- }
-
- @Override
- public ICStorageElement importStorage(String id, ICStorageElement el)
- throws UnsupportedOperationException, CoreException {
- return null;
- }
-
- @Override
- public void setReadOnly(boolean readOnly, boolean keepModify) {
- }
-
- @Override
- public boolean isActive() {
- return false;
- }
-
- @Override
- public String getDescription() {
- return null;
- }
-
- @Override
- public void setDescription(String des) throws WriteAccessException {
- }
-
- @Override
- public ICProjectDescription getProjectDescription() {
- return projectDescription;
- }
-
- @Override
- public ICFolderDescription getRootFolderDescription() {
- return null;
- }
-
- @Override
- public ICFolderDescription[] getFolderDescriptions() {
- return null;
- }
-
- @Override
- public ICFileDescription[] getFileDescriptions() {
- return null;
- }
-
- @Override
- public ICResourceDescription[] getResourceDescriptions() {
- return null;
- }
-
- @Override
- public ICResourceDescription getResourceDescription(IPath path,
- boolean exactPath) {
- return null;
- }
-
- @Override
- public void removeResourceDescription(ICResourceDescription des)
- throws CoreException, WriteAccessException {
- }
-
- @Override
- public ICFileDescription createFileDescription(IPath path,
- ICResourceDescription base) throws CoreException,
- WriteAccessException {
- return null;
- }
-
- @Override
- public ICFolderDescription createFolderDescription(IPath path,
- ICFolderDescription base) throws CoreException,
- WriteAccessException {
- return null;
- }
-
- @Override
- public String getBuildSystemId() {
- return null;
- }
-
- @Override
- public CConfigurationData getConfigurationData() {
- return null;
- }
-
- @Override
- public void setActive() throws WriteAccessException {
- }
-
- @Override
- public void setConfigurationData(String buildSystemId, CConfigurationData data) throws WriteAccessException {
- }
-
- @Override
- public boolean isModified() {
- return false;
- }
-
- @Override
- public ICTargetPlatformSetting getTargetPlatformSetting() {
- return null;
- }
-
- @Override
- public ICSourceEntry[] getSourceEntries() {
- return null;
- }
-
- @Override
- public ICSourceEntry[] getResolvedSourceEntries() {
- return null;
- }
-
- @Override
- public void setSourceEntries(ICSourceEntry[] entries) throws CoreException, WriteAccessException {
- }
-
- @Override
- public Map<String, String> getReferenceInfo() {
- return null;
- }
-
- @Override
- public void setReferenceInfo(Map<String, String> refs) throws WriteAccessException {
- }
-
- @Override
- public ICExternalSetting[] getExternalSettings() {
- return null;
- }
-
- @Override
- public ICExternalSetting createExternalSetting(String[] languageIDs,
- String[] contentTypeIds, String[] extensions,
- ICSettingEntry[] entries) throws WriteAccessException {
- return null;
- }
-
- @Override
- public void removeExternalSetting(ICExternalSetting setting) throws WriteAccessException {
- }
-
- @Override
- public void removeExternalSettings() throws WriteAccessException {
- }
-
- @Override
- public ICBuildSetting getBuildSetting() {
- return null;
- }
-
- @Override
- public ICdtVariablesContributor getBuildVariablesContributor() {
- return null;
- }
-
- @Override
- public Object getSessionProperty(QualifiedName name) {
- return null;
- }
-
- @Override
- public void setSessionProperty(QualifiedName name, Object value) {
- }
-
- @Override
- public void setName(String name) throws WriteAccessException {
- }
-
- @Override
- public ICConfigExtensionReference[] get(String extensionPointID) {
- return null;
- }
-
- @Override
- public ICConfigExtensionReference create(String extensionPoint, String extension) throws CoreException {
- return null;
- }
-
- @Override
- public void remove(ICConfigExtensionReference ext) throws CoreException {
- }
-
- @Override
- public void remove(String extensionPoint) throws CoreException {
- }
-
- @Override
- public boolean isPreferenceConfiguration() {
- return false;
- }
-
- @Override
- public ICLanguageSetting getLanguageSettingForFile(IPath path, boolean ignoreExludeStatus) {
- return null;
- }
-
- @Override
- public void setExternalSettingsProviderIds(String[] ids) {
- }
-
- @Override
- public String[] getExternalSettingsProviderIds() {
- return null;
- }
-
- @Override
- public void updateExternalSettingsProviders(String[] ids) throws WriteAccessException {
- }
-
- @Override
- public CConfigurationStatus getConfigurationStatus() {
- return null;
- }
-
- }
-}
+/******************************************************************************* + * Copyright (c) 2010, 2012 Andrew Gvozdev 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: + * Andrew Gvozdev - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.cdt.core.testplugin; + +import java.util.Map; + +import org.eclipse.cdt.core.cdtvariables.ICdtVariablesContributor; +import org.eclipse.cdt.core.settings.model.CConfigurationStatus; +import org.eclipse.cdt.core.settings.model.ICBuildSetting; +import org.eclipse.cdt.core.settings.model.ICConfigExtensionReference; +import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; +import org.eclipse.cdt.core.settings.model.ICExternalSetting; +import org.eclipse.cdt.core.settings.model.ICFileDescription; +import org.eclipse.cdt.core.settings.model.ICFolderDescription; +import org.eclipse.cdt.core.settings.model.ICLanguageSetting; +import org.eclipse.cdt.core.settings.model.ICProjectDescription; +import org.eclipse.cdt.core.settings.model.ICResourceDescription; +import org.eclipse.cdt.core.settings.model.ICSettingContainer; +import org.eclipse.cdt.core.settings.model.ICSettingEntry; +import org.eclipse.cdt.core.settings.model.ICSettingObject; +import org.eclipse.cdt.core.settings.model.ICSourceEntry; +import org.eclipse.cdt.core.settings.model.ICStorageElement; +import org.eclipse.cdt.core.settings.model.ICTargetPlatformSetting; +import org.eclipse.cdt.core.settings.model.WriteAccessException; +import org.eclipse.cdt.core.settings.model.extension.CConfigurationData; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.QualifiedName; + +/** + * Collection of mock classes for testing + */ +public class CModelMock { + /** + * Dummy implementation of ICProjectDescription for testing. + * Feel free to override the methods you are interested to mock. + */ + public static class DummyCProjectDescription implements ICProjectDescription { + + @Override + public ICSettingObject[] getChildSettings() { + return null; + } + + @Override + public String getId() { + return null; + } + + @Override + public String getName() { + return null; + } + + @Override + public int getType() { + return 0; + } + + @Override + public boolean isValid() { + return false; + } + + @Override + public ICConfigurationDescription getConfiguration() { + return null; + } + + @Override + public ICSettingContainer getParent() { + return null; + } + + @Override + public boolean isReadOnly() { + return false; + } + + @Override + public ICStorageElement getStorage(String id, boolean create) + throws CoreException { + return null; + } + + @Override + public void removeStorage(String id) throws CoreException { + } + + @Override + public ICStorageElement importStorage(String id, ICStorageElement el) + throws UnsupportedOperationException, CoreException { + return null; + } + + @Override + public void setReadOnly(boolean readOnly, boolean keepModify) { + } + + @Override + public int getConfigurationRelations() { + return 0; + } + + @Override + public void setConfigurationRelations(int status) { + } + + @Override + public void useDefaultConfigurationRelations() { + } + + @Override + public boolean isDefaultConfigurationRelations() { + return false; + } + + @Override + public ICConfigurationDescription[] getConfigurations() { + return null; + } + + @Override + public ICConfigurationDescription getActiveConfiguration() { + return null; + } + + @Override + public void setActiveConfiguration(ICConfigurationDescription cfg) + throws WriteAccessException { + } + + @Override + public ICConfigurationDescription createConfiguration(String id, + String name, ICConfigurationDescription base) + throws CoreException, WriteAccessException { + return null; + } + + @Override + public ICConfigurationDescription createConfiguration( + String buildSystemId, CConfigurationData data) + throws CoreException, WriteAccessException { + return null; + } + + @Override + public ICConfigurationDescription getConfigurationByName(String name) { + return null; + } + + @Override + public ICConfigurationDescription getConfigurationById(String id) { + return null; + } + + @Override + public void removeConfiguration(String name) + throws WriteAccessException { + } + + @Override + public void removeConfiguration(ICConfigurationDescription cfg) + throws WriteAccessException { + } + + @Override + public IProject getProject() { + return null; + } + + @Override + public boolean isModified() { + return false; + } + + @Override + public Object getSessionProperty(QualifiedName name) { + return null; + } + + @Override + public void setSessionProperty(QualifiedName name, Object value) { + + } + + @Override + public ICConfigurationDescription getDefaultSettingConfiguration() { + return null; + } + + @Override + public void setDefaultSettingConfiguration( + ICConfigurationDescription cfg) { + } + + @Override + public boolean isCdtProjectCreating() { + return false; + } + + @Override + public void setCdtProjectCreated() { + } + + } + + /** + * Dummy implementation of ICConfigurationDescription for testing. + * Feel free to override the methods you are interested to mock. + */ + public static class DummyCConfigurationDescription implements ICConfigurationDescription { + private String id; + private ICProjectDescription projectDescription; + + public DummyCConfigurationDescription(String id) { + this.id = id; + this.projectDescription = new DummyCProjectDescription(); + } + + @Override + public ICSettingObject[] getChildSettings() { + return null; + } + + @Override + public String getId() { + return id; + } + + @Override + public String getName() { + return null; + } + + @Override + public int getType() { + return 0; + } + + @Override + public boolean isValid() { + return false; + } + + @Override + public ICConfigurationDescription getConfiguration() { + return null; + } + + @Override + public ICSettingContainer getParent() { + return null; + } + + @Override + public boolean isReadOnly() { + return false; + } + + @Override + public ICStorageElement getStorage(String id, boolean create) + throws CoreException { + return null; + } + + @Override + public void removeStorage(String id) throws CoreException { + } + + @Override + public ICStorageElement importStorage(String id, ICStorageElement el) + throws UnsupportedOperationException, CoreException { + return null; + } + + @Override + public void setReadOnly(boolean readOnly, boolean keepModify) { + } + + @Override + public boolean isActive() { + return false; + } + + @Override + public String getDescription() { + return null; + } + + @Override + public void setDescription(String des) throws WriteAccessException { + } + + @Override + public ICProjectDescription getProjectDescription() { + return projectDescription; + } + + @Override + public ICFolderDescription getRootFolderDescription() { + return null; + } + + @Override + public ICFolderDescription[] getFolderDescriptions() { + return null; + } + + @Override + public ICFileDescription[] getFileDescriptions() { + return null; + } + + @Override + public ICResourceDescription[] getResourceDescriptions() { + return null; + } + + @Override + public ICResourceDescription getResourceDescription(IPath path, + boolean exactPath) { + return null; + } + + @Override + public void removeResourceDescription(ICResourceDescription des) + throws CoreException, WriteAccessException { + } + + @Override + public ICFileDescription createFileDescription(IPath path, + ICResourceDescription base) throws CoreException, + WriteAccessException { + return null; + } + + @Override + public ICFolderDescription createFolderDescription(IPath path, + ICFolderDescription base) throws CoreException, + WriteAccessException { + return null; + } + + @Override + public String getBuildSystemId() { + return null; + } + + @Override + public CConfigurationData getConfigurationData() { + return null; + } + + @Override + public void setActive() throws WriteAccessException { + } + + @Override + public void setConfigurationData(String buildSystemId, CConfigurationData data) throws WriteAccessException { + } + + @Override + public boolean isModified() { + return false; + } + + @Override + public ICTargetPlatformSetting getTargetPlatformSetting() { + return null; + } + + @Override + public ICSourceEntry[] getSourceEntries() { + return null; + } + + @Override + public ICSourceEntry[] getResolvedSourceEntries() { + return null; + } + + @Override + public void setSourceEntries(ICSourceEntry[] entries) throws CoreException, WriteAccessException { + } + + @Override + public Map<String, String> getReferenceInfo() { + return null; + } + + @Override + public void setReferenceInfo(Map<String, String> refs) throws WriteAccessException { + } + + @Override + public ICExternalSetting[] getExternalSettings() { + return null; + } + + @Override + public ICExternalSetting createExternalSetting(String[] languageIDs, + String[] contentTypeIds, String[] extensions, + ICSettingEntry[] entries) throws WriteAccessException { + return null; + } + + @Override + public void removeExternalSetting(ICExternalSetting setting) throws WriteAccessException { + } + + @Override + public void removeExternalSettings() throws WriteAccessException { + } + + @Override + public ICBuildSetting getBuildSetting() { + return null; + } + + @Override + public ICdtVariablesContributor getBuildVariablesContributor() { + return null; + } + + @Override + public Object getSessionProperty(QualifiedName name) { + return null; + } + + @Override + public void setSessionProperty(QualifiedName name, Object value) { + } + + @Override + public void setName(String name) throws WriteAccessException { + } + + @Override + public ICConfigExtensionReference[] get(String extensionPointID) { + return null; + } + + @Override + public ICConfigExtensionReference create(String extensionPoint, String extension) throws CoreException { + return null; + } + + @Override + public void remove(ICConfigExtensionReference ext) throws CoreException { + } + + @Override + public void remove(String extensionPoint) throws CoreException { + } + + @Override + public boolean isPreferenceConfiguration() { + return false; + } + + @Override + public ICLanguageSetting getLanguageSettingForFile(IPath path, boolean ignoreExludeStatus) { + return null; + } + + @Override + public void setExternalSettingsProviderIds(String[] ids) { + } + + @Override + public String[] getExternalSettingsProviderIds() { + return null; + } + + @Override + public void updateExternalSettingsProviders(String[] ids) throws WriteAccessException { + } + + @Override + public CConfigurationStatus getConfigurationStatus() { + return null; + } + + } +} diff --git a/core/org.eclipse.cdt.core.win32.x86/.project b/core/org.eclipse.cdt.core.win32.x86/.project index 29368923c4c..35ed365d43b 100644 --- a/core/org.eclipse.cdt.core.win32.x86/.project +++ b/core/org.eclipse.cdt.core.win32.x86/.project @@ -1,22 +1,22 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.cdt.core.win32.x86</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>
+<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.cdt.core.win32.x86</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.win32.x86/about.html b/core/org.eclipse.cdt.core.win32.x86/about.html index 5eba4faba08..d7c511887d6 100644 --- a/core/org.eclipse.cdt.core.win32.x86/about.html +++ b/core/org.eclipse.cdt.core.win32.x86/about.html @@ -1,24 +1,24 @@ -<!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>June 22, 2007</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 1.0 ("EPL"). A copy of the EPL is available
-at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</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="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
-
+<!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>June 22, 2007</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 1.0 ("EPL"). A copy of the EPL is available +at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</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="http://www.eclipse.org/">http://www.eclipse.org</a>.</p> + </body></html>
\ No newline at end of file diff --git a/core/org.eclipse.cdt.core.win32.x86/build.properties b/core/org.eclipse.cdt.core.win32.x86/build.properties index 437fccbc0c7..7432ecbfa61 100644 --- a/core/org.eclipse.cdt.core.win32.x86/build.properties +++ b/core/org.eclipse.cdt.core.win32.x86/build.properties @@ -1,15 +1,15 @@ -###############################################################################
-# Copyright (c) 2011 Marc-Andre Laperle 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:
-# Marc-Andre Laperle - initial API and implementation
-###############################################################################
-bin.includes = META-INF/,\
- os/,\
- about.html,\
- plugin.properties
-src.includes = about.html
+############################################################################### +# Copyright (c) 2011 Marc-Andre Laperle 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: +# Marc-Andre Laperle - initial API and implementation +############################################################################### +bin.includes = META-INF/,\ + os/,\ + about.html,\ + plugin.properties +src.includes = about.html diff --git a/core/org.eclipse.cdt.core.win32.x86_64/.project b/core/org.eclipse.cdt.core.win32.x86_64/.project index 11d5a0fe822..f3a99b7c96b 100644 --- a/core/org.eclipse.cdt.core.win32.x86_64/.project +++ b/core/org.eclipse.cdt.core.win32.x86_64/.project @@ -1,22 +1,22 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.cdt.core.win32.x86_64</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>
+<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.cdt.core.win32.x86_64</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.win32.x86_64/about.html b/core/org.eclipse.cdt.core.win32.x86_64/about.html index 5eba4faba08..d7c511887d6 100644 --- a/core/org.eclipse.cdt.core.win32.x86_64/about.html +++ b/core/org.eclipse.cdt.core.win32.x86_64/about.html @@ -1,24 +1,24 @@ -<!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>June 22, 2007</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 1.0 ("EPL"). A copy of the EPL is available
-at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</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="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
-
+<!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>June 22, 2007</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 1.0 ("EPL"). A copy of the EPL is available +at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</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="http://www.eclipse.org/">http://www.eclipse.org</a>.</p> + </body></html>
\ No newline at end of file diff --git a/core/org.eclipse.cdt.core.win32.x86_64/build.properties b/core/org.eclipse.cdt.core.win32.x86_64/build.properties index 437fccbc0c7..7432ecbfa61 100644 --- a/core/org.eclipse.cdt.core.win32.x86_64/build.properties +++ b/core/org.eclipse.cdt.core.win32.x86_64/build.properties @@ -1,15 +1,15 @@ -###############################################################################
-# Copyright (c) 2011 Marc-Andre Laperle 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:
-# Marc-Andre Laperle - initial API and implementation
-###############################################################################
-bin.includes = META-INF/,\
- os/,\
- about.html,\
- plugin.properties
-src.includes = about.html
+############################################################################### +# Copyright (c) 2011 Marc-Andre Laperle 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: +# Marc-Andre Laperle - initial API and implementation +############################################################################### +bin.includes = META-INF/,\ + os/,\ + about.html,\ + plugin.properties +src.includes = about.html 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 index bec950a18d2..5fe1804cc99 100644 --- a/core/org.eclipse.cdt.core.win32/library/Makefile_x86_64.mk +++ b/core/org.eclipse.cdt.core.win32/library/Makefile_x86_64.mk @@ -1,73 +1,73 @@ -#*******************************************************************************
-# Copyright (c) 2011 Marc-Andre Laperle
-# 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:
-# 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
-
-DLL_WINREG = winreg.dll
-OBJS_WINREG=winreg/winreg.obj
-
-EXE_STARTER = starter.exe
-OBJS_STARTER=starter/starter.obj
-
-EXE_LISTTASKS = listtasks.exe
-OBJS_LISTTASKS=listtasks/listtasks.obj listtasks/StdAfx.obj
-
-.c.obj:
- cl /c $(CFLAGS_UNICODE) $*.c /Fo$@
-
-.cpp.obj:
- cl /c $(CFLAGS_UNICODE) $*.cpp /Fo$@
-
-#TODO: Use unicode for listtasks, see bug 353460
-listtasks/listtasks.obj:
- cl /c $(CFLAGS) $*.cpp /Fo$@
-
-spawner: $(OBJS_SPAWNER)
- link /dll /nologo /out:$(DLL_SPAWNER) $(OBJS_SPAWNER) User32.lib
-
-winreg: $(OBJS_WINREG)
- link /dll /nologo /out:$(DLL_WINREG) $(OBJS_WINREG) Advapi32.lib
-
-starter: $(OBJS_STARTER)
- link /nologo /out:$(EXE_STARTER) $(OBJS_STARTER) Psapi.Lib Shell32.lib
-
-listtasks: $(OBJS_LISTTASKS)
- link /nologo /out:$(EXE_LISTTASKS) $(OBJS_LISTTASKS) Psapi.Lib
-
-all: spawner winreg starter listtasks
-
-clean:
- del *.obj *.lib *.exp *.exe *.dll winreg\*.obj starter\*.obj listtasks\*.obj
-
-rebuild: clean all
-
-install: all
- copy *.dll $(INSTALL_DIR)
- copy *.exe $(INSTALL_DIR)
-
-uninstall:
- del $(INSTALL_DIR)\*.dll $(INSTALL_DIR)\*.exe
+#******************************************************************************* +# Copyright (c) 2011 Marc-Andre Laperle +# 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: +# 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 + +DLL_WINREG = winreg.dll +OBJS_WINREG=winreg/winreg.obj + +EXE_STARTER = starter.exe +OBJS_STARTER=starter/starter.obj + +EXE_LISTTASKS = listtasks.exe +OBJS_LISTTASKS=listtasks/listtasks.obj listtasks/StdAfx.obj + +.c.obj: + cl /c $(CFLAGS_UNICODE) $*.c /Fo$@ + +.cpp.obj: + cl /c $(CFLAGS_UNICODE) $*.cpp /Fo$@ + +#TODO: Use unicode for listtasks, see bug 353460 +listtasks/listtasks.obj: + cl /c $(CFLAGS) $*.cpp /Fo$@ + +spawner: $(OBJS_SPAWNER) + link /dll /nologo /out:$(DLL_SPAWNER) $(OBJS_SPAWNER) User32.lib + +winreg: $(OBJS_WINREG) + link /dll /nologo /out:$(DLL_WINREG) $(OBJS_WINREG) Advapi32.lib + +starter: $(OBJS_STARTER) + link /nologo /out:$(EXE_STARTER) $(OBJS_STARTER) Psapi.Lib Shell32.lib + +listtasks: $(OBJS_LISTTASKS) + link /nologo /out:$(EXE_LISTTASKS) $(OBJS_LISTTASKS) Psapi.Lib + +all: spawner winreg starter listtasks + +clean: + del *.obj *.lib *.exp *.exe *.dll winreg\*.obj starter\*.obj listtasks\*.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 index fc59c9e51c4..ce6b1379478 100644 --- a/core/org.eclipse.cdt.core.win32/library/Readme64.txt +++ b/core/org.eclipse.cdt.core.win32/library/Readme64.txt @@ -1,23 +1,23 @@ -#*******************************************************************************
-# Copyright (c) 2011 Marc-Andre Laperle
-# 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:
-# 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.
+#******************************************************************************* +# Copyright (c) 2011 Marc-Andre Laperle +# 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: +# 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/build64.bat b/core/org.eclipse.cdt.core.win32/library/build64.bat index 8ec30651315..41201d443b6 100644 --- a/core/org.eclipse.cdt.core.win32/library/build64.bat +++ b/core/org.eclipse.cdt.core.win32/library/build64.bat @@ -1,12 +1,12 @@ -@rem ***************************************************************************
-@rem Copyright (c) 2011 Marc-Andre Laperle and others.
-@rem All rights reserved. This program and the accompanying materials
-@rem are made available under the terms of the Eclipse Public License v1.0
-@rem which accompanies this distribution, and is available at
-@rem http://www.eclipse.org/legal/epl-v10.html
-@rem
-@rem Contributors:
-@rem Marc-Andre Laperle - initial API and implementation
-@rem ***************************************************************************
-
+@rem *************************************************************************** +@rem Copyright (c) 2011 Marc-Andre Laperle and others. +@rem All rights reserved. This program and the accompanying materials +@rem are made available under the terms of the Eclipse Public License v1.0 +@rem which accompanies this distribution, and is available at +@rem http://www.eclipse.org/legal/epl-v10.html +@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/cdt-win32.sln b/core/org.eclipse.cdt.core.win32/library/cdt-win32.sln index 5367a43acb8..01d10abe31e 100644 --- a/core/org.eclipse.cdt.core.win32/library/cdt-win32.sln +++ b/core/org.eclipse.cdt.core.win32/library/cdt-win32.sln @@ -1,33 +1,33 @@ -
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 2013
-VisualStudioVersion = 12.0.31101.0
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "winreg", "winreg\winreg.vcxproj", "{4CA57EA3-42F2-4CC1-8E95-5C707A8E7363}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Mixed Platforms = Debug|Mixed Platforms
- Debug|Win32 = Debug|Win32
- Debug|x64 = Debug|x64
- Release|Mixed Platforms = Release|Mixed Platforms
- Release|Win32 = Release|Win32
- Release|x64 = Release|x64
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {4CA57EA3-42F2-4CC1-8E95-5C707A8E7363}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
- {4CA57EA3-42F2-4CC1-8E95-5C707A8E7363}.Debug|Mixed Platforms.Build.0 = Debug|Win32
- {4CA57EA3-42F2-4CC1-8E95-5C707A8E7363}.Debug|Win32.ActiveCfg = Debug|Win32
- {4CA57EA3-42F2-4CC1-8E95-5C707A8E7363}.Debug|Win32.Build.0 = Debug|Win32
- {4CA57EA3-42F2-4CC1-8E95-5C707A8E7363}.Debug|x64.ActiveCfg = Debug|Win32
- {4CA57EA3-42F2-4CC1-8E95-5C707A8E7363}.Release|Mixed Platforms.ActiveCfg = Release|Win32
- {4CA57EA3-42F2-4CC1-8E95-5C707A8E7363}.Release|Mixed Platforms.Build.0 = Release|Win32
- {4CA57EA3-42F2-4CC1-8E95-5C707A8E7363}.Release|Win32.ActiveCfg = Release|Win32
- {4CA57EA3-42F2-4CC1-8E95-5C707A8E7363}.Release|Win32.Build.0 = Release|Win32
- {4CA57EA3-42F2-4CC1-8E95-5C707A8E7363}.Release|x64.ActiveCfg = Release|x64
- {4CA57EA3-42F2-4CC1-8E95-5C707A8E7363}.Release|x64.Build.0 = Release|x64
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
+ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.31101.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "winreg", "winreg\winreg.vcxproj", "{4CA57EA3-42F2-4CC1-8E95-5C707A8E7363}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Mixed Platforms = Debug|Mixed Platforms + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Mixed Platforms = Release|Mixed Platforms + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4CA57EA3-42F2-4CC1-8E95-5C707A8E7363}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 + {4CA57EA3-42F2-4CC1-8E95-5C707A8E7363}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {4CA57EA3-42F2-4CC1-8E95-5C707A8E7363}.Debug|Win32.ActiveCfg = Debug|Win32 + {4CA57EA3-42F2-4CC1-8E95-5C707A8E7363}.Debug|Win32.Build.0 = Debug|Win32 + {4CA57EA3-42F2-4CC1-8E95-5C707A8E7363}.Debug|x64.ActiveCfg = Debug|Win32 + {4CA57EA3-42F2-4CC1-8E95-5C707A8E7363}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {4CA57EA3-42F2-4CC1-8E95-5C707A8E7363}.Release|Mixed Platforms.Build.0 = Release|Win32 + {4CA57EA3-42F2-4CC1-8E95-5C707A8E7363}.Release|Win32.ActiveCfg = Release|Win32 + {4CA57EA3-42F2-4CC1-8E95-5C707A8E7363}.Release|Win32.Build.0 = Release|Win32 + {4CA57EA3-42F2-4CC1-8E95-5C707A8E7363}.Release|x64.ActiveCfg = Release|x64 + {4CA57EA3-42F2-4CC1-8E95-5C707A8E7363}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/core/org.eclipse.cdt.core.win32/library/listtasks/StdAfx.cpp b/core/org.eclipse.cdt.core.win32/library/listtasks/StdAfx.cpp index ace4d4df66d..f231562921e 100644 --- a/core/org.eclipse.cdt.core.win32/library/listtasks/StdAfx.cpp +++ b/core/org.eclipse.cdt.core.win32/library/listtasks/StdAfx.cpp @@ -1,18 +1,18 @@ -/*******************************************************************************
- * Copyright (c) 2002 - 2005 QNX Software Systems 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:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-// stdafx.cpp : source file that includes just the standard includes
-// ProcList.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
+/******************************************************************************* + * Copyright (c) 2002 - 2005 QNX Software Systems 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: + * QNX Software Systems - initial API and implementation + *******************************************************************************/ +// stdafx.cpp : source file that includes just the standard includes +// ProcList.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/listtasks/StdAfx.h b/core/org.eclipse.cdt.core.win32/library/listtasks/StdAfx.h index 3eebdec8144..f51c2a6b60d 100644 --- a/core/org.eclipse.cdt.core.win32/library/listtasks/StdAfx.h +++ b/core/org.eclipse.cdt.core.win32/library/listtasks/StdAfx.h @@ -1,29 +1,29 @@ -/*******************************************************************************
- * Copyright (c) 2002 - 2005 QNX Software Systems 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:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-// 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__CB3B970F_AA1A_4B59_9F98_DDBEA28470AF__INCLUDED_)
-#define AFX_STDAFX_H__CB3B970F_AA1A_4B59_9F98_DDBEA28470AF__INCLUDED_
-
-#if _MSC_VER > 1000
-#pragma once
-#endif // _MSC_VER > 1000
-
-
-// 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__CB3B970F_AA1A_4B59_9F98_DDBEA28470AF__INCLUDED_)
+/******************************************************************************* + * Copyright (c) 2002 - 2005 QNX Software Systems 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: + * QNX Software Systems - initial API and implementation + *******************************************************************************/ +// 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__CB3B970F_AA1A_4B59_9F98_DDBEA28470AF__INCLUDED_) +#define AFX_STDAFX_H__CB3B970F_AA1A_4B59_9F98_DDBEA28470AF__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + + +// 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__CB3B970F_AA1A_4B59_9F98_DDBEA28470AF__INCLUDED_) diff --git a/core/org.eclipse.cdt.core.win32/library/listtasks/listtasks.cpp b/core/org.eclipse.cdt.core.win32/library/listtasks/listtasks.cpp index c6a626c26d7..bdfc126abb1 100644 --- a/core/org.eclipse.cdt.core.win32/library/listtasks/listtasks.cpp +++ b/core/org.eclipse.cdt.core.win32/library/listtasks/listtasks.cpp @@ -1,346 +1,346 @@ -/*******************************************************************************
- * Copyright (c) 2002, 2011 QNX Software Systems 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:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-// ProcList.cpp : Defines the entry point for the console application.
-//
-
-#include "stdafx.h"
-
-#include "listtasks.h"
-#include <tlhelp32.h>
-#include <vdmdbg.h>
-#include <iostream>
-#include <iomanip>
-
-using namespace std;
-
-typedef struct
-{
- DWORD dwPID ;
- PROCENUMPROC lpProc ;
- DWORD lParam ;
- BOOL bEnd ;
-} EnumInfoStruct ;
-
-BOOL WINAPI Enum16( DWORD dwThreadId, WORD hMod16, WORD hTask16,
- PSZ pszModName, PSZ pszFileName, LPARAM lpUserDefined ) ;
-
-BOOL CALLBACK OutProcInfo( DWORD pid, WORD, LPSTR procName, LPARAM ) ;
-
-int main(int argc, char* argv[])
-{
- EnumProcs(OutProcInfo, 0);
- return 0;
-}
-
-
-
-/*********************
-EnumProc.cpp
-*********************/
-
-// The EnumProcs function takes a pointer to a callback function
-// that will be called once per process in the system providing
-// process EXE filename and process ID.
-// Callback function definition:
-// BOOL CALLBACK Proc( DWORD dw, LPCSTR lpstr, LPARAM lParam ) ;
-//
-// lpProc -- Address of callback routine.
-//
-// lParam -- A user-defined LPARAM value to be passed to
-// the callback routine.
-BOOL WINAPI EnumProcs( PROCENUMPROC lpProc, LPARAM lParam )
-{
- OSVERSIONINFO osver ;
- HINSTANCE hInstLib ;
- HINSTANCE hInstLib2 ;
- HANDLE hSnapShot ;
- PROCESSENTRY32 procentry ;
- BOOL bFlag ;
- LPDWORD lpdwPIDs ;
- DWORD dwSize, dwSize2, dwIndex ;
- HMODULE hMod ;
- HANDLE hProcess ;
- char szFileName[ MAX_PATH ] ;
- EnumInfoStruct sInfo ;
-
- // ToolHelp Function Pointers.
- HANDLE (WINAPI *lpfCreateToolhelp32Snapshot)(DWORD,DWORD) ;
- BOOL (WINAPI *lpfProcess32First)(HANDLE,LPPROCESSENTRY32) ;
- BOOL (WINAPI *lpfProcess32Next)(HANDLE,LPPROCESSENTRY32) ;
-
- // PSAPI Function Pointers.
- BOOL (WINAPI *lpfEnumProcesses)( DWORD *, DWORD cb, DWORD * );
- BOOL (WINAPI *lpfEnumProcessModules)( HANDLE, HMODULE *,
- DWORD, LPDWORD );
- DWORD (WINAPI *lpfGetModuleFileNameEx)( HANDLE, HMODULE,
- LPTSTR, DWORD );
-
- // VDMDBG Function Pointers.
- INT (WINAPI *lpfVDMEnumTaskWOWEx)( DWORD,
- TASKENUMPROCEX fp, LPARAM );
-
-
- // Check to see if were running under Windows95 or
- // Windows NT.
- osver.dwOSVersionInfoSize = sizeof( osver ) ;
- if( !GetVersionEx( &osver ) )
- {
- return FALSE ;
- }
-
- // If Windows NT:
- if( osver.dwPlatformId == VER_PLATFORM_WIN32_NT )
- {
-
- // Load library and get the procedures explicitly. We do
- // this so that we don't have to worry about modules using
- // this code failing to load under Windows 95, because
- // it can't resolve references to the PSAPI.DLL.
- hInstLib = LoadLibraryA( "PSAPI.DLL" ) ;
- if( hInstLib == NULL )
- return FALSE ;
-
- SYSTEM_INFO systemInfo;
-
- GetSystemInfo(&systemInfo);
- bool isWin64 = systemInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64;
-
- if(!isWin64)
- {
- hInstLib2 = LoadLibraryA( "VDMDBG.DLL" ) ;
- if( hInstLib2 == NULL )
- return FALSE ;
- }
-
- // Get procedure addresses.
- lpfEnumProcesses = (BOOL(WINAPI *)(DWORD *,DWORD,DWORD*))
- GetProcAddress( hInstLib, "EnumProcesses" ) ;
- lpfEnumProcessModules = (BOOL(WINAPI *)(HANDLE, HMODULE *,
- DWORD, LPDWORD)) GetProcAddress( hInstLib,
- "EnumProcessModules" ) ;
- lpfGetModuleFileNameEx =(DWORD (WINAPI *)(HANDLE, HMODULE,
- LPTSTR, DWORD )) GetProcAddress( hInstLib,
- "GetModuleFileNameExA" ) ;
- if(!isWin64)
- {
- lpfVDMEnumTaskWOWEx =(INT(WINAPI *)( DWORD, TASKENUMPROCEX,
- LPARAM))GetProcAddress( hInstLib2, "VDMEnumTaskWOWEx" );
- }
- if( lpfEnumProcesses == NULL ||
- lpfEnumProcessModules == NULL ||
- lpfGetModuleFileNameEx == NULL ||
- (!isWin64 && lpfVDMEnumTaskWOWEx == NULL))
- {
- FreeLibrary( hInstLib ) ;
- if(!isWin64)
- {
- FreeLibrary( hInstLib2 ) ;
- }
- return FALSE ;
- }
-
- // Call the PSAPI function EnumProcesses to get all of the
- // ProcID's currently in the system.
- // NOTE: In the documentation, the third parameter of
- // EnumProcesses is named cbNeeded, which implies that you
- // can call the function once to find out how much space to
- // allocate for a buffer and again to fill the buffer.
- // This is not the case. The cbNeeded parameter returns
- // the number of PIDs returned, so if your buffer size is
- // zero cbNeeded returns zero.
- // NOTE: The "HeapAlloc" loop here ensures that we
- // actually allocate a buffer large enough for all the
- // PIDs in the system.
- dwSize2 = 256 * sizeof( DWORD ) ;
- lpdwPIDs = NULL ;
- do
- {
- if( lpdwPIDs )
- {
- HeapFree( GetProcessHeap(), 0, lpdwPIDs ) ;
- dwSize2 *= 2 ;
- }
- lpdwPIDs = (LPDWORD)HeapAlloc( GetProcessHeap(), 0, dwSize2 );
- if( lpdwPIDs == NULL )
- {
- FreeLibrary( hInstLib ) ;
- if(!isWin64)
- {
- FreeLibrary( hInstLib2 ) ;
- }
- return FALSE ;
- }
- if( !lpfEnumProcesses( lpdwPIDs, dwSize2, &dwSize ) )
- {
- HeapFree( GetProcessHeap(), 0, lpdwPIDs ) ;
- FreeLibrary( hInstLib ) ;
- if(!isWin64)
- {
- FreeLibrary( hInstLib2 ) ;
- }
- return FALSE ;
- }
- }while( dwSize == dwSize2 ) ;
-
- // How many ProcID's did we get?
- dwSize /= sizeof( DWORD ) ;
-
- // Loop through each ProcID.
- for( dwIndex = 0 ; dwIndex < dwSize ; dwIndex++ )
- {
- szFileName[0] = 0 ;
- // Open the process (if we can... security does not
- // permit every process in the system).
- hProcess = OpenProcess(
- PROCESS_QUERY_INFORMATION | PROCESS_VM_READ,
- FALSE, lpdwPIDs[ dwIndex ] ) ;
- if( hProcess != NULL )
- {
- // Here we call EnumProcessModules to get only the
- // first module in the process this is important,
- // because this will be the .EXE module for which we
- // will retrieve the full path name in a second.
- if( lpfEnumProcessModules( hProcess, &hMod,
- sizeof( hMod ), &dwSize2 ) )
- {
- // Get Full pathname:
- if( !lpfGetModuleFileNameEx( hProcess, hMod,
- szFileName, sizeof( szFileName ) ) )
- {
- szFileName[0] = 0 ;
- }
- }
- CloseHandle( hProcess ) ;
- }
- // Regardless of OpenProcess success or failure, we
- // still call the enum func with the ProcID.
- if(!lpProc( lpdwPIDs[dwIndex], 0, szFileName, lParam))
- break ;
-
- // Did we just bump into an NTVDM?
- if(!isWin64 && _stricmp( szFileName+(strlen(szFileName)-9),
- "NTVDM.EXE")==0)
- {
- // Fill in some info for the 16-bit enum proc.
- sInfo.dwPID = lpdwPIDs[dwIndex] ;
- sInfo.lpProc = lpProc ;
- sInfo.lParam = lParam ;
- sInfo.bEnd = FALSE ;
- // Enum the 16-bit stuff.
- lpfVDMEnumTaskWOWEx( lpdwPIDs[dwIndex],
- (TASKENUMPROCEX) Enum16,
- (LPARAM) &sInfo);
-
- // Did our main enum func say quit?
- if(sInfo.bEnd)
- break ;
- }
- }
-
- HeapFree( GetProcessHeap(), 0, lpdwPIDs ) ;
- if(!isWin64)
- {
- FreeLibrary( hInstLib2 ) ;
- }
-
- // If Windows 95:
- }else if( osver.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS )
- {
-
-
- hInstLib = LoadLibraryA( "Kernel32.DLL" ) ;
- if( hInstLib == NULL )
- return FALSE ;
-
- // Get procedure addresses.
- // We are linking to these functions of Kernel32
- // explicitly, because otherwise a module using
- // this code would fail to load under Windows NT,
- // which does not have the Toolhelp32
- // functions in the Kernel 32.
- lpfCreateToolhelp32Snapshot=
- (HANDLE(WINAPI *)(DWORD,DWORD))
- GetProcAddress( hInstLib,
- "CreateToolhelp32Snapshot" ) ;
- lpfProcess32First=
- (BOOL(WINAPI *)(HANDLE,LPPROCESSENTRY32))
- GetProcAddress( hInstLib, "Process32First" ) ;
- lpfProcess32Next=
- (BOOL(WINAPI *)(HANDLE,LPPROCESSENTRY32))
- GetProcAddress( hInstLib, "Process32Next" ) ;
- if( lpfProcess32Next == NULL ||
- lpfProcess32First == NULL ||
- lpfCreateToolhelp32Snapshot == NULL )
- {
- FreeLibrary( hInstLib ) ;
- return FALSE ;
- }
-
- // Get a handle to a Toolhelp snapshot of the systems
- // processes.
- hSnapShot = lpfCreateToolhelp32Snapshot(
- TH32CS_SNAPPROCESS, 0 ) ;
- if( hSnapShot == INVALID_HANDLE_VALUE )
- {
- FreeLibrary( hInstLib ) ;
- return FALSE ;
- }
-
- // Get the first process' information.
- procentry.dwSize = sizeof(PROCESSENTRY32) ;
- bFlag = lpfProcess32First( hSnapShot, &procentry ) ;
-
- // While there are processes, keep looping.
- while( bFlag )
- {
- // Call the enum func with the filename and ProcID.
- if(lpProc( procentry.th32ProcessID, 0,
- procentry.szExeFile, lParam ))
- {
- procentry.dwSize = sizeof(PROCESSENTRY32) ;
- bFlag = lpfProcess32Next( hSnapShot, &procentry );
- }else
- bFlag = FALSE ;
- }
-
-
- }else
- return FALSE ;
-
- // Free the library.
- FreeLibrary( hInstLib ) ;
-
- return TRUE ;
-}
-
-BOOL WINAPI Enum16( DWORD dwThreadId, WORD hMod16, WORD hTask16,
- PSZ pszModName, PSZ pszFileName, LPARAM lpUserDefined )
-{
- BOOL bRet ;
-
- EnumInfoStruct *psInfo = (EnumInfoStruct *)lpUserDefined ;
-
- bRet = psInfo->lpProc( psInfo->dwPID, hTask16, pszFileName,
- psInfo->lParam ) ;
-
- if(!bRet)
- {
- psInfo->bEnd = TRUE ;
- }
-
- return !bRet;
-}
-
-BOOL CALLBACK OutProcInfo( DWORD pid, WORD, LPSTR procName, LPARAM )
-{
- cout << setw(10) << pid << '\t' << procName << '\n';
- return TRUE;
-}
+/******************************************************************************* + * Copyright (c) 2002, 2011 QNX Software Systems 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: + * QNX Software Systems - initial API and implementation + *******************************************************************************/ +// ProcList.cpp : Defines the entry point for the console application. +// + +#include "stdafx.h" + +#include "listtasks.h" +#include <tlhelp32.h> +#include <vdmdbg.h> +#include <iostream> +#include <iomanip> + +using namespace std; + +typedef struct +{ + DWORD dwPID ; + PROCENUMPROC lpProc ; + DWORD lParam ; + BOOL bEnd ; +} EnumInfoStruct ; + +BOOL WINAPI Enum16( DWORD dwThreadId, WORD hMod16, WORD hTask16, + PSZ pszModName, PSZ pszFileName, LPARAM lpUserDefined ) ; + +BOOL CALLBACK OutProcInfo( DWORD pid, WORD, LPSTR procName, LPARAM ) ; + +int main(int argc, char* argv[]) +{ + EnumProcs(OutProcInfo, 0); + return 0; +} + + + +/********************* +EnumProc.cpp +*********************/ + +// The EnumProcs function takes a pointer to a callback function +// that will be called once per process in the system providing +// process EXE filename and process ID. +// Callback function definition: +// BOOL CALLBACK Proc( DWORD dw, LPCSTR lpstr, LPARAM lParam ) ; +// +// lpProc -- Address of callback routine. +// +// lParam -- A user-defined LPARAM value to be passed to +// the callback routine. +BOOL WINAPI EnumProcs( PROCENUMPROC lpProc, LPARAM lParam ) +{ + OSVERSIONINFO osver ; + HINSTANCE hInstLib ; + HINSTANCE hInstLib2 ; + HANDLE hSnapShot ; + PROCESSENTRY32 procentry ; + BOOL bFlag ; + LPDWORD lpdwPIDs ; + DWORD dwSize, dwSize2, dwIndex ; + HMODULE hMod ; + HANDLE hProcess ; + char szFileName[ MAX_PATH ] ; + EnumInfoStruct sInfo ; + + // ToolHelp Function Pointers. + HANDLE (WINAPI *lpfCreateToolhelp32Snapshot)(DWORD,DWORD) ; + BOOL (WINAPI *lpfProcess32First)(HANDLE,LPPROCESSENTRY32) ; + BOOL (WINAPI *lpfProcess32Next)(HANDLE,LPPROCESSENTRY32) ; + + // PSAPI Function Pointers. + BOOL (WINAPI *lpfEnumProcesses)( DWORD *, DWORD cb, DWORD * ); + BOOL (WINAPI *lpfEnumProcessModules)( HANDLE, HMODULE *, + DWORD, LPDWORD ); + DWORD (WINAPI *lpfGetModuleFileNameEx)( HANDLE, HMODULE, + LPTSTR, DWORD ); + + // VDMDBG Function Pointers. + INT (WINAPI *lpfVDMEnumTaskWOWEx)( DWORD, + TASKENUMPROCEX fp, LPARAM ); + + + // Check to see if were running under Windows95 or + // Windows NT. + osver.dwOSVersionInfoSize = sizeof( osver ) ; + if( !GetVersionEx( &osver ) ) + { + return FALSE ; + } + + // If Windows NT: + if( osver.dwPlatformId == VER_PLATFORM_WIN32_NT ) + { + + // Load library and get the procedures explicitly. We do + // this so that we don't have to worry about modules using + // this code failing to load under Windows 95, because + // it can't resolve references to the PSAPI.DLL. + hInstLib = LoadLibraryA( "PSAPI.DLL" ) ; + if( hInstLib == NULL ) + return FALSE ; + + SYSTEM_INFO systemInfo; + + GetSystemInfo(&systemInfo); + bool isWin64 = systemInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64; + + if(!isWin64) + { + hInstLib2 = LoadLibraryA( "VDMDBG.DLL" ) ; + if( hInstLib2 == NULL ) + return FALSE ; + } + + // Get procedure addresses. + lpfEnumProcesses = (BOOL(WINAPI *)(DWORD *,DWORD,DWORD*)) + GetProcAddress( hInstLib, "EnumProcesses" ) ; + lpfEnumProcessModules = (BOOL(WINAPI *)(HANDLE, HMODULE *, + DWORD, LPDWORD)) GetProcAddress( hInstLib, + "EnumProcessModules" ) ; + lpfGetModuleFileNameEx =(DWORD (WINAPI *)(HANDLE, HMODULE, + LPTSTR, DWORD )) GetProcAddress( hInstLib, + "GetModuleFileNameExA" ) ; + if(!isWin64) + { + lpfVDMEnumTaskWOWEx =(INT(WINAPI *)( DWORD, TASKENUMPROCEX, + LPARAM))GetProcAddress( hInstLib2, "VDMEnumTaskWOWEx" ); + } + if( lpfEnumProcesses == NULL || + lpfEnumProcessModules == NULL || + lpfGetModuleFileNameEx == NULL || + (!isWin64 && lpfVDMEnumTaskWOWEx == NULL)) + { + FreeLibrary( hInstLib ) ; + if(!isWin64) + { + FreeLibrary( hInstLib2 ) ; + } + return FALSE ; + } + + // Call the PSAPI function EnumProcesses to get all of the + // ProcID's currently in the system. + // NOTE: In the documentation, the third parameter of + // EnumProcesses is named cbNeeded, which implies that you + // can call the function once to find out how much space to + // allocate for a buffer and again to fill the buffer. + // This is not the case. The cbNeeded parameter returns + // the number of PIDs returned, so if your buffer size is + // zero cbNeeded returns zero. + // NOTE: The "HeapAlloc" loop here ensures that we + // actually allocate a buffer large enough for all the + // PIDs in the system. + dwSize2 = 256 * sizeof( DWORD ) ; + lpdwPIDs = NULL ; + do + { + if( lpdwPIDs ) + { + HeapFree( GetProcessHeap(), 0, lpdwPIDs ) ; + dwSize2 *= 2 ; + } + lpdwPIDs = (LPDWORD)HeapAlloc( GetProcessHeap(), 0, dwSize2 ); + if( lpdwPIDs == NULL ) + { + FreeLibrary( hInstLib ) ; + if(!isWin64) + { + FreeLibrary( hInstLib2 ) ; + } + return FALSE ; + } + if( !lpfEnumProcesses( lpdwPIDs, dwSize2, &dwSize ) ) + { + HeapFree( GetProcessHeap(), 0, lpdwPIDs ) ; + FreeLibrary( hInstLib ) ; + if(!isWin64) + { + FreeLibrary( hInstLib2 ) ; + } + return FALSE ; + } + }while( dwSize == dwSize2 ) ; + + // How many ProcID's did we get? + dwSize /= sizeof( DWORD ) ; + + // Loop through each ProcID. + for( dwIndex = 0 ; dwIndex < dwSize ; dwIndex++ ) + { + szFileName[0] = 0 ; + // Open the process (if we can... security does not + // permit every process in the system). + hProcess = OpenProcess( + PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, + FALSE, lpdwPIDs[ dwIndex ] ) ; + if( hProcess != NULL ) + { + // Here we call EnumProcessModules to get only the + // first module in the process this is important, + // because this will be the .EXE module for which we + // will retrieve the full path name in a second. + if( lpfEnumProcessModules( hProcess, &hMod, + sizeof( hMod ), &dwSize2 ) ) + { + // Get Full pathname: + if( !lpfGetModuleFileNameEx( hProcess, hMod, + szFileName, sizeof( szFileName ) ) ) + { + szFileName[0] = 0 ; + } + } + CloseHandle( hProcess ) ; + } + // Regardless of OpenProcess success or failure, we + // still call the enum func with the ProcID. + if(!lpProc( lpdwPIDs[dwIndex], 0, szFileName, lParam)) + break ; + + // Did we just bump into an NTVDM? + if(!isWin64 && _stricmp( szFileName+(strlen(szFileName)-9), + "NTVDM.EXE")==0) + { + // Fill in some info for the 16-bit enum proc. + sInfo.dwPID = lpdwPIDs[dwIndex] ; + sInfo.lpProc = lpProc ; + sInfo.lParam = lParam ; + sInfo.bEnd = FALSE ; + // Enum the 16-bit stuff. + lpfVDMEnumTaskWOWEx( lpdwPIDs[dwIndex], + (TASKENUMPROCEX) Enum16, + (LPARAM) &sInfo); + + // Did our main enum func say quit? + if(sInfo.bEnd) + break ; + } + } + + HeapFree( GetProcessHeap(), 0, lpdwPIDs ) ; + if(!isWin64) + { + FreeLibrary( hInstLib2 ) ; + } + + // If Windows 95: + }else if( osver.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS ) + { + + + hInstLib = LoadLibraryA( "Kernel32.DLL" ) ; + if( hInstLib == NULL ) + return FALSE ; + + // Get procedure addresses. + // We are linking to these functions of Kernel32 + // explicitly, because otherwise a module using + // this code would fail to load under Windows NT, + // which does not have the Toolhelp32 + // functions in the Kernel 32. + lpfCreateToolhelp32Snapshot= + (HANDLE(WINAPI *)(DWORD,DWORD)) + GetProcAddress( hInstLib, + "CreateToolhelp32Snapshot" ) ; + lpfProcess32First= + (BOOL(WINAPI *)(HANDLE,LPPROCESSENTRY32)) + GetProcAddress( hInstLib, "Process32First" ) ; + lpfProcess32Next= + (BOOL(WINAPI *)(HANDLE,LPPROCESSENTRY32)) + GetProcAddress( hInstLib, "Process32Next" ) ; + if( lpfProcess32Next == NULL || + lpfProcess32First == NULL || + lpfCreateToolhelp32Snapshot == NULL ) + { + FreeLibrary( hInstLib ) ; + return FALSE ; + } + + // Get a handle to a Toolhelp snapshot of the systems + // processes. + hSnapShot = lpfCreateToolhelp32Snapshot( + TH32CS_SNAPPROCESS, 0 ) ; + if( hSnapShot == INVALID_HANDLE_VALUE ) + { + FreeLibrary( hInstLib ) ; + return FALSE ; + } + + // Get the first process' information. + procentry.dwSize = sizeof(PROCESSENTRY32) ; + bFlag = lpfProcess32First( hSnapShot, &procentry ) ; + + // While there are processes, keep looping. + while( bFlag ) + { + // Call the enum func with the filename and ProcID. + if(lpProc( procentry.th32ProcessID, 0, + procentry.szExeFile, lParam )) + { + procentry.dwSize = sizeof(PROCESSENTRY32) ; + bFlag = lpfProcess32Next( hSnapShot, &procentry ); + }else + bFlag = FALSE ; + } + + + }else + return FALSE ; + + // Free the library. + FreeLibrary( hInstLib ) ; + + return TRUE ; +} + +BOOL WINAPI Enum16( DWORD dwThreadId, WORD hMod16, WORD hTask16, + PSZ pszModName, PSZ pszFileName, LPARAM lpUserDefined ) +{ + BOOL bRet ; + + EnumInfoStruct *psInfo = (EnumInfoStruct *)lpUserDefined ; + + bRet = psInfo->lpProc( psInfo->dwPID, hTask16, pszFileName, + psInfo->lParam ) ; + + if(!bRet) + { + psInfo->bEnd = TRUE ; + } + + return !bRet; +} + +BOOL CALLBACK OutProcInfo( DWORD pid, WORD, LPSTR procName, LPARAM ) +{ + cout << setw(10) << pid << '\t' << procName << '\n'; + return TRUE; +} diff --git a/core/org.eclipse.cdt.core.win32/library/listtasks/listtasks.dsp b/core/org.eclipse.cdt.core.win32/library/listtasks/listtasks.dsp index d14d3c49bc1..da100f1a4e5 100644 --- a/core/org.eclipse.cdt.core.win32/library/listtasks/listtasks.dsp +++ b/core/org.eclipse.cdt.core.win32/library/listtasks/listtasks.dsp @@ -1,117 +1,117 @@ -# Microsoft Developer Studio Project File - Name="listtasks" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=listtasks - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "listtasks.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "listtasks.mak" CFG="listtasks - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "listtasks - Win32 Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "listtasks - Win32 Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "listtasks - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /c
-# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /c
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-
-!ELSEIF "$(CFG)" == "listtasks - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c
-# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-
-!ENDIF
-
-# Begin Target
-
-# Name "listtasks - Win32 Release"
-# Name "listtasks - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=.\listtasks.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\StdAfx.cpp
-# ADD CPP /Yc"stdafx.h"
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=.\listtasks.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\StdAfx.h
-# End Source File
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
-# End Group
-# Begin Source File
-
-SOURCE=.\ReadMe.txt
-# End Source File
-# End Target
-# End Project
+# Microsoft Developer Studio Project File - Name="listtasks" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=listtasks - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "listtasks.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "listtasks.mak" CFG="listtasks - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "listtasks - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "listtasks - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "listtasks - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 + +!ELSEIF "$(CFG)" == "listtasks - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "listtasks - Win32 Release" +# Name "listtasks - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\listtasks.cpp +# End Source File +# Begin Source File + +SOURCE=.\StdAfx.cpp +# ADD CPP /Yc"stdafx.h" +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\listtasks.h +# End Source File +# Begin Source File + +SOURCE=.\StdAfx.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# Begin Source File + +SOURCE=.\ReadMe.txt +# End Source File +# End Target +# End Project diff --git a/core/org.eclipse.cdt.core.win32/library/listtasks/listtasks.dsw b/core/org.eclipse.cdt.core.win32/library/listtasks/listtasks.dsw index 329bd2f44e0..914555a178f 100644 --- a/core/org.eclipse.cdt.core.win32/library/listtasks/listtasks.dsw +++ b/core/org.eclipse.cdt.core.win32/library/listtasks/listtasks.dsw @@ -1,29 +1,29 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00
-# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
-
-###############################################################################
-
-Project: "listtasks"=.\listtasks.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-}}}
-
-###############################################################################
-
-Global:
-
-Package=<5>
-{{{
-}}}
-
-Package=<3>
-{{{
-}}}
-
-###############################################################################
-
+Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "listtasks"=.\listtasks.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/core/org.eclipse.cdt.core.win32/library/listtasks/listtasks.h b/core/org.eclipse.cdt.core.win32/library/listtasks/listtasks.h index ded4503f798..67cf3be123d 100644 --- a/core/org.eclipse.cdt.core.win32/library/listtasks/listtasks.h +++ b/core/org.eclipse.cdt.core.win32/library/listtasks/listtasks.h @@ -1,22 +1,22 @@ -/*******************************************************************************
- * Copyright (c) 2002 - 2005 QNX Software Systems 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:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-#include <windows.h>
-
-#ifndef __LISTTASKS_H
-#define __LISTTASKS_H
-
-typedef BOOL (CALLBACK *PROCENUMPROC)( DWORD, WORD, LPSTR,
- LPARAM ) ;
-
-BOOL WINAPI EnumProcs( PROCENUMPROC lpProc, LPARAM lParam ) ;
-
-
+/******************************************************************************* + * Copyright (c) 2002 - 2005 QNX Software Systems 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: + * QNX Software Systems - initial API and implementation + *******************************************************************************/ +#include <windows.h> + +#ifndef __LISTTASKS_H +#define __LISTTASKS_H + +typedef BOOL (CALLBACK *PROCENUMPROC)( DWORD, WORD, LPSTR, + LPARAM ) ; + +BOOL WINAPI EnumProcs( PROCENUMPROC lpProc, LPARAM lParam ) ; + + #endif
\ No newline at end of file diff --git a/core/org.eclipse.cdt.core.win32/library/pty/jni/include/PTY.h b/core/org.eclipse.cdt.core.win32/library/pty/jni/include/PTY.h index 5c80c5793c8..d73d5c00e16 100644 --- a/core/org.eclipse.cdt.core.win32/library/pty/jni/include/PTY.h +++ b/core/org.eclipse.cdt.core.win32/library/pty/jni/include/PTY.h @@ -1,45 +1,45 @@ -/* 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);
-
-/*
- * 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 *, jobject, jobjectArray, jobjectArray, jstring, jintArray, 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);
-
-#ifdef __cplusplus
-}
-#endif
-#endif
+/* 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); + +/* + * 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 *, jobject, jobjectArray, jobjectArray, jstring, jintArray, 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); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/core/org.eclipse.cdt.core.win32/library/pty/jni/include/PTYInputStream.h b/core/org.eclipse.cdt.core.win32/library/pty/jni/include/PTYInputStream.h index 86cd5bdd240..7767be6bd8c 100644 --- a/core/org.eclipse.cdt.core.win32/library/pty/jni/include/PTYInputStream.h +++ b/core/org.eclipse.cdt.core.win32/library/pty/jni/include/PTYInputStream.h @@ -1,31 +1,31 @@ -/* 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_MAX_SKIP_BUFFER_SIZE
-#define org_eclipse_cdt_utils_pty_PTYInputStream_MAX_SKIP_BUFFER_SIZE 2048L
-/*
- * 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
+/* 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_MAX_SKIP_BUFFER_SIZE +#define org_eclipse_cdt_utils_pty_PTYInputStream_MAX_SKIP_BUFFER_SIZE 2048L +/* + * 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.win32/library/pty/jni/include/PTYOutputStream.h b/core/org.eclipse.cdt.core.win32/library/pty/jni/include/PTYOutputStream.h index 108ef248d8c..fb28491060e 100644 --- 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 @@ -1,29 +1,29 @@ -/* 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
+/* 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/pty.sln b/core/org.eclipse.cdt.core.win32/library/pty/pty.sln index bd82345255b..220c281aade 100644 --- a/core/org.eclipse.cdt.core.win32/library/pty/pty.sln +++ b/core/org.eclipse.cdt.core.win32/library/pty/pty.sln @@ -1,46 +1,46 @@ -
-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
+ +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 index 29311ce2b06..7d526ce88b1 100644 --- a/core/org.eclipse.cdt.core.win32/library/pty/pty.vcxproj +++ b/core/org.eclipse.cdt.core.win32/library/pty/pty.vcxproj @@ -1,177 +1,177 @@ -<?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>
+<?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 index 4c428115fd8..b92d3375bf7 100644 --- a/core/org.eclipse.cdt.core.win32/library/pty/pty.vcxproj.filters +++ b/core/org.eclipse.cdt.core.win32/library/pty/pty.vcxproj.filters @@ -1,30 +1,30 @@ -<?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>
+<?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 index 69e8ac3b008..0eef37a0900 100644 --- a/core/org.eclipse.cdt.core.win32/library/pty/winpty-agent.vcxproj +++ b/core/org.eclipse.cdt.core.win32/library/pty/winpty-agent.vcxproj @@ -1,185 +1,185 @@ -<?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>
+<?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 index 17401866621..46cdf6beaa8 100644 --- 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 @@ -1,90 +1,90 @@ -<?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>
+<?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 index bf4fabb5b4d..e83366bc905 100644 --- a/core/org.eclipse.cdt.core.win32/library/pty/winpty.vcxproj +++ b/core/org.eclipse.cdt.core.win32/library/pty/winpty.vcxproj @@ -1,167 +1,167 @@ -<?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>
+<?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 index ad2b6019f77..86016e30242 100644 --- a/core/org.eclipse.cdt.core.win32/library/pty/winpty.vcxproj.filters +++ b/core/org.eclipse.cdt.core.win32/library/pty/winpty.vcxproj.filters @@ -1,39 +1,39 @@ -<?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>
+<?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/winreg/dllmain.cpp b/core/org.eclipse.cdt.core.win32/library/winreg/dllmain.cpp index 6e297985f3b..fb210e2a522 100644 --- a/core/org.eclipse.cdt.core.win32/library/winreg/dllmain.cpp +++ b/core/org.eclipse.cdt.core.win32/library/winreg/dllmain.cpp @@ -1,28 +1,28 @@ -/*******************************************************************************
- * Copyright (c) 2015 QNX Software Systems 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:
- * QNX Software Systems - Initial API and implementation
- *******************************************************************************/
-#include "stdafx.h"
-
-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;
-}
-
+/******************************************************************************* + * Copyright (c) 2015 QNX Software Systems 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: + * QNX Software Systems - Initial API and implementation + *******************************************************************************/ +#include "stdafx.h" + +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; +} + diff --git a/core/org.eclipse.cdt.core.win32/library/winreg/stdafx.cpp b/core/org.eclipse.cdt.core.win32/library/winreg/stdafx.cpp index c97de4cd232..74d5be2a887 100644 --- a/core/org.eclipse.cdt.core.win32/library/winreg/stdafx.cpp +++ b/core/org.eclipse.cdt.core.win32/library/winreg/stdafx.cpp @@ -1,14 +1,14 @@ -/*******************************************************************************
- * Copyright (c) 2015 QNX Software Systems 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:
- * QNX Software Systems - Initial API and implementation
- *******************************************************************************/
-#include "stdafx.h"
-
-// TODO: reference any additional headers you need in STDAFX.H
-// and not in this file
+/******************************************************************************* + * Copyright (c) 2015 QNX Software Systems 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: + * QNX Software Systems - Initial API and implementation + *******************************************************************************/ +#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/winreg/stdafx.h b/core/org.eclipse.cdt.core.win32/library/winreg/stdafx.h index 0babced30e7..d3a8b238d5f 100644 --- a/core/org.eclipse.cdt.core.win32/library/winreg/stdafx.h +++ b/core/org.eclipse.cdt.core.win32/library/winreg/stdafx.h @@ -1,22 +1,22 @@ -/*******************************************************************************
- * Copyright (c) 2015 QNX Software Systems 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:
- * QNX Software Systems - Initial API and implementation
- *******************************************************************************/
-#pragma once
-
-#include "targetver.h"
-
-#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
-// Windows Header Files:
-#include <windows.h>
-#include <jni.h>
-
-
-
-// TODO: reference additional headers your program requires here
+/******************************************************************************* + * Copyright (c) 2015 QNX Software Systems 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: + * QNX Software Systems - Initial API and implementation + *******************************************************************************/ +#pragma once + +#include "targetver.h" + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +// Windows Header Files: +#include <windows.h> +#include <jni.h> + + + +// TODO: reference additional headers your program requires here diff --git a/core/org.eclipse.cdt.core.win32/library/winreg/targetver.h b/core/org.eclipse.cdt.core.win32/library/winreg/targetver.h index d27181a16d6..061a668b8c4 100644 --- a/core/org.eclipse.cdt.core.win32/library/winreg/targetver.h +++ b/core/org.eclipse.cdt.core.win32/library/winreg/targetver.h @@ -1,18 +1,18 @@ -/*******************************************************************************
- * Copyright (c) 2015 QNX Software Systems 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:
- * QNX Software Systems - Initial API and implementation
- *******************************************************************************/
-#pragma once
-
-// Including SDKDDKVer.h defines the highest available Windows platform.
-
-// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
-// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
-
-#include <SDKDDKVer.h>
+/******************************************************************************* + * Copyright (c) 2015 QNX Software Systems 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: + * QNX Software Systems - Initial API and implementation + *******************************************************************************/ +#pragma once + +// Including SDKDDKVer.h defines the highest available Windows platform. + +// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and +// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. + +#include <SDKDDKVer.h> diff --git a/core/org.eclipse.cdt.core.win32/library/winreg/winreg.cpp b/core/org.eclipse.cdt.core.win32/library/winreg/winreg.cpp index 231910a1f77..c64a43ae870 100644 --- a/core/org.eclipse.cdt.core.win32/library/winreg/winreg.cpp +++ b/core/org.eclipse.cdt.core.win32/library/winreg/winreg.cpp @@ -1,151 +1,151 @@ -/*******************************************************************************
- * Copyright (c) 2015 QNX Software Systems 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:
- * QNX Software Systems - Initial API and implementation
- *******************************************************************************/
-#include "stdafx.h"
-
-static jstring getValue(JNIEnv * env, HKEY key, jstring subkey, jstring name) {
- const jchar * csubkey = env->GetStringChars(subkey, NULL);
- const jchar * cname = env->GetStringChars(name, NULL);
- jstring result = NULL;
-
- HKEY skey;
- LONG rc = RegOpenKeyEx(key, (const wchar_t *)csubkey, 0, KEY_READ, &skey);
- if (rc == ERROR_SUCCESS) {
- DWORD type;
- wchar_t buffer[256];
- DWORD len = sizeof(buffer);
- rc = RegQueryValueEx(skey, (const wchar_t *)cname, NULL, &type, (BYTE *)&buffer, &len);
- if (rc == ERROR_SUCCESS) {
- result = env->NewString((jchar *) buffer, (jsize) wcslen(buffer));
- }
- RegCloseKey(skey);
- }
-
- env->ReleaseStringChars(subkey, csubkey);
- env->ReleaseStringChars(name, cname);
-
- return result;
-}
-
-extern "C"
-JNIEXPORT jstring JNICALL Java_org_eclipse_cdt_utils_WindowsRegistry_getLocalMachineValue(
-JNIEnv * env, jobject obj, jstring subkey, jstring name)
-{
- return getValue(env, HKEY_LOCAL_MACHINE, subkey, name);
-}
-
-extern "C"
-JNIEXPORT jstring JNICALL Java_org_eclipse_cdt_utils_WindowsRegistry_getCurrentUserValue(
-JNIEnv * env, jobject obj, jstring subkey, jstring name)
-{
- return getValue(env, HKEY_CURRENT_USER, subkey, name);
-}
-
-/*
-* Given a subkey (string) under 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.
-*/
-
-static jstring getValueName(JNIEnv * env, HKEY key, jstring subkey, jint index) {
- const jchar * csubkey = env->GetStringChars(subkey, NULL);
- jstring result = NULL;
-
- HKEY skey;
- LONG rc = RegOpenKeyEx(key, (const wchar_t *)csubkey, 0, KEY_READ, &skey);
- if (rc != ERROR_SUCCESS)
- return NULL;
-
- wchar_t valueName[256];
- DWORD nameSize = sizeof(valueName) + 2;
-
- rc = RegEnumValue(skey, index,
- valueName, // UNICODE string
- &nameSize,
- NULL, NULL,
- NULL, // data string
- NULL); // size in BYTE of data.
-
- if (rc == ERROR_SUCCESS)
- {
- result = env->NewString((jchar *)valueName, nameSize);
- }
-
- RegCloseKey(skey);
-
- env->ReleaseStringChars(subkey, csubkey);
-
- return result;
-}
-
-extern "C"
-JNIEXPORT jstring JNICALL Java_org_eclipse_cdt_utils_WindowsRegistry_getLocalMachineValueName(
-JNIEnv * env, jobject obj, jstring subkey, jint index)
-{
- return getValueName(env, HKEY_LOCAL_MACHINE, subkey, index);
-}
-
-extern "C"
-JNIEXPORT jstring JNICALL Java_org_eclipse_cdt_utils_WindowsRegistry_getCurrentUserValueName(
-JNIEnv * env, jobject obj, jstring subkey, jint index)
-{
- return getValueName(env, HKEY_CURRENT_USER, subkey, index);
-}
-
-/*
-* Given a subkey (string) under HKEY_LOCAL_MACHINE, and an index (starting from 0)
-* to the key's array of keys, return the name of the indexed key.
-* The return value is null on any error or when the index is invalid.
-*/
-
-static jstring getKeyName(JNIEnv * env, HKEY key, jstring subkey, jint index) {
- const jchar * csubkey = env->GetStringChars(subkey, NULL);
- jstring result = NULL;
-
- HKEY skey;
- LONG rc = RegOpenKeyEx(key, (const wchar_t *)csubkey, 0, KEY_READ, &skey);
- if (rc != ERROR_SUCCESS)
- return NULL;
-
- wchar_t keyName[256];
- DWORD nameSize = sizeof(keyName) + 2;
-
- rc = RegEnumKeyEx(skey, index,
- keyName, // UNICODE string
- &nameSize,
- NULL, NULL,
- NULL,
- NULL); // size in BYTE of data.
-
- if (rc == ERROR_SUCCESS)
- {
- result = env->NewString((jchar *)keyName, nameSize);
- }
-
- RegCloseKey(skey);
-
- env->ReleaseStringChars(subkey, csubkey);
-
- return result;
-}
-
-extern "C"
-JNIEXPORT jstring JNICALL Java_org_eclipse_cdt_utils_WindowsRegistry_getLocalMachineKeyName(
-JNIEnv * env, jobject obj, jstring subkey, jint index)
-{
- return getKeyName(env, HKEY_LOCAL_MACHINE, subkey, index);
-}
-
-extern "C"
-JNIEXPORT jstring JNICALL Java_org_eclipse_cdt_utils_WindowsRegistry_getCurrentUserKeyName(
-JNIEnv * env, jobject obj, jstring subkey, jint index)
-{
- return getKeyName(env, HKEY_CURRENT_USER, subkey, index);
-}
+/******************************************************************************* + * Copyright (c) 2015 QNX Software Systems 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: + * QNX Software Systems - Initial API and implementation + *******************************************************************************/ +#include "stdafx.h" + +static jstring getValue(JNIEnv * env, HKEY key, jstring subkey, jstring name) { + const jchar * csubkey = env->GetStringChars(subkey, NULL); + const jchar * cname = env->GetStringChars(name, NULL); + jstring result = NULL; + + HKEY skey; + LONG rc = RegOpenKeyEx(key, (const wchar_t *)csubkey, 0, KEY_READ, &skey); + if (rc == ERROR_SUCCESS) { + DWORD type; + wchar_t buffer[256]; + DWORD len = sizeof(buffer); + rc = RegQueryValueEx(skey, (const wchar_t *)cname, NULL, &type, (BYTE *)&buffer, &len); + if (rc == ERROR_SUCCESS) { + result = env->NewString((jchar *) buffer, (jsize) wcslen(buffer)); + } + RegCloseKey(skey); + } + + env->ReleaseStringChars(subkey, csubkey); + env->ReleaseStringChars(name, cname); + + return result; +} + +extern "C" +JNIEXPORT jstring JNICALL Java_org_eclipse_cdt_utils_WindowsRegistry_getLocalMachineValue( +JNIEnv * env, jobject obj, jstring subkey, jstring name) +{ + return getValue(env, HKEY_LOCAL_MACHINE, subkey, name); +} + +extern "C" +JNIEXPORT jstring JNICALL Java_org_eclipse_cdt_utils_WindowsRegistry_getCurrentUserValue( +JNIEnv * env, jobject obj, jstring subkey, jstring name) +{ + return getValue(env, HKEY_CURRENT_USER, subkey, name); +} + +/* +* Given a subkey (string) under 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. +*/ + +static jstring getValueName(JNIEnv * env, HKEY key, jstring subkey, jint index) { + const jchar * csubkey = env->GetStringChars(subkey, NULL); + jstring result = NULL; + + HKEY skey; + LONG rc = RegOpenKeyEx(key, (const wchar_t *)csubkey, 0, KEY_READ, &skey); + if (rc != ERROR_SUCCESS) + return NULL; + + wchar_t valueName[256]; + DWORD nameSize = sizeof(valueName) + 2; + + rc = RegEnumValue(skey, index, + valueName, // UNICODE string + &nameSize, + NULL, NULL, + NULL, // data string + NULL); // size in BYTE of data. + + if (rc == ERROR_SUCCESS) + { + result = env->NewString((jchar *)valueName, nameSize); + } + + RegCloseKey(skey); + + env->ReleaseStringChars(subkey, csubkey); + + return result; +} + +extern "C" +JNIEXPORT jstring JNICALL Java_org_eclipse_cdt_utils_WindowsRegistry_getLocalMachineValueName( +JNIEnv * env, jobject obj, jstring subkey, jint index) +{ + return getValueName(env, HKEY_LOCAL_MACHINE, subkey, index); +} + +extern "C" +JNIEXPORT jstring JNICALL Java_org_eclipse_cdt_utils_WindowsRegistry_getCurrentUserValueName( +JNIEnv * env, jobject obj, jstring subkey, jint index) +{ + return getValueName(env, HKEY_CURRENT_USER, subkey, index); +} + +/* +* Given a subkey (string) under HKEY_LOCAL_MACHINE, and an index (starting from 0) +* to the key's array of keys, return the name of the indexed key. +* The return value is null on any error or when the index is invalid. +*/ + +static jstring getKeyName(JNIEnv * env, HKEY key, jstring subkey, jint index) { + const jchar * csubkey = env->GetStringChars(subkey, NULL); + jstring result = NULL; + + HKEY skey; + LONG rc = RegOpenKeyEx(key, (const wchar_t *)csubkey, 0, KEY_READ, &skey); + if (rc != ERROR_SUCCESS) + return NULL; + + wchar_t keyName[256]; + DWORD nameSize = sizeof(keyName) + 2; + + rc = RegEnumKeyEx(skey, index, + keyName, // UNICODE string + &nameSize, + NULL, NULL, + NULL, + NULL); // size in BYTE of data. + + if (rc == ERROR_SUCCESS) + { + result = env->NewString((jchar *)keyName, nameSize); + } + + RegCloseKey(skey); + + env->ReleaseStringChars(subkey, csubkey); + + return result; +} + +extern "C" +JNIEXPORT jstring JNICALL Java_org_eclipse_cdt_utils_WindowsRegistry_getLocalMachineKeyName( +JNIEnv * env, jobject obj, jstring subkey, jint index) +{ + return getKeyName(env, HKEY_LOCAL_MACHINE, subkey, index); +} + +extern "C" +JNIEXPORT jstring JNICALL Java_org_eclipse_cdt_utils_WindowsRegistry_getCurrentUserKeyName( +JNIEnv * env, jobject obj, jstring subkey, jint index) +{ + return getKeyName(env, HKEY_CURRENT_USER, subkey, index); +} diff --git a/core/org.eclipse.cdt.core.win32/library/winreg/winreg.vcxproj b/core/org.eclipse.cdt.core.win32/library/winreg/winreg.vcxproj index 994ba556f5a..0c82aec90f9 100644 --- a/core/org.eclipse.cdt.core.win32/library/winreg/winreg.vcxproj +++ b/core/org.eclipse.cdt.core.win32/library/winreg/winreg.vcxproj @@ -1,175 +1,175 @@ -<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="12.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>{4CA57EA3-42F2-4CC1-8E95-5C707A8E7363}</ProjectGuid>
- <Keyword>Win32Proj</Keyword>
- <RootNamespace>winreg</RootNamespace>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseDebugLibraries>true</UseDebugLibraries>
- <PlatformToolset>v120</PlatformToolset>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseDebugLibraries>true</UseDebugLibraries>
- <PlatformToolset>v120</PlatformToolset>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseDebugLibraries>false</UseDebugLibraries>
- <PlatformToolset>v120</PlatformToolset>
- <WholeProgramOptimization>true</WholeProgramOptimization>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseDebugLibraries>false</UseDebugLibraries>
- <PlatformToolset>v120</PlatformToolset>
- <WholeProgramOptimization>true</WholeProgramOptimization>
- <CharacterSet>Unicode</CharacterSet>
- </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>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <LinkIncremental>true</LinkIncremental>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <LinkIncremental>false</LinkIncremental>
- <OutDir>$(SolutionDir)..\..\org.eclipse.cdt.core.win32.x86\os\win32\x86\</OutDir>
- <IntDir />
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <LinkIncremental>false</LinkIncremental>
- <OutDir>$(SolutionDir)..\..\org.eclipse.cdt.core.win32.x86_64\os\win32\x86_64\</OutDir>
- <IntDir />
- </PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <ClCompile>
- <PrecompiledHeader>Use</PrecompiledHeader>
- <WarningLevel>Level3</WarningLevel>
- <Optimization>Disabled</Optimization>
- <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;WINREG_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- <Link>
- <SubSystem>Windows</SubSystem>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <ClCompile>
- <PrecompiledHeader>Use</PrecompiledHeader>
- <WarningLevel>Level3</WarningLevel>
- <Optimization>Disabled</Optimization>
- <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;WINREG_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- <Link>
- <SubSystem>Windows</SubSystem>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <ClCompile>
- <WarningLevel>Level3</WarningLevel>
- <PrecompiledHeader>Use</PrecompiledHeader>
- <Optimization>MaxSpeed</Optimization>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <IntrinsicFunctions>true</IntrinsicFunctions>
- <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;WINREG_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>C:\Program Files\Java\jdk1.8.0_31\include;C:\Program Files\Java\jdk1.8.0_31\include\win32</AdditionalIncludeDirectories>
- <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
- </ClCompile>
- <Link>
- <SubSystem>Windows</SubSystem>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <OptimizeReferences>true</OptimizeReferences>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <ClCompile>
- <WarningLevel>Level3</WarningLevel>
- <PrecompiledHeader>Use</PrecompiledHeader>
- <Optimization>MaxSpeed</Optimization>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <IntrinsicFunctions>true</IntrinsicFunctions>
- <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;WINREG_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>C:\Program Files\Java\jdk1.8.0_31\include;C:\Program Files\Java\jdk1.8.0_31\include\win32</AdditionalIncludeDirectories>
- <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
- </ClCompile>
- <Link>
- <SubSystem>Windows</SubSystem>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <OptimizeReferences>true</OptimizeReferences>
- </Link>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClInclude Include="stdafx.h" />
- <ClInclude Include="targetver.h" />
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="dllmain.cpp">
- <CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsManaged>
- <CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</CompileAsManaged>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- </PrecompiledHeader>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- </PrecompiledHeader>
- <CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</CompileAsManaged>
- <CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</CompileAsManaged>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- </PrecompiledHeader>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- </PrecompiledHeader>
- </ClCompile>
- <ClCompile Include="stdafx.cpp">
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
- </ClCompile>
- <ClCompile Include="winreg.cpp" />
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
+<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="12.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>{4CA57EA3-42F2-4CC1-8E95-5C707A8E7363}</ProjectGuid> + <Keyword>Win32Proj</Keyword> + <RootNamespace>winreg</RootNamespace> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <PlatformToolset>v120</PlatformToolset> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <PlatformToolset>v120</PlatformToolset> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <PlatformToolset>v120</PlatformToolset> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <PlatformToolset>v120</PlatformToolset> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>Unicode</CharacterSet> + </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> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <LinkIncremental>true</LinkIncremental> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <LinkIncremental>false</LinkIncremental> + <OutDir>$(SolutionDir)..\..\org.eclipse.cdt.core.win32.x86\os\win32\x86\</OutDir> + <IntDir /> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <LinkIncremental>false</LinkIncremental> + <OutDir>$(SolutionDir)..\..\org.eclipse.cdt.core.win32.x86_64\os\win32\x86_64\</OutDir> + <IntDir /> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <PrecompiledHeader>Use</PrecompiledHeader> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;WINREG_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + </ClCompile> + <Link> + <SubSystem>Windows</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <ClCompile> + <PrecompiledHeader>Use</PrecompiledHeader> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;WINREG_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + </ClCompile> + <Link> + <SubSystem>Windows</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <PrecompiledHeader>Use</PrecompiledHeader> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;WINREG_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <AdditionalIncludeDirectories>C:\Program Files\Java\jdk1.8.0_31\include;C:\Program Files\Java\jdk1.8.0_31\include\win32</AdditionalIncludeDirectories> + <RuntimeLibrary>MultiThreaded</RuntimeLibrary> + </ClCompile> + <Link> + <SubSystem>Windows</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <PrecompiledHeader>Use</PrecompiledHeader> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;WINREG_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <AdditionalIncludeDirectories>C:\Program Files\Java\jdk1.8.0_31\include;C:\Program Files\Java\jdk1.8.0_31\include\win32</AdditionalIncludeDirectories> + <RuntimeLibrary>MultiThreaded</RuntimeLibrary> + </ClCompile> + <Link> + <SubSystem>Windows</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClInclude Include="stdafx.h" /> + <ClInclude Include="targetver.h" /> + </ItemGroup> + <ItemGroup> + <ClCompile Include="dllmain.cpp"> + <CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsManaged> + <CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</CompileAsManaged> + <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + </PrecompiledHeader> + <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + </PrecompiledHeader> + <CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</CompileAsManaged> + <CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</CompileAsManaged> + <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + </PrecompiledHeader> + <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + </PrecompiledHeader> + </ClCompile> + <ClCompile Include="stdafx.cpp"> + <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader> + <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader> + <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader> + <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader> + </ClCompile> + <ClCompile Include="winreg.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/winreg/winreg.vcxproj.filters b/core/org.eclipse.cdt.core.win32/library/winreg/winreg.vcxproj.filters index 41d99849235..afa4a0f572f 100644 --- a/core/org.eclipse.cdt.core.win32/library/winreg/winreg.vcxproj.filters +++ b/core/org.eclipse.cdt.core.win32/library/winreg/winreg.vcxproj.filters @@ -1,36 +1,36 @@ -<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup>
- <Filter Include="Source Files">
- <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
- <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
- </Filter>
- <Filter Include="Header Files">
- <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
- <Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
- </Filter>
- <Filter Include="Resource Files">
- <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
- <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
- </Filter>
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="stdafx.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="targetver.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="stdafx.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="winreg.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="dllmain.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- </ItemGroup>
+<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup> + <Filter Include="Source Files"> + <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> + <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions> + </Filter> + <Filter Include="Header Files"> + <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> + <Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions> + </Filter> + <Filter Include="Resource Files"> + <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier> + <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions> + </Filter> + </ItemGroup> + <ItemGroup> + <ClInclude Include="stdafx.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="targetver.h"> + <Filter>Header Files</Filter> + </ClInclude> + </ItemGroup> + <ItemGroup> + <ClCompile Include="stdafx.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="winreg.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="dllmain.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + </ItemGroup> </Project>
\ No newline at end of file diff --git a/core/org.eclipse.cdt.core.win32/plugin.properties b/core/org.eclipse.cdt.core.win32/plugin.properties index 0b31b3ca94e..9dec4fd06a0 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
-providerName=Eclipse CDT
+fragmentName.linux=C/C++ Development Tools Core for Windows +providerName=Eclipse CDT diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/ILanguageSettingsProvidersKeeper.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/ILanguageSettingsProvidersKeeper.java index fb9be5d5ae4..0d2a44c9b6d 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/ILanguageSettingsProvidersKeeper.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/ILanguageSettingsProvidersKeeper.java @@ -1,69 +1,69 @@ -/*******************************************************************************
- * Copyright (c) 2011, 2013 Andrew Gvozdev 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:
- * Andrew Gvozdev - initial API and implementation
+/******************************************************************************* + * Copyright (c) 2011, 2013 Andrew Gvozdev 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: + * Andrew Gvozdev - initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.core.language.settings.providers;
-
-import java.util.List;
-
-import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
-/**
- * Interface to express ability (of a configuration description) to handle Language Settings
- * Providers.
- * @see ILanguageSettingsProvider
- *
- * @since 5.4
- *
- */
-public interface ILanguageSettingsProvidersKeeper {
- /**
- * Sets the list of language settings providers. Language settings providers are
- * used to supply language settings {@link ICLanguageSettingEntry} such as include paths
- * or preprocessor macros.
- *
- * @param providers - the list of providers to assign to the owner (configuration description).
- * This method clones the internal list or otherwise ensures immutability of the internal
- * list before actual addition to the project model. That is to ensure that there is no
- * back-door access and all changes in the list done by this method which fires notifications
- * to the registered listeners about the accompanied changes in settings entries, see
- * {@link LanguageSettingsManager#registerLanguageSettingsChangeListener(ILanguageSettingsChangeListener)}.
- */
- public void setLanguageSettingProviders(List<? extends ILanguageSettingsProvider> providers);
-
- /**
- * Returns the list of language settings providers. Language settings providers are
- * used to supply language settings {@link ICLanguageSettingEntry} such as include paths
- * or preprocessor macros.
- *
- * @return the list of providers to assign to the owner (configuration description). This
- * returns immutable list. Use {@link #setLanguageSettingProviders(List)} to change.
- * This method does not return {@code null}.
- */
- public List<ILanguageSettingsProvider> getLanguageSettingProviders();
-
- /**
- * Sets the list of IDs of default language settings providers.
- * <br><br>
- * The method is intended to be used by MBS to set the list from tool-chain definition.
- * The default list from the tool-chain is used, for example, while resetting
- * configuration providers to default in UI.
- *
- * @param ids - default provider IDs specified in the tool-chain.
- */
- public void setDefaultLanguageSettingsProvidersIds(String[] ids);
-
- /**
- * Retrieve the list of IDs of default language settings providers.
- * Normally the list would come from the tool-chain definition.
- *
- * @return default provider IDs or {@code null} if default providers are not defined.
- */
- public String[] getDefaultLanguageSettingsProvidersIds();
-
-}
+package org.eclipse.cdt.core.language.settings.providers; + +import java.util.List; + +import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; +/** + * Interface to express ability (of a configuration description) to handle Language Settings + * Providers. + * @see ILanguageSettingsProvider + * + * @since 5.4 + * + */ +public interface ILanguageSettingsProvidersKeeper { + /** + * Sets the list of language settings providers. Language settings providers are + * used to supply language settings {@link ICLanguageSettingEntry} such as include paths + * or preprocessor macros. + * + * @param providers - the list of providers to assign to the owner (configuration description). + * This method clones the internal list or otherwise ensures immutability of the internal + * list before actual addition to the project model. That is to ensure that there is no + * back-door access and all changes in the list done by this method which fires notifications + * to the registered listeners about the accompanied changes in settings entries, see + * {@link LanguageSettingsManager#registerLanguageSettingsChangeListener(ILanguageSettingsChangeListener)}. + */ + public void setLanguageSettingProviders(List<? extends ILanguageSettingsProvider> providers); + + /** + * Returns the list of language settings providers. Language settings providers are + * used to supply language settings {@link ICLanguageSettingEntry} such as include paths + * or preprocessor macros. + * + * @return the list of providers to assign to the owner (configuration description). This + * returns immutable list. Use {@link #setLanguageSettingProviders(List)} to change. + * This method does not return {@code null}. + */ + public List<ILanguageSettingsProvider> getLanguageSettingProviders(); + + /** + * Sets the list of IDs of default language settings providers. + * <br><br> + * The method is intended to be used by MBS to set the list from tool-chain definition. + * The default list from the tool-chain is used, for example, while resetting + * configuration providers to default in UI. + * + * @param ids - default provider IDs specified in the tool-chain. + */ + public void setDefaultLanguageSettingsProvidersIds(String[] ids); + + /** + * Retrieve the list of IDs of default language settings providers. + * Normally the list would come from the tool-chain definition. + * + * @return default provider IDs or {@code null} if default providers are not defined. + */ + public String[] getDefaultLanguageSettingsProvidersIds(); + +} diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/IWorkingDirectoryTracker.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/IWorkingDirectoryTracker.java index 6bf62071aa3..4f64bc39cd2 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/IWorkingDirectoryTracker.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/IWorkingDirectoryTracker.java @@ -1,28 +1,28 @@ -/*******************************************************************************
- * Copyright (c) 2012, 2012 Andrew Gvozdev 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:
- * Andrew Gvozdev - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.core.language.settings.providers;
-
-import java.net.URI;
-
-/**
- * Interface for console parsers able to track current working directory for build.
- *
- * @since 5.4
- */
-public interface IWorkingDirectoryTracker {
- /**
- * Returns current working directory for the current build command as determined from
- * build output.
- *
- * @return URI of current working directory or {@code null}.
- */
- public URI getWorkingDirectoryURI();
-}
+/******************************************************************************* + * Copyright (c) 2012, 2012 Andrew Gvozdev 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: + * Andrew Gvozdev - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.core.language.settings.providers; + +import java.net.URI; + +/** + * Interface for console parsers able to track current working directory for build. + * + * @since 5.4 + */ +public interface IWorkingDirectoryTracker { + /** + * Returns current working directory for the current build command as determined from + * build output. + * + * @return URI of current working directory or {@code null}. + */ + public URI getWorkingDirectoryURI(); +} diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsStorage.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsStorage.java index 992ee4e7097..a3e0e76468c 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsStorage.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsStorage.java @@ -1,266 +1,266 @@ -/*******************************************************************************
- * Copyright (c) 2011, 2014 Andrew Gvozdev 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:
- * Andrew Gvozdev - initial API and implementation
+/******************************************************************************* + * Copyright (c) 2011, 2014 Andrew Gvozdev 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: + * Andrew Gvozdev - initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.core.language.settings.providers;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
-import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
-import org.eclipse.cdt.core.settings.model.ICSettingEntry;
-import org.eclipse.cdt.internal.core.WeakHashSet;
-import org.eclipse.cdt.internal.core.WeakHashSetSynchronized;
-
-/**
- * The class representing the (in-memory) storage for language settings entries {@link ICLanguageSettingEntry}.
- *
- * @since 5.4
- */
-public class LanguageSettingsStorage implements Cloneable {
- /** Storage to keep settings entries. */
- protected Map<String, // languageId
- Map<String, // resource project path
- List<ICLanguageSettingEntry>>> fStorage = new HashMap<String, Map<String, List<ICLanguageSettingEntry>>>();
-
- /**
- * Pool of LSE lists implemented as WeakHashSet. That allows to gain memory savings
- * at the expense of CPU time. WeakHashSet handles garbage collection when a list is not
- * referenced anywhere else. See JavaDoc {@link java.lang.ref.WeakReference} about weak reference objects.
- */
- private static WeakHashSet<List<ICLanguageSettingEntry>> listPool = new WeakHashSetSynchronized<List<ICLanguageSettingEntry>>();
-
- /**
- * Returns the list of setting entries for the given resource and language.
- * <br> Note that this list is <b>unmodifiable</b>.
- *
- * @param rcProjectPath - path to the resource relative to the project.
- * @param languageId - language id.
- *
- * @return the list of setting entries or {@code null} if no settings defined.
- */
- public List<ICLanguageSettingEntry> getSettingEntries(String rcProjectPath, String languageId) {
- List<ICLanguageSettingEntry> entries = null;
- Map<String, List<ICLanguageSettingEntry>> langMap = fStorage.get(languageId);
- if (langMap!=null) {
- entries = langMap.get(rcProjectPath);
- }
- return entries;
- }
-
- /**
- * Some providers may collect entries in pretty much random order. For the intent of
- * predictability, UI usability and efficient storage the entries are sorted by kinds
- * and secondary by name for kinds where the secondary order is not significant.
- *
- * @param entries - list of entries to sort.
- * @return - sorted entries.
- */
- private List<ICLanguageSettingEntry> sortEntries(List<? extends ICLanguageSettingEntry> entries) {
- List<ICLanguageSettingEntry> sortedEntries = new ArrayList<>(entries);
- Collections.sort(sortedEntries, new Comparator<ICLanguageSettingEntry>() {
- /**
- * This comparator sorts by kinds first and the macros are sorted additionally by name.
- */
- @Override
- public int compare(ICLanguageSettingEntry entry0, ICLanguageSettingEntry entry1) {
- int kind0 = entry0.getKind();
- int kind1 = entry1.getKind();
- if (kind0 == ICSettingEntry.MACRO && kind1 == ICSettingEntry.MACRO) {
- return entry0.getName().compareTo(entry1.getName());
- }
-
- return kind0 - kind1;
- }});
-
- return sortedEntries;
- }
-
- /**
- * Sets language settings entries for the resource and language.
- *
- * @param rcProjectPath - path to the resource relative to the project. If {@code null} the entries are
- * considered to be being defined as default entries for resources.
- * @param languageId - language id. If {@code null}, then entries are considered
- * to be defined for the language scope.
- * @param entries - language settings entries to set.
- */
- public void setSettingEntries(String rcProjectPath, String languageId,
- List<? extends ICLanguageSettingEntry> entries) {
- synchronized (fStorage) {
- if (entries!=null) {
- Map<String, List<ICLanguageSettingEntry>> langMap = fStorage.get(languageId);
- if (langMap == null) {
- langMap = new HashMap<String, List<ICLanguageSettingEntry>>();
- fStorage.put(languageId, langMap);
- }
- List<ICLanguageSettingEntry> sortedEntries = getPooledList(sortEntries(entries), false);
- langMap.put(rcProjectPath, sortedEntries);
- } else {
- // reduct the empty maps in the tables
- Map<String, List<ICLanguageSettingEntry>> langMap = fStorage.get(languageId);
- if (langMap != null) {
- langMap.remove(rcProjectPath);
- if (langMap.isEmpty()) {
- fStorage.remove(languageId);
- }
- }
- }
- }
- }
-
- /**
- * @return {@code true} if the storage is empty or {@code false} otherwise.
- */
- public boolean isEmpty() {
- return fStorage.isEmpty();
- }
-
- /**
- * Clear all the entries for all resources and all languages.
- */
- public void clear() {
- synchronized (fStorage) {
- fStorage.clear();
- }
- }
-
- /**
- * @return set of all languages associated with the entries.
- * Note that the storage can keep default entries for the language scope
- * of the provider, so the set can contain {@code null}.
- */
- public Set<String> getLanguages() {
- return new HashSet<String>(fStorage.keySet());
- }
-
- /**
- * Returns set of paths for all resources associated with entries for given language.
- * The paths are project relative.
- *
- * @param languageId - language ID.
- * @return the set of resource paths associated with entries for the given language or empty set.
- * Note that the storage can keep default entries for resources, so the set can contain {@code null}.
- */
- public Set<String> getResourcePaths(String languageId) {
- Map<String, List<ICLanguageSettingEntry>> rcPathsMap = fStorage.get(languageId);
- if (rcPathsMap == null) {
- return new HashSet<String>();
- }
- return new HashSet<String>(rcPathsMap.keySet());
- }
-
- /**
- * Find and return the equal list of entries from the pool.
- *
- * @param entries - list of entries to pool.
- * @param copy - specify {@code true} to copy the list in order to prevent
- * back-door modification on the original list changes.
- * @return returns the list of entries from the pool.
- */
- private static List<ICLanguageSettingEntry> getPooledList(List<ICLanguageSettingEntry> entries, boolean copy) {
- if (entries == null)
- return null;
-
- List<ICLanguageSettingEntry> pooledList = listPool.get(entries);
- if (pooledList != null) {
- return pooledList;
- }
-
- if (entries.size() == 0) {
- return getPooledEmptyList();
- }
-
- if (copy) {
- entries = new ArrayList<ICLanguageSettingEntry>(entries);
- }
- pooledList = Collections.unmodifiableList(entries);
- return listPool.add(pooledList);
- }
-
- /**
- * Find and return the equal list of entries from the pool to conserve the memory.
- *
- * @param entries - list of entries to pool.
- * @return returns the list of entries from the pool.
- */
- public static List<ICLanguageSettingEntry> getPooledList(List<ICLanguageSettingEntry> entries) {
- return getPooledList(entries, true);
- }
-
- /**
- * @return Returns the empty immutable list which is pooled. Use this call rather than creating
- * new empty array to ensure that faster shallow operator '==' can be used instead of equals()
- * which goes deep on HashMaps.
- */
- public static List<ICLanguageSettingEntry> getPooledEmptyList() {
- List<ICLanguageSettingEntry> pooledEmptyList = Collections.emptyList();
- return listPool.add(pooledEmptyList);
- }
-
- /**
- * Clone storage for the entries. Copies references for lists of entries as a whole.
- * Note that that is OK as the lists kept in storage are unmodifiable and pooled.
- */
- @Override
- public LanguageSettingsStorage clone() throws CloneNotSupportedException {
- LanguageSettingsStorage storageClone = (LanguageSettingsStorage) super.clone();
- storageClone.fStorage = new HashMap<String, Map<String, List<ICLanguageSettingEntry>>>();
- synchronized (fStorage) {
- Set<Entry<String, Map<String, List<ICLanguageSettingEntry>>>> entrySetLang = fStorage.entrySet();
- for (Entry<String, Map<String, List<ICLanguageSettingEntry>>> entryLang : entrySetLang) {
- String langId = entryLang.getKey();
- Map<String, List<ICLanguageSettingEntry>> mapRc = entryLang.getValue();
- Map<String, List<ICLanguageSettingEntry>> mapRcClone = new HashMap<String, List<ICLanguageSettingEntry>>();
- Set<Entry<String, List<ICLanguageSettingEntry>>> entrySetRc = mapRc.entrySet();
- for (Entry<String, List<ICLanguageSettingEntry>> entryRc : entrySetRc) {
- String rcProjectPath = entryRc.getKey();
- List<ICLanguageSettingEntry> lsEntries = entryRc.getValue();
- // don't need to clone entries, they are from the LSE lists pool
- mapRcClone.put(rcProjectPath, lsEntries);
- }
- storageClone.fStorage.put(langId, mapRcClone);
- }
- }
- return storageClone;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((fStorage == null) ? 0 : fStorage.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- LanguageSettingsStorage other = (LanguageSettingsStorage) obj;
- if (fStorage == null) {
- if (other.fStorage != null)
- return false;
- } else if (!fStorage.equals(other.fStorage))
- return false;
- return true;
- }
-
-}
+package org.eclipse.cdt.core.language.settings.providers; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; +import org.eclipse.cdt.core.settings.model.ICSettingEntry; +import org.eclipse.cdt.internal.core.WeakHashSet; +import org.eclipse.cdt.internal.core.WeakHashSetSynchronized; + +/** + * The class representing the (in-memory) storage for language settings entries {@link ICLanguageSettingEntry}. + * + * @since 5.4 + */ +public class LanguageSettingsStorage implements Cloneable { + /** Storage to keep settings entries. */ + protected Map<String, // languageId + Map<String, // resource project path + List<ICLanguageSettingEntry>>> fStorage = new HashMap<String, Map<String, List<ICLanguageSettingEntry>>>(); + + /** + * Pool of LSE lists implemented as WeakHashSet. That allows to gain memory savings + * at the expense of CPU time. WeakHashSet handles garbage collection when a list is not + * referenced anywhere else. See JavaDoc {@link java.lang.ref.WeakReference} about weak reference objects. + */ + private static WeakHashSet<List<ICLanguageSettingEntry>> listPool = new WeakHashSetSynchronized<List<ICLanguageSettingEntry>>(); + + /** + * Returns the list of setting entries for the given resource and language. + * <br> Note that this list is <b>unmodifiable</b>. + * + * @param rcProjectPath - path to the resource relative to the project. + * @param languageId - language id. + * + * @return the list of setting entries or {@code null} if no settings defined. + */ + public List<ICLanguageSettingEntry> getSettingEntries(String rcProjectPath, String languageId) { + List<ICLanguageSettingEntry> entries = null; + Map<String, List<ICLanguageSettingEntry>> langMap = fStorage.get(languageId); + if (langMap!=null) { + entries = langMap.get(rcProjectPath); + } + return entries; + } + + /** + * Some providers may collect entries in pretty much random order. For the intent of + * predictability, UI usability and efficient storage the entries are sorted by kinds + * and secondary by name for kinds where the secondary order is not significant. + * + * @param entries - list of entries to sort. + * @return - sorted entries. + */ + private List<ICLanguageSettingEntry> sortEntries(List<? extends ICLanguageSettingEntry> entries) { + List<ICLanguageSettingEntry> sortedEntries = new ArrayList<>(entries); + Collections.sort(sortedEntries, new Comparator<ICLanguageSettingEntry>() { + /** + * This comparator sorts by kinds first and the macros are sorted additionally by name. + */ + @Override + public int compare(ICLanguageSettingEntry entry0, ICLanguageSettingEntry entry1) { + int kind0 = entry0.getKind(); + int kind1 = entry1.getKind(); + if (kind0 == ICSettingEntry.MACRO && kind1 == ICSettingEntry.MACRO) { + return entry0.getName().compareTo(entry1.getName()); + } + + return kind0 - kind1; + }}); + + return sortedEntries; + } + + /** + * Sets language settings entries for the resource and language. + * + * @param rcProjectPath - path to the resource relative to the project. If {@code null} the entries are + * considered to be being defined as default entries for resources. + * @param languageId - language id. If {@code null}, then entries are considered + * to be defined for the language scope. + * @param entries - language settings entries to set. + */ + public void setSettingEntries(String rcProjectPath, String languageId, + List<? extends ICLanguageSettingEntry> entries) { + synchronized (fStorage) { + if (entries!=null) { + Map<String, List<ICLanguageSettingEntry>> langMap = fStorage.get(languageId); + if (langMap == null) { + langMap = new HashMap<String, List<ICLanguageSettingEntry>>(); + fStorage.put(languageId, langMap); + } + List<ICLanguageSettingEntry> sortedEntries = getPooledList(sortEntries(entries), false); + langMap.put(rcProjectPath, sortedEntries); + } else { + // reduct the empty maps in the tables + Map<String, List<ICLanguageSettingEntry>> langMap = fStorage.get(languageId); + if (langMap != null) { + langMap.remove(rcProjectPath); + if (langMap.isEmpty()) { + fStorage.remove(languageId); + } + } + } + } + } + + /** + * @return {@code true} if the storage is empty or {@code false} otherwise. + */ + public boolean isEmpty() { + return fStorage.isEmpty(); + } + + /** + * Clear all the entries for all resources and all languages. + */ + public void clear() { + synchronized (fStorage) { + fStorage.clear(); + } + } + + /** + * @return set of all languages associated with the entries. + * Note that the storage can keep default entries for the language scope + * of the provider, so the set can contain {@code null}. + */ + public Set<String> getLanguages() { + return new HashSet<String>(fStorage.keySet()); + } + + /** + * Returns set of paths for all resources associated with entries for given language. + * The paths are project relative. + * + * @param languageId - language ID. + * @return the set of resource paths associated with entries for the given language or empty set. + * Note that the storage can keep default entries for resources, so the set can contain {@code null}. + */ + public Set<String> getResourcePaths(String languageId) { + Map<String, List<ICLanguageSettingEntry>> rcPathsMap = fStorage.get(languageId); + if (rcPathsMap == null) { + return new HashSet<String>(); + } + return new HashSet<String>(rcPathsMap.keySet()); + } + + /** + * Find and return the equal list of entries from the pool. + * + * @param entries - list of entries to pool. + * @param copy - specify {@code true} to copy the list in order to prevent + * back-door modification on the original list changes. + * @return returns the list of entries from the pool. + */ + private static List<ICLanguageSettingEntry> getPooledList(List<ICLanguageSettingEntry> entries, boolean copy) { + if (entries == null) + return null; + + List<ICLanguageSettingEntry> pooledList = listPool.get(entries); + if (pooledList != null) { + return pooledList; + } + + if (entries.size() == 0) { + return getPooledEmptyList(); + } + + if (copy) { + entries = new ArrayList<ICLanguageSettingEntry>(entries); + } + pooledList = Collections.unmodifiableList(entries); + return listPool.add(pooledList); + } + + /** + * Find and return the equal list of entries from the pool to conserve the memory. + * + * @param entries - list of entries to pool. + * @return returns the list of entries from the pool. + */ + public static List<ICLanguageSettingEntry> getPooledList(List<ICLanguageSettingEntry> entries) { + return getPooledList(entries, true); + } + + /** + * @return Returns the empty immutable list which is pooled. Use this call rather than creating + * new empty array to ensure that faster shallow operator '==' can be used instead of equals() + * which goes deep on HashMaps. + */ + public static List<ICLanguageSettingEntry> getPooledEmptyList() { + List<ICLanguageSettingEntry> pooledEmptyList = Collections.emptyList(); + return listPool.add(pooledEmptyList); + } + + /** + * Clone storage for the entries. Copies references for lists of entries as a whole. + * Note that that is OK as the lists kept in storage are unmodifiable and pooled. + */ + @Override + public LanguageSettingsStorage clone() throws CloneNotSupportedException { + LanguageSettingsStorage storageClone = (LanguageSettingsStorage) super.clone(); + storageClone.fStorage = new HashMap<String, Map<String, List<ICLanguageSettingEntry>>>(); + synchronized (fStorage) { + Set<Entry<String, Map<String, List<ICLanguageSettingEntry>>>> entrySetLang = fStorage.entrySet(); + for (Entry<String, Map<String, List<ICLanguageSettingEntry>>> entryLang : entrySetLang) { + String langId = entryLang.getKey(); + Map<String, List<ICLanguageSettingEntry>> mapRc = entryLang.getValue(); + Map<String, List<ICLanguageSettingEntry>> mapRcClone = new HashMap<String, List<ICLanguageSettingEntry>>(); + Set<Entry<String, List<ICLanguageSettingEntry>>> entrySetRc = mapRc.entrySet(); + for (Entry<String, List<ICLanguageSettingEntry>> entryRc : entrySetRc) { + String rcProjectPath = entryRc.getKey(); + List<ICLanguageSettingEntry> lsEntries = entryRc.getValue(); + // don't need to clone entries, they are from the LSE lists pool + mapRcClone.put(rcProjectPath, lsEntries); + } + storageClone.fStorage.put(langId, mapRcClone); + } + } + return storageClone; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((fStorage == null) ? 0 : fStorage.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + LanguageSettingsStorage other = (LanguageSettingsStorage) obj; + if (fStorage == null) { + if (other.fStorage != null) + return false; + } else if (!fStorage.equals(other.fStorage)) + return false; + return true; + } + +} diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/ScannerDiscoveryLegacySupport.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/ScannerDiscoveryLegacySupport.java index ab7b58ea514..6159f1641e2 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/ScannerDiscoveryLegacySupport.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/ScannerDiscoveryLegacySupport.java @@ -1,289 +1,289 @@ -/*******************************************************************************
- * Copyright (c) 2009, 2013 Andrew Gvozdev 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:
- * Andrew Gvozdev - initial API and implementation
- * Sergey Prigogin (Google)
- *******************************************************************************/
-
-package org.eclipse.cdt.core.language.settings.providers;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
-import org.eclipse.cdt.core.settings.model.ICProjectDescription;
-import org.eclipse.cdt.internal.core.LocalProjectScope;
-import org.eclipse.cdt.internal.core.language.settings.providers.ReferencedProjectsLanguageSettingsProvider;
-import org.eclipse.cdt.internal.core.language.settings.providers.ScannerInfoExtensionLanguageSettingsProvider;
-import org.eclipse.cdt.internal.core.model.PathEntryManager;
-import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.preferences.InstanceScope;
-import org.osgi.service.prefs.BackingStoreException;
-import org.osgi.service.prefs.Preferences;
-
-/**
- * Collection of utilities for legacy support of older Scanner Discovery functionality.
- * This class is temporary and not intended to be used by clients.
- *
- * @noextend This class is not intended to be subclassed by clients.
- * @noinstantiate This class is not intended to be instantiated by clients.
- *
- * @since 5.4
- */
-public class ScannerDiscoveryLegacySupport {
- /** ID of User language settings provider (from org.eclipse.cdt.ui) */
- public static final String USER_LANGUAGE_SETTINGS_PROVIDER_ID = "org.eclipse.cdt.ui.UserLanguageSettingsProvider"; //$NON-NLS-1$
- /** ID of MBS language settings provider (from org.eclipse.cdt.managedbuilder.core) */
- public static final String MBS_LANGUAGE_SETTINGS_PROVIDER_ID = "org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider"; //$NON-NLS-1$
-
- /**
- * ID of ScannerInfo language settings provider wrapping ScannerInfoProvider defined by org.eclipse.cdt.core.ScannerInfoProvider extension point
- * @since 5.5
- */
- public static final String SI_LANGUAGE_SETTINGS_PROVIDER_ID = "org.eclipse.cdt.core.LegacyScannerInfoLanguageSettingsProvider"; //$NON-NLS-1$
-
- /**
- * ID of language settings provider wrapping {@link org.eclipse.cdt.core.resources.ScannerProvider} of {@link PathEntryManager} for 3.X projects
- * @since 5.5
- */
- public static final String PATH_ENTRY_MANAGER_LANGUAGE_SETTINGS_PROVIDER_ID = "org.eclipse.cdt.core.PathEntryScannerInfoLanguageSettingsProvider"; //$NON-NLS-1$
-
- private static String DISABLE_LSP_PREFERENCE = "language.settings.providers.disabled"; //$NON-NLS-1$
- private static boolean DISABLE_LSP_DEFAULT_PROJECT = false;
- private static boolean DISABLE_LSP_DEFAULT_WORKSPACE = false;
- private static final String PREFERENCES_QUALIFIER_CCORE = CCorePlugin.PLUGIN_ID;
-
- private static Map<String, String> legacyProfiles = null;
-
- /**
- * Get preferences node for org.eclipse.cdt.core.
- *
- * @param project - project to get preferences or {@code null} for workspace preferences
- * @return
- */
- private static Preferences getPreferences(IProject project) {
- if (project == null) {
- return InstanceScope.INSTANCE.getNode(PREFERENCES_QUALIFIER_CCORE);
- } else {
- return new LocalProjectScope(project).getNode(PREFERENCES_QUALIFIER_CCORE);
- }
- }
-
- /**
- * Checks if Language Settings functionality is defined for given project in preferences.
- *
- * @param project - project to check the preference or {@code null} for workspace preference
- * @return {@code true} if functionality is defined
- *
- * @noreference This method is temporary and not intended to be referenced by clients.
- *
- * @since 5.5
- */
- public static boolean isLanguageSettingsProvidersFunctionalityDefined(IProject project) {
- Preferences pref = getPreferences(project);
- String value = pref.get(DISABLE_LSP_PREFERENCE, null);
- return value != null;
- }
-
- /**
- * Checks if Language Settings functionality is enabled for given project.
- * Note that disabling on workspace level will disable it for all projects.
- *
- * @param project - project to check the preference or {@code null} for workspace preference
- * @return {@code true} if functionality is enabled
- *
- * @noreference This method is temporary and not intended to be referenced by clients.
- */
- public static boolean isLanguageSettingsProvidersFunctionalityEnabled(IProject project) {
- boolean isEnabledInWorkspace = !getPreferences(null).getBoolean(DISABLE_LSP_PREFERENCE, DISABLE_LSP_DEFAULT_WORKSPACE);
- if (isEnabledInWorkspace && project != null) {
- return !getPreferences(project).getBoolean(DISABLE_LSP_PREFERENCE, DISABLE_LSP_DEFAULT_PROJECT);
- }
- return isEnabledInWorkspace;
- }
-
- /**
- * Enable/disable Language Settings functionality for the given project.
- *
- * @param project or {@code null} for workspace preference
- * @param value {@code true} to enable or {@code false} to disable the functionality.
- *
- * @noreference This method is temporary and not intended to be referenced by clients.
- */
- public static void setLanguageSettingsProvidersFunctionalityEnabled(IProject project, boolean value) {
- Preferences pref = getPreferences(project);
- if (value == isLanguageSettingsProvidersFunctionalityEnabled(project))
- return;
- pref.putBoolean(DISABLE_LSP_PREFERENCE, !value);
- // Scanner info provider have changed - clear the cached copy (http://bugs.eclipse.org/413357).
- CCorePlugin.getDefault().resetCachedScannerInfoProvider(project);
- try {
- pref.flush();
- } catch (BackingStoreException e) {
- CCorePlugin.log(e);
- }
- }
-
- /**
- * Check if legacy Scanner Discovery in MBS should be active.
- * @noreference This is internal helper method to support compatibility with previous versions
- * which is not intended to be referenced by clients.
- */
- public static boolean isMbsLanguageSettingsProviderOn(ICConfigurationDescription cfgDescription) {
- if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) {
- List<ILanguageSettingsProvider> lsProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
- for (ILanguageSettingsProvider lsp : lsProviders) {
- if (MBS_LANGUAGE_SETTINGS_PROVIDER_ID.equals(lsp.getId())) {
- return true;
- }
- }
- }
- return false;
- }
-
- /**
- * Check if legacy Scanner Discovery should be active.
- * which is not intended to be referenced by clients.
- */
- private static boolean isLegacyProviderOn(ICConfigurationDescription cfgDescription) {
- if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) {
- List<ILanguageSettingsProvider> lsProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
- for (ILanguageSettingsProvider lsp : lsProviders) {
- String id = lsp.getId();
- if (MBS_LANGUAGE_SETTINGS_PROVIDER_ID.equals(id) || SI_LANGUAGE_SETTINGS_PROVIDER_ID.equals(id) || PATH_ENTRY_MANAGER_LANGUAGE_SETTINGS_PROVIDER_ID.equals(id)) {
- return true;
- }
- }
- }
- return false;
- }
-
- /**
- * @noreference This is internal helper method to support compatibility with previous versions
- * which is not intended to be referenced by clients.
- */
- public static boolean isLegacyScannerDiscoveryOn(ICConfigurationDescription cfgDescription) {
- IProject project = null;
- if (cfgDescription != null) {
- ICProjectDescription prjDescription = cfgDescription.getProjectDescription();
- if (prjDescription != null) {
- project = prjDescription.getProject();
- }
- }
- return !isLanguageSettingsProvidersFunctionalityEnabled(project) || isLegacyProviderOn(cfgDescription);
- }
-
- /**
- * @noreference This is internal helper method to support compatibility with previous versions
- * which is not intended to be referenced by clients.
- */
- public static boolean isLegacyScannerDiscoveryOn(IProject project) {
- ICConfigurationDescription cfgDescription = null;
- ICProjectDescription prjDescription = CoreModel.getDefault().getProjectDescription(project);
- if (prjDescription != null) {
- cfgDescription = prjDescription.getActiveConfiguration();
- }
- return !isLanguageSettingsProvidersFunctionalityEnabled(project) || isLegacyProviderOn(cfgDescription);
- }
-
- /**
- * Return list containing User provider and one of wrapper providers to support legacy projects (backward compatibility).
- *
- * @noreference This is internal helper method to support compatibility with previous versions
- * which is not intended to be referenced by clients.
- * @since 5.5
- */
- public static String[] getDefaultProviderIdsLegacy(ICConfigurationDescription cfgDescription) {
- boolean useScannerInfoProviderExtension = new ScannerInfoExtensionLanguageSettingsProvider().getScannerInfoProvider(cfgDescription) != null;
- String legacyProviderId;
- if (useScannerInfoProviderExtension) {
- legacyProviderId = SI_LANGUAGE_SETTINGS_PROVIDER_ID;
- } else if (CProjectDescriptionManager.getInstance().isNewStyleCfg(cfgDescription)) {
- legacyProviderId = MBS_LANGUAGE_SETTINGS_PROVIDER_ID;
- } else {
- legacyProviderId = PATH_ENTRY_MANAGER_LANGUAGE_SETTINGS_PROVIDER_ID;
- }
-
- return new String[] {USER_LANGUAGE_SETTINGS_PROVIDER_ID, ReferencedProjectsLanguageSettingsProvider.ID, legacyProviderId};
- }
-
- /**
- * Checks if the provider is applicable for configuration from backward compatibility point of view
- *
- * @noreference This is internal helper method to support compatibility with previous versions
- * which is not intended to be referenced by clients.
- * @since 5.5
- */
- public static boolean isProviderCompatible(String providerId, ICConfigurationDescription cfgDescription) {
- if (cfgDescription != null) {
- boolean useScannerInfoProviderExtension = new ScannerInfoExtensionLanguageSettingsProvider().getScannerInfoProvider(cfgDescription) != null;
- if (SI_LANGUAGE_SETTINGS_PROVIDER_ID.equals(providerId)) {
- return useScannerInfoProviderExtension;
- }
-
- boolean isNewStyleCfg = CProjectDescriptionManager.getInstance().isNewStyleCfg(cfgDescription);
- if (MBS_LANGUAGE_SETTINGS_PROVIDER_ID.equals(providerId)) {
- return !useScannerInfoProviderExtension && isNewStyleCfg;
- }
-
- if (PATH_ENTRY_MANAGER_LANGUAGE_SETTINGS_PROVIDER_ID.equals(providerId)) {
- return !useScannerInfoProviderExtension && !isNewStyleCfg;
- }
- }
-
- return true;
- }
-
- /**
- * If not defined yet, define property that controls if language settings providers functionality enabled for a given project.
- * Workspace preference is checked and the project property is set to match it.
- *
- * @param project - project to define enablement.
- * @since 5.5
- */
- public static void defineLanguageSettingsEnablement(IProject project) {
- if (project != null && ! ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityDefined(project)) {
- boolean isPreferenceEnabled = ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityEnabled(null);
- ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, isPreferenceEnabled);
- }
- }
-
- /**
- * Returns the values of scanner discovery profiles (scannerConfigDiscoveryProfileId) which were deprecated
- * and replaced with language settings providers in plugin.xml.
- * This (temporary) function serves as fail-safe switch during the transition.
- *
- * @param id - can be id of either org.eclipse.cdt.managedbuilder.internal.core.InputType
- * or org.eclipse.cdt.managedbuilder.internal.core.ToolChain.
- * @return legacy scannerConfigDiscoveryProfileId.
- */
- @SuppressWarnings("nls")
- public static String getDeprecatedLegacyProfiles(String id) {
- if (legacyProfiles == null) {
- legacyProfiles = new HashMap<String, String>();
-
- // InputTypes
- legacyProfiles.put("cdt.managedbuild.tool.gnu.c.compiler.input", "org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC|org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile");
- legacyProfiles.put("cdt.managedbuild.tool.gnu.cpp.compiler.input", "org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP|org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile");
- legacyProfiles.put("cdt.managedbuild.tool.gnu.c.compiler.input.cygwin", "org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC");
- legacyProfiles.put("cdt.managedbuild.tool.gnu.cpp.compiler.input.cygwin", "org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP");
- legacyProfiles.put("cdt.managedbuild.tool.xlc.c.compiler.input", "org.eclipse.cdt.managedbuilder.xlc.core.XLCManagedMakePerProjectProfile");
- legacyProfiles.put("cdt.managedbuild.tool.xlc.cpp.c.compiler.input", "org.eclipse.cdt.managedbuilder.xlc.core.XLCManagedMakePerProjectProfile");
- legacyProfiles.put("cdt.managedbuild.tool.xlc.cpp.compiler.input", "org.eclipse.cdt.managedbuilder.xlc.core.XLCManagedMakePerProjectProfileCPP");
-
- // Toolchains
- }
-
- return legacyProfiles.get(id);
- }
-
-}
+/******************************************************************************* + * Copyright (c) 2009, 2013 Andrew Gvozdev 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: + * Andrew Gvozdev - initial API and implementation + * Sergey Prigogin (Google) + *******************************************************************************/ + +package org.eclipse.cdt.core.language.settings.providers; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.model.CoreModel; +import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; +import org.eclipse.cdt.core.settings.model.ICProjectDescription; +import org.eclipse.cdt.internal.core.LocalProjectScope; +import org.eclipse.cdt.internal.core.language.settings.providers.ReferencedProjectsLanguageSettingsProvider; +import org.eclipse.cdt.internal.core.language.settings.providers.ScannerInfoExtensionLanguageSettingsProvider; +import org.eclipse.cdt.internal.core.model.PathEntryManager; +import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.preferences.InstanceScope; +import org.osgi.service.prefs.BackingStoreException; +import org.osgi.service.prefs.Preferences; + +/** + * Collection of utilities for legacy support of older Scanner Discovery functionality. + * This class is temporary and not intended to be used by clients. + * + * @noextend This class is not intended to be subclassed by clients. + * @noinstantiate This class is not intended to be instantiated by clients. + * + * @since 5.4 + */ +public class ScannerDiscoveryLegacySupport { + /** ID of User language settings provider (from org.eclipse.cdt.ui) */ + public static final String USER_LANGUAGE_SETTINGS_PROVIDER_ID = "org.eclipse.cdt.ui.UserLanguageSettingsProvider"; //$NON-NLS-1$ + /** ID of MBS language settings provider (from org.eclipse.cdt.managedbuilder.core) */ + public static final String MBS_LANGUAGE_SETTINGS_PROVIDER_ID = "org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider"; //$NON-NLS-1$ + + /** + * ID of ScannerInfo language settings provider wrapping ScannerInfoProvider defined by org.eclipse.cdt.core.ScannerInfoProvider extension point + * @since 5.5 + */ + public static final String SI_LANGUAGE_SETTINGS_PROVIDER_ID = "org.eclipse.cdt.core.LegacyScannerInfoLanguageSettingsProvider"; //$NON-NLS-1$ + + /** + * ID of language settings provider wrapping {@link org.eclipse.cdt.core.resources.ScannerProvider} of {@link PathEntryManager} for 3.X projects + * @since 5.5 + */ + public static final String PATH_ENTRY_MANAGER_LANGUAGE_SETTINGS_PROVIDER_ID = "org.eclipse.cdt.core.PathEntryScannerInfoLanguageSettingsProvider"; //$NON-NLS-1$ + + private static String DISABLE_LSP_PREFERENCE = "language.settings.providers.disabled"; //$NON-NLS-1$ + private static boolean DISABLE_LSP_DEFAULT_PROJECT = false; + private static boolean DISABLE_LSP_DEFAULT_WORKSPACE = false; + private static final String PREFERENCES_QUALIFIER_CCORE = CCorePlugin.PLUGIN_ID; + + private static Map<String, String> legacyProfiles = null; + + /** + * Get preferences node for org.eclipse.cdt.core. + * + * @param project - project to get preferences or {@code null} for workspace preferences + * @return + */ + private static Preferences getPreferences(IProject project) { + if (project == null) { + return InstanceScope.INSTANCE.getNode(PREFERENCES_QUALIFIER_CCORE); + } else { + return new LocalProjectScope(project).getNode(PREFERENCES_QUALIFIER_CCORE); + } + } + + /** + * Checks if Language Settings functionality is defined for given project in preferences. + * + * @param project - project to check the preference or {@code null} for workspace preference + * @return {@code true} if functionality is defined + * + * @noreference This method is temporary and not intended to be referenced by clients. + * + * @since 5.5 + */ + public static boolean isLanguageSettingsProvidersFunctionalityDefined(IProject project) { + Preferences pref = getPreferences(project); + String value = pref.get(DISABLE_LSP_PREFERENCE, null); + return value != null; + } + + /** + * Checks if Language Settings functionality is enabled for given project. + * Note that disabling on workspace level will disable it for all projects. + * + * @param project - project to check the preference or {@code null} for workspace preference + * @return {@code true} if functionality is enabled + * + * @noreference This method is temporary and not intended to be referenced by clients. + */ + public static boolean isLanguageSettingsProvidersFunctionalityEnabled(IProject project) { + boolean isEnabledInWorkspace = !getPreferences(null).getBoolean(DISABLE_LSP_PREFERENCE, DISABLE_LSP_DEFAULT_WORKSPACE); + if (isEnabledInWorkspace && project != null) { + return !getPreferences(project).getBoolean(DISABLE_LSP_PREFERENCE, DISABLE_LSP_DEFAULT_PROJECT); + } + return isEnabledInWorkspace; + } + + /** + * Enable/disable Language Settings functionality for the given project. + * + * @param project or {@code null} for workspace preference + * @param value {@code true} to enable or {@code false} to disable the functionality. + * + * @noreference This method is temporary and not intended to be referenced by clients. + */ + public static void setLanguageSettingsProvidersFunctionalityEnabled(IProject project, boolean value) { + Preferences pref = getPreferences(project); + if (value == isLanguageSettingsProvidersFunctionalityEnabled(project)) + return; + pref.putBoolean(DISABLE_LSP_PREFERENCE, !value); + // Scanner info provider have changed - clear the cached copy (http://bugs.eclipse.org/413357). + CCorePlugin.getDefault().resetCachedScannerInfoProvider(project); + try { + pref.flush(); + } catch (BackingStoreException e) { + CCorePlugin.log(e); + } + } + + /** + * Check if legacy Scanner Discovery in MBS should be active. + * @noreference This is internal helper method to support compatibility with previous versions + * which is not intended to be referenced by clients. + */ + public static boolean isMbsLanguageSettingsProviderOn(ICConfigurationDescription cfgDescription) { + if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) { + List<ILanguageSettingsProvider> lsProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + for (ILanguageSettingsProvider lsp : lsProviders) { + if (MBS_LANGUAGE_SETTINGS_PROVIDER_ID.equals(lsp.getId())) { + return true; + } + } + } + return false; + } + + /** + * Check if legacy Scanner Discovery should be active. + * which is not intended to be referenced by clients. + */ + private static boolean isLegacyProviderOn(ICConfigurationDescription cfgDescription) { + if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) { + List<ILanguageSettingsProvider> lsProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + for (ILanguageSettingsProvider lsp : lsProviders) { + String id = lsp.getId(); + if (MBS_LANGUAGE_SETTINGS_PROVIDER_ID.equals(id) || SI_LANGUAGE_SETTINGS_PROVIDER_ID.equals(id) || PATH_ENTRY_MANAGER_LANGUAGE_SETTINGS_PROVIDER_ID.equals(id)) { + return true; + } + } + } + return false; + } + + /** + * @noreference This is internal helper method to support compatibility with previous versions + * which is not intended to be referenced by clients. + */ + public static boolean isLegacyScannerDiscoveryOn(ICConfigurationDescription cfgDescription) { + IProject project = null; + if (cfgDescription != null) { + ICProjectDescription prjDescription = cfgDescription.getProjectDescription(); + if (prjDescription != null) { + project = prjDescription.getProject(); + } + } + return !isLanguageSettingsProvidersFunctionalityEnabled(project) || isLegacyProviderOn(cfgDescription); + } + + /** + * @noreference This is internal helper method to support compatibility with previous versions + * which is not intended to be referenced by clients. + */ + public static boolean isLegacyScannerDiscoveryOn(IProject project) { + ICConfigurationDescription cfgDescription = null; + ICProjectDescription prjDescription = CoreModel.getDefault().getProjectDescription(project); + if (prjDescription != null) { + cfgDescription = prjDescription.getActiveConfiguration(); + } + return !isLanguageSettingsProvidersFunctionalityEnabled(project) || isLegacyProviderOn(cfgDescription); + } + + /** + * Return list containing User provider and one of wrapper providers to support legacy projects (backward compatibility). + * + * @noreference This is internal helper method to support compatibility with previous versions + * which is not intended to be referenced by clients. + * @since 5.5 + */ + public static String[] getDefaultProviderIdsLegacy(ICConfigurationDescription cfgDescription) { + boolean useScannerInfoProviderExtension = new ScannerInfoExtensionLanguageSettingsProvider().getScannerInfoProvider(cfgDescription) != null; + String legacyProviderId; + if (useScannerInfoProviderExtension) { + legacyProviderId = SI_LANGUAGE_SETTINGS_PROVIDER_ID; + } else if (CProjectDescriptionManager.getInstance().isNewStyleCfg(cfgDescription)) { + legacyProviderId = MBS_LANGUAGE_SETTINGS_PROVIDER_ID; + } else { + legacyProviderId = PATH_ENTRY_MANAGER_LANGUAGE_SETTINGS_PROVIDER_ID; + } + + return new String[] {USER_LANGUAGE_SETTINGS_PROVIDER_ID, ReferencedProjectsLanguageSettingsProvider.ID, legacyProviderId}; + } + + /** + * Checks if the provider is applicable for configuration from backward compatibility point of view + * + * @noreference This is internal helper method to support compatibility with previous versions + * which is not intended to be referenced by clients. + * @since 5.5 + */ + public static boolean isProviderCompatible(String providerId, ICConfigurationDescription cfgDescription) { + if (cfgDescription != null) { + boolean useScannerInfoProviderExtension = new ScannerInfoExtensionLanguageSettingsProvider().getScannerInfoProvider(cfgDescription) != null; + if (SI_LANGUAGE_SETTINGS_PROVIDER_ID.equals(providerId)) { + return useScannerInfoProviderExtension; + } + + boolean isNewStyleCfg = CProjectDescriptionManager.getInstance().isNewStyleCfg(cfgDescription); + if (MBS_LANGUAGE_SETTINGS_PROVIDER_ID.equals(providerId)) { + return !useScannerInfoProviderExtension && isNewStyleCfg; + } + + if (PATH_ENTRY_MANAGER_LANGUAGE_SETTINGS_PROVIDER_ID.equals(providerId)) { + return !useScannerInfoProviderExtension && !isNewStyleCfg; + } + } + + return true; + } + + /** + * If not defined yet, define property that controls if language settings providers functionality enabled for a given project. + * Workspace preference is checked and the project property is set to match it. + * + * @param project - project to define enablement. + * @since 5.5 + */ + public static void defineLanguageSettingsEnablement(IProject project) { + if (project != null && ! ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityDefined(project)) { + boolean isPreferenceEnabled = ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityEnabled(null); + ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, isPreferenceEnabled); + } + } + + /** + * Returns the values of scanner discovery profiles (scannerConfigDiscoveryProfileId) which were deprecated + * and replaced with language settings providers in plugin.xml. + * This (temporary) function serves as fail-safe switch during the transition. + * + * @param id - can be id of either org.eclipse.cdt.managedbuilder.internal.core.InputType + * or org.eclipse.cdt.managedbuilder.internal.core.ToolChain. + * @return legacy scannerConfigDiscoveryProfileId. + */ + @SuppressWarnings("nls") + public static String getDeprecatedLegacyProfiles(String id) { + if (legacyProfiles == null) { + legacyProfiles = new HashMap<String, String>(); + + // InputTypes + legacyProfiles.put("cdt.managedbuild.tool.gnu.c.compiler.input", "org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC|org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile"); + legacyProfiles.put("cdt.managedbuild.tool.gnu.cpp.compiler.input", "org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP|org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile"); + legacyProfiles.put("cdt.managedbuild.tool.gnu.c.compiler.input.cygwin", "org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC"); + legacyProfiles.put("cdt.managedbuild.tool.gnu.cpp.compiler.input.cygwin", "org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP"); + legacyProfiles.put("cdt.managedbuild.tool.xlc.c.compiler.input", "org.eclipse.cdt.managedbuilder.xlc.core.XLCManagedMakePerProjectProfile"); + legacyProfiles.put("cdt.managedbuild.tool.xlc.cpp.c.compiler.input", "org.eclipse.cdt.managedbuilder.xlc.core.XLCManagedMakePerProjectProfile"); + legacyProfiles.put("cdt.managedbuild.tool.xlc.cpp.compiler.input", "org.eclipse.cdt.managedbuilder.xlc.core.XLCManagedMakePerProjectProfileCPP"); + + // Toolchains + } + + return legacyProfiles.get(id); + } + +} 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 1cb99ec7ee5..be3ed312b7b 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 @@ -1,437 +1,437 @@ -/*******************************************************************************
- * Copyright (c) 2000, 2014 QNX Software Systems 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:
- * QNX Software Systems - Initial API and implementation
- * Markus Schorn (Wind River Systems)
- * Anton Leherbauer (Wind River Systems)
+/******************************************************************************* + * Copyright (c) 2000, 2014 QNX Software Systems 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: + * QNX Software Systems - Initial API and implementation + * Markus Schorn (Wind River Systems) + * Anton Leherbauer (Wind River Systems) *******************************************************************************/ -package org.eclipse.cdt.core.model;
-
-import java.net.URI;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IPath;
-
-/**
- * Common protocol for all elements provided by the C model.
- *
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
- */
-public interface ICElement extends IAdaptable {
- /** @since 5.6 */
- public static final ICElement[] EMPTY_ARRAY = {};
-
- /**
- * IResource from 10-20
- */
-
- /**
- * Constant representing a C Root workspace (IWorkspaceRoot object).
- * A C element with this type can be safely cast to <code>ICModel</code>.
- */
- static final int C_MODEL = 10;
-
- /**
- * Constant representing a C project (IProject object).
- * A C element with this type can be safely cast to <code>ICProject</code>.
- */
- static final int C_PROJECT = 11;
-
- /**
- * Constant representing a folder (ICContainer object).
- * A C element with this type can be safely cast to <code>ICContainer</code>.
- */
- static final int C_CCONTAINER = 12;
-
- static final int C_BINARY = 14;
-
- static final int C_ARCHIVE = 18;
- /**
- * Virtual container serving as a place holder.
- */
- static final int C_VCONTAINER = 30;
-
- /**
- * Constant representing a C/C++ children of a Translation Unit
- */
- static final int C_UNIT = 60;
-
- /**
- * Namespace.
- */
- static final int C_NAMESPACE = 61;
-
- /**
- * Using.
- */
- static final int C_USING = 62;
-
- /**
- * Enumeration.
- */
- static final int C_ENUMERATION = 63;
-
- /**
- * Declaration of a class without the definition.
- * class C;
- */
- static final int C_CLASS_DECLARATION = 64;
-
- /**
- * Constant representing a class structure.
- */
- static final int C_CLASS = 65;
-
- /**
- * Declaration of a structure without the definition.
- * struct C;
- */
- static final int C_STRUCT_DECLARATION = 66;
-
- /**
- * Constant representing a struct structure.
- */
- static final int C_STRUCT = 67;
-
- /**
- * Declaration of a union without the definition.
- * struct C;
- */
- static final int C_UNION_DECLARATION = 68;
-
- /**
- * Constant representing a union structure.
- */
- static final int C_UNION = 69;
-
- /**
- * A method definition part of a structure(class, struct, union).
- */
- static final int C_METHOD = 70;
-
- /**
- * A method declaration part of a structure(class, struct, union).
- */
- static final int C_METHOD_DECLARATION = 71;
-
- /**
- * A Field definition part of a structure(class, struct, union).
- */
- static final int C_FIELD = 72;
-
- /**
- * a C/C++ function prototype.
- */
- static final int C_FUNCTION_DECLARATION = 73;
-
- /**
- * a C/C++ function definition.
- */
- static final int C_FUNCTION = 74;
-
- /**
- * Preprocessor #include directive.
- */
- static final int C_INCLUDE = 75;
-
- /**
- * Global variable.
- */
- static final int C_VARIABLE = 76;
-
- /**
- * variable Declaration.
- */
- static final int C_VARIABLE_DECLARATION = 77;
-
- /**
- * Local Variable.
- */
- static final int C_VARIABLE_LOCAL = 78;
-
- /**
- * A preprocessor macro.
- */
- static final int C_MACRO = 79;
-
- /**
- * a Typedef.
- */
- static final int C_TYPEDEF = 80;
-
- /**
- * Enumerator.
- */
- static final int C_ENUMERATOR = 81;
-
- /**
- * C++ template class declaration without a definition.
- */
- static final int C_TEMPLATE_CLASS_DECLARATION = 82;
-
- /**
- * C++ template class with definition.
- */
- static final int C_TEMPLATE_CLASS = 83;
-
- /**
- * C++ template struct.
- */
- static final int C_TEMPLATE_STRUCT_DECLARATION = 84;
-
- /**
- * C++ template struct.
- */
- static final int C_TEMPLATE_STRUCT = 85;
-
- /**
- * C++ template union.
- */
- static final int C_TEMPLATE_UNION_DECLARATION = 86;
-
- /**
- * C++ template union.
- */
- static final int C_TEMPLATE_UNION = 87;
-
- /**
- * C++ template function declaration.
- */
- static final int C_TEMPLATE_FUNCTION_DECLARATION = 88;
-
- /**
- * C++ template function.
- */
- static final int C_TEMPLATE_FUNCTION = 89;
-
- /**
- * C++ template method.
- */
- static final int C_TEMPLATE_METHOD_DECLARATION = 90;
-
- /**
- * C++ template method.
- */
- static final int C_TEMPLATE_METHOD = 91;
-
- /**
- * C++ template variable.
- */
- static final int C_TEMPLATE_VARIABLE = 92;
-
- /**
- * An unknown ICElement. Mainly used to determine what elements are not yet implemented.
- * i.e. the new DOM Parser supports open declaration on labels, while the old parser did not
- */
- static final int C_UNKNOWN_DECLARATION = 93;
-
- /**
- * Assembly label.
- *
- * @since 5.0
- */
- static final int ASM_LABEL= 94;
-
- /**
- * @deprecated use {@link IMethodDeclaration#isConstructor()}
- * @noreference This field is not intended to be referenced by clients.
- */
- @Deprecated
- static final int C_CLASS_CTOR = 0x100;
-
- /**
- * @deprecated use {@link IMethodDeclaration#isDestructor()}
- * @noreference This field is not intended to be referenced by clients.
- */
- @Deprecated
- static final int C_CLASS_DTOR = 0x200;
-
- /**
- * @deprecated use {@link IDeclaration#isStatic()}
- * @noreference This field is not intended to be referenced by clients.
- */
- @Deprecated
- static final int C_STORAGE_STATIC = 0x400;
-
- /**
- * @deprecated not used anymore
- * @noreference This field is not intended to be referenced by clients.
- */
- @Deprecated
- static final int C_STORAGE_EXTERN = 0x800;
-
- /**
- * @deprecated use {@link IMember#getVisibility()}
- * @noreference This field is not intended to be referenced by clients.
- */
- @Deprecated
- static final int CPP_PRIVATE = 0x1000;
-
- /**
- * @deprecated use {@link IMember#getVisibility()}
- * @noreference This field is not intended to be referenced by clients.
- */
- @Deprecated
- static final int CPP_PUBLIC = 0x2000;
-
- /**
- * @deprecated use {@link IMember#getVisibility()}
- * @noreference This field is not intended to be referenced by clients.
- */
- @Deprecated
- static final int CPP_PROTECTED = 0x4000;
- /**
- * @deprecated use {@link IMethodDeclaration#isFriend()}
- * @noreference This field is not intended to be referenced by clients.
- */
- @Deprecated
- static final int CPP_FRIEND = 0x8000;
-
- /**
- * Returns whether this C element exists in the model.
- *
- * @return {@code true} if this element exists in the C model
- */
- boolean exists();
-
- /**
- * Returns the first ancestor of this C element that has the given type.
- * Returns {@code null} if no such an ancestor can be found.
- * This is a handle-only method.
- *
- * @param ancestorType the given type
- * @return the first ancestor of this C element that has the given type, {@code null} if no such
- * an ancestor can be found
- * @since 2.0
- */
- ICElement getAncestor(int ancestorType);
-
- /**
- * Returns the name of this element.
- *
- * @return the element name
- */
- String getElementName();
-
- /**
- * Returns this element's kind encoded as an integer.
- * This is a handle-only method.
- *
- * @return the kind of element; one of the constants declared in {@link ICElement}
- */
- int getElementType();
-
- /**
- * Returns the C model.
- *
- * @return the C model
- */
- ICModel getCModel();
-
- /**
- * Returns the C project this element is contained in, or {@code null} if this element
- * is not contained in any C project
- *
- * @return the containing C project, or {@code null} if this element is
- * not contained in a C project
- */
- ICProject getCProject();
-
- /**
- * Returns the element directly containing this element,
- * or {@code null} if this element has no parent.
- *
- * @return the parent element, or {@code null} if this element has no parent
- */
- ICElement getParent();
-
- /**
- * Returns the path to the innermost resource enclosing this element.
- * If this element is not included in an external archive,
- * the path returned is the full, absolute path to the underlying resource,
- * relative to the workbench.
- * If this element is included in an external archive,
- * the path returned is the absolute path to the archive in the file system.
- * This is a handle-only method.
- */
- IPath getPath();
-
- /**
- * Returns an absolute URI corresponding to the innermost file enclosing this element.
- *
- * @since 5.0
- * @return the URI corresponding to the location
- */
- URI getLocationURI();
-
- /**
- * Returns the underlying resource that contains this element, or {@code null} if this element
- * is not contained in a resource.
- *
- * @return the underlying resource, or {@code null} if none
- */
- IResource getUnderlyingResource();
-
- /**
- * Returns the corresponding resource for this element, or {@code null} if this element
- * does not have a corresponding resource.
- *
- * @return the corresponding resource, or {@code null} if none
- */
- IResource getResource();
-
- /**
- * Returns whether this C element is read-only. An element is read-only
- * if its structure cannot be modified by the C model.
- *
- * @return {@code true} if this element is read-only
- */
- boolean isReadOnly();
-
- /**
- * Returns whether the structure of this element is known. For example, for a
- * translation unit that could not be parsed, {@code false} is returned.
- * If the structure of an element is unknown, navigations will return reasonable
- * defaults. For example, {@code getChildren} will return an empty collection.
- * <p>
- * Note: This does not imply anything about consistency with the
- * underlying resource/buffer contents.
- *
- * @return {@code true} if the structure of this element is known
- * @exception CModelException if this element does not exist or if an
- * exception occurs while accessing its corresponding resource
- */
- boolean isStructureKnown() throws CModelException;
-
- /**
- * Accept a visitor and walk the ICElement tree with it.
- *
- * @param visitor
- * @throws CModelException
- */
- void accept(ICElementVisitor visitor) throws CoreException;
-
- /**
- * Returns a string representation of this element handle. The format of the
- * string is not specified; however, the identifier is stable across
- * workspace sessions, and can be used to recreate this handle via the
- * <code>CoreModel.create(String)</code> method.
- * <p>
- * Some element types, like binaries, do not support handle identifiers and
- * return {@code null}.
- *
- * @return the string handle identifier, or {@code null} if the element type is not supported
- * @see CoreModel#create(java.lang.String)
- *
- * @since 5.0
- */
- String getHandleIdentifier();
-}
+package org.eclipse.cdt.core.model; + +import java.net.URI; + +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IPath; + +/** + * Common protocol for all elements provided by the C model. + * + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + */ +public interface ICElement extends IAdaptable { + /** @since 5.6 */ + public static final ICElement[] EMPTY_ARRAY = {}; + + /** + * IResource from 10-20 + */ + + /** + * Constant representing a C Root workspace (IWorkspaceRoot object). + * A C element with this type can be safely cast to <code>ICModel</code>. + */ + static final int C_MODEL = 10; + + /** + * Constant representing a C project (IProject object). + * A C element with this type can be safely cast to <code>ICProject</code>. + */ + static final int C_PROJECT = 11; + + /** + * Constant representing a folder (ICContainer object). + * A C element with this type can be safely cast to <code>ICContainer</code>. + */ + static final int C_CCONTAINER = 12; + + static final int C_BINARY = 14; + + static final int C_ARCHIVE = 18; + /** + * Virtual container serving as a place holder. + */ + static final int C_VCONTAINER = 30; + + /** + * Constant representing a C/C++ children of a Translation Unit + */ + static final int C_UNIT = 60; + + /** + * Namespace. + */ + static final int C_NAMESPACE = 61; + + /** + * Using. + */ + static final int C_USING = 62; + + /** + * Enumeration. + */ + static final int C_ENUMERATION = 63; + + /** + * Declaration of a class without the definition. + * class C; + */ + static final int C_CLASS_DECLARATION = 64; + + /** + * Constant representing a class structure. + */ + static final int C_CLASS = 65; + + /** + * Declaration of a structure without the definition. + * struct C; + */ + static final int C_STRUCT_DECLARATION = 66; + + /** + * Constant representing a struct structure. + */ + static final int C_STRUCT = 67; + + /** + * Declaration of a union without the definition. + * struct C; + */ + static final int C_UNION_DECLARATION = 68; + + /** + * Constant representing a union structure. + */ + static final int C_UNION = 69; + + /** + * A method definition part of a structure(class, struct, union). + */ + static final int C_METHOD = 70; + + /** + * A method declaration part of a structure(class, struct, union). + */ + static final int C_METHOD_DECLARATION = 71; + + /** + * A Field definition part of a structure(class, struct, union). + */ + static final int C_FIELD = 72; + + /** + * a C/C++ function prototype. + */ + static final int C_FUNCTION_DECLARATION = 73; + + /** + * a C/C++ function definition. + */ + static final int C_FUNCTION = 74; + + /** + * Preprocessor #include directive. + */ + static final int C_INCLUDE = 75; + + /** + * Global variable. + */ + static final int C_VARIABLE = 76; + + /** + * variable Declaration. + */ + static final int C_VARIABLE_DECLARATION = 77; + + /** + * Local Variable. + */ + static final int C_VARIABLE_LOCAL = 78; + + /** + * A preprocessor macro. + */ + static final int C_MACRO = 79; + + /** + * a Typedef. + */ + static final int C_TYPEDEF = 80; + + /** + * Enumerator. + */ + static final int C_ENUMERATOR = 81; + + /** + * C++ template class declaration without a definition. + */ + static final int C_TEMPLATE_CLASS_DECLARATION = 82; + + /** + * C++ template class with definition. + */ + static final int C_TEMPLATE_CLASS = 83; + + /** + * C++ template struct. + */ + static final int C_TEMPLATE_STRUCT_DECLARATION = 84; + + /** + * C++ template struct. + */ + static final int C_TEMPLATE_STRUCT = 85; + + /** + * C++ template union. + */ + static final int C_TEMPLATE_UNION_DECLARATION = 86; + + /** + * C++ template union. + */ + static final int C_TEMPLATE_UNION = 87; + + /** + * C++ template function declaration. + */ + static final int C_TEMPLATE_FUNCTION_DECLARATION = 88; + + /** + * C++ template function. + */ + static final int C_TEMPLATE_FUNCTION = 89; + + /** + * C++ template method. + */ + static final int C_TEMPLATE_METHOD_DECLARATION = 90; + + /** + * C++ template method. + */ + static final int C_TEMPLATE_METHOD = 91; + + /** + * C++ template variable. + */ + static final int C_TEMPLATE_VARIABLE = 92; + + /** + * An unknown ICElement. Mainly used to determine what elements are not yet implemented. + * i.e. the new DOM Parser supports open declaration on labels, while the old parser did not + */ + static final int C_UNKNOWN_DECLARATION = 93; + + /** + * Assembly label. + * + * @since 5.0 + */ + static final int ASM_LABEL= 94; + + /** + * @deprecated use {@link IMethodDeclaration#isConstructor()} + * @noreference This field is not intended to be referenced by clients. + */ + @Deprecated + static final int C_CLASS_CTOR = 0x100; + + /** + * @deprecated use {@link IMethodDeclaration#isDestructor()} + * @noreference This field is not intended to be referenced by clients. + */ + @Deprecated + static final int C_CLASS_DTOR = 0x200; + + /** + * @deprecated use {@link IDeclaration#isStatic()} + * @noreference This field is not intended to be referenced by clients. + */ + @Deprecated + static final int C_STORAGE_STATIC = 0x400; + + /** + * @deprecated not used anymore + * @noreference This field is not intended to be referenced by clients. + */ + @Deprecated + static final int C_STORAGE_EXTERN = 0x800; + + /** + * @deprecated use {@link IMember#getVisibility()} + * @noreference This field is not intended to be referenced by clients. + */ + @Deprecated + static final int CPP_PRIVATE = 0x1000; + + /** + * @deprecated use {@link IMember#getVisibility()} + * @noreference This field is not intended to be referenced by clients. + */ + @Deprecated + static final int CPP_PUBLIC = 0x2000; + + /** + * @deprecated use {@link IMember#getVisibility()} + * @noreference This field is not intended to be referenced by clients. + */ + @Deprecated + static final int CPP_PROTECTED = 0x4000; + /** + * @deprecated use {@link IMethodDeclaration#isFriend()} + * @noreference This field is not intended to be referenced by clients. + */ + @Deprecated + static final int CPP_FRIEND = 0x8000; + + /** + * Returns whether this C element exists in the model. + * + * @return {@code true} if this element exists in the C model + */ + boolean exists(); + + /** + * Returns the first ancestor of this C element that has the given type. + * Returns {@code null} if no such an ancestor can be found. + * This is a handle-only method. + * + * @param ancestorType the given type + * @return the first ancestor of this C element that has the given type, {@code null} if no such + * an ancestor can be found + * @since 2.0 + */ + ICElement getAncestor(int ancestorType); + + /** + * Returns the name of this element. + * + * @return the element name + */ + String getElementName(); + + /** + * Returns this element's kind encoded as an integer. + * This is a handle-only method. + * + * @return the kind of element; one of the constants declared in {@link ICElement} + */ + int getElementType(); + + /** + * Returns the C model. + * + * @return the C model + */ + ICModel getCModel(); + + /** + * Returns the C project this element is contained in, or {@code null} if this element + * is not contained in any C project + * + * @return the containing C project, or {@code null} if this element is + * not contained in a C project + */ + ICProject getCProject(); + + /** + * Returns the element directly containing this element, + * or {@code null} if this element has no parent. + * + * @return the parent element, or {@code null} if this element has no parent + */ + ICElement getParent(); + + /** + * Returns the path to the innermost resource enclosing this element. + * If this element is not included in an external archive, + * the path returned is the full, absolute path to the underlying resource, + * relative to the workbench. + * If this element is included in an external archive, + * the path returned is the absolute path to the archive in the file system. + * This is a handle-only method. + */ + IPath getPath(); + + /** + * Returns an absolute URI corresponding to the innermost file enclosing this element. + * + * @since 5.0 + * @return the URI corresponding to the location + */ + URI getLocationURI(); + + /** + * Returns the underlying resource that contains this element, or {@code null} if this element + * is not contained in a resource. + * + * @return the underlying resource, or {@code null} if none + */ + IResource getUnderlyingResource(); + + /** + * Returns the corresponding resource for this element, or {@code null} if this element + * does not have a corresponding resource. + * + * @return the corresponding resource, or {@code null} if none + */ + IResource getResource(); + + /** + * Returns whether this C element is read-only. An element is read-only + * if its structure cannot be modified by the C model. + * + * @return {@code true} if this element is read-only + */ + boolean isReadOnly(); + + /** + * Returns whether the structure of this element is known. For example, for a + * translation unit that could not be parsed, {@code false} is returned. + * If the structure of an element is unknown, navigations will return reasonable + * defaults. For example, {@code getChildren} will return an empty collection. + * <p> + * Note: This does not imply anything about consistency with the + * underlying resource/buffer contents. + * + * @return {@code true} if the structure of this element is known + * @exception CModelException if this element does not exist or if an + * exception occurs while accessing its corresponding resource + */ + boolean isStructureKnown() throws CModelException; + + /** + * Accept a visitor and walk the ICElement tree with it. + * + * @param visitor + * @throws CModelException + */ + void accept(ICElementVisitor visitor) throws CoreException; + + /** + * Returns a string representation of this element handle. The format of the + * string is not specified; however, the identifier is stable across + * workspace sessions, and can be used to recreate this handle via the + * <code>CoreModel.create(String)</code> method. + * <p> + * Some element types, like binaries, do not support handle identifiers and + * return {@code null}. + * + * @return the string handle identifier, or {@code null} if the element type is not supported + * @see CoreModel#create(java.lang.String) + * + * @since 5.0 + */ + String getHandleIdentifier(); +} diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICFileDescription.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICFileDescription.java index 74fef6b7267..298098dd9e0 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICFileDescription.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICFileDescription.java @@ -1,15 +1,15 @@ -/*******************************************************************************
- * Copyright (c) 2007, 2010 Intel Corporation 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:
- * Intel Corporation - Initial API and implementation
+/******************************************************************************* + * Copyright (c) 2007, 2010 Intel Corporation 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: + * Intel Corporation - Initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.core.settings.model;
-
-public interface ICFileDescription extends ICResourceDescription {
- ICLanguageSetting getLanguageSetting();
-}
+package org.eclipse.cdt.core.settings.model; + +public interface ICFileDescription extends ICResourceDescription { + ICLanguageSetting getLanguageSetting(); +} diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsDelta.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsDelta.java index 5aef3614481..282be48054b 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsDelta.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsDelta.java @@ -1,116 +1,116 @@ -/*******************************************************************************
- * Copyright (c) 2011, 2012 Andrew Gvozdev 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:
- * Andrew Gvozdev - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.core.language.settings.providers;
-
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Set;
-import java.util.TreeSet;
-
-import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsStorage;
-import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
-
-
-/**
- * Contains the delta of changes that occurred as a result of modifying
- * language settings entries {@link ICLanguageSettingEntry}. The delta is
- * associated with a configuration description.
- *
- * <p>
- * <strong>EXPERIMENTAL</strong>. This class interface is not stable yet as
- * it is not currently clear how it may need to be used in future. Only bare
- * minimum is provided here at this point (CDT 8.1, Juno).
- * There is no guarantee that this API will work or that it will remain the same.
- * Please do not use this API without consulting with the CDT team.
- * </p>
- *
- * @noextend This interface is not intended to be extended by clients.
- * @noinstantiate This class is not intended to be instantiated by clients.
- */
-public class LanguageSettingsDelta {
- // maps are ordered by providers
- private LinkedHashMap<String/*providerId*/, LanguageSettingsStorage> oldLanguageSettingsState;
- private LinkedHashMap<String/*providerId*/, LanguageSettingsStorage> newLanguageSettingsState;
-
- private Set<String> paths = null;
-
- /**
- * Constructor.
- *
- * @param oldState - old language settings storage state.
- * @param newState - new language settings storage state.
- */
- public LanguageSettingsDelta(LinkedHashMap<String, LanguageSettingsStorage> oldState, LinkedHashMap<String, LanguageSettingsStorage> newState) {
- oldLanguageSettingsState = oldState;
- newLanguageSettingsState = newState;
- }
-
- /**
- * @return resource paths affected by changes represented by this delta.
- */
- public Set<String> getAffectedResourcePaths() {
- if (paths != null) {
- return paths;
- }
-
- paths = new TreeSet<String>();
-
- LanguageSettingsStorage oldCombinedStorage = combineStorage(oldLanguageSettingsState);
- LanguageSettingsStorage newCombinedStorage = combineStorage(newLanguageSettingsState);
-
- for (String lang : oldCombinedStorage.getLanguages()) {
- for (String path : oldCombinedStorage.getResourcePaths(lang)) {
- if (oldCombinedStorage.getSettingEntries(path, lang) != newCombinedStorage.getSettingEntries(path, lang)) {
- if (path == null) {
- // add path of the project
- path = ""; //$NON-NLS-1$
- }
- paths.add(path);
- }
- }
- }
-
- for (String lang : newCombinedStorage.getLanguages()) {
- for (String path : newCombinedStorage.getResourcePaths(lang)) {
- if (newCombinedStorage.getSettingEntries(path, lang) != oldCombinedStorage.getSettingEntries(path, lang)) {
- if (path == null) {
- // add path of the project
- path = ""; //$NON-NLS-1$
- }
- paths.add(path);
- }
- }
- }
-
- return paths;
- }
-
- /**
- * Language settings entries from different providers can overlap. This method resolves all overlapping
- * ones combining entries into one aggregate storage.
- */
- private LanguageSettingsStorage combineStorage(LinkedHashMap<String, LanguageSettingsStorage> state) {
- LanguageSettingsStorage combinedStore = new LanguageSettingsStorage();
- for (LanguageSettingsStorage providerStore : state.values()) {
- for (String lang : providerStore.getLanguages()) {
- for (String path : providerStore.getResourcePaths(lang)) {
- // provider (store) higher on the list overrides others below
- if (combinedStore.getSettingEntries(path, lang) == null) {
- List<ICLanguageSettingEntry> entries = providerStore.getSettingEntries(path, lang);
- combinedStore.setSettingEntries(path, lang, entries);
- }
- }
- }
- }
-
- return combinedStore;
- }
-}
+/******************************************************************************* + * Copyright (c) 2011, 2012 Andrew Gvozdev 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: + * Andrew Gvozdev - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.core.language.settings.providers; + +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Set; +import java.util.TreeSet; + +import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsStorage; +import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; + + +/** + * Contains the delta of changes that occurred as a result of modifying + * language settings entries {@link ICLanguageSettingEntry}. The delta is + * associated with a configuration description. + * + * <p> + * <strong>EXPERIMENTAL</strong>. This class interface is not stable yet as + * it is not currently clear how it may need to be used in future. Only bare + * minimum is provided here at this point (CDT 8.1, Juno). + * There is no guarantee that this API will work or that it will remain the same. + * Please do not use this API without consulting with the CDT team. + * </p> + * + * @noextend This interface is not intended to be extended by clients. + * @noinstantiate This class is not intended to be instantiated by clients. + */ +public class LanguageSettingsDelta { + // maps are ordered by providers + private LinkedHashMap<String/*providerId*/, LanguageSettingsStorage> oldLanguageSettingsState; + private LinkedHashMap<String/*providerId*/, LanguageSettingsStorage> newLanguageSettingsState; + + private Set<String> paths = null; + + /** + * Constructor. + * + * @param oldState - old language settings storage state. + * @param newState - new language settings storage state. + */ + public LanguageSettingsDelta(LinkedHashMap<String, LanguageSettingsStorage> oldState, LinkedHashMap<String, LanguageSettingsStorage> newState) { + oldLanguageSettingsState = oldState; + newLanguageSettingsState = newState; + } + + /** + * @return resource paths affected by changes represented by this delta. + */ + public Set<String> getAffectedResourcePaths() { + if (paths != null) { + return paths; + } + + paths = new TreeSet<String>(); + + LanguageSettingsStorage oldCombinedStorage = combineStorage(oldLanguageSettingsState); + LanguageSettingsStorage newCombinedStorage = combineStorage(newLanguageSettingsState); + + for (String lang : oldCombinedStorage.getLanguages()) { + for (String path : oldCombinedStorage.getResourcePaths(lang)) { + if (oldCombinedStorage.getSettingEntries(path, lang) != newCombinedStorage.getSettingEntries(path, lang)) { + if (path == null) { + // add path of the project + path = ""; //$NON-NLS-1$ + } + paths.add(path); + } + } + } + + for (String lang : newCombinedStorage.getLanguages()) { + for (String path : newCombinedStorage.getResourcePaths(lang)) { + if (newCombinedStorage.getSettingEntries(path, lang) != oldCombinedStorage.getSettingEntries(path, lang)) { + if (path == null) { + // add path of the project + path = ""; //$NON-NLS-1$ + } + paths.add(path); + } + } + } + + return paths; + } + + /** + * Language settings entries from different providers can overlap. This method resolves all overlapping + * ones combining entries into one aggregate storage. + */ + private LanguageSettingsStorage combineStorage(LinkedHashMap<String, LanguageSettingsStorage> state) { + LanguageSettingsStorage combinedStore = new LanguageSettingsStorage(); + for (LanguageSettingsStorage providerStore : state.values()) { + for (String lang : providerStore.getLanguages()) { + for (String path : providerStore.getResourcePaths(lang)) { + // provider (store) higher on the list overrides others below + if (combinedStore.getSettingEntries(path, lang) == null) { + List<ICLanguageSettingEntry> entries = providerStore.getSettingEntries(path, lang); + combinedStore.setSettingEntries(path, lang, entries); + } + } + } + } + + return combinedStore; + } +} diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsSerializableStorage.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsSerializableStorage.java index 5e5cbeea774..a74154de47a 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsSerializableStorage.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsSerializableStorage.java @@ -1,228 +1,228 @@ -/*******************************************************************************
- * Copyright (c) 2011, 2012 Andrew Gvozdev 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:
- * Andrew Gvozdev - initial API and implementation
+/******************************************************************************* + * Copyright (c) 2011, 2012 Andrew Gvozdev 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: + * Andrew Gvozdev - initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.internal.core.language.settings.providers;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsStorage;
-import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
-import org.eclipse.cdt.core.settings.model.ICSettingEntry;
-import org.eclipse.cdt.core.settings.model.util.CDataUtil;
-import org.eclipse.cdt.core.settings.model.util.LanguageSettingEntriesSerializer;
-import org.eclipse.cdt.internal.core.XmlUtil;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * The class representing persistent storage for language settings entries {@link ICLanguageSettingEntry}.
- */
-public class LanguageSettingsSerializableStorage extends LanguageSettingsStorage {
- private static final String ELEM_LANGUAGE = "language"; //$NON-NLS-1$
- private static final String ATTR_LANGUAGE_ID = "id"; //$NON-NLS-1$
- private static final String ELEM_RESOURCE = "resource"; //$NON-NLS-1$
- private static final String ATTR_PROJECT_PATH = "project-relative-path"; //$NON-NLS-1$
-
- private static final String ELEM_ENTRY = LanguageSettingsExtensionManager.ELEM_ENTRY;
- private static final String ATTR_ENTRY_KIND = LanguageSettingsExtensionManager.ATTR_ENTRY_KIND;
- private static final String ATTR_ENTRY_NAME = LanguageSettingsExtensionManager.ATTR_ENTRY_NAME;
- private static final String ATTR_ENTRY_VALUE = LanguageSettingsExtensionManager.ATTR_ENTRY_VALUE;
- private static final String ELEM_ENTRY_FLAG = LanguageSettingsExtensionManager.ELEM_ENTRY_FLAG;
-
- /**
- * Serialize the provider entries under parent XML element.
- *
- * @param elementProvider - element where to serialize the entries.
- */
- public void serializeEntries(Element elementProvider) {
- synchronized (fStorage) {
- for (Entry<String, Map<String, List<ICLanguageSettingEntry>>> entryLang : fStorage.entrySet()) {
- serializeLanguage(elementProvider, entryLang.getKey(), entryLang.getValue());
- }
- }
- }
-
- /**
- * Serialize the provider entries for a given language list.
- */
- private void serializeLanguage(Element parentElement, String langId, Map<String, List<ICLanguageSettingEntry>> langMap) {
- if (langId!=null) {
- Element elementLanguage = XmlUtil.appendElement(parentElement, ELEM_LANGUAGE, new String[] {ATTR_LANGUAGE_ID, langId});
- parentElement = elementLanguage;
- }
- for (Entry<String, List<ICLanguageSettingEntry>> entryRc : langMap.entrySet()) {
- serializeResource(parentElement, entryRc.getKey(), entryRc.getValue());
- }
- }
-
- /**
- * Serialize the provider entries for a given resource list.
- */
- private void serializeResource(Element parentElement, String rcProjectPath, List<ICLanguageSettingEntry> rcList) {
- if (rcProjectPath!=null) {
- Element elementRc = XmlUtil.appendElement(parentElement, ELEM_RESOURCE, new String[] {ATTR_PROJECT_PATH, rcProjectPath});
- parentElement = elementRc;
- }
- serializeSettingEntries(parentElement, rcList);
- }
-
- /**
- * Serialize given settings entries.
- */
- private void serializeSettingEntries(Element parentElement, List<ICLanguageSettingEntry> settingEntries) {
- for (ICLanguageSettingEntry entry : settingEntries) {
- Element elementSettingEntry = XmlUtil.appendElement(parentElement, ELEM_ENTRY, new String[] {
- ATTR_ENTRY_KIND, LanguageSettingEntriesSerializer.kindToString(entry.getKind()),
- ATTR_ENTRY_NAME, entry.getName(),
- });
- switch (entry.getKind()) {
- case ICSettingEntry.MACRO:
- elementSettingEntry.setAttribute(ATTR_ENTRY_VALUE, entry.getValue());
- break;
-// case ICLanguageSettingEntry.LIBRARY_FILE:
-// // YAGNI: sourceAttachment fields may need to be covered
-// break;
- }
- int flags = entry.getFlags();
- if (flags != 0) {
- // Element elementFlag =
- XmlUtil.appendElement(elementSettingEntry, ELEM_ENTRY_FLAG, new String[] {
- ATTR_ENTRY_VALUE, LanguageSettingEntriesSerializer.composeFlagsString(entry.getFlags())
- });
- }
- }
- }
-
- /**
- * Load provider entries from XML provider element.
- *
- * @param providerNode - parent XML element "provider" where entries are defined.
- */
- public void loadEntries(Element providerNode) {
- List<ICLanguageSettingEntry> settings = new ArrayList<ICLanguageSettingEntry>();
- NodeList nodes = providerNode.getChildNodes();
- for (int i=0;i<nodes.getLength();i++) {
- Node elementNode = nodes.item(i);
- if (elementNode.getNodeType() != Node.ELEMENT_NODE)
- continue;
-
- if (ELEM_LANGUAGE.equals(elementNode.getNodeName())) {
- loadLanguageElement(elementNode, null);
- } else if (ELEM_RESOURCE.equals(elementNode.getNodeName())) {
- loadResourceElement(elementNode, null, null);
- } else if (ELEM_ENTRY.equals(elementNode.getNodeName())) {
- ICLanguageSettingEntry entry = loadSettingEntry(elementNode);
- if (entry!=null) {
- settings.add(entry);
- }
- }
- }
- // set settings
- if (settings.size() > 0) {
- setSettingEntries(null, null, settings);
- }
- }
-
- /**
- * Load a setting entry from XML element.
- */
- private ICLanguageSettingEntry loadSettingEntry(Node parentElement) {
- String settingKind = XmlUtil.determineAttributeValue(parentElement, ATTR_ENTRY_KIND);
- String settingName = XmlUtil.determineAttributeValue(parentElement, ATTR_ENTRY_NAME);
-
- NodeList flagNodes = parentElement.getChildNodes();
- int flags = 0;
- for (int i=0;i<flagNodes.getLength();i++) {
- Node flagNode = flagNodes.item(i);
- if (flagNode.getNodeType() != Node.ELEMENT_NODE || !ELEM_ENTRY_FLAG.equals(flagNode.getNodeName()))
- continue;
-
- String settingFlags = XmlUtil.determineAttributeValue(flagNode, ATTR_ENTRY_VALUE);
- int bitFlag = LanguageSettingEntriesSerializer.composeFlags(settingFlags);
- flags |= bitFlag;
-
- }
-
- String settingValue = null;
- int kind = LanguageSettingEntriesSerializer.stringToKind(settingKind);
- if (kind == ICSettingEntry.MACRO)
- settingValue = XmlUtil.determineAttributeValue(parentElement, ATTR_ENTRY_VALUE);
- ICLanguageSettingEntry entry = (ICLanguageSettingEntry) CDataUtil.createEntry(kind, settingName, settingValue, null, flags);
- return entry;
- }
-
- /**
- * Load entries defined in language element.
- */
- private void loadLanguageElement(Node parentNode, String cfgId) {
- String langId = XmlUtil.determineAttributeValue(parentNode, ATTR_LANGUAGE_ID);
- if (langId.length() == 0) {
- langId=null;
- }
-
- List<ICLanguageSettingEntry> settings = new ArrayList<ICLanguageSettingEntry>();
- NodeList nodes = parentNode.getChildNodes();
- for (int i=0;i<nodes.getLength();i++) {
- Node elementNode = nodes.item(i);
- if (elementNode.getNodeType() != Node.ELEMENT_NODE)
- continue;
-
- if (ELEM_RESOURCE.equals(elementNode.getNodeName())) {
- loadResourceElement(elementNode, cfgId, langId);
- } else if (ELEM_ENTRY.equals(elementNode.getNodeName())) {
- ICLanguageSettingEntry entry = loadSettingEntry(elementNode);
- if (entry!=null) {
- settings.add(entry);
- }
- }
- }
- // set settings
- if (settings.size() > 0) {
- setSettingEntries(null, langId, settings);
- }
- }
-
- /**
- * Load entries defined in resource element.
- */
- private void loadResourceElement(Node parentNode, String cfgId, String langId) {
- String rcProjectPath = XmlUtil.determineAttributeValue(parentNode, ATTR_PROJECT_PATH);
-
- List<ICLanguageSettingEntry> settings = new ArrayList<ICLanguageSettingEntry>();
- NodeList nodes = parentNode.getChildNodes();
- for (int i=0;i<nodes.getLength();i++) {
- Node elementNode = nodes.item(i);
- if (elementNode.getNodeType() != Node.ELEMENT_NODE)
- continue;
-
- if (ELEM_ENTRY.equals(elementNode.getNodeName())) {
- ICLanguageSettingEntry entry = loadSettingEntry(elementNode);
- if (entry!=null) {
- settings.add(entry);
- }
- }
- }
-
- // set settings
- if (settings.size() > 0) {
- setSettingEntries(rcProjectPath, langId, settings);
- }
- }
-
- @Override
- public LanguageSettingsSerializableStorage clone() throws CloneNotSupportedException {
- return (LanguageSettingsSerializableStorage) super.clone();
- }
-
-}
+package org.eclipse.cdt.internal.core.language.settings.providers; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsStorage; +import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; +import org.eclipse.cdt.core.settings.model.ICSettingEntry; +import org.eclipse.cdt.core.settings.model.util.CDataUtil; +import org.eclipse.cdt.core.settings.model.util.LanguageSettingEntriesSerializer; +import org.eclipse.cdt.internal.core.XmlUtil; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +/** + * The class representing persistent storage for language settings entries {@link ICLanguageSettingEntry}. + */ +public class LanguageSettingsSerializableStorage extends LanguageSettingsStorage { + private static final String ELEM_LANGUAGE = "language"; //$NON-NLS-1$ + private static final String ATTR_LANGUAGE_ID = "id"; //$NON-NLS-1$ + private static final String ELEM_RESOURCE = "resource"; //$NON-NLS-1$ + private static final String ATTR_PROJECT_PATH = "project-relative-path"; //$NON-NLS-1$ + + private static final String ELEM_ENTRY = LanguageSettingsExtensionManager.ELEM_ENTRY; + private static final String ATTR_ENTRY_KIND = LanguageSettingsExtensionManager.ATTR_ENTRY_KIND; + private static final String ATTR_ENTRY_NAME = LanguageSettingsExtensionManager.ATTR_ENTRY_NAME; + private static final String ATTR_ENTRY_VALUE = LanguageSettingsExtensionManager.ATTR_ENTRY_VALUE; + private static final String ELEM_ENTRY_FLAG = LanguageSettingsExtensionManager.ELEM_ENTRY_FLAG; + + /** + * Serialize the provider entries under parent XML element. + * + * @param elementProvider - element where to serialize the entries. + */ + public void serializeEntries(Element elementProvider) { + synchronized (fStorage) { + for (Entry<String, Map<String, List<ICLanguageSettingEntry>>> entryLang : fStorage.entrySet()) { + serializeLanguage(elementProvider, entryLang.getKey(), entryLang.getValue()); + } + } + } + + /** + * Serialize the provider entries for a given language list. + */ + private void serializeLanguage(Element parentElement, String langId, Map<String, List<ICLanguageSettingEntry>> langMap) { + if (langId!=null) { + Element elementLanguage = XmlUtil.appendElement(parentElement, ELEM_LANGUAGE, new String[] {ATTR_LANGUAGE_ID, langId}); + parentElement = elementLanguage; + } + for (Entry<String, List<ICLanguageSettingEntry>> entryRc : langMap.entrySet()) { + serializeResource(parentElement, entryRc.getKey(), entryRc.getValue()); + } + } + + /** + * Serialize the provider entries for a given resource list. + */ + private void serializeResource(Element parentElement, String rcProjectPath, List<ICLanguageSettingEntry> rcList) { + if (rcProjectPath!=null) { + Element elementRc = XmlUtil.appendElement(parentElement, ELEM_RESOURCE, new String[] {ATTR_PROJECT_PATH, rcProjectPath}); + parentElement = elementRc; + } + serializeSettingEntries(parentElement, rcList); + } + + /** + * Serialize given settings entries. + */ + private void serializeSettingEntries(Element parentElement, List<ICLanguageSettingEntry> settingEntries) { + for (ICLanguageSettingEntry entry : settingEntries) { + Element elementSettingEntry = XmlUtil.appendElement(parentElement, ELEM_ENTRY, new String[] { + ATTR_ENTRY_KIND, LanguageSettingEntriesSerializer.kindToString(entry.getKind()), + ATTR_ENTRY_NAME, entry.getName(), + }); + switch (entry.getKind()) { + case ICSettingEntry.MACRO: + elementSettingEntry.setAttribute(ATTR_ENTRY_VALUE, entry.getValue()); + break; +// case ICLanguageSettingEntry.LIBRARY_FILE: +// // YAGNI: sourceAttachment fields may need to be covered +// break; + } + int flags = entry.getFlags(); + if (flags != 0) { + // Element elementFlag = + XmlUtil.appendElement(elementSettingEntry, ELEM_ENTRY_FLAG, new String[] { + ATTR_ENTRY_VALUE, LanguageSettingEntriesSerializer.composeFlagsString(entry.getFlags()) + }); + } + } + } + + /** + * Load provider entries from XML provider element. + * + * @param providerNode - parent XML element "provider" where entries are defined. + */ + public void loadEntries(Element providerNode) { + List<ICLanguageSettingEntry> settings = new ArrayList<ICLanguageSettingEntry>(); + NodeList nodes = providerNode.getChildNodes(); + for (int i=0;i<nodes.getLength();i++) { + Node elementNode = nodes.item(i); + if (elementNode.getNodeType() != Node.ELEMENT_NODE) + continue; + + if (ELEM_LANGUAGE.equals(elementNode.getNodeName())) { + loadLanguageElement(elementNode, null); + } else if (ELEM_RESOURCE.equals(elementNode.getNodeName())) { + loadResourceElement(elementNode, null, null); + } else if (ELEM_ENTRY.equals(elementNode.getNodeName())) { + ICLanguageSettingEntry entry = loadSettingEntry(elementNode); + if (entry!=null) { + settings.add(entry); + } + } + } + // set settings + if (settings.size() > 0) { + setSettingEntries(null, null, settings); + } + } + + /** + * Load a setting entry from XML element. + */ + private ICLanguageSettingEntry loadSettingEntry(Node parentElement) { + String settingKind = XmlUtil.determineAttributeValue(parentElement, ATTR_ENTRY_KIND); + String settingName = XmlUtil.determineAttributeValue(parentElement, ATTR_ENTRY_NAME); + + NodeList flagNodes = parentElement.getChildNodes(); + int flags = 0; + for (int i=0;i<flagNodes.getLength();i++) { + Node flagNode = flagNodes.item(i); + if (flagNode.getNodeType() != Node.ELEMENT_NODE || !ELEM_ENTRY_FLAG.equals(flagNode.getNodeName())) + continue; + + String settingFlags = XmlUtil.determineAttributeValue(flagNode, ATTR_ENTRY_VALUE); + int bitFlag = LanguageSettingEntriesSerializer.composeFlags(settingFlags); + flags |= bitFlag; + + } + + String settingValue = null; + int kind = LanguageSettingEntriesSerializer.stringToKind(settingKind); + if (kind == ICSettingEntry.MACRO) + settingValue = XmlUtil.determineAttributeValue(parentElement, ATTR_ENTRY_VALUE); + ICLanguageSettingEntry entry = (ICLanguageSettingEntry) CDataUtil.createEntry(kind, settingName, settingValue, null, flags); + return entry; + } + + /** + * Load entries defined in language element. + */ + private void loadLanguageElement(Node parentNode, String cfgId) { + String langId = XmlUtil.determineAttributeValue(parentNode, ATTR_LANGUAGE_ID); + if (langId.length() == 0) { + langId=null; + } + + List<ICLanguageSettingEntry> settings = new ArrayList<ICLanguageSettingEntry>(); + NodeList nodes = parentNode.getChildNodes(); + for (int i=0;i<nodes.getLength();i++) { + Node elementNode = nodes.item(i); + if (elementNode.getNodeType() != Node.ELEMENT_NODE) + continue; + + if (ELEM_RESOURCE.equals(elementNode.getNodeName())) { + loadResourceElement(elementNode, cfgId, langId); + } else if (ELEM_ENTRY.equals(elementNode.getNodeName())) { + ICLanguageSettingEntry entry = loadSettingEntry(elementNode); + if (entry!=null) { + settings.add(entry); + } + } + } + // set settings + if (settings.size() > 0) { + setSettingEntries(null, langId, settings); + } + } + + /** + * Load entries defined in resource element. + */ + private void loadResourceElement(Node parentNode, String cfgId, String langId) { + String rcProjectPath = XmlUtil.determineAttributeValue(parentNode, ATTR_PROJECT_PATH); + + List<ICLanguageSettingEntry> settings = new ArrayList<ICLanguageSettingEntry>(); + NodeList nodes = parentNode.getChildNodes(); + for (int i=0;i<nodes.getLength();i++) { + Node elementNode = nodes.item(i); + if (elementNode.getNodeType() != Node.ELEMENT_NODE) + continue; + + if (ELEM_ENTRY.equals(elementNode.getNodeName())) { + ICLanguageSettingEntry entry = loadSettingEntry(elementNode); + if (entry!=null) { + settings.add(entry); + } + } + } + + // set settings + if (settings.size() > 0) { + setSettingEntries(rcProjectPath, langId, settings); + } + } + + @Override + public LanguageSettingsSerializableStorage clone() throws CloneNotSupportedException { + return (LanguageSettingsSerializableStorage) super.clone(); + } + +} 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 ee3ae24a027..8e390c88644 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 @@ -1,165 +1,165 @@ -/*******************************************************************************
- * Copyright (c) 2013, 2013 Andrew Gvozdev 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:
- * Andrew Gvozdev - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.core.language.settings.providers;
-
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.TreeSet;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsBaseProvider;
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.core.model.IContainerEntry;
-import org.eclipse.cdt.core.model.IIncludeEntry;
-import org.eclipse.cdt.core.model.IIncludeFileEntry;
-import org.eclipse.cdt.core.model.ILibraryEntry;
-import org.eclipse.cdt.core.model.IMacroEntry;
-import org.eclipse.cdt.core.model.IMacroFileEntry;
-import org.eclipse.cdt.core.model.IPathEntry;
-import org.eclipse.cdt.core.model.IPathEntryContainer;
-import org.eclipse.cdt.core.model.IPathEntryContainerExtension;
-import org.eclipse.cdt.core.resources.IPathEntryStore;
-import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
-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.core.settings.model.util.CDataUtil;
-import org.eclipse.cdt.internal.core.model.CModelManager;
-import org.eclipse.cdt.internal.core.model.DefaultPathEntryStore;
-import org.eclipse.cdt.internal.core.model.PathEntryManager;
-import org.eclipse.cdt.internal.core.model.PathEntryUtil;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-
-/**
- * Wrapper class intended to provide backward compatibility with ScannerInfo supplied by {@link PathEntryManager}.
- */
-public class PathEntryScannerInfoLanguageSettingsProvider extends LanguageSettingsBaseProvider {
- @Override
- public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) {
- if (cfgDescription == null) {
- return null;
- }
- ICProjectDescription prjDescription = cfgDescription.getProjectDescription();
- if (prjDescription == null) {
- return null;
- }
-
- IProject project = prjDescription.getProject();
- ICProject cproject = CModelManager.getDefault().getCModel().getCProject(project);
- IPath projectPath = cproject.getPath();
-
- // using map of sets to support specific ordering of entries
- LinkedHashMap<Integer, Set<IPathEntry>> pathEntriesMap = new LinkedHashMap<Integer, Set<IPathEntry>>();
- pathEntriesMap.put(IPathEntry.CDT_INCLUDE, new LinkedHashSet<IPathEntry>());
- // keep macros sorted
- pathEntriesMap.put(IPathEntry.CDT_MACRO, new TreeSet<IPathEntry>(new Comparator<IPathEntry>() {
- @Override
- public int compare(IPathEntry macro1, IPathEntry macro2) {
- if (macro1 instanceof IMacroEntry && macro2 instanceof IMacroEntry) {
- return ((IMacroEntry)macro1).getMacroName().compareTo(((IMacroEntry)macro2).getMacroName());
- }
- return 0;
- }
- }));
- pathEntriesMap.put(IPathEntry.CDT_INCLUDE_FILE, new LinkedHashSet<IPathEntry>());
- pathEntriesMap.put(IPathEntry.CDT_MACRO_FILE, new LinkedHashSet<IPathEntry>());
- pathEntriesMap.put(IPathEntry.CDT_LIBRARY, new LinkedHashSet<IPathEntry>());
-
- IPathEntryStore pathEntryStore = new DefaultPathEntryStore(project);
- int typesMask = IPathEntry.CDT_INCLUDE | IPathEntry.CDT_MACRO | IPathEntry.CDT_INCLUDE_FILE | IPathEntry.CDT_MACRO_FILE | IPathEntry.CDT_LIBRARY;
- try {
- IPathEntry[] storePathEntries = pathEntryStore.getRawPathEntries();
- for (IPathEntry storePathEntry : storePathEntries) {
- if (storePathEntry instanceof IContainerEntry) {
- try {
- IPathEntryContainer container = PathEntryManager.getDefault().getPathEntryContainer((IContainerEntry) storePathEntry, cproject);
- if (container != null) {
- IPathEntry[] pathEntries = null;
- if (container instanceof IPathEntryContainerExtension) {
- pathEntries = ((IPathEntryContainerExtension)container).getPathEntries(rc.getFullPath(), typesMask);
- } else {
- pathEntries = container.getPathEntries();
- }
- if (pathEntries != null) {
- for (IPathEntry pathEntry : pathEntries) {
- collectPathEntry(pathEntriesMap, projectPath, pathEntry);
- }
- }
- }
- } catch (CoreException e) {
- CCorePlugin.log(e);
- }
- } else {
- collectPathEntry(pathEntriesMap, projectPath, storePathEntry);
- }
- }
- } catch (CoreException e) {
- CCorePlugin.log(e);
- }
-
- Set<ICLanguageSettingEntry> lsEntries = new LinkedHashSet<ICLanguageSettingEntry>();
- for (Entry<Integer, Set<IPathEntry>> entrySet : pathEntriesMap.entrySet()) {
- Set<IPathEntry> pathEntries = entrySet.getValue();
- for (IPathEntry pathEntry : pathEntries) {
- ICLanguageSettingEntry lsEntry = toLanguageSettingsEntry(pathEntry);
- if (lsEntry != null) {
- lsEntries.add(lsEntry);
- }
- }
- }
-
- return LanguageSettingsSerializableStorage.getPooledList(new ArrayList<ICLanguageSettingEntry>(lsEntries));
- }
-
- private void collectPathEntry(LinkedHashMap<Integer, Set<IPathEntry>> pathEntriesMap, IPath projectPath, IPathEntry pathEntry) {
- switch (pathEntry.getEntryKind()) {
- case IPathEntry.CDT_INCLUDE:
- case IPathEntry.CDT_MACRO:
- case IPathEntry.CDT_INCLUDE_FILE:
- case IPathEntry.CDT_MACRO_FILE:
- case IPathEntry.CDT_LIBRARY:
- IPathEntry resolvedPathEntry = PathEntryUtil.cloneEntryAndExpand(projectPath, pathEntry);
- Set<IPathEntry> set = pathEntriesMap.get(resolvedPathEntry.getEntryKind());
- if (set != null) {
- set.add(resolvedPathEntry);
- }
- }
- }
-
- private ICLanguageSettingEntry toLanguageSettingsEntry(IPathEntry pathEntry) {
- switch (pathEntry.getEntryKind()) {
- case IPathEntry.CDT_INCLUDE:
- IIncludeEntry includeEntry = (IIncludeEntry)pathEntry;
- return CDataUtil.createCIncludePathEntry(includeEntry.getFullIncludePath().toOSString(), includeEntry.isSystemInclude() ? 0 : ICSettingEntry.LOCAL);
- case IPathEntry.CDT_MACRO:
- IMacroEntry macroEntry = (IMacroEntry) pathEntry;
- return CDataUtil.createCMacroEntry(macroEntry.getMacroName(), macroEntry.getMacroValue(), 0);
- case IPathEntry.CDT_INCLUDE_FILE:
- IIncludeFileEntry includeFileEntry = (IIncludeFileEntry) pathEntry;
- return CDataUtil.createCIncludeFileEntry(includeFileEntry.getFullIncludeFilePath().toOSString(), 0);
- case IPathEntry.CDT_MACRO_FILE:
- IMacroFileEntry macroFileEntry = (IMacroFileEntry) pathEntry;
- return CDataUtil.createCMacroFileEntry(macroFileEntry.getFullMacroFilePath().toOSString(), 0);
- case IPathEntry.CDT_LIBRARY:
- ILibraryEntry libraryEntry = (ILibraryEntry) pathEntry;
- return CDataUtil.createCLibraryFileEntry(libraryEntry.getFullLibraryPath().toOSString(), 0);
- }
- return null;
- }
-}
+/******************************************************************************* + * Copyright (c) 2013, 2013 Andrew Gvozdev 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: + * Andrew Gvozdev - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.core.language.settings.providers; + +import java.util.ArrayList; +import java.util.Comparator; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map.Entry; +import java.util.Set; +import java.util.TreeSet; + +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsBaseProvider; +import org.eclipse.cdt.core.model.ICProject; +import org.eclipse.cdt.core.model.IContainerEntry; +import org.eclipse.cdt.core.model.IIncludeEntry; +import org.eclipse.cdt.core.model.IIncludeFileEntry; +import org.eclipse.cdt.core.model.ILibraryEntry; +import org.eclipse.cdt.core.model.IMacroEntry; +import org.eclipse.cdt.core.model.IMacroFileEntry; +import org.eclipse.cdt.core.model.IPathEntry; +import org.eclipse.cdt.core.model.IPathEntryContainer; +import org.eclipse.cdt.core.model.IPathEntryContainerExtension; +import org.eclipse.cdt.core.resources.IPathEntryStore; +import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; +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.core.settings.model.util.CDataUtil; +import org.eclipse.cdt.internal.core.model.CModelManager; +import org.eclipse.cdt.internal.core.model.DefaultPathEntryStore; +import org.eclipse.cdt.internal.core.model.PathEntryManager; +import org.eclipse.cdt.internal.core.model.PathEntryUtil; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; + +/** + * Wrapper class intended to provide backward compatibility with ScannerInfo supplied by {@link PathEntryManager}. + */ +public class PathEntryScannerInfoLanguageSettingsProvider extends LanguageSettingsBaseProvider { + @Override + public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) { + if (cfgDescription == null) { + return null; + } + ICProjectDescription prjDescription = cfgDescription.getProjectDescription(); + if (prjDescription == null) { + return null; + } + + IProject project = prjDescription.getProject(); + ICProject cproject = CModelManager.getDefault().getCModel().getCProject(project); + IPath projectPath = cproject.getPath(); + + // using map of sets to support specific ordering of entries + LinkedHashMap<Integer, Set<IPathEntry>> pathEntriesMap = new LinkedHashMap<Integer, Set<IPathEntry>>(); + pathEntriesMap.put(IPathEntry.CDT_INCLUDE, new LinkedHashSet<IPathEntry>()); + // keep macros sorted + pathEntriesMap.put(IPathEntry.CDT_MACRO, new TreeSet<IPathEntry>(new Comparator<IPathEntry>() { + @Override + public int compare(IPathEntry macro1, IPathEntry macro2) { + if (macro1 instanceof IMacroEntry && macro2 instanceof IMacroEntry) { + return ((IMacroEntry)macro1).getMacroName().compareTo(((IMacroEntry)macro2).getMacroName()); + } + return 0; + } + })); + pathEntriesMap.put(IPathEntry.CDT_INCLUDE_FILE, new LinkedHashSet<IPathEntry>()); + pathEntriesMap.put(IPathEntry.CDT_MACRO_FILE, new LinkedHashSet<IPathEntry>()); + pathEntriesMap.put(IPathEntry.CDT_LIBRARY, new LinkedHashSet<IPathEntry>()); + + IPathEntryStore pathEntryStore = new DefaultPathEntryStore(project); + int typesMask = IPathEntry.CDT_INCLUDE | IPathEntry.CDT_MACRO | IPathEntry.CDT_INCLUDE_FILE | IPathEntry.CDT_MACRO_FILE | IPathEntry.CDT_LIBRARY; + try { + IPathEntry[] storePathEntries = pathEntryStore.getRawPathEntries(); + for (IPathEntry storePathEntry : storePathEntries) { + if (storePathEntry instanceof IContainerEntry) { + try { + IPathEntryContainer container = PathEntryManager.getDefault().getPathEntryContainer((IContainerEntry) storePathEntry, cproject); + if (container != null) { + IPathEntry[] pathEntries = null; + if (container instanceof IPathEntryContainerExtension) { + pathEntries = ((IPathEntryContainerExtension)container).getPathEntries(rc.getFullPath(), typesMask); + } else { + pathEntries = container.getPathEntries(); + } + if (pathEntries != null) { + for (IPathEntry pathEntry : pathEntries) { + collectPathEntry(pathEntriesMap, projectPath, pathEntry); + } + } + } + } catch (CoreException e) { + CCorePlugin.log(e); + } + } else { + collectPathEntry(pathEntriesMap, projectPath, storePathEntry); + } + } + } catch (CoreException e) { + CCorePlugin.log(e); + } + + Set<ICLanguageSettingEntry> lsEntries = new LinkedHashSet<ICLanguageSettingEntry>(); + for (Entry<Integer, Set<IPathEntry>> entrySet : pathEntriesMap.entrySet()) { + Set<IPathEntry> pathEntries = entrySet.getValue(); + for (IPathEntry pathEntry : pathEntries) { + ICLanguageSettingEntry lsEntry = toLanguageSettingsEntry(pathEntry); + if (lsEntry != null) { + lsEntries.add(lsEntry); + } + } + } + + return LanguageSettingsSerializableStorage.getPooledList(new ArrayList<ICLanguageSettingEntry>(lsEntries)); + } + + private void collectPathEntry(LinkedHashMap<Integer, Set<IPathEntry>> pathEntriesMap, IPath projectPath, IPathEntry pathEntry) { + switch (pathEntry.getEntryKind()) { + case IPathEntry.CDT_INCLUDE: + case IPathEntry.CDT_MACRO: + case IPathEntry.CDT_INCLUDE_FILE: + case IPathEntry.CDT_MACRO_FILE: + case IPathEntry.CDT_LIBRARY: + IPathEntry resolvedPathEntry = PathEntryUtil.cloneEntryAndExpand(projectPath, pathEntry); + Set<IPathEntry> set = pathEntriesMap.get(resolvedPathEntry.getEntryKind()); + if (set != null) { + set.add(resolvedPathEntry); + } + } + } + + private ICLanguageSettingEntry toLanguageSettingsEntry(IPathEntry pathEntry) { + switch (pathEntry.getEntryKind()) { + case IPathEntry.CDT_INCLUDE: + IIncludeEntry includeEntry = (IIncludeEntry)pathEntry; + return CDataUtil.createCIncludePathEntry(includeEntry.getFullIncludePath().toOSString(), includeEntry.isSystemInclude() ? 0 : ICSettingEntry.LOCAL); + case IPathEntry.CDT_MACRO: + IMacroEntry macroEntry = (IMacroEntry) pathEntry; + return CDataUtil.createCMacroEntry(macroEntry.getMacroName(), macroEntry.getMacroValue(), 0); + case IPathEntry.CDT_INCLUDE_FILE: + IIncludeFileEntry includeFileEntry = (IIncludeFileEntry) pathEntry; + return CDataUtil.createCIncludeFileEntry(includeFileEntry.getFullIncludeFilePath().toOSString(), 0); + case IPathEntry.CDT_MACRO_FILE: + IMacroFileEntry macroFileEntry = (IMacroFileEntry) pathEntry; + return CDataUtil.createCMacroFileEntry(macroFileEntry.getFullMacroFilePath().toOSString(), 0); + case IPathEntry.CDT_LIBRARY: + ILibraryEntry libraryEntry = (ILibraryEntry) pathEntry; + return CDataUtil.createCLibraryFileEntry(libraryEntry.getFullLibraryPath().toOSString(), 0); + } + return null; + } +} 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 68dc700d0be..3fca1995de1 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 @@ -1,79 +1,79 @@ -/*******************************************************************************
- * Copyright (c) 2013, 2013 Andrew Gvozdev 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:
- * Andrew Gvozdev - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.core.language.settings.providers;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsBaseProvider;
-import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager;
-import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsStorage;
-import org.eclipse.cdt.core.model.CoreModelUtil;
-import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
-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.core.settings.model.util.CDataUtil;
-import org.eclipse.core.resources.IResource;
-
-/**
- * Language settings provider to provide entries exported from referenced projects.
- */
-public class ReferencedProjectsLanguageSettingsProvider extends LanguageSettingsBaseProvider {
- /** 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>() {
- @Override
- protected Boolean initialValue() {
- return false;
- }
- };
-
- @Override
- public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) {
- if (recursiveCallIndicator.get()) {
- // Recursive call indicates that the provider of a referenced project is called.
- // Only exported entries of the original configuration should be considered,
- // entries of referenced projects are not re-exported.
- return null;
- }
-
- if (cfgDescription == null) {
- return null;
- }
- ICProjectDescription prjDescription = cfgDescription.getProjectDescription();
- if (prjDescription == null) {
- return null;
- }
-
- try {
- recursiveCallIndicator.set(true);
- List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
- ICConfigurationDescription[] refCfgDescriptions = CoreModelUtil.getReferencedConfigurationDescriptions(cfgDescription, false);
- for (ICConfigurationDescription refCfgDescription : refCfgDescriptions) {
- List<ICLanguageSettingEntry> refEntries = LanguageSettingsManager.getSettingEntriesByKind(refCfgDescription, rc, languageId, ICSettingEntry.ALL);
- for (ICLanguageSettingEntry refEntry : refEntries) {
- int flags = refEntry.getFlags();
- if ((flags & ICSettingEntry.EXPORTED) == ICSettingEntry.EXPORTED) {
- // create a new entry with EXPORTED flag cleared
- ICLanguageSettingEntry entry = CDataUtil.createEntry(refEntry, flags & ~ICSettingEntry.EXPORTED);
- entries.add(entry);
- }
- }
- }
-
- return LanguageSettingsStorage.getPooledList(new ArrayList<ICLanguageSettingEntry>(entries));
- } finally {
- recursiveCallIndicator.set(false);
- }
- }
-}
+/******************************************************************************* + * Copyright (c) 2013, 2013 Andrew Gvozdev 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: + * Andrew Gvozdev - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.core.language.settings.providers; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsBaseProvider; +import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager; +import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsStorage; +import org.eclipse.cdt.core.model.CoreModelUtil; +import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; +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.core.settings.model.util.CDataUtil; +import org.eclipse.core.resources.IResource; + +/** + * Language settings provider to provide entries exported from referenced projects. + */ +public class ReferencedProjectsLanguageSettingsProvider extends LanguageSettingsBaseProvider { + /** 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>() { + @Override + protected Boolean initialValue() { + return false; + } + }; + + @Override + public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) { + if (recursiveCallIndicator.get()) { + // Recursive call indicates that the provider of a referenced project is called. + // Only exported entries of the original configuration should be considered, + // entries of referenced projects are not re-exported. + return null; + } + + if (cfgDescription == null) { + return null; + } + ICProjectDescription prjDescription = cfgDescription.getProjectDescription(); + if (prjDescription == null) { + return null; + } + + try { + recursiveCallIndicator.set(true); + List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>(); + ICConfigurationDescription[] refCfgDescriptions = CoreModelUtil.getReferencedConfigurationDescriptions(cfgDescription, false); + for (ICConfigurationDescription refCfgDescription : refCfgDescriptions) { + List<ICLanguageSettingEntry> refEntries = LanguageSettingsManager.getSettingEntriesByKind(refCfgDescription, rc, languageId, ICSettingEntry.ALL); + for (ICLanguageSettingEntry refEntry : refEntries) { + int flags = refEntry.getFlags(); + if ((flags & ICSettingEntry.EXPORTED) == ICSettingEntry.EXPORTED) { + // create a new entry with EXPORTED flag cleared + ICLanguageSettingEntry entry = CDataUtil.createEntry(refEntry, flags & ~ICSettingEntry.EXPORTED); + entries.add(entry); + } + } + } + + return LanguageSettingsStorage.getPooledList(new ArrayList<ICLanguageSettingEntry>(entries)); + } finally { + recursiveCallIndicator.set(false); + } + } +} diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/ScannerInfoExtensionLanguageSettingsProvider.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/ScannerInfoExtensionLanguageSettingsProvider.java index 956b7919d1a..ea6cf1054d5 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/ScannerInfoExtensionLanguageSettingsProvider.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/ScannerInfoExtensionLanguageSettingsProvider.java @@ -1,158 +1,158 @@ -/*******************************************************************************
- * Copyright (c) 2013, 2013 Andrew Gvozdev 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:
- * Andrew Gvozdev - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.core.language.settings.providers;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.TreeMap;
-
-import org.eclipse.cdt.core.AbstractCExtension;
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsBaseProvider;
-import org.eclipse.cdt.core.parser.IExtendedScannerInfo;
-import org.eclipse.cdt.core.parser.IScannerInfo;
-import org.eclipse.cdt.core.parser.IScannerInfoProvider;
-import org.eclipse.cdt.core.settings.model.ICConfigExtensionReference;
-import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
-import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
-import org.eclipse.cdt.core.settings.model.ICSettingEntry;
-import org.eclipse.cdt.core.settings.model.util.CDataUtil;
-import org.eclipse.cdt.core.settings.model.util.CExtensionUtil;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-
-/**
- * Wrapper class intended to provide backward compatibility with ScannerInfoProvider defined by org.eclipse.cdt.core.ScannerInfoProvider extension point
- */
-public class ScannerInfoExtensionLanguageSettingsProvider extends LanguageSettingsBaseProvider {
- @Override
- public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) {
- List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
- IScannerInfoProvider scannerInfoProvider = getScannerInfoProvider(cfgDescription);
- if (scannerInfoProvider != null) {
- IScannerInfo si = scannerInfoProvider.getScannerInformation(rc);
- if (si != null) {
- if (si instanceof IExtendedScannerInfo) {
- addLocalIncludePaths(entries, (IExtendedScannerInfo) si);
- }
-
- addSystemIncludePaths(entries, si);
- addDefinedSymbols(entries, si);
-
- if (si instanceof IExtendedScannerInfo) {
- addIncludeFiles(entries, (IExtendedScannerInfo) si);
- addMacroFiles(entries, (IExtendedScannerInfo) si);
- }
-
- if (!entries.isEmpty()) {
- return LanguageSettingsSerializableStorage.getPooledList(entries);
- }
- }
- }
- return null;
- }
-
- /**
- * Return ScannerInfoProvider defined in configuration metadata in .cproject.
- *
- * @param cfgDescription - configuration description.
- * @return an instance of ScannerInfoProvider or {@code null}.
- */
- public IScannerInfoProvider getScannerInfoProvider(ICConfigurationDescription cfgDescription) {
- if (cfgDescription == null || cfgDescription.isPreferenceConfiguration()) {
- return null;
- }
-
- IScannerInfoProvider scannerInfoProvider = null;
- ICConfigExtensionReference[] refs = cfgDescription.get(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID);
- if (refs != null && refs.length > 0) {
- ICConfigExtensionReference ref = refs[0];
- try {
- AbstractCExtension cExtension = null;
- IConfigurationElement el = CExtensionUtil.getFirstConfigurationElement(ref, "cextension", false); //$NON-NLS-1$
- cExtension = (AbstractCExtension)el.createExecutableExtension("run"); //$NON-NLS-1$
- cExtension.setExtensionReference(ref);
- cExtension.setProject(ref.getConfiguration().getProjectDescription().getProject());
- if (cExtension instanceof IScannerInfoProvider) {
- scannerInfoProvider = (IScannerInfoProvider) cExtension;
- }
- } catch (CoreException e) {
- CCorePlugin.log(e);
- }
- }
- return scannerInfoProvider;
- }
-
- /**
- * Add local include paths to the list of entries.
- */
- private void addLocalIncludePaths(List<ICLanguageSettingEntry> entries, IExtendedScannerInfo esi) {
- String[] localIncludePaths = esi.getLocalIncludePath();
- if (localIncludePaths != null) {
- for (String path : localIncludePaths) {
- entries.add(CDataUtil.createCIncludePathEntry(path, ICSettingEntry.LOCAL));
- }
- }
- }
-
- /**
- * Add system include paths to the list of entries.
- */
- private void addSystemIncludePaths(List<ICLanguageSettingEntry> entries, IScannerInfo si) {
- String[] includePaths = si.getIncludePaths();
- if (includePaths != null) {
- for (String path : includePaths) {
- entries.add(CDataUtil.createCIncludePathEntry(path, 0));
- }
- }
- }
-
- /**
- * Add defined macros to the list of entries.
- */
- private void addDefinedSymbols(List<ICLanguageSettingEntry> entries, IScannerInfo si) {
- Map<String, String> definedSymbols = si.getDefinedSymbols();
- if (definedSymbols != null) {
- for (Entry<String, String> entry : new TreeMap<String, String>(definedSymbols).entrySet()) {
- String name = entry.getKey();
- String value = entry.getValue();
- entries.add(CDataUtil.createCMacroEntry(name, value, 0));
- }
- }
- }
-
- /**
- * Add include files to the list of entries.
- */
- private void addIncludeFiles(List<ICLanguageSettingEntry> entries, IExtendedScannerInfo esi) {
- String[] includeFiles = esi.getIncludeFiles();
- if (includeFiles != null) {
- for (String path : includeFiles) {
- entries.add(CDataUtil.createCIncludeFileEntry(path, 0));
- }
- }
- }
-
- /**
- * Add macro files to the list of entries.
- */
- private void addMacroFiles(List<ICLanguageSettingEntry> entries, IExtendedScannerInfo esi) {
- String[] macroFiles = esi.getMacroFiles();
- if (macroFiles != null) {
- for (String path : macroFiles) {
- entries.add(CDataUtil.createCMacroFileEntry(path, 0));
- }
- }
- }
-}
+/******************************************************************************* + * Copyright (c) 2013, 2013 Andrew Gvozdev 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: + * Andrew Gvozdev - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.core.language.settings.providers; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.TreeMap; + +import org.eclipse.cdt.core.AbstractCExtension; +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsBaseProvider; +import org.eclipse.cdt.core.parser.IExtendedScannerInfo; +import org.eclipse.cdt.core.parser.IScannerInfo; +import org.eclipse.cdt.core.parser.IScannerInfoProvider; +import org.eclipse.cdt.core.settings.model.ICConfigExtensionReference; +import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; +import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; +import org.eclipse.cdt.core.settings.model.ICSettingEntry; +import org.eclipse.cdt.core.settings.model.util.CDataUtil; +import org.eclipse.cdt.core.settings.model.util.CExtensionUtil; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; + +/** + * Wrapper class intended to provide backward compatibility with ScannerInfoProvider defined by org.eclipse.cdt.core.ScannerInfoProvider extension point + */ +public class ScannerInfoExtensionLanguageSettingsProvider extends LanguageSettingsBaseProvider { + @Override + public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) { + List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>(); + IScannerInfoProvider scannerInfoProvider = getScannerInfoProvider(cfgDescription); + if (scannerInfoProvider != null) { + IScannerInfo si = scannerInfoProvider.getScannerInformation(rc); + if (si != null) { + if (si instanceof IExtendedScannerInfo) { + addLocalIncludePaths(entries, (IExtendedScannerInfo) si); + } + + addSystemIncludePaths(entries, si); + addDefinedSymbols(entries, si); + + if (si instanceof IExtendedScannerInfo) { + addIncludeFiles(entries, (IExtendedScannerInfo) si); + addMacroFiles(entries, (IExtendedScannerInfo) si); + } + + if (!entries.isEmpty()) { + return LanguageSettingsSerializableStorage.getPooledList(entries); + } + } + } + return null; + } + + /** + * Return ScannerInfoProvider defined in configuration metadata in .cproject. + * + * @param cfgDescription - configuration description. + * @return an instance of ScannerInfoProvider or {@code null}. + */ + public IScannerInfoProvider getScannerInfoProvider(ICConfigurationDescription cfgDescription) { + if (cfgDescription == null || cfgDescription.isPreferenceConfiguration()) { + return null; + } + + IScannerInfoProvider scannerInfoProvider = null; + ICConfigExtensionReference[] refs = cfgDescription.get(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID); + if (refs != null && refs.length > 0) { + ICConfigExtensionReference ref = refs[0]; + try { + AbstractCExtension cExtension = null; + IConfigurationElement el = CExtensionUtil.getFirstConfigurationElement(ref, "cextension", false); //$NON-NLS-1$ + cExtension = (AbstractCExtension)el.createExecutableExtension("run"); //$NON-NLS-1$ + cExtension.setExtensionReference(ref); + cExtension.setProject(ref.getConfiguration().getProjectDescription().getProject()); + if (cExtension instanceof IScannerInfoProvider) { + scannerInfoProvider = (IScannerInfoProvider) cExtension; + } + } catch (CoreException e) { + CCorePlugin.log(e); + } + } + return scannerInfoProvider; + } + + /** + * Add local include paths to the list of entries. + */ + private void addLocalIncludePaths(List<ICLanguageSettingEntry> entries, IExtendedScannerInfo esi) { + String[] localIncludePaths = esi.getLocalIncludePath(); + if (localIncludePaths != null) { + for (String path : localIncludePaths) { + entries.add(CDataUtil.createCIncludePathEntry(path, ICSettingEntry.LOCAL)); + } + } + } + + /** + * Add system include paths to the list of entries. + */ + private void addSystemIncludePaths(List<ICLanguageSettingEntry> entries, IScannerInfo si) { + String[] includePaths = si.getIncludePaths(); + if (includePaths != null) { + for (String path : includePaths) { + entries.add(CDataUtil.createCIncludePathEntry(path, 0)); + } + } + } + + /** + * Add defined macros to the list of entries. + */ + private void addDefinedSymbols(List<ICLanguageSettingEntry> entries, IScannerInfo si) { + Map<String, String> definedSymbols = si.getDefinedSymbols(); + if (definedSymbols != null) { + for (Entry<String, String> entry : new TreeMap<String, String>(definedSymbols).entrySet()) { + String name = entry.getKey(); + String value = entry.getValue(); + entries.add(CDataUtil.createCMacroEntry(name, value, 0)); + } + } + } + + /** + * Add include files to the list of entries. + */ + private void addIncludeFiles(List<ICLanguageSettingEntry> entries, IExtendedScannerInfo esi) { + String[] includeFiles = esi.getIncludeFiles(); + if (includeFiles != null) { + for (String path : includeFiles) { + entries.add(CDataUtil.createCIncludeFileEntry(path, 0)); + } + } + } + + /** + * Add macro files to the list of entries. + */ + private void addMacroFiles(List<ICLanguageSettingEntry> entries, IExtendedScannerInfo esi) { + String[] macroFiles = esi.getMacroFiles(); + if (macroFiles != null) { + for (String path : macroFiles) { + entries.add(CDataUtil.createCMacroFileEntry(path, 0)); + } + } + } +} diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BatchOperation.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BatchOperation.java index d294ae94ede..8a70bff4f2c 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BatchOperation.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BatchOperation.java @@ -1,59 +1,59 @@ -/*******************************************************************************
- * Copyright (c) 2001, 2011 IBM Corporation 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:
- * Rational Software - initial implementation
+/******************************************************************************* + * Copyright (c) 2001, 2011 IBM Corporation 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: + * Rational Software - initial implementation *******************************************************************************/ -package org.eclipse.cdt.internal.core.model;
-
-import org.eclipse.core.resources.IResourceStatus;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.cdt.core.model.ICModelStatus;
-import org.eclipse.cdt.core.model.CModelException;
-
-/**
- * An operation created as a result of a call to JavaCore.run(IWorkspaceRunnable, IProgressMonitor)
- * that encapsulates a user defined IWorkspaceRunnable.
- */
-public class BatchOperation extends CModelOperation {
- protected IWorkspaceRunnable runnable;
-
- public BatchOperation(IWorkspaceRunnable runnable) {
- this.runnable = runnable;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.core.JavaModelOperation#executeOperation()
- */
- @Override
- protected void executeOperation() throws CModelException {
- try {
- this.runnable.run(fMonitor);
- } catch (CoreException ce) {
- if (ce instanceof CModelException) {
- throw (CModelException)ce;
- }
- if (ce.getStatus().getCode() == IResourceStatus.OPERATION_FAILED) {
- Throwable e= ce.getStatus().getException();
- if (e instanceof CModelException) {
- throw (CModelException) e;
- }
- }
- throw new CModelException(ce);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.core.JavaModelOperation#verify()
- */
- @Override
- protected ICModelStatus verify() {
- // cannot verify user defined operation
- return CModelStatus.VERIFIED_OK;
- }
-}
+package org.eclipse.cdt.internal.core.model; + +import org.eclipse.core.resources.IResourceStatus; +import org.eclipse.core.resources.IWorkspaceRunnable; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.cdt.core.model.ICModelStatus; +import org.eclipse.cdt.core.model.CModelException; + +/** + * An operation created as a result of a call to JavaCore.run(IWorkspaceRunnable, IProgressMonitor) + * that encapsulates a user defined IWorkspaceRunnable. + */ +public class BatchOperation extends CModelOperation { + protected IWorkspaceRunnable runnable; + + public BatchOperation(IWorkspaceRunnable runnable) { + this.runnable = runnable; + } + + /* (non-Javadoc) + * @see org.eclipse.jdt.internal.core.JavaModelOperation#executeOperation() + */ + @Override + protected void executeOperation() throws CModelException { + try { + this.runnable.run(fMonitor); + } catch (CoreException ce) { + if (ce instanceof CModelException) { + throw (CModelException)ce; + } + if (ce.getStatus().getCode() == IResourceStatus.OPERATION_FAILED) { + Throwable e= ce.getStatus().getException(); + if (e instanceof CModelException) { + throw (CModelException) e; + } + } + throw new CModelException(ce); + } + } + + /* (non-Javadoc) + * @see org.eclipse.jdt.internal.core.JavaModelOperation#verify() + */ + @Override + protected ICModelStatus verify() { + // cannot verify user defined operation + return CModelStatus.VERIFIED_OK; + } +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPAliasTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPAliasTemplate.java index 897abdd2173..c3491406ca8 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPAliasTemplate.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPAliasTemplate.java @@ -1,28 +1,28 @@ -/*******************************************************************************
- * Copyright (c) 2012, 2014 Institute for Software, HSR Hochschule fuer Technik
- * Rapperswil, University of applied sciences.
- * 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:
- * Thomas Corbat (IFS) - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.core.dom.ast.cpp;
-
-import org.eclipse.cdt.core.dom.ast.IType;
-
-/**
- * Represents an alias template (14.5.7).
- * @since 5.5
- *
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
- */
-public interface ICPPAliasTemplate extends IType, ICPPTemplateDefinition {
- /**
- * Returns the aliased type.
- */
- public IType getType();
-}
+/******************************************************************************* + * Copyright (c) 2012, 2014 Institute for Software, HSR Hochschule fuer Technik + * Rapperswil, University of applied sciences. + * 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: + * Thomas Corbat (IFS) - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.core.dom.ast.cpp; + +import org.eclipse.cdt.core.dom.ast.IType; + +/** + * Represents an alias template (14.5.7). + * @since 5.5 + * + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + */ +public interface ICPPAliasTemplate extends IType, ICPPTemplateDefinition { + /** + * Returns the aliased type. + */ + public IType getType(); +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/rewrite/DeclarationGenerator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/rewrite/DeclarationGenerator.java index 5ab56f46e1e..4082f1b0c04 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/rewrite/DeclarationGenerator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/rewrite/DeclarationGenerator.java @@ -1,47 +1,47 @@ -/*******************************************************************************
- * Copyright (c) 2010, 2013 Tomasz Wesolowski
- * 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:
- * Tomasz Wesolowski - initial API and implementation
+/******************************************************************************* + * Copyright (c) 2010, 2013 Tomasz Wesolowski + * 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: + * Tomasz Wesolowski - initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.core.dom.rewrite;
-
-import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
-import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
-import org.eclipse.cdt.core.dom.ast.INodeFactory;
-import org.eclipse.cdt.core.dom.ast.IType;
-import org.eclipse.cdt.internal.core.dom.rewrite.DeclarationGeneratorImpl;
-
-/**
- * This class handles the creation of {@link IASTDeclarator}s and {@link IASTDeclSpecifier}s
- * for a given type.
- *
- * @author Tomasz Wesolowski
- * @noextend This interface is not intended to be extended by clients.
- * @since 5.3
- */
-public abstract class DeclarationGenerator {
-
- public static DeclarationGenerator create(INodeFactory factory) {
- return new DeclarationGeneratorImpl(factory);
- }
-
- /**
- * Creates a new {@link IASTDeclSpecifier} for a given {@link IType}.
- * @param type the type to describe
- * @return the generated declaration specifier
- */
- public abstract IASTDeclSpecifier createDeclSpecFromType(IType type);
-
- /**
- * Creates a new {@link IASTDeclarator} for a given {@link IType}.
- * @param type the type to describe
- * @param name the name for the declarator
- * @return the generated declarator
- */
- public abstract IASTDeclarator createDeclaratorFromType(IType type, char[] name);
+package org.eclipse.cdt.core.dom.rewrite; + +import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; +import org.eclipse.cdt.core.dom.ast.IASTDeclarator; +import org.eclipse.cdt.core.dom.ast.INodeFactory; +import org.eclipse.cdt.core.dom.ast.IType; +import org.eclipse.cdt.internal.core.dom.rewrite.DeclarationGeneratorImpl; + +/** + * This class handles the creation of {@link IASTDeclarator}s and {@link IASTDeclSpecifier}s + * for a given type. + * + * @author Tomasz Wesolowski + * @noextend This interface is not intended to be extended by clients. + * @since 5.3 + */ +public abstract class DeclarationGenerator { + + public static DeclarationGenerator create(INodeFactory factory) { + return new DeclarationGeneratorImpl(factory); + } + + /** + * Creates a new {@link IASTDeclSpecifier} for a given {@link IType}. + * @param type the type to describe + * @return the generated declaration specifier + */ + public abstract IASTDeclSpecifier createDeclSpecFromType(IType type); + + /** + * Creates a new {@link IASTDeclarator} for a given {@link IType}. + * @param type the type to describe + * @param name the name for the declarator + * @return the generated declarator + */ + public abstract IASTDeclarator createDeclaratorFromType(IType type, char[] name); }
\ No newline at end of file diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/ResourceContainerRelativeLocationConverter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/ResourceContainerRelativeLocationConverter.java index 4c86e4326eb..018730f8337 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/ResourceContainerRelativeLocationConverter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/ResourceContainerRelativeLocationConverter.java @@ -8,14 +8,14 @@ * Contributors: * Andrew Ferguson (Symbian) - Initial implementation *******************************************************************************/ -package org.eclipse.cdt.core.index;
+package org.eclipse.cdt.core.index; import org.eclipse.cdt.internal.core.index.IndexFileLocation; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Path; /** * A location converter for converting project resource locations to be relative to a specified @@ -33,13 +33,13 @@ public class ResourceContainerRelativeLocationConverter implements IIndexLocatio public ResourceContainerRelativeLocationConverter(IContainer container) { this.fullPath = container.getFullPath(); this.root = ResourcesPlugin.getWorkspace().getRoot(); - }
+ } @Override public IIndexFileLocation fromInternalFormat(String raw) { IResource member= root.getFile(fullPath.append(raw)); return new IndexFileLocation(member.getLocationURI(), member.getFullPath().toString()); - }
+ } @Override public String toInternalFormat(IIndexFileLocation location) { String sFullPath= location.getFullPath(); @@ -51,4 +51,4 @@ public class ResourceContainerRelativeLocationConverter implements IIndexLocatio } return null; } -}
+} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/StandardAttributes.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/StandardAttributes.java index 1597a77dafa..bcca01f1b47 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/StandardAttributes.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/StandardAttributes.java @@ -1,30 +1,30 @@ -/*******************************************************************************
- * Copyright (c) 2017 Institute for Software, HSR Hochschule fuer Technik
- * 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
- *******************************************************************************/
-package org.eclipse.cdt.core.parser;
-
-/**
- * @noextend This class is not intended to be subclassed by clients.
- * @noinstantiate This class is not intended to be instantiated by clients.
- * @since 6.3
- */
-@SuppressWarnings("nls")
-public class StandardAttributes {
- public static final String CARRIES_DEPENDENCY = "carries_dependency";
- public static final String DEPRECATED = "deprecated";
- public static final String FALLTHROUGH = "fallthrough";
- public static final String MAYBE_UNUSED = "maybe_unused";
- public static final String NODISCARD = "nodiscard";
- public static final String NORETURN = "noreturn";
-
- public static final char[] cCARRIES_DEPENDENCY = "carries_dependency".toCharArray();
- public static final char[] cDEPRECATED = "deprecated".toCharArray();
- public static final char[] cFALLTHROUGH = "fallthrough".toCharArray();
- public static final char[] cMAYBE_UNUSED = "maybe_unused".toCharArray();
- public static final char[] cNODISCARD = "nodiscard".toCharArray();
- public static final char[] cNORETURN = "noreturn".toCharArray();
-}
+/******************************************************************************* + * Copyright (c) 2017 Institute for Software, HSR Hochschule fuer Technik + * 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 + *******************************************************************************/ +package org.eclipse.cdt.core.parser; + +/** + * @noextend This class is not intended to be subclassed by clients. + * @noinstantiate This class is not intended to be instantiated by clients. + * @since 6.3 + */ +@SuppressWarnings("nls") +public class StandardAttributes { + public static final String CARRIES_DEPENDENCY = "carries_dependency"; + public static final String DEPRECATED = "deprecated"; + public static final String FALLTHROUGH = "fallthrough"; + public static final String MAYBE_UNUSED = "maybe_unused"; + public static final String NODISCARD = "nodiscard"; + public static final String NORETURN = "noreturn"; + + public static final char[] cCARRIES_DEPENDENCY = "carries_dependency".toCharArray(); + public static final char[] cDEPRECATED = "deprecated".toCharArray(); + public static final char[] cFALLTHROUGH = "fallthrough".toCharArray(); + public static final char[] cMAYBE_UNUSED = "maybe_unused".toCharArray(); + public static final char[] cNODISCARD = "nodiscard".toCharArray(); + public static final char[] cNORETURN = "noreturn".toCharArray(); +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPAliasTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPAliasTemplate.java index 5f098d4fbe4..594cda3abbd 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPAliasTemplate.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPAliasTemplate.java @@ -1,167 +1,167 @@ -/*******************************************************************************
- * Copyright (c) 2012 Institute for Software, HSR Hochschule fuer Technik
- * Rapperswil, University of applied sciences.
- * 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:
- * Thomas Corbat (IFS) - Initial API and implementation
- * Sergey Prigogin (Google)
- *******************************************************************************/
-package org.eclipse.cdt.internal.core.dom.parser.cpp;
-
-import org.eclipse.cdt.core.dom.ILinkage;
-import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
-import org.eclipse.cdt.core.dom.ast.DOMException;
-import org.eclipse.cdt.core.dom.ast.IASTName;
-import org.eclipse.cdt.core.dom.ast.IASTNode;
-import org.eclipse.cdt.core.dom.ast.IBinding;
-import org.eclipse.cdt.core.dom.ast.IScope;
-import org.eclipse.cdt.core.dom.ast.IType;
-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.ICPPAliasTemplate;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
-import org.eclipse.cdt.core.parser.util.ArrayUtil;
-import org.eclipse.cdt.internal.core.dom.Linkage;
-import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
-import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
-import org.eclipse.core.runtime.PlatformObject;
-
-public class CPPAliasTemplate extends PlatformObject
- implements ICPPAliasTemplate, ICPPTemplateParameterOwner, ICPPInternalBinding {
- private final IASTName aliasName;
- private final IType aliasedType;
- private ICPPTemplateParameter[] templateParameters;
-
- public CPPAliasTemplate(IASTName aliasName, IType aliasedType) {
- this.aliasName = aliasName;
- this.aliasedType = aliasedType;
- aliasName.setBinding(this);
- }
-
- @Override
- public IType getType() {
- return aliasedType;
- }
-
- @Override
- public String getName() {
- return new String(getNameCharArray());
- }
-
- @Override
- public char[] getNameCharArray() {
- return aliasName.getSimpleID();
- }
-
- @Override
- public ILinkage getLinkage() {
- return Linkage.CPP_LINKAGE;
- }
-
- @Override
- public IBinding getOwner() {
- return CPPVisitor.findDeclarationOwner(aliasName, true);
- }
-
- @Override
- public IScope getScope() throws DOMException {
- return CPPVisitor.getContainingScope(aliasName.getParent());
- }
-
- @Override
- public boolean isSameType(IType type) {
- if (type == null) {
- return false;
- }
- IType aliasedType = getType();
- return type.isSameType(aliasedType);
- }
-
- @Override
- public Object clone() {
- IType t = null;
- try {
- t = (IType) super.clone();
- } catch (CloneNotSupportedException e) {
- // Not going to happen
- }
- return t;
- }
-
- @Override
- public String[] getQualifiedName() throws DOMException {
- return CPPVisitor.getQualifiedName(this);
- }
-
- @Override
- public char[][] getQualifiedNameCharArray() throws DOMException {
- return CPPVisitor.getQualifiedNameCharArray(this);
- }
-
- @Override
- public boolean isGloballyQualified() throws DOMException {
- return true;
- }
-
- @Override
- public ICPPTemplateParameter[] getTemplateParameters() {
- if (templateParameters == null) {
- ICPPASTTemplateDeclaration template = CPPTemplates.getTemplateDeclaration(aliasName);
- if (template == null)
- return ICPPTemplateParameter.EMPTY_TEMPLATE_PARAMETER_ARRAY;
- ICPPASTTemplateParameter[] params = template.getTemplateParameters();
- IBinding p = null;
- ICPPTemplateParameter[] result = null;
- for (ICPPASTTemplateParameter param : params) {
- p= CPPTemplates.getTemplateParameterName(param).resolveBinding();
- if (p instanceof ICPPTemplateParameter) {
- result = ArrayUtil.append(ICPPTemplateParameter.class, result, (ICPPTemplateParameter) p);
- }
- }
- templateParameters = ArrayUtil.trim(ICPPTemplateParameter.class, result);
- }
- return templateParameters;
- }
-
- @Override
- public IBinding resolveTemplateParameter(ICPPTemplateParameter templateParameter) {
- int pos= templateParameter.getParameterPosition();
-
- ICPPASTTemplateParameter[] params = CPPTemplates.getTemplateDeclaration(aliasName).getTemplateParameters();
- if (pos < params.length) {
- final IASTName oName = CPPTemplates.getTemplateParameterName(params[pos]);
- return oName.resolvePreBinding();
- }
- return templateParameter;
- }
-
- @Override
- public IASTNode getDefinition() {
- return aliasName;
- }
-
- @Override
- public IASTNode[] getDeclarations() {
- return null;
- }
-
- @Override
- public void addDefinition(IASTNode node) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void addDeclaration(IASTNode node) {
- throw new UnsupportedOperationException();
- }
-
- /** For debugging only. */
- @Override
- public String toString() {
- return ASTTypeUtil.getQualifiedName(this) + " -> " + ASTTypeUtil.getType(aliasedType, true); //$NON-NLS-1$
- }
-}
+/******************************************************************************* + * Copyright (c) 2012 Institute for Software, HSR Hochschule fuer Technik + * Rapperswil, University of applied sciences. + * 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: + * Thomas Corbat (IFS) - Initial API and implementation + * Sergey Prigogin (Google) + *******************************************************************************/ +package org.eclipse.cdt.internal.core.dom.parser.cpp; + +import org.eclipse.cdt.core.dom.ILinkage; +import org.eclipse.cdt.core.dom.ast.ASTTypeUtil; +import org.eclipse.cdt.core.dom.ast.DOMException; +import org.eclipse.cdt.core.dom.ast.IASTName; +import org.eclipse.cdt.core.dom.ast.IASTNode; +import org.eclipse.cdt.core.dom.ast.IBinding; +import org.eclipse.cdt.core.dom.ast.IScope; +import org.eclipse.cdt.core.dom.ast.IType; +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.ICPPAliasTemplate; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter; +import org.eclipse.cdt.core.parser.util.ArrayUtil; +import org.eclipse.cdt.internal.core.dom.Linkage; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; +import org.eclipse.core.runtime.PlatformObject; + +public class CPPAliasTemplate extends PlatformObject + implements ICPPAliasTemplate, ICPPTemplateParameterOwner, ICPPInternalBinding { + private final IASTName aliasName; + private final IType aliasedType; + private ICPPTemplateParameter[] templateParameters; + + public CPPAliasTemplate(IASTName aliasName, IType aliasedType) { + this.aliasName = aliasName; + this.aliasedType = aliasedType; + aliasName.setBinding(this); + } + + @Override + public IType getType() { + return aliasedType; + } + + @Override + public String getName() { + return new String(getNameCharArray()); + } + + @Override + public char[] getNameCharArray() { + return aliasName.getSimpleID(); + } + + @Override + public ILinkage getLinkage() { + return Linkage.CPP_LINKAGE; + } + + @Override + public IBinding getOwner() { + return CPPVisitor.findDeclarationOwner(aliasName, true); + } + + @Override + public IScope getScope() throws DOMException { + return CPPVisitor.getContainingScope(aliasName.getParent()); + } + + @Override + public boolean isSameType(IType type) { + if (type == null) { + return false; + } + IType aliasedType = getType(); + return type.isSameType(aliasedType); + } + + @Override + public Object clone() { + IType t = null; + try { + t = (IType) super.clone(); + } catch (CloneNotSupportedException e) { + // Not going to happen + } + return t; + } + + @Override + public String[] getQualifiedName() throws DOMException { + return CPPVisitor.getQualifiedName(this); + } + + @Override + public char[][] getQualifiedNameCharArray() throws DOMException { + return CPPVisitor.getQualifiedNameCharArray(this); + } + + @Override + public boolean isGloballyQualified() throws DOMException { + return true; + } + + @Override + public ICPPTemplateParameter[] getTemplateParameters() { + if (templateParameters == null) { + ICPPASTTemplateDeclaration template = CPPTemplates.getTemplateDeclaration(aliasName); + if (template == null) + return ICPPTemplateParameter.EMPTY_TEMPLATE_PARAMETER_ARRAY; + ICPPASTTemplateParameter[] params = template.getTemplateParameters(); + IBinding p = null; + ICPPTemplateParameter[] result = null; + for (ICPPASTTemplateParameter param : params) { + p= CPPTemplates.getTemplateParameterName(param).resolveBinding(); + if (p instanceof ICPPTemplateParameter) { + result = ArrayUtil.append(ICPPTemplateParameter.class, result, (ICPPTemplateParameter) p); + } + } + templateParameters = ArrayUtil.trim(ICPPTemplateParameter.class, result); + } + return templateParameters; + } + + @Override + public IBinding resolveTemplateParameter(ICPPTemplateParameter templateParameter) { + int pos= templateParameter.getParameterPosition(); + + ICPPASTTemplateParameter[] params = CPPTemplates.getTemplateDeclaration(aliasName).getTemplateParameters(); + if (pos < params.length) { + final IASTName oName = CPPTemplates.getTemplateParameterName(params[pos]); + return oName.resolvePreBinding(); + } + return templateParameter; + } + + @Override + public IASTNode getDefinition() { + return aliasName; + } + + @Override + public IASTNode[] getDeclarations() { + return null; + } + + @Override + public void addDefinition(IASTNode node) { + throw new UnsupportedOperationException(); + } + + @Override + public void addDeclaration(IASTNode node) { + throw new UnsupportedOperationException(); + } + + /** For debugging only. */ + @Override + public String toString() { + return ASTTypeUtil.getQualifiedName(this) + " -> " + ASTTypeUtil.getType(aliasedType, true); //$NON-NLS-1$ + } +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPAliasTemplateInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPAliasTemplateInstance.java index 0f595659952..2274469a4f1 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPAliasTemplateInstance.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPAliasTemplateInstance.java @@ -1,166 +1,166 @@ -/*******************************************************************************
- * Copyright (c) 2012, 2016 Institute for Software, HSR Hochschule fuer Technik
- * Rapperswil, University of applied sciences.
- * 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:
- * Thomas Corbat (IFS) - Initial API and implementation
- * Sergey Prigogin (Google)
+/******************************************************************************* + * Copyright (c) 2012, 2016 Institute for Software, HSR Hochschule fuer Technik + * Rapperswil, University of applied sciences. + * 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: + * Thomas Corbat (IFS) - Initial API and implementation + * Sergey Prigogin (Google) *******************************************************************************/ -package org.eclipse.cdt.internal.core.dom.parser.cpp;
-
-import org.eclipse.cdt.core.dom.ILinkage;
-import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
-import org.eclipse.cdt.core.dom.ast.DOMException;
-import org.eclipse.cdt.core.dom.ast.IASTNode;
-import org.eclipse.cdt.core.dom.ast.IBinding;
-import org.eclipse.cdt.core.dom.ast.IScope;
-import org.eclipse.cdt.core.dom.ast.IType;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplate;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplateInstance;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
-import org.eclipse.cdt.core.parser.util.CharArrayUtils;
-import org.eclipse.cdt.internal.core.dom.Linkage;
-import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
-import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
-
-public class CPPAliasTemplateInstance extends CPPSpecialization implements ICPPAliasTemplateInstance,
- ITypeContainer {
- private IType aliasedType;
- private ICPPTemplateArgument[] fArguments;
-
- public CPPAliasTemplateInstance(ICPPAliasTemplate aliasTemplate, IType aliasedType, IBinding owner,
- ICPPTemplateParameterMap argumentMap, ICPPTemplateArgument[] arguments) {
- super(aliasTemplate, owner, argumentMap);
- this.aliasedType = aliasedType;
- this.fArguments = arguments;
- }
-
- @Override
- public ICPPAliasTemplate getTemplateDefinition() {
- return (ICPPAliasTemplate) super.getSpecializedBinding();
- }
-
- @Override
- public boolean isSameType(IType other) {
- if (other == aliasedType)
- return true;
- if (aliasedType != null) {
- return aliasedType.isSameType(other);
- }
- return false;
- }
-
- @Override
- public IType getType() {
- return aliasedType;
- }
-
- @Override
- public void setType(IType type) {
- aliasedType = type;
- }
-
- @Override
- public Object clone() {
- try {
- return super.clone();
- } catch (CloneNotSupportedException e) {
- }
- return null;
- }
-
- @Override
- public String getName() {
- return new String(getNameCharArray());
- }
-
- @Override
- public char[] getNameCharArray() {
- char[] name = getTemplateDefinition().getNameCharArray();
- if (name != null) {
- return name;
- }
- return CharArrayUtils.EMPTY_CHAR_ARRAY;
- }
-
- @Override
- public ILinkage getLinkage() {
- return Linkage.CPP_LINKAGE;
- }
-
- @Override
- public IBinding getOwner() {
- if (getTemplateDefinition() != null) {
- return getTemplateDefinition().getOwner();
- }
- return null;
- }
-
- @Override
- public IScope getScope() throws DOMException {
- if (getTemplateDefinition() != null) {
- return getTemplateDefinition().getScope();
- }
- return null;
- }
-
- @Override
- public String[] getQualifiedName() {
- return CPPVisitor.getQualifiedName(this);
- }
-
- @Override
- public char[][] getQualifiedNameCharArray() {
- return CPPVisitor.getQualifiedNameCharArray(this);
- }
-
- @Override
- public boolean isGloballyQualified() throws DOMException {
- return getTemplateDefinition().isGloballyQualified();
- }
-
- @Override
- public IASTNode getDefinition() {
- if (getTemplateDefinition() instanceof ICPPInternalBinding) {
- return ((ICPPInternalBinding) getTemplateDefinition()).getDefinition();
- }
- return null;
- }
-
- @Override
- public IASTNode[] getDeclarations() {
- return null;
- }
-
- @Override
- public void addDefinition(IASTNode node) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void addDeclaration(IASTNode node) {
- throw new UnsupportedOperationException();
- }
-
- /** For debugging only. */
- @Override
- public String toString() {
- return ASTTypeUtil.getQualifiedName(this) + " -> " + ASTTypeUtil.getType(aliasedType, true); //$NON-NLS-1$
- }
-
- @Override
- public ICPPTemplateArgument[] getTemplateArguments() {
- return fArguments;
- }
-
- @Override
- public boolean isExplicitSpecialization() {
- // Alias templates cannot have explicit specializations.
- return false;
- }
-}
+package org.eclipse.cdt.internal.core.dom.parser.cpp; + +import org.eclipse.cdt.core.dom.ILinkage; +import org.eclipse.cdt.core.dom.ast.ASTTypeUtil; +import org.eclipse.cdt.core.dom.ast.DOMException; +import org.eclipse.cdt.core.dom.ast.IASTNode; +import org.eclipse.cdt.core.dom.ast.IBinding; +import org.eclipse.cdt.core.dom.ast.IScope; +import org.eclipse.cdt.core.dom.ast.IType; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplate; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplateInstance; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap; +import org.eclipse.cdt.core.parser.util.CharArrayUtils; +import org.eclipse.cdt.internal.core.dom.Linkage; +import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; + +public class CPPAliasTemplateInstance extends CPPSpecialization implements ICPPAliasTemplateInstance, + ITypeContainer { + private IType aliasedType; + private ICPPTemplateArgument[] fArguments; + + public CPPAliasTemplateInstance(ICPPAliasTemplate aliasTemplate, IType aliasedType, IBinding owner, + ICPPTemplateParameterMap argumentMap, ICPPTemplateArgument[] arguments) { + super(aliasTemplate, owner, argumentMap); + this.aliasedType = aliasedType; + this.fArguments = arguments; + } + + @Override + public ICPPAliasTemplate getTemplateDefinition() { + return (ICPPAliasTemplate) super.getSpecializedBinding(); + } + + @Override + public boolean isSameType(IType other) { + if (other == aliasedType) + return true; + if (aliasedType != null) { + return aliasedType.isSameType(other); + } + return false; + } + + @Override + public IType getType() { + return aliasedType; + } + + @Override + public void setType(IType type) { + aliasedType = type; + } + + @Override + public Object clone() { + try { + return super.clone(); + } catch (CloneNotSupportedException e) { + } + return null; + } + + @Override + public String getName() { + return new String(getNameCharArray()); + } + + @Override + public char[] getNameCharArray() { + char[] name = getTemplateDefinition().getNameCharArray(); + if (name != null) { + return name; + } + return CharArrayUtils.EMPTY_CHAR_ARRAY; + } + + @Override + public ILinkage getLinkage() { + return Linkage.CPP_LINKAGE; + } + + @Override + public IBinding getOwner() { + if (getTemplateDefinition() != null) { + return getTemplateDefinition().getOwner(); + } + return null; + } + + @Override + public IScope getScope() throws DOMException { + if (getTemplateDefinition() != null) { + return getTemplateDefinition().getScope(); + } + return null; + } + + @Override + public String[] getQualifiedName() { + return CPPVisitor.getQualifiedName(this); + } + + @Override + public char[][] getQualifiedNameCharArray() { + return CPPVisitor.getQualifiedNameCharArray(this); + } + + @Override + public boolean isGloballyQualified() throws DOMException { + return getTemplateDefinition().isGloballyQualified(); + } + + @Override + public IASTNode getDefinition() { + if (getTemplateDefinition() instanceof ICPPInternalBinding) { + return ((ICPPInternalBinding) getTemplateDefinition()).getDefinition(); + } + return null; + } + + @Override + public IASTNode[] getDeclarations() { + return null; + } + + @Override + public void addDefinition(IASTNode node) { + throw new UnsupportedOperationException(); + } + + @Override + public void addDeclaration(IASTNode node) { + throw new UnsupportedOperationException(); + } + + /** For debugging only. */ + @Override + public String toString() { + return ASTTypeUtil.getQualifiedName(this) + " -> " + ASTTypeUtil.getType(aliasedType, true); //$NON-NLS-1$ + } + + @Override + public ICPPTemplateArgument[] getTemplateArguments() { + return fArguments; + } + + @Override + public boolean isExplicitSpecialization() { + // Alias templates cannot have explicit specializations. + return false; + } +} diff --git a/core/org.eclipse.cdt.core/schema/buildConfigProvider.exsd b/core/org.eclipse.cdt.core/schema/buildConfigProvider.exsd index 3abc3226dcc..c2d7de5cf85 100644 --- a/core/org.eclipse.cdt.core/schema/buildConfigProvider.exsd +++ b/core/org.eclipse.cdt.core/schema/buildConfigProvider.exsd @@ -1,119 +1,119 @@ -<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.cdt.core" xmlns="http://www.w3.org/2001/XMLSchema">
-<annotation>
- <appInfo>
- <meta.schema plugin="org.eclipse.cdt.core" id="CBuildConfigProvider" name="CBuildConfigProvider"/>
- </appInfo>
- <documentation>
- [Enter description of this extension point.]
- </documentation>
- </annotation>
-
- <element name="extension">
- <annotation>
- <appInfo>
- <meta.element />
- </appInfo>
- </annotation>
- <complexType>
- <sequence minOccurs="1" maxOccurs="unbounded">
- <element ref="provider"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- <appInfo>
- <meta.attribute translatable="true"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="provider">
- <complexType>
- <attribute name="id" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- <appInfo>
- <meta.attribute kind="java" basedOn=":org.eclipse.cdt.core.build.ICBuildConfigurationProvider"/>
- </appInfo>
- </annotation>
- </attribute>
- <attribute name="natureId" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- <appInfo>
- <meta.attribute kind="identifier" basedOn="org.eclipse.core.resources.natures/@id"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appInfo>
- <meta.section type="since"/>
- </appInfo>
- <documentation>
- [Enter the first release in which this extension point appears.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="examples"/>
- </appInfo>
- <documentation>
- [Enter extension point usage example here.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="apiinfo"/>
- </appInfo>
- <documentation>
- [Enter API information here.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="implementation"/>
- </appInfo>
- <documentation>
- [Enter information about supplied implementation of this extension point.]
- </documentation>
- </annotation>
-
-
-</schema>
+<?xml version='1.0' encoding='UTF-8'?> +<!-- Schema file written by PDE --> +<schema targetNamespace="org.eclipse.cdt.core" xmlns="http://www.w3.org/2001/XMLSchema"> +<annotation> + <appInfo> + <meta.schema plugin="org.eclipse.cdt.core" id="CBuildConfigProvider" name="CBuildConfigProvider"/> + </appInfo> + <documentation> + [Enter description of this extension point.] + </documentation> + </annotation> + + <element name="extension"> + <annotation> + <appInfo> + <meta.element /> + </appInfo> + </annotation> + <complexType> + <sequence minOccurs="1" maxOccurs="unbounded"> + <element ref="provider"/> + </sequence> + <attribute name="point" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="id" type="string"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="name" type="string"> + <annotation> + <documentation> + + </documentation> + <appInfo> + <meta.attribute translatable="true"/> + </appInfo> + </annotation> + </attribute> + </complexType> + </element> + + <element name="provider"> + <complexType> + <attribute name="id" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="class" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + <appInfo> + <meta.attribute kind="java" basedOn=":org.eclipse.cdt.core.build.ICBuildConfigurationProvider"/> + </appInfo> + </annotation> + </attribute> + <attribute name="natureId" type="string"> + <annotation> + <documentation> + + </documentation> + <appInfo> + <meta.attribute kind="identifier" basedOn="org.eclipse.core.resources.natures/@id"/> + </appInfo> + </annotation> + </attribute> + </complexType> + </element> + + <annotation> + <appInfo> + <meta.section type="since"/> + </appInfo> + <documentation> + [Enter the first release in which this extension point appears.] + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="examples"/> + </appInfo> + <documentation> + [Enter extension point usage example here.] + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="apiinfo"/> + </appInfo> + <documentation> + [Enter API information here.] + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="implementation"/> + </appInfo> + <documentation> + [Enter information about supplied implementation of this extension point.] + </documentation> + </annotation> + + +</schema> diff --git a/core/org.eclipse.cdt.core/schema/toolChainProvider.exsd b/core/org.eclipse.cdt.core/schema/toolChainProvider.exsd index 78c09ea5a12..b4962a3957e 100644 --- a/core/org.eclipse.cdt.core/schema/toolChainProvider.exsd +++ b/core/org.eclipse.cdt.core/schema/toolChainProvider.exsd @@ -1,132 +1,132 @@ -<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.cdt.core" xmlns="http://www.w3.org/2001/XMLSchema">
-<annotation>
- <appInfo>
- <meta.schema plugin="org.eclipse.cdt.core" id="ToolChainProvider" name="Tool Chain Provider"/>
- </appInfo>
- <documentation>
- A toolchain provider provides automatically discovered toolchains when requested. Providers have enablement to make sure they aren't called unless there's a good chance they have toolchains to offer.
- </documentation>
- </annotation>
-
- <element name="extension">
- <annotation>
- <appInfo>
- <meta.element />
- </appInfo>
- </annotation>
- <complexType>
- <sequence minOccurs="1" maxOccurs="unbounded">
- <element ref="provider"/>
- <element ref="type"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- <appInfo>
- <meta.attribute translatable="true"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="provider">
- <complexType>
- <attribute name="id" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- <appInfo>
- <meta.attribute kind="java" basedOn=":org.eclipse.cdt.core.build.IToolChainProvider"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="type">
- <complexType>
- <attribute name="id" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- <appInfo>
- <meta.attribute translatable="true"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appInfo>
- <meta.section type="since"/>
- </appInfo>
- <documentation>
- [Enter the first release in which this extension point appears.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="examples"/>
- </appInfo>
- <documentation>
- [Enter extension point usage example here.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="apiinfo"/>
- </appInfo>
- <documentation>
- [Enter API information here.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="implementation"/>
- </appInfo>
- <documentation>
- [Enter information about supplied implementation of this extension point.]
- </documentation>
- </annotation>
-
-
-</schema>
+<?xml version='1.0' encoding='UTF-8'?> +<!-- Schema file written by PDE --> +<schema targetNamespace="org.eclipse.cdt.core" xmlns="http://www.w3.org/2001/XMLSchema"> +<annotation> + <appInfo> + <meta.schema plugin="org.eclipse.cdt.core" id="ToolChainProvider" name="Tool Chain Provider"/> + </appInfo> + <documentation> + A toolchain provider provides automatically discovered toolchains when requested. Providers have enablement to make sure they aren't called unless there's a good chance they have toolchains to offer. + </documentation> + </annotation> + + <element name="extension"> + <annotation> + <appInfo> + <meta.element /> + </appInfo> + </annotation> + <complexType> + <sequence minOccurs="1" maxOccurs="unbounded"> + <element ref="provider"/> + <element ref="type"/> + </sequence> + <attribute name="point" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="id" type="string"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="name" type="string"> + <annotation> + <documentation> + + </documentation> + <appInfo> + <meta.attribute translatable="true"/> + </appInfo> + </annotation> + </attribute> + </complexType> + </element> + + <element name="provider"> + <complexType> + <attribute name="id" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="class" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + <appInfo> + <meta.attribute kind="java" basedOn=":org.eclipse.cdt.core.build.IToolChainProvider"/> + </appInfo> + </annotation> + </attribute> + </complexType> + </element> + + <element name="type"> + <complexType> + <attribute name="id" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="name" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + <appInfo> + <meta.attribute translatable="true"/> + </appInfo> + </annotation> + </attribute> + </complexType> + </element> + + <annotation> + <appInfo> + <meta.section type="since"/> + </appInfo> + <documentation> + [Enter the first release in which this extension point appears.] + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="examples"/> + </appInfo> + <documentation> + [Enter extension point usage example here.] + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="apiinfo"/> + </appInfo> + <documentation> + [Enter API information here.] + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="implementation"/> + </appInfo> + <documentation> + [Enter information about supplied implementation of this extension point.] + </documentation> + </annotation> + + +</schema> diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChain.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChain.java index 3e9bd08818a..fab7d8ad5cf 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChain.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChain.java @@ -1,274 +1,274 @@ -/*******************************************************************************
- * Copyright (c) 2016 QNX Software Systems 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
- *******************************************************************************/
-package org.eclipse.cdt.core.build;
-
-import java.net.URI;
-import java.nio.file.Path;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
-import org.eclipse.cdt.core.model.ILanguage;
-import org.eclipse.cdt.core.parser.IExtendedScannerInfo;
-import org.eclipse.core.resources.IBuildConfiguration;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IAdaptable;
-
-/**
- * Toolchains are a collection of tools that take the source code and converts
- * it into an executable system.
- *
- * @since 6.0
- */
-public interface IToolChain extends IAdaptable {
-
- /**
- * Property: The OS the toolchain builds for.
- */
- static final String ATTR_OS = "os"; //$NON-NLS-1$
-
- /**
- * Property: The CPU architecture the toolchain supports.
- */
- static final String ATTR_ARCH = "arch"; //$NON-NLS-1$
-
- /**
- * Property: A package ID to reflect different version/package line up of
- * the platform this toolchain supports.
- */
- static final String ATTR_PACKAGE = "package"; //$NON-NLS-1$
-
- /**
- * The provider of the toolchain.
- *
- * @return toolchain provider
- */
- IToolChainProvider getProvider();
-
- /**
- * The ID of the toolchain
- *
- * @return toolchain ID
- */
- String getId();
-
- /**
- * The version of the toolchain
- *
- * @deprecated the version doesn't matter. id's for a given type must be unique.
- * @return toolchain version
- */
- @Deprecated
- String getVersion();
-
- /**
- * The user friendly name for the toolchain
- *
- * @return toolchain name
- */
- String getName();
-
- /**
- * The type id for the toolchain. The combination of type id and toolchain id
- * uniquely identify the toolchain in the system.
- *
- * @since 6.4
- */
- default String getTypeId() {
- // Subclasses really need to override this. There can be multiple providers for
- // a given toolchain type.
- return getProvider().getId();
- }
-
- /**
- * Returns an property of the toolchain. Used to determine applicability of
- * a toolchain for a given situation.
- *
- * @param key
- * key of the property
- * @return value of the property or null if the toolchain does not have that
- * property
- */
- String getProperty(String key);
-
- /**
- * Set a property on the toolchain.
- *
- * @param key
- * key of the property
- * @param value
- * value of the property
- */
- void setProperty(String key, String value);
-
- /**
- * Return the environment variables to be set when invoking the tools in the
- * toolchain.
- *
- * @return environment variables
- */
- IEnvironmentVariable[] getVariables();
-
- /**
- * Return the environment variable of the given name used when invoking the
- * toolchain.
- *
- * @param name
- * environment variable name
- * @return environment variable value
- */
- IEnvironmentVariable getVariable(String name);
-
- /**
- * Returns the error parser IDs use to create error markers for builds with
- * this toolchain.
- *
- * @return error parser IDs
- */
- String[] getErrorParserIds();
-
- /**
- * Returns the IDs for the binary parsers that can parse the build output of
- * the toolchain.
- *
- * @return binary parser IDs for this toolchain
- */
- String getBinaryParserId();
-
- /**
- * Get the scanner info for a given build config, command, base scanner
- * info, resource and build directory.
- *
- * @param buildConfig
- * the build configuration this scanner info applies to
- * @param command
- * the compile command that is used to build the resource
- * @param baseScannerInfo
- * base scanner info that this scanner info extends/replaces
- * @param resource
- * the resource this scanner info applies to, usually a source
- * file
- * @param buildDirectoryURI
- * where the build command is run to build this resource
- * @return scanner info for this resource
- * @since 6.1
- */
- default IExtendedScannerInfo getScannerInfo(IBuildConfiguration buildConfig, List<String> command,
- IExtendedScannerInfo baseScannerInfo, IResource resource, URI buildDirectoryURI) {
- return null;
- }
-
- @Deprecated
- default IExtendedScannerInfo getScannerInfo(IBuildConfiguration buildConfig, Path command, String[] args,
- IExtendedScannerInfo baseScannerInfo, IResource resource, URI buildDirectoryURI) {
- List<String> commandStrings = new ArrayList<>(args.length + 1);
- commandStrings.add(command.toString());
- commandStrings.addAll(Arrays.asList(args));
- return getScannerInfo(buildConfig, commandStrings, baseScannerInfo, resource, buildDirectoryURI);
- }
-
- /**
- * Return the default scanner info for this toolchain. This is used before
- * any build information is available to provide at least a minimal scanner
- * info based on the compiler built-ins.
- *
- * @param buildConfig
- * the build configuration this scanner info applies to
- * @param baseScannerInfo
- * base scanner info that this scanner info extends/replaces
- * @param language
- * the source language that selects the tool to provide scanner
- * info for
- * @param buildDirectoryURI
- * the build directory that would be used to run commands
- * @returns default scanner info for this language
- * @since 6.1
- */
- default IExtendedScannerInfo getDefaultScannerInfo(IBuildConfiguration buildConfig,
- IExtendedScannerInfo baseScannerInfo, ILanguage language, URI buildDirectoryURI) {
- return null;
- }
-
- /**
- * Returns the absolute path of the tool represented by the command
- *
- * @param command
- * the command as it usually appears on the command line
- * @return the absolute path to the tool for the command
- */
- Path getCommandPath(Path command);
-
- /**
- * Returns the list of compiler tools.
- *
- * @return list of compiler tools
- */
- String[] getCompileCommands();
-
- /**
- * Returns the list of compiler tools for a given language.
- *
- * @param language
- * the language for the commands
- * @return the compile commands for the language
- * @since 6.1
- */
- default String[] getCompileCommands(ILanguage language) {
- return new String[0];
- }
-
- /**
- * Returns the list of resources referenced in a compile command.
- *
- * @param command
- * the compile command
- * @param buildDirectoryURI
- * the directory the compile command runs in
- * @return the list of resources referenced in the compile command
- * @since 6.1
- */
- default IResource[] getResourcesFromCommand(List<String> command, URI buildDirectoryURI) {
- return new IResource[0];
- }
-
- @Deprecated
- default IResource[] getResourcesFromCommand(String[] command, URI buildDirectoryURI) {
- return getResourcesFromCommand(Arrays.asList(command), buildDirectoryURI);
- }
-
- /**
- * Strips the resources from the compile command. Use to produce the common
- * parts of the command shared by a number of resources.
- *
- * @param command
- * the original compile command
- * @param resources
- * the resources this command compiles for usually returned by
- * getResourcesFromCommand()
- * @return the stripped command
- * @since 6.1
- */
- default List<String> stripCommand(List<String> command, IResource[] resources) {
- return command;
- }
-
- /**
- * @since 6.1
- */
- default boolean matches(Map<String, String> properties) {
- for (Map.Entry<String, String> property : properties.entrySet()) {
- if (!property.getValue().equals(getProperty(property.getKey()))) {
- return false;
- }
- }
- return true;
- }
-
-}
+/******************************************************************************* + * Copyright (c) 2016 QNX Software Systems 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 + *******************************************************************************/ +package org.eclipse.cdt.core.build; + +import java.net.URI; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import org.eclipse.cdt.core.envvar.IEnvironmentVariable; +import org.eclipse.cdt.core.model.ILanguage; +import org.eclipse.cdt.core.parser.IExtendedScannerInfo; +import org.eclipse.core.resources.IBuildConfiguration; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.IAdaptable; + +/** + * Toolchains are a collection of tools that take the source code and converts + * it into an executable system. + * + * @since 6.0 + */ +public interface IToolChain extends IAdaptable { + + /** + * Property: The OS the toolchain builds for. + */ + static final String ATTR_OS = "os"; //$NON-NLS-1$ + + /** + * Property: The CPU architecture the toolchain supports. + */ + static final String ATTR_ARCH = "arch"; //$NON-NLS-1$ + + /** + * Property: A package ID to reflect different version/package line up of + * the platform this toolchain supports. + */ + static final String ATTR_PACKAGE = "package"; //$NON-NLS-1$ + + /** + * The provider of the toolchain. + * + * @return toolchain provider + */ + IToolChainProvider getProvider(); + + /** + * The ID of the toolchain + * + * @return toolchain ID + */ + String getId(); + + /** + * The version of the toolchain + * + * @deprecated the version doesn't matter. id's for a given type must be unique. + * @return toolchain version + */ + @Deprecated + String getVersion(); + + /** + * The user friendly name for the toolchain + * + * @return toolchain name + */ + String getName(); + + /** + * The type id for the toolchain. The combination of type id and toolchain id + * uniquely identify the toolchain in the system. + * + * @since 6.4 + */ + default String getTypeId() { + // Subclasses really need to override this. There can be multiple providers for + // a given toolchain type. + return getProvider().getId(); + } + + /** + * Returns an property of the toolchain. Used to determine applicability of + * a toolchain for a given situation. + * + * @param key + * key of the property + * @return value of the property or null if the toolchain does not have that + * property + */ + String getProperty(String key); + + /** + * Set a property on the toolchain. + * + * @param key + * key of the property + * @param value + * value of the property + */ + void setProperty(String key, String value); + + /** + * Return the environment variables to be set when invoking the tools in the + * toolchain. + * + * @return environment variables + */ + IEnvironmentVariable[] getVariables(); + + /** + * Return the environment variable of the given name used when invoking the + * toolchain. + * + * @param name + * environment variable name + * @return environment variable value + */ + IEnvironmentVariable getVariable(String name); + + /** + * Returns the error parser IDs use to create error markers for builds with + * this toolchain. + * + * @return error parser IDs + */ + String[] getErrorParserIds(); + + /** + * Returns the IDs for the binary parsers that can parse the build output of + * the toolchain. + * + * @return binary parser IDs for this toolchain + */ + String getBinaryParserId(); + + /** + * Get the scanner info for a given build config, command, base scanner + * info, resource and build directory. + * + * @param buildConfig + * the build configuration this scanner info applies to + * @param command + * the compile command that is used to build the resource + * @param baseScannerInfo + * base scanner info that this scanner info extends/replaces + * @param resource + * the resource this scanner info applies to, usually a source + * file + * @param buildDirectoryURI + * where the build command is run to build this resource + * @return scanner info for this resource + * @since 6.1 + */ + default IExtendedScannerInfo getScannerInfo(IBuildConfiguration buildConfig, List<String> command, + IExtendedScannerInfo baseScannerInfo, IResource resource, URI buildDirectoryURI) { + return null; + } + + @Deprecated + default IExtendedScannerInfo getScannerInfo(IBuildConfiguration buildConfig, Path command, String[] args, + IExtendedScannerInfo baseScannerInfo, IResource resource, URI buildDirectoryURI) { + List<String> commandStrings = new ArrayList<>(args.length + 1); + commandStrings.add(command.toString()); + commandStrings.addAll(Arrays.asList(args)); + return getScannerInfo(buildConfig, commandStrings, baseScannerInfo, resource, buildDirectoryURI); + } + + /** + * Return the default scanner info for this toolchain. This is used before + * any build information is available to provide at least a minimal scanner + * info based on the compiler built-ins. + * + * @param buildConfig + * the build configuration this scanner info applies to + * @param baseScannerInfo + * base scanner info that this scanner info extends/replaces + * @param language + * the source language that selects the tool to provide scanner + * info for + * @param buildDirectoryURI + * the build directory that would be used to run commands + * @returns default scanner info for this language + * @since 6.1 + */ + default IExtendedScannerInfo getDefaultScannerInfo(IBuildConfiguration buildConfig, + IExtendedScannerInfo baseScannerInfo, ILanguage language, URI buildDirectoryURI) { + return null; + } + + /** + * Returns the absolute path of the tool represented by the command + * + * @param command + * the command as it usually appears on the command line + * @return the absolute path to the tool for the command + */ + Path getCommandPath(Path command); + + /** + * Returns the list of compiler tools. + * + * @return list of compiler tools + */ + String[] getCompileCommands(); + + /** + * Returns the list of compiler tools for a given language. + * + * @param language + * the language for the commands + * @return the compile commands for the language + * @since 6.1 + */ + default String[] getCompileCommands(ILanguage language) { + return new String[0]; + } + + /** + * Returns the list of resources referenced in a compile command. + * + * @param command + * the compile command + * @param buildDirectoryURI + * the directory the compile command runs in + * @return the list of resources referenced in the compile command + * @since 6.1 + */ + default IResource[] getResourcesFromCommand(List<String> command, URI buildDirectoryURI) { + return new IResource[0]; + } + + @Deprecated + default IResource[] getResourcesFromCommand(String[] command, URI buildDirectoryURI) { + return getResourcesFromCommand(Arrays.asList(command), buildDirectoryURI); + } + + /** + * Strips the resources from the compile command. Use to produce the common + * parts of the command shared by a number of resources. + * + * @param command + * the original compile command + * @param resources + * the resources this command compiles for usually returned by + * getResourcesFromCommand() + * @return the stripped command + * @since 6.1 + */ + default List<String> stripCommand(List<String> command, IResource[] resources) { + return command; + } + + /** + * @since 6.1 + */ + default boolean matches(Map<String, String> properties) { + for (Map.Entry<String, String> property : properties.entrySet()) { + if (!property.getValue().equals(getProperty(property.getKey()))) { + return false; + } + } + return true; + } + +} diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/StreamProgressMonitor.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/StreamProgressMonitor.java index 551401d8e6a..aa7f7d2f31e 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/StreamProgressMonitor.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/StreamProgressMonitor.java @@ -1,109 +1,109 @@ -/*******************************************************************************
- * Copyright (c) 2000, 2012 QNX Software Systems 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:
- * QNX Software Systems - Initial API and implementation
+/******************************************************************************* + * Copyright (c) 2000, 2012 QNX Software Systems 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: + * QNX Software Systems - Initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.internal.core;
-
-import java.io.IOException;
-import java.io.OutputStream;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-
-/**
- * Helper class to report progress of the build via {@link IProgressMonitor}
- */
-public class StreamProgressMonitor extends OutputStream {
-
- private IProgressMonitor monitor;
- private OutputStream console;
- private final int fTotalWork;
- private int halfWay;
- private int currentIncrement = 2;
- private int nextProgress = currentIncrement;
- private int worked = 0;
-
- public StreamProgressMonitor(IProgressMonitor mon, OutputStream cos, int totalWork) {
- monitor = mon;
- console = cos;
- fTotalWork = totalWork;
- halfWay = fTotalWork / 2;
- monitor.beginTask("", fTotalWork); //$NON-NLS-1$
- }
-
- private void progressUpdate() {
- if (--nextProgress <= 0) {
- //we have exhausted the current increment, so report progress
- if (fTotalWork > worked) {
- monitor.worked(1);
- }
- worked++;
- if (worked >= halfWay) {
- //we have passed the current halfway point, so double the
- //increment and reset the halfway point.
- currentIncrement *= 2;
- halfWay += (fTotalWork - halfWay) / 2;
- }
- //reset the progress counter to another full increment
- nextProgress = currentIncrement;
- }
- }
- /**
- * @see java.io.OutputStream#close()
- */
- @Override
- public void close() throws IOException {
- if (console != null) {
- console.close();
- }
- monitor.done();
- }
-
- /**
- * @see java.io.OutputStream#flush()
- */
- @Override
- public void flush() throws IOException {
- if (console != null) {
- console.flush();
- }
- }
-
- /**
- * @see java.io.OutputStream#write(int)
- */
- @Override
- public synchronized void write(int b) throws IOException {
- if (console != null) {
- console.write(b);
- }
- progressUpdate();
- }
-
- /**
- * @see java.io.OutputStream#write(byte[], int, int)
- */
- @Override
- public synchronized void write(byte[] b, int off, int len) throws IOException {
- if (b == null) {
- throw new NullPointerException();
- } else if (off != 0 || (len < 0) || (len > b.length)) {
- throw new IndexOutOfBoundsException();
- } else if (len == 0) {
- return;
- }
- if (console != null) {
- console.write(b, off, len);
- }
- progressUpdate();
- }
-
- public int getWorkDone() {
- return worked;
- }
-}
+package org.eclipse.cdt.internal.core; + +import java.io.IOException; +import java.io.OutputStream; + +import org.eclipse.core.runtime.IProgressMonitor; + +/** + * Helper class to report progress of the build via {@link IProgressMonitor} + */ +public class StreamProgressMonitor extends OutputStream { + + private IProgressMonitor monitor; + private OutputStream console; + private final int fTotalWork; + private int halfWay; + private int currentIncrement = 2; + private int nextProgress = currentIncrement; + private int worked = 0; + + public StreamProgressMonitor(IProgressMonitor mon, OutputStream cos, int totalWork) { + monitor = mon; + console = cos; + fTotalWork = totalWork; + halfWay = fTotalWork / 2; + monitor.beginTask("", fTotalWork); //$NON-NLS-1$ + } + + private void progressUpdate() { + if (--nextProgress <= 0) { + //we have exhausted the current increment, so report progress + if (fTotalWork > worked) { + monitor.worked(1); + } + worked++; + if (worked >= halfWay) { + //we have passed the current halfway point, so double the + //increment and reset the halfway point. + currentIncrement *= 2; + halfWay += (fTotalWork - halfWay) / 2; + } + //reset the progress counter to another full increment + nextProgress = currentIncrement; + } + } + /** + * @see java.io.OutputStream#close() + */ + @Override + public void close() throws IOException { + if (console != null) { + console.close(); + } + monitor.done(); + } + + /** + * @see java.io.OutputStream#flush() + */ + @Override + public void flush() throws IOException { + if (console != null) { + console.flush(); + } + } + + /** + * @see java.io.OutputStream#write(int) + */ + @Override + public synchronized void write(int b) throws IOException { + if (console != null) { + console.write(b); + } + progressUpdate(); + } + + /** + * @see java.io.OutputStream#write(byte[], int, int) + */ + @Override + public synchronized void write(byte[] b, int off, int len) throws IOException { + if (b == null) { + throw new NullPointerException(); + } else if (off != 0 || (len < 0) || (len > b.length)) { + throw new IndexOutOfBoundsException(); + } else if (len == 0) { + return; + } + if (console != null) { + console.write(b, off, len); + } + progressUpdate(); + } + + public int getWorkDone() { + return worked; + } +} diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/ToolChainEnvironmentSupplier.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/ToolChainEnvironmentSupplier.java index 889fade0c6c..176312db830 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/ToolChainEnvironmentSupplier.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/ToolChainEnvironmentSupplier.java @@ -1,64 +1,64 @@ -/*******************************************************************************
- * Copyright (c) 2016 QNX Software Systems 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
- *******************************************************************************/
-package org.eclipse.cdt.internal.core.envvar;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.build.ICBuildConfiguration;
-import org.eclipse.cdt.core.build.IToolChain;
-import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
-import org.eclipse.core.resources.IBuildConfiguration;
-import org.eclipse.core.runtime.CoreException;
-
-public class ToolChainEnvironmentSupplier implements ICoreEnvironmentVariableSupplier {
-
- @Override
- public IEnvironmentVariable getVariable(String name, Object context) {
- if (context instanceof IBuildConfiguration) {
- ICBuildConfiguration config = ((IBuildConfiguration) context)
- .getAdapter(ICBuildConfiguration.class);
- if (config != null) {
- try {
- IToolChain toolChain = config.getToolChain();
- if (toolChain != null) {
- return toolChain.getVariable(name);
- }
- } catch (CoreException e) {
- CCorePlugin.log(e);
- return null;
- }
- }
- }
- return null;
- }
-
- @Override
- public IEnvironmentVariable[] getVariables(Object context) {
- if (context instanceof IBuildConfiguration) {
- ICBuildConfiguration config = ((IBuildConfiguration) context)
- .getAdapter(ICBuildConfiguration.class);
- if (config != null) {
- try {
- IToolChain toolChain = config.getToolChain();
- if (toolChain != null) {
- return toolChain.getVariables();
- }
- } catch (CoreException e) {
- CCorePlugin.log(e);
- return null;
- }
- }
- }
- return null;
- }
-
- @Override
- public boolean appendEnvironment(Object context) {
- return true;
- }
-
-}
+/******************************************************************************* + * Copyright (c) 2016 QNX Software Systems 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 + *******************************************************************************/ +package org.eclipse.cdt.internal.core.envvar; + +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.build.ICBuildConfiguration; +import org.eclipse.cdt.core.build.IToolChain; +import org.eclipse.cdt.core.envvar.IEnvironmentVariable; +import org.eclipse.core.resources.IBuildConfiguration; +import org.eclipse.core.runtime.CoreException; + +public class ToolChainEnvironmentSupplier implements ICoreEnvironmentVariableSupplier { + + @Override + public IEnvironmentVariable getVariable(String name, Object context) { + if (context instanceof IBuildConfiguration) { + ICBuildConfiguration config = ((IBuildConfiguration) context) + .getAdapter(ICBuildConfiguration.class); + if (config != null) { + try { + IToolChain toolChain = config.getToolChain(); + if (toolChain != null) { + return toolChain.getVariable(name); + } + } catch (CoreException e) { + CCorePlugin.log(e); + return null; + } + } + } + return null; + } + + @Override + public IEnvironmentVariable[] getVariables(Object context) { + if (context instanceof IBuildConfiguration) { + ICBuildConfiguration config = ((IBuildConfiguration) context) + .getAdapter(ICBuildConfiguration.class); + if (config != null) { + try { + IToolChain toolChain = config.getToolChain(); + if (toolChain != null) { + return toolChain.getVariables(); + } + } catch (CoreException e) { + CCorePlugin.log(e); + return null; + } + } + } + return null; + } + + @Override + public boolean appendEnvironment(Object context) { + return true; + } + +} diff --git a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateCategory.java b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateCategory.java index 265ee19d3a4..058b50fb320 100644 --- a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateCategory.java +++ b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateCategory.java @@ -1,44 +1,44 @@ -/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems 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:
- * Doug Schaefer - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.core.templateengine;
-
-import java.util.List;
-
-/**
- * @author Doug Schaefer
- * @since 5.4
- */
-public class TemplateCategory {
-
- private final String id;
- private String label;
- private List<String> parentCategoryIds;
-
- public TemplateCategory(String id, String label, List<String> parentCategoryIds) {
- this.id = id;
- this.label = label;
- this.parentCategoryIds = parentCategoryIds;
- }
-
- public String getId() {
- return id;
- }
-
- public String getLabel() {
- return label;
- }
-
- public List<String> getParentCategoryIds() {
- return parentCategoryIds;
- }
-
-}
+/******************************************************************************* + * Copyright (c) 2012 Wind River Systems 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: + * Doug Schaefer - initial API and implementation + *******************************************************************************/ + +package org.eclipse.cdt.core.templateengine; + +import java.util.List; + +/** + * @author Doug Schaefer + * @since 5.4 + */ +public class TemplateCategory { + + private final String id; + private String label; + private List<String> parentCategoryIds; + + public TemplateCategory(String id, String label, List<String> parentCategoryIds) { + this.id = id; + this.label = label; + this.parentCategoryIds = parentCategoryIds; + } + + public String getId() { + return id; + } + + public String getLabel() { + return label; + } + + public List<String> getParentCategoryIds() { + return parentCategoryIds; + } + +} diff --git a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateEngine2.java b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateEngine2.java index 1e172ca620c..a6aa4c1d247 100644 --- a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateEngine2.java +++ b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateEngine2.java @@ -1,33 +1,33 @@ -/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems 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:
- * Doug Schaefer - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.core.templateengine;
-
-/**
- * @author Doug Schaefer
- * @since 5.4
- */
-public class TemplateEngine2 extends TemplateEngine {
-
- /**
- * Project type for new templates. Default if not set in extension.
- */
- public static final String NEW_TEMPLATE = "newTemplate"; //$NON-NLS-1$
-
- public static TemplateEngine2 getDefault() {
- return (TemplateEngine2)TemplateEngine.getDefault();
- }
-
- public TemplateCategory getCategory(String id) {
- return categoryMap.get(id);
- }
-
-}
+/******************************************************************************* + * Copyright (c) 2012 Wind River Systems 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: + * Doug Schaefer - initial API and implementation + *******************************************************************************/ + +package org.eclipse.cdt.core.templateengine; + +/** + * @author Doug Schaefer + * @since 5.4 + */ +public class TemplateEngine2 extends TemplateEngine { + + /** + * Project type for new templates. Default if not set in extension. + */ + public static final String NEW_TEMPLATE = "newTemplate"; //$NON-NLS-1$ + + public static TemplateEngine2 getDefault() { + return (TemplateEngine2)TemplateEngine.getDefault(); + } + + public TemplateCategory getCategory(String id) { + return categoryMap.get(id); + } + +} diff --git a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateInfo2.java b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateInfo2.java index 478e0cf2618..5a11b23ed4f 100644 --- a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateInfo2.java +++ b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateInfo2.java @@ -1,39 +1,39 @@ -/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems 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:
- * Doug Schaefer - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.core.templateengine;
-
-import java.util.List;
-import java.util.Set;
-
-/**
- * Template info extended to include new stuff for new new project wizard UI.
- *
- * @author Doug Schaefer
- * @since 5.4
- */
-public class TemplateInfo2 extends TemplateInfo {
-
- private List<String> parentCategoryIds;
-
- public TemplateInfo2(String templateId, String projectTypeId, String filterPattern,
- String templatePath, String pluginId, Set<String> toolChainIdSet,
- Object extraPagesProvider, boolean isCategory, List<String> parentCategoryIds) {
- super(templateId, projectTypeId, filterPattern, templatePath, pluginId, toolChainIdSet,
- extraPagesProvider, isCategory);
- this.parentCategoryIds = parentCategoryIds;
- }
-
- public List<String> getParentCategoryIds() {
- return parentCategoryIds;
- }
-
-}
+/******************************************************************************* + * Copyright (c) 2012 Wind River Systems 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: + * Doug Schaefer - initial API and implementation + *******************************************************************************/ + +package org.eclipse.cdt.core.templateengine; + +import java.util.List; +import java.util.Set; + +/** + * Template info extended to include new stuff for new new project wizard UI. + * + * @author Doug Schaefer + * @since 5.4 + */ +public class TemplateInfo2 extends TemplateInfo { + + private List<String> parentCategoryIds; + + public TemplateInfo2(String templateId, String projectTypeId, String filterPattern, + String templatePath, String pluginId, Set<String> toolChainIdSet, + Object extraPagesProvider, boolean isCategory, List<String> parentCategoryIds) { + super(templateId, projectTypeId, filterPattern, templatePath, pluginId, toolChainIdSet, + extraPagesProvider, isCategory); + this.parentCategoryIds = parentCategoryIds; + } + + public List<String> getParentCategoryIds() { + return parentCategoryIds; + } + +} diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/Cygwin.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/Cygwin.java index 902f6e1ba54..80884db7c83 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/Cygwin.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/Cygwin.java @@ -1,333 +1,333 @@ -/*******************************************************************************
- * Copyright (c) 2012, 2013 Andrew Gvozdev 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:
- * Andrew Gvozdev - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.core;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.Collections;
-import java.util.Map;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
-import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
-import org.eclipse.cdt.core.settings.model.util.CDataUtil;
-import org.eclipse.cdt.utils.PathUtil;
-import org.eclipse.cdt.utils.WindowsRegistry;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-
-/**
- * A collection of cygwin-related utilities.
- */
-public class Cygwin {
- public static final String ENV_CYGWIN_HOME = "CYGWIN_HOME"; //$NON-NLS-1$
- private static final String ENV_PATH = "PATH"; //$NON-NLS-1$
-
- private static final String CYGPATH = "cygpath"; //$NON-NLS-1$
- private static final String DEFAULT_ROOT = "C:\\cygwin"; //$NON-NLS-1$
- private static final String CYGWIN_DLL = "cygwin1.dll"; //$NON-NLS-1$
- private static final String REGISTRY_KEY_SETUP = "SOFTWARE\\Cygwin\\setup"; //$NON-NLS-1$
- private static final String REGISTRY_KEY_SETUP_WIN64 = "SOFTWARE\\Wow6432Node\\Cygwin\\setup"; //$NON-NLS-1$
- // note that in Cygwin 1.7 the mount point storage has been moved out of the registry
- private static final String REGISTRY_KEY_MOUNTS = "SOFTWARE\\Cygnus Solutions\\Cygwin\\mounts v2\\"; //$NON-NLS-1$
- private static final String PATH_NAME = "native"; //$NON-NLS-1$
- private static final String ROOTPATTERN = "/"; //$NON-NLS-1$
- private static final char SLASH = '/';
- private static final char BACKSLASH = '\\';
-
- private static final boolean isWindowsPlatform = Platform.getOS().equals(Platform.OS_WIN32);
-
- private static String envPathValueCached = null;
- private static String envCygwinHomeValueCached = null;
- private static String cygwinLocation = null;
- private static boolean isCygwinLocationCached = false;
-
- private final static Map<String/*envPath*/, String /*cygpathLocation*/> cygpathLocationCache = Collections.synchronizedMap(new LRUCache<String, String>(1,20));
- private final static Map<String/*command*/, String /*translatedPath*/> translatedPathsCache = Collections.synchronizedMap(new LRUCache<String, String>(10,500));
-
- /**
- * Find location of "cygpath" utility on the file system.
- */
- private static String findCygpathLocation(String envPath) {
- if (envPath == null) {
- // $PATH from user preferences
- IEnvironmentVariable varPath = CCorePlugin.getDefault().getBuildEnvironmentManager().getVariable(ENV_PATH, (ICConfigurationDescription) null, true);
- if (varPath != null) {
- envPath = varPath.getValue();
- }
- }
-
- String cygpathLocation = cygpathLocationCache.get(envPath);
- if (cygpathLocation == null) {
- IPath loc = PathUtil.findProgramLocation(CYGPATH, envPath);
- cygpathLocation = loc != null ? loc.toOSString() : null;
- cygpathLocationCache.put(envPath, cygpathLocation);
- }
- return cygpathLocation;
- }
-
- /**
- * Check if cygwin path conversion utilities are available in the path.
- * Tells whether cygwin is installed in the path.
- *
- * @param envPath - list of directories to search for cygwin utilities separated
- * by path separator (format of environment variable $PATH)
- * or {@code null} to use current $PATH.
- * @return {@code true} if cygwin is available, {@code false} otherwise.
- */
- public static boolean isAvailable(String envPath) {
- return isWindowsPlatform && findCygpathLocation(envPath) != null;
- }
-
- /**
- * Check if cygwin path conversion utilities are available in $PATH.
- * Tells whether cygwin is installed in the path.
- *
- * @return {@code true} if cygwin is available, {@code false} otherwise.
- */
- public static boolean isAvailable() {
- return isWindowsPlatform && findCygpathLocation(null) != null;
- }
-
- /**
- * Run program (assuming cygpath) and return the translated path which is the first line of output.
- */
- private static String runCygpath(String[] args) throws IOException {
- String command = getCommand(args);
- String translatedPath = translatedPathsCache.get(command);
- if (translatedPath == null) {
- Process cygpathProcess = Runtime.getRuntime().exec(args);
- BufferedReader stdout = new BufferedReader(new InputStreamReader(cygpathProcess.getInputStream()));
- String firstLine = null;
- try {
- firstLine = stdout.readLine();
- } finally {
- stdout.close();
- }
- if (firstLine == null) {
- throw new IOException("Unable read output from command=[" + command + "]"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- translatedPath = firstLine.trim();
- translatedPathsCache.put(command, translatedPath);
- }
-
- return translatedPath;
- }
-
- /**
- * Construct a command from arguments array.
- */
- private static String getCommand(String[] args) {
- String command = ""; //$NON-NLS-1$
- for (String arg : args) {
- command = command + arg + ' ';
- }
- return command.trim();
- }
-
- /**
- * Conversion from Cygwin path to Windows path.
- * Note that there is no need to cache results, they are already cached internally.
- *
- * @param cygwinPath - cygwin path.
- * @param envPath - list of directories to search for cygwin utilities separated
- * by path separator (format of environment variable $PATH).
- * @return Windows style converted path. Note that that also converts cygwin links to their targets.
- *
- * @throws UnsupportedOperationException if Cygwin is unavailable.
- * @throws IOException on IO problem.
- */
- public static String cygwinToWindowsPath(String cygwinPath, String envPath) throws IOException, UnsupportedOperationException {
- if (cygwinPath == null || cygwinPath.trim().length() == 0)
- return cygwinPath;
-
- if (!isWindowsPlatform) {
- throw new UnsupportedOperationException("Not a Windows system, Cygwin is unavailable."); //$NON-NLS-1$
- }
-
- String cygpathLocation = findCygpathLocation(envPath);
- if (cygpathLocation == null) {
- throw new UnsupportedOperationException(CYGPATH + " is not in the system search path."); //$NON-NLS-1$
- }
-
- String windowsPath = runCygpath(new String[] {cygpathLocation, "-w", cygwinPath}); //$NON-NLS-1$
- return windowsPath;
- }
-
- /**
- * Conversion from Cygwin path to Windows path.
- * Note that there is no need to cache results, they are already cached internally.
- *
- * @param cygwinPath - cygwin path.
- * @return Windows style converted path. Note that that also converts cygwin links to their targets.
- *
- * @throws UnsupportedOperationException if Cygwin is unavailable.
- * @throws IOException on IO problem.
- */
- public static String cygwinToWindowsPath(String cygwinPath) throws IOException, UnsupportedOperationException {
- return cygwinToWindowsPath(cygwinPath, null);
- }
-
- /**
- * Conversion from Windows path to Cygwin path.
- * Note that there is no need to cache results, they are already cached internally.
- *
- * @param windowsPath - Windows path.
- * @param envPath - list of directories to search for cygwin utilities (value of environment variable $PATH).
- * @return Cygwin style converted path.
- *
- * @throws UnsupportedOperationException if Cygwin is unavailable.
- * @throws IOException on IO problem.
- */
- public static String windowsToCygwinPath(String windowsPath, String envPath) throws IOException, UnsupportedOperationException {
- if (windowsPath == null || windowsPath.trim().length() == 0)
- return windowsPath;
-
- if (!isWindowsPlatform) {
- throw new UnsupportedOperationException("Not a Windows system, Cygwin is unavailable."); //$NON-NLS-1$
- }
-
- String cygpathLocation = findCygpathLocation(envPath);
- if (cygpathLocation == null) {
- throw new UnsupportedOperationException(CYGPATH + " is not in the system search path."); //$NON-NLS-1$
- }
-
- String cygwinPath = runCygpath(new String[] {cygpathLocation, "-u", windowsPath}); //$NON-NLS-1$
- return cygwinPath;
- }
-
- /**
- * Conversion from Windows path to Cygwin path.
- * Note that there is no need to cache results, they are already cached internally.
- *
- * @param windowsPath - Windows path.
- * @return Cygwin style converted path.
- *
- * @throws UnsupportedOperationException if Cygwin is unavailable.
- * @throws IOException on IO problem.
- */
- public static String windowsToCygwinPath(String windowsPath) throws IOException, UnsupportedOperationException {
- return windowsToCygwinPath(windowsPath, null);
- }
-
- /**
- * Find location where Cygwin is installed. A number of locations is being checked,
- * such as environment variable $CYGWIN_HOME, $PATH, Windows registry et al.
- * <br><br>
- * If you use this do not cache results to ensure user preferences are accounted for.
- * Please rely on internal caching.
- *
- * @return Location of Cygwin root folder "/" on file system in Windows format.
- */
- public static String getCygwinHome() {
- if (!isWindowsPlatform) {
- return null;
- }
-
- IEnvironmentVariable varPath = CCorePlugin.getDefault().getBuildEnvironmentManager().getVariable(ENV_PATH, (ICConfigurationDescription) null, true);
- String envPathValue = varPath != null ? varPath.getValue() : null;
- IEnvironmentVariable varCygwinHome = CCorePlugin.getDefault().getBuildEnvironmentManager().getVariable(ENV_CYGWIN_HOME, (ICConfigurationDescription) null, true);
- String envCygwinHomeValue = varCygwinHome != null ? varCygwinHome.getValue() : null;
-
- // isCygwinLocationCached is used to figure fact of caching when all cached objects are null
- if (isCygwinLocationCached && CDataUtil.objectsEqual(envPathValue, envPathValueCached) && CDataUtil.objectsEqual(envCygwinHomeValue, envCygwinHomeValueCached)) {
- return cygwinLocation;
- }
-
- cygwinLocation = findCygwinRoot(envPathValue, envCygwinHomeValue);
-
- envPathValueCached = envPathValue;
- envCygwinHomeValueCached = envCygwinHomeValue;
- isCygwinLocationCached = true;
-
- return cygwinLocation;
- }
-
- /**
- * Reads required value from registry. Looks in both
- * HKEY_CURRENT_USER and HKEY_LOCAL_MACHINE
- *
- * @param key Registry key
- * @param name Registry value to read
- * @return corresponding string value or null if nothing found
- */
- private static String readValueFromRegistry(String key, String name) {
- WindowsRegistry registry = WindowsRegistry.getRegistry();
- if (registry != null) {
- String s = registry.getCurrentUserValue(key, name);
- if(s == null) {
- s = registry.getLocalMachineValue(key, name);
- }
-
- if (s != null) {
- return (s.replace(BACKSLASH, SLASH));
- }
- }
- return null;
- }
-
- /**
- * @return The absolute path to cygwin's root or null if not found
- */
- private static String findCygwinRoot(String envPathValue, String envCygwinHomeValue) {
- String rootValue = null;
-
- // Check $CYGWIN_HOME
- if (envCygwinHomeValue != null && !envCygwinHomeValue.isEmpty()) {
- IPath location = new Path(envCygwinHomeValue + "/bin/" + CYGWIN_DLL); //$NON-NLS-1$
- if (location.toFile().exists()) {
- // get rootValue from "rootValue\bin\cygwin1.dll"
- rootValue = location.removeLastSegments(2).toOSString();
- }
- }
-
- // Look in PATH values. Look for cygwin1.dll
- if(rootValue == null) {
- IPath location = PathUtil.findProgramLocation(CYGWIN_DLL, envPathValue);
- if (location != null) {
- // get rootValue from "rootValue\bin\cygwin1.dll"
- rootValue = location.removeLastSegments(2).toOSString();
- }
- }
-
- // Try to find the root dir in SOFTWARE\Cygwin\setup
- if(rootValue == null) {
- rootValue = readValueFromRegistry(REGISTRY_KEY_SETUP, "rootdir"); //$NON-NLS-1$
- }
-
- // Try to find the root dir in SOFTWARE\Wow6432Node\Cygwin\setup
- if(rootValue == null) {
- rootValue = readValueFromRegistry(REGISTRY_KEY_SETUP_WIN64, "rootdir"); //$NON-NLS-1$
- }
-
- // Try to find the root dir in SOFTWARE\Cygnus Solutions
- if (rootValue == null) {
- rootValue = readValueFromRegistry(REGISTRY_KEY_MOUNTS + ROOTPATTERN, PATH_NAME);
- }
-
- // Try the default Cygwin install dir
- if(rootValue == null) {
- File file = new File(DEFAULT_ROOT);
- if (file.exists() && file.isDirectory())
- rootValue = DEFAULT_ROOT;
- }
-
- if(rootValue != null) {
- rootValue = rootValue.replace(BACKSLASH, SLASH);
- }
-
- return rootValue;
- }
-
-}
+/******************************************************************************* + * Copyright (c) 2012, 2013 Andrew Gvozdev 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: + * Andrew Gvozdev - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.core; + +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Collections; +import java.util.Map; + +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.envvar.IEnvironmentVariable; +import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; +import org.eclipse.cdt.core.settings.model.util.CDataUtil; +import org.eclipse.cdt.utils.PathUtil; +import org.eclipse.cdt.utils.WindowsRegistry; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Platform; + +/** + * A collection of cygwin-related utilities. + */ +public class Cygwin { + public static final String ENV_CYGWIN_HOME = "CYGWIN_HOME"; //$NON-NLS-1$ + private static final String ENV_PATH = "PATH"; //$NON-NLS-1$ + + private static final String CYGPATH = "cygpath"; //$NON-NLS-1$ + private static final String DEFAULT_ROOT = "C:\\cygwin"; //$NON-NLS-1$ + private static final String CYGWIN_DLL = "cygwin1.dll"; //$NON-NLS-1$ + private static final String REGISTRY_KEY_SETUP = "SOFTWARE\\Cygwin\\setup"; //$NON-NLS-1$ + private static final String REGISTRY_KEY_SETUP_WIN64 = "SOFTWARE\\Wow6432Node\\Cygwin\\setup"; //$NON-NLS-1$ + // note that in Cygwin 1.7 the mount point storage has been moved out of the registry + private static final String REGISTRY_KEY_MOUNTS = "SOFTWARE\\Cygnus Solutions\\Cygwin\\mounts v2\\"; //$NON-NLS-1$ + private static final String PATH_NAME = "native"; //$NON-NLS-1$ + private static final String ROOTPATTERN = "/"; //$NON-NLS-1$ + private static final char SLASH = '/'; + private static final char BACKSLASH = '\\'; + + private static final boolean isWindowsPlatform = Platform.getOS().equals(Platform.OS_WIN32); + + private static String envPathValueCached = null; + private static String envCygwinHomeValueCached = null; + private static String cygwinLocation = null; + private static boolean isCygwinLocationCached = false; + + private final static Map<String/*envPath*/, String /*cygpathLocation*/> cygpathLocationCache = Collections.synchronizedMap(new LRUCache<String, String>(1,20)); + private final static Map<String/*command*/, String /*translatedPath*/> translatedPathsCache = Collections.synchronizedMap(new LRUCache<String, String>(10,500)); + + /** + * Find location of "cygpath" utility on the file system. + */ + private static String findCygpathLocation(String envPath) { + if (envPath == null) { + // $PATH from user preferences + IEnvironmentVariable varPath = CCorePlugin.getDefault().getBuildEnvironmentManager().getVariable(ENV_PATH, (ICConfigurationDescription) null, true); + if (varPath != null) { + envPath = varPath.getValue(); + } + } + + String cygpathLocation = cygpathLocationCache.get(envPath); + if (cygpathLocation == null) { + IPath loc = PathUtil.findProgramLocation(CYGPATH, envPath); + cygpathLocation = loc != null ? loc.toOSString() : null; + cygpathLocationCache.put(envPath, cygpathLocation); + } + return cygpathLocation; + } + + /** + * Check if cygwin path conversion utilities are available in the path. + * Tells whether cygwin is installed in the path. + * + * @param envPath - list of directories to search for cygwin utilities separated + * by path separator (format of environment variable $PATH) + * or {@code null} to use current $PATH. + * @return {@code true} if cygwin is available, {@code false} otherwise. + */ + public static boolean isAvailable(String envPath) { + return isWindowsPlatform && findCygpathLocation(envPath) != null; + } + + /** + * Check if cygwin path conversion utilities are available in $PATH. + * Tells whether cygwin is installed in the path. + * + * @return {@code true} if cygwin is available, {@code false} otherwise. + */ + public static boolean isAvailable() { + return isWindowsPlatform && findCygpathLocation(null) != null; + } + + /** + * Run program (assuming cygpath) and return the translated path which is the first line of output. + */ + private static String runCygpath(String[] args) throws IOException { + String command = getCommand(args); + String translatedPath = translatedPathsCache.get(command); + if (translatedPath == null) { + Process cygpathProcess = Runtime.getRuntime().exec(args); + BufferedReader stdout = new BufferedReader(new InputStreamReader(cygpathProcess.getInputStream())); + String firstLine = null; + try { + firstLine = stdout.readLine(); + } finally { + stdout.close(); + } + if (firstLine == null) { + throw new IOException("Unable read output from command=[" + command + "]"); //$NON-NLS-1$ //$NON-NLS-2$ + } + translatedPath = firstLine.trim(); + translatedPathsCache.put(command, translatedPath); + } + + return translatedPath; + } + + /** + * Construct a command from arguments array. + */ + private static String getCommand(String[] args) { + String command = ""; //$NON-NLS-1$ + for (String arg : args) { + command = command + arg + ' '; + } + return command.trim(); + } + + /** + * Conversion from Cygwin path to Windows path. + * Note that there is no need to cache results, they are already cached internally. + * + * @param cygwinPath - cygwin path. + * @param envPath - list of directories to search for cygwin utilities separated + * by path separator (format of environment variable $PATH). + * @return Windows style converted path. Note that that also converts cygwin links to their targets. + * + * @throws UnsupportedOperationException if Cygwin is unavailable. + * @throws IOException on IO problem. + */ + public static String cygwinToWindowsPath(String cygwinPath, String envPath) throws IOException, UnsupportedOperationException { + if (cygwinPath == null || cygwinPath.trim().length() == 0) + return cygwinPath; + + if (!isWindowsPlatform) { + throw new UnsupportedOperationException("Not a Windows system, Cygwin is unavailable."); //$NON-NLS-1$ + } + + String cygpathLocation = findCygpathLocation(envPath); + if (cygpathLocation == null) { + throw new UnsupportedOperationException(CYGPATH + " is not in the system search path."); //$NON-NLS-1$ + } + + String windowsPath = runCygpath(new String[] {cygpathLocation, "-w", cygwinPath}); //$NON-NLS-1$ + return windowsPath; + } + + /** + * Conversion from Cygwin path to Windows path. + * Note that there is no need to cache results, they are already cached internally. + * + * @param cygwinPath - cygwin path. + * @return Windows style converted path. Note that that also converts cygwin links to their targets. + * + * @throws UnsupportedOperationException if Cygwin is unavailable. + * @throws IOException on IO problem. + */ + public static String cygwinToWindowsPath(String cygwinPath) throws IOException, UnsupportedOperationException { + return cygwinToWindowsPath(cygwinPath, null); + } + + /** + * Conversion from Windows path to Cygwin path. + * Note that there is no need to cache results, they are already cached internally. + * + * @param windowsPath - Windows path. + * @param envPath - list of directories to search for cygwin utilities (value of environment variable $PATH). + * @return Cygwin style converted path. + * + * @throws UnsupportedOperationException if Cygwin is unavailable. + * @throws IOException on IO problem. + */ + public static String windowsToCygwinPath(String windowsPath, String envPath) throws IOException, UnsupportedOperationException { + if (windowsPath == null || windowsPath.trim().length() == 0) + return windowsPath; + + if (!isWindowsPlatform) { + throw new UnsupportedOperationException("Not a Windows system, Cygwin is unavailable."); //$NON-NLS-1$ + } + + String cygpathLocation = findCygpathLocation(envPath); + if (cygpathLocation == null) { + throw new UnsupportedOperationException(CYGPATH + " is not in the system search path."); //$NON-NLS-1$ + } + + String cygwinPath = runCygpath(new String[] {cygpathLocation, "-u", windowsPath}); //$NON-NLS-1$ + return cygwinPath; + } + + /** + * Conversion from Windows path to Cygwin path. + * Note that there is no need to cache results, they are already cached internally. + * + * @param windowsPath - Windows path. + * @return Cygwin style converted path. + * + * @throws UnsupportedOperationException if Cygwin is unavailable. + * @throws IOException on IO problem. + */ + public static String windowsToCygwinPath(String windowsPath) throws IOException, UnsupportedOperationException { + return windowsToCygwinPath(windowsPath, null); + } + + /** + * Find location where Cygwin is installed. A number of locations is being checked, + * such as environment variable $CYGWIN_HOME, $PATH, Windows registry et al. + * <br><br> + * If you use this do not cache results to ensure user preferences are accounted for. + * Please rely on internal caching. + * + * @return Location of Cygwin root folder "/" on file system in Windows format. + */ + public static String getCygwinHome() { + if (!isWindowsPlatform) { + return null; + } + + IEnvironmentVariable varPath = CCorePlugin.getDefault().getBuildEnvironmentManager().getVariable(ENV_PATH, (ICConfigurationDescription) null, true); + String envPathValue = varPath != null ? varPath.getValue() : null; + IEnvironmentVariable varCygwinHome = CCorePlugin.getDefault().getBuildEnvironmentManager().getVariable(ENV_CYGWIN_HOME, (ICConfigurationDescription) null, true); + String envCygwinHomeValue = varCygwinHome != null ? varCygwinHome.getValue() : null; + + // isCygwinLocationCached is used to figure fact of caching when all cached objects are null + if (isCygwinLocationCached && CDataUtil.objectsEqual(envPathValue, envPathValueCached) && CDataUtil.objectsEqual(envCygwinHomeValue, envCygwinHomeValueCached)) { + return cygwinLocation; + } + + cygwinLocation = findCygwinRoot(envPathValue, envCygwinHomeValue); + + envPathValueCached = envPathValue; + envCygwinHomeValueCached = envCygwinHomeValue; + isCygwinLocationCached = true; + + return cygwinLocation; + } + + /** + * Reads required value from registry. Looks in both + * HKEY_CURRENT_USER and HKEY_LOCAL_MACHINE + * + * @param key Registry key + * @param name Registry value to read + * @return corresponding string value or null if nothing found + */ + private static String readValueFromRegistry(String key, String name) { + WindowsRegistry registry = WindowsRegistry.getRegistry(); + if (registry != null) { + String s = registry.getCurrentUserValue(key, name); + if(s == null) { + s = registry.getLocalMachineValue(key, name); + } + + if (s != null) { + return (s.replace(BACKSLASH, SLASH)); + } + } + return null; + } + + /** + * @return The absolute path to cygwin's root or null if not found + */ + private static String findCygwinRoot(String envPathValue, String envCygwinHomeValue) { + String rootValue = null; + + // Check $CYGWIN_HOME + if (envCygwinHomeValue != null && !envCygwinHomeValue.isEmpty()) { + IPath location = new Path(envCygwinHomeValue + "/bin/" + CYGWIN_DLL); //$NON-NLS-1$ + if (location.toFile().exists()) { + // get rootValue from "rootValue\bin\cygwin1.dll" + rootValue = location.removeLastSegments(2).toOSString(); + } + } + + // Look in PATH values. Look for cygwin1.dll + if(rootValue == null) { + IPath location = PathUtil.findProgramLocation(CYGWIN_DLL, envPathValue); + if (location != null) { + // get rootValue from "rootValue\bin\cygwin1.dll" + rootValue = location.removeLastSegments(2).toOSString(); + } + } + + // Try to find the root dir in SOFTWARE\Cygwin\setup + if(rootValue == null) { + rootValue = readValueFromRegistry(REGISTRY_KEY_SETUP, "rootdir"); //$NON-NLS-1$ + } + + // Try to find the root dir in SOFTWARE\Wow6432Node\Cygwin\setup + if(rootValue == null) { + rootValue = readValueFromRegistry(REGISTRY_KEY_SETUP_WIN64, "rootdir"); //$NON-NLS-1$ + } + + // Try to find the root dir in SOFTWARE\Cygnus Solutions + if (rootValue == null) { + rootValue = readValueFromRegistry(REGISTRY_KEY_MOUNTS + ROOTPATTERN, PATH_NAME); + } + + // Try the default Cygwin install dir + if(rootValue == null) { + File file = new File(DEFAULT_ROOT); + if (file.exists() && file.isDirectory()) + rootValue = DEFAULT_ROOT; + } + + if(rootValue != null) { + rootValue = rootValue.replace(BACKSLASH, SLASH); + } + + return rootValue; + } + +} diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/LRUCache.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/LRUCache.java index 817613c6406..df63401266e 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/LRUCache.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/LRUCache.java @@ -1,50 +1,50 @@ -/*******************************************************************************
- * Copyright (c) 2013 Andrew Gvozdev 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:
- * Andrew Gvozdev - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.core;
-
-import java.util.LinkedHashMap;
-import java.util.Map.Entry;
-
-/**
- * A simple cache with limited number of items in the cache. LRUCache discards the Least Recently Used items first.
- * Based on {@link LinkedHashMap}. Note that {@link LinkedHashMap} has built-in facility to support cache like that
- * which is described in its JavaDoc.
- */
-public class LRUCache<K, V> extends LinkedHashMap<K, V> {
- private int fLimit;
-
- /**
- * Constructs an empty LRUCache with the specified limit on the number of items in the cache.
- *
- * @param limit - the maximum number of items to keep in the cache.
- */
- public LRUCache(int limit) {
- super(limit, 0.75f, true);
- fLimit= limit;
- }
-
- /**
- * Constructs an empty LRUCache with the specified initial capacity and limit on the number of items in the cache.
- *
- * @param initialCapacity - initial capacity.
- * @param limit - the maximum number of items to keep in the cache.
- */
- public LRUCache(int initialCapacity, int limit) {
- super(initialCapacity, 0.75f, true);
- fLimit= limit;
- }
-
- @Override
- protected boolean removeEldestEntry(Entry<K, V> eldest) {
- return size() >= fLimit;
- }
+/******************************************************************************* + * Copyright (c) 2013 Andrew Gvozdev 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: + * Andrew Gvozdev - initial API and implementation + *******************************************************************************/ + +package org.eclipse.cdt.internal.core; + +import java.util.LinkedHashMap; +import java.util.Map.Entry; + +/** + * A simple cache with limited number of items in the cache. LRUCache discards the Least Recently Used items first. + * Based on {@link LinkedHashMap}. Note that {@link LinkedHashMap} has built-in facility to support cache like that + * which is described in its JavaDoc. + */ +public class LRUCache<K, V> extends LinkedHashMap<K, V> { + private int fLimit; + + /** + * Constructs an empty LRUCache with the specified limit on the number of items in the cache. + * + * @param limit - the maximum number of items to keep in the cache. + */ + public LRUCache(int limit) { + super(limit, 0.75f, true); + fLimit= limit; + } + + /** + * Constructs an empty LRUCache with the specified initial capacity and limit on the number of items in the cache. + * + * @param initialCapacity - initial capacity. + * @param limit - the maximum number of items to keep in the cache. + */ + public LRUCache(int initialCapacity, int limit) { + super(initialCapacity, 0.75f, true); + fLimit= limit; + } + + @Override + protected boolean removeEldestEntry(Entry<K, V> eldest) { + return size() >= fLimit; + } }
\ No newline at end of file diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/MinGW.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/MinGW.java index ad62fc2378b..e1cbceb5888 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/MinGW.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/MinGW.java @@ -1,359 +1,359 @@ -/*******************************************************************************
- * Copyright (c) 2012, 2013 Andrew Gvozdev 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:
- * Andrew Gvozdev - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.core;
-
-import java.io.File;
-import java.util.Collections;
-import java.util.Map;
-import java.util.WeakHashMap;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
-import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
-import org.eclipse.cdt.core.settings.model.util.CDataUtil;
-import org.eclipse.cdt.utils.PathUtil;
-import org.eclipse.cdt.utils.WindowsRegistry;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-
-/**
- * A collection of MinGW-related utility methods.
- */
-public class MinGW {
- public static final String ENV_MINGW_HOME = "MINGW_HOME"; //$NON-NLS-1$
- public static final String ENV_MSYS_HOME = "MSYS_HOME"; //$NON-NLS-1$
- private static final String ENV_PATH = "PATH"; //$NON-NLS-1$
-
- private static final boolean isWindowsPlatform = Platform.getOS().equals(Platform.OS_WIN32);
-
- private static String envPathValueCached = null;
- private static String envMinGWHomeValueCached = null;
- private static String minGWLocation = null;
- private static boolean isMinGWLocationCached = false;
-
- private static String envMinGWHomeValueCached_msys = null;
- private static String mSysLocation = null;
- private static boolean isMSysLocationCached = false;
-
- private final static Map<String/* envPath */, String/* mingwLocation */> mingwLocationCache = Collections
- .synchronizedMap(new WeakHashMap<String, String>(1));
-
- /**
- * @return The absolute path to MinGW root folder or {@code null} if not
- * found
- */
- private static String findMinGWRoot(String envPathValue, String envMinGWHomeValue) {
- String rootValue = null;
-
- // Check $MINGW_HOME
- if (envMinGWHomeValue != null && !envMinGWHomeValue.isEmpty()) {
- IPath mingwBinDir = new Path(envMinGWHomeValue + "\\bin"); //$NON-NLS-1$
- if (mingwBinDir.toFile().isDirectory()) {
- rootValue = mingwBinDir.removeLastSegments(1).toOSString();
- }
- }
-
- // Try the mingw directory in the platform install directory
- // CDT distributions like Wascana may distribute MinGW like that
- if (rootValue == null) {
- IPath installPath = new Path(Platform.getInstallLocation().getURL().getFile());
- IPath mingwBinDir = installPath.append("mingw\\bin"); //$NON-NLS-1$
- if (mingwBinDir.toFile().isDirectory()) {
- rootValue = mingwBinDir.removeLastSegments(1).toOSString();
- }
- }
-
- // Look in PATH values. Look for mingw32-gcc.exe or
- // x86_64-w64-mingw32-gcc.exe
- if (rootValue == null) {
- rootValue = findMingwInPath(envPathValue);
- }
-
- // Look in MSYS2
- if (rootValue == null) {
- WindowsRegistry registry = WindowsRegistry.getRegistry();
- String uninstallKey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"; //$NON-NLS-1$
- String subkey;
- boolean on64bit = Platform.getOSArch().equals(Platform.ARCH_X86_64);
- String key32bit = null;
- for (int i = 0; (subkey = registry.getCurrentUserKeyName(uninstallKey, i)) != null; i++) {
- String compKey = uninstallKey + '\\' + subkey;
- String displayName = registry.getCurrentUserValue(compKey, "DisplayName"); //$NON-NLS-1$
- if (on64bit) {
- if ("MSYS2 64bit".equals(displayName)) { //$NON-NLS-1$
- String installLocation = registry.getCurrentUserValue(compKey, "InstallLocation"); //$NON-NLS-1$
- String mingwLocation = installLocation + "\\mingw64"; //$NON-NLS-1$
- File gccFile = new File(mingwLocation + "\\bin\\gcc.exe"); //$NON-NLS-1$
- if (gccFile.canExecute()) {
- rootValue = mingwLocation;
- break;
- } else {
- mingwLocation = installLocation + "\\mingw32"; //$NON-NLS-1$
- gccFile = new File(mingwLocation + "\\bin\\gcc.exe"); //$NON-NLS-1$
- if (gccFile.canExecute()) {
- rootValue = mingwLocation;
- break;
- }
- }
- } else if ("MSYS2 32bit".equals(displayName)) { //$NON-NLS-1$
- key32bit = compKey;
- }
- } else {
- if ("MSYS2 32bit".equals(displayName)) { //$NON-NLS-1$
- String installLocation = registry.getCurrentUserValue(compKey, "InstallLocation"); //$NON-NLS-1$
- String mingwLocation = installLocation + "\\mingw32"; //$NON-NLS-1$
- File gccFile = new File(mingwLocation + "\\bin\\gcc.exe"); //$NON-NLS-1$
- if (gccFile.canExecute()) {
- rootValue = mingwLocation;
- break;
- }
- }
- }
- }
-
- if (on64bit && key32bit != null) {
- String installLocation = registry.getCurrentUserValue(key32bit, "InstallLocation"); //$NON-NLS-1$
- String mingwLocation = installLocation + "\\mingw64"; //$NON-NLS-1$
- File gccFile = new File(mingwLocation + "\\bin\\gcc.exe"); //$NON-NLS-1$
- if (gccFile.canExecute()) {
- rootValue = mingwLocation;
- } else {
- mingwLocation = installLocation + "\\mingw32"; //$NON-NLS-1$
- gccFile = new File(mingwLocation + "\\bin\\gcc.exe"); //$NON-NLS-1$
- if (gccFile.canExecute()) {
- rootValue = mingwLocation;
- }
- }
- }
- }
-
- // Try the default MinGW install dir
- if (rootValue == null) {
- IPath mingwBinDir = new Path("C:\\MinGW"); //$NON-NLS-1$
- if (mingwBinDir.toFile().isDirectory()) {
- rootValue = mingwBinDir.toOSString();
- }
- }
-
- return rootValue;
- }
-
- private static String findMingwInPath(String envPath) {
- if (envPath == null) {
- // $PATH from user preferences
- IEnvironmentVariable varPath = CCorePlugin.getDefault().getBuildEnvironmentManager()
- .getVariable(ENV_PATH, (ICConfigurationDescription) null, true);
- if (varPath != null) {
- envPath = varPath.getValue();
- }
- }
-
- String mingwLocation = mingwLocationCache.get(envPath);
- // check if WeakHashMap contains the key as null may be the cached value
- if (mingwLocation == null && !mingwLocationCache.containsKey(envPath)) {
- // Check for MinGW-w64 on Windows 64 bit, see
- // http://mingw-w64.sourceforge.net/
- if (Platform.ARCH_X86_64.equals(Platform.getOSArch())) {
- IPath gcc64Loc = PathUtil.findProgramLocation("x86_64-w64-mingw32-gcc.exe", envPath); //$NON-NLS-1$
- if (gcc64Loc != null) {
- mingwLocation = gcc64Loc.removeLastSegments(2).toOSString();
- }
- }
-
- // Look for mingw32-gcc.exe
- if (mingwLocation == null) {
- IPath gccLoc = PathUtil.findProgramLocation("mingw32-gcc.exe", envPath); //$NON-NLS-1$
- if (gccLoc != null) {
- mingwLocation = gccLoc.removeLastSegments(2).toOSString();
- }
- }
- mingwLocationCache.put(envPath, mingwLocation);
- }
-
- return mingwLocation;
- }
-
- private static String findMSysRoot(String envMinGWHomeValue) {
- String msysHome = null;
-
- // Look in the install location parent dir
- IPath installPath = new Path(Platform.getInstallLocation().getURL().getFile());
- IPath installMsysBin = installPath.append("msys\\bin"); //$NON-NLS-1$
- if (installMsysBin.toFile().isDirectory()) {
- msysHome = installMsysBin.removeLastSegments(1).toOSString();
- }
-
- // Look under $MINGW_HOME
- if (msysHome == null) {
- if (envMinGWHomeValue != null && !envMinGWHomeValue.isEmpty()) {
- IPath minGwMsysBin = new Path(envMinGWHomeValue + "\\msys\\1.0\\bin"); //$NON-NLS-1$
- if (minGwMsysBin.toFile().isDirectory()) {
- msysHome = minGwMsysBin.removeLastSegments(1).toOSString();
- }
- }
- }
-
- // Try under MSYS2
- if (msysHome == null) {
- // Give preference to msys64 on 64-bit platforms and ignore 64 on
- // 32-bit platforms
- WindowsRegistry registry = WindowsRegistry.getRegistry();
- String uninstallKey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"; //$NON-NLS-1$
- String subkey;
- boolean on64bit = Platform.getOSArch().equals(Platform.ARCH_X86_64);
- String key32bit = null;
- for (int i = 0; (subkey = registry.getCurrentUserKeyName(uninstallKey, i)) != null; i++) {
- String compKey = uninstallKey + '\\' + subkey;
- String displayName = registry.getCurrentUserValue(compKey, "DisplayName"); //$NON-NLS-1$
- if (on64bit) {
- if ("MSYS2 64bit".equals(displayName)) { //$NON-NLS-1$
- String home = registry.getCurrentUserValue(compKey, "InstallLocation"); //$NON-NLS-1$
- if (new File(home).isDirectory()) {
- msysHome = home;
- break;
- }
- } else if ("MSYS2 32bit".equals(displayName)) { //$NON-NLS-1$
- key32bit = compKey;
- }
- } else {
- if ("MSYS2 32bit".equals(displayName)) { //$NON-NLS-1$
- String home = registry.getCurrentUserValue(compKey, "InstallLocation"); //$NON-NLS-1$
- if (new File(home).isDirectory()) {
- msysHome = home;
- break;
- }
- }
- }
- }
-
- if (on64bit && key32bit != null) {
- String home = registry.getCurrentUserValue(key32bit, "InstallLocation"); //$NON-NLS-1$
- if (new File(home).isDirectory()) {
- msysHome = home;
- }
- }
- }
-
- // Try under default MinGW dir
- if (msysHome == null) {
- IPath minGwMsysBin = new Path("C:\\MinGW\\msys\\1.0\\bin"); //$NON-NLS-1$
- if (minGwMsysBin.toFile().isDirectory()) {
- msysHome = minGwMsysBin.removeLastSegments(1).toOSString();
- }
- }
-
- // Try in default MSYS root folder
- if (msysHome == null) {
- IPath defaultMsysBin = new Path("C:\\msys\\1.0\\bin"); //$NON-NLS-1$
- if (defaultMsysBin.toFile().isDirectory()) {
- msysHome = defaultMsysBin.removeLastSegments(1).toOSString();
- }
- }
- return msysHome;
- }
-
- /**
- * Find location where MinGW is installed. A number of locations is being
- * checked, such as environment variable $MINGW_HOME, $PATH, Windows
- * registry et al. <br>
- * <br>
- * If you use this do not cache results to ensure user preferences are
- * accounted for. Please rely on internal caching.
- *
- * @return MinGW root ("/") path in Windows format.
- */
- public static String getMinGWHome() {
- if (!isWindowsPlatform) {
- return null;
- }
-
- IEnvironmentVariable varPath = CCorePlugin.getDefault().getBuildEnvironmentManager()
- .getVariable(ENV_PATH, (ICConfigurationDescription) null, true);
- String envPathValue = varPath != null ? varPath.getValue() : null;
- IEnvironmentVariable varMinGWHome = CCorePlugin.getDefault().getBuildEnvironmentManager()
- .getVariable(ENV_MINGW_HOME, (ICConfigurationDescription) null, true);
- String envMinGWHomeValue = varMinGWHome != null ? varMinGWHome.getValue() : null;
-
- // isMinGWLocationCached is used to figure fact of caching when all
- // cached objects are null
- if (isMinGWLocationCached && CDataUtil.objectsEqual(envPathValue, envPathValueCached)
- && CDataUtil.objectsEqual(envMinGWHomeValue, envMinGWHomeValueCached)) {
- return minGWLocation;
- }
-
- minGWLocation = findMinGWRoot(envPathValue, envMinGWHomeValue);
- envPathValueCached = envPathValue;
- envMinGWHomeValueCached = envMinGWHomeValue;
- isMinGWLocationCached = true;
-
- return minGWLocation;
- }
-
- /**
- * Find location where MSys is installed. Environment variable $MSYS_HOME
- * and some predetermined locations are being checked. <br>
- * <br>
- * If you use this do not cache results to ensure user preferences are
- * accounted for. Please rely on internal caching.
- *
- * @return MSys root ("/") path in Windows format.
- */
- public static String getMSysHome() {
- if (!isWindowsPlatform) {
- return null;
- }
-
- // Use $MSYS_HOME if defined
- IEnvironmentVariable varMsysHome = CCorePlugin.getDefault().getBuildEnvironmentManager()
- .getVariable(ENV_MSYS_HOME, (ICConfigurationDescription) null, true);
- String msysHomeValue = varMsysHome != null ? varMsysHome.getValue() : null;
- if (msysHomeValue != null) {
- return msysHomeValue;
- }
-
- String envMinGWHomeValue = getMinGWHome();
-
- // isMSysLocationCached is used to figure whether it was cached when all
- // cached objects are null
- if (isMSysLocationCached && CDataUtil.objectsEqual(envMinGWHomeValue, envMinGWHomeValueCached_msys)) {
- return mSysLocation;
- }
-
- mSysLocation = findMSysRoot(envMinGWHomeValue);
- envMinGWHomeValueCached_msys = envMinGWHomeValue;
- isMSysLocationCached = true;
-
- return mSysLocation;
- }
-
- /**
- * Check if MinGW is available in the path.
- *
- * @param envPath
- * - list of directories to search for MinGW separated by path
- * separator (format of environment variable $PATH) or
- * {@code null} to use current $PATH.
- * @return {@code true} if MinGW is available, {@code false} otherwise.
- */
- public static boolean isAvailable(String envPath) {
- return isWindowsPlatform && findMingwInPath(envPath) != null;
- }
-
- /**
- * Check if MinGW is available in $PATH.
- *
- * @return {@code true} if MinGW is available, {@code false} otherwise.
- */
- public static boolean isAvailable() {
- return isWindowsPlatform && findMingwInPath(null) != null;
- }
-}
+/******************************************************************************* + * Copyright (c) 2012, 2013 Andrew Gvozdev 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: + * Andrew Gvozdev - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.core; + +import java.io.File; +import java.util.Collections; +import java.util.Map; +import java.util.WeakHashMap; + +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.envvar.IEnvironmentVariable; +import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; +import org.eclipse.cdt.core.settings.model.util.CDataUtil; +import org.eclipse.cdt.utils.PathUtil; +import org.eclipse.cdt.utils.WindowsRegistry; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Platform; + +/** + * A collection of MinGW-related utility methods. + */ +public class MinGW { + public static final String ENV_MINGW_HOME = "MINGW_HOME"; //$NON-NLS-1$ + public static final String ENV_MSYS_HOME = "MSYS_HOME"; //$NON-NLS-1$ + private static final String ENV_PATH = "PATH"; //$NON-NLS-1$ + + private static final boolean isWindowsPlatform = Platform.getOS().equals(Platform.OS_WIN32); + + private static String envPathValueCached = null; + private static String envMinGWHomeValueCached = null; + private static String minGWLocation = null; + private static boolean isMinGWLocationCached = false; + + private static String envMinGWHomeValueCached_msys = null; + private static String mSysLocation = null; + private static boolean isMSysLocationCached = false; + + private final static Map<String/* envPath */, String/* mingwLocation */> mingwLocationCache = Collections + .synchronizedMap(new WeakHashMap<String, String>(1)); + + /** + * @return The absolute path to MinGW root folder or {@code null} if not + * found + */ + private static String findMinGWRoot(String envPathValue, String envMinGWHomeValue) { + String rootValue = null; + + // Check $MINGW_HOME + if (envMinGWHomeValue != null && !envMinGWHomeValue.isEmpty()) { + IPath mingwBinDir = new Path(envMinGWHomeValue + "\\bin"); //$NON-NLS-1$ + if (mingwBinDir.toFile().isDirectory()) { + rootValue = mingwBinDir.removeLastSegments(1).toOSString(); + } + } + + // Try the mingw directory in the platform install directory + // CDT distributions like Wascana may distribute MinGW like that + if (rootValue == null) { + IPath installPath = new Path(Platform.getInstallLocation().getURL().getFile()); + IPath mingwBinDir = installPath.append("mingw\\bin"); //$NON-NLS-1$ + if (mingwBinDir.toFile().isDirectory()) { + rootValue = mingwBinDir.removeLastSegments(1).toOSString(); + } + } + + // Look in PATH values. Look for mingw32-gcc.exe or + // x86_64-w64-mingw32-gcc.exe + if (rootValue == null) { + rootValue = findMingwInPath(envPathValue); + } + + // Look in MSYS2 + if (rootValue == null) { + WindowsRegistry registry = WindowsRegistry.getRegistry(); + String uninstallKey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"; //$NON-NLS-1$ + String subkey; + boolean on64bit = Platform.getOSArch().equals(Platform.ARCH_X86_64); + String key32bit = null; + for (int i = 0; (subkey = registry.getCurrentUserKeyName(uninstallKey, i)) != null; i++) { + String compKey = uninstallKey + '\\' + subkey; + String displayName = registry.getCurrentUserValue(compKey, "DisplayName"); //$NON-NLS-1$ + if (on64bit) { + if ("MSYS2 64bit".equals(displayName)) { //$NON-NLS-1$ + String installLocation = registry.getCurrentUserValue(compKey, "InstallLocation"); //$NON-NLS-1$ + String mingwLocation = installLocation + "\\mingw64"; //$NON-NLS-1$ + File gccFile = new File(mingwLocation + "\\bin\\gcc.exe"); //$NON-NLS-1$ + if (gccFile.canExecute()) { + rootValue = mingwLocation; + break; + } else { + mingwLocation = installLocation + "\\mingw32"; //$NON-NLS-1$ + gccFile = new File(mingwLocation + "\\bin\\gcc.exe"); //$NON-NLS-1$ + if (gccFile.canExecute()) { + rootValue = mingwLocation; + break; + } + } + } else if ("MSYS2 32bit".equals(displayName)) { //$NON-NLS-1$ + key32bit = compKey; + } + } else { + if ("MSYS2 32bit".equals(displayName)) { //$NON-NLS-1$ + String installLocation = registry.getCurrentUserValue(compKey, "InstallLocation"); //$NON-NLS-1$ + String mingwLocation = installLocation + "\\mingw32"; //$NON-NLS-1$ + File gccFile = new File(mingwLocation + "\\bin\\gcc.exe"); //$NON-NLS-1$ + if (gccFile.canExecute()) { + rootValue = mingwLocation; + break; + } + } + } + } + + if (on64bit && key32bit != null) { + String installLocation = registry.getCurrentUserValue(key32bit, "InstallLocation"); //$NON-NLS-1$ + String mingwLocation = installLocation + "\\mingw64"; //$NON-NLS-1$ + File gccFile = new File(mingwLocation + "\\bin\\gcc.exe"); //$NON-NLS-1$ + if (gccFile.canExecute()) { + rootValue = mingwLocation; + } else { + mingwLocation = installLocation + "\\mingw32"; //$NON-NLS-1$ + gccFile = new File(mingwLocation + "\\bin\\gcc.exe"); //$NON-NLS-1$ + if (gccFile.canExecute()) { + rootValue = mingwLocation; + } + } + } + } + + // Try the default MinGW install dir + if (rootValue == null) { + IPath mingwBinDir = new Path("C:\\MinGW"); //$NON-NLS-1$ + if (mingwBinDir.toFile().isDirectory()) { + rootValue = mingwBinDir.toOSString(); + } + } + + return rootValue; + } + + private static String findMingwInPath(String envPath) { + if (envPath == null) { + // $PATH from user preferences + IEnvironmentVariable varPath = CCorePlugin.getDefault().getBuildEnvironmentManager() + .getVariable(ENV_PATH, (ICConfigurationDescription) null, true); + if (varPath != null) { + envPath = varPath.getValue(); + } + } + + String mingwLocation = mingwLocationCache.get(envPath); + // check if WeakHashMap contains the key as null may be the cached value + if (mingwLocation == null && !mingwLocationCache.containsKey(envPath)) { + // Check for MinGW-w64 on Windows 64 bit, see + // http://mingw-w64.sourceforge.net/ + if (Platform.ARCH_X86_64.equals(Platform.getOSArch())) { + IPath gcc64Loc = PathUtil.findProgramLocation("x86_64-w64-mingw32-gcc.exe", envPath); //$NON-NLS-1$ + if (gcc64Loc != null) { + mingwLocation = gcc64Loc.removeLastSegments(2).toOSString(); + } + } + + // Look for mingw32-gcc.exe + if (mingwLocation == null) { + IPath gccLoc = PathUtil.findProgramLocation("mingw32-gcc.exe", envPath); //$NON-NLS-1$ + if (gccLoc != null) { + mingwLocation = gccLoc.removeLastSegments(2).toOSString(); + } + } + mingwLocationCache.put(envPath, mingwLocation); + } + + return mingwLocation; + } + + private static String findMSysRoot(String envMinGWHomeValue) { + String msysHome = null; + + // Look in the install location parent dir + IPath installPath = new Path(Platform.getInstallLocation().getURL().getFile()); + IPath installMsysBin = installPath.append("msys\\bin"); //$NON-NLS-1$ + if (installMsysBin.toFile().isDirectory()) { + msysHome = installMsysBin.removeLastSegments(1).toOSString(); + } + + // Look under $MINGW_HOME + if (msysHome == null) { + if (envMinGWHomeValue != null && !envMinGWHomeValue.isEmpty()) { + IPath minGwMsysBin = new Path(envMinGWHomeValue + "\\msys\\1.0\\bin"); //$NON-NLS-1$ + if (minGwMsysBin.toFile().isDirectory()) { + msysHome = minGwMsysBin.removeLastSegments(1).toOSString(); + } + } + } + + // Try under MSYS2 + if (msysHome == null) { + // Give preference to msys64 on 64-bit platforms and ignore 64 on + // 32-bit platforms + WindowsRegistry registry = WindowsRegistry.getRegistry(); + String uninstallKey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"; //$NON-NLS-1$ + String subkey; + boolean on64bit = Platform.getOSArch().equals(Platform.ARCH_X86_64); + String key32bit = null; + for (int i = 0; (subkey = registry.getCurrentUserKeyName(uninstallKey, i)) != null; i++) { + String compKey = uninstallKey + '\\' + subkey; + String displayName = registry.getCurrentUserValue(compKey, "DisplayName"); //$NON-NLS-1$ + if (on64bit) { + if ("MSYS2 64bit".equals(displayName)) { //$NON-NLS-1$ + String home = registry.getCurrentUserValue(compKey, "InstallLocation"); //$NON-NLS-1$ + if (new File(home).isDirectory()) { + msysHome = home; + break; + } + } else if ("MSYS2 32bit".equals(displayName)) { //$NON-NLS-1$ + key32bit = compKey; + } + } else { + if ("MSYS2 32bit".equals(displayName)) { //$NON-NLS-1$ + String home = registry.getCurrentUserValue(compKey, "InstallLocation"); //$NON-NLS-1$ + if (new File(home).isDirectory()) { + msysHome = home; + break; + } + } + } + } + + if (on64bit && key32bit != null) { + String home = registry.getCurrentUserValue(key32bit, "InstallLocation"); //$NON-NLS-1$ + if (new File(home).isDirectory()) { + msysHome = home; + } + } + } + + // Try under default MinGW dir + if (msysHome == null) { + IPath minGwMsysBin = new Path("C:\\MinGW\\msys\\1.0\\bin"); //$NON-NLS-1$ + if (minGwMsysBin.toFile().isDirectory()) { + msysHome = minGwMsysBin.removeLastSegments(1).toOSString(); + } + } + + // Try in default MSYS root folder + if (msysHome == null) { + IPath defaultMsysBin = new Path("C:\\msys\\1.0\\bin"); //$NON-NLS-1$ + if (defaultMsysBin.toFile().isDirectory()) { + msysHome = defaultMsysBin.removeLastSegments(1).toOSString(); + } + } + return msysHome; + } + + /** + * Find location where MinGW is installed. A number of locations is being + * checked, such as environment variable $MINGW_HOME, $PATH, Windows + * registry et al. <br> + * <br> + * If you use this do not cache results to ensure user preferences are + * accounted for. Please rely on internal caching. + * + * @return MinGW root ("/") path in Windows format. + */ + public static String getMinGWHome() { + if (!isWindowsPlatform) { + return null; + } + + IEnvironmentVariable varPath = CCorePlugin.getDefault().getBuildEnvironmentManager() + .getVariable(ENV_PATH, (ICConfigurationDescription) null, true); + String envPathValue = varPath != null ? varPath.getValue() : null; + IEnvironmentVariable varMinGWHome = CCorePlugin.getDefault().getBuildEnvironmentManager() + .getVariable(ENV_MINGW_HOME, (ICConfigurationDescription) null, true); + String envMinGWHomeValue = varMinGWHome != null ? varMinGWHome.getValue() : null; + + // isMinGWLocationCached is used to figure fact of caching when all + // cached objects are null + if (isMinGWLocationCached && CDataUtil.objectsEqual(envPathValue, envPathValueCached) + && CDataUtil.objectsEqual(envMinGWHomeValue, envMinGWHomeValueCached)) { + return minGWLocation; + } + + minGWLocation = findMinGWRoot(envPathValue, envMinGWHomeValue); + envPathValueCached = envPathValue; + envMinGWHomeValueCached = envMinGWHomeValue; + isMinGWLocationCached = true; + + return minGWLocation; + } + + /** + * Find location where MSys is installed. Environment variable $MSYS_HOME + * and some predetermined locations are being checked. <br> + * <br> + * If you use this do not cache results to ensure user preferences are + * accounted for. Please rely on internal caching. + * + * @return MSys root ("/") path in Windows format. + */ + public static String getMSysHome() { + if (!isWindowsPlatform) { + return null; + } + + // Use $MSYS_HOME if defined + IEnvironmentVariable varMsysHome = CCorePlugin.getDefault().getBuildEnvironmentManager() + .getVariable(ENV_MSYS_HOME, (ICConfigurationDescription) null, true); + String msysHomeValue = varMsysHome != null ? varMsysHome.getValue() : null; + if (msysHomeValue != null) { + return msysHomeValue; + } + + String envMinGWHomeValue = getMinGWHome(); + + // isMSysLocationCached is used to figure whether it was cached when all + // cached objects are null + if (isMSysLocationCached && CDataUtil.objectsEqual(envMinGWHomeValue, envMinGWHomeValueCached_msys)) { + return mSysLocation; + } + + mSysLocation = findMSysRoot(envMinGWHomeValue); + envMinGWHomeValueCached_msys = envMinGWHomeValue; + isMSysLocationCached = true; + + return mSysLocation; + } + + /** + * Check if MinGW is available in the path. + * + * @param envPath + * - list of directories to search for MinGW separated by path + * separator (format of environment variable $PATH) or + * {@code null} to use current $PATH. + * @return {@code true} if MinGW is available, {@code false} otherwise. + */ + public static boolean isAvailable(String envPath) { + return isWindowsPlatform && findMingwInPath(envPath) != null; + } + + /** + * Check if MinGW is available in $PATH. + * + * @return {@code true} if MinGW is available, {@code false} otherwise. + */ + public static boolean isAvailable() { + return isWindowsPlatform && findMingwInPath(null) != null; + } +} diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/envvar/IEnvironmentChangeListener.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/envvar/IEnvironmentChangeListener.java index 6adea60095c..10340bb9375 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/envvar/IEnvironmentChangeListener.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/envvar/IEnvironmentChangeListener.java @@ -1,27 +1,27 @@ -/*******************************************************************************
- * Copyright (c) 2013, 2013 Andrew Gvozdev 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:
- * Andrew Gvozdev - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.utils.envvar;
-
-
-/**
- * Interface for listeners to changes in environment variables defined by user
- * on CDT Environment page in Preferences.
- *
- * @since 5.5
- */
-public interface IEnvironmentChangeListener {
- /**
- * Indicates that environment variables have been changed.
- *
- * @param event - details of the event.
- */
- public void handleEvent(IEnvironmentChangeEvent event);
-}
+/******************************************************************************* + * Copyright (c) 2013, 2013 Andrew Gvozdev 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: + * Andrew Gvozdev - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.utils.envvar; + + +/** + * Interface for listeners to changes in environment variables defined by user + * on CDT Environment page in Preferences. + * + * @since 5.5 + */ +public interface IEnvironmentChangeListener { + /** + * Indicates that environment variables have been changed. + * + * @param event - details of the event. + */ + public void handleEvent(IEnvironmentChangeEvent event); +} diff --git a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart.h b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart.h index 33da8f2c080..01b014b3425 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart.h +++ b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart.h @@ -1,72 +1,72 @@ -#define DEBUG 1
-#define AMacro(x) x+1
-#define XMacro(x,y) x+y
-
-int aVariable;
-int xVariable;
-
-bool aFunction();
-bool xFunction();
-
-enum anEnumeration {
- aFirstEnum,
- aSecondEnum,
- aThirdEnum
-};
-
-enum xEnumeration {
- xFirstEnum,
- xSecondEnum,
- xThirdEnum
-};
-
-struct AStruct{
- int aStructField;
-};
-
-struct XStruct{
- int xStructField;
-};
-
-void anotherFunction(){
- int aLocalDeclaration = 1;
-}
-
-void xOtherFunction(){
- int xLocalDeclaration = 1;
-}
-
-class aClass {
-public:
- int aField;
- float xAClassField;
- int aMethod();
- void xAClassMethod(int x);
-};
-
-class anotherClass {
-public:
- int anotherField;
- void anotherMethod();
-};
-
-class xOtherClass {
-public:
- xOtherClass(char*);
- xOtherClass(int);
- int xOtherField;
- void xOtherMethod();
- void xOtherMethod(int);
-};
-
-namespace aNamespace {
- void aNamespaceFunction(){
- }
-};
-
-namespace xNamespace {
- void xNamespaceFunction(){
- }
-};
-
-
+#define DEBUG 1 +#define AMacro(x) x+1 +#define XMacro(x,y) x+y + +int aVariable; +int xVariable; + +bool aFunction(); +bool xFunction(); + +enum anEnumeration { + aFirstEnum, + aSecondEnum, + aThirdEnum +}; + +enum xEnumeration { + xFirstEnum, + xSecondEnum, + xThirdEnum +}; + +struct AStruct{ + int aStructField; +}; + +struct XStruct{ + int xStructField; +}; + +void anotherFunction(){ + int aLocalDeclaration = 1; +} + +void xOtherFunction(){ + int xLocalDeclaration = 1; +} + +class aClass { +public: + int aField; + float xAClassField; + int aMethod(); + void xAClassMethod(int x); +}; + +class anotherClass { +public: + int anotherField; + void anotherMethod(); +}; + +class xOtherClass { +public: + xOtherClass(char*); + xOtherClass(int); + int xOtherField; + void xOtherMethod(); + void xOtherMethod(int); +}; + +namespace aNamespace { + void aNamespaceFunction(){ + } +}; + +namespace xNamespace { + void xNamespaceFunction(){ + } +}; + + diff --git a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart1.cpp b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart1.cpp index 7316b66f9a7..37fb07c8803 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart1.cpp +++ b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart1.cpp @@ -1,6 +1,6 @@ -#include "CompletionTestStart.h"
-
-void anotherClass::anotherMethod()
-{
- a
-}
+#include "CompletionTestStart.h" + +void anotherClass::anotherMethod() +{ + a +} diff --git a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart10.cpp b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart10.cpp index 26d5d6f57e8..c308ac03b1a 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart10.cpp +++ b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart10.cpp @@ -1,7 +1,7 @@ -#include "CompletionTestStart.h"
-
-void anotherClass::anotherMethod()
-{
- aClass* c = new aClass();
- c->
-}
+#include "CompletionTestStart.h" + +void anotherClass::anotherMethod() +{ + aClass* c = new aClass(); + c-> +} diff --git a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart11.cpp b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart11.cpp index 60434778568..98b4bdf8489 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart11.cpp +++ b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart11.cpp @@ -1,3 +1,3 @@ -#include "CompletionTestStart.h"
-
-
+#include "CompletionTestStart.h" + + diff --git a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart12.h b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart12.h index 29e593e9a8e..8b0fe2ac05c 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart12.h +++ b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart12.h @@ -1,6 +1,6 @@ -#include "CompletionTestStart.h"
-
-class aThirdClass {
- int x;
-
-};
+#include "CompletionTestStart.h" + +class aThirdClass { + int x; + +}; diff --git a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart13.h b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart13.h index b41aa044f55..daf8f016612 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart13.h +++ b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart13.h @@ -1,5 +1,5 @@ -#include "CompletionTestStart.h"
-
-class aThirdClass {
-
-};
+#include "CompletionTestStart.h" + +class aThirdClass { + +}; diff --git a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart14.cpp b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart14.cpp index 5d33709a5a7..bd11959c9a4 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart14.cpp +++ b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart14.cpp @@ -1,5 +1,5 @@ -#include "CompletionTestStart.h"
-
-void foo(int x){
- int y = a
-}
+#include "CompletionTestStart.h" + +void foo(int x){ + int y = a +} diff --git a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart15.cpp b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart15.cpp index 238e95c0f8f..8b10c71995b 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart15.cpp +++ b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart15.cpp @@ -1,5 +1,5 @@ -#include "CompletionTestStart.h"
-
-void foo(int x){
- int y =
-}
+#include "CompletionTestStart.h" + +void foo(int x){ + int y = +} diff --git a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart16.cpp b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart16.cpp index 8e4eed27f1f..90e459559cb 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart16.cpp +++ b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart16.cpp @@ -1,3 +1,3 @@ -#include "CompletionTestStart.h"
-
-void foo ( a
+#include "CompletionTestStart.h" + +void foo ( a diff --git a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart17.cpp b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart17.cpp index fb9f4cda180..0dae57ff522 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart17.cpp +++ b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart17.cpp @@ -1,3 +1,3 @@ -#include "CompletionTestStart.h"
-
-void foo (
+#include "CompletionTestStart.h" + +void foo ( diff --git a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart18.cpp b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart18.cpp index aa593d21370..b4a5ec71ee0 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart18.cpp +++ b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart18.cpp @@ -1,6 +1,6 @@ -#include "CompletionTestStart.h"
-
-class ClassA {
- void foo ( a
-};
-
+#include "CompletionTestStart.h" + +class ClassA { + void foo ( a +}; + diff --git a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart19.cpp b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart19.cpp index 6ec3631b5dc..4ad14958f60 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart19.cpp +++ b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart19.cpp @@ -1,5 +1,5 @@ -#include "CompletionTestStart.h"
-
-class ClassA {
- void foo (
-};
+#include "CompletionTestStart.h" + +class ClassA { + void foo ( +}; diff --git a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart2.cpp b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart2.cpp index 23afd8cf770..a7ba3be4f2e 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart2.cpp +++ b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart2.cpp @@ -1,7 +1,7 @@ -#include "CompletionTestStart.h"
-
-void anotherClass::anotherMethod()
-{
- aClass c;
- c.a
-}
+#include "CompletionTestStart.h" + +void anotherClass::anotherMethod() +{ + aClass c; + c.a +} diff --git a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart20.h b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart20.h index c0dd03edf34..3f388823558 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart20.h +++ b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart20.h @@ -1,4 +1,4 @@ -#include "CompletionTestStart.h"
-
-class ClassA : public a
-
+#include "CompletionTestStart.h" + +class ClassA : public a + diff --git a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart21.h b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart21.h index 142826ffde4..0e065c26c0e 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart21.h +++ b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart21.h @@ -1,3 +1,3 @@ -#include "CompletionTestStart.h"
-
-class ClassA : public
+#include "CompletionTestStart.h" + +class ClassA : public diff --git a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart22.cpp b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart22.cpp index 721d0efbe98..621d904c21f 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart22.cpp +++ b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart22.cpp @@ -1,8 +1,8 @@ -#include "CompletionTestStart.h"
-
-void anotherClass::anotherMethod()
-{
- try {
- } catch ( a
-
-}
+#include "CompletionTestStart.h" + +void anotherClass::anotherMethod() +{ + try { + } catch ( a + +} diff --git a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart23.cpp b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart23.cpp index 5e2cbae78aa..05c0ada5de5 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart23.cpp +++ b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart23.cpp @@ -1,7 +1,7 @@ -#include "CompletionTestStart.h"
-
-void anotherClass::anotherMethod()
-{
- try {
- } catch (
-}
+#include "CompletionTestStart.h" + +void anotherClass::anotherMethod() +{ + try { + } catch ( +} diff --git a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart24.cpp b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart24.cpp index 1af4d33b200..351a73eb20c 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart24.cpp +++ b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart24.cpp @@ -1,3 +1,3 @@ -#include "CompletionTestStart.h"
-
-using
+#include "CompletionTestStart.h" + +using diff --git a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart25.cpp b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart25.cpp index 6f1f93e3984..2606b81e112 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart25.cpp +++ b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart25.cpp @@ -1,3 +1,3 @@ -#include "CompletionTestStart.h"
-
-using a
+#include "CompletionTestStart.h" + +using a diff --git a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart26.cpp b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart26.cpp index 5a09fa91ecf..40dcc80481c 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart26.cpp +++ b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart26.cpp @@ -1,3 +1,3 @@ -#include "CompletionTestStart.h"
-
-#ifdef
+#include "CompletionTestStart.h" + +#ifdef diff --git a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart27.cpp b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart27.cpp index 4f474a2883f..0d43dd4bd28 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart27.cpp +++ b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart27.cpp @@ -1,3 +1,3 @@ -#include "CompletionTestStart.h"
-
-#ifdef D
+#include "CompletionTestStart.h" + +#ifdef D diff --git a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart28.cpp b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart28.cpp index 6b50a7263f5..d7ba50e7bba 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart28.cpp +++ b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart28.cpp @@ -1,6 +1,6 @@ -#include "CompletionTestStart.h"
-
-void anotherClass::anotherMethod()
-{
- aClass myClass = new a
-}
+#include "CompletionTestStart.h" + +void anotherClass::anotherMethod() +{ + aClass myClass = new a +} diff --git a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart29.cpp b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart29.cpp index 7ee28ed7cc8..f5723c07aa3 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart29.cpp +++ b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart29.cpp @@ -1,7 +1,7 @@ -#include "CompletionTestStart.h"
-
-void anotherClass::anotherMethod()
-{
- aClass myClass = new
-}
-
+#include "CompletionTestStart.h" + +void anotherClass::anotherMethod() +{ + aClass myClass = new +} + diff --git a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart3.cpp b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart3.cpp index 9baf9431709..c756e46477b 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart3.cpp +++ b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart3.cpp @@ -1,3 +1,3 @@ -#include "CompletionTestStart.h"
-
- a
+#include "CompletionTestStart.h" + + a diff --git a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart30.cpp b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart30.cpp index 9010ea4240a..fdf3cbae8e3 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart30.cpp +++ b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart30.cpp @@ -1,6 +1,6 @@ -#include "CompletionTestStart.h"
-
-void anotherClass::anotherMethod()
-{
- aNamespace::
-}
+#include "CompletionTestStart.h" + +void anotherClass::anotherMethod() +{ + aNamespace:: +} diff --git a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart31.cpp b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart31.cpp index 63286f3bf6f..f4156bde5c0 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart31.cpp +++ b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart31.cpp @@ -1,6 +1,6 @@ -#include "CompletionTestStart.h"
-
-void anotherClass::anotherMethod()
-{
- aNamespace::a
-}
+#include "CompletionTestStart.h" + +void anotherClass::anotherMethod() +{ + aNamespace::a +} diff --git a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart32.cpp b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart32.cpp index 463a3446454..e62ae6a5e58 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart32.cpp +++ b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart32.cpp @@ -1,3 +1,3 @@ -#include "CompletionTestStart.h"
-
-using namespace
+#include "CompletionTestStart.h" + +using namespace diff --git a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart33.cpp b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart33.cpp index f6fd9f0e9d7..f52d73b753d 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart33.cpp +++ b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart33.cpp @@ -1,3 +1,3 @@ -#include "CompletionTestStart.h"
-
-using namespace a
+#include "CompletionTestStart.h" + +using namespace a diff --git a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart34.cpp b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart34.cpp index 260938d2cad..ccabe827f35 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart34.cpp +++ b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart34.cpp @@ -1,6 +1,6 @@ -#include "CompletionTestStart.h"
-
-int anotherClass::anotherMethod(){
- xOtherClass c;
- c.xOtherMethod (
-}
+#include "CompletionTestStart.h" + +int anotherClass::anotherMethod(){ + xOtherClass c; + c.xOtherMethod ( +} diff --git a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart35.cpp b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart35.cpp index c30d27fa823..1c2f6353189 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart35.cpp +++ b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart35.cpp @@ -1,5 +1,5 @@ -#include "CompletionTestStart.h"
-
-int anotherClass::anotherMethod(){
- xOtherClass* a = new xOtherClass (
-}
+#include "CompletionTestStart.h" + +int anotherClass::anotherMethod(){ + xOtherClass* a = new xOtherClass ( +} diff --git a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart36.cpp b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart36.cpp index 9799e8a1949..d715732c140 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart36.cpp +++ b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart36.cpp @@ -1,7 +1,7 @@ -#include "CompletionTestStart.h"
-
-void aClass::aMethod()
-{
- int xLocal = 0;
- xAClassMethod( x
-}
+#include "CompletionTestStart.h" + +void aClass::aMethod() +{ + int xLocal = 0; + xAClassMethod( x +} diff --git a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart37.cpp b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart37.cpp index a9e27fb56a0..157101251a5 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart37.cpp +++ b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart37.cpp @@ -1,5 +1,5 @@ -#include "CompletionTestStart.h"
-
-typedef int myType;
-
- m
+#include "CompletionTestStart.h" + +typedef int myType; + + m diff --git a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart38.cpp b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart38.cpp index 3e5a238a22c..bf249f93a24 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart38.cpp +++ b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart38.cpp @@ -1,11 +1,11 @@ -class Foo{
-public:
-Foo();
-class DEF{};
-void bar();
-static void fum();
-static int x;
-int y;
-};
-
+class Foo{ +public: +Foo(); +class DEF{}; +void bar(); +static void fum(); +static int x; +int y; +}; + Foo::
\ No newline at end of file diff --git a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart39.cpp b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart39.cpp index 077937373bc..ad0577d18cb 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart39.cpp +++ b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart39.cpp @@ -1,10 +1,10 @@ -class Foo{
-public:
-Foo();
-void bar();
-static void fum();
-static int x;
-int y;
-};
-
+class Foo{ +public: +Foo(); +void bar(); +static void fum(); +static int x; +int y; +}; + void Foo::
\ No newline at end of file diff --git a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart4.h b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart4.h index d09cc7c4d10..25c504e0a8b 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart4.h +++ b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart4.h @@ -1,5 +1,5 @@ -#include "CompletionTestStart.h"
-
-class aThirdClass {
- a
-};
+#include "CompletionTestStart.h" + +class aThirdClass { + a +}; diff --git a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart5.cpp b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart5.cpp index ae96bff9fc7..a0656bbd714 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart5.cpp +++ b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart5.cpp @@ -1,6 +1,6 @@ -#include "CompletionTestStart.h"
-
-void anotherClass::anotherMethod()
-{
-
-}
+#include "CompletionTestStart.h" + +void anotherClass::anotherMethod() +{ + +} diff --git a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart6.cpp b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart6.cpp index 57d57b987fd..21ff5cc2a0e 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart6.cpp +++ b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart6.cpp @@ -1,7 +1,7 @@ -#include "CompletionTestStart.h"
-
-void anotherClass::anotherMethod()
-{
- aClass* c = new aClass();
- c->a
-}
+#include "CompletionTestStart.h" + +void anotherClass::anotherMethod() +{ + aClass* c = new aClass(); + c->a +} diff --git a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart7.cpp b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart7.cpp index d91f3a4f204..faaecc249b3 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart7.cpp +++ b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart7.cpp @@ -1,10 +1,10 @@ -#include "CompletionTestStart.h"
-
-aClass* foo(){
- return new aClass();
-}
-
-void anotherClass::anotherMethod()
-{
- foo()->a
-}
+#include "CompletionTestStart.h" + +aClass* foo(){ + return new aClass(); +} + +void anotherClass::anotherMethod() +{ + foo()->a +} diff --git a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart8.cpp b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart8.cpp index 0dd8dffa0d0..e3701dba399 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart8.cpp +++ b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart8.cpp @@ -1,5 +1,5 @@ -#include "CompletionTestStart.h"
-
-void foo(int x){
- int y = AM
-}
+#include "CompletionTestStart.h" + +void foo(int x){ + int y = AM +} diff --git a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart9.cpp b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart9.cpp index 6fa0e57c1ab..24bf9db6187 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart9.cpp +++ b/core/org.eclipse.cdt.ui.tests/resources/contentassist/CompletionTestStart9.cpp @@ -1,7 +1,7 @@ -#include "CompletionTestStart.h"
-
-void anotherClass::anotherMethod()
-{
- aClass c;
- c.
-}
+#include "CompletionTestStart.h" + +void anotherClass::anotherMethod() +{ + aClass c; + c. +} 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 b85184476c3..d903ce74653 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 @@ -1,47 +1,47 @@ -/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation 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:
- * IBM - Initial API and implementation
- * Anton Leherbauer (Wind River Systems)
- * Markus Schorn (Wind River Systems)
- * Jonah Graham (Kichwa Coders) - converted to new style suite (Bug 515178)
- *******************************************************************************/
-package org.eclipse.cdt.ui.tests;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-/**
- * Test all areas of the UI.
- */
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
- org.eclipse.cdt.ui.tests.text.TextTestSuite.class,
- org.eclipse.cdt.ui.tests.outline.OutlineTestSuite.class,
- org.eclipse.cdt.ui.tests.viewsupport.ViewSupportTestSuite.class,
- org.eclipse.cdt.ui.tests.callhierarchy.CallHierarchyTestSuite.class,
- org.eclipse.cdt.ui.tests.callhierarchy.extension.CHExtensionTest.class,
- org.eclipse.cdt.ui.tests.typehierarchy.TypeHierarchyTestSuite.class,
- org.eclipse.cdt.ui.tests.includebrowser.IncludeBrowserTestSuite.class,
- org.eclipse.cdt.ui.tests.text.contentassist.ContentAssistTestSuite.class,
- org.eclipse.cdt.ui.tests.text.contentassist2.ContentAssist2TestSuite.class,
- org.eclipse.cdt.ui.tests.text.selection.SelectionTestSuite.class,
- org.eclipse.cdt.ui.tests.quickfix.AssistQuickFixTest.class,
- org.eclipse.cdt.ui.tests.buildconsole.BuildConsoleTests.class,
- org.eclipse.cdt.ui.tests.search.SearchTestSuite.class,
- org.eclipse.cdt.ui.tests.refactoring.RefactoringTestSuite.class,
- org.eclipse.cdt.ui.tests.chelp.CHelpTest.class,
- 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,
-
-})
-public class AutomatedSuite {
-}
+/******************************************************************************* + * Copyright (c) 2000, 2017 IBM Corporation 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: + * IBM - Initial API and implementation + * Anton Leherbauer (Wind River Systems) + * Markus Schorn (Wind River Systems) + * Jonah Graham (Kichwa Coders) - converted to new style suite (Bug 515178) + *******************************************************************************/ +package org.eclipse.cdt.ui.tests; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +/** + * Test all areas of the UI. + */ +@RunWith(Suite.class) +@Suite.SuiteClasses({ + org.eclipse.cdt.ui.tests.text.TextTestSuite.class, + org.eclipse.cdt.ui.tests.outline.OutlineTestSuite.class, + org.eclipse.cdt.ui.tests.viewsupport.ViewSupportTestSuite.class, + org.eclipse.cdt.ui.tests.callhierarchy.CallHierarchyTestSuite.class, + org.eclipse.cdt.ui.tests.callhierarchy.extension.CHExtensionTest.class, + org.eclipse.cdt.ui.tests.typehierarchy.TypeHierarchyTestSuite.class, + org.eclipse.cdt.ui.tests.includebrowser.IncludeBrowserTestSuite.class, + org.eclipse.cdt.ui.tests.text.contentassist.ContentAssistTestSuite.class, + org.eclipse.cdt.ui.tests.text.contentassist2.ContentAssist2TestSuite.class, + org.eclipse.cdt.ui.tests.text.selection.SelectionTestSuite.class, + org.eclipse.cdt.ui.tests.quickfix.AssistQuickFixTest.class, + org.eclipse.cdt.ui.tests.buildconsole.BuildConsoleTests.class, + org.eclipse.cdt.ui.tests.search.SearchTestSuite.class, + org.eclipse.cdt.ui.tests.refactoring.RefactoringTestSuite.class, + org.eclipse.cdt.ui.tests.chelp.CHelpTest.class, + 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, + +}) +public class AutomatedSuite { +} diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/extension/CHContentProvider.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/extension/CHContentProvider.java index f04412856ae..31dba4a22c2 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/extension/CHContentProvider.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/extension/CHContentProvider.java @@ -1,61 +1,61 @@ -/*******************************************************************************
- * Copyright (c) 2018 Wind River Systems, Inc. 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:
- * Lidia Popescu - [536255] initial API and implementation. Extension point for open call hierarchy view
- *******************************************************************************/
-package org.eclipse.cdt.ui.tests.callhierarchy.extension;
-
-import org.eclipse.jface.viewers.IOpenListener;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.ui.ICHEContentProvider;
-
-import org.eclipse.cdt.internal.core.model.ext.FunctionDeclarationHandle;
-
-/**
- * This class implements ICHEProvider and provides test information
- * */
-public class CHContentProvider implements ICHEContentProvider {
-
- @Override
- public Object[] asyncComputeExtendedRoot(Object parentElement) {
- Object[] object =null;
- if (parentElement instanceof ICElement) {
- ICElement element = (ICElement)parentElement;
- if ( isDslFunction(element)) {
- // check if this function declaration comes from a DSL file
- DslNode node = new DslNode(element);
- node.setProject(element.getCProject());
- return new Object[]{node};
- }
- }
- return object;
- }
-
- @Override
- public IOpenListener getCCallHierarchyOpenListener() {
- return new CHOpenListener();
- }
-
- /**
- * E.g. A custom implementation, suppose that functions that ends with
- * "_dsl" have been originally declared in a DSL file.
- * @param cElement
- * @return
- */
- private static boolean isDslFunction(ICElement cElement) {
- if (cElement instanceof FunctionDeclarationHandle) {
- FunctionDeclarationHandle f = (FunctionDeclarationHandle)cElement;
- if (f.getElementName() !=null & f.getElementName().endsWith("_dsl")) {
- return true;
- }
- }
- return false;
- }
-
-}
+/******************************************************************************* + * Copyright (c) 2018 Wind River Systems, Inc. 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: + * Lidia Popescu - [536255] initial API and implementation. Extension point for open call hierarchy view + *******************************************************************************/ +package org.eclipse.cdt.ui.tests.callhierarchy.extension; + +import org.eclipse.jface.viewers.IOpenListener; + +import org.eclipse.cdt.core.model.ICElement; +import org.eclipse.cdt.ui.ICHEContentProvider; + +import org.eclipse.cdt.internal.core.model.ext.FunctionDeclarationHandle; + +/** + * This class implements ICHEProvider and provides test information + * */ +public class CHContentProvider implements ICHEContentProvider { + + @Override + public Object[] asyncComputeExtendedRoot(Object parentElement) { + Object[] object =null; + if (parentElement instanceof ICElement) { + ICElement element = (ICElement)parentElement; + if ( isDslFunction(element)) { + // check if this function declaration comes from a DSL file + DslNode node = new DslNode(element); + node.setProject(element.getCProject()); + return new Object[]{node}; + } + } + return object; + } + + @Override + public IOpenListener getCCallHierarchyOpenListener() { + return new CHOpenListener(); + } + + /** + * E.g. A custom implementation, suppose that functions that ends with + * "_dsl" have been originally declared in a DSL file. + * @param cElement + * @return + */ + private static boolean isDslFunction(ICElement cElement) { + if (cElement instanceof FunctionDeclarationHandle) { + FunctionDeclarationHandle f = (FunctionDeclarationHandle)cElement; + if (f.getElementName() !=null & f.getElementName().endsWith("_dsl")) { + return true; + } + } + return false; + } + +} diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/extension/CHExtensionTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/extension/CHExtensionTest.java index af8b5c0b3a8..35dd3c1e4bc 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/extension/CHExtensionTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/extension/CHExtensionTest.java @@ -1,106 +1,106 @@ -/*******************************************************************************
- * Copyright (c) 2018 Wind River Systems, Inc. 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:
- * Lidia Popescu - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.ui.tests.callhierarchy.extension;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.tests.callhierarchy.CallHierarchyBaseTest;
-
-import org.eclipse.cdt.internal.ui.editor.CEditor;
-
-import junit.framework.TestSuite;
-
-/**
- * @author Lidia Popescu
- *
- */
-public class CHExtensionTest extends CallHierarchyBaseTest {
-
- private static final String FILE_NAME_MAIN_C = "CallHierarchy_main.c";
- private static final String FILE_NAME_DSL = "CallHierarchy_test.java";
- private static final String FILE_NAME_C = "CallHierarchy_test.c";
-
- public CHExtensionTest(String name) {
- super(name);
- }
-
- public static TestSuite suite() {
- return new TestSuite(CHExtensionTest.class);
- }
-
-// {CallHierarchy_main.c}
-// extern void function_c(void);
-// extern void function_dsl(void);
-//
-// void main(void)
-// {
-// function_c();
-// function_dsl();
-// }
-
-// {CallHierarchy_test.c}
-// void function_c(void)
-// {
-// printf("Hello, world!\n");
-// }
-
-// {CallHierarchy_test.java}
-// /** Suppose this code is written in a different custom programming language, any DSL, e.g. Java*/
-// class CallHierarchy_test {
-// public static void function_dsl() {
-// System.out.println("Hello, world!");
-// }
-// }
- public void testCallHierarchy() throws Exception {
-
- assertNotNull(Platform.getExtensionRegistry().getExtensionPoint("org.eclipse.cdt.ui.CCallHierarchy"));
-
- ImageDescriptor imageDesc = AbstractUIPlugin.imageDescriptorFromPlugin(CUIPlugin.PLUGIN_ID, CHLabelProvider.ICON_PATH);
- assertNotNull(imageDesc);
- Image image = imageDesc.createImage(); //$NON-NLS-1$
- assertNotNull(image);
-
- String content = readTaggedComment(FILE_NAME_DSL);
- assertNotNull(content);
- IFile file= createFile(getProject(), FILE_NAME_DSL, content);
-
- content = readTaggedComment(FILE_NAME_C);
- assertNotNull(content);
- file= createFile(getProject(), FILE_NAME_C, content);
- waitUntilFileIsIndexed(fIndex, file);
-
- content = readTaggedComment(FILE_NAME_MAIN_C);
- assertNotNull(content);
- file= createFile(getProject(), FILE_NAME_MAIN_C, content);
- waitUntilFileIsIndexed(fIndex, file);
- CEditor editor = openEditor(file);
-
- String functionName ="function_c";
- editor.selectAndReveal(content.indexOf(functionName), functionName.length());
- openCallHierarchy(editor);
- Tree tree = getCHTreeViewer().getTree();
- checkTreeNode(tree, 0, "function_c() : void");
- checkTreeNode(tree, 0, 0 ,"main() : void");
-
- functionName ="function_dsl";
- editor.selectAndReveal(content.indexOf(functionName), functionName.length());
- openCallHierarchy(editor);
- tree = getCHTreeViewer().getTree();
- checkTreeNode(tree, 0, "JAVA function function_dsl()");
- checkTreeNode(tree, 0, 0, "function_dsl() : void");
- }
-}
+/******************************************************************************* + * Copyright (c) 2018 Wind River Systems, Inc. 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: + * Lidia Popescu - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.ui.tests.callhierarchy.extension; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.Platform; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.widgets.Tree; +import org.eclipse.ui.plugin.AbstractUIPlugin; + +import org.eclipse.cdt.ui.CUIPlugin; +import org.eclipse.cdt.ui.tests.callhierarchy.CallHierarchyBaseTest; + +import org.eclipse.cdt.internal.ui.editor.CEditor; + +import junit.framework.TestSuite; + +/** + * @author Lidia Popescu + * + */ +public class CHExtensionTest extends CallHierarchyBaseTest { + + private static final String FILE_NAME_MAIN_C = "CallHierarchy_main.c"; + private static final String FILE_NAME_DSL = "CallHierarchy_test.java"; + private static final String FILE_NAME_C = "CallHierarchy_test.c"; + + public CHExtensionTest(String name) { + super(name); + } + + public static TestSuite suite() { + return new TestSuite(CHExtensionTest.class); + } + +// {CallHierarchy_main.c} +// extern void function_c(void); +// extern void function_dsl(void); +// +// void main(void) +// { +// function_c(); +// function_dsl(); +// } + +// {CallHierarchy_test.c} +// void function_c(void) +// { +// printf("Hello, world!\n"); +// } + +// {CallHierarchy_test.java} +// /** Suppose this code is written in a different custom programming language, any DSL, e.g. Java*/ +// class CallHierarchy_test { +// public static void function_dsl() { +// System.out.println("Hello, world!"); +// } +// } + public void testCallHierarchy() throws Exception { + + assertNotNull(Platform.getExtensionRegistry().getExtensionPoint("org.eclipse.cdt.ui.CCallHierarchy")); + + ImageDescriptor imageDesc = AbstractUIPlugin.imageDescriptorFromPlugin(CUIPlugin.PLUGIN_ID, CHLabelProvider.ICON_PATH); + assertNotNull(imageDesc); + Image image = imageDesc.createImage(); //$NON-NLS-1$ + assertNotNull(image); + + String content = readTaggedComment(FILE_NAME_DSL); + assertNotNull(content); + IFile file= createFile(getProject(), FILE_NAME_DSL, content); + + content = readTaggedComment(FILE_NAME_C); + assertNotNull(content); + file= createFile(getProject(), FILE_NAME_C, content); + waitUntilFileIsIndexed(fIndex, file); + + content = readTaggedComment(FILE_NAME_MAIN_C); + assertNotNull(content); + file= createFile(getProject(), FILE_NAME_MAIN_C, content); + waitUntilFileIsIndexed(fIndex, file); + CEditor editor = openEditor(file); + + String functionName ="function_c"; + editor.selectAndReveal(content.indexOf(functionName), functionName.length()); + openCallHierarchy(editor); + Tree tree = getCHTreeViewer().getTree(); + checkTreeNode(tree, 0, "function_c() : void"); + checkTreeNode(tree, 0, 0 ,"main() : void"); + + functionName ="function_dsl"; + editor.selectAndReveal(content.indexOf(functionName), functionName.length()); + openCallHierarchy(editor); + tree = getCHTreeViewer().getTree(); + checkTreeNode(tree, 0, "JAVA function function_dsl()"); + checkTreeNode(tree, 0, 0, "function_dsl() : void"); + } +} diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/extension/CHLabelProvider.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/extension/CHLabelProvider.java index 86ae3cfcd3f..a400878599b 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/extension/CHLabelProvider.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/extension/CHLabelProvider.java @@ -1,72 +1,72 @@ -/*******************************************************************************
- * Copyright (c) 2018 Wind River Systems, Inc. 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:
- * Lidia Popescu - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.ui.tests.callhierarchy.extension;
-
-import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.StyledCellLabelProvider;
-import org.eclipse.jface.viewers.StyledString;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.ui.CUIPlugin;
-
-public class CHLabelProvider implements IStyledLabelProvider {
-
- public static String ICON_PATH= "$nl$/icons/obj16/container_obj.gif";
-
- @Override
- public void addListener(ILabelProviderListener listener) {
- }
-
- @Override
- public void dispose() {
- }
-
- @Override
- public boolean isLabelProperty(Object element, String property) {
- return true;
- }
-
- @Override
- public void removeListener(ILabelProviderListener listener) {
- }
-
- @Override
- public StyledString getStyledText(Object element) {
- if (element instanceof DslNode) {
- DslNode node = (DslNode)element;
- ICElement decl = node.getRepresentedDeclaration();
-
- if (decl !=null) {
- StyledString label = new StyledString();
- label.append(decl.getElementName());
- if (node.getDslNodeName() != null) {
- return StyledCellLabelProvider.styleDecoratedString(node.getDslNodeName(), StyledString.DECORATIONS_STYLER, label);
- }
- return label;
- }
- }
- return null;
- }
-
- @Override
- public Image getImage(Object element) {
- if (element instanceof DslNode) {
- Image img = AbstractUIPlugin.imageDescriptorFromPlugin(
- CUIPlugin.PLUGIN_ID, ICON_PATH).createImage(); //$NON-NLS-1$
- return img;
- }
- return null;
- }
-
-}
+/******************************************************************************* + * Copyright (c) 2018 Wind River Systems, Inc. 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: + * Lidia Popescu - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.ui.tests.callhierarchy.extension; + +import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider; +import org.eclipse.jface.viewers.ILabelProviderListener; +import org.eclipse.jface.viewers.StyledCellLabelProvider; +import org.eclipse.jface.viewers.StyledString; +import org.eclipse.swt.graphics.Image; +import org.eclipse.ui.plugin.AbstractUIPlugin; + +import org.eclipse.cdt.core.model.ICElement; +import org.eclipse.cdt.ui.CUIPlugin; + +public class CHLabelProvider implements IStyledLabelProvider { + + public static String ICON_PATH= "$nl$/icons/obj16/container_obj.gif"; + + @Override + public void addListener(ILabelProviderListener listener) { + } + + @Override + public void dispose() { + } + + @Override + public boolean isLabelProperty(Object element, String property) { + return true; + } + + @Override + public void removeListener(ILabelProviderListener listener) { + } + + @Override + public StyledString getStyledText(Object element) { + if (element instanceof DslNode) { + DslNode node = (DslNode)element; + ICElement decl = node.getRepresentedDeclaration(); + + if (decl !=null) { + StyledString label = new StyledString(); + label.append(decl.getElementName()); + if (node.getDslNodeName() != null) { + return StyledCellLabelProvider.styleDecoratedString(node.getDslNodeName(), StyledString.DECORATIONS_STYLER, label); + } + return label; + } + } + return null; + } + + @Override + public Image getImage(Object element) { + if (element instanceof DslNode) { + Image img = AbstractUIPlugin.imageDescriptorFromPlugin( + CUIPlugin.PLUGIN_ID, ICON_PATH).createImage(); //$NON-NLS-1$ + return img; + } + return null; + } + +} diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/extension/CHOpenListener.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/extension/CHOpenListener.java index 4023687829b..579879c8484 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/extension/CHOpenListener.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/extension/CHOpenListener.java @@ -1,92 +1,92 @@ -/*******************************************************************************
- * Copyright (c) 2018 Wind River Systems, Inc. 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:
- * Lidia Popescu - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.ui.tests.callhierarchy.extension;
-
-import java.util.HashMap;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.viewers.IOpenListener;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.OpenEvent;
-import org.eclipse.jface.viewers.TreeSelection;
-import org.eclipse.ui.IEditorDescriptor;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.ide.IDE;
-import org.eclipse.ui.part.FileEditorInput;
-import org.eclipse.ui.progress.UIJob;
-
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.ui.testplugin.CTestPlugin;
-
-
-public class CHOpenListener implements IOpenListener {
-
- /** On Node click open corresponding file */
- @Override
- public void open(OpenEvent event) {
- if (event !=null ) {
- ISelection selection = event.getSelection();
- if (selection instanceof TreeSelection ) {
- TreeSelection treeSelection = (TreeSelection)selection;
- Object element = treeSelection.getFirstElement();
- if (element instanceof DslNode) {
- DslNode node = (DslNode)element;
- ICProject project = node.getProject();
- /**
- * Based on a custom algorithm the corresponding file and line should be found and open. Suppose that the file
- * 'CallHierarchy_test.java' has been found, and the line number '3' where the function 'function_dsl' is defined.
- */
- IFile file = project.getProject().getFile("CallHierarchy_test.java");
- IWorkbenchPage page= PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart().getSite().getPage();
- IEditorInput input = new FileEditorInput(file);
- IEditorDescriptor desc = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(input.getName());
-
- UIJob ui = new UIJob("Open File") {
-
- @Override
- public IStatus runInUIThread(IProgressMonitor monitor) {
- try {
- String editorId = null;
- if (desc == null || desc.isOpenExternal()) {
- editorId = "org.eclipse.ui.DefaultTextEditor";
- } else {
- editorId = desc.getId();
- }
- IEditorPart editor = page.openEditor(input, editorId);
- IMarker fMarker = file.createMarker(IMarker.TEXT);
- HashMap<String, Object> map = new HashMap<String, Object>();
- map.put(IMarker.LINE_NUMBER, 3);
- fMarker.setAttributes(map);
- IDE.gotoMarker(editor,fMarker);
-
- } catch (PartInitException e) {
- e.printStackTrace();
- } catch (CoreException e) {
- e.printStackTrace();
- }
- return new Status(IStatus.OK, CTestPlugin.PLUGIN_ID, "");
- }
- };
- ui.schedule();
- }
- }
- }
- }
-}
+/******************************************************************************* + * Copyright (c) 2018 Wind River Systems, Inc. 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: + * Lidia Popescu - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.ui.tests.callhierarchy.extension; + +import java.util.HashMap; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IMarker; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.jface.viewers.IOpenListener; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.OpenEvent; +import org.eclipse.jface.viewers.TreeSelection; +import org.eclipse.ui.IEditorDescriptor; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.ide.IDE; +import org.eclipse.ui.part.FileEditorInput; +import org.eclipse.ui.progress.UIJob; + +import org.eclipse.cdt.core.model.ICProject; +import org.eclipse.cdt.ui.testplugin.CTestPlugin; + + +public class CHOpenListener implements IOpenListener { + + /** On Node click open corresponding file */ + @Override + public void open(OpenEvent event) { + if (event !=null ) { + ISelection selection = event.getSelection(); + if (selection instanceof TreeSelection ) { + TreeSelection treeSelection = (TreeSelection)selection; + Object element = treeSelection.getFirstElement(); + if (element instanceof DslNode) { + DslNode node = (DslNode)element; + ICProject project = node.getProject(); + /** + * Based on a custom algorithm the corresponding file and line should be found and open. Suppose that the file + * 'CallHierarchy_test.java' has been found, and the line number '3' where the function 'function_dsl' is defined. + */ + IFile file = project.getProject().getFile("CallHierarchy_test.java"); + IWorkbenchPage page= PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart().getSite().getPage(); + IEditorInput input = new FileEditorInput(file); + IEditorDescriptor desc = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(input.getName()); + + UIJob ui = new UIJob("Open File") { + + @Override + public IStatus runInUIThread(IProgressMonitor monitor) { + try { + String editorId = null; + if (desc == null || desc.isOpenExternal()) { + editorId = "org.eclipse.ui.DefaultTextEditor"; + } else { + editorId = desc.getId(); + } + IEditorPart editor = page.openEditor(input, editorId); + IMarker fMarker = file.createMarker(IMarker.TEXT); + HashMap<String, Object> map = new HashMap<String, Object>(); + map.put(IMarker.LINE_NUMBER, 3); + fMarker.setAttributes(map); + IDE.gotoMarker(editor,fMarker); + + } catch (PartInitException e) { + e.printStackTrace(); + } catch (CoreException e) { + e.printStackTrace(); + } + return new Status(IStatus.OK, CTestPlugin.PLUGIN_ID, ""); + } + }; + ui.schedule(); + } + } + } + } +} diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/extension/DslNode.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/extension/DslNode.java index 9da5175c153..7515fb44b35 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/extension/DslNode.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/extension/DslNode.java @@ -1,76 +1,76 @@ -/*******************************************************************************
- * Copyright (c) 2018 Wind River Systems, Inc. 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:
- * Lidia Popescu - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.ui.tests.callhierarchy.extension;
-
-import org.eclipse.core.runtime.IAdaptable;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.ui.ICHENode;
-
-
-/**
- * The dsl node sample
- * */
-public class DslNode implements IAdaptable, ICHENode {
-
- private ICElement fRepresentedDecl;
- private ICProject mProject;
- private String mDslNodeName;
-
- /**
- * Constructor used for Open Call Hierarchy command
- * */
- public DslNode(ICElement decl) {
- this.fRepresentedDecl = decl;
- }
-
- /**
- * Constructor used for Open Dsl declaration command
- * */
- public DslNode() {
-
- }
-
- public ICProject getProject() {
- return mProject;
- }
-
-
- public void setProject(ICProject mProject) {
- this.mProject = mProject;
- }
-
- @Override
- public ICElement getRepresentedDeclaration() {
- return fRepresentedDecl;
- }
-
-
- @Override
- public <T> T getAdapter(Class<T> adapterClass) {
- if (adapterClass == ICElement.class) {
- return (T)getRepresentedDeclaration();
- }
- return null;
- }
-
- /**
- * Should be displayed with an indication that this is the dsl,
- * e.g. "Java function <function_name>".
- * */
- public String getDslNodeName() {
- if ( mDslNodeName == null ) {
- mDslNodeName = "JAVA function " + fRepresentedDecl.getElementName()+"()";
- }
- return mDslNodeName;
- }
-}
+/******************************************************************************* + * Copyright (c) 2018 Wind River Systems, Inc. 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: + * Lidia Popescu - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.ui.tests.callhierarchy.extension; + +import org.eclipse.core.runtime.IAdaptable; + +import org.eclipse.cdt.core.model.ICElement; +import org.eclipse.cdt.core.model.ICProject; +import org.eclipse.cdt.ui.ICHENode; + + +/** + * The dsl node sample + * */ +public class DslNode implements IAdaptable, ICHENode { + + private ICElement fRepresentedDecl; + private ICProject mProject; + private String mDslNodeName; + + /** + * Constructor used for Open Call Hierarchy command + * */ + public DslNode(ICElement decl) { + this.fRepresentedDecl = decl; + } + + /** + * Constructor used for Open Dsl declaration command + * */ + public DslNode() { + + } + + public ICProject getProject() { + return mProject; + } + + + public void setProject(ICProject mProject) { + this.mProject = mProject; + } + + @Override + public ICElement getRepresentedDeclaration() { + return fRepresentedDecl; + } + + + @Override + public <T> T getAdapter(Class<T> adapterClass) { + if (adapterClass == ICElement.class) { + return (T)getRepresentedDeclaration(); + } + return null; + } + + /** + * Should be displayed with an indication that this is the dsl, + * e.g. "Java function <function_name>". + * */ + public String getDslNodeName() { + if ( mDslNodeName == null ) { + mDslNodeName = "JAVA function " + fRepresentedDecl.getElementName()+"()"; + } + return mDslNodeName; + } +} diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/TemplateProposalTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/TemplateProposalTest.java index 6edae0b2ce6..47545979aad 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/TemplateProposalTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/TemplateProposalTest.java @@ -1,223 +1,223 @@ -/*******************************************************************************
- * Copyright (c) 2012, 2014 Marc-Andre Laperle 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:
- * Marc-Andre Laperle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.ui.tests.text.contentassist2;
-
-import junit.framework.Test;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.jface.text.templates.Template;
-import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData;
-import org.eclipse.jface.text.templates.persistence.TemplateStore;
-
-import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
-import org.eclipse.cdt.ui.CUIPlugin;
-
-import org.eclipse.cdt.internal.corext.template.c.CContextType;
-
-
-public class TemplateProposalTest extends AbstractContentAssistTest {
-
- public TemplateProposalTest(String name) {
- super(name, true);
- }
-
- public TemplateProposalTest(String name, boolean isCpp) {
- super(name, isCpp);
- }
-
- public static Test suite() {
- return BaseTestCase.suite(TemplateProposalTest.class, "_");
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
- // Remove all the default templates. Tests will add templates as necessary.
- TemplateStore templateStore = CUIPlugin.getDefault().getTemplateStore();
- TemplatePersistenceData[] templateData = templateStore.getTemplateData(false);
- for (TemplatePersistenceData templatePersistenceData : templateData) {
- templateStore.delete(templatePersistenceData);
- }
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
-
- // Restore the default templates
- CUIPlugin.getDefault().getTemplateStore().restoreDefaults();
- }
-
- private static final String HEADER_FILE_NAME = "CompletionTest.h";
- private static final String SOURCE_FILE_NAME = "CompletionTest.cpp";
- private static final String SELECTION_START_TAG = "/*sel-start*/";
- private static final String SELECTION_END_TAG = "/*sel-end*/";
-
- private static final String TEMPLATE_NAME_WORD_SELECTION = "word selection template";
- private static final String TEMPLATE_NAME_WORD_SELECTION_DISP = TEMPLATE_NAME_WORD_SELECTION + " - ";
- private static final String TEMPLATE_NAME_LINE_SELECTION = "line selection template";
- private static final String TEMPLATE_NAME_LINE_SELECTION_DISP = TEMPLATE_NAME_LINE_SELECTION + " - ";
-
- protected int fSelectionOffset;
- protected int fSelectionLength;
- private IProject fProject;
-
- @Override
- protected IFile setUpProjectContent(IProject project) throws Exception {
- fProject= project;
- StringBuilder sourceContent= getContentsForTest(1)[0];
- fSelectionOffset= sourceContent.indexOf(SELECTION_START_TAG);
- assertTrue("No selection start specified", fSelectionOffset >= 0);
- sourceContent.delete(fSelectionOffset, fSelectionOffset + SELECTION_START_TAG.length());
- int selEndOffset = sourceContent.indexOf(SELECTION_END_TAG);
-
- if (selEndOffset >= 0) {
- sourceContent.delete(selEndOffset, selEndOffset + SELECTION_END_TAG.length());
- fSelectionLength = selEndOffset - fSelectionOffset;
- } else {
- fSelectionLength = 0;
- }
-
- return createFile(project, SOURCE_FILE_NAME, sourceContent.toString());
- }
-
- private void addWordSelectionTemplate() {
- Template newTemplate = new Template(TEMPLATE_NAME_WORD_SELECTION, "", CContextType.ID, "cout << ${word_selection};", true);
- TemplatePersistenceData data= new TemplatePersistenceData(newTemplate, true);
- CUIPlugin.getDefault().getTemplateStore().add(data);
- }
-
- private void addLineSelectionTemplate() {
- Template newTemplate = new Template(TEMPLATE_NAME_LINE_SELECTION, "", CContextType.ID, "cout << ${line_selection};", true);
- TemplatePersistenceData data= new TemplatePersistenceData(newTemplate, true);
- CUIPlugin.getDefault().getTemplateStore().add(data);
- }
-
- protected static final int DEFAULT_FLAGS = AbstractContentAssistTest.DEFAULT_FLAGS | IS_COMPLETION | IS_TEMPLATE;
-
- protected void assertCompletionResults(String[] expected) throws Exception {
- assertContentAssistResults(fSelectionOffset, fSelectionLength, expected, DEFAULT_FLAGS, CompareType.ID);
- }
-
- //void func() {
- ///*sel-start*/test foo bar/*sel-end*/
- //}
- public void testFullLineSelection() throws Exception {
- addLineSelectionTemplate();
- addWordSelectionTemplate();
- final String[] expected= {
- TEMPLATE_NAME_LINE_SELECTION_DISP
- };
- assertCompletionResults(expected);
- }
-
- //void func() {
- ///*sel-start*/test foo bar
- //test foo bar/*sel-end*/
- //}
- public void testMultiLineSelection() throws Exception {
- addLineSelectionTemplate();
- addWordSelectionTemplate();
- final String[] expected= {
- TEMPLATE_NAME_LINE_SELECTION_DISP
- };
- assertCompletionResults(expected);
- }
-
- //void func() {
- //foo /*sel-start*/test/*sel-end*/
- //}
- public void testWordSelection() throws Exception {
- addLineSelectionTemplate();
- addWordSelectionTemplate();
- final String[] expected= {
- TEMPLATE_NAME_WORD_SELECTION_DISP
- };
- assertCompletionResults(expected);
- }
-
- //void func() {
- //foo/*sel-start*/test/*sel-end*/
- //}
- public void testPartialLineWordSelection() throws Exception {
- addLineSelectionTemplate();
- addWordSelectionTemplate();
- final String[] expected= {
- TEMPLATE_NAME_WORD_SELECTION_DISP
- };
- assertCompletionResults(expected);
- }
-
- //void func() {
- //test foo/*sel-start*/bar
- //test foo /*sel-end*/bar
- //}
- public void testWordSelectionOverMultiLine() throws Exception {
- addLineSelectionTemplate();
- addWordSelectionTemplate();
- final String[] expected= {
- TEMPLATE_NAME_WORD_SELECTION_DISP
- };
- assertCompletionResults(expected);
- }
-
- //void func() {
- // /*sel-start*/test/*sel-end*/
- //}
- public void testBug298554_lineSelectedWithoutWhitespaces() throws Exception {
- addLineSelectionTemplate();
- final String[] expected= {
- TEMPLATE_NAME_LINE_SELECTION_DISP
- };
- assertCompletionResults(expected);
- }
-
- //void func() {
- // /*sel-start*/test foo bar
- //test foo bar/*sel-end*/
- //}
- public void testBug298554_multiLineSelectedWithoutWhitespaces() throws Exception {
- addWordSelectionTemplate();
- addLineSelectionTemplate();
- final String[] expected= {
- TEMPLATE_NAME_LINE_SELECTION_DISP
- };
- assertCompletionResults(expected);
- }
-
- //void func() {
- // /*sel-start*/test/*sel-end*/
- //}
- public void testBug304482_onlyWordOnLine() throws Exception {
- addLineSelectionTemplate();
- addWordSelectionTemplate();
- final String[] expected= {
- TEMPLATE_NAME_LINE_SELECTION_DISP,
- TEMPLATE_NAME_WORD_SELECTION_DISP
- };
- assertCompletionResults(expected);
- }
-
- //void func() {
- ///*sel-start*/test/*sel-end*/
- //}
- public void testBug304482_onlyWordOnLineStartOfLine() throws Exception {
- addLineSelectionTemplate();
- addWordSelectionTemplate();
- final String[] expected= {
- TEMPLATE_NAME_LINE_SELECTION_DISP,
- TEMPLATE_NAME_WORD_SELECTION_DISP
- };
- assertCompletionResults(expected);
- }
-
-}
+/******************************************************************************* + * Copyright (c) 2012, 2014 Marc-Andre Laperle 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: + * Marc-Andre Laperle - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.ui.tests.text.contentassist2; + +import junit.framework.Test; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.jface.text.templates.Template; +import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData; +import org.eclipse.jface.text.templates.persistence.TemplateStore; + +import org.eclipse.cdt.core.testplugin.util.BaseTestCase; +import org.eclipse.cdt.ui.CUIPlugin; + +import org.eclipse.cdt.internal.corext.template.c.CContextType; + + +public class TemplateProposalTest extends AbstractContentAssistTest { + + public TemplateProposalTest(String name) { + super(name, true); + } + + public TemplateProposalTest(String name, boolean isCpp) { + super(name, isCpp); + } + + public static Test suite() { + return BaseTestCase.suite(TemplateProposalTest.class, "_"); + } + + @Override + protected void setUp() throws Exception { + super.setUp(); + + // Remove all the default templates. Tests will add templates as necessary. + TemplateStore templateStore = CUIPlugin.getDefault().getTemplateStore(); + TemplatePersistenceData[] templateData = templateStore.getTemplateData(false); + for (TemplatePersistenceData templatePersistenceData : templateData) { + templateStore.delete(templatePersistenceData); + } + } + + @Override + protected void tearDown() throws Exception { + super.tearDown(); + + // Restore the default templates + CUIPlugin.getDefault().getTemplateStore().restoreDefaults(); + } + + private static final String HEADER_FILE_NAME = "CompletionTest.h"; + private static final String SOURCE_FILE_NAME = "CompletionTest.cpp"; + private static final String SELECTION_START_TAG = "/*sel-start*/"; + private static final String SELECTION_END_TAG = "/*sel-end*/"; + + private static final String TEMPLATE_NAME_WORD_SELECTION = "word selection template"; + private static final String TEMPLATE_NAME_WORD_SELECTION_DISP = TEMPLATE_NAME_WORD_SELECTION + " - "; + private static final String TEMPLATE_NAME_LINE_SELECTION = "line selection template"; + private static final String TEMPLATE_NAME_LINE_SELECTION_DISP = TEMPLATE_NAME_LINE_SELECTION + " - "; + + protected int fSelectionOffset; + protected int fSelectionLength; + private IProject fProject; + + @Override + protected IFile setUpProjectContent(IProject project) throws Exception { + fProject= project; + StringBuilder sourceContent= getContentsForTest(1)[0]; + fSelectionOffset= sourceContent.indexOf(SELECTION_START_TAG); + assertTrue("No selection start specified", fSelectionOffset >= 0); + sourceContent.delete(fSelectionOffset, fSelectionOffset + SELECTION_START_TAG.length()); + int selEndOffset = sourceContent.indexOf(SELECTION_END_TAG); + + if (selEndOffset >= 0) { + sourceContent.delete(selEndOffset, selEndOffset + SELECTION_END_TAG.length()); + fSelectionLength = selEndOffset - fSelectionOffset; + } else { + fSelectionLength = 0; + } + + return createFile(project, SOURCE_FILE_NAME, sourceContent.toString()); + } + + private void addWordSelectionTemplate() { + Template newTemplate = new Template(TEMPLATE_NAME_WORD_SELECTION, "", CContextType.ID, "cout << ${word_selection};", true); + TemplatePersistenceData data= new TemplatePersistenceData(newTemplate, true); + CUIPlugin.getDefault().getTemplateStore().add(data); + } + + private void addLineSelectionTemplate() { + Template newTemplate = new Template(TEMPLATE_NAME_LINE_SELECTION, "", CContextType.ID, "cout << ${line_selection};", true); + TemplatePersistenceData data= new TemplatePersistenceData(newTemplate, true); + CUIPlugin.getDefault().getTemplateStore().add(data); + } + + protected static final int DEFAULT_FLAGS = AbstractContentAssistTest.DEFAULT_FLAGS | IS_COMPLETION | IS_TEMPLATE; + + protected void assertCompletionResults(String[] expected) throws Exception { + assertContentAssistResults(fSelectionOffset, fSelectionLength, expected, DEFAULT_FLAGS, CompareType.ID); + } + + //void func() { + ///*sel-start*/test foo bar/*sel-end*/ + //} + public void testFullLineSelection() throws Exception { + addLineSelectionTemplate(); + addWordSelectionTemplate(); + final String[] expected= { + TEMPLATE_NAME_LINE_SELECTION_DISP + }; + assertCompletionResults(expected); + } + + //void func() { + ///*sel-start*/test foo bar + //test foo bar/*sel-end*/ + //} + public void testMultiLineSelection() throws Exception { + addLineSelectionTemplate(); + addWordSelectionTemplate(); + final String[] expected= { + TEMPLATE_NAME_LINE_SELECTION_DISP + }; + assertCompletionResults(expected); + } + + //void func() { + //foo /*sel-start*/test/*sel-end*/ + //} + public void testWordSelection() throws Exception { + addLineSelectionTemplate(); + addWordSelectionTemplate(); + final String[] expected= { + TEMPLATE_NAME_WORD_SELECTION_DISP + }; + assertCompletionResults(expected); + } + + //void func() { + //foo/*sel-start*/test/*sel-end*/ + //} + public void testPartialLineWordSelection() throws Exception { + addLineSelectionTemplate(); + addWordSelectionTemplate(); + final String[] expected= { + TEMPLATE_NAME_WORD_SELECTION_DISP + }; + assertCompletionResults(expected); + } + + //void func() { + //test foo/*sel-start*/bar + //test foo /*sel-end*/bar + //} + public void testWordSelectionOverMultiLine() throws Exception { + addLineSelectionTemplate(); + addWordSelectionTemplate(); + final String[] expected= { + TEMPLATE_NAME_WORD_SELECTION_DISP + }; + assertCompletionResults(expected); + } + + //void func() { + // /*sel-start*/test/*sel-end*/ + //} + public void testBug298554_lineSelectedWithoutWhitespaces() throws Exception { + addLineSelectionTemplate(); + final String[] expected= { + TEMPLATE_NAME_LINE_SELECTION_DISP + }; + assertCompletionResults(expected); + } + + //void func() { + // /*sel-start*/test foo bar + //test foo bar/*sel-end*/ + //} + public void testBug298554_multiLineSelectedWithoutWhitespaces() throws Exception { + addWordSelectionTemplate(); + addLineSelectionTemplate(); + final String[] expected= { + TEMPLATE_NAME_LINE_SELECTION_DISP + }; + assertCompletionResults(expected); + } + + //void func() { + // /*sel-start*/test/*sel-end*/ + //} + public void testBug304482_onlyWordOnLine() throws Exception { + addLineSelectionTemplate(); + addWordSelectionTemplate(); + final String[] expected= { + TEMPLATE_NAME_LINE_SELECTION_DISP, + TEMPLATE_NAME_WORD_SELECTION_DISP + }; + assertCompletionResults(expected); + } + + //void func() { + ///*sel-start*/test/*sel-end*/ + //} + public void testBug304482_onlyWordOnLineStartOfLine() throws Exception { + addLineSelectionTemplate(); + addWordSelectionTemplate(); + final String[] expected= { + TEMPLATE_NAME_LINE_SELECTION_DISP, + TEMPLATE_NAME_WORD_SELECTION_DISP + }; + assertCompletionResults(expected); + } + +} diff --git a/core/org.eclipse.cdt.ui/schema/CCallHierarchy.exsd b/core/org.eclipse.cdt.ui/schema/CCallHierarchy.exsd index f0a235b9c9c..1c349f889ae 100644 --- a/core/org.eclipse.cdt.ui/schema/CCallHierarchy.exsd +++ b/core/org.eclipse.cdt.ui/schema/CCallHierarchy.exsd @@ -1,148 +1,148 @@ -<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.cdt.ui" xmlns="http://www.w3.org/2001/XMLSchema">
-<annotation>
- <appInfo>
- <meta.schema plugin="org.eclipse.cdt.ui" id="CCallHierarchy" name="The Call Hierarchy Tree Extension"/>
- </appInfo>
- <documentation>
- This Call Hierarchy Tree Extension makes possible to extend the CH tree content by adding a new node at the top of the tree, respectivity to customize it's icon and style text, and to add additional click listeners. This could be usefull for mixed source projects, when original declaration of a CDT node comes from a different programming language.
- </documentation>
- </annotation>
-
- <element name="extension">
- <annotation>
- <appInfo>
- <meta.element />
- </appInfo>
- </annotation>
- <complexType>
- <sequence>
- <element ref="CallHierarchyContentProvider"/>
- <element ref="CallHierarchyLabelProvider"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- <appInfo>
- <meta.attribute translatable="true"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="CallHierarchyContentProvider">
- <complexType>
- <attribute name="id" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- <appInfo>
- <meta.attribute kind="identifier"/>
- </appInfo>
- </annotation>
- </attribute>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
- </documentation>
- <appInfo>
- <meta.attribute kind="java" basedOn=":org.eclipse.cdt.ui.ICHEContentProvider"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="CallHierarchyLabelProvider">
- <complexType>
- <attribute name="id" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- <appInfo>
- <meta.attribute kind="identifier"/>
- </appInfo>
- </annotation>
- </attribute>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
- </documentation>
- <appInfo>
- <meta.attribute kind="java" basedOn=":org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider$IStyledLabelProvider"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appInfo>
- <meta.section type="since"/>
- </appInfo>
- <documentation>
- 6.4
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="examples"/>
- </appInfo>
- <documentation>
- A full sample of implementation is provided in org.eclipse.cdt.ui.tests plugin.
-<extension
- point="org.eclipse.cdt.ui.CCallHierarchy">
- <CallHierarchyLabelProvider
- class="org.eclipse.cdt.ui.tests.callhierarchy.extension.CHLabelProvider"
- id="org.eclipse.cdt.ui.tests.callhierarchy.extension.CHLabelProvider">
- </CallHierarchyLabelProvider>
- <CallHierarchyContentProvider
- class="org.eclipse.cdt.ui.tests.callhierarchy.extension.CHContentProvider"
- id="org.eclipse.cdt.ui.tests.callhierarchy.extension.CHContentProvider">
- </CallHierarchyContentProvider>
- </extension>
-
-
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="apiinfo"/>
- </appInfo>
- <documentation>
- [Enter API information here.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="implementation"/>
- </appInfo>
- <documentation>
- [Enter information about supplied implementation of this extension point.]
- </documentation>
- </annotation>
-
-
-</schema>
+<?xml version='1.0' encoding='UTF-8'?> +<!-- Schema file written by PDE --> +<schema targetNamespace="org.eclipse.cdt.ui" xmlns="http://www.w3.org/2001/XMLSchema"> +<annotation> + <appInfo> + <meta.schema plugin="org.eclipse.cdt.ui" id="CCallHierarchy" name="The Call Hierarchy Tree Extension"/> + </appInfo> + <documentation> + This Call Hierarchy Tree Extension makes possible to extend the CH tree content by adding a new node at the top of the tree, respectivity to customize it's icon and style text, and to add additional click listeners. This could be usefull for mixed source projects, when original declaration of a CDT node comes from a different programming language. + </documentation> + </annotation> + + <element name="extension"> + <annotation> + <appInfo> + <meta.element /> + </appInfo> + </annotation> + <complexType> + <sequence> + <element ref="CallHierarchyContentProvider"/> + <element ref="CallHierarchyLabelProvider"/> + </sequence> + <attribute name="point" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="id" type="string"> + <annotation> + <documentation> + </documentation> + </annotation> + </attribute> + <attribute name="name" type="string"> + <annotation> + <documentation> + + </documentation> + <appInfo> + <meta.attribute translatable="true"/> + </appInfo> + </annotation> + </attribute> + </complexType> + </element> + + <element name="CallHierarchyContentProvider"> + <complexType> + <attribute name="id" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + <appInfo> + <meta.attribute kind="identifier"/> + </appInfo> + </annotation> + </attribute> + <attribute name="class" type="string" use="required"> + <annotation> + <documentation> + </documentation> + <appInfo> + <meta.attribute kind="java" basedOn=":org.eclipse.cdt.ui.ICHEContentProvider"/> + </appInfo> + </annotation> + </attribute> + </complexType> + </element> + + <element name="CallHierarchyLabelProvider"> + <complexType> + <attribute name="id" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + <appInfo> + <meta.attribute kind="identifier"/> + </appInfo> + </annotation> + </attribute> + <attribute name="class" type="string" use="required"> + <annotation> + <documentation> + </documentation> + <appInfo> + <meta.attribute kind="java" basedOn=":org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider$IStyledLabelProvider"/> + </appInfo> + </annotation> + </attribute> + </complexType> + </element> + + <annotation> + <appInfo> + <meta.section type="since"/> + </appInfo> + <documentation> + 6.4 + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="examples"/> + </appInfo> + <documentation> + A full sample of implementation is provided in org.eclipse.cdt.ui.tests plugin. +<extension + point="org.eclipse.cdt.ui.CCallHierarchy"> + <CallHierarchyLabelProvider + class="org.eclipse.cdt.ui.tests.callhierarchy.extension.CHLabelProvider" + id="org.eclipse.cdt.ui.tests.callhierarchy.extension.CHLabelProvider"> + </CallHierarchyLabelProvider> + <CallHierarchyContentProvider + class="org.eclipse.cdt.ui.tests.callhierarchy.extension.CHContentProvider" + id="org.eclipse.cdt.ui.tests.callhierarchy.extension.CHContentProvider"> + </CallHierarchyContentProvider> + </extension> + + + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="apiinfo"/> + </appInfo> + <documentation> + [Enter API information here.] + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="implementation"/> + </appInfo> + <documentation> + [Enter information about supplied implementation of this extension point.] + </documentation> + </annotation> + + +</schema> diff --git a/core/org.eclipse.cdt.ui/schema/newToolChainWizards.exsd b/core/org.eclipse.cdt.ui/schema/newToolChainWizards.exsd index c316643ab07..4ca38d8ac34 100644 --- a/core/org.eclipse.cdt.ui/schema/newToolChainWizards.exsd +++ b/core/org.eclipse.cdt.ui/schema/newToolChainWizards.exsd @@ -1,129 +1,129 @@ -<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.cdt.ui" xmlns="http://www.w3.org/2001/XMLSchema">
-<annotation>
- <appInfo>
- <meta.schema plugin="org.eclipse.cdt.ui" id="newToolChainWizards" name="New ToolChain Wizards"/>
- </appInfo>
- <documentation>
- [Enter description of this extension point.]
- </documentation>
- </annotation>
-
- <element name="extension">
- <annotation>
- <appInfo>
- <meta.element />
- </appInfo>
- </annotation>
- <complexType>
- <sequence minOccurs="1" maxOccurs="unbounded">
- <element ref="wizard"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- <appInfo>
- <meta.attribute translatable="true"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="wizard">
- <complexType>
- <attribute name="name" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="icon" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- <appInfo>
- <meta.attribute kind="resource"/>
- </appInfo>
- </annotation>
- </attribute>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- <appInfo>
- <meta.attribute kind="java" basedOn="org.eclipse.cdt.ui.build.ToolChainWizard:"/>
- </appInfo>
- </annotation>
- </attribute>
- <attribute name="providerId" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- <appInfo>
- <meta.attribute kind="identifier" basedOn="org.eclipse.cdt.core.toolChainProvider/provider/@id"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appInfo>
- <meta.section type="since"/>
- </appInfo>
- <documentation>
- [Enter the first release in which this extension point appears.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="examples"/>
- </appInfo>
- <documentation>
- [Enter extension point usage example here.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="apiinfo"/>
- </appInfo>
- <documentation>
- [Enter API information here.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="implementation"/>
- </appInfo>
- <documentation>
- [Enter information about supplied implementation of this extension point.]
- </documentation>
- </annotation>
-
-
-</schema>
+<?xml version='1.0' encoding='UTF-8'?> +<!-- Schema file written by PDE --> +<schema targetNamespace="org.eclipse.cdt.ui" xmlns="http://www.w3.org/2001/XMLSchema"> +<annotation> + <appInfo> + <meta.schema plugin="org.eclipse.cdt.ui" id="newToolChainWizards" name="New ToolChain Wizards"/> + </appInfo> + <documentation> + [Enter description of this extension point.] + </documentation> + </annotation> + + <element name="extension"> + <annotation> + <appInfo> + <meta.element /> + </appInfo> + </annotation> + <complexType> + <sequence minOccurs="1" maxOccurs="unbounded"> + <element ref="wizard"/> + </sequence> + <attribute name="point" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="id" type="string"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="name" type="string"> + <annotation> + <documentation> + + </documentation> + <appInfo> + <meta.attribute translatable="true"/> + </appInfo> + </annotation> + </attribute> + </complexType> + </element> + + <element name="wizard"> + <complexType> + <attribute name="name" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="icon" type="string"> + <annotation> + <documentation> + + </documentation> + <appInfo> + <meta.attribute kind="resource"/> + </appInfo> + </annotation> + </attribute> + <attribute name="class" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + <appInfo> + <meta.attribute kind="java" basedOn="org.eclipse.cdt.ui.build.ToolChainWizard:"/> + </appInfo> + </annotation> + </attribute> + <attribute name="providerId" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + <appInfo> + <meta.attribute kind="identifier" basedOn="org.eclipse.cdt.core.toolChainProvider/provider/@id"/> + </appInfo> + </annotation> + </attribute> + </complexType> + </element> + + <annotation> + <appInfo> + <meta.section type="since"/> + </appInfo> + <documentation> + [Enter the first release in which this extension point appears.] + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="examples"/> + </appInfo> + <documentation> + [Enter extension point usage example here.] + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="apiinfo"/> + </appInfo> + <documentation> + [Enter API information here.] + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="implementation"/> + </appInfo> + <documentation> + [Enter information about supplied implementation of this extension point.] + </documentation> + </annotation> + + +</schema> diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ImageCombo.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ImageCombo.java index e4f308de5f7..18a52ee082d 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ImageCombo.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ImageCombo.java @@ -1,1502 +1,1502 @@ -/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- * Tom Seidel - enhancements for image-handling
+/******************************************************************************* + * Copyright (c) 2000, 2015 IBM Corporation 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: + * IBM Corporation - initial API and implementation + * Tom Seidel - enhancements for image-handling *******************************************************************************/ -package org.eclipse.cdt.internal.ui;
-
-import java.util.Arrays;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.SWTException;
-import org.eclipse.swt.accessibility.ACC;
-import org.eclipse.swt.accessibility.AccessibleAdapter;
-import org.eclipse.swt.accessibility.AccessibleControlAdapter;
-import org.eclipse.swt.accessibility.AccessibleControlEvent;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.accessibility.AccessibleTextAdapter;
-import org.eclipse.swt.accessibility.AccessibleTextEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Layout;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.swt.widgets.TypedListener;
-import org.eclipse.swt.widgets.Widget;
-
-/**
- * The ImageCombo class represents a selectable user interface object
- * that combines a text field and a table and issues notification
- * when an item is selected from the table.
- * <p>
- * Note that although this class is a subclass of <code>Composite</code>,
- * it does not make sense to add children to it, or set a layout on it.
- * </p>
- * <dl>
- * <dt><b>Styles:</b>
- * <dd>BORDER, READ_ONLY, FLAT</dd>
- * <dt><b>Events:</b>
- * <dd>Selection</dd>
- * </dl>
- */
-public final class ImageCombo extends Composite {
-
- Text text;
- Table table;
- int visibleItemCount = 5;
- Shell popup;
- Button arrow;
- boolean hasFocus;
- Listener listener, filter;
- Color foreground, background;
- Font font;
-
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a widget which will be the parent of the new instance (cannot be null)
- * @param style the style of widget to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * </ul>
- *
- * @see SWT#BORDER
- * @see SWT#READ_ONLY
- * @see SWT#FLAT
- * @see Widget#getStyle()
- */
-public ImageCombo (Composite parent, int style) {
- super (parent, style = checkStyle (style));
-
- int textStyle = SWT.SINGLE;
- if ((style & SWT.READ_ONLY) != 0) textStyle |= SWT.READ_ONLY;
- if ((style & SWT.FLAT) != 0) textStyle |= SWT.FLAT;
- text = new Text (this, SWT.NONE);
- int arrowStyle = SWT.ARROW | SWT.DOWN;
- if ((style & SWT.FLAT) != 0) arrowStyle |= SWT.FLAT;
- arrow = new Button (this, arrowStyle);
-
- listener = new Listener () {
- @Override
- public void handleEvent (Event event) {
- if (popup == event.widget) {
- popupEvent (event);
- return;
- }
- if (text == event.widget) {
- textEvent (event);
- return;
- }
- if (table == event.widget) {
- listEvent (event);
- return;
- }
- if (arrow == event.widget) {
- arrowEvent (event);
- return;
- }
- if (ImageCombo.this == event.widget) {
- comboEvent (event);
- return;
- }
- if (getShell () == event.widget) {
- handleFocus (SWT.FocusOut);
- }
- }
- };
- filter = new Listener() {
- @Override
- public void handleEvent(Event event) {
- Shell shell = ((Control)event.widget).getShell ();
- if (shell == ImageCombo.this.getShell ()) {
- handleFocus (SWT.FocusOut);
- }
- }
- };
-
- int [] comboEvents = {SWT.Dispose, SWT.Move, SWT.Resize};
- for (int i=0; i<comboEvents.length; i++) this.addListener (comboEvents [i], listener);
-
- int [] textEvents = {SWT.KeyDown, SWT.KeyUp, SWT.Modify, SWT.MouseDown, SWT.MouseUp, SWT.Traverse, SWT.FocusIn};
- for (int i=0; i<textEvents.length; i++) text.addListener (textEvents [i], listener);
-
- int [] arrowEvents = {SWT.Selection, SWT.FocusIn};
- for (int i=0; i<arrowEvents.length; i++) arrow.addListener (arrowEvents [i], listener);
-
- createPopup( -1);
- initAccessible();
-}
-static int checkStyle (int style) {
- int mask = SWT.BORDER | SWT.READ_ONLY | SWT.FLAT | SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT;
- return style & mask;
-}
-/**
- * Adds the argument to the end of the receiver's list.
- *
- * @param string the new item
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #add(String,int)
- */
-public void add (String string, Image image) {
- checkWidget();
- if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- TableItem newItem = new TableItem(this.table,SWT.NONE);
- newItem.setText(string);
- if (image != null) newItem.setImage(image);
-}
-/**
- * Adds the argument to the receiver's list at the given
- * zero-relative index.
- * <p>
- * Note: To add an item at the end of the list, use the
- * result of calling <code>getItemCount()</code> as the
- * index or use <code>add(String)</code>.
- * </p>
- *
- * @param string the new item
- * @param index the index for the item
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list (inclusive)</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #add(String)
- */
-public void add (String string,Image image, int index) {
- checkWidget();
- if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- TableItem newItem = new TableItem(this.table,SWT.NONE,index);
- if (image != null) newItem.setImage(image);
-}
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when the receiver's text is modified, by sending
- * it one of the messages defined in the <code>ModifyListener</code>
- * interface.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see ModifyListener
- * @see #removeModifyListener
- */
-public void addModifyListener (ModifyListener listener) {
- checkWidget();
- if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Modify, typedListener);
-}
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when the receiver's selection changes, by sending
- * it one of the messages defined in the <code>SelectionListener</code>
- * interface.
- * <p>
- * <code>widgetSelected</code> is called when the combo's list selection changes.
- * <code>widgetDefaultSelected</code> is typically called when ENTER is pressed the combo's text area.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
- */
-public void addSelectionListener(SelectionListener listener) {
- checkWidget();
- if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Selection,typedListener);
- addListener (SWT.DefaultSelection,typedListener);
-}
-void arrowEvent (Event event) {
- switch (event.type) {
- case SWT.FocusIn: {
- handleFocus (SWT.FocusIn);
- break;
- }
- case SWT.Selection: {
- dropDown (!isDropped ());
- break;
- }
- }
-}
-/**
- * Sets the selection in the receiver's text field to an empty
- * selection starting just before the first character. If the
- * text field is editable, this has the effect of placing the
- * i-beam at the start of the text.
- * <p>
- * Note: To clear the selected items in the receiver's list,
- * use <code>deselectAll()</code>.
- * </p>
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #deselectAll
- */
-public void clearSelection () {
- checkWidget ();
- text.clearSelection ();
- table.deselectAll ();
-}
-void comboEvent (Event event) {
- switch (event.type) {
- case SWT.Dispose:
- if (popup != null && !popup.isDisposed ()) {
- table.removeListener (SWT.Dispose, listener);
- popup.dispose ();
- }
- Shell shell = getShell ();
- shell.removeListener (SWT.Deactivate, listener);
- Display display = getDisplay ();
- display.removeFilter (SWT.FocusIn, filter);
- popup = null;
- text = null;
- table = null;
- arrow = null;
- break;
- case SWT.Move:
- dropDown (false);
- break;
- case SWT.Resize:
- internalLayout (false);
- break;
- }
-}
-
-@Override
-public Point computeSize (int wHint, int hHint, boolean changed) {
- checkWidget ();
- int width = 0, height = 0;
- String[] items = getStringsFromTable();
- int textWidth = 0;
- GC gc = new GC (text);
- int spacer = gc.stringExtent (" ").x; //$NON-NLS-1$
- for (int i = 0; i < items.length; i++) {
- textWidth = Math.max (gc.stringExtent (items[i]).x, textWidth);
- }
- gc.dispose();
- Point textSize = text.computeSize (SWT.DEFAULT, SWT.DEFAULT, changed);
- Point arrowSize = arrow.computeSize (SWT.DEFAULT, SWT.DEFAULT, changed);
- Point listSize = table.computeSize (wHint, SWT.DEFAULT, changed);
- int borderWidth = getBorderWidth ();
-
- height = Math.max (hHint, Math.max (textSize.y, arrowSize.y) + 2*borderWidth);
- width = Math.max (wHint, Math.max (textWidth + 2*spacer + arrowSize.x + 2*borderWidth, listSize.x));
- return new Point (width, height);
-}
-void createPopup(int selectionIndex) {
- // create shell and list
- popup = new Shell (getShell (), SWT.NO_TRIM | SWT.ON_TOP);
- int style = getStyle ();
- int listStyle = SWT.SINGLE | SWT.V_SCROLL;
- if ((style & SWT.FLAT) != 0) listStyle |= SWT.FLAT;
- if ((style & SWT.RIGHT_TO_LEFT) != 0) listStyle |= SWT.RIGHT_TO_LEFT;
- if ((style & SWT.LEFT_TO_RIGHT) != 0) listStyle |= SWT.LEFT_TO_RIGHT;
- // create a table instead of a list.
- table = new Table (popup, listStyle);
- if (font != null) table.setFont (font);
- if (foreground != null) table.setForeground (foreground);
- if (background != null) table.setBackground (background);
-
- int [] popupEvents = {SWT.Close, SWT.Paint, SWT.Deactivate};
- for (int i=0; i<popupEvents.length; i++) popup.addListener (popupEvents [i], listener);
- int [] listEvents = {SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp, SWT.FocusIn, SWT.Dispose};
- for (int i=0; i<listEvents.length; i++) table.addListener (listEvents [i], listener);
-
- if (selectionIndex != -1) table.setSelection (selectionIndex);
-}
-/**
- * Deselects the item at the given zero-relative index in the receiver's
- * list. If the item at the index was already deselected, it remains
- * deselected. Indices that are out of range are ignored.
- *
- * @param index the index of the item to deselect
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void deselect (int index) {
- checkWidget ();
- table.deselect (index);
-}
-/**
- * Deselects all selected items in the receiver's list.
- * <p>
- * Note: To clear the selection in the receiver's text field,
- * use <code>clearSelection()</code>.
- * </p>
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #clearSelection
- */
-public void deselectAll () {
- checkWidget ();
- table.deselectAll ();
-}
-void dropDown (boolean drop) {
- if (drop == isDropped ()) return;
- if (!drop) {
- popup.setVisible (false);
- if (!isDisposed ()&& arrow.isFocusControl()) {
- text.setFocus();
- }
- return;
- }
-
- if (getShell() != popup.getParent ()) {
- TableItem[] items = table.getItems ();
- int selectionIndex = table.getSelectionIndex ();
- table.removeListener (SWT.Dispose, listener);
- popup.dispose();
- popup = null;
- table = null;
- createPopup (selectionIndex);
- }
-
- Point size = getSize ();
- int itemCount = table.getItemCount ();
- itemCount = (itemCount == 0) ? visibleItemCount : Math.min(visibleItemCount, itemCount);
- int itemHeight = table.getItemHeight () * itemCount;
- Point listSize = table.computeSize (SWT.DEFAULT, itemHeight, false);
- table.setBounds (1, 1, Math.max (size.x - 2, listSize.x), listSize.y);
-
- int index = table.getSelectionIndex ();
- if (index != -1) table.setTopIndex (index);
- Display display = getDisplay ();
- Rectangle listRect = table.getBounds ();
- Rectangle parentRect = display.map (getParent (), null, getBounds ());
- Point comboSize = getSize ();
- Rectangle displayRect = getMonitor ().getClientArea ();
- int width = Math.max (comboSize.x, listRect.width + 2);
- int height = listRect.height + 2;
- int x = parentRect.x;
- int y = parentRect.y + comboSize.y;
- if (y + height > displayRect.y + displayRect.height) y = parentRect.y - height;
- popup.setBounds (x, y, width, height);
- popup.setVisible (true);
- table.setFocus ();
-}
-/*
- * Return the Label immediately preceding the receiver in the z-order,
- * or null if none.
- */
-Label getAssociatedLabel () {
- Control[] siblings = getParent ().getChildren ();
- for (int i = 0; i < siblings.length; i++) {
- if (siblings [i] == ImageCombo.this) {
- if (i > 0 && siblings [i-1] instanceof Label) {
- return (Label) siblings [i-1];
- }
- }
- }
- return null;
-}
-@Override
-public Control [] getChildren () {
- checkWidget();
- return new Control [0];
-}
-/**
- * Gets the editable state.
- *
- * @return whether or not the reciever is editable
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 3.0
- */
-public boolean getEditable () {
- checkWidget ();
- return text.getEditable();
-}
-/**
- * Returns the item at the given, zero-relative index in the
- * receiver's list. Throws an exception if the index is out
- * of range.
- *
- * @param index the index of the item to return
- * @return the item at the given index
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public TableItem getItem (int index) {
- checkWidget();
- return this.table.getItem (index);
-}
-/**
- * Returns the number of items contained in the receiver's list.
- *
- * @return the number of items
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getItemCount () {
- checkWidget ();
- return table.getItemCount ();
-}
-/**
- * Returns the height of the area which would be used to
- * display <em>one</em> of the items in the receiver's list.
- *
- * @return the height of one item
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getItemHeight () {
- checkWidget ();
- return table.getItemHeight ();
-}
-/**
- * Returns an array of <code>String</code>s which are the items
- * in the receiver's list.
- * <p>
- * Note: This is not the actual structure used by the receiver
- * to maintain its list of items, so modifying the array will
- * not affect the receiver.
- * </p>
- *
- * @return the items in the receiver's list
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public TableItem [] getItems () {
- checkWidget ();
- return table.getItems ();
-}
-char getMnemonic (String string) {
- int index = 0;
- int length = string.length ();
- do {
- while ((index < length) && (string.charAt (index) != '&')) index++;
- if (++index >= length) return '\0';
- if (string.charAt (index) != '&') return string.charAt (index);
- index++;
- } while (index < length);
- return '\0';
-}
-
-String [] getStringsFromTable()
-{
- String[] items = new String[this.table.getItems().length];
- for (int i = 0, n = items.length; i < n; i++) {
- items[i]=this.table.getItem(i).getText();
- }
- return items;
-}
-/**
- * Returns a <code>Point</code> whose x coordinate is the start
- * of the selection in the receiver's text field, and whose y
- * coordinate is the end of the selection. The returned values
- * are zero-relative. An "empty" selection as indicated by
- * the the x and y coordinates having the same value.
- *
- * @return a point representing the selection start and end
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Point getSelection () {
- checkWidget ();
- return text.getSelection ();
-}
-/**
- * Returns the zero-relative index of the item which is currently
- * selected in the receiver's list, or -1 if no item is selected.
- *
- * @return the index of the selected item
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getSelectionIndex () {
- checkWidget ();
- return table.getSelectionIndex ();
-}
-@Override
-public int getStyle () {
- int style = super.getStyle ();
- style &= ~SWT.READ_ONLY;
- if (!text.getEditable()) style |= SWT.READ_ONLY;
- return style;
-}
-/**
- * Returns a string containing a copy of the contents of the
- * receiver's text field.
- *
- * @return the receiver's text
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public String getText () {
- checkWidget ();
- return text.getText ();
-}
-/**
- * Returns the height of the receivers's text field.
- *
- * @return the text height
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getTextHeight () {
- checkWidget ();
- return text.getLineHeight ();
-}
-/**
- * Returns the maximum number of characters that the receiver's
- * text field is capable of holding. If this has not been changed
- * by <code>setTextLimit()</code>, it will be the constant
- * <code>Combo.LIMIT</code>.
- *
- * @return the text limit
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getTextLimit () {
- checkWidget ();
- return text.getTextLimit ();
-}
-/**
- * Gets the number of items that are visible in the drop
- * down portion of the receiver's list.
- *
- * @return the number of items that are visible
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 3.0
- */
-public int getVisibleItemCount () {
- checkWidget ();
- return visibleItemCount;
-}
-void handleFocus (int type) {
- if (isDisposed ()) return;
- switch (type) {
- case SWT.FocusIn: {
- if (hasFocus) return;
- if (getEditable ()) text.selectAll ();
- hasFocus = true;
- Shell shell = getShell ();
- shell.removeListener (SWT.Deactivate, listener);
- shell.addListener (SWT.Deactivate, listener);
- Display display = getDisplay ();
- display.removeFilter (SWT.FocusIn, filter);
- display.addFilter (SWT.FocusIn, filter);
- Event e = new Event ();
- notifyListeners (SWT.FocusIn, e);
- break;
- }
- case SWT.FocusOut: {
- if (!hasFocus) return;
- Control focusControl = getDisplay ().getFocusControl ();
- if (focusControl == arrow || focusControl == table || focusControl == text) return;
- hasFocus = false;
- Shell shell = getShell ();
- shell.removeListener(SWT.Deactivate, listener);
- Display display = getDisplay ();
- display.removeFilter (SWT.FocusIn, filter);
- Event e = new Event ();
- notifyListeners (SWT.FocusOut, e);
- break;
- }
- }
-}
-/**
- * Searches the receiver's list starting at the first item
- * (index 0) until an item is found that is equal to the
- * argument, and returns the index of that item. If no item
- * is found, returns -1.
- *
- * @param string the search item
- * @return the index of the item
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int indexOf (String string) {
- checkWidget ();
- if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- return Arrays.asList(getStringsFromTable()).indexOf (string);
-}
-
-
-void initAccessible() {
- AccessibleAdapter accessibleAdapter = new AccessibleAdapter () {
- @Override
- public void getName (AccessibleEvent e) {
- String name = null;
- Label label = getAssociatedLabel ();
- if (label != null) {
- name = stripMnemonic (label.getText());
- }
- e.result = name;
- }
- @Override
- public void getKeyboardShortcut(AccessibleEvent e) {
- String shortcut = null;
- Label label = getAssociatedLabel ();
- if (label != null) {
- String text = label.getText ();
- if (text != null) {
- char mnemonic = getMnemonic (text);
- if (mnemonic != '\0') {
- shortcut = "Alt+"+mnemonic; //$NON-NLS-1$
- }
- }
- }
- e.result = shortcut;
- }
- @Override
- public void getHelp (AccessibleEvent e) {
- e.result = getToolTipText ();
- }
- };
- getAccessible ().addAccessibleListener (accessibleAdapter);
- text.getAccessible ().addAccessibleListener (accessibleAdapter);
- table.getAccessible ().addAccessibleListener (accessibleAdapter);
-
- arrow.getAccessible ().addAccessibleListener (new AccessibleAdapter() {
- @Override
- public void getName (AccessibleEvent e) {
- e.result = isDropped () ? SWT.getMessage ("SWT_Close") : SWT.getMessage ("SWT_Open"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- @Override
- public void getKeyboardShortcut (AccessibleEvent e) {
- e.result = "Alt+Down Arrow"; //$NON-NLS-1$
- }
- @Override
- public void getHelp (AccessibleEvent e) {
- e.result = getToolTipText ();
- }
- });
-
- getAccessible().addAccessibleTextListener (new AccessibleTextAdapter() {
- @Override
- public void getCaretOffset (AccessibleTextEvent e) {
- e.offset = text.getCaretPosition ();
- }
- });
-
- getAccessible().addAccessibleControlListener (new AccessibleControlAdapter() {
- @Override
- public void getChildAtPoint (AccessibleControlEvent e) {
- Point testPoint = toControl (e.x, e.y);
- if (getBounds ().contains (testPoint)) {
- e.childID = ACC.CHILDID_SELF;
- }
- }
-
- @Override
- public void getLocation (AccessibleControlEvent e) {
- Rectangle location = getBounds ();
- Point pt = toDisplay (location.x, location.y);
- e.x = pt.x;
- e.y = pt.y;
- e.width = location.width;
- e.height = location.height;
- }
-
- @Override
- public void getChildCount (AccessibleControlEvent e) {
- e.detail = 0;
- }
-
- @Override
- public void getRole (AccessibleControlEvent e) {
- e.detail = ACC.ROLE_COMBOBOX;
- }
-
- @Override
- public void getState (AccessibleControlEvent e) {
- e.detail = ACC.STATE_NORMAL;
- }
-
- @Override
- public void getValue (AccessibleControlEvent e) {
- e.result = getText ();
- }
- });
-
- text.getAccessible ().addAccessibleControlListener (new AccessibleControlAdapter () {
- @Override
- public void getRole (AccessibleControlEvent e) {
- e.detail = text.getEditable () ? ACC.ROLE_TEXT : ACC.ROLE_LABEL;
- }
- });
-
- arrow.getAccessible ().addAccessibleControlListener (new AccessibleControlAdapter() {
- @Override
- public void getDefaultAction (AccessibleControlEvent e) {
- e.result = isDropped () ? SWT.getMessage ("SWT_Close") : SWT.getMessage ("SWT_Open"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- });
-}
-boolean isDropped () {
- return popup.getVisible ();
-}
-@Override
-public boolean isFocusControl () {
- checkWidget();
- if (text.isFocusControl () || arrow.isFocusControl () || table.isFocusControl () || popup.isFocusControl ()) {
- return true;
- }
- return super.isFocusControl ();
-}
-void internalLayout (boolean changed) {
- if (isDropped ()) dropDown (false);
- Rectangle rect = getClientArea ();
- int width = rect.width;
- int height = rect.height;
- Point arrowSize = arrow.computeSize (SWT.DEFAULT, height, changed);
- text.setBounds (0, 0, width - arrowSize.x, height);
- arrow.setBounds (width - arrowSize.x, 0, arrowSize.x, arrowSize.y);
-}
-void listEvent (Event event) {
- switch (event.type) {
- case SWT.Dispose:
- if (getShell () != popup.getParent ()) {
- TableItem[] items = table.getItems ();
- int selectionIndex = table.getSelectionIndex ();
- popup = null;
- table = null;
- createPopup (selectionIndex);
- }
- break;
- case SWT.FocusIn: {
- handleFocus (SWT.FocusIn);
- break;
- }
- case SWT.MouseUp: {
- if (event.button != 1) return;
- dropDown (false);
- break;
- }
- case SWT.Selection: {
- int index = table.getSelectionIndex ();
- if (index == -1) return;
- text.setText (table.getItem (index).getText());
- text.selectAll ();
- table.setSelection (index);
- Event e = new Event ();
- e.time = event.time;
- e.stateMask = event.stateMask;
- e.doit = event.doit;
- notifyListeners (SWT.Selection, e);
- event.doit = e.doit;
- break;
- }
- case SWT.Traverse: {
- switch (event.detail) {
- case SWT.TRAVERSE_RETURN:
- case SWT.TRAVERSE_ESCAPE:
- case SWT.TRAVERSE_ARROW_PREVIOUS:
- case SWT.TRAVERSE_ARROW_NEXT:
- event.doit = false;
- break;
- }
- Event e = new Event ();
- e.time = event.time;
- e.detail = event.detail;
- e.doit = event.doit;
- e.character = event.character;
- e.keyCode = event.keyCode;
- notifyListeners (SWT.Traverse, e);
- event.doit = e.doit;
- event.detail = e.detail;
- break;
- }
- case SWT.KeyUp: {
- Event e = new Event ();
- e.time = event.time;
- e.character = event.character;
- e.keyCode = event.keyCode;
- e.stateMask = event.stateMask;
- notifyListeners (SWT.KeyUp, e);
- break;
- }
- case SWT.KeyDown: {
- if (event.character == SWT.ESC) {
- // Escape key cancels popup list
- dropDown (false);
- }
- if ((event.stateMask & SWT.ALT) != 0 && (event.keyCode == SWT.ARROW_UP || event.keyCode == SWT.ARROW_DOWN)) {
- dropDown (false);
- }
- if (event.character == SWT.CR) {
- // Enter causes default selection
- dropDown (false);
- Event e = new Event ();
- e.time = event.time;
- e.stateMask = event.stateMask;
- notifyListeners (SWT.DefaultSelection, e);
- }
- // At this point the widget may have been disposed.
- // If so, do not continue.
- if (isDisposed ()) break;
- Event e = new Event();
- e.time = event.time;
- e.character = event.character;
- e.keyCode = event.keyCode;
- e.stateMask = event.stateMask;
- notifyListeners(SWT.KeyDown, e);
- break;
-
- }
- }
-}
-
-void popupEvent(Event event) {
- switch (event.type) {
- case SWT.Paint:
- // draw black rectangle around list
- Rectangle listRect = table.getBounds();
- Color black = getDisplay().getSystemColor(SWT.COLOR_BLACK);
- event.gc.setForeground(black);
- event.gc.drawRectangle(0, 0, listRect.width + 1, listRect.height + 1);
- break;
- case SWT.Close:
- event.doit = false;
- dropDown (false);
- break;
- case SWT.Deactivate:
- dropDown (false);
- break;
- }
-}
-@Override
-public void redraw () {
- super.redraw();
- text.redraw();
- arrow.redraw();
- if (popup.isVisible()) table.redraw();
-}
-@Override
-public void redraw (int x, int y, int width, int height, boolean all) {
- super.redraw(x, y, width, height, true);
-}
-
-/**
- * Removes the item from the receiver's list at the given
- * zero-relative index.
- *
- * @param index the index for the item
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void remove (int index) {
- checkWidget();
- table.remove (index);
-}
-/**
- * Removes the items from the receiver's list which are
- * between the given zero-relative start and end
- * indices (inclusive).
- *
- * @param start the start of the range
- * @param end the end of the range
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_RANGE - if either the start or end are not between 0 and the number of elements in the list minus 1 (inclusive)</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void remove (int start, int end) {
- checkWidget();
- table.remove (start, end);
-}
-/**
- * Searches the receiver's list starting at the first item
- * until an item is found that is equal to the argument,
- * and removes that item from the list.
- *
- * @param string the item to remove
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the string is not found in the list</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void remove (String string) {
- checkWidget();
- if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- int index = -1;
- for (int i = 0, n = table.getItemCount(); i < n; i++) {
- if (table.getItem(i).getText().equals(string)) {
- index = i;
- break;
- }
- }
- remove(index);
-}
-/**
- * Removes all of the items from the receiver's list and clear the
- * contents of receiver's text field.
- * <p>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void removeAll () {
- checkWidget();
- text.setText (""); //$NON-NLS-1$
- table.removeAll ();
-}
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when the receiver's text is modified.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see ModifyListener
- * @see #addModifyListener
- */
-public void removeModifyListener (ModifyListener listener) {
- checkWidget();
- if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- removeListener(SWT.Modify, listener);
-}
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when the receiver's selection changes.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #addSelectionListener
- */
-public void removeSelectionListener (SelectionListener listener) {
- checkWidget();
- if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- removeListener(SWT.Selection, listener);
- removeListener(SWT.DefaultSelection,listener);
-}
-/**
- * Selects the item at the given zero-relative index in the receiver's
- * list. If the item at the index was already selected, it remains
- * selected. Indices that are out of range are ignored.
- *
- * @param index the index of the item to select
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void select (int index) {
- checkWidget();
- if (index == -1) {
- table.deselectAll ();
- text.setText (""); //$NON-NLS-1$
- return;
- }
- if (0 <= index && index < table.getItemCount()) {
- if (index != getSelectionIndex()) {
- text.setText (table.getItem (index).getText());
- text.selectAll ();
- table.select (index);
- table.showSelection ();
- }
- }
-}
-@Override
-public void setBackground (Color color) {
- super.setBackground(color);
- background = color;
- if (text != null) text.setBackground(color);
- if (table != null) table.setBackground(color);
- if (arrow != null) arrow.setBackground(color);
-}
-/**
- * Sets the editable state.
- *
- * @param editable the new editable state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 3.0
- */
-public void setEditable (boolean editable) {
- checkWidget ();
- text.setEditable(editable);
-}
-@Override
-public void setEnabled (boolean enabled) {
- super.setEnabled(enabled);
- if (popup != null) popup.setVisible (false);
- if (text != null) text.setEnabled(enabled);
- if (arrow != null) arrow.setEnabled(enabled);
-}
-@Override
-public boolean setFocus () {
- checkWidget();
- return text.setFocus ();
-}
-@Override
-public void setFont (Font font) {
- super.setFont (font);
- this.font = font;
- text.setFont (font);
- table.setFont (font);
- internalLayout (true);
-}
-@Override
-public void setForeground (Color color) {
- super.setForeground(color);
- foreground = color;
- if (text != null) text.setForeground(color);
- if (table != null) table.setForeground(color);
- if (arrow != null) arrow.setForeground(color);
-}
-/**
- * Sets the text of the item in the receiver's list at the given
- * zero-relative index to the string argument. This is equivalent
- * to <code>remove</code>'ing the old item at the index, and then
- * <code>add</code>'ing the new item at that index.
- *
- * @param index the index for the item
- * @param string the new text for the item
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setItem (int index, String string, Image image) {
- checkWidget();
- remove(index);
- add(string,image,index);
-}
-/**
- * Sets the receiver's list to be the given array of items.
- *
- * @param items the array of items
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the items array is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if an item in the items array is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setItems (String [] items) {
- checkWidget ();
- this.table.removeAll();
- for (int i = 0, n = items.length; i < n; i++) {
- add(items[i],null);
- }
- if (!text.getEditable ()) text.setText (""); //$NON-NLS-1$
-}
-
-/**
- * Sets the layout which is associated with the receiver to be
- * the argument which may be null.
- * <p>
- * Note : No Layout can be set on this Control because it already
- * manages the size and position of its children.
- * </p>
- *
- * @param layout the receiver's new layout or null
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-@Override
-public void setLayout (Layout layout) {
- checkWidget ();
- return;
-}
-/**
- * Sets the selection in the receiver's text field to the
- * range specified by the argument whose x coordinate is the
- * start of the selection and whose y coordinate is the end
- * of the selection.
- *
- * @param selection a point representing the new selection start and end
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the point is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setSelection (Point selection) {
- checkWidget();
- if (selection == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- text.setSelection (selection.x, selection.y);
-}
-
-/**
- * Sets the contents of the receiver's text field to the
- * given string.
- * <p>
- * Note: The text field in a <code>Combo</code> is typically
- * only capable of displaying a single line of text. Thus,
- * setting the text to a string containing line breaks or
- * other special characters will probably cause it to
- * display incorrectly.
- * </p>
- *
- * @param string the new text
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setText (String string) {
- checkWidget();
- if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- int index = -1;
- for (int i = 0, n = table.getItemCount(); i < n; i++) {
- if (table.getItem(i).getText().equals(string)) {
- index = i;
- break;
- }
- }
- if (index == -1) {
- table.deselectAll ();
- text.setText (string);
- return;
- }
- text.setText (string);
- text.selectAll ();
- table.setSelection (index);
- table.showSelection ();
-}
-/**
- * Sets the maximum number of characters that the receiver's
- * text field is capable of holding to be the argument.
- *
- * @param limit new text limit
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_CANNOT_BE_ZERO - if the limit is zero</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setTextLimit (int limit) {
- checkWidget();
- text.setTextLimit (limit);
-}
-
-@Override
-public void setToolTipText (String string) {
- checkWidget();
- super.setToolTipText(string);
- arrow.setToolTipText (string);
- text.setToolTipText (string);
-}
-
-@Override
-public void setVisible (boolean visible) {
- super.setVisible(visible);
- if (!visible) popup.setVisible(false);
-}
-/**
- * Sets the number of items that are visible in the drop
- * down portion of the receiver's list.
- *
- * @param count the new number of items to be visible
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 3.0
- */
-public void setVisibleItemCount (int count) {
- checkWidget ();
- if (count < 0) return;
- visibleItemCount = count;
-}
-String stripMnemonic (String string) {
- int index = 0;
- int length = string.length ();
- do {
- while ((index < length) && (string.charAt (index) != '&')) index++;
- if (++index >= length) return string;
- if (string.charAt (index) != '&') {
- return string.substring(0, index-1) + string.substring(index, length);
- }
- index++;
- } while (index < length);
- return string;
-}
-void textEvent (Event event) {
- switch (event.type) {
- case SWT.FocusIn: {
- handleFocus (SWT.FocusIn);
- break;
- }
- case SWT.KeyDown: {
- if (event.character == SWT.CR) {
- dropDown (false);
- Event e = new Event ();
- e.time = event.time;
- e.stateMask = event.stateMask;
- notifyListeners (SWT.DefaultSelection, e);
- }
- //At this point the widget may have been disposed.
- // If so, do not continue.
- if (isDisposed ()) break;
-
- if (event.keyCode == SWT.ARROW_UP || event.keyCode == SWT.ARROW_DOWN) {
- event.doit = false;
- if ((event.stateMask & SWT.ALT) != 0) {
- boolean dropped = isDropped ();
- text.selectAll ();
- if (!dropped) setFocus ();
- dropDown (!dropped);
- break;
- }
-
- int oldIndex = getSelectionIndex ();
- if (event.keyCode == SWT.ARROW_UP) {
- select (Math.max (oldIndex - 1, 0));
- } else {
- select (Math.min (oldIndex + 1, getItemCount () - 1));
- }
- if (oldIndex != getSelectionIndex ()) {
- Event e = new Event();
- e.time = event.time;
- e.stateMask = event.stateMask;
- notifyListeners (SWT.Selection, e);
- }
- //At this point the widget may have been disposed.
- // If so, do not continue.
- if (isDisposed ()) break;
- }
-
- // Further work : Need to add support for incremental search in
- // pop up list as characters typed in text widget
-
- Event e = new Event ();
- e.time = event.time;
- e.character = event.character;
- e.keyCode = event.keyCode;
- e.stateMask = event.stateMask;
- notifyListeners (SWT.KeyDown, e);
- break;
- }
- case SWT.KeyUp: {
- Event e = new Event ();
- e.time = event.time;
- e.character = event.character;
- e.keyCode = event.keyCode;
- e.stateMask = event.stateMask;
- notifyListeners (SWT.KeyUp, e);
- break;
- }
- case SWT.Modify: {
- table.deselectAll ();
- Event e = new Event ();
- e.time = event.time;
- notifyListeners (SWT.Modify, e);
- break;
- }
- case SWT.MouseDown: {
- if (event.button != 1) return;
- if (text.getEditable ()) return;
- boolean dropped = isDropped ();
- text.selectAll ();
- if (!dropped) setFocus ();
- dropDown (!dropped);
- break;
- }
- case SWT.MouseUp: {
- if (event.button != 1) return;
- if (text.getEditable ()) return;
- text.selectAll ();
- break;
- }
- case SWT.Traverse: {
- switch (event.detail) {
- case SWT.TRAVERSE_RETURN:
- case SWT.TRAVERSE_ARROW_PREVIOUS:
- case SWT.TRAVERSE_ARROW_NEXT:
- // The enter causes default selection and
- // the arrow keys are used to manipulate the list contents so
- // do not use them for traversal.
- event.doit = false;
- break;
- }
-
- Event e = new Event ();
- e.time = event.time;
- e.detail = event.detail;
- e.doit = event.doit;
- e.character = event.character;
- e.keyCode = event.keyCode;
- notifyListeners (SWT.Traverse, e);
- event.doit = e.doit;
- event.detail = e.detail;
- break;
- }
- }
-}
-}
+package org.eclipse.cdt.internal.ui; + +import java.util.Arrays; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.SWTException; +import org.eclipse.swt.accessibility.ACC; +import org.eclipse.swt.accessibility.AccessibleAdapter; +import org.eclipse.swt.accessibility.AccessibleControlAdapter; +import org.eclipse.swt.accessibility.AccessibleControlEvent; +import org.eclipse.swt.accessibility.AccessibleEvent; +import org.eclipse.swt.accessibility.AccessibleTextAdapter; +import org.eclipse.swt.accessibility.AccessibleTextEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Layout; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableItem; +import org.eclipse.swt.widgets.Text; +import org.eclipse.swt.widgets.TypedListener; +import org.eclipse.swt.widgets.Widget; + +/** + * The ImageCombo class represents a selectable user interface object + * that combines a text field and a table and issues notification + * when an item is selected from the table. + * <p> + * Note that although this class is a subclass of <code>Composite</code>, + * it does not make sense to add children to it, or set a layout on it. + * </p> + * <dl> + * <dt><b>Styles:</b> + * <dd>BORDER, READ_ONLY, FLAT</dd> + * <dt><b>Events:</b> + * <dd>Selection</dd> + * </dl> + */ +public final class ImageCombo extends Composite { + + Text text; + Table table; + int visibleItemCount = 5; + Shell popup; + Button arrow; + boolean hasFocus; + Listener listener, filter; + Color foreground, background; + Font font; + +/** + * Constructs a new instance of this class given its parent + * and a style value describing its behavior and appearance. + * <p> + * The style value is either one of the style constants defined in + * class <code>SWT</code> which is applicable to instances of this + * class, or must be built by <em>bitwise OR</em>'ing together + * (that is, using the <code>int</code> "|" operator) two or more + * of those <code>SWT</code> style constants. The class description + * lists the style constants that are applicable to the class. + * Style bits are also inherited from superclasses. + * </p> + * + * @param parent a widget which will be the parent of the new instance (cannot be null) + * @param style the style of widget to construct + * + * @exception IllegalArgumentException <ul> + * <li>ERROR_NULL_ARGUMENT - if the parent is null</li> + * </ul> + * @exception SWTException <ul> + * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li> + * </ul> + * + * @see SWT#BORDER + * @see SWT#READ_ONLY + * @see SWT#FLAT + * @see Widget#getStyle() + */ +public ImageCombo (Composite parent, int style) { + super (parent, style = checkStyle (style)); + + int textStyle = SWT.SINGLE; + if ((style & SWT.READ_ONLY) != 0) textStyle |= SWT.READ_ONLY; + if ((style & SWT.FLAT) != 0) textStyle |= SWT.FLAT; + text = new Text (this, SWT.NONE); + int arrowStyle = SWT.ARROW | SWT.DOWN; + if ((style & SWT.FLAT) != 0) arrowStyle |= SWT.FLAT; + arrow = new Button (this, arrowStyle); + + listener = new Listener () { + @Override + public void handleEvent (Event event) { + if (popup == event.widget) { + popupEvent (event); + return; + } + if (text == event.widget) { + textEvent (event); + return; + } + if (table == event.widget) { + listEvent (event); + return; + } + if (arrow == event.widget) { + arrowEvent (event); + return; + } + if (ImageCombo.this == event.widget) { + comboEvent (event); + return; + } + if (getShell () == event.widget) { + handleFocus (SWT.FocusOut); + } + } + }; + filter = new Listener() { + @Override + public void handleEvent(Event event) { + Shell shell = ((Control)event.widget).getShell (); + if (shell == ImageCombo.this.getShell ()) { + handleFocus (SWT.FocusOut); + } + } + }; + + int [] comboEvents = {SWT.Dispose, SWT.Move, SWT.Resize}; + for (int i=0; i<comboEvents.length; i++) this.addListener (comboEvents [i], listener); + + int [] textEvents = {SWT.KeyDown, SWT.KeyUp, SWT.Modify, SWT.MouseDown, SWT.MouseUp, SWT.Traverse, SWT.FocusIn}; + for (int i=0; i<textEvents.length; i++) text.addListener (textEvents [i], listener); + + int [] arrowEvents = {SWT.Selection, SWT.FocusIn}; + for (int i=0; i<arrowEvents.length; i++) arrow.addListener (arrowEvents [i], listener); + + createPopup( -1); + initAccessible(); +} +static int checkStyle (int style) { + int mask = SWT.BORDER | SWT.READ_ONLY | SWT.FLAT | SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT; + return style & mask; +} +/** + * Adds the argument to the end of the receiver's list. + * + * @param string the new item + * + * @exception IllegalArgumentException <ul> + * <li>ERROR_NULL_ARGUMENT - if the string is null</li> + * </ul> + * @exception SWTException <ul> + * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> + * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> + * </ul> + * + * @see #add(String,int) + */ +public void add (String string, Image image) { + checkWidget(); + if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); + TableItem newItem = new TableItem(this.table,SWT.NONE); + newItem.setText(string); + if (image != null) newItem.setImage(image); +} +/** + * Adds the argument to the receiver's list at the given + * zero-relative index. + * <p> + * Note: To add an item at the end of the list, use the + * result of calling <code>getItemCount()</code> as the + * index or use <code>add(String)</code>. + * </p> + * + * @param string the new item + * @param index the index for the item + * + * @exception IllegalArgumentException <ul> + * <li>ERROR_NULL_ARGUMENT - if the string is null</li> + * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list (inclusive)</li> + * </ul> + * @exception SWTException <ul> + * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> + * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> + * </ul> + * + * @see #add(String) + */ +public void add (String string,Image image, int index) { + checkWidget(); + if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); + TableItem newItem = new TableItem(this.table,SWT.NONE,index); + if (image != null) newItem.setImage(image); +} +/** + * Adds the listener to the collection of listeners who will + * be notified when the receiver's text is modified, by sending + * it one of the messages defined in the <code>ModifyListener</code> + * interface. + * + * @param listener the listener which should be notified + * + * @exception IllegalArgumentException <ul> + * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> + * </ul> + * @exception SWTException <ul> + * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> + * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> + * </ul> + * + * @see ModifyListener + * @see #removeModifyListener + */ +public void addModifyListener (ModifyListener listener) { + checkWidget(); + if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); + TypedListener typedListener = new TypedListener (listener); + addListener (SWT.Modify, typedListener); +} +/** + * Adds the listener to the collection of listeners who will + * be notified when the receiver's selection changes, by sending + * it one of the messages defined in the <code>SelectionListener</code> + * interface. + * <p> + * <code>widgetSelected</code> is called when the combo's list selection changes. + * <code>widgetDefaultSelected</code> is typically called when ENTER is pressed the combo's text area. + * </p> + * + * @param listener the listener which should be notified + * + * @exception IllegalArgumentException <ul> + * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> + * </ul> + * @exception SWTException <ul> + * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> + * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> + * </ul> + * + * @see SelectionListener + * @see #removeSelectionListener + * @see SelectionEvent + */ +public void addSelectionListener(SelectionListener listener) { + checkWidget(); + if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); + TypedListener typedListener = new TypedListener (listener); + addListener (SWT.Selection,typedListener); + addListener (SWT.DefaultSelection,typedListener); +} +void arrowEvent (Event event) { + switch (event.type) { + case SWT.FocusIn: { + handleFocus (SWT.FocusIn); + break; + } + case SWT.Selection: { + dropDown (!isDropped ()); + break; + } + } +} +/** + * Sets the selection in the receiver's text field to an empty + * selection starting just before the first character. If the + * text field is editable, this has the effect of placing the + * i-beam at the start of the text. + * <p> + * Note: To clear the selected items in the receiver's list, + * use <code>deselectAll()</code>. + * </p> + * + * @exception SWTException <ul> + * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> + * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> + * </ul> + * + * @see #deselectAll + */ +public void clearSelection () { + checkWidget (); + text.clearSelection (); + table.deselectAll (); +} +void comboEvent (Event event) { + switch (event.type) { + case SWT.Dispose: + if (popup != null && !popup.isDisposed ()) { + table.removeListener (SWT.Dispose, listener); + popup.dispose (); + } + Shell shell = getShell (); + shell.removeListener (SWT.Deactivate, listener); + Display display = getDisplay (); + display.removeFilter (SWT.FocusIn, filter); + popup = null; + text = null; + table = null; + arrow = null; + break; + case SWT.Move: + dropDown (false); + break; + case SWT.Resize: + internalLayout (false); + break; + } +} + +@Override +public Point computeSize (int wHint, int hHint, boolean changed) { + checkWidget (); + int width = 0, height = 0; + String[] items = getStringsFromTable(); + int textWidth = 0; + GC gc = new GC (text); + int spacer = gc.stringExtent (" ").x; //$NON-NLS-1$ + for (int i = 0; i < items.length; i++) { + textWidth = Math.max (gc.stringExtent (items[i]).x, textWidth); + } + gc.dispose(); + Point textSize = text.computeSize (SWT.DEFAULT, SWT.DEFAULT, changed); + Point arrowSize = arrow.computeSize (SWT.DEFAULT, SWT.DEFAULT, changed); + Point listSize = table.computeSize (wHint, SWT.DEFAULT, changed); + int borderWidth = getBorderWidth (); + + height = Math.max (hHint, Math.max (textSize.y, arrowSize.y) + 2*borderWidth); + width = Math.max (wHint, Math.max (textWidth + 2*spacer + arrowSize.x + 2*borderWidth, listSize.x)); + return new Point (width, height); +} +void createPopup(int selectionIndex) { + // create shell and list + popup = new Shell (getShell (), SWT.NO_TRIM | SWT.ON_TOP); + int style = getStyle (); + int listStyle = SWT.SINGLE | SWT.V_SCROLL; + if ((style & SWT.FLAT) != 0) listStyle |= SWT.FLAT; + if ((style & SWT.RIGHT_TO_LEFT) != 0) listStyle |= SWT.RIGHT_TO_LEFT; + if ((style & SWT.LEFT_TO_RIGHT) != 0) listStyle |= SWT.LEFT_TO_RIGHT; + // create a table instead of a list. + table = new Table (popup, listStyle); + if (font != null) table.setFont (font); + if (foreground != null) table.setForeground (foreground); + if (background != null) table.setBackground (background); + + int [] popupEvents = {SWT.Close, SWT.Paint, SWT.Deactivate}; + for (int i=0; i<popupEvents.length; i++) popup.addListener (popupEvents [i], listener); + int [] listEvents = {SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp, SWT.FocusIn, SWT.Dispose}; + for (int i=0; i<listEvents.length; i++) table.addListener (listEvents [i], listener); + + if (selectionIndex != -1) table.setSelection (selectionIndex); +} +/** + * Deselects the item at the given zero-relative index in the receiver's + * list. If the item at the index was already deselected, it remains + * deselected. Indices that are out of range are ignored. + * + * @param index the index of the item to deselect + * + * @exception SWTException <ul> + * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> + * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> + * </ul> + */ +public void deselect (int index) { + checkWidget (); + table.deselect (index); +} +/** + * Deselects all selected items in the receiver's list. + * <p> + * Note: To clear the selection in the receiver's text field, + * use <code>clearSelection()</code>. + * </p> + * + * @exception SWTException <ul> + * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> + * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> + * </ul> + * + * @see #clearSelection + */ +public void deselectAll () { + checkWidget (); + table.deselectAll (); +} +void dropDown (boolean drop) { + if (drop == isDropped ()) return; + if (!drop) { + popup.setVisible (false); + if (!isDisposed ()&& arrow.isFocusControl()) { + text.setFocus(); + } + return; + } + + if (getShell() != popup.getParent ()) { + TableItem[] items = table.getItems (); + int selectionIndex = table.getSelectionIndex (); + table.removeListener (SWT.Dispose, listener); + popup.dispose(); + popup = null; + table = null; + createPopup (selectionIndex); + } + + Point size = getSize (); + int itemCount = table.getItemCount (); + itemCount = (itemCount == 0) ? visibleItemCount : Math.min(visibleItemCount, itemCount); + int itemHeight = table.getItemHeight () * itemCount; + Point listSize = table.computeSize (SWT.DEFAULT, itemHeight, false); + table.setBounds (1, 1, Math.max (size.x - 2, listSize.x), listSize.y); + + int index = table.getSelectionIndex (); + if (index != -1) table.setTopIndex (index); + Display display = getDisplay (); + Rectangle listRect = table.getBounds (); + Rectangle parentRect = display.map (getParent (), null, getBounds ()); + Point comboSize = getSize (); + Rectangle displayRect = getMonitor ().getClientArea (); + int width = Math.max (comboSize.x, listRect.width + 2); + int height = listRect.height + 2; + int x = parentRect.x; + int y = parentRect.y + comboSize.y; + if (y + height > displayRect.y + displayRect.height) y = parentRect.y - height; + popup.setBounds (x, y, width, height); + popup.setVisible (true); + table.setFocus (); +} +/* + * Return the Label immediately preceding the receiver in the z-order, + * or null if none. + */ +Label getAssociatedLabel () { + Control[] siblings = getParent ().getChildren (); + for (int i = 0; i < siblings.length; i++) { + if (siblings [i] == ImageCombo.this) { + if (i > 0 && siblings [i-1] instanceof Label) { + return (Label) siblings [i-1]; + } + } + } + return null; +} +@Override +public Control [] getChildren () { + checkWidget(); + return new Control [0]; +} +/** + * Gets the editable state. + * + * @return whether or not the reciever is editable + * + * @exception SWTException <ul> + * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> + * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> + * </ul> + * + * @since 3.0 + */ +public boolean getEditable () { + checkWidget (); + return text.getEditable(); +} +/** + * Returns the item at the given, zero-relative index in the + * receiver's list. Throws an exception if the index is out + * of range. + * + * @param index the index of the item to return + * @return the item at the given index + * + * @exception IllegalArgumentException <ul> + * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li> + * </ul> + * @exception SWTException <ul> + * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> + * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> + * </ul> + */ +public TableItem getItem (int index) { + checkWidget(); + return this.table.getItem (index); +} +/** + * Returns the number of items contained in the receiver's list. + * + * @return the number of items + * + * @exception SWTException <ul> + * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> + * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> + * </ul> + */ +public int getItemCount () { + checkWidget (); + return table.getItemCount (); +} +/** + * Returns the height of the area which would be used to + * display <em>one</em> of the items in the receiver's list. + * + * @return the height of one item + * + * @exception SWTException <ul> + * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> + * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> + * </ul> + */ +public int getItemHeight () { + checkWidget (); + return table.getItemHeight (); +} +/** + * Returns an array of <code>String</code>s which are the items + * in the receiver's list. + * <p> + * Note: This is not the actual structure used by the receiver + * to maintain its list of items, so modifying the array will + * not affect the receiver. + * </p> + * + * @return the items in the receiver's list + * + * @exception SWTException <ul> + * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> + * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> + * </ul> + */ +public TableItem [] getItems () { + checkWidget (); + return table.getItems (); +} +char getMnemonic (String string) { + int index = 0; + int length = string.length (); + do { + while ((index < length) && (string.charAt (index) != '&')) index++; + if (++index >= length) return '\0'; + if (string.charAt (index) != '&') return string.charAt (index); + index++; + } while (index < length); + return '\0'; +} + +String [] getStringsFromTable() +{ + String[] items = new String[this.table.getItems().length]; + for (int i = 0, n = items.length; i < n; i++) { + items[i]=this.table.getItem(i).getText(); + } + return items; +} +/** + * Returns a <code>Point</code> whose x coordinate is the start + * of the selection in the receiver's text field, and whose y + * coordinate is the end of the selection. The returned values + * are zero-relative. An "empty" selection as indicated by + * the the x and y coordinates having the same value. + * + * @return a point representing the selection start and end + * + * @exception SWTException <ul> + * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> + * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> + * </ul> + */ +public Point getSelection () { + checkWidget (); + return text.getSelection (); +} +/** + * Returns the zero-relative index of the item which is currently + * selected in the receiver's list, or -1 if no item is selected. + * + * @return the index of the selected item + * + * @exception SWTException <ul> + * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> + * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> + * </ul> + */ +public int getSelectionIndex () { + checkWidget (); + return table.getSelectionIndex (); +} +@Override +public int getStyle () { + int style = super.getStyle (); + style &= ~SWT.READ_ONLY; + if (!text.getEditable()) style |= SWT.READ_ONLY; + return style; +} +/** + * Returns a string containing a copy of the contents of the + * receiver's text field. + * + * @return the receiver's text + * + * @exception SWTException <ul> + * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> + * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> + * </ul> + */ +public String getText () { + checkWidget (); + return text.getText (); +} +/** + * Returns the height of the receivers's text field. + * + * @return the text height + * + * @exception SWTException <ul> + * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> + * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> + * </ul> + */ +public int getTextHeight () { + checkWidget (); + return text.getLineHeight (); +} +/** + * Returns the maximum number of characters that the receiver's + * text field is capable of holding. If this has not been changed + * by <code>setTextLimit()</code>, it will be the constant + * <code>Combo.LIMIT</code>. + * + * @return the text limit + * + * @exception SWTException <ul> + * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> + * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> + * </ul> + */ +public int getTextLimit () { + checkWidget (); + return text.getTextLimit (); +} +/** + * Gets the number of items that are visible in the drop + * down portion of the receiver's list. + * + * @return the number of items that are visible + * + * @exception SWTException <ul> + * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> + * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> + * </ul> + * + * @since 3.0 + */ +public int getVisibleItemCount () { + checkWidget (); + return visibleItemCount; +} +void handleFocus (int type) { + if (isDisposed ()) return; + switch (type) { + case SWT.FocusIn: { + if (hasFocus) return; + if (getEditable ()) text.selectAll (); + hasFocus = true; + Shell shell = getShell (); + shell.removeListener (SWT.Deactivate, listener); + shell.addListener (SWT.Deactivate, listener); + Display display = getDisplay (); + display.removeFilter (SWT.FocusIn, filter); + display.addFilter (SWT.FocusIn, filter); + Event e = new Event (); + notifyListeners (SWT.FocusIn, e); + break; + } + case SWT.FocusOut: { + if (!hasFocus) return; + Control focusControl = getDisplay ().getFocusControl (); + if (focusControl == arrow || focusControl == table || focusControl == text) return; + hasFocus = false; + Shell shell = getShell (); + shell.removeListener(SWT.Deactivate, listener); + Display display = getDisplay (); + display.removeFilter (SWT.FocusIn, filter); + Event e = new Event (); + notifyListeners (SWT.FocusOut, e); + break; + } + } +} +/** + * Searches the receiver's list starting at the first item + * (index 0) until an item is found that is equal to the + * argument, and returns the index of that item. If no item + * is found, returns -1. + * + * @param string the search item + * @return the index of the item + * + * @exception IllegalArgumentException <ul> + * <li>ERROR_NULL_ARGUMENT - if the string is null</li> + * </ul> + * @exception SWTException <ul> + * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> + * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> + * </ul> + */ +public int indexOf (String string) { + checkWidget (); + if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); + return Arrays.asList(getStringsFromTable()).indexOf (string); +} + + +void initAccessible() { + AccessibleAdapter accessibleAdapter = new AccessibleAdapter () { + @Override + public void getName (AccessibleEvent e) { + String name = null; + Label label = getAssociatedLabel (); + if (label != null) { + name = stripMnemonic (label.getText()); + } + e.result = name; + } + @Override + public void getKeyboardShortcut(AccessibleEvent e) { + String shortcut = null; + Label label = getAssociatedLabel (); + if (label != null) { + String text = label.getText (); + if (text != null) { + char mnemonic = getMnemonic (text); + if (mnemonic != '\0') { + shortcut = "Alt+"+mnemonic; //$NON-NLS-1$ + } + } + } + e.result = shortcut; + } + @Override + public void getHelp (AccessibleEvent e) { + e.result = getToolTipText (); + } + }; + getAccessible ().addAccessibleListener (accessibleAdapter); + text.getAccessible ().addAccessibleListener (accessibleAdapter); + table.getAccessible ().addAccessibleListener (accessibleAdapter); + + arrow.getAccessible ().addAccessibleListener (new AccessibleAdapter() { + @Override + public void getName (AccessibleEvent e) { + e.result = isDropped () ? SWT.getMessage ("SWT_Close") : SWT.getMessage ("SWT_Open"); //$NON-NLS-1$ //$NON-NLS-2$ + } + @Override + public void getKeyboardShortcut (AccessibleEvent e) { + e.result = "Alt+Down Arrow"; //$NON-NLS-1$ + } + @Override + public void getHelp (AccessibleEvent e) { + e.result = getToolTipText (); + } + }); + + getAccessible().addAccessibleTextListener (new AccessibleTextAdapter() { + @Override + public void getCaretOffset (AccessibleTextEvent e) { + e.offset = text.getCaretPosition (); + } + }); + + getAccessible().addAccessibleControlListener (new AccessibleControlAdapter() { + @Override + public void getChildAtPoint (AccessibleControlEvent e) { + Point testPoint = toControl (e.x, e.y); + if (getBounds ().contains (testPoint)) { + e.childID = ACC.CHILDID_SELF; + } + } + + @Override + public void getLocation (AccessibleControlEvent e) { + Rectangle location = getBounds (); + Point pt = toDisplay (location.x, location.y); + e.x = pt.x; + e.y = pt.y; + e.width = location.width; + e.height = location.height; + } + + @Override + public void getChildCount (AccessibleControlEvent e) { + e.detail = 0; + } + + @Override + public void getRole (AccessibleControlEvent e) { + e.detail = ACC.ROLE_COMBOBOX; + } + + @Override + public void getState (AccessibleControlEvent e) { + e.detail = ACC.STATE_NORMAL; + } + + @Override + public void getValue (AccessibleControlEvent e) { + e.result = getText (); + } + }); + + text.getAccessible ().addAccessibleControlListener (new AccessibleControlAdapter () { + @Override + public void getRole (AccessibleControlEvent e) { + e.detail = text.getEditable () ? ACC.ROLE_TEXT : ACC.ROLE_LABEL; + } + }); + + arrow.getAccessible ().addAccessibleControlListener (new AccessibleControlAdapter() { + @Override + public void getDefaultAction (AccessibleControlEvent e) { + e.result = isDropped () ? SWT.getMessage ("SWT_Close") : SWT.getMessage ("SWT_Open"); //$NON-NLS-1$ //$NON-NLS-2$ + } + }); +} +boolean isDropped () { + return popup.getVisible (); +} +@Override +public boolean isFocusControl () { + checkWidget(); + if (text.isFocusControl () || arrow.isFocusControl () || table.isFocusControl () || popup.isFocusControl ()) { + return true; + } + return super.isFocusControl (); +} +void internalLayout (boolean changed) { + if (isDropped ()) dropDown (false); + Rectangle rect = getClientArea (); + int width = rect.width; + int height = rect.height; + Point arrowSize = arrow.computeSize (SWT.DEFAULT, height, changed); + text.setBounds (0, 0, width - arrowSize.x, height); + arrow.setBounds (width - arrowSize.x, 0, arrowSize.x, arrowSize.y); +} +void listEvent (Event event) { + switch (event.type) { + case SWT.Dispose: + if (getShell () != popup.getParent ()) { + TableItem[] items = table.getItems (); + int selectionIndex = table.getSelectionIndex (); + popup = null; + table = null; + createPopup (selectionIndex); + } + break; + case SWT.FocusIn: { + handleFocus (SWT.FocusIn); + break; + } + case SWT.MouseUp: { + if (event.button != 1) return; + dropDown (false); + break; + } + case SWT.Selection: { + int index = table.getSelectionIndex (); + if (index == -1) return; + text.setText (table.getItem (index).getText()); + text.selectAll (); + table.setSelection (index); + Event e = new Event (); + e.time = event.time; + e.stateMask = event.stateMask; + e.doit = event.doit; + notifyListeners (SWT.Selection, e); + event.doit = e.doit; + break; + } + case SWT.Traverse: { + switch (event.detail) { + case SWT.TRAVERSE_RETURN: + case SWT.TRAVERSE_ESCAPE: + case SWT.TRAVERSE_ARROW_PREVIOUS: + case SWT.TRAVERSE_ARROW_NEXT: + event.doit = false; + break; + } + Event e = new Event (); + e.time = event.time; + e.detail = event.detail; + e.doit = event.doit; + e.character = event.character; + e.keyCode = event.keyCode; + notifyListeners (SWT.Traverse, e); + event.doit = e.doit; + event.detail = e.detail; + break; + } + case SWT.KeyUp: { + Event e = new Event (); + e.time = event.time; + e.character = event.character; + e.keyCode = event.keyCode; + e.stateMask = event.stateMask; + notifyListeners (SWT.KeyUp, e); + break; + } + case SWT.KeyDown: { + if (event.character == SWT.ESC) { + // Escape key cancels popup list + dropDown (false); + } + if ((event.stateMask & SWT.ALT) != 0 && (event.keyCode == SWT.ARROW_UP || event.keyCode == SWT.ARROW_DOWN)) { + dropDown (false); + } + if (event.character == SWT.CR) { + // Enter causes default selection + dropDown (false); + Event e = new Event (); + e.time = event.time; + e.stateMask = event.stateMask; + notifyListeners (SWT.DefaultSelection, e); + } + // At this point the widget may have been disposed. + // If so, do not continue. + if (isDisposed ()) break; + Event e = new Event(); + e.time = event.time; + e.character = event.character; + e.keyCode = event.keyCode; + e.stateMask = event.stateMask; + notifyListeners(SWT.KeyDown, e); + break; + + } + } +} + +void popupEvent(Event event) { + switch (event.type) { + case SWT.Paint: + // draw black rectangle around list + Rectangle listRect = table.getBounds(); + Color black = getDisplay().getSystemColor(SWT.COLOR_BLACK); + event.gc.setForeground(black); + event.gc.drawRectangle(0, 0, listRect.width + 1, listRect.height + 1); + break; + case SWT.Close: + event.doit = false; + dropDown (false); + break; + case SWT.Deactivate: + dropDown (false); + break; + } +} +@Override +public void redraw () { + super.redraw(); + text.redraw(); + arrow.redraw(); + if (popup.isVisible()) table.redraw(); +} +@Override +public void redraw (int x, int y, int width, int height, boolean all) { + super.redraw(x, y, width, height, true); +} + +/** + * Removes the item from the receiver's list at the given + * zero-relative index. + * + * @param index the index for the item + * + * @exception IllegalArgumentException <ul> + * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li> + * </ul> + * @exception SWTException <ul> + * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> + * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> + * </ul> + */ +public void remove (int index) { + checkWidget(); + table.remove (index); +} +/** + * Removes the items from the receiver's list which are + * between the given zero-relative start and end + * indices (inclusive). + * + * @param start the start of the range + * @param end the end of the range + * + * @exception IllegalArgumentException <ul> + * <li>ERROR_INVALID_RANGE - if either the start or end are not between 0 and the number of elements in the list minus 1 (inclusive)</li> + * </ul> + * @exception SWTException <ul> + * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> + * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> + * </ul> + */ +public void remove (int start, int end) { + checkWidget(); + table.remove (start, end); +} +/** + * Searches the receiver's list starting at the first item + * until an item is found that is equal to the argument, + * and removes that item from the list. + * + * @param string the item to remove + * + * @exception IllegalArgumentException <ul> + * <li>ERROR_NULL_ARGUMENT - if the string is null</li> + * <li>ERROR_INVALID_ARGUMENT - if the string is not found in the list</li> + * </ul> + * @exception SWTException <ul> + * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> + * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> + * </ul> + */ +public void remove (String string) { + checkWidget(); + if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); + int index = -1; + for (int i = 0, n = table.getItemCount(); i < n; i++) { + if (table.getItem(i).getText().equals(string)) { + index = i; + break; + } + } + remove(index); +} +/** + * Removes all of the items from the receiver's list and clear the + * contents of receiver's text field. + * <p> + * @exception SWTException <ul> + * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> + * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> + * </ul> + */ +public void removeAll () { + checkWidget(); + text.setText (""); //$NON-NLS-1$ + table.removeAll (); +} +/** + * Removes the listener from the collection of listeners who will + * be notified when the receiver's text is modified. + * + * @param listener the listener which should no longer be notified + * + * @exception IllegalArgumentException <ul> + * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> + * </ul> + * @exception SWTException <ul> + * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> + * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> + * </ul> + * + * @see ModifyListener + * @see #addModifyListener + */ +public void removeModifyListener (ModifyListener listener) { + checkWidget(); + if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); + removeListener(SWT.Modify, listener); +} +/** + * Removes the listener from the collection of listeners who will + * be notified when the receiver's selection changes. + * + * @param listener the listener which should no longer be notified + * + * @exception IllegalArgumentException <ul> + * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> + * </ul> + * @exception SWTException <ul> + * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> + * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> + * </ul> + * + * @see SelectionListener + * @see #addSelectionListener + */ +public void removeSelectionListener (SelectionListener listener) { + checkWidget(); + if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); + removeListener(SWT.Selection, listener); + removeListener(SWT.DefaultSelection,listener); +} +/** + * Selects the item at the given zero-relative index in the receiver's + * list. If the item at the index was already selected, it remains + * selected. Indices that are out of range are ignored. + * + * @param index the index of the item to select + * + * @exception SWTException <ul> + * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> + * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> + * </ul> + */ +public void select (int index) { + checkWidget(); + if (index == -1) { + table.deselectAll (); + text.setText (""); //$NON-NLS-1$ + return; + } + if (0 <= index && index < table.getItemCount()) { + if (index != getSelectionIndex()) { + text.setText (table.getItem (index).getText()); + text.selectAll (); + table.select (index); + table.showSelection (); + } + } +} +@Override +public void setBackground (Color color) { + super.setBackground(color); + background = color; + if (text != null) text.setBackground(color); + if (table != null) table.setBackground(color); + if (arrow != null) arrow.setBackground(color); +} +/** + * Sets the editable state. + * + * @param editable the new editable state + * + * @exception SWTException <ul> + * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> + * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> + * </ul> + * + * @since 3.0 + */ +public void setEditable (boolean editable) { + checkWidget (); + text.setEditable(editable); +} +@Override +public void setEnabled (boolean enabled) { + super.setEnabled(enabled); + if (popup != null) popup.setVisible (false); + if (text != null) text.setEnabled(enabled); + if (arrow != null) arrow.setEnabled(enabled); +} +@Override +public boolean setFocus () { + checkWidget(); + return text.setFocus (); +} +@Override +public void setFont (Font font) { + super.setFont (font); + this.font = font; + text.setFont (font); + table.setFont (font); + internalLayout (true); +} +@Override +public void setForeground (Color color) { + super.setForeground(color); + foreground = color; + if (text != null) text.setForeground(color); + if (table != null) table.setForeground(color); + if (arrow != null) arrow.setForeground(color); +} +/** + * Sets the text of the item in the receiver's list at the given + * zero-relative index to the string argument. This is equivalent + * to <code>remove</code>'ing the old item at the index, and then + * <code>add</code>'ing the new item at that index. + * + * @param index the index for the item + * @param string the new text for the item + * + * @exception IllegalArgumentException <ul> + * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li> + * <li>ERROR_NULL_ARGUMENT - if the string is null</li> + * </ul> + * @exception SWTException <ul> + * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> + * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> + * </ul> + */ +public void setItem (int index, String string, Image image) { + checkWidget(); + remove(index); + add(string,image,index); +} +/** + * Sets the receiver's list to be the given array of items. + * + * @param items the array of items + * + * @exception IllegalArgumentException <ul> + * <li>ERROR_NULL_ARGUMENT - if the items array is null</li> + * <li>ERROR_INVALID_ARGUMENT - if an item in the items array is null</li> + * </ul> + * @exception SWTException <ul> + * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> + * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> + * </ul> + */ +public void setItems (String [] items) { + checkWidget (); + this.table.removeAll(); + for (int i = 0, n = items.length; i < n; i++) { + add(items[i],null); + } + if (!text.getEditable ()) text.setText (""); //$NON-NLS-1$ +} + +/** + * Sets the layout which is associated with the receiver to be + * the argument which may be null. + * <p> + * Note : No Layout can be set on this Control because it already + * manages the size and position of its children. + * </p> + * + * @param layout the receiver's new layout or null + * + * @exception SWTException <ul> + * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> + * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> + * </ul> + */ +@Override +public void setLayout (Layout layout) { + checkWidget (); + return; +} +/** + * Sets the selection in the receiver's text field to the + * range specified by the argument whose x coordinate is the + * start of the selection and whose y coordinate is the end + * of the selection. + * + * @param selection a point representing the new selection start and end + * + * @exception IllegalArgumentException <ul> + * <li>ERROR_NULL_ARGUMENT - if the point is null</li> + * </ul> + * @exception SWTException <ul> + * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> + * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> + * </ul> + */ +public void setSelection (Point selection) { + checkWidget(); + if (selection == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); + text.setSelection (selection.x, selection.y); +} + +/** + * Sets the contents of the receiver's text field to the + * given string. + * <p> + * Note: The text field in a <code>Combo</code> is typically + * only capable of displaying a single line of text. Thus, + * setting the text to a string containing line breaks or + * other special characters will probably cause it to + * display incorrectly. + * </p> + * + * @param string the new text + * + * @exception IllegalArgumentException <ul> + * <li>ERROR_NULL_ARGUMENT - if the string is null</li> + * </ul> + * @exception SWTException <ul> + * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> + * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> + * </ul> + */ +public void setText (String string) { + checkWidget(); + if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); + int index = -1; + for (int i = 0, n = table.getItemCount(); i < n; i++) { + if (table.getItem(i).getText().equals(string)) { + index = i; + break; + } + } + if (index == -1) { + table.deselectAll (); + text.setText (string); + return; + } + text.setText (string); + text.selectAll (); + table.setSelection (index); + table.showSelection (); +} +/** + * Sets the maximum number of characters that the receiver's + * text field is capable of holding to be the argument. + * + * @param limit new text limit + * + * @exception IllegalArgumentException <ul> + * <li>ERROR_CANNOT_BE_ZERO - if the limit is zero</li> + * </ul> + * @exception SWTException <ul> + * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> + * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> + * </ul> + */ +public void setTextLimit (int limit) { + checkWidget(); + text.setTextLimit (limit); +} + +@Override +public void setToolTipText (String string) { + checkWidget(); + super.setToolTipText(string); + arrow.setToolTipText (string); + text.setToolTipText (string); +} + +@Override +public void setVisible (boolean visible) { + super.setVisible(visible); + if (!visible) popup.setVisible(false); +} +/** + * Sets the number of items that are visible in the drop + * down portion of the receiver's list. + * + * @param count the new number of items to be visible + * + * @exception SWTException <ul> + * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> + * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> + * </ul> + * + * @since 3.0 + */ +public void setVisibleItemCount (int count) { + checkWidget (); + if (count < 0) return; + visibleItemCount = count; +} +String stripMnemonic (String string) { + int index = 0; + int length = string.length (); + do { + while ((index < length) && (string.charAt (index) != '&')) index++; + if (++index >= length) return string; + if (string.charAt (index) != '&') { + return string.substring(0, index-1) + string.substring(index, length); + } + index++; + } while (index < length); + return string; +} +void textEvent (Event event) { + switch (event.type) { + case SWT.FocusIn: { + handleFocus (SWT.FocusIn); + break; + } + case SWT.KeyDown: { + if (event.character == SWT.CR) { + dropDown (false); + Event e = new Event (); + e.time = event.time; + e.stateMask = event.stateMask; + notifyListeners (SWT.DefaultSelection, e); + } + //At this point the widget may have been disposed. + // If so, do not continue. + if (isDisposed ()) break; + + if (event.keyCode == SWT.ARROW_UP || event.keyCode == SWT.ARROW_DOWN) { + event.doit = false; + if ((event.stateMask & SWT.ALT) != 0) { + boolean dropped = isDropped (); + text.selectAll (); + if (!dropped) setFocus (); + dropDown (!dropped); + break; + } + + int oldIndex = getSelectionIndex (); + if (event.keyCode == SWT.ARROW_UP) { + select (Math.max (oldIndex - 1, 0)); + } else { + select (Math.min (oldIndex + 1, getItemCount () - 1)); + } + if (oldIndex != getSelectionIndex ()) { + Event e = new Event(); + e.time = event.time; + e.stateMask = event.stateMask; + notifyListeners (SWT.Selection, e); + } + //At this point the widget may have been disposed. + // If so, do not continue. + if (isDisposed ()) break; + } + + // Further work : Need to add support for incremental search in + // pop up list as characters typed in text widget + + Event e = new Event (); + e.time = event.time; + e.character = event.character; + e.keyCode = event.keyCode; + e.stateMask = event.stateMask; + notifyListeners (SWT.KeyDown, e); + break; + } + case SWT.KeyUp: { + Event e = new Event (); + e.time = event.time; + e.character = event.character; + e.keyCode = event.keyCode; + e.stateMask = event.stateMask; + notifyListeners (SWT.KeyUp, e); + break; + } + case SWT.Modify: { + table.deselectAll (); + Event e = new Event (); + e.time = event.time; + notifyListeners (SWT.Modify, e); + break; + } + case SWT.MouseDown: { + if (event.button != 1) return; + if (text.getEditable ()) return; + boolean dropped = isDropped (); + text.selectAll (); + if (!dropped) setFocus (); + dropDown (!dropped); + break; + } + case SWT.MouseUp: { + if (event.button != 1) return; + if (text.getEditable ()) return; + text.selectAll (); + break; + } + case SWT.Traverse: { + switch (event.detail) { + case SWT.TRAVERSE_RETURN: + case SWT.TRAVERSE_ARROW_PREVIOUS: + case SWT.TRAVERSE_ARROW_NEXT: + // The enter causes default selection and + // the arrow keys are used to manipulate the list contents so + // do not use them for traversal. + event.doit = false; + break; + } + + Event e = new Event (); + e.time = event.time; + e.detail = event.detail; + e.doit = event.doit; + e.character = event.character; + e.keyCode = event.keyCode; + notifyListeners (SWT.Traverse, e); + event.doit = e.doit; + event.detail = e.detail; + break; + } + } +} +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHEProviderSettings.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHEProviderSettings.java index b36fda158dd..c2d2fbf0bd1 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHEProviderSettings.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHEProviderSettings.java @@ -1,97 +1,97 @@ -/*******************************************************************************
- * Copyright (c) 2018 Wind River Systems, Inc. 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:
- * Lidia Popescu - [536255] initial API and implementation. Extension point for open call hierarchy view
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.callhierarchy;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
-import org.eclipse.jface.viewers.IOpenListener;
-
-import org.eclipse.cdt.ui.ICHEContentProvider;
-
-/**
- * The Call Hierarchy Extension provider Settings
- * Responsible to load all available extensions for EXTENSION_POINT_ID
- * */
-public class CHEProviderSettings {
-
- private static final String EXTENSION_POINT_ID = "org.eclipse.cdt.ui.CCallHierarchy"; //$NON-NLS-1$
- private static final String ELEMENT_NAME_CONTENT = "CallHierarchyContentProvider"; //$NON-NLS-1$
- private static final String ELEMENT_NAME_LABEL = "CallHierarchyLabelProvider"; //$NON-NLS-1$
- private static final String ATTRIB_CLASS = "class"; //$NON-NLS-1$
-
- IOpenListener[] openListeners =null;
-
- static ICHEContentProvider[] chContentProviders = null;
- static IStyledLabelProvider[] chLabelProviders = null;
-
- private static void loadExtensions() {
- List<ICHEContentProvider> chCProviders = new ArrayList<ICHEContentProvider>();
- List<IStyledLabelProvider> chLProviders = new ArrayList<IStyledLabelProvider>();
-
- IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(EXTENSION_POINT_ID);
- if (extensionPoint != null) {
- IExtension[] extensions = extensionPoint.getExtensions();
- if (extensions != null) {
- for (IExtension ex : extensions) {
- for (IConfigurationElement el : ex.getConfigurationElements()) {
- if (el.getName().equals(ELEMENT_NAME_CONTENT)) {
- ICHEContentProvider provider = null;
- try {
- provider = (ICHEContentProvider) el.createExecutableExtension(ATTRIB_CLASS);
- } catch (CoreException e) {
- e.printStackTrace();
- }
- if (provider != null) {
- chCProviders.add(provider);
- }
- }
- if (el.getName().equals(ELEMENT_NAME_LABEL)) {
- IStyledLabelProvider provider = null;
- try {
- provider = (IStyledLabelProvider) el.createExecutableExtension(ATTRIB_CLASS);
- } catch (CoreException e) {
- e.printStackTrace();
- }
- if (provider != null) {
- chLProviders.add(provider);
- }
- }
- }
- }
- }
- }
- chLabelProviders = chLProviders.toArray(new IStyledLabelProvider[chLProviders.size()]);
- chContentProviders = chCProviders.toArray(new ICHEContentProvider[chCProviders.size()]);
- }
-
-
-
- public static IStyledLabelProvider[] getCCallHierarchyLabelProviders() {
- if ( chLabelProviders == null) {
- loadExtensions();
- }
- return chLabelProviders;
- }
-
- public static ICHEContentProvider[] getCCallHierarchyContentProviders() {
- if ( chContentProviders == null) {
- loadExtensions();
- }
- return chContentProviders;
- }
-}
+/******************************************************************************* + * Copyright (c) 2018 Wind River Systems, Inc. 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: + * Lidia Popescu - [536255] initial API and implementation. Extension point for open call hierarchy view + *******************************************************************************/ +package org.eclipse.cdt.internal.ui.callhierarchy; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtension; +import org.eclipse.core.runtime.IExtensionPoint; +import org.eclipse.core.runtime.Platform; +import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider; +import org.eclipse.jface.viewers.IOpenListener; + +import org.eclipse.cdt.ui.ICHEContentProvider; + +/** + * The Call Hierarchy Extension provider Settings + * Responsible to load all available extensions for EXTENSION_POINT_ID + * */ +public class CHEProviderSettings { + + private static final String EXTENSION_POINT_ID = "org.eclipse.cdt.ui.CCallHierarchy"; //$NON-NLS-1$ + private static final String ELEMENT_NAME_CONTENT = "CallHierarchyContentProvider"; //$NON-NLS-1$ + private static final String ELEMENT_NAME_LABEL = "CallHierarchyLabelProvider"; //$NON-NLS-1$ + private static final String ATTRIB_CLASS = "class"; //$NON-NLS-1$ + + IOpenListener[] openListeners =null; + + static ICHEContentProvider[] chContentProviders = null; + static IStyledLabelProvider[] chLabelProviders = null; + + private static void loadExtensions() { + List<ICHEContentProvider> chCProviders = new ArrayList<ICHEContentProvider>(); + List<IStyledLabelProvider> chLProviders = new ArrayList<IStyledLabelProvider>(); + + IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(EXTENSION_POINT_ID); + if (extensionPoint != null) { + IExtension[] extensions = extensionPoint.getExtensions(); + if (extensions != null) { + for (IExtension ex : extensions) { + for (IConfigurationElement el : ex.getConfigurationElements()) { + if (el.getName().equals(ELEMENT_NAME_CONTENT)) { + ICHEContentProvider provider = null; + try { + provider = (ICHEContentProvider) el.createExecutableExtension(ATTRIB_CLASS); + } catch (CoreException e) { + e.printStackTrace(); + } + if (provider != null) { + chCProviders.add(provider); + } + } + if (el.getName().equals(ELEMENT_NAME_LABEL)) { + IStyledLabelProvider provider = null; + try { + provider = (IStyledLabelProvider) el.createExecutableExtension(ATTRIB_CLASS); + } catch (CoreException e) { + e.printStackTrace(); + } + if (provider != null) { + chLProviders.add(provider); + } + } + } + } + } + } + chLabelProviders = chLProviders.toArray(new IStyledLabelProvider[chLProviders.size()]); + chContentProviders = chCProviders.toArray(new ICHEContentProvider[chCProviders.size()]); + } + + + + public static IStyledLabelProvider[] getCCallHierarchyLabelProviders() { + if ( chLabelProviders == null) { + loadExtensions(); + } + return chLabelProviders; + } + + public static ICHEContentProvider[] getCCallHierarchyContentProviders() { + if ( chContentProviders == null) { + loadExtensions(); + } + return chContentProviders; + } +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHPinAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHPinAction.java index 4eaf05c409e..b0c4d051152 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHPinAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHPinAction.java @@ -1,38 +1,38 @@ -/*******************************************************************************
- * Copyright (c) 2011, 2013 IBM Corporation 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:
- * IBM Corporation - initial API and implementation
- * Marc-Andre Laperle - Adapted to CDT from JDT
+/******************************************************************************* + * Copyright (c) 2011, 2013 IBM Corporation 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: + * IBM Corporation - initial API and implementation + * Marc-Andre Laperle - Adapted to CDT from JDT *******************************************************************************/ -package org.eclipse.cdt.internal.ui.callhierarchy;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-
-import org.eclipse.cdt.internal.ui.CPluginImages;
-
-public class CHPinAction extends Action {
- private CHViewPart fView;
-
- /**
- * Constructs a 'Pin Call Hierarchy view' action.
- *
- * @param view the Call Hierarchy view
- */
- public CHPinAction(CHViewPart view) {
- super(CHMessages.CHPinAction_label, IAction.AS_CHECK_BOX);
- setToolTipText(CHMessages.CHPinAction_tooltip);
- CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, "pin_view.gif"); //$NON-NLS-1$
- fView= view;
- }
-
- @Override
- public void run() {
- fView.setPinned(isChecked());
- }
-}
+package org.eclipse.cdt.internal.ui.callhierarchy; + +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.IAction; + +import org.eclipse.cdt.internal.ui.CPluginImages; + +public class CHPinAction extends Action { + private CHViewPart fView; + + /** + * Constructs a 'Pin Call Hierarchy view' action. + * + * @param view the Call Hierarchy view + */ + public CHPinAction(CHViewPart view) { + super(CHMessages.CHPinAction_label, IAction.AS_CHECK_BOX); + setToolTipText(CHMessages.CHPinAction_tooltip); + CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, "pin_view.gif"); //$NON-NLS-1$ + fView= view; + } + + @Override + public void run() { + fView.setPinned(isChecked()); + } +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/AddIncludeAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/AddIncludeAction.java index 447d24e3548..c5730c9ec09 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/AddIncludeAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/AddIncludeAction.java @@ -1,190 +1,190 @@ -/*******************************************************************************
- * Copyright (c) 2013, 2014 Google, Inc 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:
- * Sergey Prigogin (Google) - initial API and implementation
+/******************************************************************************* + * Copyright (c) 2013, 2014 Google, Inc 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: + * Sergey Prigogin (Google) - initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.internal.ui.editor;
-
-import java.util.Collection;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.window.Window;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.text.edits.MalformedTreeException;
-import org.eclipse.text.edits.MultiTextEdit;
-import org.eclipse.text.undo.DocumentUndoManagerRegistry;
-import org.eclipse.text.undo.IDocumentUndoManager;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.dialogs.ElementListSelectionDialog;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.texteditor.TextEditorAction;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
-import org.eclipse.cdt.core.index.IIndex;
-import org.eclipse.cdt.core.index.IIndexManager;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.ui.CUIPlugin;
-
-import org.eclipse.cdt.internal.core.model.ASTCache;
-
-import org.eclipse.cdt.internal.ui.BusyCursorJobRunner;
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-import org.eclipse.cdt.internal.ui.refactoring.includes.IElementSelector;
-import org.eclipse.cdt.internal.ui.refactoring.includes.IncludeCreator;
-
-/**
- * Adds an '#include' statement and, optionally, a 'using' declaration necessary to resolve a name.
- */
-public class AddIncludeAction extends TextEditorAction {
- private IElementSelector fAmbiguityResolver;
-
- /**
- * Constructor
- * @param editor The editor on which this Add Include action should operate.
- */
- public AddIncludeAction(ITextEditor editor) {
- super(CEditorMessages.getBundleForConstructedKeys(), "AddInclude.", editor); //$NON-NLS-1$
- CUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.ADD_INCLUDE_ON_SELECTION_ACTION);
- final Shell shell = editor.getEditorSite().getShell();
- fAmbiguityResolver = new IElementSelector() {
- @SuppressWarnings("unchecked")
- @Override
- public <T> T selectElement(final Collection<T> elements) {
- final Object[] result = new Object[1];
- runInUIThread(new Runnable() {
- @Override
- public void run() {
- ElementListSelectionDialog dialog=
- new ElementListSelectionDialog(shell, new LabelProvider());
- dialog.setElements(elements.toArray());
- dialog.setTitle(CEditorMessages.AddInclude_label);
- dialog.setMessage(CEditorMessages.AddInclude_description);
- if (dialog.open() == Window.OK)
- result[0] = dialog.getFirstResult();
- }
- });
- return (T) result[0];
- }
- };
- }
-
- @Override
- public void run() {
- final ITextEditor editor = getTextEditor();
- final ITranslationUnit tu = getTranslationUnit(editor);
- if (tu == null) {
- return;
- }
- final ISelection selection= getTextEditor().getSelectionProvider().getSelection();
- if (selection.isEmpty() || !(selection instanceof ITextSelection)) {
- return;
- }
- if (!validateEditorInputState()) {
- return;
- }
-
- final MultiTextEdit[] holder = new MultiTextEdit[1];
- // We can't use SharedASTJob because IncludeCreator needs to disable promiscuous
- // binding resolution, and you can't mix promiscuous and non-promiscuous binding
- // resolution in the same AST.
- Job job = new Job(CEditorMessages.AddInclude_action) {
- @Override
- public IStatus run(IProgressMonitor monitor) {
- try {
- IIndex index= CCorePlugin.getIndexManager().getIndex(tu.getCProject(),
- IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_EXTENSION_FRAGMENTS_ADD_IMPORT);
- try {
- index.acquireReadLock();
- IASTTranslationUnit ast = tu.getAST(index, ASTCache.PARSE_MODE);
- if (ast == null) {
- return CUIPlugin.createErrorStatus(
- NLS.bind(CEditorMessages.AddInclude_ast_not_available, tu.getPath().toOSString()));
- }
- IncludeCreator creator = new IncludeCreator(tu, index, fAmbiguityResolver);
- holder[0] = creator.createInclude(ast, (ITextSelection) selection);
- return Status.OK_STATUS;
- } catch (InterruptedException e) {
- return Status.CANCEL_STATUS;
- } finally {
- index.releaseReadLock();
- }
- } catch (CoreException e) {
- return e.getStatus();
- }
- }
- };
- IStatus status = BusyCursorJobRunner.execute(job);
- if (status.isOK()) {
- MultiTextEdit edit = holder[0];
- if (edit.hasChildren()) {
- // Apply text edits.
- IEditorInput editorInput = editor.getEditorInput();
- IDocument document = editor.getDocumentProvider().getDocument(editorInput);
- IDocumentUndoManager manager= DocumentUndoManagerRegistry.getDocumentUndoManager(document);
- manager.beginCompoundChange();
- try {
- edit.apply(document);
- } catch (MalformedTreeException | BadLocationException e) {
- CUIPlugin.log(e);
- }
- manager.endCompoundChange();
- }
- } else if (status.matches(IStatus.ERROR)) {
- ErrorDialog.openError(editor.getEditorSite().getShell(),
- CEditorMessages.AddInclude_error_title,
- CEditorMessages.AddInclude_insertion_failed, status);
- }
- }
-
- private static void runInUIThread(Runnable runnable) {
- if (Display.getCurrent() != null) {
- runnable.run();
- } else {
- Display.getDefault().syncExec(runnable);
- }
- }
-
- @Override
- public void update() {
- ITextEditor editor = getTextEditor();
- setEnabled(editor != null && getTranslationUnit(editor) != null);
- }
-
- /**
- * Returns the translation unit of the given editor.
- *
- * @param editor The editor.
- * @return The translation unit.
- */
- private static ITranslationUnit getTranslationUnit(ITextEditor editor) {
- if (editor == null) {
- return null;
- }
- return CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editor.getEditorInput());
- }
-
- /**
- * For tests only.
- */
- public void setAmbiguityResolver(IElementSelector fAmbiguityResolver) {
- this.fAmbiguityResolver = fAmbiguityResolver;
- }
-}
+package org.eclipse.cdt.internal.ui.editor; + +import java.util.Collection; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.jface.dialogs.ErrorDialog; +import org.eclipse.jface.text.BadLocationException; +import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.ITextSelection; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.jface.window.Window; +import org.eclipse.osgi.util.NLS; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.text.edits.MalformedTreeException; +import org.eclipse.text.edits.MultiTextEdit; +import org.eclipse.text.undo.DocumentUndoManagerRegistry; +import org.eclipse.text.undo.IDocumentUndoManager; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.dialogs.ElementListSelectionDialog; +import org.eclipse.ui.texteditor.ITextEditor; +import org.eclipse.ui.texteditor.TextEditorAction; + +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; +import org.eclipse.cdt.core.index.IIndex; +import org.eclipse.cdt.core.index.IIndexManager; +import org.eclipse.cdt.core.model.ITranslationUnit; +import org.eclipse.cdt.ui.CUIPlugin; + +import org.eclipse.cdt.internal.core.model.ASTCache; + +import org.eclipse.cdt.internal.ui.BusyCursorJobRunner; +import org.eclipse.cdt.internal.ui.ICHelpContextIds; +import org.eclipse.cdt.internal.ui.refactoring.includes.IElementSelector; +import org.eclipse.cdt.internal.ui.refactoring.includes.IncludeCreator; + +/** + * Adds an '#include' statement and, optionally, a 'using' declaration necessary to resolve a name. + */ +public class AddIncludeAction extends TextEditorAction { + private IElementSelector fAmbiguityResolver; + + /** + * Constructor + * @param editor The editor on which this Add Include action should operate. + */ + public AddIncludeAction(ITextEditor editor) { + super(CEditorMessages.getBundleForConstructedKeys(), "AddInclude.", editor); //$NON-NLS-1$ + CUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.ADD_INCLUDE_ON_SELECTION_ACTION); + final Shell shell = editor.getEditorSite().getShell(); + fAmbiguityResolver = new IElementSelector() { + @SuppressWarnings("unchecked") + @Override + public <T> T selectElement(final Collection<T> elements) { + final Object[] result = new Object[1]; + runInUIThread(new Runnable() { + @Override + public void run() { + ElementListSelectionDialog dialog= + new ElementListSelectionDialog(shell, new LabelProvider()); + dialog.setElements(elements.toArray()); + dialog.setTitle(CEditorMessages.AddInclude_label); + dialog.setMessage(CEditorMessages.AddInclude_description); + if (dialog.open() == Window.OK) + result[0] = dialog.getFirstResult(); + } + }); + return (T) result[0]; + } + }; + } + + @Override + public void run() { + final ITextEditor editor = getTextEditor(); + final ITranslationUnit tu = getTranslationUnit(editor); + if (tu == null) { + return; + } + final ISelection selection= getTextEditor().getSelectionProvider().getSelection(); + if (selection.isEmpty() || !(selection instanceof ITextSelection)) { + return; + } + if (!validateEditorInputState()) { + return; + } + + final MultiTextEdit[] holder = new MultiTextEdit[1]; + // We can't use SharedASTJob because IncludeCreator needs to disable promiscuous + // binding resolution, and you can't mix promiscuous and non-promiscuous binding + // resolution in the same AST. + Job job = new Job(CEditorMessages.AddInclude_action) { + @Override + public IStatus run(IProgressMonitor monitor) { + try { + IIndex index= CCorePlugin.getIndexManager().getIndex(tu.getCProject(), + IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_EXTENSION_FRAGMENTS_ADD_IMPORT); + try { + index.acquireReadLock(); + IASTTranslationUnit ast = tu.getAST(index, ASTCache.PARSE_MODE); + if (ast == null) { + return CUIPlugin.createErrorStatus( + NLS.bind(CEditorMessages.AddInclude_ast_not_available, tu.getPath().toOSString())); + } + IncludeCreator creator = new IncludeCreator(tu, index, fAmbiguityResolver); + holder[0] = creator.createInclude(ast, (ITextSelection) selection); + return Status.OK_STATUS; + } catch (InterruptedException e) { + return Status.CANCEL_STATUS; + } finally { + index.releaseReadLock(); + } + } catch (CoreException e) { + return e.getStatus(); + } + } + }; + IStatus status = BusyCursorJobRunner.execute(job); + if (status.isOK()) { + MultiTextEdit edit = holder[0]; + if (edit.hasChildren()) { + // Apply text edits. + IEditorInput editorInput = editor.getEditorInput(); + IDocument document = editor.getDocumentProvider().getDocument(editorInput); + IDocumentUndoManager manager= DocumentUndoManagerRegistry.getDocumentUndoManager(document); + manager.beginCompoundChange(); + try { + edit.apply(document); + } catch (MalformedTreeException | BadLocationException e) { + CUIPlugin.log(e); + } + manager.endCompoundChange(); + } + } else if (status.matches(IStatus.ERROR)) { + ErrorDialog.openError(editor.getEditorSite().getShell(), + CEditorMessages.AddInclude_error_title, + CEditorMessages.AddInclude_insertion_failed, status); + } + } + + private static void runInUIThread(Runnable runnable) { + if (Display.getCurrent() != null) { + runnable.run(); + } else { + Display.getDefault().syncExec(runnable); + } + } + + @Override + public void update() { + ITextEditor editor = getTextEditor(); + setEnabled(editor != null && getTranslationUnit(editor) != null); + } + + /** + * Returns the translation unit of the given editor. + * + * @param editor The editor. + * @return The translation unit. + */ + private static ITranslationUnit getTranslationUnit(ITextEditor editor) { + if (editor == null) { + return null; + } + return CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editor.getEditorInput()); + } + + /** + * For tests only. + */ + public void setAmbiguityResolver(IElementSelector fAmbiguityResolver) { + this.fAmbiguityResolver = fAmbiguityResolver; + } +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OrganizeIncludesAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OrganizeIncludesAction.java index 7fb44bbae9f..cb4055e7ab3 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OrganizeIncludesAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OrganizeIncludesAction.java @@ -1,143 +1,143 @@ -/*******************************************************************************
- * Copyright (c) 2012, 2014 Mathias Kunter 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:
- * Mathias Kunter - initial API and implementation
- * Sergey Prigogin (Google)
+/******************************************************************************* + * Copyright (c) 2012, 2014 Mathias Kunter 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: + * Mathias Kunter - initial API and implementation + * Sergey Prigogin (Google) *******************************************************************************/ -package org.eclipse.cdt.internal.ui.editor;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.text.edits.MalformedTreeException;
-import org.eclipse.text.edits.MultiTextEdit;
-import org.eclipse.text.undo.DocumentUndoManagerRegistry;
-import org.eclipse.text.undo.IDocumentUndoManager;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.texteditor.TextEditorAction;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
-import org.eclipse.cdt.core.index.IIndex;
-import org.eclipse.cdt.core.index.IIndexManager;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.ui.CUIPlugin;
-
-import org.eclipse.cdt.internal.core.model.ASTCache;
-
-import org.eclipse.cdt.internal.ui.BusyCursorJobRunner;
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-import org.eclipse.cdt.internal.ui.refactoring.includes.IHeaderChooser;
-import org.eclipse.cdt.internal.ui.refactoring.includes.IncludeOrganizer;
-
-/**
- * Organizes the include directives and forward declarations of a source or header file.
- */
-public class OrganizeIncludesAction extends TextEditorAction {
- /**
- * Constructor
- * @param editor The editor on which this Organize Includes action should operate.
- */
- public OrganizeIncludesAction(ITextEditor editor) {
- super(CEditorMessages.getBundleForConstructedKeys(), "OrganizeIncludes.", editor); //$NON-NLS-1$
- CUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.ORGANIZE_INCLUDES_ACTION);
- }
-
- @Override
- public void run() {
- final ITextEditor editor = getTextEditor();
- final ITranslationUnit tu = getTranslationUnit(editor);
- if (tu == null) {
- return;
- }
- if (!validateEditorInputState()) {
- return;
- }
-
- final IHeaderChooser headerChooser = new InteractiveHeaderChooser(
- CEditorMessages.OrganizeIncludes_label, editor.getSite().getShell());
- final MultiTextEdit[] holder = new MultiTextEdit[1];
- // We can't use SharedASTJob because IncludeOrganizer needs to disable promiscuous
- // binding resolution, and you can't mix promiscuous and non-promiscuous binding
- // resolution in the same AST.
- Job job = new Job(CEditorMessages.OrganizeIncludes_action) {
- @Override
- public IStatus run(IProgressMonitor monitor) {
- try {
- IIndex index= CCorePlugin.getIndexManager().getIndex(tu.getCProject(),
- IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_EXTENSION_FRAGMENTS_ADD_IMPORT);
- try {
- index.acquireReadLock();
- IASTTranslationUnit ast = tu.getAST(index, ASTCache.PARSE_MODE);
- if (ast == null) {
- return CUIPlugin.createErrorStatus(
- NLS.bind(CEditorMessages.OrganizeIncludes_ast_not_available, tu.getPath().toOSString()));
- }
- IncludeOrganizer organizer = new IncludeOrganizer(tu, index, headerChooser);
- holder[0] = organizer.organizeIncludes(ast);
- return Status.OK_STATUS;
- } catch (InterruptedException e) {
- return Status.CANCEL_STATUS;
- } finally {
- index.releaseReadLock();
- }
- } catch (CoreException e) {
- return e.getStatus();
- }
- }
- };
- IStatus status = BusyCursorJobRunner.execute(job);
- if (status.isOK()) {
- MultiTextEdit edit = holder[0];
- if (edit.hasChildren()) {
- // Apply the text edit.
- IEditorInput editorInput = editor.getEditorInput();
- IDocument document = editor.getDocumentProvider().getDocument(editorInput);
- IDocumentUndoManager manager= DocumentUndoManagerRegistry.getDocumentUndoManager(document);
- manager.beginCompoundChange();
- try {
- edit.apply(document);
- } catch (MalformedTreeException e) {
- CUIPlugin.log(e);
- } catch (BadLocationException e) {
- CUIPlugin.log(e);
- }
- manager.endCompoundChange();
- }
- } else if (status.matches(IStatus.ERROR)) {
- ErrorDialog.openError(editor.getEditorSite().getShell(),
- CEditorMessages.OrganizeIncludes_error_title,
- CEditorMessages.OrganizeIncludes_insertion_failed, status);
- }
- }
-
- @Override
- public void update() {
- ITextEditor editor = getTextEditor();
- setEnabled(editor != null && getTranslationUnit(editor) != null);
- }
-
- /**
- * Returns the translation unit of the given editor.
- * @param editor The editor.
- * @return The translation unit.
- */
- private static ITranslationUnit getTranslationUnit(ITextEditor editor) {
- if (editor == null) {
- return null;
- }
- return CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editor.getEditorInput());
- }
-}
+package org.eclipse.cdt.internal.ui.editor; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.jface.dialogs.ErrorDialog; +import org.eclipse.jface.text.BadLocationException; +import org.eclipse.jface.text.IDocument; +import org.eclipse.osgi.util.NLS; +import org.eclipse.text.edits.MalformedTreeException; +import org.eclipse.text.edits.MultiTextEdit; +import org.eclipse.text.undo.DocumentUndoManagerRegistry; +import org.eclipse.text.undo.IDocumentUndoManager; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.texteditor.ITextEditor; +import org.eclipse.ui.texteditor.TextEditorAction; + +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; +import org.eclipse.cdt.core.index.IIndex; +import org.eclipse.cdt.core.index.IIndexManager; +import org.eclipse.cdt.core.model.ITranslationUnit; +import org.eclipse.cdt.ui.CUIPlugin; + +import org.eclipse.cdt.internal.core.model.ASTCache; + +import org.eclipse.cdt.internal.ui.BusyCursorJobRunner; +import org.eclipse.cdt.internal.ui.ICHelpContextIds; +import org.eclipse.cdt.internal.ui.refactoring.includes.IHeaderChooser; +import org.eclipse.cdt.internal.ui.refactoring.includes.IncludeOrganizer; + +/** + * Organizes the include directives and forward declarations of a source or header file. + */ +public class OrganizeIncludesAction extends TextEditorAction { + /** + * Constructor + * @param editor The editor on which this Organize Includes action should operate. + */ + public OrganizeIncludesAction(ITextEditor editor) { + super(CEditorMessages.getBundleForConstructedKeys(), "OrganizeIncludes.", editor); //$NON-NLS-1$ + CUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.ORGANIZE_INCLUDES_ACTION); + } + + @Override + public void run() { + final ITextEditor editor = getTextEditor(); + final ITranslationUnit tu = getTranslationUnit(editor); + if (tu == null) { + return; + } + if (!validateEditorInputState()) { + return; + } + + final IHeaderChooser headerChooser = new InteractiveHeaderChooser( + CEditorMessages.OrganizeIncludes_label, editor.getSite().getShell()); + final MultiTextEdit[] holder = new MultiTextEdit[1]; + // We can't use SharedASTJob because IncludeOrganizer needs to disable promiscuous + // binding resolution, and you can't mix promiscuous and non-promiscuous binding + // resolution in the same AST. + Job job = new Job(CEditorMessages.OrganizeIncludes_action) { + @Override + public IStatus run(IProgressMonitor monitor) { + try { + IIndex index= CCorePlugin.getIndexManager().getIndex(tu.getCProject(), + IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_EXTENSION_FRAGMENTS_ADD_IMPORT); + try { + index.acquireReadLock(); + IASTTranslationUnit ast = tu.getAST(index, ASTCache.PARSE_MODE); + if (ast == null) { + return CUIPlugin.createErrorStatus( + NLS.bind(CEditorMessages.OrganizeIncludes_ast_not_available, tu.getPath().toOSString())); + } + IncludeOrganizer organizer = new IncludeOrganizer(tu, index, headerChooser); + holder[0] = organizer.organizeIncludes(ast); + return Status.OK_STATUS; + } catch (InterruptedException e) { + return Status.CANCEL_STATUS; + } finally { + index.releaseReadLock(); + } + } catch (CoreException e) { + return e.getStatus(); + } + } + }; + IStatus status = BusyCursorJobRunner.execute(job); + if (status.isOK()) { + MultiTextEdit edit = holder[0]; + if (edit.hasChildren()) { + // Apply the text edit. + IEditorInput editorInput = editor.getEditorInput(); + IDocument document = editor.getDocumentProvider().getDocument(editorInput); + IDocumentUndoManager manager= DocumentUndoManagerRegistry.getDocumentUndoManager(document); + manager.beginCompoundChange(); + try { + edit.apply(document); + } catch (MalformedTreeException e) { + CUIPlugin.log(e); + } catch (BadLocationException e) { + CUIPlugin.log(e); + } + manager.endCompoundChange(); + } + } else if (status.matches(IStatus.ERROR)) { + ErrorDialog.openError(editor.getEditorSite().getShell(), + CEditorMessages.OrganizeIncludes_error_title, + CEditorMessages.OrganizeIncludes_insertion_failed, status); + } + } + + @Override + public void update() { + ITextEditor editor = getTextEditor(); + setEnabled(editor != null && getTranslationUnit(editor) != null); + } + + /** + * Returns the translation unit of the given editor. + * @param editor The editor. + * @return The translation unit. + */ + private static ITranslationUnit getTranslationUnit(ITextEditor editor) { + if (editor == null) { + return null; + } + return CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editor.getEditorInput()); + } +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsImages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsImages.java index 47f418009bc..63879cf26c9 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsImages.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsImages.java @@ -1,245 +1,245 @@ -/*******************************************************************************
- * Copyright (c) 2010, 2013 Andrew Gvozdev 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:
- * Andrew Gvozdev - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.language.settings.providers;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.viewers.IDecoration;
-import org.eclipse.swt.graphics.Image;
-
-import org.eclipse.cdt.core.settings.model.ACPathEntry;
-import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
-import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
-import org.eclipse.cdt.core.settings.model.ICSettingEntry;
-import org.eclipse.cdt.core.settings.model.util.CDataUtil;
-import org.eclipse.cdt.ui.CDTSharedImages;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.utils.UNCPathConverter;
-import org.eclipse.cdt.utils.cdtvariables.CdtVariableResolver;
-
-import org.eclipse.cdt.internal.ui.newui.Messages;
-
-/**
- * Helper class to provide unified images for {@link ICLanguageSettingEntry}.
- */
-public class LanguageSettingsImages {
- // evaluates to "/${ProjName)/"
- private static final String PROJ_NAME_PREFIX = '/' + CdtVariableResolver.createVariableReference(CdtVariableResolver.VAR_PROJ_NAME) + '/';
-
- /**
- * Check if the language settings entry should be presented as "project-relative" in UI.
- *
- * @param entry - language settings entry to check.
- * @return {@code true} if the entry should be displayed as "project-relative", {@code false} otherwise.
- */
- public static boolean isProjectRelative(ICLanguageSettingEntry entry) {
- if (entry instanceof ACPathEntry) {
- String path = entry.getName();
- return ((ACPathEntry) entry).isValueWorkspacePath() && path.startsWith(PROJ_NAME_PREFIX);
- }
- return false;
- }
-
- /**
- * Convert path used by {@link ICLanguageSettingEntry} to label representing project-relative portion.
- *
- * @param path - path to convert to label in project-relative format.
- * @return label to be used to display the path in UI.
- */
- public static String toProjectRelative(String path) {
- if (path.startsWith(LanguageSettingsImages.PROJ_NAME_PREFIX)) {
- return path.substring(LanguageSettingsImages.PROJ_NAME_PREFIX.length());
- }
- return path;
- }
-
- /**
- * Convert label for project-relative path back to path representation carried by {@link ICLanguageSettingEntry}.
- *
- * @param label - label in project-relative format.
- * @return path to be used by {@link ICLanguageSettingEntry}.
- */
- public static String fromProjectRelative(String label) {
- return LanguageSettingsImages.PROJ_NAME_PREFIX + label;
- }
-
- /**
- * Returns image for the given {@link ICLanguageSettingEntry} from internally managed repository including
- * necessary overlays for given configuration description.
- *
- * @param kind - kind of {@link ICLanguageSettingEntry}, i.e. {@link ICSettingEntry#INCLUDE_PATH} etc.
- * @param flags - flags of {@link ICSettingEntry}.
- * @param isProjectRelative specifies if the image should present "project-relative" icon.
- * @return the image for the entry with appropriate overlays.
- */
- public static Image getImage(int kind, int flags, boolean isProjectRelative) {
- String imageKey = getImageKey(kind, flags, isProjectRelative);
- if (imageKey != null) {
- return CDTSharedImages.getImage(imageKey);
- }
- return null;
- }
-
- /**
- * Returns image for the given entry from internally managed repository including
- * necessary overlays for given configuration description.
- *
- * @param entry - language settings entry to get an image for.
- * @param cfgDescription - configuration description of the entry.
- * @return the image for the entry with appropriate overlays.
- */
- public static Image getImage(ICLanguageSettingEntry entry, ICConfigurationDescription cfgDescription) {
- int kind = entry.getKind();
- int flags = entry.getFlags();
- boolean isProjectRelative = isProjectRelative(entry);
-
- String imageKey = getImageKey(kind, flags, isProjectRelative);
- Image image = null;
- if (imageKey != null) {
- String[] overlayKeys = new String[5];
-
- if ((flags & ICSettingEntry.UNDEFINED) != 0) {
- image = CDTSharedImages.getImageOverlaid(imageKey, CDTSharedImages.IMG_OVR_INACTIVE, IDecoration.BOTTOM_LEFT);
- } else {
- String overlayKeyStatus=null;
- IStatus status = getStatus(entry, cfgDescription);
- switch (status.getSeverity()) {
- case IStatus.ERROR:
- overlayKeyStatus = CDTSharedImages.IMG_OVR_ERROR;
- break;
- case IStatus.WARNING:
- overlayKeyStatus = CDTSharedImages.IMG_OVR_WARNING;
- break;
- case IStatus.INFO:
- overlayKeyStatus = CDTSharedImages.IMG_OVR_WARNING;
- break;
- }
- if (overlayKeyStatus != null) {
- overlayKeys[IDecoration.BOTTOM_LEFT]=overlayKeyStatus;
- }
-
- if ((flags & ICSettingEntry.EXPORTED) != 0) {
- overlayKeys[IDecoration.BOTTOM_RIGHT]=CDTSharedImages.IMG_OVR_EXPORTED;
- }
-
- image = CDTSharedImages.getImageOverlaid(imageKey, overlayKeys);
- }
- }
- return image;
- }
-
- /**
- * @return the base key for the image.
- */
- public static String getImageKey(int kind, int flag, boolean isProjectRelative) {
- String imageKey = null;
-
- boolean isWorkspacePath = (flag & ICSettingEntry.VALUE_WORKSPACE_PATH) != 0;
- boolean isBuiltin = (flag & ICSettingEntry.BUILTIN) != 0;
- boolean isFramework = (flag & ICSettingEntry.FRAMEWORKS_MAC) != 0;
-
- switch (kind) {
- case ICSettingEntry.INCLUDE_PATH:
- if (isWorkspacePath) {
- if (isProjectRelative) {
- imageKey = CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER_PROJECT;
- } else {
- imageKey = CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER_WORKSPACE;
- }
- } else if (isFramework) {
- imageKey = CDTSharedImages.IMG_OBJS_FRAMEWORKS_FOLDER;
- } else if (isBuiltin) {
- imageKey = CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER_SYSTEM;
- } else {
- imageKey = CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER;
- }
- break;
- case ICSettingEntry.INCLUDE_FILE:
- imageKey = CDTSharedImages.IMG_OBJS_TUNIT_HEADER;
- break;
- case ICSettingEntry.MACRO:
- imageKey = CDTSharedImages.IMG_OBJS_MACRO;
- break;
- case ICSettingEntry.MACRO_FILE:
- imageKey = CDTSharedImages.IMG_OBJS_MACROS_FILE;
- break;
- case ICSettingEntry.LIBRARY_PATH:
- imageKey = CDTSharedImages.IMG_OBJS_LIBRARY_FOLDER;
- break;
- case ICSettingEntry.LIBRARY_FILE:
- imageKey = CDTSharedImages.IMG_OBJS_LIBRARY;
- break;
- }
- if (imageKey == null)
- imageKey = CDTSharedImages.IMG_OBJS_UNKNOWN_TYPE;
- return imageKey;
- }
-
- /**
- * Checking if the entry points to existing or accessible location.
- * @param entry - resolved entry
- */
- private static boolean isLocationOk(ACPathEntry entry) {
- boolean exists = true;
- boolean isWorkspacePath = (entry.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH) != 0;
- if (isWorkspacePath) {
- IPath path = new Path(entry.getValue());
- IResource rc = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
- exists = (rc !=null) && rc.isAccessible();
- } else if (UNCPathConverter.isUNC(entry.getName())) {
- return true;
- } else {
- String pathname = entry.getName();
- java.io.File file = new java.io.File(pathname);
- exists = file.exists();
- }
- return exists;
- }
-
- /**
- * Defines status object for the status message line.
- *
- * @param entry - the entry to check status on.
- * @param cfgDescription - configuration description of the entry.
- * @return a status object defining severity and message.
- */
- public static IStatus getStatus(ICLanguageSettingEntry entry, ICConfigurationDescription cfgDescription) {
- if (entry instanceof ACPathEntry) {
- if (!entry.isResolved()) {
- ICLanguageSettingEntry[] entries = CDataUtil.resolveEntries(new ICLanguageSettingEntry[] {entry}, cfgDescription);
- if (entries != null && entries.length > 0) {
- entry = entries[0];
- }
- }
-
- ACPathEntry acEntry = (ACPathEntry)entry;
- String acEntryName = acEntry.getName();
- IPath path = new Path(acEntryName);
- if (!path.isAbsolute()) {
- return new Status(IStatus.INFO, CUIPlugin.PLUGIN_ID, Messages.LanguageSettingsImages_UsingRelativePathsNotRecommended);
- }
- if (!isLocationOk(acEntry)) {
- if (acEntry.isFile()) {
- return new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, Messages.LanguageSettingsImages_FileDoesNotExist);
- } else {
- return new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, Messages.LanguageSettingsImages_FolderDoesNotExist);
- }
- }
-
- }
- return Status.OK_STATUS;
- }
-
-}
+/******************************************************************************* + * Copyright (c) 2010, 2013 Andrew Gvozdev 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: + * Andrew Gvozdev - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.ui.language.settings.providers; + +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Status; +import org.eclipse.jface.viewers.IDecoration; +import org.eclipse.swt.graphics.Image; + +import org.eclipse.cdt.core.settings.model.ACPathEntry; +import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; +import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; +import org.eclipse.cdt.core.settings.model.ICSettingEntry; +import org.eclipse.cdt.core.settings.model.util.CDataUtil; +import org.eclipse.cdt.ui.CDTSharedImages; +import org.eclipse.cdt.ui.CUIPlugin; +import org.eclipse.cdt.utils.UNCPathConverter; +import org.eclipse.cdt.utils.cdtvariables.CdtVariableResolver; + +import org.eclipse.cdt.internal.ui.newui.Messages; + +/** + * Helper class to provide unified images for {@link ICLanguageSettingEntry}. + */ +public class LanguageSettingsImages { + // evaluates to "/${ProjName)/" + private static final String PROJ_NAME_PREFIX = '/' + CdtVariableResolver.createVariableReference(CdtVariableResolver.VAR_PROJ_NAME) + '/'; + + /** + * Check if the language settings entry should be presented as "project-relative" in UI. + * + * @param entry - language settings entry to check. + * @return {@code true} if the entry should be displayed as "project-relative", {@code false} otherwise. + */ + public static boolean isProjectRelative(ICLanguageSettingEntry entry) { + if (entry instanceof ACPathEntry) { + String path = entry.getName(); + return ((ACPathEntry) entry).isValueWorkspacePath() && path.startsWith(PROJ_NAME_PREFIX); + } + return false; + } + + /** + * Convert path used by {@link ICLanguageSettingEntry} to label representing project-relative portion. + * + * @param path - path to convert to label in project-relative format. + * @return label to be used to display the path in UI. + */ + public static String toProjectRelative(String path) { + if (path.startsWith(LanguageSettingsImages.PROJ_NAME_PREFIX)) { + return path.substring(LanguageSettingsImages.PROJ_NAME_PREFIX.length()); + } + return path; + } + + /** + * Convert label for project-relative path back to path representation carried by {@link ICLanguageSettingEntry}. + * + * @param label - label in project-relative format. + * @return path to be used by {@link ICLanguageSettingEntry}. + */ + public static String fromProjectRelative(String label) { + return LanguageSettingsImages.PROJ_NAME_PREFIX + label; + } + + /** + * Returns image for the given {@link ICLanguageSettingEntry} from internally managed repository including + * necessary overlays for given configuration description. + * + * @param kind - kind of {@link ICLanguageSettingEntry}, i.e. {@link ICSettingEntry#INCLUDE_PATH} etc. + * @param flags - flags of {@link ICSettingEntry}. + * @param isProjectRelative specifies if the image should present "project-relative" icon. + * @return the image for the entry with appropriate overlays. + */ + public static Image getImage(int kind, int flags, boolean isProjectRelative) { + String imageKey = getImageKey(kind, flags, isProjectRelative); + if (imageKey != null) { + return CDTSharedImages.getImage(imageKey); + } + return null; + } + + /** + * Returns image for the given entry from internally managed repository including + * necessary overlays for given configuration description. + * + * @param entry - language settings entry to get an image for. + * @param cfgDescription - configuration description of the entry. + * @return the image for the entry with appropriate overlays. + */ + public static Image getImage(ICLanguageSettingEntry entry, ICConfigurationDescription cfgDescription) { + int kind = entry.getKind(); + int flags = entry.getFlags(); + boolean isProjectRelative = isProjectRelative(entry); + + String imageKey = getImageKey(kind, flags, isProjectRelative); + Image image = null; + if (imageKey != null) { + String[] overlayKeys = new String[5]; + + if ((flags & ICSettingEntry.UNDEFINED) != 0) { + image = CDTSharedImages.getImageOverlaid(imageKey, CDTSharedImages.IMG_OVR_INACTIVE, IDecoration.BOTTOM_LEFT); + } else { + String overlayKeyStatus=null; + IStatus status = getStatus(entry, cfgDescription); + switch (status.getSeverity()) { + case IStatus.ERROR: + overlayKeyStatus = CDTSharedImages.IMG_OVR_ERROR; + break; + case IStatus.WARNING: + overlayKeyStatus = CDTSharedImages.IMG_OVR_WARNING; + break; + case IStatus.INFO: + overlayKeyStatus = CDTSharedImages.IMG_OVR_WARNING; + break; + } + if (overlayKeyStatus != null) { + overlayKeys[IDecoration.BOTTOM_LEFT]=overlayKeyStatus; + } + + if ((flags & ICSettingEntry.EXPORTED) != 0) { + overlayKeys[IDecoration.BOTTOM_RIGHT]=CDTSharedImages.IMG_OVR_EXPORTED; + } + + image = CDTSharedImages.getImageOverlaid(imageKey, overlayKeys); + } + } + return image; + } + + /** + * @return the base key for the image. + */ + public static String getImageKey(int kind, int flag, boolean isProjectRelative) { + String imageKey = null; + + boolean isWorkspacePath = (flag & ICSettingEntry.VALUE_WORKSPACE_PATH) != 0; + boolean isBuiltin = (flag & ICSettingEntry.BUILTIN) != 0; + boolean isFramework = (flag & ICSettingEntry.FRAMEWORKS_MAC) != 0; + + switch (kind) { + case ICSettingEntry.INCLUDE_PATH: + if (isWorkspacePath) { + if (isProjectRelative) { + imageKey = CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER_PROJECT; + } else { + imageKey = CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER_WORKSPACE; + } + } else if (isFramework) { + imageKey = CDTSharedImages.IMG_OBJS_FRAMEWORKS_FOLDER; + } else if (isBuiltin) { + imageKey = CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER_SYSTEM; + } else { + imageKey = CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER; + } + break; + case ICSettingEntry.INCLUDE_FILE: + imageKey = CDTSharedImages.IMG_OBJS_TUNIT_HEADER; + break; + case ICSettingEntry.MACRO: + imageKey = CDTSharedImages.IMG_OBJS_MACRO; + break; + case ICSettingEntry.MACRO_FILE: + imageKey = CDTSharedImages.IMG_OBJS_MACROS_FILE; + break; + case ICSettingEntry.LIBRARY_PATH: + imageKey = CDTSharedImages.IMG_OBJS_LIBRARY_FOLDER; + break; + case ICSettingEntry.LIBRARY_FILE: + imageKey = CDTSharedImages.IMG_OBJS_LIBRARY; + break; + } + if (imageKey == null) + imageKey = CDTSharedImages.IMG_OBJS_UNKNOWN_TYPE; + return imageKey; + } + + /** + * Checking if the entry points to existing or accessible location. + * @param entry - resolved entry + */ + private static boolean isLocationOk(ACPathEntry entry) { + boolean exists = true; + boolean isWorkspacePath = (entry.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH) != 0; + if (isWorkspacePath) { + IPath path = new Path(entry.getValue()); + IResource rc = ResourcesPlugin.getWorkspace().getRoot().findMember(path); + exists = (rc !=null) && rc.isAccessible(); + } else if (UNCPathConverter.isUNC(entry.getName())) { + return true; + } else { + String pathname = entry.getName(); + java.io.File file = new java.io.File(pathname); + exists = file.exists(); + } + return exists; + } + + /** + * Defines status object for the status message line. + * + * @param entry - the entry to check status on. + * @param cfgDescription - configuration description of the entry. + * @return a status object defining severity and message. + */ + public static IStatus getStatus(ICLanguageSettingEntry entry, ICConfigurationDescription cfgDescription) { + if (entry instanceof ACPathEntry) { + if (!entry.isResolved()) { + ICLanguageSettingEntry[] entries = CDataUtil.resolveEntries(new ICLanguageSettingEntry[] {entry}, cfgDescription); + if (entries != null && entries.length > 0) { + entry = entries[0]; + } + } + + ACPathEntry acEntry = (ACPathEntry)entry; + String acEntryName = acEntry.getName(); + IPath path = new Path(acEntryName); + if (!path.isAbsolute()) { + return new Status(IStatus.INFO, CUIPlugin.PLUGIN_ID, Messages.LanguageSettingsImages_UsingRelativePathsNotRecommended); + } + if (!isLocationOk(acEntry)) { + if (acEntry.isFile()) { + return new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, Messages.LanguageSettingsImages_FileDoesNotExist); + } else { + return new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, Messages.LanguageSettingsImages_FolderDoesNotExist); + } + } + + } + return Status.OK_STATUS; + } + +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsProviderAssociationManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsProviderAssociationManager.java index 7cb5c087873..c57ad83a23b 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsProviderAssociationManager.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsProviderAssociationManager.java @@ -1,361 +1,361 @@ -/*******************************************************************************
- * Copyright (c) 2010, 2012 Andrew Gvozdev 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:
- * Andrew Gvozdev - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.language.settings.providers;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.Platform;
-
-import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider;
-import org.eclipse.cdt.ui.CDTSharedImages;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.dialogs.ICOptionPage;
-
-/**
- * This class manages extensions of extension point org.eclipse.cdt.core.LanguageSettingsProvider
- * which defines appearance and behavior of UI controls for Language Settings Providers.
- *
- * @noextend This class is not intended to be subclassed by clients.
- * @noinstantiate This class is not intended to be instantiated by clients.
- */
-public class LanguageSettingsProviderAssociationManager {
- /** Name of the extension point for contributing language settings provider associations */
- private static final String PROVIDER_ASSOCIATION_EXTENSION_POINT_SIMPLE_ID = "LanguageSettingsProviderAssociation"; //$NON-NLS-1$
-
- private static final String ELEM_ID_ASSOCIATION = "id-association"; //$NON-NLS-1$
- private static final String ELEM_CLASS_ASSOCIATION = "class-association"; //$NON-NLS-1$
- private static final String ATTR_ID = "id"; //$NON-NLS-1$
- private static final String ATTR_CLASS = "class"; //$NON-NLS-1$
- private static final String ATTR_ICON = "icon"; //$NON-NLS-1$
- private static final String ATTR_PAGE = "page"; //$NON-NLS-1$
- private static final String ATTR_UI_CLEAR_ENTRIES = "ui-clear-entries"; //$NON-NLS-1$
- private static final String ATTR_UI_EDIT_ENTRIES = "ui-edit-entries"; //$NON-NLS-1$
-
- private static boolean isLoaded = false;
- private static List<URL> loadedIcons = new ArrayList<URL>();
- private static Map<String, URL> fImagesUrlById = new HashMap<String, URL>();
- private static Map<String, URL> fImagesUrlByClass = new HashMap<String, URL>();
- private static List<String> fRegirestedIds = new ArrayList<String>();
- private static List<String> fRegisteredClasses = new ArrayList<String>();
-
- private static Map<String, Map<String, String>> fAssociationsById = new HashMap<String, Map<String, String>>();
- private static Map<String, Map<String, String>> fAssociationsByClass = new HashMap<String, Map<String, String>>();
-
- /**
- * Load extensions into memory maps.
- */
- private static void loadExtensions() {
- if (isLoaded) {
- return;
- }
- isLoaded = true;
-
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IExtensionPoint extension = registry.getExtensionPoint(CUIPlugin.PLUGIN_ID, PROVIDER_ASSOCIATION_EXTENSION_POINT_SIMPLE_ID);
- if (extension != null) {
- IExtension[] extensions = extension.getExtensions();
- for (IExtension ext : extensions) {
- @SuppressWarnings("unused")
- String extensionID = ext.getUniqueIdentifier();
- for (IConfigurationElement cfgEl : ext.getConfigurationElements()) {
- if (cfgEl.getName().equals(ELEM_ID_ASSOCIATION)) {
- String id = cfgEl.getAttribute(ATTR_ID);
- URL url = getIconUrl(cfgEl);
- fImagesUrlById.put(id, url);
- fRegirestedIds.add(id);
-
- Map<String, String> properties = new HashMap<String, String>();
- putNotEmpty(properties, ATTR_PAGE, cfgEl.getAttribute(ATTR_PAGE));
- putNotEmpty(properties, ATTR_UI_CLEAR_ENTRIES, cfgEl.getAttribute(ATTR_UI_CLEAR_ENTRIES));
- putNotEmpty(properties, ATTR_UI_EDIT_ENTRIES, cfgEl.getAttribute(ATTR_UI_EDIT_ENTRIES));
- fAssociationsById.put(id, properties);
- } else if (cfgEl.getName().equals(ELEM_CLASS_ASSOCIATION)) {
- String className = cfgEl.getAttribute(ATTR_CLASS);
- URL url = getIconUrl(cfgEl);
- fImagesUrlByClass.put(className, url);
- String pageClass = cfgEl.getAttribute(ATTR_PAGE);
- if (pageClass != null && pageClass.length() > 0) {
- fRegisteredClasses.add(className);
- }
-
- Map<String, String> properties = new HashMap<String, String>();
- putNotEmpty(properties, ATTR_PAGE, cfgEl.getAttribute(ATTR_PAGE));
- putNotEmpty(properties, ATTR_UI_CLEAR_ENTRIES, cfgEl.getAttribute(ATTR_UI_CLEAR_ENTRIES));
- putNotEmpty(properties, ATTR_UI_EDIT_ENTRIES, cfgEl.getAttribute(ATTR_UI_EDIT_ENTRIES));
- fAssociationsByClass.put(className, properties);
- }
- }
- }
- }
-
- }
-
- /**
- * Put value into properties ignoring nulls.
- */
- private static void putNotEmpty(Map<String, String> properties, String key, String value) {
- if (value != null)
- properties.put(key, value);
- }
-
- /**
- * Find icon URL in its bundle.
- */
- private static URL getIconUrl(IConfigurationElement config) {
- URL url = null;
- try {
- String iconName = config.getAttribute(ATTR_ICON);
- if (iconName != null) {
- URL pluginInstallUrl = Platform.getBundle(config.getDeclaringExtension().getContributor().getName()).getEntry("/"); //$NON-NLS-1$
- url = new URL(pluginInstallUrl, iconName);
- if (loadedIcons.contains(url)) {
- return url;
- }
- }
- } catch (MalformedURLException e) {
- CUIPlugin.log(e);
- }
-
- loadedIcons.add(url);
- if (url != null) {
- CDTSharedImages.register(url);
- }
-
- return url;
- }
-
- /**
- * Get image URL for language settings provider with the given ID.
- *
- * @param providerId - ID of language settings provider.
- * @return image URL or {@code null}.
- */
- public static URL getImageUrl(String providerId) {
- loadExtensions();
- return fImagesUrlById.get(providerId);
- }
-
- /**
- * Create an Options page for language settings provider with given ID.
- */
- private static ICOptionPage createOptionsPageById(String providerId) {
- loadExtensions();
-
- if (fRegirestedIds.contains(providerId)) {
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IExtensionPoint extension = registry.getExtensionPoint(CUIPlugin.PLUGIN_ID, PROVIDER_ASSOCIATION_EXTENSION_POINT_SIMPLE_ID);
- if (extension != null) {
- IExtension[] extensions = extension.getExtensions();
- for (IExtension ext : extensions) {
- try {
- @SuppressWarnings("unused")
- String extensionID = ext.getUniqueIdentifier();
- for (IConfigurationElement cfgEl : ext.getConfigurationElements()) {
- if (cfgEl.getName().equals(ELEM_ID_ASSOCIATION)) {
- String id = cfgEl.getAttribute(ATTR_ID);
- if (providerId.equals(id)) {
- String pageClass = cfgEl.getAttribute(ATTR_PAGE);
- if (pageClass != null && pageClass.trim().length() > 0) {
- ICOptionPage page = (ICOptionPage) cfgEl.createExecutableExtension(ATTR_PAGE);
- return page;
- }
- }
- }
- }
- } catch (Exception e) {
- CUIPlugin.log("Cannot load LanguageSettingsProviderAssociation extension " + ext.getUniqueIdentifier(), e); //$NON-NLS-1$
- }
- }
- }
- }
- return null;
- }
-
- /**
- * Create an Options page for language settings provider class by its name.
- */
- private static ICOptionPage createOptionsPageByClass(String providerClassName) {
- loadExtensions();
-
- if (fRegisteredClasses.contains(providerClassName)) {
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IExtensionPoint extension = registry.getExtensionPoint(CUIPlugin.PLUGIN_ID, PROVIDER_ASSOCIATION_EXTENSION_POINT_SIMPLE_ID);
- if (extension != null) {
- IExtension[] extensions = extension.getExtensions();
- for (IExtension ext : extensions) {
- try {
- @SuppressWarnings("unused")
- String extensionID = ext.getUniqueIdentifier();
- for (IConfigurationElement cfgEl : ext.getConfigurationElements()) {
- if (cfgEl.getName().equals(ELEM_CLASS_ASSOCIATION)) {
- String className = cfgEl.getAttribute(ATTR_CLASS);
- if (providerClassName.equals(className)) {
- String pageClass = cfgEl.getAttribute(ATTR_PAGE);
- if (pageClass!=null && pageClass.trim().length()>0) {
- ICOptionPage page = (ICOptionPage) cfgEl.createExecutableExtension(ATTR_PAGE);
- return page;
- }
- }
- }
- }
- } catch (Exception e) {
- CUIPlugin.log("Cannot load LanguageSettingsProviderAssociation extension " + ext.getUniqueIdentifier(), e); //$NON-NLS-1$
- }
- }
- }
- }
- return null;
- }
-
- /**
- * Returns Language Settings Provider image registered for closest superclass
- * or interface.
- *
- * @param providerClass - class to find Language Settings Provider image.
- * @return image or {@code null}
- */
- public static URL getImage(Class<? extends ILanguageSettingsProvider> providerClass) {
- URL url = null;
-
- outer: for (Class<?> c = providerClass; c != null; c = c.getSuperclass()) {
- url = getImageURL(c);
- if (url != null) {
- break;
- }
-
- // this does not check for super-interfaces, feel free to implement as needed
- for (Class<?> i : c.getInterfaces()) {
- url = getImageURL(i);
- if (url != null) {
- break outer;
- }
- }
- }
- return url;
- }
-
- /**
- * Return image URL registered for the given class.
- */
- private static URL getImageURL(Class<?> clazz) {
- String className = clazz.getCanonicalName();
- for (Entry<String, URL> entry : fImagesUrlByClass.entrySet()) {
- if (entry.getKey().equals(className)) {
- return entry.getValue();
- }
- }
- return null;
- }
-
- /**
- * Returns language settings provider Options page registered for closest superclass.
- *
- * @param provider - instance of provider to create Options page for.
- * @return image or {@code null}.
- */
- public static ICOptionPage createOptionsPage(ILanguageSettingsProvider provider) {
- String id = provider.getId();
- ICOptionPage optionsPage = createOptionsPageById(id);
- if (optionsPage != null) {
- return optionsPage;
- }
-
- Class<? extends ILanguageSettingsProvider> clazz = provider.getClass();
- outer: for (Class<?> c = clazz ;c != null; c = c.getSuperclass()) {
- optionsPage = createOptionsPageByClass(c);
- if (optionsPage != null) {
- break;
- }
-
- // this does not check for super-interfaces, feel free to implement as needed
- for (Class<?> i : c.getInterfaces()) {
- optionsPage = createOptionsPageByClass(i);
- if (optionsPage != null) {
- break outer;
- }
- }
- }
- return optionsPage;
- }
-
- /**
- * Create an Options page for language settings provider class.
- */
- private static ICOptionPage createOptionsPageByClass(Class<?> clazz) {
- ICOptionPage optionsPage = null;
- String className = clazz.getCanonicalName();
- if (fRegisteredClasses.contains(className)) {
- optionsPage = createOptionsPageByClass(className);
- }
- return optionsPage;
- }
-
- /**
- * Returns value of the attribute of the provider by id or closest superclass.
- */
- private static boolean getBooleanAttribute(ILanguageSettingsProvider provider, String attr) {
- loadExtensions();
-
- String id = provider.getId();
-
- Map<String, String> properties = fAssociationsById.get(id);
- if (properties != null) {
- return Boolean.parseBoolean(properties.get(attr));
- }
-
- for (Class<?> c = provider.getClass();c != null; c = c.getSuperclass()) {
- String className = c.getCanonicalName();
- properties = fAssociationsByClass.get(className);
- if (properties != null) {
- return Boolean.parseBoolean(properties.get(attr));
- }
-
- // this does not check for superinterfaces, feel free to implement as needed
- for (Class<?> i : c.getInterfaces()) {
- String interfaceName = i.getCanonicalName();
- properties = fAssociationsByClass.get(interfaceName);
- if (properties != null) {
- return Boolean.parseBoolean(properties.get(attr));
- }
- }
- }
- return false;
- }
-
- /**
- * Check if the user is allowed to edit language settings provider entries in UI.
- * @param provider - language settings provider.
- * @return {@code true} if editing is allowed or {@code false} if not.
- */
- public static boolean isAllowedToEditEntries(ILanguageSettingsProvider provider) {
- return getBooleanAttribute(provider, ATTR_UI_EDIT_ENTRIES);
- }
-
- /**
- * Check if the user is allowed to clear language settings provider entries in UI.
- * @param provider - language settings provider.
- * @return {@code true} if clearing is allowed or {@code false} if not.
- */
- public static boolean isAllowedToClear(ILanguageSettingsProvider provider) {
- return getBooleanAttribute(provider, ATTR_UI_CLEAR_ENTRIES);
- }
-
-}
+/******************************************************************************* + * Copyright (c) 2010, 2012 Andrew Gvozdev 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: + * Andrew Gvozdev - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.ui.language.settings.providers; + +import java.net.MalformedURLException; +import java.net.URL; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtension; +import org.eclipse.core.runtime.IExtensionPoint; +import org.eclipse.core.runtime.IExtensionRegistry; +import org.eclipse.core.runtime.Platform; + +import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider; +import org.eclipse.cdt.ui.CDTSharedImages; +import org.eclipse.cdt.ui.CUIPlugin; +import org.eclipse.cdt.ui.dialogs.ICOptionPage; + +/** + * This class manages extensions of extension point org.eclipse.cdt.core.LanguageSettingsProvider + * which defines appearance and behavior of UI controls for Language Settings Providers. + * + * @noextend This class is not intended to be subclassed by clients. + * @noinstantiate This class is not intended to be instantiated by clients. + */ +public class LanguageSettingsProviderAssociationManager { + /** Name of the extension point for contributing language settings provider associations */ + private static final String PROVIDER_ASSOCIATION_EXTENSION_POINT_SIMPLE_ID = "LanguageSettingsProviderAssociation"; //$NON-NLS-1$ + + private static final String ELEM_ID_ASSOCIATION = "id-association"; //$NON-NLS-1$ + private static final String ELEM_CLASS_ASSOCIATION = "class-association"; //$NON-NLS-1$ + private static final String ATTR_ID = "id"; //$NON-NLS-1$ + private static final String ATTR_CLASS = "class"; //$NON-NLS-1$ + private static final String ATTR_ICON = "icon"; //$NON-NLS-1$ + private static final String ATTR_PAGE = "page"; //$NON-NLS-1$ + private static final String ATTR_UI_CLEAR_ENTRIES = "ui-clear-entries"; //$NON-NLS-1$ + private static final String ATTR_UI_EDIT_ENTRIES = "ui-edit-entries"; //$NON-NLS-1$ + + private static boolean isLoaded = false; + private static List<URL> loadedIcons = new ArrayList<URL>(); + private static Map<String, URL> fImagesUrlById = new HashMap<String, URL>(); + private static Map<String, URL> fImagesUrlByClass = new HashMap<String, URL>(); + private static List<String> fRegirestedIds = new ArrayList<String>(); + private static List<String> fRegisteredClasses = new ArrayList<String>(); + + private static Map<String, Map<String, String>> fAssociationsById = new HashMap<String, Map<String, String>>(); + private static Map<String, Map<String, String>> fAssociationsByClass = new HashMap<String, Map<String, String>>(); + + /** + * Load extensions into memory maps. + */ + private static void loadExtensions() { + if (isLoaded) { + return; + } + isLoaded = true; + + IExtensionRegistry registry = Platform.getExtensionRegistry(); + IExtensionPoint extension = registry.getExtensionPoint(CUIPlugin.PLUGIN_ID, PROVIDER_ASSOCIATION_EXTENSION_POINT_SIMPLE_ID); + if (extension != null) { + IExtension[] extensions = extension.getExtensions(); + for (IExtension ext : extensions) { + @SuppressWarnings("unused") + String extensionID = ext.getUniqueIdentifier(); + for (IConfigurationElement cfgEl : ext.getConfigurationElements()) { + if (cfgEl.getName().equals(ELEM_ID_ASSOCIATION)) { + String id = cfgEl.getAttribute(ATTR_ID); + URL url = getIconUrl(cfgEl); + fImagesUrlById.put(id, url); + fRegirestedIds.add(id); + + Map<String, String> properties = new HashMap<String, String>(); + putNotEmpty(properties, ATTR_PAGE, cfgEl.getAttribute(ATTR_PAGE)); + putNotEmpty(properties, ATTR_UI_CLEAR_ENTRIES, cfgEl.getAttribute(ATTR_UI_CLEAR_ENTRIES)); + putNotEmpty(properties, ATTR_UI_EDIT_ENTRIES, cfgEl.getAttribute(ATTR_UI_EDIT_ENTRIES)); + fAssociationsById.put(id, properties); + } else if (cfgEl.getName().equals(ELEM_CLASS_ASSOCIATION)) { + String className = cfgEl.getAttribute(ATTR_CLASS); + URL url = getIconUrl(cfgEl); + fImagesUrlByClass.put(className, url); + String pageClass = cfgEl.getAttribute(ATTR_PAGE); + if (pageClass != null && pageClass.length() > 0) { + fRegisteredClasses.add(className); + } + + Map<String, String> properties = new HashMap<String, String>(); + putNotEmpty(properties, ATTR_PAGE, cfgEl.getAttribute(ATTR_PAGE)); + putNotEmpty(properties, ATTR_UI_CLEAR_ENTRIES, cfgEl.getAttribute(ATTR_UI_CLEAR_ENTRIES)); + putNotEmpty(properties, ATTR_UI_EDIT_ENTRIES, cfgEl.getAttribute(ATTR_UI_EDIT_ENTRIES)); + fAssociationsByClass.put(className, properties); + } + } + } + } + + } + + /** + * Put value into properties ignoring nulls. + */ + private static void putNotEmpty(Map<String, String> properties, String key, String value) { + if (value != null) + properties.put(key, value); + } + + /** + * Find icon URL in its bundle. + */ + private static URL getIconUrl(IConfigurationElement config) { + URL url = null; + try { + String iconName = config.getAttribute(ATTR_ICON); + if (iconName != null) { + URL pluginInstallUrl = Platform.getBundle(config.getDeclaringExtension().getContributor().getName()).getEntry("/"); //$NON-NLS-1$ + url = new URL(pluginInstallUrl, iconName); + if (loadedIcons.contains(url)) { + return url; + } + } + } catch (MalformedURLException e) { + CUIPlugin.log(e); + } + + loadedIcons.add(url); + if (url != null) { + CDTSharedImages.register(url); + } + + return url; + } + + /** + * Get image URL for language settings provider with the given ID. + * + * @param providerId - ID of language settings provider. + * @return image URL or {@code null}. + */ + public static URL getImageUrl(String providerId) { + loadExtensions(); + return fImagesUrlById.get(providerId); + } + + /** + * Create an Options page for language settings provider with given ID. + */ + private static ICOptionPage createOptionsPageById(String providerId) { + loadExtensions(); + + if (fRegirestedIds.contains(providerId)) { + IExtensionRegistry registry = Platform.getExtensionRegistry(); + IExtensionPoint extension = registry.getExtensionPoint(CUIPlugin.PLUGIN_ID, PROVIDER_ASSOCIATION_EXTENSION_POINT_SIMPLE_ID); + if (extension != null) { + IExtension[] extensions = extension.getExtensions(); + for (IExtension ext : extensions) { + try { + @SuppressWarnings("unused") + String extensionID = ext.getUniqueIdentifier(); + for (IConfigurationElement cfgEl : ext.getConfigurationElements()) { + if (cfgEl.getName().equals(ELEM_ID_ASSOCIATION)) { + String id = cfgEl.getAttribute(ATTR_ID); + if (providerId.equals(id)) { + String pageClass = cfgEl.getAttribute(ATTR_PAGE); + if (pageClass != null && pageClass.trim().length() > 0) { + ICOptionPage page = (ICOptionPage) cfgEl.createExecutableExtension(ATTR_PAGE); + return page; + } + } + } + } + } catch (Exception e) { + CUIPlugin.log("Cannot load LanguageSettingsProviderAssociation extension " + ext.getUniqueIdentifier(), e); //$NON-NLS-1$ + } + } + } + } + return null; + } + + /** + * Create an Options page for language settings provider class by its name. + */ + private static ICOptionPage createOptionsPageByClass(String providerClassName) { + loadExtensions(); + + if (fRegisteredClasses.contains(providerClassName)) { + IExtensionRegistry registry = Platform.getExtensionRegistry(); + IExtensionPoint extension = registry.getExtensionPoint(CUIPlugin.PLUGIN_ID, PROVIDER_ASSOCIATION_EXTENSION_POINT_SIMPLE_ID); + if (extension != null) { + IExtension[] extensions = extension.getExtensions(); + for (IExtension ext : extensions) { + try { + @SuppressWarnings("unused") + String extensionID = ext.getUniqueIdentifier(); + for (IConfigurationElement cfgEl : ext.getConfigurationElements()) { + if (cfgEl.getName().equals(ELEM_CLASS_ASSOCIATION)) { + String className = cfgEl.getAttribute(ATTR_CLASS); + if (providerClassName.equals(className)) { + String pageClass = cfgEl.getAttribute(ATTR_PAGE); + if (pageClass!=null && pageClass.trim().length()>0) { + ICOptionPage page = (ICOptionPage) cfgEl.createExecutableExtension(ATTR_PAGE); + return page; + } + } + } + } + } catch (Exception e) { + CUIPlugin.log("Cannot load LanguageSettingsProviderAssociation extension " + ext.getUniqueIdentifier(), e); //$NON-NLS-1$ + } + } + } + } + return null; + } + + /** + * Returns Language Settings Provider image registered for closest superclass + * or interface. + * + * @param providerClass - class to find Language Settings Provider image. + * @return image or {@code null} + */ + public static URL getImage(Class<? extends ILanguageSettingsProvider> providerClass) { + URL url = null; + + outer: for (Class<?> c = providerClass; c != null; c = c.getSuperclass()) { + url = getImageURL(c); + if (url != null) { + break; + } + + // this does not check for super-interfaces, feel free to implement as needed + for (Class<?> i : c.getInterfaces()) { + url = getImageURL(i); + if (url != null) { + break outer; + } + } + } + return url; + } + + /** + * Return image URL registered for the given class. + */ + private static URL getImageURL(Class<?> clazz) { + String className = clazz.getCanonicalName(); + for (Entry<String, URL> entry : fImagesUrlByClass.entrySet()) { + if (entry.getKey().equals(className)) { + return entry.getValue(); + } + } + return null; + } + + /** + * Returns language settings provider Options page registered for closest superclass. + * + * @param provider - instance of provider to create Options page for. + * @return image or {@code null}. + */ + public static ICOptionPage createOptionsPage(ILanguageSettingsProvider provider) { + String id = provider.getId(); + ICOptionPage optionsPage = createOptionsPageById(id); + if (optionsPage != null) { + return optionsPage; + } + + Class<? extends ILanguageSettingsProvider> clazz = provider.getClass(); + outer: for (Class<?> c = clazz ;c != null; c = c.getSuperclass()) { + optionsPage = createOptionsPageByClass(c); + if (optionsPage != null) { + break; + } + + // this does not check for super-interfaces, feel free to implement as needed + for (Class<?> i : c.getInterfaces()) { + optionsPage = createOptionsPageByClass(i); + if (optionsPage != null) { + break outer; + } + } + } + return optionsPage; + } + + /** + * Create an Options page for language settings provider class. + */ + private static ICOptionPage createOptionsPageByClass(Class<?> clazz) { + ICOptionPage optionsPage = null; + String className = clazz.getCanonicalName(); + if (fRegisteredClasses.contains(className)) { + optionsPage = createOptionsPageByClass(className); + } + return optionsPage; + } + + /** + * Returns value of the attribute of the provider by id or closest superclass. + */ + private static boolean getBooleanAttribute(ILanguageSettingsProvider provider, String attr) { + loadExtensions(); + + String id = provider.getId(); + + Map<String, String> properties = fAssociationsById.get(id); + if (properties != null) { + return Boolean.parseBoolean(properties.get(attr)); + } + + for (Class<?> c = provider.getClass();c != null; c = c.getSuperclass()) { + String className = c.getCanonicalName(); + properties = fAssociationsByClass.get(className); + if (properties != null) { + return Boolean.parseBoolean(properties.get(attr)); + } + + // this does not check for superinterfaces, feel free to implement as needed + for (Class<?> i : c.getInterfaces()) { + String interfaceName = i.getCanonicalName(); + properties = fAssociationsByClass.get(interfaceName); + if (properties != null) { + return Boolean.parseBoolean(properties.get(attr)); + } + } + } + return false; + } + + /** + * Check if the user is allowed to edit language settings provider entries in UI. + * @param provider - language settings provider. + * @return {@code true} if editing is allowed or {@code false} if not. + */ + public static boolean isAllowedToEditEntries(ILanguageSettingsProvider provider) { + return getBooleanAttribute(provider, ATTR_UI_EDIT_ENTRIES); + } + + /** + * Check if the user is allowed to clear language settings provider entries in UI. + * @param provider - language settings provider. + * @return {@code true} if clearing is allowed or {@code false} if not. + */ + public static boolean isAllowedToClear(ILanguageSettingsProvider provider) { + return getBooleanAttribute(provider, ATTR_UI_CLEAR_ENTRIES); + } + +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsProvidersLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsProvidersLabelProvider.java index b7c8598a6b8..9b305e7159f 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsProvidersLabelProvider.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsProvidersLabelProvider.java @@ -1,101 +1,101 @@ -/*******************************************************************************
- * Copyright (c) 2010, 2012 Andrew Gvozdev 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:
- * Andrew Gvozdev - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.language.settings.providers;
-
-import java.net.URL;
-
-import org.eclipse.jface.viewers.IDecoration;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.graphics.Image;
-
-import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider;
-import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager;
-import org.eclipse.cdt.ui.CDTSharedImages;
-
-import org.eclipse.cdt.internal.ui.newui.Messages;
-
-/**
- * Label provider for language settings providers.
- *
- */
-public class LanguageSettingsProvidersLabelProvider extends LabelProvider {
- private static final String TEST_PLUGIN_ID_PATTERN = "org.eclipse.cdt.*.tests.*"; //$NON-NLS-1$
- private static final String OOPS = "OOPS"; //$NON-NLS-1$
-
- /**
- * Returns base image key (for image without overlay).
- */
- protected String getBaseKey(ILanguageSettingsProvider provider) {
- String imageKey = null;
- // try id-association
- String id = provider.getId();
- URL url = LanguageSettingsProviderAssociationManager.getImageUrl(id);
- // try class-association
- if (url == null) {
- ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(provider);
- if (rawProvider != null) {
- url = LanguageSettingsProviderAssociationManager.getImage(rawProvider.getClass());
- }
- }
- if (url != null) {
- imageKey = url.toString();
- }
-
- if (imageKey == null) {
- if (id.matches(TEST_PLUGIN_ID_PATTERN)) {
- imageKey = CDTSharedImages.IMG_OBJS_CDT_TESTING;
- } else {
- imageKey = CDTSharedImages.IMG_OBJS_EXTENSION;
- }
- }
- return imageKey;
- }
-
- /**
- * Returns keys for image overlays. Returning {@code null} is not allowed.
- */
- protected String[] getOverlayKeys(ILanguageSettingsProvider provider) {
- String[] overlayKeys = new String[5];
- if (provider.getName() == null) {
- overlayKeys[IDecoration.BOTTOM_LEFT] = CDTSharedImages.IMG_OVR_ERROR;
- }
- return overlayKeys;
- }
-
- @Override
- public Image getImage(Object element) {
- if (element instanceof ILanguageSettingsProvider) {
- ILanguageSettingsProvider provider = (ILanguageSettingsProvider)element;
- String imageKey = getBaseKey(provider);
- String[] overlayKeys = getOverlayKeys(provider);
- return CDTSharedImages.getImageOverlaid(imageKey, overlayKeys);
- }
- return null;
- }
-
- @Override
- public String getText(Object element) {
- if (element instanceof ILanguageSettingsProvider) {
- ILanguageSettingsProvider provider = (ILanguageSettingsProvider) element;
- String name = provider.getName();
- if (name != null) {
- if (LanguageSettingsManager.isWorkspaceProvider(provider)) {
- name = name + Messages.LanguageSettingsProvidersLabelProvider_TextDecorator_Shared;
- }
- return name;
- }
- return NLS.bind(Messages.GeneralMessages_NonAccessibleID, provider.getId());
- }
- return OOPS;
- }
-
+/******************************************************************************* + * Copyright (c) 2010, 2012 Andrew Gvozdev 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: + * Andrew Gvozdev - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.ui.language.settings.providers; + +import java.net.URL; + +import org.eclipse.jface.viewers.IDecoration; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.osgi.util.NLS; +import org.eclipse.swt.graphics.Image; + +import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider; +import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager; +import org.eclipse.cdt.ui.CDTSharedImages; + +import org.eclipse.cdt.internal.ui.newui.Messages; + +/** + * Label provider for language settings providers. + * + */ +public class LanguageSettingsProvidersLabelProvider extends LabelProvider { + private static final String TEST_PLUGIN_ID_PATTERN = "org.eclipse.cdt.*.tests.*"; //$NON-NLS-1$ + private static final String OOPS = "OOPS"; //$NON-NLS-1$ + + /** + * Returns base image key (for image without overlay). + */ + protected String getBaseKey(ILanguageSettingsProvider provider) { + String imageKey = null; + // try id-association + String id = provider.getId(); + URL url = LanguageSettingsProviderAssociationManager.getImageUrl(id); + // try class-association + if (url == null) { + ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(provider); + if (rawProvider != null) { + url = LanguageSettingsProviderAssociationManager.getImage(rawProvider.getClass()); + } + } + if (url != null) { + imageKey = url.toString(); + } + + if (imageKey == null) { + if (id.matches(TEST_PLUGIN_ID_PATTERN)) { + imageKey = CDTSharedImages.IMG_OBJS_CDT_TESTING; + } else { + imageKey = CDTSharedImages.IMG_OBJS_EXTENSION; + } + } + return imageKey; + } + + /** + * Returns keys for image overlays. Returning {@code null} is not allowed. + */ + protected String[] getOverlayKeys(ILanguageSettingsProvider provider) { + String[] overlayKeys = new String[5]; + if (provider.getName() == null) { + overlayKeys[IDecoration.BOTTOM_LEFT] = CDTSharedImages.IMG_OVR_ERROR; + } + return overlayKeys; + } + + @Override + public Image getImage(Object element) { + if (element instanceof ILanguageSettingsProvider) { + ILanguageSettingsProvider provider = (ILanguageSettingsProvider)element; + String imageKey = getBaseKey(provider); + String[] overlayKeys = getOverlayKeys(provider); + return CDTSharedImages.getImageOverlaid(imageKey, overlayKeys); + } + return null; + } + + @Override + public String getText(Object element) { + if (element instanceof ILanguageSettingsProvider) { + ILanguageSettingsProvider provider = (ILanguageSettingsProvider) element; + String name = provider.getName(); + if (name != null) { + if (LanguageSettingsManager.isWorkspaceProvider(provider)) { + name = name + Messages.LanguageSettingsProvidersLabelProvider_TextDecorator_Shared; + } + return name; + } + return NLS.bind(Messages.GeneralMessages_NonAccessibleID, provider.getId()); + } + return OOPS; + } + }
\ No newline at end of file diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/newui/StatusMessageLine.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/newui/StatusMessageLine.java index 28a0b187e9d..4e786b96a1c 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/newui/StatusMessageLine.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/newui/StatusMessageLine.java @@ -1,81 +1,81 @@ -/*******************************************************************************
- * Copyright (c) 2010, 2012 Andrew Gvozdev 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:
- * Andrew Gvozdev - Initial API and implementation
+/******************************************************************************* + * Copyright (c) 2010, 2012 Andrew Gvozdev 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: + * Andrew Gvozdev - Initial API and implementation *******************************************************************************/ -
-package org.eclipse.cdt.internal.ui.newui;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CLabel;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * A message line displaying a status.
- * See also org.eclipse.jface.dialogs.StatusDialog.MessageLine.
- */
-public class StatusMessageLine {
- private CLabel fLabel;
-
- /**
- * Constructor.
- *
- * @param parent - parent element.
- * @param style - the style of the control. Refer to {@link CLabel#CLabel(Composite, int)}.
- * @param span - how many columns it should span.
- */
- public StatusMessageLine(Composite parent, int style, int span) {
- fLabel = new CLabel(parent, style);
- if (span!=1) {
- GridData gd = new GridData(SWT.FILL, SWT.NONE, true, false);
- gd.horizontalSpan = span;
- fLabel.setLayoutData(gd);
- }
- }
-
- /**
- * Find an image associated with the status.
- */
- private Image findImage(IStatus status) {
- if (status.isOK()) {
- return null;
- } else if (status.matches(IStatus.ERROR)) {
- return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR);
- } else if (status.matches(IStatus.WARNING)) {
- return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING);
- } else if (status.matches(IStatus.INFO)) {
- return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_INFO);
- }
- return null;
- }
-
- /**
- * Assign {@link IStatus} object to the message line. The status should provide
- * severity for the icon and message to display.
- *
- * @param status - status object for the message line.
- */
- public void setErrorStatus(IStatus status) {
- if (status != null && !status.isOK()) {
- String message = status.getMessage();
- if (message != null && message.length() > 0) {
- fLabel.setText(message);
- fLabel.setImage(findImage(status));
- fLabel.layout();
- return;
- }
- }
- fLabel.setText(""); //$NON-NLS-1$
- fLabel.setImage(null);
- }
+ +package org.eclipse.cdt.internal.ui.newui; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.resource.JFaceResources; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.CLabel; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Composite; + +/** + * A message line displaying a status. + * See also org.eclipse.jface.dialogs.StatusDialog.MessageLine. + */ +public class StatusMessageLine { + private CLabel fLabel; + + /** + * Constructor. + * + * @param parent - parent element. + * @param style - the style of the control. Refer to {@link CLabel#CLabel(Composite, int)}. + * @param span - how many columns it should span. + */ + public StatusMessageLine(Composite parent, int style, int span) { + fLabel = new CLabel(parent, style); + if (span!=1) { + GridData gd = new GridData(SWT.FILL, SWT.NONE, true, false); + gd.horizontalSpan = span; + fLabel.setLayoutData(gd); + } + } + + /** + * Find an image associated with the status. + */ + private Image findImage(IStatus status) { + if (status.isOK()) { + return null; + } else if (status.matches(IStatus.ERROR)) { + return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR); + } else if (status.matches(IStatus.WARNING)) { + return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING); + } else if (status.matches(IStatus.INFO)) { + return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_INFO); + } + return null; + } + + /** + * Assign {@link IStatus} object to the message line. The status should provide + * severity for the icon and message to display. + * + * @param status - status object for the message line. + */ + public void setErrorStatus(IStatus status) { + if (status != null && !status.isOK()) { + String message = status.getMessage(); + if (message != null && message.length() > 0) { + fLabel.setText(message); + fLabel.setImage(findImage(status)); + fLabel.layout(); + return; + } + } + fLabel.setText(""); //$NON-NLS-1$ + fLabel.setImage(null); + } }
\ No newline at end of file diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoringContribution.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoringContribution.java index 03591892266..ca77e54400d 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoringContribution.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoringContribution.java @@ -1,33 +1,33 @@ -/*******************************************************************************
- * Copyright (c) 2009, 2012 Institute for Software, HSR Hochschule fuer Technik
- * Rapperswil, University of applied sciences 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:
- * Institute for Software (IFS)- initial API and implementation
+/******************************************************************************* + * Copyright (c) 2009, 2012 Institute for Software, HSR Hochschule fuer Technik + * Rapperswil, University of applied sciences 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: + * Institute for Software (IFS)- initial API and implementation ******************************************************************************/ -package org.eclipse.cdt.internal.ui.refactoring.extractlocalvariable;
-
-import java.util.Map;
-
-import org.eclipse.ltk.core.refactoring.RefactoringDescriptor;
-
-import org.eclipse.cdt.internal.ui.refactoring.CRefactoringContribution;
-
-/**
- * @author Emanuel Graf IFS
- */
-public class ExtractLocalVariableRefactoringContribution extends CRefactoringContribution {
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Override
- public RefactoringDescriptor createDescriptor(String id, String project, String description,
- String comment, Map arguments, int flags) throws IllegalArgumentException {
- if (id.equals(ExtractLocalVariableRefactoring.ID)) {
- return new ExtractLocalVariableRefactoringDescriptor(project, description, comment, arguments);
- }
- return null;
- }
-}
+package org.eclipse.cdt.internal.ui.refactoring.extractlocalvariable; + +import java.util.Map; + +import org.eclipse.ltk.core.refactoring.RefactoringDescriptor; + +import org.eclipse.cdt.internal.ui.refactoring.CRefactoringContribution; + +/** + * @author Emanuel Graf IFS + */ +public class ExtractLocalVariableRefactoringContribution extends CRefactoringContribution { + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public RefactoringDescriptor createDescriptor(String id, String project, String description, + String comment, Map arguments, int flags) throws IllegalArgumentException { + if (id.equals(ExtractLocalVariableRefactoring.ID)) { + return new ExtractLocalVariableRefactoringDescriptor(project, description, comment, arguments); + } + return null; + } +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoringDescriptor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoringDescriptor.java index d4efbd7b831..6d840c05b38 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoringDescriptor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoringDescriptor.java @@ -1,48 +1,48 @@ -/*******************************************************************************
- * Copyright (c) 2009, 2012 Institute for Software, HSR Hochschule fuer Technik
- * Rapperswil, University of applied sciences 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:
- * Institute for Software (IFS)- initial API and implementation
- * Sergey Prigogin (Google)
- ******************************************************************************/
-package org.eclipse.cdt.internal.ui.refactoring.extractlocalvariable;
-
-import java.util.Map;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.ltk.core.refactoring.RefactoringDescriptor;
-import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-
-import org.eclipse.cdt.core.model.ICProject;
-
-import org.eclipse.cdt.internal.ui.refactoring.CRefactoring;
-import org.eclipse.cdt.internal.ui.refactoring.CRefactoringDescriptor;
-
-/**
- * @author Emanuel Graf IFS
- */
-public class ExtractLocalVariableRefactoringDescriptor extends CRefactoringDescriptor {
- static protected final String NAME = "name"; //$NON-NLS-1$
-
- public ExtractLocalVariableRefactoringDescriptor(String project, String description,
- String comment, Map<String, String> arguments) {
- super(ExtractLocalVariableRefactoring.ID, project, description, comment,
- RefactoringDescriptor.MULTI_CHANGE, arguments);
- }
-
- @Override
- public CRefactoring createRefactoring(RefactoringStatus status) throws CoreException {
- ISelection selection = getSelection();
- ICProject proj = getCProject();
- ExtractLocalVariableRefactoring refactoring =
- new ExtractLocalVariableRefactoring(getTranslationUnit(), selection, proj);
- refactoring.getRefactoringInfo().setName(arguments.get(NAME));
- return refactoring;
- }
-}
+/******************************************************************************* + * Copyright (c) 2009, 2012 Institute for Software, HSR Hochschule fuer Technik + * Rapperswil, University of applied sciences 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: + * Institute for Software (IFS)- initial API and implementation + * Sergey Prigogin (Google) + ******************************************************************************/ +package org.eclipse.cdt.internal.ui.refactoring.extractlocalvariable; + +import java.util.Map; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.ltk.core.refactoring.RefactoringDescriptor; +import org.eclipse.ltk.core.refactoring.RefactoringStatus; + +import org.eclipse.cdt.core.model.ICProject; + +import org.eclipse.cdt.internal.ui.refactoring.CRefactoring; +import org.eclipse.cdt.internal.ui.refactoring.CRefactoringDescriptor; + +/** + * @author Emanuel Graf IFS + */ +public class ExtractLocalVariableRefactoringDescriptor extends CRefactoringDescriptor { + static protected final String NAME = "name"; //$NON-NLS-1$ + + public ExtractLocalVariableRefactoringDescriptor(String project, String description, + String comment, Map<String, String> arguments) { + super(ExtractLocalVariableRefactoring.ID, project, description, comment, + RefactoringDescriptor.MULTI_CHANGE, arguments); + } + + @Override + public CRefactoring createRefactoring(RefactoringStatus status) throws CoreException { + ISelection selection = getSelection(); + ICProject proj = getCProject(); + ExtractLocalVariableRefactoring refactoring = + new ExtractLocalVariableRefactoring(getTranslationUnit(), selection, proj); + refactoring.getRefactoringInfo().setName(arguments.get(NAME)); + return refactoring; + } +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoringRunner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoringRunner.java index 45b0fcdc77b..7b1c09ce2b6 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoringRunner.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoringRunner.java @@ -1,43 +1,43 @@ -/*******************************************************************************
- * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
- * Rapperswil, University of applied sciences 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:
- * Tom Ball (Google) - initial API and implementation
- * Sergey Prigogin (Google)
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.refactoring.extractlocalvariable;
-
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.window.IShellProvider;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ICProject;
-
-import org.eclipse.cdt.internal.ui.refactoring.RefactoringRunner;
-import org.eclipse.cdt.internal.ui.refactoring.RefactoringSaveHelper;
-
-/**
- * Extract Local Variable refactoring runner.
- *
- * @author Tom Ball
- */
-public class ExtractLocalVariableRefactoringRunner extends RefactoringRunner {
-
- public ExtractLocalVariableRefactoringRunner(ICElement element, ISelection selection,
- IShellProvider shellProvider, ICProject cProject) {
- super(element, selection, shellProvider, cProject);
- }
-
- @Override
- public void run() {
- ExtractLocalVariableRefactoring refactoring =
- new ExtractLocalVariableRefactoring(element, selection, project);
- ExtractLocalVariableWizard wizard = new ExtractLocalVariableWizard(refactoring);
- run(wizard, refactoring, RefactoringSaveHelper.SAVE_NOTHING);
- }
-}
+/******************************************************************************* + * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik + * Rapperswil, University of applied sciences 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: + * Tom Ball (Google) - initial API and implementation + * Sergey Prigogin (Google) + *******************************************************************************/ +package org.eclipse.cdt.internal.ui.refactoring.extractlocalvariable; + +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.window.IShellProvider; + +import org.eclipse.cdt.core.model.ICElement; +import org.eclipse.cdt.core.model.ICProject; + +import org.eclipse.cdt.internal.ui.refactoring.RefactoringRunner; +import org.eclipse.cdt.internal.ui.refactoring.RefactoringSaveHelper; + +/** + * Extract Local Variable refactoring runner. + * + * @author Tom Ball + */ +public class ExtractLocalVariableRefactoringRunner extends RefactoringRunner { + + public ExtractLocalVariableRefactoringRunner(ICElement element, ISelection selection, + IShellProvider shellProvider, ICProject cProject) { + super(element, selection, shellProvider, cProject); + } + + @Override + public void run() { + ExtractLocalVariableRefactoring refactoring = + new ExtractLocalVariableRefactoring(element, selection, project); + ExtractLocalVariableWizard wizard = new ExtractLocalVariableWizard(refactoring); + run(wizard, refactoring, RefactoringSaveHelper.SAVE_NOTHING); + } +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHEContentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHEContentProvider.java index 21a5a5d3e81..50abf41fb81 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHEContentProvider.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHEContentProvider.java @@ -1,24 +1,24 @@ -/*******************************************************************************
- * Copyright (c) 2018 Wind River Systems, Inc. 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:
- * Lidia Popescu - [536255] initial API and implementation. Extension point for open call hierarchy view
- *******************************************************************************/
-package org.eclipse.cdt.ui;
-
-
-import org.eclipse.jface.viewers.IOpenListener;
-/**
- * The Call Hierarchy Extension Content Provider Interface
- * @since 6.4
- * */
-public interface ICHEContentProvider {
-
- Object[] asyncComputeExtendedRoot(Object parentElement);
-
- IOpenListener getCCallHierarchyOpenListener();
-}
+/******************************************************************************* + * Copyright (c) 2018 Wind River Systems, Inc. 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: + * Lidia Popescu - [536255] initial API and implementation. Extension point for open call hierarchy view + *******************************************************************************/ +package org.eclipse.cdt.ui; + + +import org.eclipse.jface.viewers.IOpenListener; +/** + * The Call Hierarchy Extension Content Provider Interface + * @since 6.4 + * */ +public interface ICHEContentProvider { + + Object[] asyncComputeExtendedRoot(Object parentElement); + + IOpenListener getCCallHierarchyOpenListener(); +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHENode.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHENode.java index 08e952d5fd0..378f4ffc63d 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHENode.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHENode.java @@ -1,23 +1,23 @@ -/*******************************************************************************
- * Copyright (c) 2018 Wind River Systems, Inc. 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:
- * Lidia Popescu - [536255] initial API and implementation. Extension point for open call hierarchy view
- *******************************************************************************/
-package org.eclipse.cdt.ui;
-
-
-import org.eclipse.cdt.core.model.ICElement;
-
-/**
- * The Call Hierarchy Extension Node
- * @since 6.4
- */
-public interface ICHENode {
-
- ICElement getRepresentedDeclaration();
-}
+/******************************************************************************* + * Copyright (c) 2018 Wind River Systems, Inc. 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: + * Lidia Popescu - [536255] initial API and implementation. Extension point for open call hierarchy view + *******************************************************************************/ +package org.eclipse.cdt.ui; + + +import org.eclipse.cdt.core.model.ICElement; + +/** + * The Call Hierarchy Extension Node + * @since 6.4 + */ +public interface ICHENode { + + ICElement getRepresentedDeclaration(); +} 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 5078610280a..b331f70e718 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 @@ -1,84 +1,84 @@ -/*******************************************************************************
- * Copyright (c) 2008, 2009, 2012 Intel Corporation, QNX Software Systems, 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:
- * Intel Corporation - initial API and implementation
- * QNX Software Systems - [272416] Rework the config sets dialog
- * Freescale Semiconductor - [392954] disable the action if only empty working sets exist
- *******************************************************************************/
-package org.eclipse.cdt.ui.actions;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.IWorkbenchWindowActionDelegate;
-import org.eclipse.ui.IWorkingSet;
-import org.eclipse.ui.IWorkingSetManager;
-
-import org.eclipse.cdt.ui.CUIPlugin;
-
-import org.eclipse.cdt.internal.ui.workingsets.WorkingSetConfigurationDialog;
-
-/**
- */
-public class WorkingSetConfigAction implements IWorkbenchWindowActionDelegate, IPropertyChangeListener {
-
- private static final IWorkingSetManager wsm = CUIPlugin.getDefault().getWorkbench().getWorkingSetManager();
- private boolean enabled = true;
- private IWorkbenchWindow window;
- private IAction action;
-
- @Override
- public void run(IAction action) {
- this.action = action;
- checkWS();
- if (enabled) {
- new WorkingSetConfigurationDialog(window.getShell()).open();
- }
- }
-
- @Override
- public void selectionChanged(IAction action, ISelection selection) {
- this.action = action;
- checkWS();
- }
-
- @Override
- public void dispose() {
- wsm.removePropertyChangeListener(this);
- }
-
- @Override
- public void init(IWorkbenchWindow window) {
- this.window = window;
- wsm.addPropertyChangeListener(this);
- checkWS();
- }
-
- private void checkWS() {
- enabled = false;
- IWorkingSet[] w = wsm.getWorkingSets();
- if (w == null)
- w = new IWorkingSet[0];
- for (IWorkingSet ws : w) {
- if (!ws.isEmpty()) {
- enabled = true;
- break;
- }
- }
- if (action != null) {
- action.setEnabled(enabled);
- }
- }
-
- @Override
- public void propertyChange(PropertyChangeEvent event) {
- checkWS();
- }
-}
+/******************************************************************************* + * Copyright (c) 2008, 2009, 2012 Intel Corporation, QNX Software Systems, 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: + * Intel Corporation - initial API and implementation + * QNX Software Systems - [272416] Rework the config sets dialog + * Freescale Semiconductor - [392954] disable the action if only empty working sets exist + *******************************************************************************/ +package org.eclipse.cdt.ui.actions; + +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.util.IPropertyChangeListener; +import org.eclipse.jface.util.PropertyChangeEvent; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.IWorkbenchWindowActionDelegate; +import org.eclipse.ui.IWorkingSet; +import org.eclipse.ui.IWorkingSetManager; + +import org.eclipse.cdt.ui.CUIPlugin; + +import org.eclipse.cdt.internal.ui.workingsets.WorkingSetConfigurationDialog; + +/** + */ +public class WorkingSetConfigAction implements IWorkbenchWindowActionDelegate, IPropertyChangeListener { + + private static final IWorkingSetManager wsm = CUIPlugin.getDefault().getWorkbench().getWorkingSetManager(); + private boolean enabled = true; + private IWorkbenchWindow window; + private IAction action; + + @Override + public void run(IAction action) { + this.action = action; + checkWS(); + if (enabled) { + new WorkingSetConfigurationDialog(window.getShell()).open(); + } + } + + @Override + public void selectionChanged(IAction action, ISelection selection) { + this.action = action; + checkWS(); + } + + @Override + public void dispose() { + wsm.removePropertyChangeListener(this); + } + + @Override + public void init(IWorkbenchWindow window) { + this.window = window; + wsm.addPropertyChangeListener(this); + checkWS(); + } + + private void checkWS() { + enabled = false; + IWorkingSet[] w = wsm.getWorkingSets(); + if (w == null) + w = new IWorkingSet[0]; + for (IWorkingSet ws : w) { + if (!ws.isEmpty()) { + enabled = true; + break; + } + } + if (action != null) { + action.setEnabled(enabled); + } + } + + @Override + public void propertyChange(PropertyChangeEvent event) { + checkWS(); + } +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/language/settings/providers/AbstractLanguageSettingProviderOptionPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/language/settings/providers/AbstractLanguageSettingProviderOptionPage.java index a9352ab0b77..298c620fac9 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/language/settings/providers/AbstractLanguageSettingProviderOptionPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/language/settings/providers/AbstractLanguageSettingProviderOptionPage.java @@ -1,88 +1,88 @@ -/*******************************************************************************
- * Copyright (c) 2010, 2012 Andrew Gvozdev 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:
- * Andrew Gvozdev - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.ui.language.settings.providers;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-
-import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider;
-import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager;
-import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage;
-import org.eclipse.cdt.ui.newui.AbstractCPropertyTab;
-
-import org.eclipse.cdt.internal.ui.language.settings.providers.LanguageSettingsProviderTab;
-
-/**
- * Abstract class to implement language settings providers Options page.
- *
- * <p>
- * <strong>EXPERIMENTAL</strong>. This class interface is not stable yet as
- * it is not currently clear how it may need to be used in future. Only bare
- * minimum is provided here at this point (CDT 8.1, Juno).
- * There is no guarantee that this API will work or that it will remain the same.
- * Please do not use this API without consulting with the CDT team.
- * </p>
- * @noextend This class is not intended to be subclassed by clients, only internally by CDT.
- *
- * @since 5.4
- */
-public abstract class AbstractLanguageSettingProviderOptionPage extends AbstractCOptionPage {
- protected LanguageSettingsProviderTab providerTab;
- protected String providerId;
-
- /**
- * Initialize the options page with the owning tab and provider ID.
- *
- * @param providerTab - provider tab which owns the options page.
- * @param providerId - ID of the provider the options page is for.
- */
- public void init(AbstractCPropertyTab providerTab, String providerId) {
- this.providerTab = (LanguageSettingsProviderTab) providerTab;
- this.providerId = providerId;
- }
-
- /**
- * Get provider being displayed on this Options Page.
- * @return provider.
- */
- public ILanguageSettingsProvider getProvider() {
- return LanguageSettingsManager.getRawProvider(providerTab.getProvider(providerId));
- }
-
- /**
- * Get working copy of the provider to allow its options to be modified.
- * @return working copy of the provider.
- */
- public ILanguageSettingsProvider getProviderWorkingCopy() {
- return providerTab.getWorkingCopy(providerId);
- }
-
- /**
- * Refresh provider item in the table and update buttons.
- * This method is intended for use by an Options Page of the provider.
- *
- * @param provider - provider item in the table to refresh.
- */
- public void refreshItem(ILanguageSettingsProvider provider) {
- providerTab.refreshItem(provider);
- }
-
- @Override
- public void performApply(IProgressMonitor monitor) throws CoreException {
- // normally should be handled by LanguageSettingsProviderTab
- }
-
- @Override
- public void performDefaults() {
- // normally should be handled by LanguageSettingsProviderTab
- }
-
-}
+/******************************************************************************* + * Copyright (c) 2010, 2012 Andrew Gvozdev 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: + * Andrew Gvozdev - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.ui.language.settings.providers; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; + +import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider; +import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager; +import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage; +import org.eclipse.cdt.ui.newui.AbstractCPropertyTab; + +import org.eclipse.cdt.internal.ui.language.settings.providers.LanguageSettingsProviderTab; + +/** + * Abstract class to implement language settings providers Options page. + * + * <p> + * <strong>EXPERIMENTAL</strong>. This class interface is not stable yet as + * it is not currently clear how it may need to be used in future. Only bare + * minimum is provided here at this point (CDT 8.1, Juno). + * There is no guarantee that this API will work or that it will remain the same. + * Please do not use this API without consulting with the CDT team. + * </p> + * @noextend This class is not intended to be subclassed by clients, only internally by CDT. + * + * @since 5.4 + */ +public abstract class AbstractLanguageSettingProviderOptionPage extends AbstractCOptionPage { + protected LanguageSettingsProviderTab providerTab; + protected String providerId; + + /** + * Initialize the options page with the owning tab and provider ID. + * + * @param providerTab - provider tab which owns the options page. + * @param providerId - ID of the provider the options page is for. + */ + public void init(AbstractCPropertyTab providerTab, String providerId) { + this.providerTab = (LanguageSettingsProviderTab) providerTab; + this.providerId = providerId; + } + + /** + * Get provider being displayed on this Options Page. + * @return provider. + */ + public ILanguageSettingsProvider getProvider() { + return LanguageSettingsManager.getRawProvider(providerTab.getProvider(providerId)); + } + + /** + * Get working copy of the provider to allow its options to be modified. + * @return working copy of the provider. + */ + public ILanguageSettingsProvider getProviderWorkingCopy() { + return providerTab.getWorkingCopy(providerId); + } + + /** + * Refresh provider item in the table and update buttons. + * This method is intended for use by an Options Page of the provider. + * + * @param provider - provider item in the table to refresh. + */ + public void refreshItem(ILanguageSettingsProvider provider) { + providerTab.refreshItem(provider); + } + + @Override + public void performApply(IProgressMonitor monitor) throws CoreException { + // normally should be handled by LanguageSettingsProviderTab + } + + @Override + public void performDefaults() { + // normally should be handled by LanguageSettingsProviderTab + } + +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/language/settings/providers/LanguageSettingsProvidersImages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/language/settings/providers/LanguageSettingsProvidersImages.java index 7317e6e8c4c..e88fe13eb06 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/language/settings/providers/LanguageSettingsProvidersImages.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/language/settings/providers/LanguageSettingsProvidersImages.java @@ -1,33 +1,33 @@ -/*******************************************************************************
- * Copyright (c) 2012, 2012 Andrew Gvozdev 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:
- * Andrew Gvozdev - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.ui.language.settings.providers;
-
-import java.net.URL;
-
-import org.eclipse.cdt.internal.ui.language.settings.providers.LanguageSettingsProviderAssociationManager;
-
-/**
- * Utility class to provide API for language settings providers images.
- *
- * @since 5.4
- */
-public class LanguageSettingsProvidersImages {
- /**
- * Get image URL for language settings provider with the given ID.
- *
- * @param providerId - ID of language settings provider.
- * @return image URL or {@code null}.
- */
- public static URL getImageUrl(String providerId) {
- return LanguageSettingsProviderAssociationManager.getImageUrl(providerId);
- }
-
-}
+/******************************************************************************* + * Copyright (c) 2012, 2012 Andrew Gvozdev 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: + * Andrew Gvozdev - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.ui.language.settings.providers; + +import java.net.URL; + +import org.eclipse.cdt.internal.ui.language.settings.providers.LanguageSettingsProviderAssociationManager; + +/** + * Utility class to provide API for language settings providers images. + * + * @since 5.4 + */ +public class LanguageSettingsProvidersImages { + /** + * Get image URL for language settings provider with the given ID. + * + * @param providerId - ID of language settings provider. + * @return image URL or {@code null}. + */ + public static URL getImageUrl(String providerId) { + return LanguageSettingsProviderAssociationManager.getImageUrl(providerId); + } + +} |