diff --git a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/AutotoolsProblemMarkerInfo.java b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/AutotoolsProblemMarkerInfo.java index 62f3489a245..195c39679bf 100644 --- a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/AutotoolsProblemMarkerInfo.java +++ b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/AutotoolsProblemMarkerInfo.java @@ -21,7 +21,7 @@ import org.eclipse.core.runtime.IPath; */ public class AutotoolsProblemMarkerInfo { - public static enum Type{PACKAGE, HEADER, PROG, FILE, GENERIC} + public static enum Type{PACKAGE, HEADER, PROG, LIB, FILE, GENERIC} private ProblemMarkerInfo marker; diff --git a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/ErrorParser.java b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/ErrorParser.java index a6725458419..ffd1ef57133 100644 --- a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/ErrorParser.java +++ b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/ErrorParser.java @@ -175,6 +175,8 @@ public class ErrorParser extends MarkerGenerator implements IErrorParser { return AutotoolsProblemMarkerInfo.Type.HEADER; if (typeString.equals("file")) return AutotoolsProblemMarkerInfo.Type.FILE; + if (typeString.equals("lib")) + return AutotoolsProblemMarkerInfo.Type.LIB; return null; } diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/GCCBuiltinSpecsDetectorTest.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/GCCBuiltinSpecsDetectorTest.java index b9dfedc77d3..870cc21e0c0 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/GCCBuiltinSpecsDetectorTest.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/GCCBuiltinSpecsDetectorTest.java @@ -147,6 +147,7 @@ public class GCCBuiltinSpecsDetectorTest extends BaseTestCase { detector.processLine("#define \t MACRO_1 VALUE"); detector.processLine("#define MACRO_2 \t VALUE"); detector.processLine("#define MACRO_3 VALUE \t"); + detector.processLine("#define MACRO_4 VALUE + 1"); detector.shutdownForLanguage(); detector.shutdown(); @@ -155,6 +156,7 @@ public class GCCBuiltinSpecsDetectorTest extends BaseTestCase { assertEquals(new CMacroEntry("MACRO_1", "VALUE", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY), entries.get(index++)); assertEquals(new CMacroEntry("MACRO_2", "VALUE", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY), entries.get(index++)); assertEquals(new CMacroEntry("MACRO_3", "VALUE", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY), entries.get(index++)); + assertEquals(new CMacroEntry("MACRO_4", "VALUE + 1", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY), entries.get(index++)); assertEquals(index, entries.size()); } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Builder.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Builder.java index 3f6b3818677..55f4995f5c3 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Builder.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Builder.java @@ -2522,7 +2522,13 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider * The function never returns number smaller than 1. */ public int getOptimalParallelJobNum() { - return Runtime.getRuntime().availableProcessors(); + // Bug 398426: On my Mac running parallel builds at full tilt hangs the desktop. + // Need to pull it back one. + int j = Runtime.getRuntime().availableProcessors(); + if (j > 1 && Platform.getOS().equals(Platform.OS_MACOSX)) + return j - 1; + else + return j; } /** diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/language/settings/providers/MBSLanguageSettingsProvider.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/language/settings/providers/MBSLanguageSettingsProvider.java index 3c66105c2ed..17bc5530c25 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/language/settings/providers/MBSLanguageSettingsProvider.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/language/settings/providers/MBSLanguageSettingsProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2011 Andrew Gvozdev and others. + * 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 @@ -12,7 +12,9 @@ package org.eclipse.cdt.managedbuilder.internal.language.settings.providers; import java.util.ArrayList; +import java.util.LinkedHashSet; import java.util.List; +import java.util.Set; import org.eclipse.cdt.core.AbstractExecutableExtensionBase; import org.eclipse.cdt.core.CCorePlugin; @@ -59,7 +61,7 @@ public class MBSLanguageSettingsProvider extends AbstractExecutableExtensionBase languageSettings = getLanguageSettings(rcDescription); } - List list = new ArrayList(); + Set set = new LinkedHashSet(); if (languageSettings != null) { for (ICLanguageSetting langSetting : languageSettings) { @@ -86,8 +88,8 @@ public class MBSLanguageSettingsProvider extends AbstractExecutableExtensionBase IStringVariableManager mngr = VariablesPlugin.getDefault().getStringVariableManager(); String projectRootedPath = mngr.generateVariableExpression("workspace_loc", rc.getProject().getName()) + Path.SEPARATOR + pathStr; //$NON-NLS-1$ ICLanguageSettingEntry projectRootedEntry = (ICLanguageSettingEntry) CDataUtil.createEntry(kind, projectRootedPath, projectRootedPath, null, entry.getFlags()); - if (! list.contains(projectRootedEntry)) { - list.add(projectRootedEntry); + if (!set.contains(projectRootedEntry)) { + set.add(projectRootedEntry); } } } catch (CdtVariableException e) { @@ -97,8 +99,8 @@ public class MBSLanguageSettingsProvider extends AbstractExecutableExtensionBase } } - if (! list.contains(entry)) { - list.add(entry); + if (!set.contains(entry)) { + set.add(entry); } } } @@ -107,7 +109,7 @@ public class MBSLanguageSettingsProvider extends AbstractExecutableExtensionBase } } } - return LanguageSettingsStorage.getPooledList(list); + return LanguageSettingsStorage.getPooledList(new ArrayList(set)); } /** diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/GCCBuiltinSpecsDetector.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/GCCBuiltinSpecsDetector.java index e821b0d72a2..5b8ded66a44 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/GCCBuiltinSpecsDetector.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/GCCBuiltinSpecsDetector.java @@ -45,7 +45,7 @@ public class GCCBuiltinSpecsDetector extends ToolchainBuiltinSpecsDetector imple new IncludePathOptionParser("#include <(\\S.*)>", "$1", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY), new IncludePathOptionParser("#framework <(\\S.*)>", "$1", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY | ICSettingEntry.FRAMEWORKS_MAC), new MacroOptionParser("#define\\s+(\\S*\\(.*?\\))\\s*(.*)", "$1", "$2", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY), - new MacroOptionParser("#define\\s+(\\S*)\\s*(\\S*)", "$1", "$2", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY), + new MacroOptionParser("#define\\s+(\\S*)\\s*(.*)", "$1", "$2", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY), }; /** diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/Messages.properties b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/Messages.properties index 59bc380dca0..ac4acf5dce1 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/Messages.properties +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/Messages.properties @@ -32,7 +32,7 @@ BuilderSettingsTab_8=&Expand Env. Variable Refs in Makefiles BuilderSettingsTab_9=Build settings BuilderSettingsTab_10=Stop on first build error BuilderSettingsTab_EnableParallelBuild=Enable parallel build -BuilderSettingsTab_UseOptimalJobs=Use number of processors ({0}) +BuilderSettingsTab_UseOptimalJobs=Use optimal jobs ({0}) BuilderSettingsTab_UseParallelJobs=Use parallel jobs: BuilderSettingsTab_UseUnlimitedJobs=Use unlimited jobs BuilderSettingsTab_14=Workbench Build Behavior diff --git a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/CodanFastCxxAstTestCase.java b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/CodanFastCxxAstTestCase.java index fda1349b053..6175ae8d035 100644 --- a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/CodanFastCxxAstTestCase.java +++ b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/CodanFastCxxAstTestCase.java @@ -35,7 +35,7 @@ import org.eclipse.cdt.core.parser.NullLogService; import org.eclipse.cdt.core.parser.ParserLanguage; import org.eclipse.cdt.core.parser.ParserMode; import org.eclipse.cdt.core.parser.ScannerInfo; -import org.eclipse.cdt.core.parser.tests.ast2.AST2BaseTest; +import org.eclipse.cdt.core.parser.tests.ast2.AST2TestBase; import org.eclipse.cdt.core.testplugin.util.TestSourceReader; import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor; import org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser; @@ -83,7 +83,7 @@ public abstract class CodanFastCxxAstTestCase extends TestCase { protected IASTTranslationUnit parse(String code, ParserLanguage lang, boolean gcc) { FileContent codeReader = FileContent.create("code.c", code.toCharArray()); IScannerInfo scannerInfo = new ScannerInfo(); - IScanner scanner = AST2BaseTest.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo); + IScanner scanner = AST2TestBase.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo); ISourceCodeParser parser2 = null; if (lang == ParserLanguage.CPP) { ICPPParserExtensionConfiguration config = null; diff --git a/core/org.eclipse.cdt.core.aix/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.core.aix/META-INF/MANIFEST.MF index 1ee36ed73f0..3faa5d1c085 100644 --- a/core/org.eclipse.cdt.core.aix/META-INF/MANIFEST.MF +++ b/core/org.eclipse.cdt.core.aix/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %fragmentName.aix Bundle-SymbolicName: org.eclipse.cdt.core.aix; singleton:=true -Bundle-Version: 5.1.1.qualifier +Bundle-Version: 5.3.0.qualifier Bundle-Vendor: %providerName Fragment-Host: org.eclipse.cdt.core;bundle-version="[5.0.0,6.0.0)" Bundle-Localization: plugin diff --git a/core/org.eclipse.cdt.core.aix/library/PTY.h b/core/org.eclipse.cdt.core.aix/library/PTY.h index 46a8dd9b622..f717942a01d 100644 --- a/core/org.eclipse.cdt.core.aix/library/PTY.h +++ b/core/org.eclipse.cdt.core.aix/library/PTY.h @@ -7,14 +7,21 @@ #ifdef __cplusplus extern "C" { #endif -/* Inaccessible static: hasPTY */ /* * Class: org_eclipse_cdt_utils_pty_PTY * Method: openMaster - * Signature: ()Ljava/lang/String; + * Signature: (Z)Ljava/lang/String; */ JNIEXPORT jstring JNICALL Java_org_eclipse_cdt_utils_pty_PTY_openMaster - (JNIEnv *, jobject); + (JNIEnv *, jobject, jboolean); + +/* + * Class: org_eclipse_cdt_utils_pty_PTY + * Method: change_window_size + * Signature: (III)I + */ +JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTY_change_1window_1size + (JNIEnv *, jobject, jint, jint, jint); #ifdef __cplusplus } diff --git a/core/org.eclipse.cdt.core.aix/library/Spawner.h b/core/org.eclipse.cdt.core.aix/library/Spawner.h index 272366bad75..e2fea946912 100644 --- a/core/org.eclipse.cdt.core.aix/library/Spawner.h +++ b/core/org.eclipse.cdt.core.aix/library/Spawner.h @@ -29,7 +29,7 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec1 * Signature: ([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[ILjava/lang/String;I)I */ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec2 - (JNIEnv *, jobject, jobjectArray, jobjectArray, jstring, jintArray, jstring, jint); + (JNIEnv *, jobject, jobjectArray, jobjectArray, jstring, jintArray, jstring, jint, jboolean); /* * Class: org_eclipse_cdt_utils_spawner_Spawner diff --git a/core/org.eclipse.cdt.core.aix/library/exec0.h b/core/org.eclipse.cdt.core.aix/library/exec0.h index f0e88f36efe..630e741a582 100644 --- a/core/org.eclipse.cdt.core.aix/library/exec0.h +++ b/core/org.eclipse.cdt.core.aix/library/exec0.h @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2008 IBM Corporation and others. + * Copyright (c) 2003, 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 @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * IBM Corporation - port of 248071 *******************************************************************************/ #include @@ -16,7 +17,13 @@ #include extern pid_t exec0(const char *path, char *const argv[], - char *const envp[], const char *dirpath, - int channels[3] ); + 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.aix/library/exec_pty.c b/core/org.eclipse.cdt.core.aix/library/exec_pty.c index 9eb60cf17e1..2c3a03ee0d4 100644 --- a/core/org.eclipse.cdt.core.aix/library/exec_pty.c +++ b/core/org.eclipse.cdt.core.aix/library/exec_pty.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004 QNX Software Systems and others. + * Copyright (c) 2004, 2013 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 @@ -7,6 +7,7 @@ * * Contributors: * QNX Software Systems - initial API and implementation + * IBM Corporation - port of 248071 *******************************************************************************/ #include "exec0.h" @@ -20,11 +21,11 @@ #include /* from pfind.c */ -extern char *pfind(const char *name); +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) + const char *dirpath, int channels[3], const char *pts_name, int fdm, int console) { int pipe2[2]; pid_t childpid; @@ -34,7 +35,7 @@ exec_pty(const char *path, char *const argv[], char *const envp[], * 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); + full_path = pfind(path, envp); if (full_path == NULL) { fprintf(stderr, "Unable to find full path for \"%s\"\n", (path) ? path : ""); return -1; @@ -43,7 +44,7 @@ exec_pty(const char *path, char *const argv[], char *const envp[], /* * Make sure we can create our pipes before forking. */ - if (channels != NULL) { + 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); @@ -64,6 +65,11 @@ exec_pty(const char *path, char *const argv[], char *const envp[], 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)); @@ -71,17 +77,28 @@ exec_pty(const char *path, char *const argv[], char *const envp[], } /* Close the read end of pipe2 */ - if (close(pipe2[0]) == -1) + if (console && close(pipe2[0]) == -1) perror("close(pipe2[0]))"); /* close the master, no need in the child */ close(fdm); - set_noecho(fds); + 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 */ - dup2(pipe2[1], STDERR_FILENO); /* dup stderr */ + if (console) { + dup2(pipe2[1], STDERR_FILENO); /* dup stderr */ + } else { + dup2(fds, STDERR_FILENO); /* dup stderr */ + } close(fds); /* done with fds. */ } @@ -104,16 +121,20 @@ exec_pty(const char *path, char *const argv[], char *const envp[], } else if (childpid != 0) { /* parent */ - set_noecho(fdm); + if (console) { + set_noecho(fdm); + } if (channels != NULL) { - /* close the write end of pipe1 */ - if (close(pipe2[1]) == -1) - perror("close(pipe2[1])"); - channels[0] = fdm; /* Input Stream. */ channels[1] = fdm; /* Output Stream. */ - channels[2] = pipe2[0]; /* stderr Stream. */ - /*channels[2] = fdm; Input 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); diff --git a/core/org.eclipse.cdt.core.aix/library/exec_unix.c b/core/org.eclipse.cdt.core.aix/library/exec_unix.c index a8399643a39..8c71787b618 100644 --- a/core/org.eclipse.cdt.core.aix/library/exec_unix.c +++ b/core/org.eclipse.cdt.core.aix/library/exec_unix.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2008 IBM Corporation and others. + * Copyright (c) 2003, 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 @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * IBM Corporation - port of 248071 *******************************************************************************/ #include "exec0.h" @@ -19,7 +20,7 @@ #include /* from pfind.c */ -extern char *pfind(const char *name); +extern char *pfind(const char *name, char * const envp[]); pid_t exec0(const char *path, char *const argv[], char *const envp[], @@ -33,7 +34,7 @@ exec0(const char *path, char *const argv[], char *const envp[], * 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); + full_path = pfind(path, envp); if (full_path == NULL) { fprintf(stderr, "Unable to find full path for \"%s\"\n", (path) ? path : ""); return -1; @@ -91,6 +92,8 @@ exec0(const char *path, char *const argv[], char *const envp[], close(fd++); } + setpgid(getpid(), getpid()); + if (envp[0] == NULL) { execv(full_path, argv); } else { @@ -135,9 +138,19 @@ int wait0(pid_t pid) int status; int val = -1; - if (pid < 0 || waitpid(pid, &status, 0) < 0) + 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); } diff --git a/core/org.eclipse.cdt.core.aix/library/openpty.c b/core/org.eclipse.cdt.core.aix/library/openpty.c index 954b2b6b852..2207e682532 100644 --- a/core/org.eclipse.cdt.core.aix/library/openpty.c +++ b/core/org.eclipse.cdt.core.aix/library/openpty.c @@ -30,7 +30,7 @@ */ int ptym_open (char *pts_name); -int ptys_open (int fdm, char * pts_name); +int ptys_open (int fdm, const char * pts_name); void set_noecho(int fd); int diff --git a/core/org.eclipse.cdt.core.aix/library/openpty.h b/core/org.eclipse.cdt.core.aix/library/openpty.h index d07317e883b..21c98ac82fd 100644 --- a/core/org.eclipse.cdt.core.aix/library/openpty.h +++ b/core/org.eclipse.cdt.core.aix/library/openpty.h @@ -1,5 +1,5 @@ -/******************************************************************************* - * Copyright (c) 2003, 2008 IBM Corporation and others. +/****************************************************************************** + * Copyright (c) 2003, 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 @@ -8,11 +8,12 @@ * Contributors: * IBM Corporation - initial API and implementation * QNX Software Systems + * IBM Corporation - port of 248071 *******************************************************************************/ #ifndef _OPENPTY_H #define _OPENPTY_H int ptym_open (char *pts_name); -int ptys_open (int fdm, char * pts_name); +int ptys_open (int fdm, const char * pts_name); void set_noecho(int fd); #endif diff --git a/core/org.eclipse.cdt.core.aix/library/pfind.c b/core/org.eclipse.cdt.core.aix/library/pfind.c index ba64f8d6e7d..b97942e298d 100644 --- a/core/org.eclipse.cdt.core.aix/library/pfind.c +++ b/core/org.eclipse.cdt.core.aix/library/pfind.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2008 IBM Corporation and others. + * Copyright (c) 2003, 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 @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * IBM Corporation - port of 248071 *******************************************************************************/ /* @@ -23,8 +24,25 @@ #define PATH_MAX 1024 #endif +#define PATH_DEF "PATH=" +const int path_def_len = 5; /* strlen(PATH_DEF); */ +char * path_val(char * const envp[]) +{ + int i; + if (envp == NULL || envp[0] == NULL) + return getenv("PATH" ); + + for(i = 0; envp[i] != NULL; i++){ + char* p = envp[i]; + if(!strncmp(PATH_DEF, p, path_def_len)){ + return p + path_def_len; + } + } + + return NULL; +} -char * pfind(const char *name) +char * pfind(const char *name, char * const envp[]) { char *tok; char *sp; @@ -46,7 +64,7 @@ char * pfind(const char *name) } /* Search in the PATH environment. */ - path = getenv("PATH" ); + path = path_val( envp ); if (path == NULL || strlen(path) <= 0) { fprintf(stderr, "Unable to get $PATH.\n"); @@ -79,7 +97,7 @@ int main(int argc, char **argv) char *fullpath; for (i=1; i #include "PTY.h" #include "openpty.h" @@ -19,7 +20,7 @@ * Signature: ()I */ JNIEXPORT jstring JNICALL -Java_org_eclipse_cdt_utils_pty_PTY_openMaster (JNIEnv *env, jobject jobj) { +Java_org_eclipse_cdt_utils_pty_PTY_openMaster (JNIEnv *env, jobject jobj, jboolean console) { jfieldID fid; /* Store the field ID */ jstring jstr = NULL; int master = -1; @@ -30,8 +31,10 @@ Java_org_eclipse_cdt_utils_pty_PTY_openMaster (JNIEnv *env, jobject jobj) { master = ptym_open(line); if (master >= 0) { - /* turn off echo */ - set_noecho(master); + // turn off echo + if (console) { + set_noecho(master); + } /* Get a reference to the obj's class */ cls = (*env)->GetObjectClass(env, jobj); @@ -48,3 +51,22 @@ Java_org_eclipse_cdt_utils_pty_PTY_openMaster (JNIEnv *env, jobject jobj) { } return jstr; } + +JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTY_change_1window_1size + (JNIEnv *env, jobject jobj, jint fdm, jint width, jint height) +{ +#ifdef TIOCGWINSZ + struct winsize win; + + win.ws_col = width; + win.ws_row = height; + win.ws_xpixel = 0; + win.ws_ypixel = 0; + + return ioctl(fdm, TIOCSWINSZ, &win); +#else + return 0; +#endif +} + + diff --git a/core/org.eclipse.cdt.core.aix/library/spawner.c b/core/org.eclipse.cdt.core.aix/library/spawner.c index b8707ca0e2b..710ae08e1de 100644 --- a/core/org.eclipse.cdt.core.aix/library/spawner.c +++ b/core/org.eclipse.cdt.core.aix/library/spawner.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2008 IBM Corporation and others. + * Copyright (c) 2003, 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 @@ -8,6 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation * QNX Software Systems + * IBM Corporation - port of 248071 *******************************************************************************/ #include @@ -90,13 +91,13 @@ static void free_c_array(char **c_array) */ 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) + 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; - char **envp; + char **cmd = NULL; + char **envp = NULL; int fd[3]; pid_t pid = -1; @@ -120,7 +121,7 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec2 fprintf(stderr, "pts_name: %s\n", pts_name); #endif - pid = exec_pty(cmd[0], cmd, envp, dirpath, fd, pts_name, masterFD); + pid = exec_pty(cmd[0], cmd, envp, dirpath, fd, pts_name, masterFD, console); if (pid < 0) goto bail_out; @@ -147,8 +148,8 @@ Java_org_eclipse_cdt_utils_spawner_Spawner_exec1(JNIEnv * env, jobject jobj, jstring jdir) { const char *dirpath = (*env)->GetStringUTFChars(env, jdir, NULL); - char **cmd; - char **envp; + char **cmd = NULL; + char **envp = NULL; pid_t pid = -1; cmd = alloc_c_array(env, jcmd); @@ -194,8 +195,8 @@ Java_org_eclipse_cdt_utils_spawner_Spawner_exec0(JNIEnv * env, jobject jobj, { jint *channels = (*env)->GetIntArrayElements(env, jchannels, 0); const char *dirpath = (*env)->GetStringUTFChars(env, jdir, NULL); - char **cmd; - char **envp; + char **cmd = NULL; + char **envp = NULL; int fd[3]; pid_t pid = -1; diff --git a/core/org.eclipse.cdt.core.aix/os/aix/ppc/libpty.so b/core/org.eclipse.cdt.core.aix/os/aix/ppc/libpty.so index d5aed7004d4..8caa860f81b 100644 Binary files a/core/org.eclipse.cdt.core.aix/os/aix/ppc/libpty.so and b/core/org.eclipse.cdt.core.aix/os/aix/ppc/libpty.so differ diff --git a/core/org.eclipse.cdt.core.aix/os/aix/ppc/libspawner.so b/core/org.eclipse.cdt.core.aix/os/aix/ppc/libspawner.so index 26dccd762c1..386d68ced3a 100644 Binary files a/core/org.eclipse.cdt.core.aix/os/aix/ppc/libspawner.so and b/core/org.eclipse.cdt.core.aix/os/aix/ppc/libspawner.so differ diff --git a/core/org.eclipse.cdt.core.aix/pom.xml b/core/org.eclipse.cdt.core.aix/pom.xml index 10b13960c8a..e2d76453c16 100644 --- a/core/org.eclipse.cdt.core.aix/pom.xml +++ b/core/org.eclipse.cdt.core.aix/pom.xml @@ -11,7 +11,7 @@ ../../pom.xml - 5.1.1-SNAPSHOT + 5.3.0-SNAPSHOT org.eclipse.cdt.core.aix eclipse-plugin diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/FileBasePluginTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/FileBasePluginTestCase.java similarity index 59% rename from core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/FileBasePluginTest.java rename to core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/FileBasePluginTestCase.java index 57601678d90..12a869f2466 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/FileBasePluginTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/FileBasePluginTestCase.java @@ -8,10 +8,6 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ - -/* - * Created on Sept 28, 2004 - */ package org.eclipse.cdt.core.parser.tests; import java.io.ByteArrayInputStream; @@ -36,127 +32,110 @@ import org.eclipse.core.runtime.NullProgressMonitor; /** * @author dsteffle */ -public class FileBasePluginTest extends TestCase { +public class FileBasePluginTestCase extends TestCase { static NullProgressMonitor monitor; static IWorkspace workspace; static IProject project; static FileManager fileManager; - static int numProjects = 0; + static int numProjects; static Class className; static ICProject cPrj; - public FileBasePluginTest() { + public FileBasePluginTestCase() { } - public FileBasePluginTest(String name) { + public FileBasePluginTestCase(String name) { super(name); } - private void initialize(Class aClassName){ - if( CCorePlugin.getDefault() != null && CCorePlugin.getDefault().getCoreModel() != null){ + private void initialize(Class aClassName) { + if (CCorePlugin.getDefault() != null && CCorePlugin.getDefault().getCoreModel() != null) { //(CCorePlugin.getDefault().getCoreModel().getIndexManager()).reset(); monitor = new NullProgressMonitor(); - + workspace = ResourcesPlugin.getWorkspace(); - + try { cPrj = CProjectHelper.createCCProject("ParserTestProject", "bin", IPDOMManager.ID_NO_INDEXER); //$NON-NLS-1$ //$NON-NLS-2$ project = cPrj.getProject(); - + // ugly if (className == null || !className.equals(aClassName)) { className = aClassName; numProjects++; } - } catch ( CoreException e ) { - /*boo*/ + } catch (CoreException e) { + // Ignore } if (project == null) throw new NullPointerException("Unable to create project"); //$NON-NLS-1$ - + //Create file manager fileManager = new FileManager(); } } - public FileBasePluginTest(String name, Class className) - { + public FileBasePluginTestCase(String name, Class className) { super(name); initialize(className); } - + public void cleanupProject() throws Exception { numProjects--; - - try{ + + try { if (numProjects == 0) { - project.delete( true, false, monitor ); + project.delete(true, false, monitor); project = null; } - } catch( Throwable e ){ - /*boo*/ + } catch (Throwable e) { + // Ignore } } @Override protected void tearDown() throws Exception { - if( project == null || !project.exists() ) + if (project == null || !project.exists()) return; - + IResource [] members = project.members(); - for( int i = 0; i < members.length; i++ ){ - if( members[i].getName().equals( ".project" ) || members[i].getName().equals( ".cproject" ) ) //$NON-NLS-1$ //$NON-NLS-2$ + for (int i = 0; i < members.length; i++) { + if (members[i].getName().equals(".project") || members[i].getName().equals(".cproject")) //$NON-NLS-1$ //$NON-NLS-2$ continue; if (members[i].getName().equals(".settings")) continue; - try{ - members[i].delete( false, monitor ); - } catch( Throwable e ){ - /*boo*/ + try { + members[i].delete(false, monitor); + } catch (Throwable e) { + // Ignore } } } - // below can be used to work with large files (too large for memory) -// protected IFile importFile(String fileName) throws Exception { -// IFile file = cPrj.getProject().getFile(fileName); -// if (!file.exists()) { -// try{ -// FileInputStream fileIn = new FileInputStream( -// CTestPlugin.getDefault().getFileInPlugin(new Path("resources/parser/" + fileName))); -// file.create(fileIn,false, monitor); -// } catch (CoreException e) { -// e.printStackTrace(); -// } catch (FileNotFoundException e) { -// e.printStackTrace(); -// } -// } -// -// return file; -// } - protected IFolder importFolder(String folderName) throws Exception { IFolder folder = project.getProject().getFolder(folderName); - - //Create file input stream - if( !folder.exists() ) - folder.create( false, false, monitor ); - + + // Create file input stream + if (!folder.exists()) + folder.create(false, false, monitor); + return folder; } - public IFile importFile(String fileName, String contents ) throws Exception{ - //Obtain file handle + + public IFile importFile(String fileName, String contents) throws Exception { + // Obtain file handle IFile file = project.getProject().getFile(fileName); - - InputStream stream = new ByteArrayInputStream( contents.getBytes() ); - //Create file input stream - if( file.exists() ) - file.setContents( stream, false, false, monitor ); - else - file.create( stream, false, monitor ); - + + InputStream stream = new ByteArrayInputStream(contents.getBytes()); + // Create file input stream + if (file.exists()) { + file.setContents(stream, false, false, monitor); + } else { + file.create(stream, false, monitor); + } + fileManager.addFile(file); - + return file; } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPImplicitNameTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPImplicitNameTests.java index 002916af926..3d4d2c70d0f 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPImplicitNameTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPImplicitNameTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 IBM Corporation and others. + * Copyright (c) 2009, 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 @@ -9,6 +9,7 @@ * Mike Kucera (IBM) * Sergey Prigogin (Google) * Markus Schorn (Wind River Systems) + * Nathan Ridge *******************************************************************************/ package org.eclipse.cdt.core.parser.tests.ast2; @@ -28,19 +29,19 @@ import org.eclipse.cdt.core.parser.ParserLanguage; /** * Tests for classes implementing IASTImplicitNameOwner interface. */ -public class AST2CPPImplicitNameTests extends AST2BaseTest { +public class AST2CPPImplicitNameTests extends AST2TestBase { public AST2CPPImplicitNameTests() { } - + public AST2CPPImplicitNameTests(String name) { super(name); } - + public static TestSuite suite() { return suite(AST2CPPImplicitNameTests.class); } - + public IASTImplicitName[] getImplicitNames(IASTTranslationUnit tu, String contents, String section, int len) { final int offset = contents.indexOf(section); assertTrue(offset >= 0); @@ -75,25 +76,25 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest { CPPNameCollector col = new CPPNameCollector(); tu.accept(col); IASTImplicitName n; - + n = ba.assertImplicitName("+= 5", 2, ICPPMethod.class); assertSame(n.resolveBinding(), col.getName(14).resolveBinding()); - + n = ba.assertImplicitName("+ p", 1, ICPPMethod.class); assertSame(n.resolveBinding(), col.getName(4).resolveBinding()); - + n = ba.assertImplicitName("- p", 1, ICPPMethod.class); assertSame(n.resolveBinding(), col.getName(8).resolveBinding()); - + n = ba.assertImplicitName("* p", 1, ICPPFunction.class); assertSame(n.resolveBinding(), col.getName(17).resolveBinding()); - + n = ba.assertImplicitName("/ p", 1, ICPPFunction.class); assertSame(n.resolveBinding(), col.getName(23).resolveBinding()); - + n = ba.assertImplicitName("-p;", 1, ICPPMethod.class); assertSame(n.resolveBinding(), col.getName(12).resolveBinding()); - + ba.assertNoImplicitName("<< 6", 2); ba.assertNoImplicitName("+p;", 1); } @@ -136,9 +137,9 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest { IASTTranslationUnit tu = ba.getTranslationUnit(); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ba.assertNoImplicitName("&Y::x;", 1); - + IASTImplicitName n = ba.assertImplicitName("&y;", 1, ICPPFunction.class); assertSame(n.resolveBinding(), col.getName(9).resolveBinding()); } @@ -165,20 +166,20 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest { // p2->doA(); // } public void testArrowOperator() throws Exception { - String contents = getAboveComment(); + String contents = getAboveComment(); IASTTranslationUnit tu = parse(contents, ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + IASTImplicitName[] implicits = getImplicitNames(tu, contents, "->doA();", 2); - + assertNotNull(implicits); assertEquals(2, implicits.length); - + assertSame(implicits[1].getBinding(), col.getName(4).resolveBinding()); assertSame(implicits[0].getBinding(), col.getName(12).resolveBinding()); } - + // struct A { // int x; // }; @@ -224,15 +225,15 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest { ba.assertNoImplicitName(", b, c, d); // func", 1); ba.assertNoImplicitName(", c, d); // func", 1); ba.assertNoImplicitName(", d); // func", 1); - + IASTImplicitName opAB = ba.assertImplicitName(", b, c, d; // expr", 1, ICPPFunction.class); IASTImplicitName opCC = ba.assertImplicitName(", c, d; // expr", 1, ICPPFunction.class); ba.assertNoImplicitName(", d; // expr", 1); - + IASTTranslationUnit tu = ba.getTranslationUnit(); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + assertSame(opAB.resolveBinding(), col.getName(5).resolveBinding()); assertSame(opCC.resolveBinding(), col.getName(11).resolveBinding()); } @@ -255,20 +256,20 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest { // } public void testCommaOperator2() throws Exception { BindingAssertionHelper ba = new BindingAssertionHelper(getAboveComment(), true); - + IASTImplicitName opAB = ba.assertImplicitName(", b, c, d", 1, ICPPMethod.class); IASTImplicitName opCC = ba.assertImplicitName(", c, d", 1, ICPPFunction.class); IASTImplicitName opDD = ba.assertImplicitName(", d", 1, ICPPMethod.class); - + IASTTranslationUnit tu = ba.getTranslationUnit(); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + // 6, 11, 15 assertSame(opAB.resolveBinding(), col.getName(6).resolveBinding()); assertSame(opCC.resolveBinding(), col.getName(15).resolveBinding()); assertSame(opDD.resolveBinding(), col.getName(11).resolveBinding()); - + ba.assertNonProblem("ee;", 2); } @@ -289,7 +290,7 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest { IASTTranslationUnit tu = ba.getTranslationUnit(); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + IASTImplicitName n1 = ba.assertImplicitName("(b); // 1", 1, ICPPMethod.class); IASTImplicitName n2 = ba.assertImplicitName("); // 1", 1, ICPPMethod.class); assertSame(n1.resolveBinding(), n2.resolveBinding()); @@ -298,14 +299,14 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest { // there should be no overlap ba.assertNoImplicitName("b); // 1", 1); assertSame(col.getName(1).resolveBinding(), n1.resolveBinding()); - + n1 = ba.assertImplicitName("(); // 2", 1, ICPPMethod.class); n2 = ba.assertImplicitName("); // 2", 1, ICPPMethod.class); assertSame(n1.resolveBinding(), n2.resolveBinding()); assertFalse(n1.isAlternate()); assertTrue(n2.isAlternate()); assertSame(col.getName(3).resolveBinding(), n1.resolveBinding()); - + n1 = ba.assertImplicitName("(1, 2); // 3", 1, ICPPMethod.class); n2 = ba.assertImplicitName("); // 3", 1, ICPPMethod.class); assertSame(n1.resolveBinding(), n2.resolveBinding()); @@ -348,7 +349,7 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest { IASTTranslationUnit tu = ba.getTranslationUnit(); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + IASTImplicitName n1 = ba.assertImplicitName("[0]); //1", 1, ICPPMethod.class); ba.assertNoImplicitName("0]); //1", 1); IASTImplicitName n2 = ba.assertImplicitName("]); //1", 1, ICPPMethod.class); @@ -356,7 +357,7 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest { assertFalse(n1.isAlternate()); assertTrue(n2.isAlternate()); assertSame(col.getName(1).resolveBinding(), n1.resolveBinding()); - + n1 = ba.assertImplicitName("[q]); //2", 1, ICPPMethod.class); ba.assertNoImplicitName("q]); //2", 1); n2 = ba.assertImplicitName("]); //2", 1, ICPPMethod.class); @@ -384,21 +385,21 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest { assertEquals(2, names.length); IASTImplicitName destructor = names[0]; IASTImplicitName delete = names[1]; - + IASTTranslationUnit tu = ba.getTranslationUnit(); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + assertSame(col.getName(1).resolveBinding(), destructor.resolveBinding()); assertSame(col.getName(2).resolveBinding(), delete.resolveBinding()); - + names = ba.getImplicitNames("delete[] x;", 6); assertEquals(1, names.length); assertSame(col.getName(4).resolveBinding(), names[0].resolveBinding()); - + ba.assertNoImplicitName("delete 1;", 6); } - + // struct A { // void operator delete(void * a); // }; @@ -416,15 +417,15 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest { BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), true); IBinding m= bh.assertNonProblem("operator delete(void * a)", 15); IBinding f= bh.assertNonProblem("operator delete(void * b)", 15); - + IASTImplicitName[] names = bh.getImplicitNames("delete a;", 6); - assertEquals(2, names.length); + assertEquals(2, names.length); assertTrue(((ICPPMethod) names[0].resolveBinding()).isDestructor()); assertSame(m, names[1].resolveBinding()); names = bh.getImplicitNames("delete b;", 6); assertTrue(((ICPPMethod) names[0].resolveBinding()).isDestructor()); - assertEquals(2, names.length); + assertEquals(2, names.length); assertSame(f, names[1].resolveBinding()); } @@ -443,13 +444,13 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest { BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), true); IBinding m= bh.assertNonProblem("operator new(size_t a)", 12); IBinding f= bh.assertNonProblem("operator new(size_t b)", 12); - + IASTImplicitName[] names = bh.getImplicitNames("new A;", 3); - assertEquals(1, names.length); + assertEquals(2, names.length); assertSame(m, names[0].resolveBinding()); names = bh.getImplicitNames("new B;", 3); - assertEquals(1, names.length); + assertEquals(2, names.length); assertSame(f, names[0].resolveBinding()); } @@ -461,9 +462,9 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest { public void testImplicitNewAndDelete() throws Exception { BindingAssertionHelper ba = new BindingAssertionHelper(getAboveComment(), true); ba.assertNoImplicitName("new X", 3); - ba.assertNoImplicitName("delete[]", 6); + ba.assertNoImplicitName("delete[]", 6); } - + // typedef long unsigned int size_t // struct nothrow_t {}; // extern const nothrow_t nothrow; @@ -491,7 +492,7 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest { assertSame(col.getName(9).resolveBinding(), n2.resolveBinding()); assertSame(col.getName(14).resolveBinding(), n3.resolveBinding()); } - + // int test() { // throw; // } @@ -551,7 +552,7 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest { IASTImplicitName v = ba.assertImplicitName("v(p)", 1, ICPPConstructor.class); assertSame(ctor1, v.resolveBinding()); } - + // enum A {aa}; // struct B{ operator A();}; // bool operator==(A, A); // overrides the built-in operator. @@ -567,5 +568,5 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest { ICPPFunction op = ba.assertNonProblem("operator==", 0); IASTImplicitName a = ba.assertImplicitName("==b", 2, ICPPFunction.class); assertSame(op, a.resolveBinding()); - } + } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecTest.java index ef4f48076d4..5f28ad59cf6 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecTest.java @@ -46,7 +46,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; /** * Examples taken from the c++-specification. */ -public class AST2CPPSpecTest extends AST2SpecBaseTest { +public class AST2CPPSpecTest extends AST2SpecTestBase { public AST2CPPSpecTest() { } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java index 5908699d91c..b7f7c8bee72 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2012 IBM Corporation and others. + * Copyright (c) 2004, 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 @@ -139,7 +139,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; import org.eclipse.cdt.internal.core.index.IndexCPPSignatureUtil; import org.eclipse.cdt.internal.core.parser.ParserException; -public class AST2CPPTests extends AST2BaseTest { +public class AST2CPPTests extends AST2TestBase { public AST2CPPTests() { } @@ -260,7 +260,7 @@ public class AST2CPPTests extends AST2BaseTest { assertEquals(declNames.length, i); assertEquals(defNames.length, j); } - + @Override protected void assertSameType(IType first, IType second){ assertNotNull(first); @@ -1201,10 +1201,10 @@ public class AST2CPPTests extends AST2BaseTest { // } public void testVirtualParentLookup() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); - CPPNameCollector collector = new CPPNameCollector(); + CPPNameCollector collector = new CPPNameCollector(true); tu.accept(collector); - assertEquals(collector.size(), 15); + assertEquals(collector.size(), 16); ICPPClassType D = (ICPPClassType) collector.getName(0).resolveBinding(); ICPPField x = (ICPPField) collector.getName(1).resolveBinding(); @@ -1215,7 +1215,7 @@ public class AST2CPPTests extends AST2BaseTest { assertInstances(collector, D, 3); assertInstances(collector, C, 2); assertInstances(collector, B, 2); - assertInstances(collector, A, 2); + assertInstances(collector, A, 3); assertInstances(collector, ctor, 1); assertInstances(collector, x, 2); } @@ -1230,10 +1230,10 @@ public class AST2CPPTests extends AST2BaseTest { // } public void testAmbiguousVirtualParentLookup() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); - CPPNameCollector collector = new CPPNameCollector(); + CPPNameCollector collector = new CPPNameCollector(true); tu.accept(collector); - assertEquals(collector.size(), 15); + assertEquals(collector.size(), 16); ICPPClassType D = (ICPPClassType) collector.getName(0).resolveBinding(); ICPPField x1 = (ICPPField) collector.getName(1).resolveBinding(); @@ -1241,13 +1241,13 @@ public class AST2CPPTests extends AST2BaseTest { ICPPClassType B = (ICPPClassType) collector.getName(4).resolveBinding(); ICPPClassType A = (ICPPClassType) collector.getName(6).resolveBinding(); ICPPConstructor ctor = A.getConstructors()[0]; - IProblemBinding x2 = (IProblemBinding) collector.getName(14).resolveBinding(); + IProblemBinding x2 = (IProblemBinding) collector.getName(15).resolveBinding(); assertEquals(x2.getID(), IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP); assertInstances(collector, D, 3); assertInstances(collector, C, 2); assertInstances(collector, B, 2); - assertInstances(collector, A, 2); + assertInstances(collector, A, 3); assertInstances(collector, ctor, 1); assertInstances(collector, x1, 1); } @@ -1843,7 +1843,7 @@ public class AST2CPPTests extends AST2BaseTest { ICPPMethod dtor = (ICPPMethod) col.getName(13).resolveBinding(); assertNotNull(dtor); assertEquals(dtor.getName(), "~C"); //$NON-NLS-1$ - assertInstances(col, C, 6); + assertInstances(col, C, 7); assertInstances(col, op, 3); assertInstances(col, other, 4); @@ -1993,7 +1993,7 @@ public class AST2CPPTests extends AST2BaseTest { assertInstances(col, pb, 2); assertInstances(col, mutate, 2); - assertInstances(col, B, 2); + assertInstances(col, B, 3); } // struct S { int i; }; @@ -2511,7 +2511,7 @@ public class AST2CPPTests extends AST2BaseTest { // } public void testBug86267() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); - CPPNameCollector col = new CPPNameCollector(); + CPPNameCollector col = new CPPNameCollector(true); tu.accept(col); ICPPClassType D1 = (ICPPClassType) col.getName(2).resolveBinding(); @@ -2549,7 +2549,7 @@ public class AST2CPPTests extends AST2BaseTest { ICPPMethod op = (ICPPMethod) col.getName(3).resolveBinding(); IParameter other = (IParameter) col.getName(5).resolveBinding(); - assertInstances(col, C, 6); + assertInstances(col, C, 7); assertInstances(col, f, 2); assertInstances(col, op, 3); assertInstances(col, other, 4); @@ -4052,11 +4052,11 @@ public class AST2CPPTests extends AST2BaseTest { // X x = new X(y); public void testBug90654_1() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); - CPPNameCollector col = new CPPNameCollector(); + CPPNameCollector col = new CPPNameCollector(true); tu.accept(col); ICPPConstructor ctor1 = (ICPPConstructor) col.getName(1).resolveBinding(); - ICPPConstructor ctor = (ICPPConstructor) col.getName(11).resolveBinding(); + ICPPConstructor ctor = (ICPPConstructor) col.getName(12).resolveBinding(); assertSame(ctor, ctor1); } @@ -8382,20 +8382,24 @@ public class AST2CPPTests extends AST2BaseTest { // fH({1}); // H(G(1)) // } public void testListInitialization_302412f() throws Exception { - ICPPConstructor ctor; IProblemBinding problem; String code= getAboveComment(); BindingAssertionHelper bh= new BindingAssertionHelper(code, true); bh.assertProblem("f({1,1})", 1); - ctor= bh.assertNonProblem("F({1,1})", 1); + bh.assertImplicitName("F({1,1})", 1, ICPPConstructor.class); bh.assertNonProblem("fF({1,1})", 2); bh.assertNonProblem("fG(1)", 2); bh.assertNonProblem("fG({1})", 2); - ctor= bh.assertNonProblem("H(1)", 1); - problem= bh.assertProblem("H({1})", 1); - assertEquals(IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, problem.getID()); + bh.assertImplicitName("H(1)", 1, ICPPConstructor.class); + bh.assertNoImplicitName("H({1})", 1); + // TODO(nathanridge): Perhaps we should store implicit names even if they + // resolve to ProblemBindings. Then we can do the stronger check in the + // 3 commented lines below. + //IASTImplicitName n= bh.assertImplicitName("H({1})", 1, IProblemBinding.class); + //problem= (IProblemBinding) n.resolveBinding(); + //assertEquals(IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, problem.getID()); bh.assertProblem("fH(1)", 2); bh.assertNonProblem("fH({1})", 2); } @@ -9823,7 +9827,7 @@ public class AST2CPPTests extends AST2BaseTest { } // struct Base { - // virtual void mFuncDecl(); + // virtual void mFuncDecl(); // virtual void mFuncDef(){} // }; // struct S : public Base { @@ -9851,9 +9855,9 @@ public class AST2CPPTests extends AST2BaseTest { assertInstance(declarator, ICPPASTFunctionDeclarator.class); assertVirtualSpecifiers((ICPPASTFunctionDeclarator)declarator, true, false); } - + // struct Base { - // virtual void mFuncDecl(); + // virtual void mFuncDecl(); // virtual void mFuncDef(){} // }; // struct S : public Base { @@ -10025,7 +10029,7 @@ public class AST2CPPTests extends AST2BaseTest { // double vdouble; // long double vlongdouble; // UnscopedEnum vue; - // + // // // Narrowing conversions // fint({vdouble}); // ffloat({vlongdouble}); @@ -10083,7 +10087,7 @@ public class AST2CPPTests extends AST2BaseTest { helper.assertNonProblemOnFirstIdentifier("fint({vbool"); helper.assertNonProblemOnFirstIdentifier("fint({vchar"); } - + // namespace std { // struct string {}; // struct exception {}; diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CSpecTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CSpecTest.java index 974728e23da..9ad87f0b996 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CSpecTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CSpecTest.java @@ -15,7 +15,7 @@ import org.eclipse.cdt.core.parser.ParserLanguage; /** * @author dsteffle */ -public class AST2CSpecTest extends AST2SpecBaseTest { +public class AST2CSpecTest extends AST2SpecTestBase { public AST2CSpecTest() { } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2FileBasePluginTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2FileBasePluginTestCase.java similarity index 68% rename from core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2FileBasePluginTest.java rename to core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2FileBasePluginTestCase.java index 8aa20c65a32..deb5f8f4b80 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2FileBasePluginTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2FileBasePluginTestCase.java @@ -8,10 +8,6 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ - -/* - * Created on Sept 28, 2004 - */ package org.eclipse.cdt.core.parser.tests.ast2; import java.io.ByteArrayInputStream; @@ -39,116 +35,116 @@ import org.eclipse.core.runtime.NullProgressMonitor; /** * @author dsteffle */ -public class AST2FileBasePluginTest extends TestCase { +public class AST2FileBasePluginTestCase extends TestCase { static NullProgressMonitor monitor; static IWorkspace workspace; static IProject project; static FileManager fileManager; - static int numProjects = 0; + static int numProjects; static Class className; static ICProject cPrj; - public AST2FileBasePluginTest() { + public AST2FileBasePluginTestCase() { } - public AST2FileBasePluginTest(String name) { + public AST2FileBasePluginTestCase(String name) { super(name); } - private void initialize(Class aClassName){ - if( CCorePlugin.getDefault() != null && CCorePlugin.getDefault().getCoreModel() != null){ + private void initialize(Class aClassName) { + if (CCorePlugin.getDefault() != null && CCorePlugin.getDefault().getCoreModel() != null) { //(CCorePlugin.getDefault().getCoreModel().getIndexManager()).reset(); monitor = new NullProgressMonitor(); - + workspace = ResourcesPlugin.getWorkspace(); - + try { cPrj = CProjectHelper.createCCProject("AST2BasedProjectMofo", "bin", IPDOMManager.ID_NO_INDEXER); //$NON-NLS-1$ //$NON-NLS-2$ - + project = cPrj.getProject(); - + // ugly if (className == null || !className.equals(aClassName)) { className = aClassName; numProjects++; } - } catch ( CoreException e ) { - /*boo*/ + } catch (CoreException e) { + // Ignore } if (project == null) throw new NullPointerException("Unable to create project"); //$NON-NLS-1$ - - //Create file manager + + // Create file manager fileManager = new FileManager(); } } - public AST2FileBasePluginTest(String name, Class className) - { + public AST2FileBasePluginTestCase(String name, Class className) { super(name); initialize(className); } - + public void cleanupProject() throws Exception { numProjects--; - - try{ + + try { if (numProjects == 0) { - project.delete( true, false, monitor ); + project.delete(true, false, monitor); project = null; } - } catch( Throwable e ){ - /*boo*/ + } catch (Throwable e) { + // Ignore } } @Override protected void tearDown() throws Exception { - if( project == null || !project.exists() ) + if (project == null || !project.exists()) return; - - IResource [] members = project.members(); - for( int i = 0; i < members.length; i++ ){ - if( members[i].getName().equals( ".project" ) || members[i].getName().equals( ".cproject" ) ) //$NON-NLS-1$ //$NON-NLS-2$ + + IResource[] members = project.members(); + for (int i = 0; i < members.length; i++) { + if (members[i].getName().equals(".project") || members[i].getName().equals(".cproject")) //$NON-NLS-1$ //$NON-NLS-2$ continue; if (members[i].getName().equals(".settings")) continue; - try{ - members[i].delete( false, monitor ); - } catch( Throwable e ){ - /*boo*/ + try { + members[i].delete(false, monitor); + } catch (Throwable e) { + // Ignore } } } protected IFolder importFolder(String folderName) throws Exception { IFolder folder = project.getProject().getFolder(folderName); - - //Create file input stream - if( !folder.exists() ) - folder.create( false, false, monitor ); - + + // Create file input stream + if (!folder.exists()) + folder.create(false, false, monitor); + return folder; } - public IFile importFile(String fileName, String contents ) throws Exception{ - //Obtain file handle + + public IFile importFile(String fileName, String contents) throws Exception { + // Obtain file handle IFile file = project.getProject().getFile(fileName); - - InputStream stream = new ByteArrayInputStream( contents.getBytes() ); - //Create file input stream - if( file.exists() ) - file.setContents( stream, false, false, monitor ); - else - file.create( stream, false, monitor ); - + + InputStream stream = new ByteArrayInputStream(contents.getBytes()); + // Create file input stream + if (file.exists()) { + file.setContents(stream, false, false, monitor); + } else { + file.create(stream, false, monitor); + } + fileManager.addFile(file); - + return file; } - + protected StringBuilder[] getContents(int sections) throws IOException { return TestSourceReader.getContentsForTest( CTestPlugin.getDefault().getBundle(), "parser", getClass(), getName(), sections); } - } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2KnRTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2KnRTests.java index b0717f0aa51..80ee143f853 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2KnRTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2KnRTests.java @@ -59,7 +59,7 @@ import org.eclipse.cdt.internal.core.dom.parser.c.ICInternalBinding; /** * @author dsteffle */ -public class AST2KnRTests extends AST2BaseTest { +public class AST2KnRTests extends AST2TestBase { public AST2KnRTests() { } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SelectionParseTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SelectionParseTest.java index 9ec90bf1263..71ec93a7c7f 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SelectionParseTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SelectionParseTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 IBM Corporation and others. + * Copyright (c) 2005, 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 @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Nathan Ridge *******************************************************************************/ package org.eclipse.cdt.core.parser.tests.ast2; @@ -26,6 +27,7 @@ import org.eclipse.cdt.core.dom.ast.IASTPreprocessorStatement; import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.core.dom.ast.IASTTypeId; +import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.ICompositeType; import org.eclipse.cdt.core.dom.ast.IEnumeration; import org.eclipse.cdt.core.dom.ast.IField; @@ -46,7 +48,7 @@ import org.eclipse.core.resources.IFile; /** * @author dsteffle */ -public class AST2SelectionParseTest extends AST2SelectionParseBaseTest { +public class AST2SelectionParseTest extends AST2SelectionParseTestBase { public AST2SelectionParseTest() { } @@ -352,9 +354,10 @@ public class AST2SelectionParseTest extends AST2SelectionParseBaseTest { assertTrue(node instanceof IASTTypeId); assertEquals(((IASTNamedTypeSpecifier)((IASTTypeId)node).getDeclSpecifier()).getName().toString(), "Gonzo"); //$NON-NLS-1$ name = ((IASTNamedTypeSpecifier)((IASTTypeId)node).getDeclSpecifier()).getName(); - assertNotNull(name.resolveBinding()); - assertTrue(name.resolveBinding() instanceof ICPPConstructor); - assertEquals(((ICPPConstructor)name.resolveBinding()).getName(), "Gonzo"); //$NON-NLS-1$ + name = TestUtil.findImplicitName(name); + IBinding binding = name.resolveBinding(); + assertTrue(binding instanceof ICPPConstructor); + assertEquals(((ICPPConstructor)binding).getName(), "Gonzo"); //$NON-NLS-1$ break; default: assertTrue(node instanceof IASTName); @@ -736,9 +739,10 @@ public class AST2SelectionParseTest extends AST2SelectionParseBaseTest { assertTrue(node instanceof IASTTypeId); assertEquals(((IASTNamedTypeSpecifier)((IASTTypeId)node).getDeclSpecifier()).getName().toString(), "B"); //$NON-NLS-1$ IASTName name = ((IASTNamedTypeSpecifier)((IASTTypeId)node).getDeclSpecifier()).getName(); - assertNotNull(name.resolveBinding()); - assertTrue(name.resolveBinding() instanceof ICPPConstructor); - assertEquals(((ICPPConstructor)name.resolveBinding()).getName(), "B"); //$NON-NLS-1$ + name = TestUtil.findImplicitName(name); + IBinding binding = name.resolveBinding(); + assertTrue(binding instanceof ICPPConstructor); + assertEquals(((ICPPConstructor)binding).getName(), "B"); //$NON-NLS-1$ } public void testBug72712_2() throws Exception{ diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SelectionParseBaseTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SelectionParseTestBase.java similarity index 94% rename from core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SelectionParseBaseTest.java rename to core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SelectionParseTestBase.java index 8aca7558fa4..851a990f72b 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SelectionParseBaseTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SelectionParseTestBase.java @@ -29,7 +29,7 @@ import org.eclipse.cdt.core.parser.NullLogService; import org.eclipse.cdt.core.parser.ParserLanguage; import org.eclipse.cdt.core.parser.ParserMode; import org.eclipse.cdt.core.parser.ScannerInfo; -import org.eclipse.cdt.core.parser.tests.FileBasePluginTest; +import org.eclipse.cdt.core.parser.tests.FileBasePluginTestCase; import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor; import org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser; import org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser; @@ -40,18 +40,18 @@ import org.eclipse.core.resources.IFile; /** * @author dsteffle */ -public class AST2SelectionParseBaseTest extends FileBasePluginTest { +public class AST2SelectionParseTestBase extends FileBasePluginTestCase { - public AST2SelectionParseBaseTest() { + public AST2SelectionParseTestBase() { } - public AST2SelectionParseBaseTest(String name) { + public AST2SelectionParseTestBase(String name) { super(name); } private static final IParserLogService NULL_LOG = new NullLogService(); - public AST2SelectionParseBaseTest(String name, Class className) { + public AST2SelectionParseTestBase(String name, Class className) { super(name, className); } @@ -76,7 +76,7 @@ public class AST2SelectionParseBaseTest extends FileBasePluginTest { protected IASTTranslationUnit parse(String code, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems) throws ParserException { FileContent codeReader = FileContent.create("", code.toCharArray()); ScannerInfo scannerInfo = new ScannerInfo(); - IScanner scanner= AST2BaseTest.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo); + IScanner scanner= AST2TestBase.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo); ISourceCodeParser parser2 = null; if (lang == ParserLanguage.CPP) { diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SpecBaseTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SpecTestBase.java similarity index 97% rename from core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SpecBaseTest.java rename to core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SpecTestBase.java index 5d9942bcf81..9dd536cb736 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SpecBaseTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SpecTestBase.java @@ -41,12 +41,12 @@ import org.eclipse.cdt.internal.core.parser.ParserException; /** * @author dsteffle */ -public class AST2SpecBaseTest extends AST2BaseTest { - public AST2SpecBaseTest() { +public class AST2SpecTestBase extends AST2TestBase { + public AST2SpecTestBase() { super(); } - public AST2SpecBaseTest(String name) { + public AST2SpecTestBase(String name) { super(name); } @@ -101,7 +101,7 @@ public class AST2SpecBaseTest extends AST2BaseTest { boolean useGNUExtensions, boolean expectNoProblems, boolean checkBindings, int expectedProblemBindings, String[] problems) throws ParserException { ScannerInfo scannerInfo = new ScannerInfo(); - IScanner scanner= AST2BaseTest.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo); + IScanner scanner= AST2TestBase.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo); ISourceCodeParser parser2 = null; if (lang == ParserLanguage.CPP) { diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java index 19350ee7d27..c06be8560cc 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2012 IBM Corporation and others. + * Copyright (c) 2005, 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 @@ -44,6 +44,7 @@ import org.eclipse.cdt.core.dom.ast.IASTTypeId; import org.eclipse.cdt.core.dom.ast.IBasicType; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.ICompositeType; +import org.eclipse.cdt.core.dom.ast.IEnumerator; import org.eclipse.cdt.core.dom.ast.IField; import org.eclipse.cdt.core.dom.ast.IFunction; import org.eclipse.cdt.core.dom.ast.IFunctionType; @@ -55,6 +56,7 @@ import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.ISemanticProblem; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.ITypedef; +import org.eclipse.cdt.core.dom.ast.IValue; import org.eclipse.cdt.core.dom.ast.IVariable; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExplicitTemplateInstantiation; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier; @@ -101,7 +103,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil; import org.eclipse.cdt.internal.core.parser.ParserException; -public class AST2TemplateTests extends AST2BaseTest { +public class AST2TemplateTests extends AST2TestBase { public AST2TemplateTests() { } @@ -2371,11 +2373,11 @@ public class AST2TemplateTests extends AST2BaseTest { public void testCPPConstructorTemplateSpecialization() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true); - CPPNameCollector col = new CPPNameCollector(); + CPPNameCollector col = new CPPNameCollector(true); tu.accept(col); - ICPPASTTemplateId tid= (ICPPASTTemplateId) col.getName(20); - IASTName cn= col.getName(21); + IASTImplicitName tid= (IASTImplicitName) col.getName(20); + IASTName cn= col.getName(22); assertInstance(cn.resolveBinding(), ICPPClassTemplate.class); // *D*(5, 6) assertInstance(cn.resolveBinding(), ICPPClassType.class); // *D*(5, 6) assertInstance(tid.resolveBinding(), ICPPTemplateInstance.class); // *D*(5, 6) @@ -3840,7 +3842,7 @@ public class AST2TemplateTests extends AST2BaseTest { // }; public void testNestedTemplates_259872_1() throws Exception { BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), CPP); - bh.assertNonProblem("A", 9, ICPPConstructor.class); + bh.assertNonProblem("A", 9, ICPPClassType.class); } // template @@ -3865,7 +3867,7 @@ public class AST2TemplateTests extends AST2BaseTest { // }; public void testNestedTemplates_259872_2() throws Exception { BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), CPP); - bh.assertNonProblem("A", 9, ICPPConstructor.class); + bh.assertNonProblem("A", 9, ICPPClassType.class); } // template @@ -6219,24 +6221,24 @@ public class AST2TemplateTests extends AST2BaseTest { // } public void testSimpleAliasDeclaration() throws Exception { parseAndCheckBindings(); - + BindingAssertionHelper assertionHelper = getAssertionHelper(); CPPNameCollector collector = getCPPNameCollector(assertionHelper.getTranslationUnit()); - + ICPPClassType S = assertionHelper.assertNonProblem("struct S {", "S", ICPPClassType.class); ICPPField x = assertionHelper.assertNonProblem("int x", "x", ICPPField.class); ITypedef Alias = assertionHelper.assertNonProblem("using Alias = S", "Alias", ITypedef.class); IFunction foo = assertionHelper.assertNonProblem("void foo() {", "foo", IFunction.class); IVariable myA = assertionHelper.assertNonProblem("Alias myA", "myA", IVariable.class); - - + + assertInstances(collector, S, 2); assertInstances(collector, x, 2); assertInstances(collector, Alias, 2); assertInstances(collector, foo, 1); assertInstances(collector, myA, 2); } - + // template // struct S { // T x; @@ -6248,7 +6250,7 @@ public class AST2TemplateTests extends AST2BaseTest { // } public void testSpecifiedTemplateAliasDeclaration() throws Exception { parseAndCheckBindings(); - + BindingAssertionHelper assertionHelper = getAssertionHelper(); CPPNameCollector collector = getCPPNameCollector(assertionHelper.getTranslationUnit()); @@ -6257,7 +6259,7 @@ public class AST2TemplateTests extends AST2BaseTest { ITypedef Alias = assertionHelper.assertNonProblem("using Alias = S;", "Alias", ITypedef.class); IVariable myA = assertionHelper.assertNonProblem("Alias myA;", "myA", IVariable.class); ICPPSpecialization xRef = assertionHelper.assertNonProblem("myA.x = 42;", "x", ICPPSpecialization.class); - + assertInstances(collector, S, 2); assertInstances(collector, Alias, 2); @@ -6273,13 +6275,13 @@ public class AST2TemplateTests extends AST2BaseTest { // } public void testTemplatedAliasBasicType() throws Exception { parseAndCheckBindings(); - + BindingAssertionHelper assertionHelper = getAssertionHelper(); CPPNameCollector collector = getCPPNameCollector(assertionHelper.getTranslationUnit()); - + ICPPAliasTemplate Alias = assertionHelper.assertNonProblem("using Alias = int;", "Alias", ICPPAliasTemplate.class); ICPPAliasTemplateInstance aliasFloatInstance = assertionHelper.assertNonProblem("Alias myA;", "Alias", ICPPAliasTemplateInstance.class); - + assertInstances(collector, Alias, 2); assertSameType(aliasFloatInstance, new CPPBasicType(IBasicType.Kind.eInt, 0)); } @@ -6296,7 +6298,7 @@ public class AST2TemplateTests extends AST2BaseTest { // } public void testTemplatedAliasDeclaration() throws Exception { parseAndCheckBindings(); - + BindingAssertionHelper assertionHelper = getAssertionHelper(); CPPNameCollector collector = getCPPNameCollector(assertionHelper.getTranslationUnit()); @@ -6334,9 +6336,9 @@ public class AST2TemplateTests extends AST2BaseTest { // } public void testTemplatedAliasDeclarationMultipleParameters() throws Exception { parseAndCheckBindings(); - + BindingAssertionHelper assertionHelper = getAssertionHelper(); - + ICPPField t1 = assertionHelper.assertNonProblem("T1 t1;", "t1", ICPPField.class); ICPPField t2 = assertionHelper.assertNonProblem("T2 t2;", "t2", ICPPField.class); ICPPField t3 = assertionHelper.assertNonProblem("T3 t3;", "t3", ICPPField.class); @@ -6377,9 +6379,9 @@ public class AST2TemplateTests extends AST2BaseTest { // } public void testTemplatedAliasDeclarationTemplateArgument() throws Exception { parseAndCheckBindings(); - + BindingAssertionHelper assertionHelper = getAssertionHelper(); - + ICPPField t = assertionHelper.assertNonProblem("T t;", "t", ICPPField.class); ICPPAliasTemplateInstance TAliasSInt = assertionHelper.assertNonProblem("TAlias> myA;", "TAlias>", ICPPAliasTemplateInstance.class); ICPPSpecialization tRef = assertionHelper.assertNonProblem("myA.t = S()", "t", ICPPSpecialization.class); @@ -6400,9 +6402,9 @@ public class AST2TemplateTests extends AST2BaseTest { // } public void testTemplatedAliasAsTemplateArgument() throws Exception { parseAndCheckBindings(); - + BindingAssertionHelper assertionHelper = getAssertionHelper(); - + ICPPField t = assertionHelper.assertNonProblem("T t;", "t", ICPPField.class); ICPPTemplateInstance STAliasInt = assertionHelper.assertNonProblem("S> myA;", "S>", ICPPTemplateInstance.class); ICPPSpecialization tRef = assertionHelper.assertNonProblem("myA.t = S();", "t", ICPPSpecialization.class); @@ -6423,9 +6425,9 @@ public class AST2TemplateTests extends AST2BaseTest { // } public void testTemplatedAliasDeclarationValueArgument() throws Exception { parseAndCheckBindings(); - + BindingAssertionHelper assertionHelper = getAssertionHelper(); - + ICPPField buff = assertionHelper.assertNonProblem("int buff [Size];", "buff", ICPPField.class); ICPPSpecialization buffRef = assertionHelper.assertNonProblem("myA.buff[0] = 1;", "buff", ICPPSpecialization.class); @@ -6446,9 +6448,9 @@ public class AST2TemplateTests extends AST2BaseTest { // } public void testTemplatedAliasDefaultArguments() throws Exception { parseAndCheckBindings(); - + BindingAssertionHelper assertionHelper = getAssertionHelper(); - + ICPPField buff = assertionHelper.assertNonProblem("T buff [Size];", "buff", ICPPField.class); ICPPAliasTemplateInstance myA = assertionHelper.assertNonProblem("TAlias<> myA;", "TAlias<>", ICPPAliasTemplateInstance.class); ICPPSpecialization buffRef = assertionHelper.assertNonProblem("myA.buff[0] = 1;", "buff", ICPPSpecialization.class); @@ -6470,9 +6472,9 @@ public class AST2TemplateTests extends AST2BaseTest { // } public void testTemplatedAliasTemplateArgument() throws Exception { parseAndCheckBindings(); - + BindingAssertionHelper assertionHelper = getAssertionHelper(); - + ICPPField t = assertionHelper.assertNonProblem("T t;", "t", ICPPField.class); ICPPSpecialization tRef = assertionHelper.assertNonProblem(" myA.t = S();", "t", ICPPSpecialization.class); ICPPClassSpecialization Sint = assertionHelper.assertNonProblem("myA.t = S();", "S", ICPPClassSpecialization.class); @@ -6497,9 +6499,9 @@ public class AST2TemplateTests extends AST2BaseTest { // } public void testTemplatedAliasAsFunctionParameter() throws Exception { parseAndCheckBindings(); - + BindingAssertionHelper assertionHelper = getAssertionHelper(); - + ICPPFunction bar = assertionHelper.assertNonProblem("void bar(TAlias arg){", "bar", ICPPFunction.class); ICPPFunction barRefAlias = assertionHelper.assertNonProblem("bar(myA);", "bar", ICPPFunction.class); ICPPFunction barRefSInt = assertionHelper.assertNonProblem("bar(myS);", "bar", ICPPFunction.class); @@ -6522,7 +6524,7 @@ public class AST2TemplateTests extends AST2BaseTest { // } public void testTemplatedAliasAsFunctionArgument() throws Exception { parseAndCheckBindings(); - + BindingAssertionHelper assertionHelper = getAssertionHelper(); ICPPFunction bar = assertionHelper.assertNonProblem("void bar(S arg){", "bar", ICPPFunction.class); @@ -6571,7 +6573,7 @@ public class AST2TemplateTests extends AST2BaseTest { // } public void testSimpleFunctionAliasDeclaration() throws Exception { parseAndCheckBindings(); - + BindingAssertionHelper assertionHelper = getAssertionHelper(); CPPNameCollector collector = getCPPNameCollector(assertionHelper.getTranslationUnit()); @@ -6596,7 +6598,7 @@ public class AST2TemplateTests extends AST2BaseTest { // } public void testTemplatedAliasForTemplateReference() throws Exception { parseAndCheckBindings(); - + BindingAssertionHelper assertionHelper = getAssertionHelper(); ICPPClassSpecialization SInt = assertionHelper.assertNonProblem("S myS;", "S", ICPPClassSpecialization.class); @@ -6612,7 +6614,7 @@ public class AST2TemplateTests extends AST2BaseTest { // } public void testSimpleFunctionTemplateAliasDeclaration() throws Exception { parseAndCheckBindings(); - + BindingAssertionHelper assertionHelper = getAssertionHelper(); CPPNameCollector collector = getCPPNameCollector(assertionHelper.getTranslationUnit()); @@ -6632,7 +6634,7 @@ public class AST2TemplateTests extends AST2BaseTest { // } public void testSimpleFunctionReferenceTemplateAliasDeclaration() throws Exception { parseAndCheckBindings(); - + BindingAssertionHelper assertionHelper = getAssertionHelper(); CPPNameCollector collector = getCPPNameCollector(assertionHelper.getTranslationUnit()); @@ -6657,7 +6659,7 @@ public class AST2TemplateTests extends AST2BaseTest { // } public void testTemplatedAliasTemplateParameter() throws Exception { parseAndCheckBindings(); - + BindingAssertionHelper assertionHelper = getAssertionHelper(); ICPPField t = assertionHelper.assertNonProblem("T t;", "t", ICPPField.class); @@ -6680,10 +6682,11 @@ public class AST2TemplateTests extends AST2BaseTest { // Alias intAlias; public void testAliasDeclarationContext() throws Exception { parseAndCheckBindings(); - + BindingAssertionHelper assertionHelper = getAssertionHelper(); - ICPPAliasTemplateInstance AliasInt = assertionHelper.assertNonProblem("Alias intAlias;", "Alias", ICPPAliasTemplateInstance.class); + ICPPAliasTemplateInstance AliasInt = + assertionHelper.assertNonProblem("Alias intAlias;", "Alias", ICPPAliasTemplateInstance.class); assertEquals("Alias", AliasInt.getName()); assertEquals("NS", AliasInt.getQualifiedName()[0]); assertEquals("Alias", AliasInt.getQualifiedName()[1]); @@ -7004,4 +7007,26 @@ public class AST2TemplateTests extends AST2BaseTest { public void testDependentExpressions_395243d() throws Exception { parseAndCheckBindings(); } + + // template + // struct B { + // enum { value = 1 }; + // }; + // + // template + // struct C { + // enum { id = B::value }; + // }; + // + // void test() { + // int x = C::id; + // } + public void _testDependentEnumValue_389009() throws Exception { + BindingAssertionHelper ah = getAssertionHelper(); + IEnumerator binding = ah.assertNonProblem("C::id", "id"); + IValue value = binding.getValue(); + Long num = value.numericalValue(); + assertNotNull(num); + assertEquals(1, num.longValue()); + } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2BaseTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TestBase.java similarity index 97% rename from core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2BaseTest.java rename to core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TestBase.java index dff0c031a63..afb76a90c9d 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2BaseTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TestBase.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2012 IBM Corporation and others. + * Copyright (c) 2004, 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 @@ -95,7 +95,7 @@ import org.eclipse.cdt.internal.core.parser.scanner.CPreprocessor; /** * @author aniefer */ -public class AST2BaseTest extends BaseTestCase { +public class AST2TestBase extends BaseTestCase { public final static String TEST_CODE = ""; protected static final IParserLogService NULL_LOG = new NullLogService(); protected static boolean sValidateCopy; @@ -121,14 +121,14 @@ public class AST2BaseTest extends BaseTestCase { return map; } - public AST2BaseTest() { + public AST2TestBase() { super(); } - - public AST2BaseTest(String name) { + + public AST2TestBase(String name) { super(name); } - + @Override protected void setUp() throws Exception { sValidateCopy= true; @@ -138,7 +138,7 @@ public class AST2BaseTest extends BaseTestCase { protected IASTTranslationUnit parse(String code, ParserLanguage lang) throws ParserException { return parse(code, lang, false, true); } - + protected IASTTranslationUnit parse(String code, ParserLanguage lang, boolean useGNUExtensions) throws ParserException { return parse(code, lang, useGNUExtensions, true); } @@ -147,10 +147,10 @@ public class AST2BaseTest extends BaseTestCase { boolean expectNoProblems) throws ParserException { return parse(code, lang, useGNUExtensions, expectNoProblems, false); } - + protected IASTTranslationUnit parse(String code, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems, boolean skipTrivialInitializers) throws ParserException { - IScanner scanner = createScanner(FileContent.create(TEST_CODE, code.toCharArray()), lang, ParserMode.COMPLETE_PARSE, + IScanner scanner = createScanner(FileContent.create(TEST_CODE, code.toCharArray()), lang, ParserMode.COMPLETE_PARSE, createScannerInfo(useGNUExtensions)); configureScanner(scanner); AbstractGNUSourceCodeParser parser = null; @@ -170,12 +170,12 @@ public class AST2BaseTest extends BaseTestCase { } else { config = new ANSICParserExtensionConfiguration(); } - + parser = new GNUCSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config, null); } if (skipTrivialInitializers) parser.setSkipTrivialExpressionsInAggregateInitializers(true); - + IASTTranslationUnit tu = parser.parse(); assertTrue(tu.isFrozen()); if (sValidateCopy) @@ -183,7 +183,7 @@ public class AST2BaseTest extends BaseTestCase { if (parser.encounteredError() && expectNoProblems) throw new ParserException("FAILURE"); //$NON-NLS-1$ - + if (lang == ParserLanguage.C && expectNoProblems) { assertEquals(CVisitor.getProblems(tu).length, 0); assertEquals(tu.getPreprocessorProblems().length, 0); @@ -193,7 +193,7 @@ public class AST2BaseTest extends BaseTestCase { } if (expectNoProblems) assertEquals(0, tu.getPreprocessorProblems().length); - + return tu; } @@ -215,7 +215,7 @@ public class AST2BaseTest extends BaseTestCase { configuration= GPPScannerExtensionConfiguration.getInstance(scannerInfo); } IScanner scanner; - scanner= new CPreprocessor(codeReader, scannerInfo, lang, NULL_LOG, configuration, + scanner= new CPreprocessor(codeReader, scannerInfo, lang, NULL_LOG, configuration, IncludeFileContentProvider.getSavedFilesProvider()); return scanner; } @@ -263,7 +263,7 @@ public class AST2BaseTest extends BaseTestCase { } protected void validateSimpleBinaryExpressionC(String code, int operand) throws ParserException { - IASTBinaryExpression e = (IASTBinaryExpression) getExpressionFromStatementInCode(code, ParserLanguage.C); + IASTBinaryExpression e = (IASTBinaryExpression) getExpressionFromStatementInCode(code, ParserLanguage.C); assertNotNull(e); assertEquals(e.getOperator(), operand); IASTIdExpression x = (IASTIdExpression) e.getOperand1(); @@ -290,8 +290,8 @@ public class AST2BaseTest extends BaseTestCase { ASTComparer.assertCopy(tu, copy); return (T) copy; } - - + + static protected class CNameCollector extends ASTVisitor { { shouldVisitNames = true; @@ -309,29 +309,35 @@ public class AST2BaseTest extends BaseTestCase { return null; return nameList.get(idx); } - + public int size() { return nameList.size(); - } + } } protected void assertInstances(CNameCollector collector, IBinding binding, int num) throws Exception { int count = 0; - + assertNotNull(binding); - + for (int i = 0; i < collector.size(); i++) { if (collector.getName(i).resolveBinding() == binding) count++; } - + assertEquals(count, num); } static protected class CPPNameCollector extends ASTVisitor { - { - shouldVisitNames = true; + public CPPNameCollector() { + this(false); // don't visit implicit names by default } + + public CPPNameCollector(boolean shouldVisitImplicitNames) { + this.shouldVisitNames = true; + this.shouldVisitImplicitNames = shouldVisitImplicitNames; + } + public List nameList = new ArrayList(); @Override @@ -349,7 +355,7 @@ public class AST2BaseTest extends BaseTestCase { public int size() { return nameList.size(); } - + public void dump() { for (int i= 0; i < size(); i++) { IASTName name= getName(i); @@ -365,7 +371,7 @@ public class AST2BaseTest extends BaseTestCase { if (collector.getName(i).resolveBinding() == binding) count++; } - + assertEquals(num, count); } @@ -386,42 +392,42 @@ public class AST2BaseTest extends BaseTestCase { String expressionString = ASTStringUtil.getExpressionString(exp); assertEquals(str, expressionString); } - + protected void isParameterSignatureEqual(IASTDeclarator decltor, String str) { assertTrue(decltor instanceof IASTFunctionDeclarator); final String[] sigArray = ASTStringUtil.getParameterSignatureArray((IASTFunctionDeclarator) decltor); assertEquals(str, "(" + ASTStringUtil.join(sigArray, ", ") + ")"); } - + protected void isSignatureEqual(IASTDeclarator declarator, String expected) { String signature= ASTStringUtil.getSignatureString(declarator); assertEquals(expected, signature); } - + protected void isSignatureEqual(IASTDeclSpecifier declSpec, String str) { assertEquals(str, ASTStringUtil.getSignatureString(declSpec, null)); } - + protected void isSignatureEqual(IASTTypeId typeId, String str) { assertEquals(str, ASTStringUtil.getSignatureString(typeId.getDeclSpecifier(), typeId.getAbstractDeclarator())); } - + protected void isTypeEqual(IASTDeclarator decltor, String str) { assertEquals(str, ASTTypeUtil.getType(decltor)); } - + protected void isTypeEqual(IASTTypeId typeId, String str) { assertEquals(str, ASTTypeUtil.getType(typeId)); } - + protected void isTypeEqual(IType type, String str) { assertEquals(str, ASTTypeUtil.getType(type)); } - + protected void isParameterTypeEqual(IFunctionType fType, String str) { assertEquals(str, ASTTypeUtil.getParameterTypeString(fType)); } - + static protected class CNameResolver extends ASTVisitor { { shouldVisitNames = true; @@ -449,9 +455,9 @@ public class AST2BaseTest extends BaseTestCase { public int size() { return nameList.size(); - } + } } - + static protected class CPPNameResolver extends ASTVisitor { { shouldVisitNames = true; @@ -479,13 +485,13 @@ public class AST2BaseTest extends BaseTestCase { public int size() { return nameList.size(); - } + } } - + protected String getAboveComment() throws IOException { return getContents(1)[0].toString(); } - + protected CharSequence[] getContents(int sections) throws IOException { CTestPlugin plugin = CTestPlugin.getDefault(); if (plugin == null) @@ -502,14 +508,14 @@ public class AST2BaseTest extends BaseTestCase { } return clazz.cast(o); } - + protected static void assertField(IBinding binding, String fieldName, String ownerName) { assertInstance(binding, IField.class); assertEquals(fieldName, binding.getName()); ICompositeType struct = ((IField) binding).getCompositeTypeOwner(); assertEquals(ownerName, struct.getName()); } - + protected class BindingAssertionHelper { protected IASTTranslationUnit tu; protected String contents; @@ -562,7 +568,7 @@ public class AST2BaseTest extends BaseTestCase { IBinding binding= binding(section, len); if (binding instanceof IProblemBinding) { IProblemBinding problem= (IProblemBinding) binding; - fail("ProblemBinding for name: " + section.substring(0, len) + " (" + renderProblemID(problem.getID()) + ")"); + fail("ProblemBinding for name: " + section.substring(0, len) + " (" + renderProblemID(problem.getID()) + ")"); } if (binding == null) { fail("Null binding resolved for name: " + section.substring(0, len)); @@ -611,12 +617,12 @@ public class AST2BaseTest extends BaseTestCase { IASTName name = findImplicitName(section, len); final String selection = section.substring(0, len); assertNotNull("did not find \"" + selection + "\"", name); - + assertInstance(name, IASTImplicitName.class); IASTImplicitNameOwner owner = (IASTImplicitNameOwner) name.getParent(); IASTImplicitName[] implicits = owner.getImplicitNames(); assertNotNull(implicits); - + if (implicits.length > 1) { boolean found = false; for (IASTImplicitName n : implicits) { @@ -627,34 +633,34 @@ public class AST2BaseTest extends BaseTestCase { } assertTrue(found); } - + assertEquals(selection, name.getRawSignature()); IBinding binding = name.resolveBinding(); assertNotNull(binding); assertInstance(binding, bindingClass); return (IASTImplicitName) name; } - + public void assertNoImplicitName(String section, int len) { IASTName name = findImplicitName(section, len); final String selection = section.substring(0, len); assertNull("found name \"" + selection + "\"", name); } - + public IASTImplicitName[] getImplicitNames(String section, int len) { IASTName name = findImplicitName(section, len); IASTImplicitNameOwner owner = (IASTImplicitNameOwner) name.getParent(); IASTImplicitName[] implicits = owner.getImplicitNames(); return implicits; } - + public IASTName findName(String section, int len) { final int offset = contents.indexOf(section); assertTrue("Section \"" + section + "\" not found", offset >= 0); IASTNodeSelector selector = tu.getNodeSelector(null); return selector.findName(offset, len); } - + public IASTName findName(String context, String name) { if (context == null) { context = contents; @@ -712,7 +718,7 @@ public class AST2BaseTest extends BaseTestCase { } return "Unknown problem ID"; } - + public T assertNonProblem(String section, int len, Class... cs) { if (len <= 0) len += section.length(); @@ -744,10 +750,10 @@ public class AST2BaseTest extends BaseTestCase { final String selection = section.substring(0, len); assertNotNull("No AST name for \"" + selection + "\"", astName); assertEquals(selection, astName.getRawSignature()); - + IBinding binding = astName.resolveBinding(); assertNotNull("No binding for " + astName.getRawSignature(), binding); - + return astName.resolveBinding(); } @@ -755,10 +761,10 @@ public class AST2BaseTest extends BaseTestCase { IASTName astName = findName(context, name); assertNotNull("No AST name for \"" + name + "\"", astName); assertEquals(name, astName.getRawSignature()); - + IBinding binding = astName.resolveBinding(); assertNotNull("No binding for " + astName.getRawSignature(), binding); - + return astName.resolveBinding(); } } @@ -770,10 +776,10 @@ public class AST2BaseTest extends BaseTestCase { final protected IASTTranslationUnit parseAndCheckBindings(String code, ParserLanguage lang, boolean useGnuExtensions) throws Exception { return parseAndCheckBindings(code, lang, useGnuExtensions, false); } - + final protected IASTTranslationUnit parseAndCheckBindings(String code, ParserLanguage lang, boolean useGnuExtensions, boolean skipTrivialInitializers) throws Exception { - IASTTranslationUnit tu = parse(code, lang, useGnuExtensions, true, skipTrivialInitializers); + IASTTranslationUnit tu = parse(code, lang, useGnuExtensions, true, skipTrivialInitializers); CNameCollector col = new CNameCollector(); tu.accept(col); assertNoProblemBindings(col); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java index 0a8e2de6c42..a0863b741a4 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java @@ -13,6 +13,7 @@ *******************************************************************************/ package org.eclipse.cdt.core.parser.tests.ast2; +import static org.eclipse.cdt.core.parser.ParserLanguage.C; import static org.eclipse.cdt.core.parser.ParserLanguage.CPP; import java.io.IOException; @@ -127,7 +128,7 @@ import org.eclipse.cdt.internal.core.parser.ParserException; /** * Test cases on the AST. */ -public class AST2Tests extends AST2BaseTest { +public class AST2Tests extends AST2TestBase { private static final int NUM_TESTS = 3; public static TestSuite suite() { @@ -144,21 +145,21 @@ public class AST2Tests extends AST2BaseTest { private void parseAndCheckBindings() throws Exception { String code= getAboveComment(); - parseAndCheckBindings(code, ParserLanguage.C); - parseAndCheckBindings(code, ParserLanguage.CPP); + parseAndCheckBindings(code, C); + parseAndCheckBindings(code, CPP); } protected IASTTranslationUnit parseAndCheckBindings(String code) throws Exception { - return parseAndCheckBindings(code, ParserLanguage.C); + return parseAndCheckBindings(code, C); } public void testBug75189() throws Exception { parseAndCheckBindings("struct A{};\n typedef int (*F) (struct A*);"); //$NON-NLS-1$ - parseAndCheckBindings("struct A{};\n typedef int (*F) (A*);", ParserLanguage.CPP); //$NON-NLS-1$ + parseAndCheckBindings("struct A{};\n typedef int (*F) (A*);", CPP); //$NON-NLS-1$ } public void testBug75340() throws Exception { - IASTTranslationUnit tu = parseAndCheckBindings("void f(int i = 0, int * p = 0);", ParserLanguage.CPP); //$NON-NLS-1$ + IASTTranslationUnit tu = parseAndCheckBindings("void f(int i = 0, int * p = 0);", CPP); //$NON-NLS-1$ IASTSimpleDeclaration sd = (IASTSimpleDeclaration) tu.getDeclarations()[0]; isParameterSignatureEqual(sd.getDeclarators()[0], "(int=0, int*=0)"); //$NON-NLS-1$ } @@ -190,7 +191,7 @@ public class AST2Tests extends AST2BaseTest { // int ((*zzz3)) (char); // int (*(zzz4)) (char); public void testBug40768() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); + IASTTranslationUnit tu = parse(getAboveComment(), C); CNameCollector col = new CNameCollector(); tu.accept(col); assertNoProblemBindings(col); @@ -201,7 +202,7 @@ public class AST2Tests extends AST2BaseTest { // int z = x + y; // } public void testBasicFunction() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); + IASTTranslationUnit tu = parse(getAboveComment(), C); assertTrue(tu.isFrozen()); for (int i = 0; i < NUM_TESTS; i++) { IScope globalScope = tu.getScope(); @@ -344,7 +345,7 @@ public class AST2Tests extends AST2BaseTest { // myS.x = 5; // } public void testSimpleStruct() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); + IASTTranslationUnit tu = parse(getAboveComment(), C); assertTrue(tu.isFrozen()); for (int i = 0; i < NUM_TESTS; i++) { IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu @@ -530,7 +531,7 @@ public class AST2Tests extends AST2BaseTest { } public void testMultipleDeclarators() throws Exception { - IASTTranslationUnit tu = parse("int r, s;", ParserLanguage.C); //$NON-NLS-1$ + IASTTranslationUnit tu = parse("int r, s;", C); //$NON-NLS-1$ assertTrue(tu.isFrozen()); for (int i = 0; i < NUM_TESTS; i++) { IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0]; @@ -568,7 +569,7 @@ public class AST2Tests extends AST2BaseTest { buffer.append(" struct A * a; \n"); //$NON-NLS-1$ buffer.append("} \n"); //$NON-NLS-1$ - IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C); + IASTTranslationUnit tu = parse(buffer.toString(), C); assertTrue(tu.isFrozen()); for (int i = 0; i < NUM_TESTS; i++) { @@ -647,7 +648,7 @@ public class AST2Tests extends AST2BaseTest { buffer.append(" struct A * a; \n"); //$NON-NLS-1$ buffer.append("} \r\n"); //$NON-NLS-1$ - IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C); + IASTTranslationUnit tu = parse(buffer.toString(), C); assertTrue(tu.isFrozen()); for (int i = 0; i < NUM_TESTS; i++) { @@ -712,7 +713,7 @@ public class AST2Tests extends AST2BaseTest { buffer.append(" a->i; \n"); //$NON-NLS-1$ buffer.append("} \n"); //$NON-NLS-1$ - IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C); + IASTTranslationUnit tu = parse(buffer.toString(), C); assertTrue(tu.isFrozen()); for (int i = 0; i < NUM_TESTS; i++) { @@ -818,7 +819,7 @@ public class AST2Tests extends AST2BaseTest { // struct x i; // } public void testStructureNamespace() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); + IASTTranslationUnit tu = parse(getAboveComment(), C); assertTrue(tu.isFrozen()); for (int i = 0; i < NUM_TESTS; i++) { @@ -906,7 +907,7 @@ public class AST2Tests extends AST2BaseTest { // } public void testFunctionParameters() throws Exception { final String code = getAboveComment(); - IASTTranslationUnit tu = parse(code, ParserLanguage.C); + IASTTranslationUnit tu = parse(code, C); assertTrue(tu.isFrozen()); // void f( @@ -947,7 +948,7 @@ public class AST2Tests extends AST2BaseTest { assertSame(param_2, param_3); assertSame(f_1, f_2); - tu = parse(code, ParserLanguage.C); + tu = parse(code, C); assertTrue(tu.isFrozen()); // void f( f_decl = (IASTSimpleDeclaration) tu.getDeclarations()[0]; @@ -1011,7 +1012,7 @@ public class AST2Tests extends AST2BaseTest { // void f(int a, int b) { } public void testSimpleFunction() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); + IASTTranslationUnit tu = parse(getAboveComment(), C); assertTrue(tu.isFrozen()); for (int i = 0; i < NUM_TESTS; i++) { IASTFunctionDefinition fDef = (IASTFunctionDefinition) tu.getDeclarations()[0]; @@ -1061,7 +1062,7 @@ public class AST2Tests extends AST2BaseTest { // } // void f() { } public void testSimpleFunctionCall() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); + IASTTranslationUnit tu = parse(getAboveComment(), C); assertTrue(tu.isFrozen()); for (int i = 0; i < NUM_TESTS; i++) { @@ -1130,7 +1131,7 @@ public class AST2Tests extends AST2BaseTest { // } // } public void testForLoop() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); + IASTTranslationUnit tu = parse(getAboveComment(), C); assertTrue(tu.isFrozen()); for (int i = 0; i < NUM_TESTS; i++) { // void f() { @@ -1204,7 +1205,7 @@ public class AST2Tests extends AST2BaseTest { // ((struct A *) 1)->x; // } public void testExpressionFieldReference() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); + IASTTranslationUnit tu = parse(getAboveComment(), C); assertTrue(tu.isFrozen()); for (int i = 0; i < NUM_TESTS; i++) { IASTSimpleDeclaration simpleDecl = (IASTSimpleDeclaration) tu.getDeclarations()[0]; @@ -1259,7 +1260,7 @@ public class AST2Tests extends AST2BaseTest { // end: ; // } public void testLabels() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); + IASTTranslationUnit tu = parse(getAboveComment(), C); assertTrue(tu.isFrozen()); for (int i = 0; i < NUM_TESTS; i++) { CNameCollector collector = new CNameCollector(); @@ -1294,7 +1295,7 @@ public class AST2Tests extends AST2BaseTest { // typedef struct { } X; // int f(X x); public void testAnonStruct() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); + IASTTranslationUnit tu = parse(getAboveComment(), C); assertTrue(tu.isFrozen()); for (int i = 0; i < NUM_TESTS; i++) { // test tu.getDeclarationsInAST(IBinding) @@ -1329,7 +1330,7 @@ public class AST2Tests extends AST2BaseTest { } public void testLongLong() throws ParserException { - IASTTranslationUnit tu = parse("long long x;\n", ParserLanguage.C); //$NON-NLS-1$ + IASTTranslationUnit tu = parse("long long x;\n", C); //$NON-NLS-1$ // test tu.getDeclarationsInAST(IBinding) IASTSimpleDeclaration decl1 = (IASTSimpleDeclaration) tu @@ -1350,7 +1351,7 @@ public class AST2Tests extends AST2BaseTest { // return; // } public void testEnumerations() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); + IASTTranslationUnit tu = parse(getAboveComment(), C); assertTrue(tu.isFrozen()); for (int i = 0; i < NUM_TESTS; i++) { IASTSimpleDeclaration decl1 = (IASTSimpleDeclaration) tu.getDeclarations()[0]; @@ -1489,7 +1490,7 @@ public class AST2Tests extends AST2BaseTest { } public void testPointerToFunction() throws Exception { - IASTTranslationUnit tu = parse("int (*pfi)();", ParserLanguage.C); //$NON-NLS-1$ + IASTTranslationUnit tu = parse("int (*pfi)();", C); //$NON-NLS-1$ assertTrue(tu.isFrozen()); for (int i = 0; i < NUM_TESTS; i++) { assertEquals(tu.getDeclarations().length, 1); @@ -1520,7 +1521,7 @@ public class AST2Tests extends AST2BaseTest { // const char ** e; // const char * const * const volatile ** const * f; public void testBasicTypes() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); + IASTTranslationUnit tu = parse(getAboveComment(), C); assertTrue(tu.isFrozen()); for (int i = 0; i < NUM_TESTS; i++) { IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu @@ -1623,7 +1624,7 @@ public class AST2Tests extends AST2BaseTest { // unsigned int unsignedInt = 99; // noSpec= 12; public void testBug270275_int_is_equivalent_to_signed_int() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); + IASTTranslationUnit tu = parse(getAboveComment(), C); IASTDeclaration[] declarations = tu.getDeclarations(); IType plainInt = ((IVariable)((IASTSimpleDeclaration) declarations[0]).getDeclarators()[0].getName().resolveBinding()).getType(); IType signedInt = ((IVariable)((IASTSimpleDeclaration) declarations[1]).getDeclarators()[0].getName().resolveBinding()).getType(); @@ -1640,7 +1641,7 @@ public class AST2Tests extends AST2BaseTest { // struct A * const a2; // AP a3; public void testCompositeTypes() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); + IASTTranslationUnit tu = parse(getAboveComment(), C); assertTrue(tu.isFrozen()); for (int i = 0; i < NUM_TESTS; i++) { IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0]; @@ -1717,7 +1718,7 @@ public class AST2Tests extends AST2BaseTest { // const char * const c[][][]; // char* d[const][]; public void testArrayTypes() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); + IASTTranslationUnit tu = parse(getAboveComment(), C); assertTrue(tu.isFrozen()); for (int i = 0; i < NUM_TESTS; i++) { IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0]; @@ -1798,7 +1799,7 @@ public class AST2Tests extends AST2BaseTest { // void (*g) (struct A *); // void (* (*h)(struct A**)) (int d); public void testFunctionTypes() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); + IASTTranslationUnit tu = parse(getAboveComment(), C); assertTrue(tu.isFrozen()); for (int i = 0; i < NUM_TESTS; i++) { IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0]; @@ -1935,7 +1936,7 @@ public class AST2Tests extends AST2BaseTest { // Point point = {.width = 100, .pos = &xy}; // } public void testDesignatedInitializers() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); + IASTTranslationUnit tu = parse(getAboveComment(), C); assertTrue(tu.isFrozen()); for (int i = 0; i < NUM_TESTS; i++) { assertNotNull(tu); @@ -2041,7 +2042,7 @@ public class AST2Tests extends AST2BaseTest { // struct S s = {.a=1,.b=2}; // } public void testMoregetDeclarationsInAST1() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); + IASTTranslationUnit tu = parse(getAboveComment(), C); assertTrue(tu.isFrozen()); for (int i = 0; i < NUM_TESTS; i++) { IASTSimpleDeclaration S_decl = (IASTSimpleDeclaration) tu.getDeclarations()[0]; @@ -2081,7 +2082,7 @@ public class AST2Tests extends AST2BaseTest { // int b; // } s = {.a=1,.b=2}; public void testMoregetDeclarationsInAST2() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); + IASTTranslationUnit tu = parse(getAboveComment(), C); assertTrue(tu.isFrozen()); for (int i = 0; i < NUM_TESTS; i++) { IASTSimpleDeclaration S_decl = (IASTSimpleDeclaration) tu.getDeclarations()[0]; @@ -2122,7 +2123,7 @@ public class AST2Tests extends AST2BaseTest { // typedef t y; // y x = {.a=1,.b=2}; public void testMoregetDeclarationsInAST3() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); + IASTTranslationUnit tu = parse(getAboveComment(), C); assertTrue(tu.isFrozen()); for (int i = 0; i < NUM_TESTS; i++) { IASTSimpleDeclaration S_decl = (IASTSimpleDeclaration) tu.getDeclarations()[0]; @@ -2158,7 +2159,7 @@ public class AST2Tests extends AST2BaseTest { public void testFnReturningPtrToFn() throws Exception { IASTTranslationUnit tu = parse( - "void (* f(int))() {}", ParserLanguage.C); //$NON-NLS-1$ + "void (* f(int))() {}", C); //$NON-NLS-1$ assertTrue(tu.isFrozen()); for (int i = 0; i < NUM_TESTS; i++) { IASTFunctionDefinition def = (IASTFunctionDefinition) tu.getDeclarations()[0]; @@ -2186,7 +2187,7 @@ public class AST2Tests extends AST2BaseTest { // array type derivation. public void testArrayTypeToQualifiedPointerTypeParm() throws Exception { IASTTranslationUnit tu = parse( - "void f(int parm[const 3]);", ParserLanguage.C); //$NON-NLS-1$ + "void f(int parm[const 3]);", C); //$NON-NLS-1$ assertTrue(tu.isFrozen()); for (int i = 0; i < NUM_TESTS; i++) { IASTSimpleDeclaration def = (IASTSimpleDeclaration) tu.getDeclarations()[0]; @@ -2225,7 +2226,7 @@ public class AST2Tests extends AST2BaseTest { // int *f2() {} // int (* f3())() {} public void testFunctionDefTypes() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); + IASTTranslationUnit tu = parse(getAboveComment(), C); assertTrue(tu.isFrozen()); for (int i = 0; i < NUM_TESTS; i++) { @@ -2268,7 +2269,7 @@ public class AST2Tests extends AST2BaseTest { // any parameter to type function returning T is adjusted to be pointer to // function returning T public void testParmToFunction() throws Exception { - IASTTranslationUnit tu = parse("int f(int g(void)) { return g();}", ParserLanguage.C); + IASTTranslationUnit tu = parse("int f(int g(void)) { return g();}", C); assertTrue(tu.isFrozen()); for (int i = 0; i < NUM_TESTS; i++) { IASTFunctionDefinition def = (IASTFunctionDefinition) tu.getDeclarations()[0]; @@ -2304,7 +2305,7 @@ public class AST2Tests extends AST2BaseTest { } public void testArrayPointerFunction() throws Exception { - IASTTranslationUnit tu = parse("int (*v[])(int *x, int *y);", ParserLanguage.C); + IASTTranslationUnit tu = parse("int (*v[])(int *x, int *y);", C); assertTrue(tu.isFrozen()); for (int i = 0; i < NUM_TESTS; i++) { @@ -2349,7 +2350,7 @@ public class AST2Tests extends AST2BaseTest { // typedef DWORD v; // v signal(int); public void testTypedefExample4a() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); + IASTTranslationUnit tu = parse(getAboveComment(), C); assertTrue(tu.isFrozen()); for (int i = 0; i < NUM_TESTS; i++) { @@ -2404,7 +2405,7 @@ public class AST2Tests extends AST2BaseTest { // typedef DWORD (*pfv)(int); // pfv signal(int, pfv); public void testTypedefExample4b() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); + IASTTranslationUnit tu = parse(getAboveComment(), C); assertTrue(tu.isFrozen()); for (int i = 0; i < NUM_TESTS; i++) { IASTSimpleDeclaration decl1 = (IASTSimpleDeclaration) tu.getDeclarations()[0]; @@ -2486,7 +2487,7 @@ public class AST2Tests extends AST2BaseTest { // fv *signal2(int, fv *); // pfv signal3(int, pfv); public void testTypedefExample4c() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); + IASTTranslationUnit tu = parse(getAboveComment(), C); assertTrue(tu.isFrozen()); for (int i = 0; i < NUM_TESTS; i++) { @@ -2575,7 +2576,7 @@ public class AST2Tests extends AST2BaseTest { // int y [ const static x ]; public void testBug80992() throws Exception { ICASTArrayModifier mod = (ICASTArrayModifier) ((IASTArrayDeclarator) ((IASTSimpleDeclaration) parse( - getAboveComment(), ParserLanguage.C).getDeclarations()[1]) + getAboveComment(), C).getDeclarations()[1]) .getDeclarators()[0]).getArrayModifiers()[0]; assertTrue(mod.isConst()); assertTrue(mod.isStatic()); @@ -2588,7 +2589,7 @@ public class AST2Tests extends AST2BaseTest { // int y (int [ const *]); public void testBug80978() throws Exception { ICASTArrayModifier mod = (ICASTArrayModifier) ((IASTArrayDeclarator) ((IASTStandardFunctionDeclarator) ((IASTSimpleDeclaration) parse( - getAboveComment(), ParserLanguage.C).getDeclarations()[0]) + getAboveComment(), C).getDeclarations()[0]) .getDeclarators()[0]).getParameters()[0].getDeclarator()) .getArrayModifiers()[0]; assertTrue(mod.isConst()); @@ -2598,13 +2599,13 @@ public class AST2Tests extends AST2BaseTest { assertFalse(mod.isVolatile()); } - //AJN: bug 77383 don't do external variables + //AJN: bug 77383 don't do external variables // // void f() { // // if (a == 0) // // a = a + 3; // // } // public void testExternalVariable() throws Exception { - // IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); + // IASTTranslationUnit tu = parse(getAboveComment(), C); // CNameCollector col = new CNameCollector(); // tu.accept(col); // @@ -2624,7 +2625,7 @@ public class AST2Tests extends AST2BaseTest { // g(*(&a + 2)); // } public void testExternalDefs() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); + IASTTranslationUnit tu = parse(getAboveComment(), C); assertTrue(tu.isFrozen()); for (int i = 0; i < NUM_TESTS; i++) { CNameCollector col = new CNameCollector(); @@ -2649,7 +2650,7 @@ public class AST2Tests extends AST2BaseTest { // Coord xy = { .x = 10, .y = 11 }; // } public void testFieldDesignators() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); + IASTTranslationUnit tu = parse(getAboveComment(), C); assertTrue(tu.isFrozen()); for (int i = 0; i < NUM_TESTS; i++) { CNameCollector col = new CNameCollector(); @@ -2674,7 +2675,7 @@ public class AST2Tests extends AST2BaseTest { // [member_two] = "two" // }; public void testArrayDesignator() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); + IASTTranslationUnit tu = parse(getAboveComment(), C); assertTrue(tu.isFrozen()); for (int i = 0; i < NUM_TESTS; i++) { CNameCollector col = new CNameCollector(); @@ -2700,7 +2701,7 @@ public class AST2Tests extends AST2BaseTest { // g(*(&a + 2)); // } public void testBug83737() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); + IASTTranslationUnit tu = parse(getAboveComment(), C); assertTrue(tu.isFrozen()); for (int i = 0; i < NUM_TESTS; i++) { IASTIfStatement if_statement = (IASTIfStatement) ((IASTCompoundStatement) ((IASTFunctionDefinition) tu @@ -2730,7 +2731,7 @@ public class AST2Tests extends AST2BaseTest { // end: ; // } public void testBug84090_LabelReferences() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); + IASTTranslationUnit tu = parse(getAboveComment(), C); assertTrue(tu.isFrozen()); for (int i = 0; i < NUM_TESTS; i++) { CNameCollector col = new CNameCollector(); @@ -2750,7 +2751,7 @@ public class AST2Tests extends AST2BaseTest { // enum col { red, blue }; // enum col c; public void testBug84092_EnumReferences() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); + IASTTranslationUnit tu = parse(getAboveComment(), C); assertTrue(tu.isFrozen()); for (int i = 0; i < NUM_TESTS; i++) { CNameCollector collector = new CNameCollector(); @@ -2769,7 +2770,7 @@ public class AST2Tests extends AST2BaseTest { public void testBug84096_FieldDesignatorRef() throws Exception { IASTTranslationUnit tu = parse( - "struct s { int a; } ss = { .a = 1 }; \n", ParserLanguage.C); //$NON-NLS-1$ + "struct s { int a; } ss = { .a = 1 }; \n", C); //$NON-NLS-1$ assertTrue(tu.isFrozen()); for (int i = 0; i < NUM_TESTS; i++) { CNameCollector collector = new CNameCollector(); @@ -2789,7 +2790,7 @@ public class AST2Tests extends AST2BaseTest { public void testProblems() throws Exception { IASTTranslationUnit tu = parse( - " a += ;", ParserLanguage.C, true, false); //$NON-NLS-1$ + " a += ;", C, true, false); //$NON-NLS-1$ IASTProblem[] ps = CVisitor.getProblems(tu); assertEquals(ps.length, 1); ps[0].getMessage(); @@ -2798,7 +2799,7 @@ public class AST2Tests extends AST2BaseTest { // enum e; // enum e{ one }; public void testEnumerationForwards() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); + IASTTranslationUnit tu = parse(getAboveComment(), C); assertTrue(tu.isFrozen()); for (int i = 0; i < NUM_TESTS; i++) { CNameCollector col = new CNameCollector(); @@ -2821,7 +2822,7 @@ public class AST2Tests extends AST2BaseTest { // (&p)[0] = 1; // } public void testBug84185() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); + IASTTranslationUnit tu = parse(getAboveComment(), C); CNameCollector col = new CNameCollector(); tu.accept(col); @@ -2840,7 +2841,7 @@ public class AST2Tests extends AST2BaseTest { // (&p)[0] = 1; // } public void testBug84185_2() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); + IASTTranslationUnit tu = parse(getAboveComment(), C); CNameCollector col = new CNameCollector(); tu.accept(col); @@ -2862,14 +2863,14 @@ public class AST2Tests extends AST2BaseTest { // p = &((struct s) { j++ }); // } public void testBug84176() throws Exception { - parse(getAboveComment(), ParserLanguage.C, false, true); + parse(getAboveComment(), C, false, true); } // struct s { double i; } f(void); // struct s f(void) {} public void testBug84266() throws Exception { final String code = getAboveComment(); - IASTTranslationUnit tu = parse(code, ParserLanguage.C); + IASTTranslationUnit tu = parse(code, C); CNameCollector col = new CNameCollector(); tu.accept(col); assertEquals(col.size(), 7); @@ -2878,7 +2879,7 @@ public class AST2Tests extends AST2BaseTest { ICompositeType s_decl = (ICompositeType) col.getName(0).resolveBinding(); assertSame(s_ref, s_decl); - tu = parse(code, ParserLanguage.C); + tu = parse(code, C); col = new CNameCollector(); tu.accept(col); assertEquals(col.size(), 7); @@ -2889,7 +2890,7 @@ public class AST2Tests extends AST2BaseTest { } public void testBug84266_2() throws Exception { - IASTTranslationUnit tu = parse("struct s f(void);", ParserLanguage.C); //$NON-NLS-1$ + IASTTranslationUnit tu = parse("struct s f(void);", C); //$NON-NLS-1$ CNameCollector col = new CNameCollector(); tu.accept(col); @@ -2898,7 +2899,7 @@ public class AST2Tests extends AST2BaseTest { ICompositeType s = (ICompositeType) col.getName(0).resolveBinding(); assertNotNull(s); - tu = parse("struct s f(void) {}", ParserLanguage.C); //$NON-NLS-1$ + tu = parse("struct s f(void) {}", C); //$NON-NLS-1$ col = new CNameCollector(); tu.accept(col); @@ -2910,7 +2911,7 @@ public class AST2Tests extends AST2BaseTest { public void testBug84250() throws Exception { assertTrue(((IASTDeclarationStatement) ((IASTCompoundStatement) ((IASTFunctionDefinition) parse( - "void f() { int (*p) [2]; }", ParserLanguage.C).getDeclarations()[0]).getBody()).getStatements()[0]).getDeclaration() instanceof IASTSimpleDeclaration); //$NON-NLS-1$ + "void f() { int (*p) [2]; }", C).getDeclarations()[0]).getBody()).getStatements()[0]).getDeclaration() instanceof IASTSimpleDeclaration); //$NON-NLS-1$ } // struct s1 { struct s2 *s2p; /* ... */ }; // D1 @@ -2945,7 +2946,7 @@ public class AST2Tests extends AST2BaseTest { // funcp()->a; // } public void testBug84267() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); + IASTTranslationUnit tu = parse(getAboveComment(), C); CNameCollector col = new CNameCollector(); tu.accept(col); @@ -2972,7 +2973,7 @@ public class AST2Tests extends AST2BaseTest { // { int x = x; } // } public void testBug84228() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); + IASTTranslationUnit tu = parse(getAboveComment(), C); CNameCollector col = new CNameCollector(); tu.accept(col); @@ -2998,7 +2999,7 @@ public class AST2Tests extends AST2BaseTest { public void testBug84236() throws Exception { String code = "double maximum(double a[ ][*]);"; //$NON-NLS-1$ IASTSimpleDeclaration d = (IASTSimpleDeclaration) parse(code, - ParserLanguage.C).getDeclarations()[0]; + C).getDeclarations()[0]; IASTStandardFunctionDeclarator fd = (IASTStandardFunctionDeclarator) d .getDeclarators()[0]; IASTParameterDeclaration p = fd.getParameters()[0]; @@ -3013,7 +3014,7 @@ public class AST2Tests extends AST2BaseTest { // B * bp; //1 // } public void testBug85049() throws Exception { - IASTTranslationUnit t = parse(getAboveComment(), ParserLanguage.C); + IASTTranslationUnit t = parse(getAboveComment(), C); IASTFunctionDefinition g = (IASTFunctionDefinition) t.getDeclarations()[1]; IASTCompoundStatement body = (IASTCompoundStatement) g.getBody(); final IASTStatement statement = body.getStatements()[0]; @@ -3026,7 +3027,7 @@ public class AST2Tests extends AST2BaseTest { public void testBug86766() throws Exception { IASTTranslationUnit tu = parse( - "char foo; void foo() {}", ParserLanguage.C); //$NON-NLS-1$ + "char foo; void foo() {}", C); //$NON-NLS-1$ CNameCollector col = new CNameCollector(); tu.accept(col); @@ -3039,7 +3040,7 @@ public class AST2Tests extends AST2BaseTest { public void testBug88338_C() throws Exception { IASTTranslationUnit tu = parse( - "struct A; struct A* a;", ParserLanguage.C); //$NON-NLS-1$ + "struct A; struct A* a;", C); //$NON-NLS-1$ CPPNameCollector col = new CPPNameCollector(); tu.accept(col); @@ -3048,7 +3049,7 @@ public class AST2Tests extends AST2BaseTest { assertTrue(col.getName(1).isReference()); assertFalse(col.getName(1).isDeclaration()); - tu = parse("struct A* a; struct A;", ParserLanguage.C); //$NON-NLS-1$ + tu = parse("struct A* a; struct A;", C); //$NON-NLS-1$ col = new CPPNameCollector(); tu.accept(col); @@ -3062,7 +3063,7 @@ public class AST2Tests extends AST2BaseTest { } public void test88460() throws Exception { - IASTTranslationUnit tu = parse("void f();", ParserLanguage.C); //$NON-NLS-1$ + IASTTranslationUnit tu = parse("void f();", C); //$NON-NLS-1$ CNameCollector col = new CNameCollector(); tu.accept(col); @@ -3072,7 +3073,7 @@ public class AST2Tests extends AST2BaseTest { public void testBug90253() throws Exception { IASTTranslationUnit tu = parse( - "void f(int par) { int v1; };", ParserLanguage.C); //$NON-NLS-1$ + "void f(int par) { int v1; };", C); //$NON-NLS-1$ CNameCollector col = new CNameCollector(); tu.accept(col); @@ -3101,7 +3102,7 @@ public class AST2Tests extends AST2BaseTest { // } // } public void testFind() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); + IASTTranslationUnit tu = parse(getAboveComment(), C); CNameCollector col = new CNameCollector(); tu.accept(col); @@ -3125,14 +3126,14 @@ public class AST2Tests extends AST2BaseTest { public void test92791() throws Exception { IASTTranslationUnit tu = parse( - "void f() { int x, y; x * y; }", ParserLanguage.C); //$NON-NLS-1$ + "void f() { int x, y; x * y; }", C); //$NON-NLS-1$ CNameCollector col = new CNameCollector(); tu.accept(col); for (int i = 0; i < col.size(); ++i) assertFalse(col.getName(i).resolveBinding() instanceof IProblemBinding); tu = parse( - "int y; void f() { typedef int x; x * y; }", ParserLanguage.C); //$NON-NLS-1$ + "int y; void f() { typedef int x; x * y; }", C); //$NON-NLS-1$ col = new CNameCollector(); tu.accept(col); for (int i = 0; i < col.size(); ++i) @@ -3141,7 +3142,7 @@ public class AST2Tests extends AST2BaseTest { public void testBug85786() throws Exception { IASTTranslationUnit tu = parse( - "void f(int); void foo () { void * p = &f; ((void (*) (int)) p) (1); }", ParserLanguage.C); //$NON-NLS-1$ + "void f(int); void foo () { void * p = &f; ((void (*) (int)) p) (1); }", C); //$NON-NLS-1$ CNameCollector nameResolver = new CNameCollector(); tu.accept(nameResolver); assertNoProblemBindings(nameResolver); @@ -3153,7 +3154,7 @@ public class AST2Tests extends AST2BaseTest { // i= (i)&0x00ff; // } public void testBug95720() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); + IASTTranslationUnit tu = parse(getAboveComment(), C); CNameCollector nameResolver = new CNameCollector(); tu.accept(nameResolver); assertNoProblemBindings(nameResolver); @@ -3168,7 +3169,7 @@ public class AST2Tests extends AST2BaseTest { // return 0; // } public void testBug94365() throws Exception { - parse(getAboveComment(), ParserLanguage.C); + parse(getAboveComment(), C); } // #define MACRO(a) @@ -3176,7 +3177,7 @@ public class AST2Tests extends AST2BaseTest { // MACRO('"'); // } public void testBug95119_a() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); + IASTTranslationUnit tu = parse(getAboveComment(), C); IASTDeclaration[] declarations = tu.getDeclarations(); assertEquals(declarations.length, 1); assertNotNull(declarations[0]); @@ -3192,7 +3193,7 @@ public class AST2Tests extends AST2BaseTest { // MACRO('X'); // } public void testBug95119_b() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C); + IASTTranslationUnit tu = parse(getAboveComment(), C); IASTDeclaration[] declarations = tu.getDeclarations(); assertEquals(declarations.length, 1); assertNotNull(declarations[0]); @@ -3207,13 +3208,13 @@ public class AST2Tests extends AST2BaseTest { // typedef _TYPE TYPE; // int function(TYPE (* pfv)(int parm)); public void testBug81739() throws Exception { - parse(getAboveComment(), ParserLanguage.C); + parse(getAboveComment(), C); } // float _Complex x; // double _Complex y; public void testBug95757() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C, true, true); + IASTTranslationUnit tu = parse(getAboveComment(), C, true, true); IASTDeclaration[] decls = tu.getDeclarations(); assertTrue(((ICASTSimpleDeclSpecifier)((IASTSimpleDeclaration) decls[0]).getDeclSpecifier()).isComplex()); @@ -3226,7 +3227,7 @@ public class AST2Tests extends AST2BaseTest { // typeof({ int x = foo(); // x; }) zoot; public void testBug93980() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C, true); + IASTTranslationUnit tu = parse(getAboveComment(), C, true); CNameCollector col = new CNameCollector(); tu.accept(col); @@ -3240,14 +3241,14 @@ public class AST2Tests extends AST2BaseTest { } public void testBug95866() throws Exception { - IASTTranslationUnit tu = parse("int test[10] = { [0 ... 9] = 2 };", ParserLanguage.C, true, true); //$NON-NLS-1$ + IASTTranslationUnit tu = parse("int test[10] = { [0 ... 9] = 2 };", C, true, true); //$NON-NLS-1$ CNameCollector col = new CNameCollector(); tu.accept(col); assertNoProblemBindings(col); } public void testBug98502() throws Exception { - IASTTranslationUnit tu = parse("typedef enum { ONE } e;", ParserLanguage.C, true, true); //$NON-NLS-1$ + IASTTranslationUnit tu = parse("typedef enum { ONE } e;", C, true, true); //$NON-NLS-1$ CNameCollector col = new CNameCollector(); tu.accept(col); @@ -3263,7 +3264,7 @@ public class AST2Tests extends AST2BaseTest { // PIPERR; // } public void testBug98365() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C, true); + IASTTranslationUnit tu = parse(getAboveComment(), C, true); CNameCollector col = new CNameCollector(); tu.accept(col); @@ -3272,7 +3273,7 @@ public class AST2Tests extends AST2BaseTest { } public void testBug99262() throws Exception { - parse("void foo() {void *f; f=__null;}", ParserLanguage.C, true, true); //$NON-NLS-1$ + parse("void foo() {void *f; f=__null;}", C, true, true); //$NON-NLS-1$ } // void f1(int*) { @@ -3280,7 +3281,7 @@ public class AST2Tests extends AST2BaseTest { // void f2() { // f1(__null); // } - public void testBug240567() throws Exception { + public void testBug240567() throws Exception { BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), false); bh.assertNonProblem("f1(__null", 2, IFunction.class); } @@ -3290,7 +3291,7 @@ public class AST2Tests extends AST2BaseTest { // { a; int a; } // } public void testBug98960() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C, true); + IASTTranslationUnit tu = parse(getAboveComment(), C, true); CNameCollector col = new CNameCollector(); tu.accept(col); @@ -3303,7 +3304,7 @@ public class AST2Tests extends AST2BaseTest { } public void testBug100408() throws Exception { - IASTTranslationUnit tu = parse("int foo() { int x=1; (x)*3; }", ParserLanguage.C); //$NON-NLS-1$ + IASTTranslationUnit tu = parse("int foo() { int x=1; (x)*3; }", C); //$NON-NLS-1$ CNameCollector col = new CNameCollector(); tu.accept(col); assertNoProblemBindings(col); @@ -3319,7 +3320,7 @@ public class AST2Tests extends AST2BaseTest { // { // } public void testBug98760() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C, true); + IASTTranslationUnit tu = parse(getAboveComment(), C, true); CNameCollector col = new CNameCollector(); tu.accept(col); @@ -3396,7 +3397,7 @@ public class AST2Tests extends AST2BaseTest { // blah: x; // } public void testBug104390_2() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C, true); + IASTTranslationUnit tu = parse(getAboveComment(), C, true); CNameCollector col = new CNameCollector(); tu.accept(col); @@ -3429,9 +3430,9 @@ public class AST2Tests extends AST2BaseTest { buffer.append("((int arg1)) {\r\n"); //$NON-NLS-1$ buffer.append("return 0;\r\n"); //$NON-NLS-1$ buffer.append("}\r\n"); //$NON-NLS-1$ - IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C); + IASTTranslationUnit tu = parse(buffer.toString(), C); assertFalse(tu.getDeclarations()[1] instanceof IASTProblemDeclaration); - tu = parse(buffer.toString(), ParserLanguage.CPP); + tu = parse(buffer.toString(), CPP); assertFalse(tu.getDeclarations()[1] instanceof IASTProblemDeclaration); buffer = new StringBuffer(); @@ -3443,9 +3444,9 @@ public class AST2Tests extends AST2BaseTest { buffer.append("((int arg1)) {\n"); //$NON-NLS-1$ buffer.append("return 0;\n"); //$NON-NLS-1$ buffer.append("}\n"); //$NON-NLS-1$ - tu= parse(buffer.toString(), ParserLanguage.C); + tu= parse(buffer.toString(), C); assertFalse(tu.getDeclarations()[1] instanceof IASTProblemDeclaration); - tu= parse(buffer.toString(), ParserLanguage.CPP); + tu= parse(buffer.toString(), CPP); assertFalse(tu.getDeclarations()[1] instanceof IASTProblemDeclaration); } @@ -3459,10 +3460,10 @@ public class AST2Tests extends AST2BaseTest { buffer.append("((int arg1)) {\r\n"); //$NON-NLS-1$ buffer.append("return 0;\r\n"); //$NON-NLS-1$ buffer.append("}\r\n"); //$NON-NLS-1$ - IASTTranslationUnit tu= parse(buffer.toString(), ParserLanguage.C); + IASTTranslationUnit tu= parse(buffer.toString(), C); assertFalse(tu.getDeclarations()[1] instanceof IASTProblemDeclaration); - tu = parse(buffer.toString(), ParserLanguage.CPP); + tu = parse(buffer.toString(), CPP); assertFalse(tu.getDeclarations()[1] instanceof IASTProblemDeclaration); buffer = new StringBuffer(); @@ -3474,9 +3475,9 @@ public class AST2Tests extends AST2BaseTest { buffer.append("((int arg1)) {\n"); //$NON-NLS-1$ buffer.append("return 0;\n"); //$NON-NLS-1$ buffer.append("}\n"); //$NON-NLS-1$ - tu = parse(buffer.toString(), ParserLanguage.C); + tu = parse(buffer.toString(), C); assertFalse(tu.getDeclarations()[1] instanceof IASTProblemDeclaration); - tu = parse(buffer.toString(), ParserLanguage.CPP); + tu = parse(buffer.toString(), CPP); assertFalse(tu.getDeclarations()[1] instanceof IASTProblemDeclaration); } @@ -3522,7 +3523,7 @@ public class AST2Tests extends AST2BaseTest { // return newWindow; // } public void testBug143502() throws Exception { - parse(getAboveComment(), ParserLanguage.C, true, false); + parse(getAboveComment(), C, true, false); } // void func(int a) { @@ -3537,13 +3538,13 @@ public class AST2Tests extends AST2BaseTest { // } public void testBracketAroundIdentifier_168924() throws IOException, ParserException { String content= getAboveComment(); - IASTTranslationUnit tu= parse(content, ParserLanguage.C, true, true); + IASTTranslationUnit tu= parse(content, C, true, true); IASTFunctionDefinition func= (IASTFunctionDefinition) tu.getDeclarations()[0]; IASTParameterDeclaration[] params= ((IASTStandardFunctionDeclarator) func.getDeclarator()).getParameters(); IBinding binding= params[0].getDeclarator().getName().resolveBinding(); assertEquals(7, tu.getReferences(binding).length); - tu= parse(content, ParserLanguage.CPP, true, true); + tu= parse(content, CPP, true, true); func= (IASTFunctionDefinition) tu.getDeclarations()[0]; params= ((IASTStandardFunctionDeclarator) func.getDeclarator()).getParameters(); binding= params[0].getDeclarator().getName().resolveBinding(); @@ -3555,7 +3556,7 @@ public class AST2Tests extends AST2BaseTest { // MAC("); // } public void testBug179383() throws ParserException, IOException { - parse(getAboveComment(), ParserLanguage.C, false, false); + parse(getAboveComment(), C, false, false); } /** @@ -3572,7 +3573,7 @@ public class AST2Tests extends AST2BaseTest { " return func(LIT); // fails to parse\r\n" + "}\r\n"; - IASTTranslationUnit tu = parse(simple, ParserLanguage.CPP, true, true); + IASTTranslationUnit tu = parse(simple, CPP, true, true); // actual reduced test case, plus extra cases String text = @@ -3594,7 +3595,7 @@ public class AST2Tests extends AST2BaseTest { ; // essential test: this code should be parseable - tu = parse(text, ParserLanguage.CPP, true, true); + tu = parse(text, CPP, true, true); // verify macros IASTPreprocessorMacroDefinition[] macroDefinitions = tu.getMacroDefinitions(); @@ -3692,11 +3693,11 @@ public class AST2Tests extends AST2BaseTest { // this should work String textNoComment = noCommentMacro + textTail; - IASTTranslationUnit tu = parse(textNoComment, ParserLanguage.CPP, true, true); + IASTTranslationUnit tu = parse(textNoComment, CPP, true, true); // this fails String textComment = commentMacro + textTail; - tu = parse(textComment, ParserLanguage.CPP, true, true); + tu = parse(textComment, CPP, true, true); } @@ -3716,7 +3717,7 @@ public class AST2Tests extends AST2BaseTest { " } \n" + "}\n"; - parseAndCheckBindings(code, ParserLanguage.C); + parseAndCheckBindings(code, C); } // template @@ -3744,7 +3745,7 @@ public class AST2Tests extends AST2BaseTest { // } // }; public void test186736() throws Exception { - IASTTranslationUnit tu= parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP); + IASTTranslationUnit tu= parseAndCheckBindings(getAboveComment(), CPP); assertTrue(tu.isFrozen()); for (int i = 0; i < NUM_TESTS; i++) { CNameCollector col = new CNameCollector(); @@ -3796,7 +3797,7 @@ public class AST2Tests extends AST2BaseTest { // } // }; public void test186736_variant1() throws Exception { - IASTTranslationUnit tu= parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP); + IASTTranslationUnit tu= parseAndCheckBindings(getAboveComment(), CPP); assertTrue(tu.isFrozen()); for (int i = 0; i < NUM_TESTS; i++) { CNameCollector col = new CNameCollector(); @@ -3834,7 +3835,7 @@ public class AST2Tests extends AST2BaseTest { // (&a)->foo(); // } public void test186736_variant2() throws Exception { - IASTTranslationUnit tu= parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP); + IASTTranslationUnit tu= parseAndCheckBindings(getAboveComment(), CPP); validateCopy(tu); } @@ -3843,8 +3844,8 @@ public class AST2Tests extends AST2BaseTest { // return *p; // } public void test167833() throws Exception { - parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP); - parseAndCheckBindings(getAboveComment(), ParserLanguage.C); + parseAndCheckBindings(getAboveComment(), CPP); + parseAndCheckBindings(getAboveComment(), C); } // // this is a \ @@ -3885,7 +3886,7 @@ public class AST2Tests extends AST2BaseTest { final IBinding typedef = col.getName(12).resolveBinding(); final IBinding secondJ = col.getName(13).resolveBinding(); assertInstance(typedef, ITypedef.class); - if (lang == ParserLanguage.CPP) { + if (lang == CPP) { assertInstance(secondJ, IProblemBinding.class); } else { // for plain C this is actually not a problem, the second J has to be interpreted as a (useless) @@ -3901,8 +3902,8 @@ public class AST2Tests extends AST2BaseTest { // INVALID(1, 2) // public void test192639() throws Exception { - parse(getAboveComment(), ParserLanguage.CPP, false, false); - parse(getAboveComment(), ParserLanguage.C, false, false); + parse(getAboveComment(), CPP, false, false); + parse(getAboveComment(), C, false, false); } public void test195943() throws Exception { @@ -3914,19 +3915,19 @@ public class AST2Tests extends AST2BaseTest { } buffer.append("int a= M" + (depth-1) + ";\n"); long time= System.currentTimeMillis(); - parse(buffer.toString(), ParserLanguage.CPP); - parse(buffer.toString(), ParserLanguage.C); + parse(buffer.toString(), CPP); + parse(buffer.toString(), C); assertTrue(System.currentTimeMillis()-time < 2000); } // int array[12]= {}; public void testBug196468_emptyArrayInitializer() throws Exception { final String content = getAboveComment(); - parse(content, ParserLanguage.CPP, false); - parse(content, ParserLanguage.CPP, true); - parse(content, ParserLanguage.C, true); + parse(content, CPP, false); + parse(content, CPP, true); + parse(content, C, true); try { - parse(content, ParserLanguage.C, false); + parse(content, C, false); fail("C89 does not allow empty braces in array initializer"); } catch (ParserException e) { @@ -3945,16 +3946,16 @@ public class AST2Tests extends AST2BaseTest { // } public void testBug197633_parenthesisInVarargMacros() throws Exception { final String content = getAboveComment(); - parse(content, ParserLanguage.CPP); - parse(content, ParserLanguage.C); + parse(content, CPP); + parse(content, C); } // void (__attribute__((__stdcall__))* foo1) (int); // void (* __attribute__((__stdcall__)) foo2) (int); // void (* __attribute__((__stdcall__))* foo3) (int); public void testBug191450_attributesInBetweenPointers() throws Exception { - parse(getAboveComment(), ParserLanguage.CPP, true, true); - parse(getAboveComment(), ParserLanguage.C, true, true); + parse(getAboveComment(), CPP, true, true); + parse(getAboveComment(), C, true, true); } // class NameClash {}; @@ -3962,7 +3963,7 @@ public class AST2Tests extends AST2BaseTest { // namespace NameClash2 {}; // class NameClash2 {}; public void testBug202271_nameClash() throws Exception { - IASTTranslationUnit tu= parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP, true); + IASTTranslationUnit tu= parseAndCheckBindings(getAboveComment(), CPP, true); assertTrue(tu.isFrozen()); for (int i = 0; i < NUM_TESTS; i++) { CNameCollector col = new CNameCollector(); @@ -3982,7 +3983,7 @@ public class AST2Tests extends AST2BaseTest { // int b= WRAP(MACRO); public void testBug94673_refsForMacrosAsArguments() throws Exception { String content= getAboveComment(); - IASTTranslationUnit tu= parseAndCheckBindings(content, ParserLanguage.CPP, true); + IASTTranslationUnit tu= parseAndCheckBindings(content, CPP, true); IASTPreprocessorMacroDefinition[] defs= tu.getMacroDefinitions(); assertEquals(2, defs.length); IASTPreprocessorMacroDefinition md= defs[1]; @@ -4041,10 +4042,10 @@ public class AST2Tests extends AST2BaseTest { CharSequence[] buffer = getContents(2); final String content1 = buffer[0].toString(); final String content2 = buffer[1].toString(); - parse(content1, ParserLanguage.CPP); - parse(content1, ParserLanguage.C); - parse(content2, ParserLanguage.CPP); - parse(content2, ParserLanguage.C); + parse(content1, CPP); + parse(content1, C); + parse(content2, CPP); + parse(content2, C); } @@ -4065,14 +4066,14 @@ public class AST2Tests extends AST2BaseTest { // // int foo() { // Point p1 = {.x = 1, .y = 2}; - // + // // Line l1 = {.p1 = {.x = 1, .y = 2}, {.x = 1, .y = 2}, {.tag = 5}}; // Line l2 = {.t.tag = 9, .p1.x = 1, .p2.x = 3, .p1.y = 4, .p2.y = 9}; // // Point points[] = {{.x=1, .y=1}, {.x=2, .y=2}}; // } public void _testBug210019_nestedDesignatedInitializers() throws Exception { - IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), ParserLanguage.C); + IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), C); CNameCollector col = new CNameCollector(); tu.accept(col); @@ -4150,7 +4151,7 @@ public class AST2Tests extends AST2BaseTest { // 3, 4 // }; public void testBug210019_designatedInitializers() throws Exception { - IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), ParserLanguage.C); + IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), C); assertTrue(tu.isFrozen()); for (int i = 0; i < NUM_TESTS; i++) { CNameCollector col = new CNameCollector(); @@ -4189,7 +4190,7 @@ public class AST2Tests extends AST2BaseTest { // externFunc(); // } public void testBug183126_nestedLinkageSpecs() throws Exception { - parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP); + parseAndCheckBindings(getAboveComment(), CPP); } // int* i= 0; @@ -4203,7 +4204,7 @@ public class AST2Tests extends AST2BaseTest { // f3(&i); // ok // } public void testBug213029_cvConversion() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, false); + IASTTranslationUnit tu = parse(getAboveComment(), CPP, false); CNameCollector col = new CNameCollector(); tu.accept(col); for (Object o : col.nameList) { @@ -4694,8 +4695,8 @@ public class AST2Tests extends AST2BaseTest { // } public void testOmittedPositiveExpression_212905() throws Exception { final String code = getAboveComment(); - parseAndCheckBindings(code, ParserLanguage.C); - parseAndCheckBindings(code, ParserLanguage.CPP); + parseAndCheckBindings(code, C); + parseAndCheckBindings(code, CPP); } // #define __inline__ __inline__ __attribute__((always_inline)) @@ -4705,16 +4706,16 @@ public class AST2Tests extends AST2BaseTest { // } public void testRedefinedGCCKeywords_226112() throws Exception { final String code = getAboveComment(); - parseAndCheckBindings(code, ParserLanguage.C, true); - parseAndCheckBindings(code, ParserLanguage.CPP, true); + parseAndCheckBindings(code, C, true); + parseAndCheckBindings(code, CPP, true); } // int foo asm ("myfoo") __attribute__((__used__)), ff asm("ss") = 2; // extern void func () asm ("FUNC") __attribute__((__used__)); public void testASMLabels_226121() throws Exception { final String code = getAboveComment(); - parseAndCheckBindings(code, ParserLanguage.C, true); - parseAndCheckBindings(code, ParserLanguage.CPP, true); + parseAndCheckBindings(code, C, true); + parseAndCheckBindings(code, CPP, true); } // void test() { @@ -4722,8 +4723,8 @@ public class AST2Tests extends AST2BaseTest { // } public void testCompoundStatementExpression_226274() throws Exception { final String code = getAboveComment(); - parseAndCheckBindings(code, ParserLanguage.C, true); - parseAndCheckBindings(code, ParserLanguage.CPP, true); + parseAndCheckBindings(code, C, true); + parseAndCheckBindings(code, CPP, true); } // void test(int count) { @@ -4732,8 +4733,8 @@ public class AST2Tests extends AST2BaseTest { // } public void testTypeofUnaryExpression_226492() throws Exception { final String code = getAboveComment(); - parseAndCheckBindings(code, ParserLanguage.C, true); - parseAndCheckBindings(code, ParserLanguage.CPP, true); + parseAndCheckBindings(code, C, true); + parseAndCheckBindings(code, CPP, true); } // void test(int count) { @@ -4741,8 +4742,8 @@ public class AST2Tests extends AST2BaseTest { // } public void testTypeofExpression_226492() throws Exception { final String code = getAboveComment(); - parseAndCheckBindings(code, ParserLanguage.C, true); - parseAndCheckBindings(code, ParserLanguage.CPP, true); + parseAndCheckBindings(code, C, true); + parseAndCheckBindings(code, CPP, true); } // void func() { @@ -4750,8 +4751,8 @@ public class AST2Tests extends AST2BaseTest { // } public void testTypeofExpressionWithAttribute_226492() throws Exception { final String code = getAboveComment(); - parseAndCheckBindings(code, ParserLanguage.C, true); - parseAndCheckBindings(code, ParserLanguage.CPP, true); + parseAndCheckBindings(code, C, true); + parseAndCheckBindings(code, CPP, true); } // void test(int count) { @@ -4762,7 +4763,7 @@ public class AST2Tests extends AST2BaseTest { public void testCaseRange_211882() throws Exception { final String code = getAboveComment(); { - IASTTranslationUnit tu = parseAndCheckBindings(code, ParserLanguage.C, true); + IASTTranslationUnit tu = parseAndCheckBindings(code, C, true); IASTCompoundStatement body = (IASTCompoundStatement)((IASTFunctionDefinition) tu.getDeclarations()[0]).getBody(); IASTSwitchStatement switchStmt = (IASTSwitchStatement) body.getStatements()[0]; IASTCaseStatement caseStmt = (IASTCaseStatement)((IASTCompoundStatement) switchStmt.getBody()).getStatements()[0]; @@ -4772,7 +4773,7 @@ public class AST2Tests extends AST2BaseTest { assertTrue(binExpr.getOperand2() instanceof IASTLiteralExpression); } { - IASTTranslationUnit tu = parseAndCheckBindings(code, ParserLanguage.CPP, true); + IASTTranslationUnit tu = parseAndCheckBindings(code, CPP, true); IASTCompoundStatement body = (IASTCompoundStatement)((IASTFunctionDefinition) tu.getDeclarations()[0]).getBody(); IASTSwitchStatement switchStmt = (IASTSwitchStatement) body.getStatements()[0]; IASTCaseStatement caseStmt = (IASTCaseStatement)((IASTCompoundStatement) switchStmt.getBody()).getStatements()[0]; @@ -4788,8 +4789,8 @@ public class AST2Tests extends AST2BaseTest { // int x(int(TIntPtr)); public void testInfiniteRecursion_269052() throws Exception { final String code= getAboveComment(); - parseAndCheckBindings(code, ParserLanguage.C, true); - parseAndCheckBindings(code, ParserLanguage.CPP, true); + parseAndCheckBindings(code, C, true); + parseAndCheckBindings(code, CPP, true); } // template class X { @@ -4799,29 +4800,29 @@ public class AST2Tests extends AST2BaseTest { // }; public void testTypenameInExpression() throws Exception { final String code = getAboveComment(); - parseAndCheckBindings(code, ParserLanguage.CPP); + parseAndCheckBindings(code, CPP); } // struct __attribute__((declspec)) bla; public void testAttributeInElaboratedTypeSpecifier_227085() throws Exception { final String code = getAboveComment(); - parseAndCheckBindings(code, ParserLanguage.C, true); - parseAndCheckBindings(code, ParserLanguage.CPP, true); + parseAndCheckBindings(code, C, true); + parseAndCheckBindings(code, CPP, true); } // struct X; // void test(struct X* __restrict result); public void testRestrictReference_227110() throws Exception { final String code = getAboveComment(); - parseAndCheckBindings(code, ParserLanguage.CPP, true); + parseAndCheckBindings(code, CPP, true); } // char buf[256]; // int x= sizeof(buf)[0]; public void testSizeofUnaryWithParenthesis_227122() throws Exception { final String code = getAboveComment(); - parseAndCheckBindings(code, ParserLanguage.C); - parseAndCheckBindings(code, ParserLanguage.CPP); + parseAndCheckBindings(code, C); + parseAndCheckBindings(code, CPP); } // class X { @@ -4835,7 +4836,7 @@ public class AST2Tests extends AST2BaseTest { // } public void testPlacementNewInConditionalExpression_227104() throws Exception { final String code = getAboveComment(); - parseAndCheckBindings(code, ParserLanguage.CPP); + parseAndCheckBindings(code, CPP); } // int f(x) { @@ -4843,7 +4844,7 @@ public class AST2Tests extends AST2BaseTest { // } public void testBug228422_noKnrParam() throws Exception { CharSequence buffer = getContents(1)[0]; - parse(buffer.toString(), ParserLanguage.C, false); + parse(buffer.toString(), C, false); } // struct { @@ -4896,8 +4897,8 @@ public class AST2Tests extends AST2BaseTest { // } public void testTypeOfPointerOperations() throws Exception { String code= getAboveComment(); - parseAndCheckBindings(code, ParserLanguage.C); - parseAndCheckBindings(code, ParserLanguage.CPP); + parseAndCheckBindings(code, C); + parseAndCheckBindings(code, CPP); } // int globalArray[4] = {1,2,3,4}; @@ -4960,8 +4961,8 @@ public class AST2Tests extends AST2BaseTest { // } public void testReturnTypeOfBuiltin_234309() throws Exception { String code= getAboveComment(); - parseAndCheckBindings(code, ParserLanguage.C, true); - parseAndCheckBindings(code, ParserLanguage.CPP, true); + parseAndCheckBindings(code, C, true); + parseAndCheckBindings(code, CPP, true); } // typedef void VOID; @@ -5490,7 +5491,7 @@ public class AST2Tests extends AST2BaseTest { // spinlock_t _lock = (spinlock_t) { }; public void testCompoundInitializer_145387() throws Exception { // valid in C99, not in C++. - parseAndCheckBindings(getAboveComment(), ParserLanguage.C, true); + parseAndCheckBindings(getAboveComment(), C, true); } // enum __declspec(uuid("uuid")) bla { a, b}; @@ -5534,8 +5535,8 @@ public class AST2Tests extends AST2BaseTest { // alloc(__func__); // } public void testPredefinedFunctionName_247747() throws Exception { - parseAndCheckBindings(getAboveComment(), ParserLanguage.C, false); - parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP, false); + parseAndCheckBindings(getAboveComment(), C, false); + parseAndCheckBindings(getAboveComment(), CPP, false); } // void alloc(const char * id) {} @@ -5545,16 +5546,16 @@ public class AST2Tests extends AST2BaseTest { // alloc(__PRETTY_FUNCTION__); // } public void testPredefinedFunctionNameGcc_247747() throws Exception { - parseAndCheckBindings(getAboveComment(), ParserLanguage.C, true); - parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP, true); + parseAndCheckBindings(getAboveComment(), C, true); + parseAndCheckBindings(getAboveComment(), CPP, true); } // int foo = 42; // typedef char StupidType; // StupidType const *bar = (StupidType const*)&foo; public void testUnusualDeclSpecOrdering_251514() throws Exception { - parseAndCheckBindings(getAboveComment(), ParserLanguage.C, true); - parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP, true); + parseAndCheckBindings(getAboveComment(), C, true); + parseAndCheckBindings(getAboveComment(), CPP, true); } // #define IF if @@ -5872,7 +5873,7 @@ public class AST2Tests extends AST2BaseTest { // {1,2,3}, // 1.2, // { - + // 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // } @@ -5978,8 +5979,8 @@ public class AST2Tests extends AST2BaseTest { // } public void testNestedDeclarator_257540() throws Exception { final String code= getAboveComment(); - parseAndCheckBindings(code, ParserLanguage.C); - parseAndCheckBindings(code, ParserLanguage.CPP); + parseAndCheckBindings(code, C); + parseAndCheckBindings(code, CPP); } // typedef struct { @@ -5992,8 +5993,8 @@ public class AST2Tests extends AST2BaseTest { // } public void testCompoundLiterals_258496() throws Exception { final String code= getAboveComment(); - parseAndCheckBindings(code, ParserLanguage.C); - parseAndCheckBindings(code, ParserLanguage.CPP); + parseAndCheckBindings(code, C); + parseAndCheckBindings(code, CPP); } // __thread int i; @@ -6001,8 +6002,8 @@ public class AST2Tests extends AST2BaseTest { // extern __thread int k; public void testThreadLocalVariables_260387() throws Exception { final String code= getAboveComment(); - parseAndCheckBindings(code, ParserLanguage.C, true); - parseAndCheckBindings(code, ParserLanguage.CPP, true); + parseAndCheckBindings(code, C, true); + parseAndCheckBindings(code, CPP, true); } // void test() { @@ -6027,7 +6028,7 @@ public class AST2Tests extends AST2BaseTest { // }; public void testAmbiguousDeclaration_259373() throws Exception { final String code= getAboveComment(); - IASTTranslationUnit tu= parseAndCheckBindings(code, ParserLanguage.C, true); + IASTTranslationUnit tu= parseAndCheckBindings(code, C, true); BindingAssertionHelper bh= new BindingAssertionHelper(code, false); ITypedef td= bh.assertNonProblem("TInt; //", 4); IField f= bh.assertNonProblem("a;", 1); @@ -6062,7 +6063,7 @@ public class AST2Tests extends AST2BaseTest { for (ParserLanguage lang : ParserLanguage.values()) { IASTTranslationUnit tu= parseAndCheckBindings(code, lang, true); - BindingAssertionHelper ba= new BindingAssertionHelper(code, lang == ParserLanguage.CPP); + BindingAssertionHelper ba= new BindingAssertionHelper(code, lang == CPP); ITypedef t= ba.assertNonProblem("A;", 1); ICompositeType s1= ba.assertNonProblem("A; // struct", 1); ICompositeType s2= ba.assertNonProblem("A*", 1); @@ -6072,7 +6073,7 @@ public class AST2Tests extends AST2BaseTest { } // typedef long unsigned int size_t; - // + // // size_t a = 0; // size_t x = a + 5; // size_t y = 2 + a; @@ -6095,7 +6096,7 @@ public class AST2Tests extends AST2BaseTest { // typedef void* VoidPtr; // typedef VoidPtr (*Func)(); - // + // // void test(Func f) { // f(); // } @@ -6127,7 +6128,7 @@ public class AST2Tests extends AST2BaseTest { public void testSizeofFunctionType_252243() throws Exception { final String code= getAboveComment(); for (ParserLanguage lang : ParserLanguage.values()) { - BindingAssertionHelper ba= new BindingAssertionHelper(code, lang == ParserLanguage.CPP); + BindingAssertionHelper ba= new BindingAssertionHelper(code, lang == CPP); ba.assertProblem("y));", 1); IVariable v= ba.assertNonProblem("y);", 1); } @@ -6341,7 +6342,7 @@ public class AST2Tests extends AST2BaseTest { // __TIME__; // } public void testPredefinedMacroNamesC() throws Exception { - parseAndCheckBindings(getAboveComment(), ParserLanguage.C); + parseAndCheckBindings(getAboveComment(), C); } // long double longDouble = 1.0; @@ -6872,7 +6873,7 @@ public class AST2Tests extends AST2BaseTest { // int MyGlobal[10]; // public void testBug273797() throws Exception { - IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), ParserLanguage.C); + IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), C); IASTName n = ((IASTSimpleDeclaration) tu.getDeclarations()[0]).getDeclarators()[0].getName(); IVariable v = (IVariable) n.resolveBinding(); @@ -6894,7 +6895,7 @@ public class AST2Tests extends AST2BaseTest { // (int) value1; // } public void testBug278797() throws Exception { - IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), ParserLanguage.C); + IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), C); IASTFunctionDefinition func = (IASTFunctionDefinition) tu.getDeclarations()[1]; IASTExpressionStatement stmt = ((IASTExpressionStatement)((IASTCompoundStatement) func.getBody()).getStatements()[0]); IType t = ((IASTCastExpression) stmt.getExpression()).getOperand().getExpressionType(); @@ -6994,7 +6995,7 @@ public class AST2Tests extends AST2BaseTest { // structure.ptr = goo; // } public void testBindingsOnFields() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C, false); + IASTTranslationUnit tu = parse(getAboveComment(), C, false); IASTCompoundStatement bodyStmt = (IASTCompoundStatement)((IASTFunctionDefinition) tu.getDeclarations()[2]).getBody(); // Get the IFields bindings from the type used in the declaration of structure @@ -7006,7 +7007,7 @@ public class AST2Tests extends AST2BaseTest { // Get the IField for the first assignment IASTFieldReference ref1 = (IASTFieldReference)((IASTBinaryExpression)((IASTExpressionStatement) bodyStmt.getStatements()[1]).getExpression()).getOperand1(); IBinding field1 = ref1.getFieldName().resolveBinding(); - + // Get the IField for the second assignment IASTFieldReference ref2 = (IASTFieldReference)((IASTBinaryExpression)((IASTExpressionStatement) bodyStmt.getStatements()[2]).getExpression()).getOperand1(); IBinding field2 = ref2.getFieldName().resolveBinding(); @@ -7014,7 +7015,7 @@ public class AST2Tests extends AST2BaseTest { // Compare the IField from the type and the assignments assertEquals(fields[0], field1); assertEquals(fields[1], field2); // fails - + assertEquals(1, ((ICInternalBinding) field1).getDeclarations().length); assertEquals(1, ((ICInternalBinding) field2).getDeclarations().length); } @@ -7092,8 +7093,8 @@ public class AST2Tests extends AST2BaseTest { // int a[1]; public void testIncompleteArrays_269926() throws Exception { final String code = getAboveComment(); - parseAndCheckBindings(code, ParserLanguage.C); - parseAndCheckBindings(code, ParserLanguage.CPP); + parseAndCheckBindings(code, C); + parseAndCheckBindings(code, CPP); } // void f1(const int* p); @@ -7146,7 +7147,7 @@ public class AST2Tests extends AST2BaseTest { // static a[2]= {0,0}; public void testSkipAggregateInitializer_297550() throws Exception { final String code = getAboveComment(); - parseAndCheckBindings(code, ParserLanguage.C, false, true); + parseAndCheckBindings(code, C, false, true); } // typeof(b(1)) b(int); @@ -7187,8 +7188,8 @@ public class AST2Tests extends AST2BaseTest { // void f () __attribute__ ((int)); public void testAttributeSyntax_298841() throws Exception { final String code = getAboveComment(); - parseAndCheckBindings(code, ParserLanguage.C, true); - parseAndCheckBindings(code, ParserLanguage.CPP, true); + parseAndCheckBindings(code, C, true); + parseAndCheckBindings(code, CPP, true); } // void func(int* obj) { @@ -7211,7 +7212,7 @@ public class AST2Tests extends AST2BaseTest { // ONCE() public void testPragmaOperator_294730() throws Exception { final String code = getAboveComment(); - IASTTranslationUnit tu= parseAndCheckBindings(code, ParserLanguage.C); + IASTTranslationUnit tu= parseAndCheckBindings(code, C); IASTPreprocessorStatement[] stmts = tu.getAllPreprocessorStatements(); assertEquals(5, stmts.length); for (int i = 2; i < stmts.length; i++) { @@ -7219,7 +7220,7 @@ public class AST2Tests extends AST2BaseTest { assertInstance(stmt, IASTPreprocessorPragmaStatement.class); assertEquals(i>2, ((IASTPreprocessorPragmaStatement) stmt).isPragmaOperator()); } - tu= parseAndCheckBindings(code, ParserLanguage.CPP); + tu= parseAndCheckBindings(code, CPP); assertEquals(5, stmts.length); for (int i = 2; i < stmts.length; i++) { IASTPreprocessorStatement stmt = stmts[i]; @@ -7234,8 +7235,8 @@ public class AST2Tests extends AST2BaseTest { // } public void testFunctionNameExpression() throws Exception { final String code = getAboveComment(); - parseAndCheckBindings(code, ParserLanguage.C, true); - parseAndCheckBindings(code, ParserLanguage.CPP, true); + parseAndCheckBindings(code, C, true); + parseAndCheckBindings(code, CPP, true); } // #define MACRO @@ -7264,8 +7265,8 @@ public class AST2Tests extends AST2BaseTest { // } public void testVaArgWithFunctionPtr_311030() throws Exception { final String code = getAboveComment(); - parseAndCheckBindings(code, ParserLanguage.C, true); - parseAndCheckBindings(code, ParserLanguage.CPP, true); + parseAndCheckBindings(code, C, true); + parseAndCheckBindings(code, CPP, true); } // void test() { @@ -7308,7 +7309,7 @@ public class AST2Tests extends AST2BaseTest { public void testPtrDiffRecursion_317004() throws Exception { final String comment = getAboveComment(); String code= comment; - parseAndCheckBindings(code, ParserLanguage.C, true); + parseAndCheckBindings(code, C, true); BindingAssertionHelper bh= new BindingAssertionHelper(code, false); ITypedef td= bh.assertNonProblem("ptrdiff_t", 0); assertEquals("int", ASTTypeUtil.getType(td.getType())); @@ -7316,7 +7317,7 @@ public class AST2Tests extends AST2BaseTest { assertEquals("unsigned long int", ASTTypeUtil.getType(td.getType())); code= "namespace std {" + comment + "}"; - parseAndCheckBindings(code, ParserLanguage.CPP, true); + parseAndCheckBindings(code, CPP, true); bh= new BindingAssertionHelper(code, true); td= bh.assertNonProblem("ptrdiff_t", 0); assertEquals("int", ASTTypeUtil.getType(td.getType())); @@ -7365,14 +7366,14 @@ public class AST2Tests extends AST2BaseTest { // } public void testTypeOfSizeof_355052() throws Exception { final String code = getAboveComment(); - IASTTranslationUnit tu= parseAndCheckBindings(code, ParserLanguage.CPP); + IASTTranslationUnit tu= parseAndCheckBindings(code, CPP); IASTFunctionDefinition a= getDeclaration(tu, 0); IASTExpressionStatement es= getStatement(a, 1); assertEquals("unsigned long int", ASTTypeUtil.getType(es.getExpression().getExpressionType())); es= getStatement(a, 2); assertEquals("unsigned long int", ASTTypeUtil.getType(es.getExpression().getExpressionType())); - tu= parseAndCheckBindings(code, ParserLanguage.C); + tu= parseAndCheckBindings(code, C); a= getDeclaration(tu, 0); es= getStatement(a, 1); assertEquals("unsigned long int", ASTTypeUtil.getType(es.getExpression().getExpressionType())); @@ -7420,9 +7421,9 @@ public class AST2Tests extends AST2BaseTest { public void testGCCDecltype_397227() throws Exception { parseAndCheckBindings(getAboveComment(), CPP, true); } - + // #define macro(R) #R"" public void testNoRawStringInPlainC_397127() throws Exception { - parseAndCheckBindings(getAboveComment(), ParserLanguage.C, true); + parseAndCheckBindings(getAboveComment(), C, true); } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2UtilOldTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2UtilOldTests.java index 1bf32ed357a..f98a9a69e3a 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2UtilOldTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2UtilOldTests.java @@ -17,7 +17,7 @@ import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.core.parser.ParserLanguage; -public class AST2UtilOldTests extends AST2BaseTest { +public class AST2UtilOldTests extends AST2TestBase { public AST2UtilOldTests() { } public AST2UtilOldTests(String name) { diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2UtilTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2UtilTests.java index 12f3c43ecc4..d4a7c5802ac 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2UtilTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2UtilTests.java @@ -27,7 +27,7 @@ import org.eclipse.cdt.internal.core.parser.scanner.ExpressionEvaluator; /** * @author dsteffle */ -public class AST2UtilTests extends AST2BaseTest { +public class AST2UtilTests extends AST2TestBase { public AST2UtilTests() { } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ASTCPPSpecDefectTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ASTCPPSpecDefectTests.java index 3a67049702c..0c7433d461f 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ASTCPPSpecDefectTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ASTCPPSpecDefectTests.java @@ -19,7 +19,7 @@ import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.core.dom.ast.IProblemBinding; import org.eclipse.cdt.core.parser.ParserLanguage; -public class ASTCPPSpecDefectTests extends AST2BaseTest { +public class ASTCPPSpecDefectTests extends AST2TestBase { public ASTCPPSpecDefectTests() { } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ASTInactiveCodeTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ASTInactiveCodeTests.java index e1ef4945dbb..873b1bda0a8 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ASTInactiveCodeTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ASTInactiveCodeTests.java @@ -28,7 +28,7 @@ import org.eclipse.cdt.core.parser.ParserLanguage; /** * Testcases for inactive code in ast. */ -public class ASTInactiveCodeTests extends AST2BaseTest { +public class ASTInactiveCodeTests extends AST2TestBase { public static TestSuite suite() { return suite(ASTInactiveCodeTests.class); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ASTNodeSelectorTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ASTNodeSelectorTest.java index 29ff910dbfb..4bb56ea205e 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ASTNodeSelectorTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ASTNodeSelectorTest.java @@ -28,7 +28,7 @@ import org.eclipse.cdt.core.parser.ParserMode; import org.eclipse.cdt.core.parser.ScannerInfo; import org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser; -public class ASTNodeSelectorTest extends AST2BaseTest { +public class ASTNodeSelectorTest extends AST2TestBase { static public TestSuite suite() { return suite(ASTNodeSelectorTest.class); @@ -55,7 +55,7 @@ public class ASTNodeSelectorTest extends AST2BaseTest { fCode= getContents(1)[0].toString(); FileContent codeReader = FileContent.create("", fCode.toCharArray()); ScannerInfo scannerInfo = new ScannerInfo(); - IScanner scanner= AST2BaseTest.createScanner(codeReader, ParserLanguage.CPP, ParserMode.COMPLETE_PARSE, scannerInfo); + IScanner scanner= AST2TestBase.createScanner(codeReader, ParserLanguage.CPP, ParserMode.COMPLETE_PARSE, scannerInfo); GNUCPPSourceParser parser= new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE, new NullLogService(), new GPPParserExtensionConfiguration()); fTu= parser.parse(); fSelector= fTu.getNodeSelector(null); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AccessControlTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AccessControlTests.java index 11bbfd143b2..922026b0dce 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AccessControlTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AccessControlTests.java @@ -18,7 +18,7 @@ import org.eclipse.cdt.core.parser.ParserLanguage; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.AccessContext; import org.eclipse.cdt.internal.core.parser.ParserException; -public class AccessControlTests extends AST2BaseTest { +public class AccessControlTests extends AST2TestBase { protected class AccessAssertionHelper extends BindingAssertionHelper { AccessAssertionHelper(String contents) throws ParserException { diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CDOMBaseTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CDOMTestBase.java similarity index 86% rename from core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CDOMBaseTest.java rename to core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CDOMTestBase.java index c59ded324af..9059c090e2c 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CDOMBaseTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CDOMTestBase.java @@ -13,22 +13,22 @@ package org.eclipse.cdt.core.parser.tests.ast2; import org.eclipse.cdt.core.dom.CDOM; import org.eclipse.cdt.core.dom.IASTServiceProvider.UnsupportedDialectException; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; -import org.eclipse.cdt.core.parser.tests.FileBasePluginTest; +import org.eclipse.cdt.core.parser.tests.FileBasePluginTestCase; import org.eclipse.core.resources.IFile; /** * @author dsteffle */ -public class CDOMBaseTest extends FileBasePluginTest { +public class CDOMTestBase extends FileBasePluginTestCase { - public CDOMBaseTest() { + public CDOMTestBase() { } - public CDOMBaseTest(String name) { + public CDOMTestBase(String name) { super(name); } - public CDOMBaseTest(String name, Class className) { + public CDOMTestBase(String name, Class className) { super(name, className); } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CodeReaderCacheTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CodeReaderCacheTest.java index e17d7fd1e6a..e557b30625e 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CodeReaderCacheTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CodeReaderCacheTest.java @@ -26,7 +26,7 @@ import org.eclipse.core.runtime.jobs.Job; /** * @author dsteffle */ -public class CodeReaderCacheTest extends CDOMBaseTest { +public class CodeReaderCacheTest extends CDOMTestBase { public CodeReaderCacheTest() { } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CommentTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CommentTests.java index b60b13cb03c..ca8d20b7f90 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CommentTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CommentTests.java @@ -23,7 +23,7 @@ import org.eclipse.cdt.internal.core.parser.ParserException; * @author Guido Zgraggen * */ -public class CommentTests extends AST2BaseTest { +public class CommentTests extends AST2TestBase { public static TestSuite suite() { return suite(CommentTests.class); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CompleteParser2Tests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CompleteParser2Tests.java index d2c052b0c22..b6afaf309c4 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CompleteParser2Tests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CompleteParser2Tests.java @@ -1,13 +1,14 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 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 - Initial API and implementation - * Markus Schorn (Wind River Systems) + * IBM - Initial API and implementation + * Markus Schorn (Wind River Systems) + * Nathan Ridge *******************************************************************************/ package org.eclipse.cdt.core.parser.tests.ast2; @@ -102,9 +103,13 @@ public class CompleteParser2Tests extends BaseTestCase { } static private class CPPNameCollector extends ASTVisitor { - { - shouldVisitNames = true; + public CPPNameCollector() { + this(false); // don't visit implicit names by default } + public CPPNameCollector(boolean shouldVisitImplicitNames) { + this.shouldVisitNames = true; + this.shouldVisitImplicitNames = shouldVisitImplicitNames; + } public List nameList = new ArrayList(); @Override public int visit(IASTName name){ @@ -141,7 +146,7 @@ public class CompleteParser2Tests extends BaseTestCase { if (nameCollector.getName(i).resolveBinding() == binding) count++; - assertEquals(count, num); + assertEquals(num, count); } protected void assertInstances(CNameCollector nameCollector, IBinding binding, int num) throws Exception { int count = 0; @@ -149,7 +154,7 @@ public class CompleteParser2Tests extends BaseTestCase { if (nameCollector.getName(i).resolveBinding() == binding) count++; - assertEquals(count, num); + assertEquals(num, count); } protected IASTTranslationUnit parse(String code, boolean expectedToPass, ParserLanguage lang) throws Exception { @@ -172,7 +177,7 @@ public class CompleteParser2Tests extends BaseTestCase { FileContent codeReader = FileContent.create("", code.toCharArray()); ScannerInfo scannerInfo = new ScannerInfo(); ISourceCodeParser parser2 = null; - IScanner scanner= AST2BaseTest.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo); + IScanner scanner= AST2TestBase.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo); if (lang == ParserLanguage.CPP) { ICPPParserExtensionConfiguration config = null; if (gcc) @@ -750,7 +755,7 @@ public class CompleteParser2Tests extends BaseTestCase { } public void testConstructorChain() throws Exception { - IASTTranslationUnit tu = parse("int x = 5;\n class A \n{ public : \n int a; \n A() : a(x) { } };"); + IASTTranslationUnit tu = parse("int x = 5;\n class A \n{ public : \n int a; \n A() : a(x) { } };"); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); @@ -1053,7 +1058,7 @@ public class CompleteParser2Tests extends BaseTestCase { } public void testScoping() throws Exception { - IASTTranslationUnit tu = parse("void foo() { int x = 3; if (x == 1) { int x = 4; } else int x = 2; }"); + IASTTranslationUnit tu = parse("void foo() { int x = 3; if (x == 1) { int x = 4; } else int x = 2; }"); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); @@ -1098,7 +1103,7 @@ public class CompleteParser2Tests extends BaseTestCase { } public void testBug42872() throws Exception { - IASTTranslationUnit tu = parse("struct B {}; struct D : B {}; void foo(D* dp) { B* bp = dynamic_cast(dp); }"); + IASTTranslationUnit tu = parse("struct B {}; struct D : B {}; void foo(D* dp) { B* bp = dynamic_cast(dp); }"); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); @@ -1112,14 +1117,14 @@ public class CompleteParser2Tests extends BaseTestCase { public void testBug43503A() throws Exception { IASTTranslationUnit tu = parse("class SD_01 { void f_SD_01() {}}; int main(){ SD_01 * a = new SD_01(); a->f_SD_01(); } "); - CPPNameCollector col = new CPPNameCollector(); + CPPNameCollector col = new CPPNameCollector(true); tu.accept(col); - assertEquals(col.size(), 8); + assertEquals(col.size(), 9); ICPPClassType SD_01 = (ICPPClassType) col.getName(0).resolveBinding(); ICPPMethod f_SD_01 = (ICPPMethod) col.getName(1).resolveBinding(); ICPPConstructor ctor = SD_01.getConstructors()[0]; - assertInstances(col, SD_01, 2); + assertInstances(col, SD_01, 3); assertInstances(col, ctor, 1); assertInstances(col, f_SD_01, 2); } @@ -1204,10 +1209,10 @@ public class CompleteParser2Tests extends BaseTestCase { buff.append("} \n"); IASTTranslationUnit tu = parse(buff.toString()); - CPPNameCollector col = new CPPNameCollector(); + CPPNameCollector col = new CPPNameCollector(true); tu.accept(col); - assertEquals(col.size(), 17); + assertEquals(col.size(), 18); ICompositeType SD_02 = (ICompositeType) col.getName(0).resolveBinding(); ICPPMethod f_SD_02 = (ICPPMethod) col.getName(1).resolveBinding(); ICPPClassType SD_01 = (ICPPClassType) col.getName(2).resolveBinding(); @@ -1217,7 +1222,7 @@ public class CompleteParser2Tests extends BaseTestCase { assertInstances(col, SD_02, 2); assertInstances(col, f_SD_02, 2); - assertInstances(col, SD_01, 3); + assertInstances(col, SD_01, 4); assertInstances(col, ctor, 1); assertInstances(col, next, 2); assertInstances(col, f_SD_01, 4); @@ -1268,10 +1273,10 @@ public class CompleteParser2Tests extends BaseTestCase { public void testBug44342() throws Exception { IASTTranslationUnit tu = parse("class A { void f(){} void f(int){} }; int main(){ A * a = new A(); a->f();} "); - CPPNameCollector col = new CPPNameCollector(); + CPPNameCollector col = new CPPNameCollector(true); tu.accept(col); - assertEquals(col.size(), 10); + assertEquals(col.size(), 11); ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding(); ICPPMethod f1 = (ICPPMethod) col.getName(1).resolveBinding(); ICPPMethod f2 = (ICPPMethod) col.getName(2).resolveBinding(); @@ -1279,7 +1284,7 @@ public class CompleteParser2Tests extends BaseTestCase { ICPPConstructor ctor = A.getConstructors()[0]; IVariable a = (IVariable) col.getName(6).resolveBinding(); - assertInstances(col, A, 2); + assertInstances(col, A, 3); assertInstances(col, f1, 2); assertInstances(col, f2, 1); assertInstances(col, ctor, 1); @@ -1288,7 +1293,7 @@ public class CompleteParser2Tests extends BaseTestCase { public void testCDesignatedInitializers() throws Exception { StringBuffer buffer = new StringBuffer(); - buffer.append("struct Inner { int a,b,c; };"); + buffer.append("struct Inner { int a,b,c; };"); buffer.append("struct A { int x; int y[]; struct Inner innerArray[]; int z[]; };"); buffer.append("struct A myA = { .x = 4, .y[3] = 4, .y[4] = 3, .innerArray[0].a = 3, .innerArray[1].b = 5, .innerArray[2].c=6, .z = { 1,4,5} };"); parse(buffer.toString(), true, ParserLanguage.C); @@ -1314,7 +1319,7 @@ public class CompleteParser2Tests extends BaseTestCase { " _Bool b; " + " f(b);" + " f(g((_Bool) 1) );" + - "}", + "}", true, ParserLanguage.C); } @@ -1337,7 +1342,7 @@ public class CompleteParser2Tests extends BaseTestCase { public void testBug44925() throws Exception { StringBuffer buffer = new StringBuffer(); - buffer.append("class MyClass { };"); + buffer.append("class MyClass { };"); buffer.append("class MyClass myObj1;"); buffer.append("enum MyEnum { Item1 };"); buffer.append("enum MyEnum myObj2;"); @@ -1420,23 +1425,23 @@ public class CompleteParser2Tests extends BaseTestCase { buffer.append("void main() { N::A * a = new N::A(); a->f(); } "); IASTTranslationUnit tu = parse(buffer.toString()); - CPPNameCollector col = new CPPNameCollector(); + CPPNameCollector col = new CPPNameCollector(true); tu.accept(col); - assertEquals(col.size(), 13); + assertEquals(col.size(), 14); ICPPNamespace N = (ICPPNamespace) col.getName(0).resolveBinding(); IFunction f = (IFunction) col.getName(1).resolveBinding(); ICPPClassType A = (ICPPClassType) col.getName(2).resolveBinding(); ICPPConstructor ctor = A.getConstructors()[0]; - IProblemBinding fp = (IProblemBinding) col.getName(12).resolveBinding(); + IProblemBinding fp = (IProblemBinding) col.getName(13).resolveBinding(); assertEquals(fp.getID(), IProblemBinding.SEMANTIC_NAME_NOT_FOUND); assertInstances(col, N, 3); assertInstances(col, f, 1); - assertInstances(col, A, 3); - assertInstances(col, ctor, 2); + assertInstances(col, A, 5); + assertInstances(col, ctor, 1); } public void testBug43110() throws Exception { @@ -1994,7 +1999,7 @@ public class CompleteParser2Tests extends BaseTestCase { writer.write("int main(int argc, char **argv) {\n"); writer.write("FILE * file = 0;\n"); writer.write("static_function(file);\n"); - writer.write("return 0;\n"); + writer.write("return 0;\n"); writer.write("}\n"); parse(writer.toString()); } @@ -2046,8 +2051,8 @@ public class CompleteParser2Tests extends BaseTestCase { writer.write("};\n"); writer.write("\n"); writer.write("template\n"); - writer.write("inline T526026< T >\n"); - writer.write("operator+(typename T526026::diff d, const T526026 & x)\n"); + writer.write("inline T526026< T >\n"); + writer.write("operator+(typename T526026::diff d, const T526026 & x)\n"); writer.write("{ return T526026< T >(); }\n"); writer.write("}\n"); parse(writer.toString(), false); @@ -2055,7 +2060,7 @@ public class CompleteParser2Tests extends BaseTestCase { public void testBug71094() throws Exception { Writer writer = new StringWriter(); - writer.write("using namespace DOESNOTEXIST;\n"); + writer.write("using namespace DOESNOTEXIST;\n"); writer.write("class A { int x; };\n"); parse(writer.toString(), false); } @@ -2223,7 +2228,7 @@ public class CompleteParser2Tests extends BaseTestCase { public void testBug74328() throws Exception { Writer writer = new StringWriter(); - writer.write("int\n"); + writer.write("int\n"); writer.write("main(int argc, char **argv) {\n"); writer.write(" char *sign;\n"); writer.write("sign = \"\"; // IProblem generated here, syntax error\n"); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMGCCSelectionParseExtensionsTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMGCCSelectionParseExtensionsTest.java index f1256dd05a4..f6daa2ad12d 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMGCCSelectionParseExtensionsTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMGCCSelectionParseExtensionsTest.java @@ -19,7 +19,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNode; * @author jcamelon * */ -public class DOMGCCSelectionParseExtensionsTest extends DOMSelectionParseBaseTest { +public class DOMGCCSelectionParseExtensionsTest extends DOMSelectionParseTestBase { public DOMGCCSelectionParseExtensionsTest() { } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationInclusionTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationInclusionTests.java index 7c7b93a3234..ddc30d2f5c1 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationInclusionTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationInclusionTests.java @@ -44,7 +44,7 @@ import org.eclipse.core.runtime.content.IContentType; /** * @author jcamelon */ -public class DOMLocationInclusionTests extends AST2FileBasePluginTest { +public class DOMLocationInclusionTests extends AST2FileBasePluginTestCase { public DOMLocationInclusionTests() { } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationMacroTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationMacroTests.java index 27c22c01543..c4a25dba2b9 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationMacroTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationMacroTests.java @@ -35,7 +35,7 @@ import org.eclipse.cdt.core.dom.ast.IMacroBinding; import org.eclipse.cdt.core.parser.ParserLanguage; import org.eclipse.cdt.internal.core.parser.ParserException; -public class DOMLocationMacroTests extends AST2BaseTest { +public class DOMLocationMacroTests extends AST2TestBase { final ParserLanguage[] languages = new ParserLanguage[] { ParserLanguage.C, ParserLanguage.CPP }; diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationTests.java index 80ec78f9b37..df72e0c9215 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationTests.java @@ -73,7 +73,7 @@ import org.eclipse.cdt.internal.core.parser.ParserException; /** * @author jcamelon */ -public class DOMLocationTests extends AST2BaseTest { +public class DOMLocationTests extends AST2TestBase { public DOMLocationTests() { } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMPreprocessorInformationTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMPreprocessorInformationTest.java index 325fc03f6dd..716098f44d3 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMPreprocessorInformationTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMPreprocessorInformationTest.java @@ -32,7 +32,7 @@ import org.eclipse.cdt.core.parser.ParserLanguage; * @author Emanuel Graf * */ -public class DOMPreprocessorInformationTest extends AST2BaseTest { +public class DOMPreprocessorInformationTest extends AST2TestBase { public void testPragma() throws Exception { String msg = "GCC poison printf sprintf fprintf"; diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMSelectionParseTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMSelectionParseTest.java index 9d59cf1c8b2..923bdf95206 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMSelectionParseTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMSelectionParseTest.java @@ -1,13 +1,14 @@ /******************************************************************************* - * Copyright (c) 2002, 2010 IBM Corporation and others. + * Copyright (c) 2002, 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 Rational Software - Initial API and implementation - * Markus Schorn (Wind River Systems) + * IBM Rational Software - Initial API and implementation + * Markus Schorn (Wind River Systems) + * Nathan Ridge *******************************************************************************/ package org.eclipse.cdt.core.parser.tests.ast2; @@ -43,7 +44,7 @@ import org.eclipse.core.resources.IFile; /** * @author dsteffle */ -public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { +public class DOMSelectionParseTest extends DOMSelectionParseTestBase { public DOMSelectionParseTest() { } @@ -56,8 +57,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { super(name, DOMSelectionParseTest.class); } - public void testBaseCase_VariableReference() throws Exception - { + public void testBaseCase_VariableReference() throws Exception { String code = "void f() { int x; x=3; }"; //$NON-NLS-1$ int offset1 = code.indexOf( "x=" ); //$NON-NLS-1$ int offset2 = code.indexOf( '='); @@ -72,8 +72,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { assertEquals( ((ASTNode)decls[0]).getLength(), 1); } - public void testBaseCase_FunctionReference() throws Exception - { + public void testBaseCase_FunctionReference() throws Exception { String code = "int x(){x( );}"; //$NON-NLS-1$ int offset1 = code.indexOf( "x( " ); //$NON-NLS-1$ int offset2 = code.indexOf( "( )"); //$NON-NLS-1$ @@ -87,17 +86,15 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { assertEquals( ((ASTNode)decls[0]).getOffset(), 4); assertEquals( ((ASTNode)decls[0]).getLength(), 1); } - - public void testBaseCase_Error() throws Exception - { + + public void testBaseCase_Error() throws Exception { String code = "int x() { y( ) }"; //$NON-NLS-1$ int offset1 = code.indexOf( "y( " ); //$NON-NLS-1$ int offset2 = code.indexOf( "( )"); //$NON-NLS-1$ assertNull( parse( code, offset1, offset2, false )); } - - public void testBaseCase_FunctionDeclaration() throws Exception - { + + public void testBaseCase_FunctionDeclaration() throws Exception { String code = "int x(); void test() {x( );}"; //$NON-NLS-1$ int offset1 = code.indexOf( "x( )" ); //$NON-NLS-1$ int offset2 = code.indexOf( "( )"); //$NON-NLS-1$ @@ -111,9 +108,8 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { assertEquals( ((ASTNode)decls[0]).getOffset(), 4); assertEquals( ((ASTNode)decls[0]).getLength(), 1); } - - public void testBaseCase_FunctionDeclaration2() throws Exception - { + + public void testBaseCase_FunctionDeclaration2() throws Exception { String code = "int printf( const char *, ... ); "; //$NON-NLS-1$ int offset1 = code.indexOf( "printf" ); //$NON-NLS-1$ int offset2 = code.indexOf( "( const"); //$NON-NLS-1$ @@ -123,8 +119,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { assertEquals( ((IASTName)node).toString(), "printf" ); //$NON-NLS-1$ } - public void testBaseCase_VariableDeclaration() throws Exception - { + public void testBaseCase_VariableDeclaration() throws Exception { String code = "int x = 3;"; //$NON-NLS-1$ int offset1 = code.indexOf( "x" ); //$NON-NLS-1$ int offset2 = code.indexOf( " ="); //$NON-NLS-1$ @@ -134,9 +129,8 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { assertTrue( ((IASTName)node).resolveBinding() instanceof IVariable ); assertEquals( ((IASTName)node).toString(), "x" ); //$NON-NLS-1$ } - - public void testBaseCase_Parameter() throws Exception - { + + public void testBaseCase_Parameter() throws Exception { String code = "int main( int argc ) { int x = argc; }"; //$NON-NLS-1$ int offset1 = code.indexOf( "argc;" ); //$NON-NLS-1$ int offset2 = code.indexOf( ";" ); //$NON-NLS-1$ @@ -151,9 +145,8 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { assertEquals( ((ASTNode)decls[0]).getOffset(), 14); assertEquals( ((ASTNode)decls[0]).getLength(), 4); } - - public void testBug57898() throws Exception - { + + public void testBug57898() throws Exception { Writer writer = new StringWriter(); writer.write( "class Gonzo { public: void playHorn(); };\n" ); //$NON-NLS-1$ writer.write( "void Gonzo::playHorn() { return; }\n" ); //$NON-NLS-1$ @@ -187,9 +180,8 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { assertEquals( ((ASTNode)decls[0]).getLength(), 8); } } - - public void testConstructorDestructorDeclaration() throws Exception - { + + public void testConstructorDestructorDeclaration() throws Exception { Writer writer = new StringWriter(); writer.write( "class Gonzo { Gonzo(); ~Gonzo(); };"); //$NON-NLS-1$ String code = writer.toString(); @@ -199,16 +191,15 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { assertTrue( node instanceof IASTName ); assertTrue( ((IASTName)node).resolveBinding() instanceof ICPPConstructor ); assertEquals( ((IASTName)node).toString(), "Gonzo" ); //$NON-NLS-1$ - + offset = code.indexOf( "~Gonzo"); //$NON-NLS-1$ node = parse( code, offset, offset + 6 ); assertTrue( node instanceof IASTName ); assertTrue( ((IASTName)node).resolveBinding() instanceof ICPPMethod ); assertEquals( ((IASTName)node).toString(), "~Gonzo" ); //$NON-NLS-1$ - } - - public void testBug60264() throws Exception - { + } + + public void testBug60264() throws Exception { Writer writer = new StringWriter(); writer.write( "namespace Muppets { int i; }\n" ); //$NON-NLS-1$ writer.write( "int main(int argc, char **argv) { Muppets::i = 1; }\n" ); //$NON-NLS-1$ @@ -236,9 +227,8 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { assertEquals( ((ASTNode)decls[0]).getOffset(), 10); assertEquals( ((ASTNode)decls[0]).getLength(), 7); } - - public void testBug61613() throws Exception - { + + public void testBug61613() throws Exception { Writer writer = new StringWriter(); writer.write( "class Foo { // ** (A) **\n" ); //$NON-NLS-1$ writer.write( " public:\n" ); //$NON-NLS-1$ @@ -260,9 +250,8 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { assertEquals( ((ASTNode)decls[0]).getOffset(), 6); assertEquals( ((ASTNode)decls[0]).getLength(), 3); } - - public void testBug60038() throws Exception - { + + public void testBug60038() throws Exception { Writer writer = new StringWriter(); writer.write( "class Gonzo {\n"); //$NON-NLS-1$ writer.write( "public:\n"); //$NON-NLS-1$ @@ -296,8 +285,12 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { } IASTNode node = parse( code, startOffset, endOffset ); assertTrue( node instanceof IASTName ); - assertTrue( ((IASTName)node).resolveBinding() instanceof ICPPMethod ); IBinding binding = ((IASTName)node).resolveBinding(); + if (binding instanceof ICPPClassType) { + node = TestUtil.findImplicitName(node); + binding = ((IASTName)node).resolveBinding(); + } + assertTrue( binding instanceof ICPPMethod ); IName[] decls = null; switch( i ) { @@ -309,7 +302,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { assertEquals( ((ASTNode)decls[0]).getOffset(), 53); assertEquals( ((ASTNode)decls[0]).getLength(), 5); break; - case 1: + case 1: assertTrue( binding instanceof ICPPConstructor ); decls = getDeclarationOffTU((IASTName)node); assertEquals(decls.length, 1); @@ -317,7 +310,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { assertEquals( ((ASTNode)decls[0]).getOffset(), 22); assertEquals( ((ASTNode)decls[0]).getLength(), 5); break; - default: + default: assertFalse( binding instanceof ICPPConstructor ); String name = ((IASTName)node).toString(); assertEquals( name.indexOf("~"), 0); //$NON-NLS-1$ @@ -328,13 +321,12 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { assertEquals( ((ASTNode)decls[0]).getOffset(), 64); assertEquals( ((ASTNode)decls[0]).getLength(), 6); break; - + } } } - - public void testMethodReference() throws Exception - { + + public void testMethodReference() throws Exception { Writer writer = new StringWriter(); writer.write( "class Sample { public:\n"); //$NON-NLS-1$ writer.write( " int getAnswer() const;\n"); //$NON-NLS-1$ @@ -355,9 +347,8 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { assertEquals( ((ASTNode)decls[0]).getOffset(), 29); assertEquals( ((ASTNode)decls[0]).getLength(), 9); } - - public void testConstructorDefinition() throws Exception - { + + public void testConstructorDefinition() throws Exception { String code = "class ABC { public: ABC(); }; ABC::ABC(){}"; //$NON-NLS-1$ int startIndex = code.indexOf( "::ABC") + 2; //$NON-NLS-1$ IASTNode node = parse( code, startIndex, startIndex + 3 ); @@ -370,9 +361,8 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { assertEquals( ((ASTNode)decls[0]).getOffset(), 20); assertEquals( ((ASTNode)decls[0]).getLength(), 3); } - - public void testBug63966() throws Exception - { + + public void testBug63966() throws Exception { Writer writer = new StringWriter(); writer.write( "void foo(int a) {}\n" ); //$NON-NLS-1$ writer.write( "void foo(long a) {}\n" ); //$NON-NLS-1$ @@ -382,22 +372,20 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { int startIndex = code.indexOf( "foo(1)"); //$NON-NLS-1$ parse( code, startIndex, startIndex + 3 ); } - - public void testBug66744() throws Exception - { + + public void testBug66744() throws Exception { Writer writer = new StringWriter(); writer.write( "enum EColours { RED, GREEN, BLUE }; \n" ); //$NON-NLS-1$ writer.write( "void foo() { EColours color = GREEN; } \n" ); //$NON-NLS-1$ - + String code = writer.toString(); int startIndex = code.indexOf( "EColours color"); //$NON-NLS-1$ parse( code, startIndex, startIndex + 8 ); } - - - public void testBug68527() throws Exception - { + + + public void testBug68527() throws Exception { Writer writer = new StringWriter(); writer.write("struct X;\n"); //$NON-NLS-1$ writer.write("struct X anA;"); //$NON-NLS-1$ @@ -406,8 +394,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { parse( code, startIndex, startIndex + 1 ); } - public void testBug60407() throws Exception - { + public void testBug60407() throws Exception { Writer writer = new StringWriter(); writer.write( "struct ZZZ { int x, y, z; };\n" ); //$NON-NLS-1$ writer.write( "typedef struct ZZZ _FILE;\n" ); //$NON-NLS-1$ @@ -422,9 +409,8 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { int startIndex = code.indexOf( "static_function( file )"); //$NON-NLS-1$ parse( code, startIndex, startIndex + "static_function".length() ); //$NON-NLS-1$ } - - public void testBug61800() throws Exception - { + + public void testBug61800() throws Exception { Writer writer = new StringWriter(); writer.write( "class B {};\n"); //$NON-NLS-1$ writer.write( "class ABCDEF {\n"); //$NON-NLS-1$ @@ -443,27 +429,25 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { assertEquals( ((ASTNode)decls[0]).getOffset(), 37); assertEquals( ((ASTNode)decls[0]).getLength(), 5); } - - public void testBug68739() throws Exception - { + + public void testBug68739() throws Exception { Writer writer = new StringWriter(); writer.write( "int fprintf( int *, const char *, ... ); \n" ); //$NON-NLS-1$ writer.write( "void boo( int * lcd ) { \n" ); //$NON-NLS-1$ writer.write( " /**/fprintf( lcd, \"%c%s 0x%x\", ' ', \"bbb\", 2 ); \n" ); //$NON-NLS-1$ writer.write( "} \n" ); //$NON-NLS-1$ - + String code = writer.toString(); int startIndex = code.indexOf( "/**/fprintf") + 4; //$NON-NLS-1$ IASTNode node = parse( code, startIndex, startIndex+ 7 ); - + assertTrue( node instanceof IASTName ); assertTrue( ((IASTName)node).resolveBinding() instanceof IFunction ); assertEquals( ((IASTName)node).toString(), "fprintf" ); //$NON-NLS-1$ } - - public void testBug72818() throws Exception - { + + public void testBug72818() throws Exception { Writer writer = new StringWriter(); writer.write( "union Squaw { int x; double u; };\n" ); //$NON-NLS-1$ writer.write( "int main(int argc, char **argv) {\n" ); //$NON-NLS-1$ @@ -482,9 +466,8 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { assertEquals( ((ASTNode)decls[0]).getOffset(), 6); assertEquals( ((ASTNode)decls[0]).getLength(), 5); } - - public void test72220() throws Exception - { + + public void test72220() throws Exception { Writer writer = new StringWriter(); writer.write( "const int FOUND_ME = 1;\n" ); //$NON-NLS-1$ writer.write( "class Test{\n" ); //$NON-NLS-1$ @@ -506,7 +489,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { assertEquals( ((ASTNode)decls[0]).getOffset(), 10); assertEquals( ((ASTNode)decls[0]).getLength(), 8); } - + public void testBug72721() throws Exception{ Writer writer = new StringWriter(); writer.write(" class ABC { public: ABC(int); }; \n"); //$NON-NLS-1$ @@ -514,7 +497,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { writer.write(" int j = 1; \n"); //$NON-NLS-1$ writer.write(" new ABC( j + 1 ); \n"); //$NON-NLS-1$ writer.write("} \n"); //$NON-NLS-1$ - + String code = writer.toString(); int startIndex = code.indexOf( "ABC(" ); //$NON-NLS-1$ IASTNode node = parse( code, startIndex, startIndex + 3 ); @@ -527,7 +510,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { assertEquals( ((ASTNode)decls[0]).getOffset(), 21); assertEquals( ((ASTNode)decls[0]).getLength(), 3); } - + public void testBug72372() throws Exception{ Writer writer = new StringWriter(); writer.write("namespace B { \n"); //$NON-NLS-1$ @@ -535,7 +518,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { writer.write("} \n"); //$NON-NLS-1$ writer.write("using namespace B; \n"); //$NON-NLS-1$ writer.write("void SD_02::f_SD(){} \n"); //$NON-NLS-1$ - + String code = writer.toString(); int startIndex = code.indexOf( ":f_SD" ); //$NON-NLS-1$ IASTNode node = parse( code, startIndex + 1, startIndex + 5 ); @@ -559,7 +542,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { writer.write(" using namespace A; \n"); //$NON-NLS-1$ writer.write("} \n"); //$NON-NLS-1$ writer.write("void C::B::f_SD(){} \n"); //$NON-NLS-1$ - + String code = writer.toString(); int startIndex = code.indexOf( ":f_SD" ); //$NON-NLS-1$ IASTNode node = parse( code, startIndex + 1, startIndex + 5 ); @@ -572,12 +555,12 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { assertEquals( ((ASTNode)decls[0]).getOffset(), 109); assertEquals( ((ASTNode)decls[0]).getLength(), 4); } - + public void testBug72713() throws Exception{ Writer writer = new StringWriter(); writer.write( "class Deck{ void initialize(); }; \n"); //$NON-NLS-1$ writer.write( "void Deck::initialize(){} \n"); //$NON-NLS-1$ - + String code = writer.toString(); int startIndex = code.indexOf( ":initialize" ); //$NON-NLS-1$ IASTNode node = parse( code, startIndex + 1, startIndex + 11 ); @@ -590,34 +573,35 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { assertEquals( ((ASTNode)decls[0]).getOffset(), 17); assertEquals( ((ASTNode)decls[0]).getLength(), 10); } - + public void testBug72712() throws Exception{ Writer writer = new StringWriter(); writer.write( "class B{ public: B(); }; void f(){ B* b; b = new B(); }" ); //$NON-NLS-1$ - + String code = writer.toString(); int startIndex = code.indexOf( "new B" ) + 4; //$NON-NLS-1$ - + IASTNode node = parse( code, startIndex, startIndex + 1 ); + node = TestUtil.findImplicitName(node); assertTrue( node instanceof IASTName ); - assertTrue( ((IASTName)node).resolveBinding() instanceof ICPPConstructor ); + assertTrue( ((IASTName) node).resolveBinding() instanceof ICPPConstructor ); assertEquals( ((IASTName)node).toString(), "B" ); //$NON-NLS-1$ IName[] decls = getDeclarationOffTU((IASTName)node); assertEquals(decls.length, 1); assertEquals( decls[0].toString(), "B" ); //$NON-NLS-1$ - assertEquals( ((ASTNode)decls[0]).getOffset(), 17); - assertEquals( ((ASTNode)decls[0]).getLength(), 1); + assertEquals( 17, ((ASTNode)decls[0]).getOffset() ); + assertEquals( 1, ((ASTNode)decls[0]).getLength() ); } - + public void testBug72712_2() throws Exception{ Writer writer = new StringWriter(); writer.write( "class A {}; \n"); //$NON-NLS-1$ writer.write( "class B{ public: B( A* ); }; \n"); //$NON-NLS-1$ writer.write( "void f(){ B* b; b = new B( (A*)0 ); } \n"); //$NON-NLS-1$ - + String code = writer.toString(); int startIndex = code.indexOf( "(A*)" ) + 1; //$NON-NLS-1$ - + IASTNode node = parse( code, startIndex, startIndex + 1 ); assertTrue( node instanceof IASTName ); assertTrue( ((IASTName)node).resolveBinding() instanceof ICPPClassType ); @@ -628,7 +612,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { assertEquals( ((ASTNode)decls[0]).getOffset(), 6); assertEquals( ((ASTNode)decls[0]).getLength(), 1); } - + public void testBug72814() throws Exception{ CPPASTNameBase.sAllowNameComputation= true; @@ -637,11 +621,11 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { writer.write( " template < class T > class AAA { T _t; };\n"); //$NON-NLS-1$ writer.write( "} \n"); //$NON-NLS-1$ writer.write( "N::AAA a; \n"); //$NON-NLS-1$ - + String code = writer.toString(); int startIndex = code.indexOf( "AAA" ); //$NON-NLS-1$ IASTNode node = parse( code, startIndex, startIndex + 3 ); - + assertTrue( node instanceof IASTName ); assertTrue( ((IASTName)node).resolveBinding() instanceof ICPPClassType ); assertEquals( ((IASTName)node).toString(), "AAA" ); //$NON-NLS-1$ @@ -650,9 +634,9 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { assertEquals( decls[0].toString(), "AAA" ); //$NON-NLS-1$ assertEquals( ((ASTNode)decls[0]).getOffset(), 75); assertEquals( ((ASTNode)decls[0]).getLength(), 3); - + node = parse( code, startIndex, startIndex + 8 ); - + assertTrue( node instanceof IASTName ); assertTrue( ((IASTName)node).resolveBinding() instanceof ICPPClassType ); assertEquals( ((IASTName)node).toString(), "AAA" ); //$NON-NLS-1$ @@ -663,9 +647,8 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { // assertEquals( ((ASTNode)decls[0]).getOffset(), 15); // assertEquals( ((ASTNode)decls[0]).getLength(), 3); } - - public void testBug72710() throws Exception - { + + public void testBug72710() throws Exception { Writer writer = new StringWriter(); writer.write( "class Card{\n" ); //$NON-NLS-1$ writer.write( " Card( int rank );\n" ); //$NON-NLS-1$ @@ -686,9 +669,9 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { assertEquals( ((ASTNode)decls[0]).getOffset(), 36); assertEquals( ((ASTNode)decls[0]).getLength(), 4); } - - - public void testBug75731() throws Exception + + + public void testBug75731() throws Exception { Writer writer = new StringWriter(); writer.write("int rank() {\n"); //$NON-NLS-1$ @@ -705,7 +688,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { writer.write("this->rank = rank;\n"); //$NON-NLS-1$ writer.write("this->rank = Card::rank;\n"); //$NON-NLS-1$ writer.write("this->rank = getRank();\n}\n"); //$NON-NLS-1$ - + String code = writer.toString(); int index = code.indexOf( "int rank() {") + 4; //$NON-NLS-1$ IASTNode node = parse( code, index, index + 4 ); @@ -718,7 +701,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { assertEquals( decls[0].toString(), "rank" ); //$NON-NLS-1$ assertEquals( ((ASTNode)decls[0]).getOffset(), 4); assertEquals( ((ASTNode)decls[0]).getLength(), 4); - + index = code.indexOf( "class Card{") + 6; //$NON-NLS-1$ node = parse( code, index, index + 4 ); assertTrue( node instanceof IASTName ); @@ -730,7 +713,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { assertEquals( decls[0].toString(), "Card" ); //$NON-NLS-1$ assertEquals( ((ASTNode)decls[0]).getOffset(), 31); assertEquals( ((ASTNode)decls[0]).getLength(), 4); - + index = code.indexOf( "Card( int rank );"); //$NON-NLS-1$ node = parse( code, index, index + 4 ); assertTrue( node instanceof IASTName ); @@ -742,7 +725,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { assertEquals( decls[0].toString(), "Card" ); //$NON-NLS-1$ assertEquals( ((ASTNode)decls[0]).getOffset(), 46); assertEquals( ((ASTNode)decls[0]).getLength(), 4); - + index = code.indexOf( "Card( int rank );") + 10; //$NON-NLS-1$ node = parse( code, index, index + 4 ); assertTrue( node instanceof IASTName ); @@ -766,7 +749,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { assertEquals( decls[0].toString(), "rank" ); //$NON-NLS-1$ assertEquals( ((ASTNode)decls[0]).getOffset(), 68); assertEquals( ((ASTNode)decls[0]).getLength(), 4); - + index = code.indexOf( "int getRank();") + 4; //$NON-NLS-1$ node = parse( code, index, index + 7 ); assertTrue( node instanceof IASTName ); @@ -778,7 +761,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { assertEquals( decls[0].toString(), "getRank" ); //$NON-NLS-1$ assertEquals( ((ASTNode)decls[0]).getOffset(), 86); assertEquals( ((ASTNode)decls[0]).getLength(), 7); - + index = code.indexOf( "Card::Card( int rank )"); //$NON-NLS-1$ node = parse( code, index, index + 4 ); assertTrue( node instanceof IASTName ); @@ -790,7 +773,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { assertEquals( decls[0].toString(), "Card" ); //$NON-NLS-1$ assertEquals( ((ASTNode)decls[0]).getOffset(), 31); assertEquals( ((ASTNode)decls[0]).getLength(), 4); - + index = code.indexOf( "Card::Card( int rank )") + 6; //$NON-NLS-1$ node = parse( code, index, index + 4 ); assertTrue( node instanceof IASTName ); @@ -802,7 +785,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { assertEquals( decls[0].toString(), "Card" ); //$NON-NLS-1$ assertEquals( ((ASTNode)decls[0]).getOffset(), 46); assertEquals( ((ASTNode)decls[0]).getLength(), 4); - + index = code.indexOf( "Card::Card( int rank )") + 16; //$NON-NLS-1$ node = parse( code, index, index + 4 ); assertTrue( node instanceof IASTName ); @@ -814,7 +797,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { assertEquals( decls[0].toString(), "rank" ); //$NON-NLS-1$ assertEquals( ((ASTNode)decls[0]).getOffset(), 56); assertEquals( ((ASTNode)decls[0]).getLength(), 4); - + index = code.indexOf( "this->rank = ::rank();") + 6; //$NON-NLS-1$ node = parse( code, index, index + 4 ); assertTrue( node instanceof IASTName ); @@ -826,7 +809,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { assertEquals( decls[0].toString(), "rank" ); //$NON-NLS-1$ assertEquals( ((ASTNode)decls[0]).getOffset(), 68); assertEquals( ((ASTNode)decls[0]).getLength(), 4); - + index = code.indexOf( "this->rank = ::rank();") + 15; //$NON-NLS-1$ node = parse( code, index, index + 4 ); assertTrue( node instanceof IASTName ); @@ -838,7 +821,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { assertEquals( decls[0].toString(), "rank" ); //$NON-NLS-1$ assertEquals( ((ASTNode)decls[0]).getOffset(), 4); assertEquals( ((ASTNode)decls[0]).getLength(), 4); - + index = code.indexOf( "this->rank = this->rank;") + 6; //$NON-NLS-1$ node = parse( code, index, index + 4 ); assertTrue( node instanceof IASTName ); @@ -850,7 +833,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { assertEquals( decls[0].toString(), "rank" ); //$NON-NLS-1$ assertEquals( ((ASTNode)decls[0]).getOffset(), 68); assertEquals( ((ASTNode)decls[0]).getLength(), 4); - + index = code.indexOf( "this->rank = this->rank;") + 19; //$NON-NLS-1$ node = parse( code, index, index + 4 ); assertTrue( node instanceof IASTName ); @@ -862,7 +845,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { assertEquals( decls[0].toString(), "rank" ); //$NON-NLS-1$ assertEquals( ((ASTNode)decls[0]).getOffset(), 68); assertEquals( ((ASTNode)decls[0]).getLength(), 4); - + index = code.indexOf( "this->rank = rank;") + 6; //$NON-NLS-1$ node = parse( code, index, index + 4 ); assertTrue( node instanceof IASTName ); @@ -874,7 +857,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { assertEquals( decls[0].toString(), "rank" ); //$NON-NLS-1$ assertEquals( ((ASTNode)decls[0]).getOffset(), 68); assertEquals( ((ASTNode)decls[0]).getLength(), 4); - + index = code.indexOf( "this->rank = rank;") + 13; //$NON-NLS-1$ node = parse( code, index, index + 4 ); assertTrue( node instanceof IASTName ); @@ -886,7 +869,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { assertEquals( decls[0].toString(), "rank" ); //$NON-NLS-1$ assertEquals( ((ASTNode)decls[0]).getOffset(), 56); assertEquals( ((ASTNode)decls[0]).getLength(), 4); - + index = code.indexOf( "this->rank = Card::rank;") + 6; //$NON-NLS-1$ node = parse( code, index, index + 4 ); assertTrue( node instanceof IASTName ); @@ -898,7 +881,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { assertEquals( decls[0].toString(), "rank" ); //$NON-NLS-1$ assertEquals( ((ASTNode)decls[0]).getOffset(), 68); assertEquals( ((ASTNode)decls[0]).getLength(), 4); - + index = code.indexOf( "this->rank = Card::rank;") + 19; //$NON-NLS-1$ node = parse( code, index, index + 4 ); assertTrue( node instanceof IASTName ); @@ -910,7 +893,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { assertEquals( decls[0].toString(), "rank" ); //$NON-NLS-1$ assertEquals( ((ASTNode)decls[0]).getOffset(), 68); assertEquals( ((ASTNode)decls[0]).getLength(), 4); - + index = code.indexOf( "this->rank = getRank();") + 6; //$NON-NLS-1$ node = parse( code, index, index + 4 ); assertTrue( node instanceof IASTName ); @@ -922,7 +905,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { assertEquals( decls[0].toString(), "rank" ); //$NON-NLS-1$ assertEquals( ((ASTNode)decls[0]).getOffset(), 68); assertEquals( ((ASTNode)decls[0]).getLength(), 4); - + index = code.indexOf( "this->rank = getRank();") + 13; //$NON-NLS-1$ node = parse( code, index, index + 7 ); assertTrue( node instanceof IASTName ); @@ -942,7 +925,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { writer.write("class C{};\n}\n"); //$NON-NLS-1$ writer.write("using namespace N; /* B */\n"); //$NON-NLS-1$ writer.write("N::C c; /* C */\n"); //$NON-NLS-1$ - + String code = writer.toString(); int index = code.indexOf( "using namespace N;") + 16; //$NON-NLS-1$ IASTNode node = parse( code, index, index + 1 ); @@ -959,9 +942,9 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { public void testBug78435() throws Exception { Writer writer = new StringWriter(); - writer.write("int itself; //A\n"); //$NON-NLS-1$ + writer.write("int itself; //A\n"); //$NON-NLS-1$ writer.write("void f(int itself){} //B\n"); //$NON-NLS-1$ - + String code = writer.toString(); int index = code.indexOf( "void f(int itself){}") + 11; //$NON-NLS-1$ IASTNode node = parse( code, index, index + 6 ); @@ -981,7 +964,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { writer.write("struct Base {\n"); //$NON-NLS-1$ writer.write("int Data; // 1\n"); //$NON-NLS-1$ writer.write("struct Data; // 2\n};\n"); //$NON-NLS-1$ - + String code = writer.toString(); int index = code.indexOf("struct Data;") + 7; //$NON-NLS-1$ IASTNode node = parse( code, index, index + 4 ); @@ -995,14 +978,14 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { assertEquals( ((ASTNode)decls[0]).getOffset(), 36); assertEquals( ((ASTNode)decls[0]).getLength(), 4); } - + public void testBug78231B() throws Exception { Writer writer = new StringWriter(); writer.write("int Data;\n"); //$NON-NLS-1$ writer.write("struct Base {\n"); //$NON-NLS-1$ writer.write("int Data; // 1\n"); //$NON-NLS-1$ writer.write("struct Data; // 2\n};\n"); //$NON-NLS-1$ - + String code = writer.toString(); int index = code.indexOf("struct Data;") + 7; //$NON-NLS-1$ IASTNode node = parse( code, index, index + 4 ); @@ -1011,7 +994,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { assertEquals( ((IASTName)node).toString(), "Data" ); //$NON-NLS-1$ assertEquals( ((ASTNode)node).getOffset(), index); } - + public void testBug64326() throws Exception { Writer writer = new StringWriter(); writer.write("class foo {\n"); //$NON-NLS-1$ @@ -1024,7 +1007,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { writer.write("foo* f;\n"); //$NON-NLS-1$ writer.write("f->bar = 1; // ** (A) **\n"); //$NON-NLS-1$ writer.write("}\n"); //$NON-NLS-1$ - + String code = writer.toString(); int index = code.indexOf("f->bar") + 3; //$NON-NLS-1$ IASTNode node = parse( code, index, index + 3 ); @@ -1037,7 +1020,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { assertEquals( ((ASTNode)decls[0]).getOffset(), 33); assertEquals( ((ASTNode)decls[0]).getLength(), 3); } - + public void testBug92605() throws Exception { Writer writer = new StringWriter(); writer.write("#define UINT32 unsigned int\n"); //$NON-NLS-1$ @@ -1055,14 +1038,14 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { assertTrue( node instanceof IASTName ); assertTrue( ((IASTName)node).resolveBinding() instanceof IMacroBinding ); assertEquals( ((IASTName)node).toString(), "UINT32" ); //$NON-NLS-1$ - + IName[] decls = getDeclarationOffTU((IASTName)node); assertEquals(decls.length, 1); assertEquals( decls[0].toString(), "UINT32" ); //$NON-NLS-1$ assertEquals( ((ASTNode)decls[0]).getOffset(), 8); assertEquals( ((ASTNode)decls[0]).getLength(), 6); } - + public void testBug79877() throws Exception { Writer writer = new StringWriter(); writer.write("int Func2() {\n"); //$NON-NLS-1$ @@ -1072,27 +1055,27 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { writer.write("}\n"); //$NON-NLS-1$ String code = writer.toString(); IFile test1 = importFile("test1.c", code); //$NON-NLS-1$ - + writer.write("int Func1(void) {\n"); //$NON-NLS-1$ writer.write("return(10);\n"); //$NON-NLS-1$ writer.write("}\n"); //$NON-NLS-1$ importFile("test2.c", writer.toString()); //$NON-NLS-1$ - + int index = code.indexOf("Func1"); //$NON-NLS-1$ IASTNode node = parse( test1, index, index + 5, true ); assertTrue( node instanceof IASTName ); assertTrue( ((IASTName)node).resolveBinding() instanceof ICExternalBinding ); assertEquals( ((IASTName)node).toString(), "Func1" ); //$NON-NLS-1$ - + ICElement[] scope = new ICElement[1]; scope[0] = new CProject(null, project); // // TODO need to register to an index and wait for it to finish before this test will work -// +// // Set matches = SearchEngine.getMatchesFromSearchEngine(SearchEngine.createCSearchScope(scope), (IASTName)node, CSearchPattern.DECLARATIONS); // assertEquals(matches.size(), 1); } - + public void testBug78114() throws Exception { Writer writer = new StringWriter(); writer.write("class Point{ //line C\n"); //$NON-NLS-1$ @@ -1106,22 +1089,23 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { writer.write("Point &p2 = *(new Point(10)); // line A\n"); //$NON-NLS-1$ writer.write("return (0);\n"); //$NON-NLS-1$ writer.write("}\n"); //$NON-NLS-1$ - + String code = writer.toString(); - + int index = code.indexOf("Point(10)"); //$NON-NLS-1$ IASTNode node = parse( code, index, index + 5, true ); + node = TestUtil.findImplicitName(node); assertTrue( node instanceof IASTName ); - assertTrue( ((IASTName)node).resolveBinding() instanceof ICPPConstructor ); + assertTrue( ((IASTName) node).resolveBinding() instanceof ICPPConstructor ); assertEquals( ((IASTName)node).toString(), "Point" ); //$NON-NLS-1$ - + IName[] decls = getDeclarationOffTU((IASTName)node); assertEquals(decls.length, 1); assertEquals( decls[0].toString(), "Point" ); //$NON-NLS-1$ assertEquals( ((ASTNode)decls[0]).getOffset(), 53); assertEquals( ((ASTNode)decls[0]).getLength(), 5); } - + public void testBug73398() throws Exception { Writer writer = new StringWriter(); writer.write("int joo=4;\n"); //$NON-NLS-1$ @@ -1129,22 +1113,22 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { writer.write("int main(int argc, char **argv) {\n"); //$NON-NLS-1$ writer.write("return (koo);\n"); //$NON-NLS-1$ writer.write("}\n"); //$NON-NLS-1$ - + String code = writer.toString(); - + int index = code.indexOf("koo);"); //$NON-NLS-1$ IASTNode node = parse( code, index, index + 3, true ); assertTrue( node instanceof IASTName ); assertTrue( ((IASTName)node).resolveBinding() instanceof IMacroBinding ); assertEquals( ((IASTName)node).toString(), "koo" ); //$NON-NLS-1$ - + IName[] decls = getDeclarationOffTU((IASTName)node); assertEquals(decls.length, 1); assertEquals( decls[0].toString(), "koo" ); //$NON-NLS-1$ assertEquals( ((ASTNode)decls[0]).getOffset(), 19); assertEquals( ((ASTNode)decls[0]).getLength(), 3); } - + public void testBug() throws Exception { Writer writer = new StringWriter(); writer.write("class Point{ \n"); //$NON-NLS-1$ @@ -1160,22 +1144,22 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { writer.write("p2->operator=(zero); // line B\n"); //$NON-NLS-1$ writer.write("return (0); \n"); //$NON-NLS-1$ writer.write(" }\n"); //$NON-NLS-1$ - + String code = writer.toString(); - + int index = code.indexOf("operator=(zero)"); //$NON-NLS-1$ IASTNode node = parse( code, index, index + 9, true ); assertTrue( node instanceof IASTName ); assertTrue( ((IASTName)node).resolveBinding() instanceof ICPPMethod ); assertEquals( ((IASTName)node).toString(), "operator =" ); //$NON-NLS-1$ - + IName[] decls = getDeclarationOffTU((IASTName)node); assertEquals(decls.length, 1); assertEquals( decls[0].toString(), "operator =" ); //$NON-NLS-1$ assertEquals( ((ASTNode)decls[0]).getOffset(), 51); assertEquals( ((ASTNode)decls[0]).getLength(), 9); } - + public void testBug80826() throws Exception { Writer writer = new StringWriter(); writer.write("void swapImpl(int& a, int& b) {/*...*/} // line C\n"); //$NON-NLS-1$ @@ -1186,22 +1170,22 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { writer.write("swap(x,y); // line A\n"); //$NON-NLS-1$ writer.write(" //...\n"); //$NON-NLS-1$ writer.write("}\n"); //$NON-NLS-1$ - + String code = writer.toString(); - + int index = code.indexOf("swap(x,y);"); //$NON-NLS-1$ IASTNode node = parse( code, index, index + 4, true ); assertTrue( node instanceof IASTName ); assertTrue( ((IASTName)node).resolveBinding() instanceof IMacroBinding ); assertEquals( ((IASTName)node).toString(), "swap" ); //$NON-NLS-1$ - + IName[] decls = getDeclarationOffTU((IASTName)node); assertEquals(decls.length, 1); assertEquals( decls[0].toString(), "swap" ); //$NON-NLS-1$ assertEquals( ((ASTNode)decls[0]).getOffset(), 58); assertEquals( ((ASTNode)decls[0]).getLength(), 4); } - + public void testBug78389() throws Exception { Writer writer = new StringWriter(); writer.write("class A{\n"); //$NON-NLS-1$ @@ -1212,22 +1196,22 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { writer.write("A a; \n"); //$NON-NLS-1$ writer.write("a.method1(3); // F3 on method1 in this line should highlight method1 on line B\n"); //$NON-NLS-1$ writer.write("}\n"); //$NON-NLS-1$ - + String code = writer.toString(); - + int index = code.indexOf("method1(3)"); //$NON-NLS-1$ IASTNode node = parse( code, index, index + 7, true ); assertTrue( node instanceof IASTName ); assertTrue( ((IASTName)node).resolveBinding() instanceof ICPPMethod ); assertEquals( ((IASTName)node).toString(), "method1" ); //$NON-NLS-1$ - + IName[] decls = getDeclarationOffTU((IASTName)node); assertEquals(decls.length, 1); assertEquals( decls[0].toString(), "method1" ); //$NON-NLS-1$ assertEquals( ((ASTNode)decls[0]).getOffset(), 41); assertEquals( ((ASTNode)decls[0]).getLength(), 7); } - + public void testBug78625() throws Exception { Writer writer = new StringWriter(); writer.write("class A{ \n"); //$NON-NLS-1$ @@ -1236,22 +1220,22 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { writer.write("class B: A{\n"); //$NON-NLS-1$ writer.write("B():A(2) {} //line 5\n"); //$NON-NLS-1$ writer.write("};\n"); //$NON-NLS-1$ - + String code = writer.toString(); - + int index = code.indexOf("A(2)"); //$NON-NLS-1$ IASTNode node = parse( code, index, index + 1, true ); assertTrue( node instanceof IASTName ); assertTrue( ((IASTName)node).resolveBinding() instanceof ICPPConstructor ); assertEquals( ((IASTName)node).toString(), "A" ); //$NON-NLS-1$ - + IName[] decls = getDeclarationOffTU((IASTName)node); assertEquals(decls.length, 1); assertEquals( decls[0].toString(), "A" ); //$NON-NLS-1$ assertEquals( ((ASTNode)decls[0]).getOffset(), 29); assertEquals( ((ASTNode)decls[0]).getLength(), 1); } - + public void testBug78656() throws Exception { Writer writer = new StringWriter(); writer.write("class A{\n"); //$NON-NLS-1$ @@ -1261,41 +1245,41 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { writer.write("A a;\n"); //$NON-NLS-1$ writer.write("int i=a.method1(); //line 6\n"); //$NON-NLS-1$ writer.write("}\n"); //$NON-NLS-1$ - + String code = writer.toString(); - + int index = code.indexOf("method1();"); //$NON-NLS-1$ IASTNode node = parse( code, index, index + 7, true ); assertTrue( node instanceof IASTName ); assertTrue( ((IASTName)node).resolveBinding() instanceof ICPPMethod ); assertEquals( ((IASTName)node).toString(), "method1" ); //$NON-NLS-1$ - + IName[] decls = getDeclarationOffTU((IASTName)node); assertEquals(decls.length, 1); assertEquals( decls[0].toString(), "method1" ); //$NON-NLS-1$ assertEquals( ((ASTNode)decls[0]).getOffset(), 21); assertEquals( ((ASTNode)decls[0]).getLength(), 7); } - + public void testBug79965() throws Exception { Writer writer = new StringWriter(); writer.write("int i = 2, half_i = i / 2;\n"); //$NON-NLS-1$ - + String code = writer.toString(); - + int index = code.indexOf("i / 2"); //$NON-NLS-1$ IASTNode node = parse( code, index, index + 1, true ); assertTrue( node instanceof IASTName ); assertTrue( ((IASTName)node).resolveBinding() instanceof IVariable ); assertEquals( ((IASTName)node).toString(), "i" ); //$NON-NLS-1$ - + IName[] decls = getDeclarationOffTU((IASTName)node); assertEquals(decls.length, 1); assertEquals( decls[0].toString(), "i" ); //$NON-NLS-1$ assertEquals( ((ASTNode)decls[0]).getOffset(), 4); assertEquals( ((ASTNode)decls[0]).getLength(), 1); } - + public void testBug64326A() throws Exception { Writer writer = new StringWriter(); writer.write("class foo {\n"); //$NON-NLS-1$ @@ -1308,22 +1292,22 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { writer.write("foo* f;\n"); //$NON-NLS-1$ writer.write("f->bar(); // ** (A) **\n"); //$NON-NLS-1$ writer.write("}\n"); //$NON-NLS-1$ - + String code = writer.toString(); - + int index = code.indexOf("bar();"); //$NON-NLS-1$ IASTNode node = parse( code, index, index + 3, true ); assertTrue( node instanceof IASTName ); assertTrue( ((IASTName)node).resolveBinding() instanceof ICPPMethod ); assertEquals( ((IASTName)node).toString(), "bar" ); //$NON-NLS-1$ - + IName[] decls = getDeclarationOffTU((IASTName)node); assertEquals(decls.length, 1); assertEquals( decls[0].toString(), "bar" ); //$NON-NLS-1$ assertEquals( ((ASTNode)decls[0]).getOffset(), 34); assertEquals( ((ASTNode)decls[0]).getLength(), 3); } - + public void testBug64326B() throws Exception { Writer writer = new StringWriter(); writer.write("class foo {\n"); //$NON-NLS-1$ @@ -1336,22 +1320,22 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { writer.write("foo* f;\n"); //$NON-NLS-1$ writer.write("f->bar = 1; // ** (A) **\n"); //$NON-NLS-1$ writer.write("}\n"); //$NON-NLS-1$ - + String code = writer.toString(); - + int index = code.indexOf("bar = "); //$NON-NLS-1$ IASTNode node = parse( code, index, index + 3, true ); assertTrue( node instanceof IASTName ); assertTrue( ((IASTName)node).resolveBinding() instanceof ICPPField ); assertEquals( ((IASTName)node).toString(), "bar" ); //$NON-NLS-1$ - + IName[] decls = getDeclarationOffTU((IASTName)node); assertEquals(decls.length, 1); assertEquals( decls[0].toString(), "bar" ); //$NON-NLS-1$ assertEquals( ((ASTNode)decls[0]).getOffset(), 33); assertEquals( ((ASTNode)decls[0]).getLength(), 3); } - + public void testBug43128A() throws Exception { Writer writer = new StringWriter(); writer.write("void foo()\n"); //$NON-NLS-1$ @@ -1360,44 +1344,44 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { writer.write(" // ...\n"); //$NON-NLS-1$ writer.write("x++;\n"); //$NON-NLS-1$ writer.write("}\n"); //$NON-NLS-1$ - + String code = writer.toString(); - + int index = code.indexOf("x++"); //$NON-NLS-1$ IASTNode node = parse( code, index, index + 1, true ); assertTrue( node instanceof IASTName ); assertTrue( ((IASTName)node).resolveBinding() instanceof IVariable ); assertEquals( ((IASTName)node).toString(), "x" ); //$NON-NLS-1$ - + IName[] decls = getDeclarationOffTU((IASTName)node); assertEquals(decls.length, 1); assertEquals( decls[0].toString(), "x" ); //$NON-NLS-1$ assertEquals( ((ASTNode)decls[0]).getOffset(), 17); assertEquals( ((ASTNode)decls[0]).getLength(), 1); } - + public void testBug43128B() throws Exception { Writer writer = new StringWriter(); writer.write("int\n"); //$NON-NLS-1$ writer.write("main(int argc, char **argv) {\n"); //$NON-NLS-1$ writer.write("int x = argc;\n"); //$NON-NLS-1$ writer.write("}\n"); //$NON-NLS-1$ - + String code = writer.toString(); - + int index = code.indexOf("argc;"); //$NON-NLS-1$ IASTNode node = parse( code, index, index + 4, true ); assertTrue( node instanceof IASTName ); assertTrue( ((IASTName)node).resolveBinding() instanceof IParameter ); assertEquals( ((IASTName)node).toString(), "argc" ); //$NON-NLS-1$ - + IName[] decls = getDeclarationOffTU((IASTName)node); assertEquals(decls.length, 1); assertEquals( decls[0].toString(), "argc" ); //$NON-NLS-1$ assertEquals( ((ASTNode)decls[0]).getOffset(), 13); assertEquals( ((ASTNode)decls[0]).getLength(), 4); } - + public void testBug43128C() throws Exception { Writer writer = new StringWriter(); writer.write("int j;\n"); //$NON-NLS-1$ @@ -1410,44 +1394,44 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { writer.write("}\n"); //$NON-NLS-1$ String code = writer.toString(); - + int index = code.indexOf("x ="); //$NON-NLS-1$ IASTNode node = parse( code, index, index + 1, true ); assertTrue( node instanceof IASTName ); assertTrue( ((IASTName)node).resolveBinding() instanceof IVariable ); assertEquals( ((IASTName)node).toString(), "x" ); //$NON-NLS-1$ - + IName[] decls = getDeclarationOffTU((IASTName)node); assertEquals(decls.length, 1); assertEquals( decls[0].toString(), "x" ); //$NON-NLS-1$ assertEquals( ((ASTNode)decls[0]).getOffset(), 19); assertEquals( ((ASTNode)decls[0]).getLength(), 1); - + index = code.indexOf("j ="); //$NON-NLS-1$ node = parse( code, index, index + 1, true ); assertTrue( node instanceof IASTName ); assertTrue( ((IASTName)node).resolveBinding() instanceof IVariable ); assertEquals( ((IASTName)node).toString(), "j" ); //$NON-NLS-1$ - + decls = getDeclarationOffTU((IASTName)node); assertEquals(decls.length, 1); assertEquals( decls[0].toString(), "j" ); //$NON-NLS-1$ assertEquals( ((ASTNode)decls[0]).getOffset(), 4); assertEquals( ((ASTNode)decls[0]).getLength(), 1); - + index = code.indexOf("y ="); //$NON-NLS-1$ node = parse( code, index, index + 1, true ); assertTrue( node instanceof IASTName ); assertTrue( ((IASTName)node).resolveBinding() instanceof IVariable ); assertEquals( ((IASTName)node).toString(), "y" ); //$NON-NLS-1$ - + decls = getDeclarationOffTU((IASTName)node); assertEquals(decls.length, 1); assertEquals( decls[0].toString(), "y" ); //$NON-NLS-1$ assertEquals( ((ASTNode)decls[0]).getOffset(), 30); assertEquals( ((ASTNode)decls[0]).getLength(), 1); - } - + } + public void testBug86504() throws Exception { Writer writer = new StringWriter(); writer.write("class C { };\n"); //$NON-NLS-1$ @@ -1457,21 +1441,21 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { writer.write("void foo() {\n"); //$NON-NLS-1$ writer.write("f(g); // openDeclarations on g causes StackOverflowError\n"); //$NON-NLS-1$ writer.write("}\n"); //$NON-NLS-1$ - + String code = writer.toString(); - + int index = code.indexOf("g); "); //$NON-NLS-1$ IASTNode node = parse( code, index, index + 1, true ); assertTrue( node instanceof IASTName ); assertTrue( ((IASTName)node).resolveBinding() instanceof ICPPFunction ); assertEquals( ((IASTName)node).toString(), "g" ); //$NON-NLS-1$ - + IName[] decls = getDeclarationOffTU((IASTName)node); assertEquals(decls.length, 1); assertEquals( decls[0].toString(), "g" ); //$NON-NLS-1$ assertEquals( ((ASTNode)decls[0]).getOffset(), 89); assertEquals( ((ASTNode)decls[0]).getLength(), 1); - } + } public void testBug79811() throws Exception { Writer writer = new StringWriter(); @@ -1481,21 +1465,21 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { writer.write("E e; //this one is incorrectly found\n"); //$NON-NLS-1$ writer.write("}\n"); //$NON-NLS-1$ writer.write("E f; //ok\n"); //$NON-NLS-1$ - + String code = writer.toString(); - + int index = code.indexOf("E{E0}"); //$NON-NLS-1$ IASTNode node = parse( code, index, index + 1, true ); assertTrue( node instanceof IASTName ); assertTrue( ((IASTName)node).resolveBinding() instanceof IEnumeration ); assertEquals( ((IASTName)node).toString(), "E" ); //$NON-NLS-1$ - + IName[] decls = getReferencesOffTU((IASTName)node); assertEquals(decls.length, 1); assertEquals( decls[0].toString(), "E" ); //$NON-NLS-1$ assertEquals( ((ASTNode)decls[0]).getOffset(), 76); assertEquals( ((ASTNode)decls[0]).getLength(), 1); - } + } public void testBugLabelWithMacro() throws Exception { Writer writer = new StringWriter(); @@ -1511,32 +1495,32 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { writer.write("goto test;\n"); //$NON-NLS-1$ writer.write("return foo();\n"); //$NON-NLS-1$ writer.write("}\n"); //$NON-NLS-1$ - + String code = writer.toString(); - + int index = code.indexOf("HANDLE h"); //$NON-NLS-1$ IASTNode node = parse( code, index, index + 6, true ); assertTrue( node instanceof IASTName ); assertTrue( ((IASTName)node).resolveBinding() instanceof IMacroBinding ); assertEquals( ((IASTName)node).toString(), "HANDLE" ); //$NON-NLS-1$ - + IName[] decls = getDeclarationOffTU((IASTName)node); assertEquals(decls.length, 1); assertEquals( decls[0].toString(), "HANDLE" ); //$NON-NLS-1$ assertEquals( ((ASTNode)decls[0]).getOffset(), 36); assertEquals( ((ASTNode)decls[0]).getLength(), 6); - + index = code.indexOf("test;"); //$NON-NLS-1$ node = parse( code, index, index + 4, true ); assertTrue( node instanceof IASTName ); assertTrue( ((IASTName)node).resolveBinding() instanceof ILabel ); assertEquals( ((IASTName)node).toString(), "test" ); //$NON-NLS-1$ - + decls = getDeclarationOffTU((IASTName)node); assertEquals(decls.length, 1); assertEquals( decls[0].toString(), "test" ); //$NON-NLS-1$ assertLocation(code, "test:", 4, decls[0]); - } + } public void testBugMethodDef() throws Exception { Writer writer = new StringWriter(); @@ -1552,28 +1536,28 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { writer.write("void tetrahedron::set() {\n"); //$NON-NLS-1$ writer.write("int color;\n"); //$NON-NLS-1$ writer.write("setColor(color);\n"); //$NON-NLS-1$ - writer.write("}\n"); //$NON-NLS-1$ - + writer.write("}\n"); //$NON-NLS-1$ + String code = writer.toString(); - + int index = code.indexOf("setColor(color)"); //$NON-NLS-1$ IASTNode node = parse( code, index, index + 8, true ); assertTrue( node instanceof IASTName ); assertTrue( ((IASTName)node).resolveBinding() instanceof ICPPMethod ); assertEquals( ((IASTName)node).toString(), "setColor" ); //$NON-NLS-1$ - + IName[] decls = getDeclarationOffTU((IASTName)node); assertEquals(decls.length, 1); assertEquals( decls[0].toString(), "setColor" ); //$NON-NLS-1$ assertEquals( ((ASTNode)decls[0]).getOffset(), 67); assertEquals( ((ASTNode)decls[0]).getLength(), 8); - + IName[] refs = getReferencesOffTU((IASTName)node); assertEquals(refs.length, 1); assertEquals( refs[0].toString(), "setColor" ); //$NON-NLS-1$ assertEquals( ((ASTNode)refs[0]).getOffset(), 162); assertEquals( ((ASTNode)refs[0]).getLength(), 8); - } + } public void testBug86698A() throws Exception { Writer writer = new StringWriter(); @@ -1583,22 +1567,22 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { writer.write("int c;\n"); //$NON-NLS-1$ writer.write("C() : c(0) { no_opt(this); }\n"); //$NON-NLS-1$ writer.write("};\n"); //$NON-NLS-1$ - + String code = writer.toString(); - + int index = code.indexOf("c(0)"); //$NON-NLS-1$ IASTNode node = parse( code, index, index + 1, true ); assertTrue( node instanceof IASTName ); assertTrue( ((IASTName)node).resolveBinding() instanceof IVariable ); assertEquals( ((IASTName)node).toString(), "c" ); //$NON-NLS-1$ - + IName[] decls = getDeclarationOffTU((IASTName)node); assertEquals(decls.length, 1); assertEquals( decls[0].toString(), "c" ); //$NON-NLS-1$ assertEquals( ((ASTNode)decls[0]).getOffset(), 42); assertEquals( ((ASTNode)decls[0]).getLength(), 1); - } - + } + public void testBug86698B() throws Exception { Writer writer = new StringWriter(); writer.write("int f(int);\n"); //$NON-NLS-1$ @@ -1619,24 +1603,23 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { writer.write("// handles exceptions thrown from the ctorinitializer\n"); //$NON-NLS-1$ writer.write("// and from the constructor function body\n"); //$NON-NLS-1$ writer.write("}\n"); //$NON-NLS-1$ - + String code = writer.toString(); - + int index = code.indexOf("i(f(ii)), d(id)"); //$NON-NLS-1$ IASTNode node = parse( code, index, index + 1, true ); assertTrue( node instanceof IASTName ); assertTrue( ((IASTName)node).resolveBinding() instanceof ICPPField ); assertEquals( ((IASTName)node).toString(), "i" ); //$NON-NLS-1$ - + IName[] decls = getDeclarationOffTU((IASTName)node); assertEquals(decls.length, 1); assertEquals( decls[0].toString(), "i" ); //$NON-NLS-1$ assertEquals( code.indexOf("int i") + 4, ((ASTNode)decls[0]).getOffset()); assertEquals( ((ASTNode)decls[0]).getLength(), 1); - } + } - public void testBug64181() throws Exception - { + public void testBug64181() throws Exception { StringBuffer buffer = new StringBuffer(); buffer.append("namespace Foo { // ** (A) **\n"); //$NON-NLS-1$ buffer.append("int bar;\n"); //$NON-NLS-1$ @@ -1648,7 +1631,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { buffer.append("main(int argc, char **argv) {\n"); //$NON-NLS-1$ buffer.append("Foo::bar; // ** (C) **\n"); //$NON-NLS-1$ buffer.append("}\n"); //$NON-NLS-1$ - + String code = buffer.toString(); int index = code.indexOf("Foo::bar;"); //$NON-NLS-1$ IASTNode node = parse( code, index, index + 3, true ); @@ -1664,9 +1647,8 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { assertEquals( ((ASTNode)decls[1]).getOffset(), 50); assertEquals( ((ASTNode)decls[1]).getLength(), 3); } - - public void testBug80823() throws Exception - { + + public void testBug80823() throws Exception { StringBuffer buffer = new StringBuffer(); buffer.append("class MyEggImpl {}; // line A\n"); //$NON-NLS-1$ buffer.append("#define MyChicken MyEggImpl\n"); //$NON-NLS-1$ @@ -1686,8 +1668,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { assertEquals( ((ASTNode)decls[0]).getLength(), 9); } - public void testBug86993() throws Exception - { + public void testBug86993() throws Exception { StringBuffer buffer = new StringBuffer(); buffer.append("#define _BEGIN_STD_C extern \"C\" {\n"); //$NON-NLS-1$ buffer.append("#define _END_STD_C }\n"); //$NON-NLS-1$ @@ -1696,8 +1677,8 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { buffer.append("_END_STD_C\n"); //$NON-NLS-1$ buffer.append("char foo() {\n"); //$NON-NLS-1$ buffer.append("return c; // ref \n"); //$NON-NLS-1$ - buffer.append("}\n"); //$NON-NLS-1$ - + buffer.append("}\n"); //$NON-NLS-1$ + String code = buffer.toString(); int index = code.indexOf("return c;"); //$NON-NLS-1$ IASTNode node = parse( code, index + 7, index + 8, true ); @@ -1709,7 +1690,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { assertEquals(decls.length, 1); assertEquals( decls[0].toString(), "c" ); //$NON-NLS-1$ assertLocation(code, "c;", 1, decls[0]); - + index = code.indexOf("char c"); //$NON-NLS-1$ node = parse( code, index + 5, index + 6, true ); assertNotNull( node ); @@ -1720,7 +1701,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { assertEquals( refs[0].toString(), "c" ); //$NON-NLS-1$ assertLocation(code, "c; // ref", 1, refs[0]); } - + private void assertLocation(String code, String occur, int length, IName name) { int offset= code.indexOf(occur); final IASTFileLocation loc= name.getFileLocation(); @@ -1728,4 +1709,3 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { assertEquals(length, loc.getNodeLength()); } } - diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMSelectionParseBaseTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMSelectionParseTestBase.java similarity index 90% rename from core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMSelectionParseBaseTest.java rename to core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMSelectionParseTestBase.java index a54b623bec7..80d7a29a63f 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMSelectionParseBaseTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMSelectionParseTestBase.java @@ -23,16 +23,16 @@ import org.eclipse.core.resources.IFile; * @author johnc * */ -public class DOMSelectionParseBaseTest extends DOMFileBasePluginTest { +public class DOMSelectionParseTestBase extends DOMFileBasePluginTest { - public DOMSelectionParseBaseTest() { + public DOMSelectionParseTestBase() { } - public DOMSelectionParseBaseTest(String name) { + public DOMSelectionParseTestBase(String name) { super(name); } - public DOMSelectionParseBaseTest(String name, Class className) { + public DOMSelectionParseTestBase(String name, Class className) { super(name, className); } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/FaultToleranceTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/FaultToleranceTests.java index 46beb30698f..9493190bb1b 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/FaultToleranceTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/FaultToleranceTests.java @@ -30,7 +30,7 @@ import org.eclipse.cdt.core.parser.ParserLanguage; /** * Testcases related to recovery from invalid syntax. */ -public class FaultToleranceTests extends AST2BaseTest { +public class FaultToleranceTests extends AST2TestBase { public static TestSuite suite() { return suite(FaultToleranceTests.class); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/GCCCompleteParseExtensionsTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/GCCCompleteParseExtensionsTest.java index 54ee449ebb2..803f458c1db 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/GCCCompleteParseExtensionsTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/GCCCompleteParseExtensionsTest.java @@ -31,7 +31,7 @@ import org.eclipse.cdt.internal.core.dom.parser.c.CFunction; import org.eclipse.cdt.internal.core.model.ASTStringUtil; import org.eclipse.cdt.internal.core.parser.ParserException; -public class GCCCompleteParseExtensionsTest extends AST2BaseTest { +public class GCCCompleteParseExtensionsTest extends AST2TestBase { public GCCCompleteParseExtensionsTest() { } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/GCCTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/GCCTests.java index 51515f83f85..4d284afb934 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/GCCTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/GCCTests.java @@ -29,7 +29,7 @@ import org.eclipse.cdt.core.parser.ParserLanguage; /** * @author aniefer */ -public class GCCTests extends AST2BaseTest { +public class GCCTests extends AST2TestBase { public GCCTests() { } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ImageLocationTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ImageLocationTests.java index 3781b3dcf99..a9b2425d18b 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ImageLocationTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ImageLocationTests.java @@ -23,7 +23,7 @@ import org.eclipse.cdt.core.parser.ParserLanguage; /** * @author jcamelon */ -public class ImageLocationTests extends AST2BaseTest { +public class ImageLocationTests extends AST2TestBase { private static final int CODE = IASTImageLocation.REGULAR_CODE; private static final int MACRO = IASTImageLocation.MACRO_DEFINITION; diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/LanguageExtensionsTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/LanguageExtensionsTest.java index 5ccbc2afdea..80fa8691192 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/LanguageExtensionsTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/LanguageExtensionsTest.java @@ -44,7 +44,7 @@ import org.eclipse.cdt.internal.core.parser.scanner.CPreprocessor; /** * Testcases for non-gnu language extensions. */ -public class LanguageExtensionsTest extends AST2BaseTest { +public class LanguageExtensionsTest extends AST2TestBase { protected static final int SIZEOF_EXTENSION = 0x1; protected static final int FUNCTION_STYLE_ASM = 0x2; diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/QuickParser2Tests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/QuickParser2Tests.java index 33cc1a0d043..9f33234002f 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/QuickParser2Tests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/QuickParser2Tests.java @@ -1335,7 +1335,7 @@ public class QuickParser2Tests extends TestCase { ParserLanguage lang, boolean gcc) throws Exception { FileContent codeReader = FileContent.create("", code.toCharArray()); IScannerInfo scannerInfo = new ScannerInfo(); - IScanner scanner= AST2BaseTest.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo); + IScanner scanner= AST2TestBase.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo); ISourceCodeParser parser2 = null; if (lang == ParserLanguage.CPP) { ICPPParserExtensionConfiguration config = null; diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/SemanticsTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/SemanticsTests.java index e4d259c68bc..d669ebbea30 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/SemanticsTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/SemanticsTests.java @@ -20,7 +20,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil; /** * Directly tests parts of the semantics package */ -public class SemanticsTests extends AST2BaseTest { +public class SemanticsTests extends AST2TestBase { public SemanticsTests() {} public SemanticsTests(String name) { super(name); } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/TaskParserTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/TaskParserTest.java index 381b6965450..bdd5255f575 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/TaskParserTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/TaskParserTest.java @@ -18,7 +18,7 @@ import org.eclipse.cdt.core.parser.ParserLanguage; import org.eclipse.cdt.internal.core.pdom.indexer.TodoTaskParser; import org.eclipse.cdt.internal.core.pdom.indexer.TodoTaskParser.Task; -public class TaskParserTest extends AST2BaseTest { +public class TaskParserTest extends AST2TestBase { public static TestSuite suite() { return suite(TaskParserTest.class); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/TestUtil.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/TestUtil.java new file mode 100644 index 00000000000..5a292b6bd77 --- /dev/null +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/TestUtil.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2013 Nathan Ridge. + * 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: + * Nathan Ridge - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.core.parser.tests.ast2; + +import org.eclipse.cdt.core.dom.ast.IASTImplicitName; +import org.eclipse.cdt.core.dom.ast.IASTImplicitNameOwner; +import org.eclipse.cdt.core.dom.ast.IASTName; +import org.eclipse.cdt.core.dom.ast.IASTNode; + +public class TestUtil { + /** + * Searches the AST upward from the given starting node to find the + * nearest IASTImplicitNameOwner and returns its first implicit name, + * or null if it has no implicit names. + */ + public static IASTName findImplicitName(IASTNode node) { + while (node != null) { + if (node instanceof IASTImplicitNameOwner) { + IASTImplicitName[] implicitNames = ((IASTImplicitNameOwner) node).getImplicitNames(); + if (implicitNames != null && implicitNames.length > 0) { + return implicitNames[0]; + } + } + node = node.getParent(); + } + return null; + } +} diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/TypeTraitsTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/TypeTraitsTests.java index 7fff28bb67d..bb536e69847 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/TypeTraitsTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/TypeTraitsTests.java @@ -21,7 +21,7 @@ import org.eclipse.cdt.internal.core.parser.ParserException; /** * Tests for ClassTypeHelper class. */ -public class TypeTraitsTests extends AST2BaseTest { +public class TypeTraitsTests extends AST2TestBase { public TypeTraitsTests() { } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/VariableReadWriteFlagsTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/VariableReadWriteFlagsTest.java index 494d56817d3..3fdf112e2fc 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/VariableReadWriteFlagsTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/VariableReadWriteFlagsTest.java @@ -23,7 +23,7 @@ import org.eclipse.cdt.internal.core.pdom.dom.PDOMName; /** * Unit tests for CPPVariableReadWriteFlags and CVariableReadWriteFlags classes. */ -public class VariableReadWriteFlagsTest extends AST2BaseTest { +public class VariableReadWriteFlagsTest extends AST2TestBase { private static final int READ = PDOMName.READ_ACCESS; private static final int WRITE = PDOMName.WRITE_ACCESS; diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/CompletionTestBase.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/CompletionTestBase.java index be9e1b6f112..f6d44ea67ff 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/CompletionTestBase.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/CompletionTestBase.java @@ -38,7 +38,7 @@ import org.eclipse.cdt.core.parser.NullLogService; import org.eclipse.cdt.core.parser.ParserLanguage; import org.eclipse.cdt.core.parser.ParserMode; import org.eclipse.cdt.core.parser.ScannerInfo; -import org.eclipse.cdt.core.parser.tests.ast2.AST2BaseTest; +import org.eclipse.cdt.core.parser.tests.ast2.AST2TestBase; import org.eclipse.cdt.core.testplugin.CTestPlugin; import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.cdt.core.testplugin.util.TestSourceReader; @@ -53,7 +53,7 @@ public class CompletionTestBase extends BaseTestCase { protected IASTCompletionNode getCompletionNode(String code, ParserLanguage lang, boolean useGNUExtensions) throws ParserException { FileContent codeReader = FileContent.create("", code.trim().toCharArray()); ScannerInfo scannerInfo = new ScannerInfo(); - IScanner scanner= AST2BaseTest.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo); + IScanner scanner= AST2TestBase.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo); ISourceCodeParser parser = null; if( lang == ParserLanguage.CPP ) diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/ASTWriterTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/ASTWriterTest.java index 8eea3e22ddf..6576a1f3eb2 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/ASTWriterTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/ASTWriterTest.java @@ -28,7 +28,7 @@ import org.eclipse.cdt.core.parser.NullLogService; import org.eclipse.cdt.core.parser.ParserLanguage; import org.eclipse.cdt.core.parser.ParserMode; import org.eclipse.cdt.core.parser.ScannerInfo; -import org.eclipse.cdt.core.parser.tests.ast2.AST2BaseTest; +import org.eclipse.cdt.core.parser.tests.ast2.AST2TestBase; import org.eclipse.cdt.core.parser.tests.rewrite.RewriteBaseTest; import org.eclipse.cdt.core.parser.tests.rewrite.TestHelper; import org.eclipse.cdt.core.parser.tests.rewrite.TestSourceFile; @@ -95,7 +95,7 @@ public class ASTWriterTest extends RewriteBaseTest { ParserLanguage language = getLanguage(testFile); boolean useGNUExtensions = getGNUExtension(testFile); - IScanner scanner = AST2BaseTest.createScanner(codeReader, language, ParserMode.COMPLETE_PARSE, scannerInfo); + IScanner scanner = AST2TestBase.createScanner(codeReader, language, ParserMode.COMPLETE_PARSE, scannerInfo); ISourceCodeParser parser = null; if (language == ParserLanguage.CPP) { diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/LexerTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/LexerTests.java index 23bdc2bd11a..a9a98d581b5 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/LexerTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/LexerTests.java @@ -1,12 +1,13 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2013 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: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.core.parser.tests.scanner; @@ -201,7 +202,29 @@ public class LexerTests extends BaseTestCase { id("ab"); eof(); } - + + public void testLessColonColon() throws Exception { + // 2.5-3 + // <: is treated as digraph [ + init("<::>"); + token(IToken.tLBRACKET); + token(IToken.tRBRACKET); + eof(); + + // <: is treated as digraph [ + init("<:::"); + token(IToken.tLBRACKET); + token(IToken.tCOLONCOLON); + eof(); + + // <:: is treated as < and :: + init("<::A"); + token(IToken.tLT); + token(IToken.tCOLONCOLON); + token(IToken.tIDENTIFIER); + eof(); + } + public void testWindowsLineEnding() throws Exception { init("\n\n"); nl(); nl(); eof(); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBindingResolutionTestBase.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBindingResolutionTestBase.java index 978a6f18bd0..4490da93a26 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBindingResolutionTestBase.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBindingResolutionTestBase.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2012 Symbian Software Systems and others. + * Copyright (c) 2006, 2013 Symbian 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 @@ -10,6 +10,7 @@ * IBM Corporation * Markus Schorn (Wind River Systems) * Sergey Prigogin (Google) + * Nathan Ridge *******************************************************************************/ package org.eclipse.cdt.internal.index.tests; @@ -83,7 +84,7 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase { super.tearDown(); } - protected IASTName findName(String section, int len) { + protected IASTName findName(String section, int len, boolean preferImplicitName) { if (len == 0) len= section.length(); for (int i = 0; i < strategy.getAstCount(); i++) { @@ -91,15 +92,27 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase { final IASTNodeSelector nodeSelector = ast.getNodeSelector(null); final int offset = strategy.getAstSource(i).indexOf(section); if (offset >= 0) { - IASTName name= nodeSelector.findName(offset, len); - if (name == null) - name= nodeSelector.findImplicitName(offset, len); - return name; + if (preferImplicitName) { + return nodeSelector.findImplicitName(offset, len); + } else { + IASTName name= nodeSelector.findName(offset, len); + if (name == null) + name= nodeSelector.findImplicitName(offset, len); + return name; + } } } return null; } + + protected IASTName findName(String section, int len) { + return findName(section, len, false); + } + + protected IASTName findImplicitName(String section, int len) { + return findName(section, len, true); + } /** * Attempts to get an IBinding from the initial specified number of characters @@ -129,9 +142,37 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase { assertInstance(binding, clazz, cs); return clazz.cast(binding); } + + /** + * Attempts to get an IBinding attached to an implicit name from the initial specified + * number of characters from the specified code fragment. Fails the test if + *
    + *
  • There is not a unique implicit name with the specified criteria + *
  • The binding associated with the implicit name is null or a problem binding + *
  • The binding is not an instance of the specified class + *
+ * @param section the code fragment to search for in the AST. The first occurrence of an identical section is used. + * @param len the length of the specified section to use as a name + * @param clazz an expected class type or interface that the binding should extend/implement + * @return the associated implicit name's binding + */ + protected T getBindingFromImplicitASTName(String section, int len, Class clazz, Class ... cs) { + if (len < 1) { + len= section.length()+len; + } + IASTName name= findImplicitName(section, len); + assertNotNull("Name not found for \"" + section + "\"", name); + assertEquals(section.substring(0, len), name.getRawSignature()); + + IBinding binding = name.resolveBinding(); + assertNotNull("No binding for " + name.getRawSignature(), binding); + assertFalse("Binding is a ProblemBinding for name \"" + name.getRawSignature() + "\"", IProblemBinding.class.isAssignableFrom(name.resolveBinding().getClass())); + assertInstance(binding, clazz, cs); + return clazz.cast(binding); + } /* - * @see IndexBindingResolutionTestBase#getBindingFromASTName(Class, String, int) + * @see IndexBindingResolutionTestBase#getBindingFromASTName(String, int, Class, Class ...) */ protected T getBindingFromASTName(String section, int len) { if (len <= 0) @@ -146,6 +187,23 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase { assertFalse("Binding is a ProblemBinding for name \"" + name.getRawSignature() + "\"", IProblemBinding.class.isAssignableFrom(name.resolveBinding().getClass())); return (T) binding; } + + /* + * @see IndexBindingResolutionTestBase#getBindingFromImplicitASTName(String, int, Class, Class ...) + */ + protected T getBindingFromImplicitASTName(String section, int len) { + if (len <= 0) + len += section.length(); + + IASTName name= findImplicitName(section, len); + assertNotNull("Name not found for \"" + section + "\"", name); + assertEquals(section.substring(0, len), name.getRawSignature()); + + IBinding binding = name.resolveBinding(); + assertNotNull("No binding for " + name.getRawSignature(), binding); + assertFalse("Binding is a ProblemBinding for name \"" + name.getRawSignature() + "\"", IProblemBinding.class.isAssignableFrom(name.resolveBinding().getClass())); + return (T) binding; + } /** * Attempts to verify that the resolved binding for a name is a problem binding. diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCBindingResolutionBugs.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCBindingResolutionBugs.java index c2210a5712e..ea7a3a80dd6 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCBindingResolutionBugs.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCBindingResolutionBugs.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2010 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2013 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 @@ -8,6 +8,7 @@ * Contributors: * Markus Schorn - initial API and implementation * Andrew Ferguson (Symbian) + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.index.tests; @@ -42,20 +43,20 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase public ProjectWithDepProj() { setStrategy(new ReferencedProject(false)); } public static TestSuite suite() { return suite(ProjectWithDepProj.class); } } - - public static void addTests(TestSuite suite) { + + public static void addTests(TestSuite suite) { suite.addTest(SingleProject.suite()); suite.addTest(ProjectWithDepProj.suite()); } - // #include + // #include // void func1(void) { // int i = 0; // for (i=0; i<10;i++) { // printf("%i", i); // } // } - + // #include "header.h" // // int main(void) { @@ -77,7 +78,7 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase } // void func1(void); - + // #include "header.h" // // int main(void) { @@ -87,7 +88,7 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase IBinding b0 = getBindingFromASTName("func1;", 5); assertTrue(b0 instanceof IFunction); } - + // typedef struct { // int utm; // } usertype; @@ -132,7 +133,7 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase assertInstance(type, IEnumeration.class); assertTrue(type instanceof IEnumeration); } - + // int globalVar; // // don't include header @@ -268,10 +269,10 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase e= (IEnumeration) b1; ei= e.getEnumerators(); assertEquals(1, ei.length); - } + } // // no header needed - + // typedef struct { // int member; // } t_struct; @@ -289,7 +290,7 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase assertTrue(tdIndex instanceof IIndexBinding); assertTrue(tdAST instanceof ITypedef); assertTrue(tdIndex instanceof ITypedef); - + IType tAST= ((ITypedef) tdAST).getType(); IType tIndex= ((ITypedef) tdIndex).getType(); assertTrue(tAST instanceof ICompositeType); @@ -304,7 +305,7 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase assertTrue(tdIndex instanceof IIndexBinding); assertTrue(tdAST instanceof ITypedef); assertTrue(tdIndex instanceof ITypedef); - + tAST= ((ITypedef) tdAST).getType(); tIndex= ((ITypedef) tdIndex).getType(); assertTrue(tAST instanceof ICompositeType); @@ -319,7 +320,7 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase assertTrue(tdIndex instanceof IIndexBinding); assertTrue(tdAST instanceof ITypedef); assertTrue(tdIndex instanceof ITypedef); - + tAST= ((ITypedef) tdAST).getType(); tIndex= ((ITypedef) tdIndex).getType(); assertTrue(tAST instanceof IEnumeration); @@ -327,13 +328,13 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase assertTrue(tAST.isSameType(tIndex)); assertTrue(tIndex.isSameType(tAST)); } - + // struct outer { // union { // int var1; // }; // }; - + // #include "header.h" // void test() { // struct outer x; @@ -354,7 +355,7 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase // int var1; // }; // }; - + // #include "header.h" // void test() { // union outer x; @@ -369,14 +370,14 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase assertTrue(outer instanceof ICCompositeTypeScope); assertEquals("outer", outer.getScopeName().toString()); } - + // int myFunc(); - + // int myFunc(var) - // int var; - // { - // return var; - // } + // int var; + // { + // return var; + // } // int main(void) { // return myFunc(0); // } @@ -390,7 +391,7 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase assertTrue(params[0].getType() instanceof IBasicType); assertEquals(IBasicType.Kind.eInt, ((IBasicType) params[0].getType()).getKind()); } - + // typedef struct S S; // void setValue(S *pSelf, int value); @@ -404,7 +405,7 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase IBinding b = getBindingFromASTName("value =", 5); assertTrue(b instanceof IField); } - + // void f255( // int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, // int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, @@ -439,8 +440,8 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase // int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, // int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, // int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int); - - // void test() { + + // void test() { // f255( // 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, @@ -463,8 +464,8 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase public void testFunctionsWithManyParameters_Bug319186() throws Exception { getBindingFromASTName("f255", 0); getBindingFromASTName("f256", 0); - } - + } + // struct B { // float f; // }; @@ -474,5 +475,17 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase // }; public void testDesignatedInitializer_Bug210019() throws Exception { IField f= getBindingFromASTName("f", 0); - } + } + + // struct S { + // int data; + // }; + + // void test(void (*f)(void*)) { + // struct S *i; + // f(&i->data); + // } + public void testBug394151() throws Exception { + IParameter f= getBindingFromASTName("f(", 1); + } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java index 2925bf8ffa3..082c99311a4 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Symbian Software Systems and others. + * Copyright (c) 2007, 2013 Symbian 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 @@ -9,6 +9,7 @@ * Andrew Ferguson (Symbian) - Initial implementation * Markus Schorn (Wind River Systems) * Sergey Prigogin (Google) + * Nathan Ridge *******************************************************************************/ package org.eclipse.cdt.internal.index.tests; @@ -1490,9 +1491,7 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti assertFalse(b0 instanceof IIndexBinding); ICPPConstructor b1 = getBindingFromASTName("B(int x)", 1, ICPPConstructor.class); assertFalse(b1 instanceof IIndexBinding); - ICPPConstructor b2 = getBindingFromASTName("B(0)", 1, ICPPConstructor.class); - assertFalse(b2 instanceof IIndexBinding); - assertEquals(b1, b2); + ICPPClassType b2 = getBindingFromASTName("B(0)", 1, ICPPClassType.class); ICPPMethod b3 = getBindingFromASTName("m(0)", 1, ICPPMethod.class); assertFalse(b3 instanceof IIndexBinding); } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java index 57ffaefda0b..2c1033ffc30 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2012 Symbian Software Systems and others. + * Copyright (c) 2007, 2013 Symbian 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 @@ -300,7 +300,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa // X xa= new X(); // } public void testUnindexedConstructorInstance() { - IBinding b0= getBindingFromASTName("X()", 4); + IBinding b0= getBindingFromImplicitASTName("X()", 4); assertInstance(b0, ICPPConstructor.class); } @@ -409,7 +409,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa // assertEquals(3, _ctcs.length); // two implicit plus the constructor template IBinding b2= getBindingFromASTName("D(", 1); - IBinding b3= getBindingFromASTName("D(", 6); + IBinding b3= getBindingFromImplicitASTName("D(", 6); assertInstance(b2, ICPPClassTemplate.class); // *D*(5, 6) assertInstance(b2, ICPPClassType.class); // *D*(5, 6) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/FileContent.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/FileContent.java index fd7085fbd78..8594ace9c3c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/FileContent.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/FileContent.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2012 Wind River Systems, Inc. and others. + * Copyright (c) 2009, 2013 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 @@ -8,9 +8,12 @@ * Contributors: * Markus Schorn - initial API and implementation * Sergey Prigogin (Google) + * Chris Recoskie (IBM Corporation) *******************************************************************************/ package org.eclipse.cdt.core.parser; +import java.io.File; + import org.eclipse.cdt.core.dom.ast.IASTFileLocation; import org.eclipse.cdt.core.index.IIndexFileLocation; import org.eclipse.cdt.core.model.ITranslationUnit; @@ -133,6 +136,11 @@ public abstract class FileContent { public static FileContent adapt(CodeReader reader) { if (reader == null) return null; - return create(reader.getPath(), reader.buffer); + + long fileReadTime = System.currentTimeMillis(); + CharArray chars = new CharArray(reader.buffer); + String filePath = reader.getPath(); + File file = new File(filePath); + return new InternalFileContent(filePath, chars, file.lastModified(), file.length(), fileReadTime); } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTEnumerator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTEnumerator.java index 32335283083..ff3726895e8 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTEnumerator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTEnumerator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2011 Wind River Systems, Inc. and others. + * Copyright (c) 2008, 2013 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 @@ -7,6 +7,7 @@ * * Contributors: * Markus Schorn - initial API and implementation + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser; @@ -33,11 +34,11 @@ public abstract class ASTEnumerator extends ASTNode implements IASTEnumerator, I setName(name); setValue(value); } - - protected void copyAbstractEnumerator(ASTEnumerator copy, CopyStyle style) { + + protected T copy(T copy, CopyStyle style) { copy.setName(name == null ? null : name.copy(style)); copy.setValue(value == null ? null : value.copy(style)); - copy.setOffsetAndLength(this); + return super.copy(copy, style); } @Override @@ -125,23 +126,26 @@ public abstract class ASTEnumerator extends ASTNode implements IASTEnumerator, I } private void createEnumValues(IASTEnumerationSpecifier parent) { + IValue previousExplicitValue = null; + int delta = 0; IASTEnumerator[] etors= parent.getEnumerators(); - long cv= -1; - boolean isknown= true; for (IASTEnumerator etor : etors) { - cv++; + IValue val; IASTExpression expr= etor.getValue(); if (expr != null) { - IValue val= Value.create(expr, Value.MAX_RECURSION_DEPTH); - Long nv= val.numericalValue(); - isknown= false; - if (nv != null) { - isknown= true; - cv= nv.longValue(); + val= Value.create(expr, Value.MAX_RECURSION_DEPTH); + previousExplicitValue = val; + delta = 1; + } else { + if (previousExplicitValue != null) { + val = Value.incrementedValue(previousExplicitValue, delta); + } else { + val = Value.create(delta); } + delta++; } if (etor instanceof ASTEnumerator) { - ((ASTEnumerator) etor).integralValue= isknown ? Value.create(cv) : Value.UNKNOWN; + ((ASTEnumerator) etor).integralValue= val; } } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/SizeofCalculator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/SizeofCalculator.java index a084775601e..92ebd31459a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/SizeofCalculator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/SizeofCalculator.java @@ -129,7 +129,11 @@ public class SizeofCalculator { sizeof_long_long = getSize(sizeofMacros, "__SIZEOF_LONG_LONG__", maxAlignment); //$NON-NLS-1$ sizeof_int128 = getSize(sizeofMacros, "__SIZEOF_INT128__", maxAlignment); //$NON-NLS-1$ sizeof_short = getSize(sizeofMacros, "__SIZEOF_SHORT__", maxAlignment); //$NON-NLS-1$ - sizeof_bool = getSize(sizeofMacros, "__SIZEOF_BOOL__", maxAlignment); //$NON-NLS-1$ + SizeAndAlignment size = getSize(sizeofMacros, "__SIZEOF_BOOL__", maxAlignment); //$NON-NLS-1$ + // __SIZEOF_BOOL__ is not defined by GCC but sizeof(bool) is needed for template resolution. + if (size == null) + size = SIZE_1; + sizeof_bool = size; sizeof_wchar_t = getSize(sizeofMacros, "__SIZEOF_WCHAR_T__", maxAlignment); //$NON-NLS-1$ sizeof_float = getSize(sizeofMacros, "__SIZEOF_FLOAT__", maxAlignment); //$NON-NLS-1$ sizeof_complex_float = getSizeOfPair(sizeof_float); @@ -152,7 +156,7 @@ public class SizeofCalculator { sizeof_long_long = null; sizeof_int128 = size_16; sizeof_short = null; - sizeof_bool = null; + sizeof_bool = SIZE_1; sizeof_wchar_t = null; sizeof_float = null; sizeof_complex_float = null; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java index 4e5a941bc05..8c074ef9932 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java @@ -39,6 +39,7 @@ import org.eclipse.cdt.core.dom.ast.IASTBinaryTypeIdExpression; import org.eclipse.cdt.core.dom.ast.IASTCastExpression; import org.eclipse.cdt.core.dom.ast.IASTConditionalExpression; import org.eclipse.cdt.core.dom.ast.IASTExpression; +import org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory; import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression; import org.eclipse.cdt.core.dom.ast.IASTIdExpression; import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression; @@ -53,16 +54,20 @@ import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IValue; import org.eclipse.cdt.core.dom.ast.IVariable; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializerClause; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter; import org.eclipse.cdt.core.parser.util.CharArrayUtils; import org.eclipse.cdt.internal.core.dom.parser.SizeofCalculator.SizeAndAlignment; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType; import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownType; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalBinary; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalBinding; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalFixed; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.TypeTraits; import org.eclipse.cdt.internal.core.parser.scanner.ExpressionEvaluator; import org.eclipse.cdt.internal.core.parser.scanner.ExpressionEvaluator.EvalException; @@ -77,6 +82,7 @@ public class Value implements IValue { public static final int MAX_RECURSION_DEPTH = 25; public static final Value UNKNOWN= new Value("".toCharArray(), null); //$NON-NLS-1$ public static final Value NOT_INITIALIZED= new Value("<__>".toCharArray(), null); //$NON-NLS-1$ + private static final IType INT_TYPE= new CPPBasicType(ICPPBasicType.Kind.eInt, 0); private static final Number VALUE_CANNOT_BE_DETERMINED = new Number() { @Override @@ -271,6 +277,16 @@ public class Value implements IValue { return UNKNOWN; } + public static IValue incrementedValue(IValue value, int increment) { + Long val = value.numericalValue(); + if (val != null) { + return create(val.longValue() + increment); + } + ICPPEvaluation arg1 = value.getEvaluation(); + EvalFixed arg2 = new EvalFixed(INT_TYPE, ValueCategory.PRVALUE, create(increment)); + return create(new EvalBinary(IASTBinaryExpression.op_plus, arg1, arg2)); + } + private static Number applyUnaryTypeIdOperator(int operator, IType type, IASTNode point) { switch (operator) { case op_sizeof: diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/VariableReadWriteFlags.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/VariableReadWriteFlags.java index a800794bc05..b32d1f97e6a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/VariableReadWriteFlags.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/VariableReadWriteFlags.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2013 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 @@ -7,6 +7,7 @@ * * Contributors: * Markus Schorn - initial API and implementation + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser; @@ -191,7 +192,7 @@ public abstract class VariableReadWriteFlags { final IType type= functionNameExpression.getExpressionType(); if (type instanceof IFunctionType) { return rwArgumentForFunctionCall((IFunctionType) type, i, indirection); - } else { + } else if (funcCall instanceof IASTImplicitNameOwner) { IASTImplicitName[] implicitNames = ((IASTImplicitNameOwner) funcCall).getImplicitNames(); if (implicitNames.length == 1) { IASTImplicitName name = implicitNames[0]; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTEnumerator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTEnumerator.java index b5706d94dac..1b596216df0 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTEnumerator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTEnumerator.java @@ -1,12 +1,12 @@ /******************************************************************************* - * Copyright (c) 2005, 2011 IBM Corporation and others. + * Copyright (c) 2005, 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: - * John Camelon (IBM Rational Software) - Initial API and implementation + * John Camelon (IBM Rational Software) - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.c; @@ -34,11 +34,6 @@ public class CASTEnumerator extends ASTEnumerator { @Override public CASTEnumerator copy(CopyStyle style) { - CASTEnumerator copy = new CASTEnumerator(); - copyAbstractEnumerator(copy, style); - if (style == CopyStyle.withLocations) { - copy.setCopyLocation(this); - } - return copy; + return copy(new CASTEnumerator(), style); } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTEnumerator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTEnumerator.java index fdd9fef35d6..0eee0c53ec3 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTEnumerator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTEnumerator.java @@ -1,13 +1,13 @@ /******************************************************************************* - * Copyright (c) 2004, 2011 IBM Corporation and others. + * Copyright (c) 2004, 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: - * John Camelon (IBM) - Initial API and implementation - * Markus Schorn (Wind River Systems) + * John Camelon (IBM) - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -35,11 +35,6 @@ public class CPPASTEnumerator extends ASTEnumerator { @Override public CPPASTEnumerator copy(CopyStyle style) { - CPPASTEnumerator copy = new CPPASTEnumerator(); - copyAbstractEnumerator(copy, style); - if (style == CopyStyle.withLocations) { - copy.setCopyLocation(this); - } - return copy; + return copy(new CPPASTEnumerator(), style); } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java index a447998e76e..70ca109fd0e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2012 IBM Corporation and others. + * Copyright (c) 2004, 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 @@ -550,14 +550,6 @@ public class CPPSemantics { if (parent instanceof ICPPASTConstructorChainInitializer) { return true; } - if (parent instanceof ICPPASTNamedTypeSpecifier) { - parent= parent.getParent(); - if (parent instanceof IASTTypeId && parent.getParent() instanceof ICPPASTNewExpression) { - IASTDeclarator dtor = ((IASTTypeId) parent).getAbstractDeclarator(); - if (dtor != null && dtor.getPointerOperators().length == 0) - return true; - } - } return false; } @@ -3103,27 +3095,43 @@ public class CPPSemantics { return null; IType type = ((ICPPVariable) binding).getType(); - try { - type = SemanticUtil.getNestedType(type, TDEF | CVTYPE); - if (!(type instanceof ICPPClassType)) - return null; - if (type instanceof ICPPClassTemplate || type instanceof ICPPUnknownType || type instanceof ISemanticProblem) - return null; + type = SemanticUtil.getNestedType(type, TDEF | CVTYPE); + if (!(type instanceof ICPPClassType)) + return null; + if (type instanceof ICPPClassTemplate || type instanceof ICPPUnknownType || type instanceof ISemanticProblem) + return null; - final ICPPClassType classType = (ICPPClassType) type; + return findImplicitlyCalledConstructor((ICPPClassType) type, initializer, name); + } + + public static ICPPConstructor findImplicitlyCalledConstructor(ICPPASTNewExpression expr) { + IType type = getNestedType(expr.getExpressionType(), TDEF | REF | CVTYPE); + if (!(type instanceof IPointerType)) + return null; + type = ((IPointerType) type).getType(); + if (type instanceof ICPPClassType) { + return findImplicitlyCalledConstructor((ICPPClassType) type, + expr.getInitializer(), expr.getTypeId()); + } + return null; + } + + private static ICPPConstructor findImplicitlyCalledConstructor(ICPPClassType type, IASTInitializer initializer, + IASTNode typeId) { + try { if (initializer instanceof IASTEqualsInitializer) { // Copy initialization. IASTEqualsInitializer eqInit= (IASTEqualsInitializer) initializer; ICPPASTInitializerClause initClause = (ICPPASTInitializerClause) eqInit.getInitializerClause(); final ICPPEvaluation evaluation = initClause.getEvaluation(); - IType sourceType= evaluation.getTypeOrFunctionSet(name); - ValueCategory isLValue= evaluation.getValueCategory(name); + IType sourceType= evaluation.getTypeOrFunctionSet(typeId); + ValueCategory isLValue= evaluation.getValueCategory(typeId); if (sourceType != null) { Cost c; - if (calculateInheritanceDepth(sourceType, classType, name) >= 0) { - c = Conversions.copyInitializationOfClass(isLValue, sourceType, classType, false, name); + if (calculateInheritanceDepth(sourceType, type, typeId) >= 0) { + c = Conversions.copyInitializationOfClass(isLValue, sourceType, type, false, typeId); } else { - c = Conversions.checkImplicitConversionSequence(type, sourceType, isLValue, UDCMode.ALLOWED, Context.ORDINARY, name); + c = Conversions.checkImplicitConversionSequence(type, sourceType, isLValue, UDCMode.ALLOWED, Context.ORDINARY, typeId); } if (c.converts()) { ICPPFunction f = c.getUserDefinedConversion(); @@ -3136,7 +3144,7 @@ public class CPPSemantics { // List initialization. ICPPEvaluation eval= ((ICPPASTInitializerList) initializer).getEvaluation(); if (eval instanceof EvalInitList) { - Cost c= Conversions.listInitializationSequence((EvalInitList) eval, type, UDCMode.ALLOWED, true, name); + Cost c= Conversions.listInitializationSequence((EvalInitList) eval, type, UDCMode.ALLOWED, true, typeId); if (c.converts()) { ICPPFunction f = c.getUserDefinedConversion(); if (f instanceof ICPPConstructor) @@ -3145,35 +3153,22 @@ public class CPPSemantics { } } else if (initializer instanceof ICPPASTConstructorInitializer) { // Direct initialization. - return findImplicitlyCalledConstructor(classType, - (ICPPASTConstructorInitializer) initializer, name); + return findImplicitlyCalledConstructor(type, + (ICPPASTConstructorInitializer) initializer, typeId); } else if (initializer == null) { // Default initialization. - ICPPConstructor[] ctors = ClassTypeHelper.getConstructors(classType, name); + ICPPConstructor[] ctors = ClassTypeHelper.getConstructors(type, typeId); for (ICPPConstructor ctor : ctors) { if (ctor.getRequiredArgumentCount() == 0) return ctor; } return null; } - } catch (DOMException e) { + } catch (DOMException e) { } - return null; + return null; } - public static ICPPConstructor findImplicitlyCalledConstructor(ICPPASTNewExpression expr) { - IType type = getNestedType(expr.getExpressionType(), TDEF | REF | CVTYPE); - if (!(type instanceof IPointerType)) - return null; - type = ((IPointerType) type).getType(); - IASTInitializer initializer = expr.getInitializer(); - if (type instanceof ICPPClassType && initializer instanceof ICPPASTConstructorInitializer) { - return findImplicitlyCalledConstructor((ICPPClassType) type, - (ICPPASTConstructorInitializer) initializer, expr.getTypeId()); - } - return null; - } - private static ICPPConstructor findImplicitlyCalledConstructor(ICPPClassType classType, ICPPASTConstructorInitializer initializer, IASTNode typeId) { final IASTInitializerClause[] arguments = initializer.getArguments(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/Lexer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/Lexer.java index 439e2a910fb..f65f9dcb5da 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/Lexer.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/Lexer.java @@ -1,13 +1,14 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2013 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: - * Markus Schorn - initial API and implementation - * Mike Kucera (IBM) - UTF string literals + * Markus Schorn - initial API and implementation + * Mike Kucera (IBM) - UTF string literals + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.core.parser.scanner; @@ -195,7 +196,7 @@ final public class Lexer implements ITokenSequence { Token t= fToken; Token lt= null; while (true) { - switch(t.getType()) { + switch (t.getType()) { case IToken.tCOMPLETION: if (lt != null) { fLastToken= lt; @@ -228,7 +229,7 @@ final public class Lexer implements ITokenSequence { public Token nextDirective() throws OffsetLimitReachedException { Token t0; Token t1= fToken; - for(;;) { + for (;;) { t0= t1; t1= fetchToken(); final int tt1 = t1.getType(); @@ -252,7 +253,7 @@ final public class Lexer implements ITokenSequence { final int start= fOffset; final int c= fCharPhase3; final int d= nextCharPhase3(); - switch(c) { + switch (c) { case END_OF_INPUT: return newToken(IToken.tEND_OF_INPUT, start); case '\n': @@ -266,7 +267,7 @@ final public class Lexer implements ITokenSequence { continue; case 'L': - switch(d) { + switch (d) { case 'R': if (fOptions.fSupportRawStringLiterals) { markPhase3(); @@ -289,7 +290,7 @@ final public class Lexer implements ITokenSequence { case 'u': case 'U': if (fOptions.fSupportUTFLiterals) { - switch(d) { + switch (d) { case 'R': if (fOptions.fSupportRawStringLiterals) { markPhase3(); @@ -364,7 +365,7 @@ final public class Lexer implements ITokenSequence { break; case '\\': - switch(d) { + switch (d) { case 'u': case 'U': nextCharPhase3(); return identifier(start, 2); @@ -376,7 +377,7 @@ final public class Lexer implements ITokenSequence { return number(start, 1, false); case '.': - switch(d) { + switch (d) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': nextCharPhase3(); @@ -420,7 +421,7 @@ final public class Lexer implements ITokenSequence { return newToken(IToken.tSEMI, start); case ':': - switch(d) { + switch (d) { case ':': nextCharPhase3(); return newToken(IToken.tCOLONCOLON, start); @@ -564,7 +565,7 @@ final public class Lexer implements ITokenSequence { return headerName(start, false); } - switch(d) { + switch (d) { case '=': nextCharPhase3(); return newToken(IToken.tLTEQUAL, start); @@ -582,8 +583,19 @@ final public class Lexer implements ITokenSequence { } break; case ':': - nextCharPhase3(); - return newDigraphToken(IToken.tLBRACKET, start); + // 2.5-3 + markPhase3(); + if (nextCharPhase3() != ':') { + return newDigraphToken(IToken.tLBRACKET, start); + } + switch (nextCharPhase3()) { + case ':': case '>': + restorePhase3(); + nextCharPhase3(); + return newDigraphToken(IToken.tLBRACKET, start); + } + restorePhase3(); + break; case '%': nextCharPhase3(); return newDigraphToken(IToken.tLBRACE, start); @@ -591,7 +603,7 @@ final public class Lexer implements ITokenSequence { return newToken(IToken.tLT, start); case '>': - switch(d) { + switch (d) { case '=': nextCharPhase3(); return newToken(IToken.tGTEQUAL, start); @@ -636,7 +648,7 @@ final public class Lexer implements ITokenSequence { private Token newToken(final int kind, final int offset, final int imageLength) { final int endOffset= fOffset; - final int sourceLen= endOffset-offset; + final int sourceLen= endOffset - offset; char[] image; if (sourceLen != imageLength) { image= getCharImage(offset, endOffset, imageLength); @@ -719,7 +731,7 @@ final public class Lexer implements ITokenSequence { int c= fCharPhase3; loop: while (!done) { - switch(c) { + switch (c) { case END_OF_INPUT: if (fSupportContentAssist) { throw new OffsetLimitReachedException(ORIGIN_LEXER, newToken(tokenType, start, length)); @@ -752,19 +764,19 @@ final public class Lexer implements ITokenSequence { final int delimOffset= fOffset; int delimEndOffset = delimOffset; int offset; - for(;; delimEndOffset++) { + for (;; delimEndOffset++) { if (!fInput.isValidOffset(delimEndOffset)) { offset= delimEndOffset; break; } if (fInput.get(delimEndOffset) == '(') { - offset= delimEndOffset+1; + offset= delimEndOffset + 1; break; } } - final int delimLength= delimEndOffset-delimOffset; - for(;; offset++) { + final int delimLength= delimEndOffset - delimOffset; + for (;; offset++) { if (!fInput.isValidOffset(offset)) { handleProblem(IProblem.SCANNER_UNBOUNDED_STRING, getInputChars(start, offset), start); break; @@ -772,27 +784,27 @@ final public class Lexer implements ITokenSequence { final char c= fInput.get(offset); if (c == ')') { - final int endingDoubleQuoteOffset= offset+delimLength+1; + final int endingDoubleQuoteOffset= offset + delimLength + 1; if (fInput.isValidOffset(endingDoubleQuoteOffset) && fInput.get(endingDoubleQuoteOffset) == '"') { boolean prefixMatches= true; for (int i = 0; i < delimLength; i++) { - if (fInput.get(offset + i + 1) != fInput.get(delimOffset+i)) { + if (fInput.get(offset + i + 1) != fInput.get(delimOffset + i)) { prefixMatches= false; break; } } if (prefixMatches) { - offset= endingDoubleQuoteOffset+1; + offset= endingDoubleQuoteOffset + 1; break; } } } } - fOffset= offset-1; + fOffset= offset - 1; fEndOffset= offset; fCharPhase3= 0; nextCharPhase3(); - return newToken(tokenType, start, offset-start); + return newToken(tokenType, start, offset - start); } private Token charLiteral(final int start, final int tokenType) throws OffsetLimitReachedException { @@ -802,7 +814,7 @@ final public class Lexer implements ITokenSequence { int c= fCharPhase3; loop: while (!done) { - switch(c) { + switch (c) { case END_OF_INPUT: if (fSupportContentAssist) { throw new OffsetLimitReachedException(ORIGIN_LEXER, newToken(tokenType, start, length)); @@ -835,7 +847,7 @@ final public class Lexer implements ITokenSequence { boolean isPartOfIdentifier= true; int c= fCharPhase3; while (true) { - switch(c) { + switch (c) { case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': @@ -849,7 +861,7 @@ final public class Lexer implements ITokenSequence { case '\\': // universal character name markPhase3(); - switch(nextCharPhase3()) { + switch (nextCharPhase3()) { case 'u': case 'U': length++; break; @@ -904,7 +916,7 @@ final public class Lexer implements ITokenSequence { boolean isHex= false; int c= fCharPhase3; while (true) { - switch(c) { + switch (c) { // non-digit case 'a': case 'b': case 'c': case 'd': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'q': case 'r': @@ -952,7 +964,7 @@ final public class Lexer implements ITokenSequence { // universal character name (non-digit) case '\\': markPhase3(); - switch(nextCharPhase3()) { + switch (nextCharPhase3()) { case 'u': case 'U': length++; break; @@ -1013,7 +1025,7 @@ final public class Lexer implements ITokenSequence { private int nextCharPhase3() { int pos= fEndOffset; do { - if (!isValidOffset(pos+1)) { + if (!isValidOffset(pos + 1)) { if (!isValidOffset(pos)) { fOffset= pos; fEndOffset= pos; @@ -1021,7 +1033,7 @@ final public class Lexer implements ITokenSequence { return END_OF_INPUT; } fOffset= pos; - fEndOffset= pos+1; + fEndOffset= pos + 1; fCharPhase3= fInput.get(pos); return fCharPhase3; } @@ -1030,7 +1042,7 @@ final public class Lexer implements ITokenSequence { fOffset= pos; fEndOffset= ++pos; fCharPhase3= c; - switch(c) { + switch (c) { // windows line-ending case '\r': if (fInput.get(pos) == '\n') { @@ -1080,7 +1092,7 @@ final public class Lexer implements ITokenSequence { * @return the character encoded or 0. */ private char checkTrigraph(char c) { - switch(c) { + switch (c) { case '=': return '#'; case '\'':return '^'; case '(': return '['; @@ -1101,7 +1113,7 @@ final public class Lexer implements ITokenSequence { boolean haveBackslash= true; int result= -1; loop: while (isValidOffset(pos)) { - switch(fInput.get(pos++)) { + switch (fInput.get(pos++)) { case '\n': if (haveBackslash) { result= pos; @@ -1140,7 +1152,7 @@ final public class Lexer implements ITokenSequence { * Returns the image from the input without any modification. */ public char[] getInputChars(int offset, int endOffset) { - final int length= endOffset-offset; + final int length= endOffset - offset; if (length <= 0) { return CharArrayUtils.EMPTY; } @@ -1160,7 +1172,7 @@ final public class Lexer implements ITokenSequence { final char[] result= new char[imageLength]; markPhase3(); fEndOffset= offset; - for (int idx=0; idxnull when the content in the project fragment of the specified project's index + * is complete (contains all sources) and up to date; or an @link{IStatus} indicating the first + * occurrence of an index file found not up-to-date, along with its include trail. + * @throws CoreException in case of a file access or other internal error + */ + public IStatus getProjectContentSyncState(ICProject cproject) throws CoreException { if (!"true".equals(IndexerPreferences.get(cproject.getProject(), IndexerPreferences.KEY_INDEX_ALL_FILES, null))) //$NON-NLS-1$ - return true; // no check performed in this case + return null; // No check is performed in this case Set sources= new HashSet(); cproject.accept(new TranslationUnitCollector(sources, null, new NullProgressMonitor())); + IStatus syncStatus = null; try { IIndex index= getIndex(cproject); @@ -1543,8 +1561,9 @@ public class PDOMManager implements IWritableIndexManager, IListener { IResource resource= tu.getResource(); if (resource instanceof IFile && isSubjectToIndexing(tu.getLanguage())) { IIndexFileLocation location= IndexLocationFactory.getWorkspaceIFL((IFile) resource); - if (!areSynchronized(new HashSet(), index, resource, location)) { - return false; + syncStatus = areSynchronized(new HashSet(), index, resource, location); + if (syncStatus != null) { + return syncStatus; } } } @@ -1555,11 +1574,11 @@ public class PDOMManager implements IWritableIndexManager, IListener { CCorePlugin.log(e); } - return true; + return null; } private boolean isSubjectToIndexing(ILanguage language) { - final int linkageID=language.getLinkageID(); + final int linkageID = language.getLinkageID(); for (int id : IDS_FOR_LINKAGES_TO_INDEX) { if (linkageID == id) return true; @@ -1568,45 +1587,57 @@ public class PDOMManager implements IWritableIndexManager, IListener { } /** - * Recursively checks that the specified file, and its include are up-to-date. + * Recursively checks that the specified file, and its includes are up-to-date. * @param trail a set of previously checked include file locations * @param index the index to check against * @param resource the resource to check from the workspace * @param location the location to check from the index - * @return whether the specified file, and its includes are up-to-date. + * @return null when whether the specified file, and its includes are up-to-date, + * or a MultiStatus indicating the file found to be not in sync along with it include trail. * @throws CoreException */ - private static boolean areSynchronized(Set trail, IIndex index, IResource resource, IIndexFileLocation location) throws CoreException { + private static MultiStatus areSynchronized(Set trail, IIndex index, + IResource resource, IIndexFileLocation location) throws CoreException { if (!trail.contains(location)) { trail.add(location); - IIndexFile[] file= index.getFiles(location); + IIndexFile[] files= index.getFiles(location); - // pre-includes may be listed twice (191989) - if (file.length < 1 || file.length > 2) - return false; + if (files.length <= 0) + return new MultiStatus(CCorePlugin.PLUGIN_ID, IStatus.OK, "No index file found for: " + location, null); //$NON-NLS-1$ - if (resource.getLocalTimeStamp() != file[0].getTimestamp()) - return false; + for (IIndexFile file : files) { + long diff = resource.getLocalTimeStamp() - file.getTimestamp(); + if (diff != 0) { + return new MultiStatus(CCorePlugin.PLUGIN_ID, IStatus.OK, + "Index timestamp for '" //$NON-NLS-1$ + + file.getLocation().getFullPath() + + "' is " + diff + " msec older than " //$NON-NLS-1$ //$NON-NLS-2$ + + location + + "(" + SimpleDateFormat.getDateTimeInstance().format(new Date(resource.getLocalTimeStamp())) //$NON-NLS-1$ + + ")", null); //$NON-NLS-1$ + } - // if it is up-to-date, the includes have not changed and may - // be read from the index. - IIndexInclude[] includes= index.findIncludes(file[0]); - for (IIndexInclude inc : includes) { - IIndexFileLocation newLocation= inc.getIncludesLocation(); - if (newLocation != null) { - String path= newLocation.getFullPath(); - if (path != null) { - IResource newResource= ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(path)); - if (!areSynchronized(trail, index, newResource, newLocation)) { - return false; + // If it is up-to-date, the includes have not changed and may be read from the index. + IIndexInclude[] includes= index.findIncludes(file); + for (IIndexInclude inc : includes) { + IIndexFileLocation newLocation= inc.getIncludesLocation(); + if (newLocation != null) { + String path= newLocation.getFullPath(); + if (path != null) { + IResource newResource= ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(path)); + MultiStatus m = areSynchronized(trail, index, newResource, newLocation); + if (m != null) { + m.add(new Status(IStatus.INFO, CCorePlugin.PLUGIN_ID, + "Included by " + file.getLocation().getFullPath())); //$NON-NLS-1$ + return m; + } } } } } } - - return true; + return null; } public boolean isFileIndexedUnconditionally(IIndexFileLocation ifl) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/export/GeneratePDOM.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/export/GeneratePDOM.java index fbd6182c35b..6312b599510 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/export/GeneratePDOM.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/export/GeneratePDOM.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Symbian Software Systems and others. + * Copyright (c) 2007, 2013 Symbian 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 @@ -8,11 +8,11 @@ * Contributors: * Andrew Ferguson (Symbian) - Initial implementation * Markus Schorn (Wind River Systems) + * Martin Oberhuber (Wind River) - [397652] fix up-to-date check for PDOM *******************************************************************************/ package org.eclipse.cdt.internal.core.pdom.export; import java.io.File; -import com.ibm.icu.text.MessageFormat; import java.util.Map; import org.eclipse.cdt.core.CCorePlugin; @@ -26,9 +26,12 @@ import org.eclipse.cdt.internal.core.pdom.WritablePDOM; import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.MultiStatus; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Status; +import com.ibm.icu.text.MessageFormat; + /** * An ISafeRunnable which *
    @@ -43,14 +46,28 @@ public class GeneratePDOM { protected File targetLocation; protected String indexerID; protected boolean deleteOnExit; - - public GeneratePDOM(IExportProjectProvider pm, String[] applicationArguments, File targetLocation, String indexerID) { + protected boolean checkIndexStatus; + + /** + * Runnable to export a PDOM. + * @param checkIndexStatus true to check index completeness before exporting, or + * false to export the index without checking anything + * @since 5.5 + */ + public GeneratePDOM(IExportProjectProvider pm, String[] applicationArguments, File targetLocation, + String indexerID, boolean checkIndexStatus) { this.pm= pm; this.applicationArguments= applicationArguments; this.targetLocation= targetLocation; this.indexerID= indexerID; + this.checkIndexStatus= checkIndexStatus; } - + + public GeneratePDOM(IExportProjectProvider pm, String[] applicationArguments, File targetLocation, + String indexerID) { + this(pm, applicationArguments, targetLocation, indexerID, true); + } + /** * When set, the project created by the associated {@link IExportProjectProvider} will * be deleted after {@link #run()} completes. By default this is not set. @@ -66,74 +83,77 @@ public class GeneratePDOM { * @throws CoreException if an internal or invalid configuration error occurs */ public final IStatus run() throws CoreException { - boolean isContentSynced= false; - - // create the project + // Create the project pm.setApplicationArguments(applicationArguments); final ICProject cproject = pm.createProject(); - if(cproject==null) { + if (cproject == null) { fail(MessageFormat.format(Messages.GeneratePDOM_ProjectProviderReturnedNullCProject, - new Object [] {pm.getClass().getName()})); - return null; // cannot be reached, inform the compiler + new Object[] { pm.getClass().getName() })); + return null; // Cannot be reached, inform the compiler } IIndexLocationConverter converter= pm.getLocationConverter(cproject); - if(converter==null) { + if (converter == null) { fail(MessageFormat.format(Messages.GeneratePDOM_NullLocationConverter, - new Object [] {pm.getClass().getName()})); + new Object[] { pm.getClass().getName() })); } - // index the project + // Index the project IndexerPreferences.set(cproject.getProject(), IndexerPreferences.KEY_INDEXER_ID, indexerID); try { - final IIndexManager im = CCorePlugin.getIndexManager(); + final IIndexManager manager = CCorePlugin.getIndexManager(); for (int i = 0; i < 20; i++) { - if(CCoreInternals.getPDOMManager().isProjectRegistered(cproject)) { - im.joinIndexer(Integer.MAX_VALUE, new NullProgressMonitor()); - if (!im.isIndexerSetupPostponed(cproject)) { + if (CCoreInternals.getPDOMManager().isProjectRegistered(cproject)) { + manager.joinIndexer(Integer.MAX_VALUE, new NullProgressMonitor()); + if (!manager.isIndexerSetupPostponed(cproject)) { break; } } Thread.sleep(200); } - // check status - isContentSynced= CCoreInternals.getPDOMManager().isProjectContentSynced(cproject); - - if(isContentSynced) { - // export a .pdom file - CCoreInternals.getPDOMManager().exportProjectPDOM(cproject, targetLocation, converter); - - // write properties to exported PDOM - WritablePDOM exportedPDOM= new WritablePDOM(targetLocation, converter, LanguageManager.getInstance().getPDOMLinkageFactoryMappings()); - exportedPDOM.acquireWriteLock(0); - try { - Map exportProperties= pm.getExportProperties(); - if(exportProperties!=null) { - for(Map.Entry entry : exportProperties.entrySet()) { - exportedPDOM.setProperty(entry.getKey(), entry.getValue()); - } - } - exportedPDOM.close(); - } - finally { - exportedPDOM.releaseWriteLock(); + if (checkIndexStatus) { + // Check status + IStatus syncStatus = CCoreInternals.getPDOMManager().getProjectContentSyncState(cproject); + if (syncStatus != null) { + // Add message and error severity + IStatus myStatus = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, Messages.GeneratePDOM_Incomplete); + MultiStatus m = new MultiStatus(CCorePlugin.PLUGIN_ID, 1, new IStatus[] {myStatus, syncStatus}, + Messages.GeneratePDOM_Incomplete, null); + // Log the status right away since legacy clients did not return any status details + CCorePlugin.log(m); + return m; } } - - } catch(InterruptedException ie) { + // Export a .pdom file + CCoreInternals.getPDOMManager().exportProjectPDOM(cproject, targetLocation, converter); + + // Write properties to exported PDOM + WritablePDOM exportedPDOM= new WritablePDOM(targetLocation, converter, + LanguageManager.getInstance().getPDOMLinkageFactoryMappings()); + exportedPDOM.acquireWriteLock(0); + try { + Map exportProperties= pm.getExportProperties(); + if (exportProperties != null) { + for(Map.Entry entry : exportProperties.entrySet()) { + exportedPDOM.setProperty(entry.getKey(), entry.getValue()); + } + } + exportedPDOM.close(); + } finally { + exportedPDOM.releaseWriteLock(); + } + } catch (InterruptedException ie) { String msg= MessageFormat.format(Messages.GeneratePDOM_GenericGenerationFailed, new Object[] {ie.getMessage()}); throw new CoreException(CCorePlugin.createStatus(msg, ie)); } finally { - if(deleteOnExit) { + if (deleteOnExit) { cproject.getProject().delete(true, new NullProgressMonitor()); } } - return isContentSynced ? - new Status(IStatus.OK, CCorePlugin.PLUGIN_ID, Messages.GeneratePDOM_Success) - : new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, Messages.GeneratePDOM_Incomplete); + return new Status(IStatus.OK, CCorePlugin.PLUGIN_ID, Messages.GeneratePDOM_Success); } private void fail(String message) throws CoreException { diff --git a/core/org.eclipse.cdt.core/plugin.xml b/core/org.eclipse.cdt.core/plugin.xml index f58003a9329..7cd1e698f09 100644 --- a/core/org.eclipse.cdt.core/plugin.xml +++ b/core/org.eclipse.cdt.core/plugin.xml @@ -757,6 +757,30 @@ + + + + + + + + + + + + + + + + + + diff --git a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/ProcessHelper.java b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/ProcessHelper.java index 465432cac9a..44c779f40ee 100644 --- a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/ProcessHelper.java +++ b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/ProcessHelper.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Symbian Software Limited and others. + * Copyright (c) 2007, 2013 Symbian Software Limited 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 @@ -9,6 +9,7 @@ * Bala Torati (Symbian) - Initial API and implementation * Mark Espiritu (VastSystems) - bug 215283 * Raphael Zulliger (Indel AG) - [367482] fixed resource leak + * Doug Schaefer (QNX) - added different start and end patterns for macros *******************************************************************************/ package org.eclipse.cdt.core.templateengine.process; @@ -77,21 +78,35 @@ public class ProcessHelper { * @since 4.0 */ public static Set getReplaceKeys(String str) { + return getReplaceKeys(str, START_PATTERN, END_PATTERN); + } + + /** + * This method returns a vector of all replace marker strings. (e.g., + * $(item), vector contains 'item' as one item) is the end pattern. + * + * @param str A given string possibly containing markers. + * @param startPattern token to start macro replacement + * @param endPattern token to end macro replacement + * @return the set of names occurring within markers + * @since 5.5 + */ + public static Set getReplaceKeys(String str, String startPattern, String endPattern) { Set replaceStrings = new HashSet(); int start= 0; int end= 0; - while ((start = str.indexOf(START_PATTERN, start)) >= 0) { - end = str.indexOf(END_PATTERN, start); + while ((start = str.indexOf(startPattern, start)) >= 0) { + end = str.indexOf(endPattern, start); if (end != -1) { - replaceStrings.add(str.substring(start + START_PATTERN.length(), end)); - start = end + END_PATTERN.length(); + replaceStrings.add(str.substring(start + startPattern.length(), end)); + start = end + endPattern.length(); } else { start++; } } return replaceStrings; } - + /** * This method takes a URL as parameter to read the contents, and to add * into a string buffer. @@ -183,12 +198,24 @@ public class ProcessHelper { * * @since 4.0 */ - public static String getValueAfterExpandingMacros(String string, Set macros, - Map valueStore) { + public static String getValueAfterExpandingMacros(String string, Set macros, Map valueStore) { + return getValueAfterExpandingMacros(string, macros, valueStore, START_PATTERN, END_PATTERN); + } + + /** + * @param string + * @param macros + * @param valueStore + * @return the macro value after expanding the macros. + * + * @since 5.5 + */ + public static String getValueAfterExpandingMacros(String string, Set macros, Map valueStore, + String startPattern, String endPattern) { for (String key : macros) { String value = valueStore.get(key); if (value != null) { - string = string.replace(START_PATTERN + key + END_PATTERN, value); + string = string.replace(startPattern + key + endPattern, value); } } return string; @@ -203,4 +230,5 @@ public class ProcessHelper { public static String getReplaceMarker(String macro) { return START_PATTERN + macro + END_PATTERN; } + } diff --git a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/processes/AddFiles.java b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/processes/AddFiles.java index e6674033e7c..1f4fa400dfe 100644 --- a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/processes/AddFiles.java +++ b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/processes/AddFiles.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Symbian Software Limited and others. + * Copyright (c) 2007, 2013 Symbian Software Limited 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 @@ -7,6 +7,7 @@ * * Contributors: * Bala Torati (Symbian) - Initial API and implementation + * Doug Schaefer (QNX) - Added overridable start and end patterns *******************************************************************************/ package org.eclipse.cdt.core.templateengine.process.processes; @@ -29,7 +30,6 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; - /** * Adds Files to the Project */ @@ -40,9 +40,30 @@ public class AddFiles extends ProcessRunner { */ @Override public void process(TemplateCore template, ProcessArgument[] args, String processId, IProgressMonitor monitor) throws ProcessFailureException { - String projectName = args[0].getSimpleValue(); - IProject projectHandle = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); - ProcessArgument[][] files = args[1].getComplexArrayValue(); + IProject projectHandle = null; + ProcessArgument[][] files = null; + String startPattern = null; + String endPattern = null; + + for (ProcessArgument arg : args) { + String argName = arg.getName(); + if (argName.equals("projectName")) { //$NON-NLS-1$ + projectHandle = ResourcesPlugin.getWorkspace().getRoot().getProject(arg.getSimpleValue()); + } else if (argName.equals("files")) { //$NON-NLS-1$ + files = arg.getComplexArrayValue(); + } else if (argName.equals("startPattern")) { //$NON-NLS-1$ + startPattern = arg.getSimpleValue(); + } else if (argName.equals("endPattern")) { //$NON-NLS-1$ + endPattern = arg.getSimpleValue(); + } + } + + if (projectHandle == null) + throw new ProcessFailureException(getProcessMessage(processId, IStatus.ERROR, Messages.getString("AddFiles.8"))); //$NON-NLS-1$ + + if (files == null) + throw new ProcessFailureException(getProcessMessage(processId, IStatus.ERROR, Messages.getString("AddFiles.9"))); //$NON-NLS-1$ + for(int i=0; i { @Override public int compare(IRegion r1, IRegion r2) { diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CIndenterTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CIndenterTest.java index 52fac36670d..e1389e636aa 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CIndenterTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CIndenterTest.java @@ -432,7 +432,7 @@ public class CIndenterTest extends BaseUITestCase { //class MyClass { //typedef int MyType; //public: - //int getA() { + //virtual int getA() { //return a; //} //MyClass(); @@ -444,7 +444,7 @@ public class CIndenterTest extends BaseUITestCase { //class MyClass { // typedef int MyType; // public: - // int getA() { + // virtual int getA() { // return a; // } // MyClass(); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CPartitionerTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CPartitionerTest.java index 2db46de0a21..0f792db66c2 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CPartitionerTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CPartitionerTest.java @@ -1,11 +1,11 @@ /******************************************************************************* - * Copyright (c) 2000, 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 + * Copyright (c) 2000, 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: + * Contributors: * IBM Corporation - initial API and implementation * Anton Leherbauer (Wind River Systems) * Andrew Ferguson (Symbian) @@ -28,26 +28,21 @@ import org.eclipse.cdt.ui.text.ICPartitions; import org.eclipse.cdt.internal.ui.text.CTextTools; - - /** * Tests to verify the C partitioning. * Derived from JavaPartitionerTest. */ public class CPartitionerTest extends TestCase { - private CTextTools fTextTools; private Document fDocument; protected boolean fDocumentPartitioningChanged; - public CPartitionerTest(String name) { super(name); } @Override protected void setUp() { - fTextTools= new CTextTools(); fDocument= new Document(); @@ -84,7 +79,6 @@ public class CPartitionerTest extends TestCase { } protected void checkPartitioning(ITypedRegion[] expectation, ITypedRegion[] result) { - assertEquals("invalid number of partitions", expectation.length, result.length); for (int i= 0; i < expectation.length; i++) { @@ -92,12 +86,10 @@ public class CPartitionerTest extends TestCase { ITypedRegion r= result[i]; assertTrue(print(r) + " != " + print(e), r.equals(e)); } - } public void testInitialPartitioning() { try { - // "xxx\n/*xxx*/\nxxx\n/**xxx*/\nxxx\n/**/\nxxx\n/***/\nxxx" ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength()); @@ -121,7 +113,6 @@ public class CPartitionerTest extends TestCase { public void testIntraPartitionChange() { try { - fDocument.replace(34, 3, "y"); // "xxx\n/*xxx*/\nxxx\n/**xxx*/\nxxx\n/**/\ny\n/***/\nxxx"); @@ -148,7 +139,6 @@ public class CPartitionerTest extends TestCase { public void testIntraPartitionChange2() { try { - fDocument.replace(41, 0, "yyy"); // "xxx\n/*xxx*/\nxxx\n/**xxx*/\nxxx\n/**/\nxxx\n/**yyy*/\nxxx"); @@ -172,9 +162,9 @@ public class CPartitionerTest extends TestCase { assertTrue(false); } } + public void testInsertNewPartition() { try { - fDocument.replace(35, 1, "/***/"); // "xxx\n/*xxx*/\nxxx\n/**xxx*/\nxxx\n/**/\nx/***/x\n/***/\nxxx"); @@ -200,9 +190,9 @@ public class CPartitionerTest extends TestCase { assertTrue(false); } } + public void testInsertStringPartition() { try { - fDocument.replace(35, 1, "\"yyy\""); // "xxx\n/*xxx*/\nxxx\n/**xxx*/\nxxx\n/**/\nx\"yyy\"x\n/***/\nxxx"); @@ -228,9 +218,9 @@ public class CPartitionerTest extends TestCase { assertTrue(false); } } + public void testInsertCharacterPartition() { try { - fDocument.replace(35, 1, "'y'"); // "xxx\n/*xxx*/\nxxx\n/**xxx*/\nxxx\n/**/\nx\"yyy\"x\n/***/\nxxx"); @@ -256,9 +246,9 @@ public class CPartitionerTest extends TestCase { assertTrue(false); } } + public void testInsertPreprocessorPartition() { try { - fDocument.replace(4, 0, " # include \n"); // "xxx\n/*xxx*/\nxxx\n/**xxx*/\nxxx\n/**/\nx\"yyy\"x\n/***/\nxxx"); // "xxx\n # include \n/*xxx*/\nxxx\n/**xxx*/\nxxx\n/**/\nx\"yyy\"x\n/***/\nxxx"); @@ -287,13 +277,11 @@ public class CPartitionerTest extends TestCase { public void testRemovePartition1() { try { - fDocument.replace(13, 16, null); // "xxx\n/*xxx*/\nx/**/\nxxx\n/***/\nxxx"); assertTrue(fDocumentPartitioningChanged); - ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength()); TypedRegion[] expectation= { new TypedRegion(0, 4, IDocument.DEFAULT_CONTENT_TYPE), @@ -312,12 +300,10 @@ public class CPartitionerTest extends TestCase { } public void testRemovePartition2() { - testJoinPartition3(); fDocumentPartitioningChanged= false; try { - fDocument.replace(5, 2, null); // "xxx\nxxx\nxxx\n/**xxx*/\nxxx\n/**/\nxxx\n/***/\nxxx" @@ -340,10 +326,8 @@ public class CPartitionerTest extends TestCase { } } - public void testJoinPartitions1() { try { - fDocument.replace(31, 1, null); // "xxx\n/*xxx*/\nxxx\n/**xxx*/\nxxx\n/*/\nxxx\n/***/\nxxx" @@ -368,7 +352,6 @@ public class CPartitionerTest extends TestCase { public void testJoinPartitions2() { try { - fDocument.replace(32, 1, null); // "xxx\n/*xxx*/\nxxx\n/**xxx*/\nxxx\n/**\nxxx\n/***/\nxxx" @@ -393,7 +376,6 @@ public class CPartitionerTest extends TestCase { public void testJoinPartition3() { try { - fDocument.replace(9, 2, null); // "xxx\n/*xxx\nxxx\n/**xxx*/\nxxx\n/**/\nxxx\n/***/\nxxx" @@ -416,22 +398,16 @@ public class CPartitionerTest extends TestCase { } } - public void testSplitPartition1() { - testJoinPartitions1(); fDocumentPartitioningChanged= false; - try { - // "xxx\n/*xxx*/\nxxx\n/**xxx*/\nxxx\n/*/\nxxx\n/***/\nxxx" fDocument.replace(31, 0, "*"); // "xxx\n/*xxx*/\nxxx\n/**xxx*/\nxxx\n/**/\nxxx\n/***/\nxxx" assertTrue(fDocumentPartitioningChanged); - - } catch (BadLocationException x) { assertTrue(false); } @@ -440,18 +416,15 @@ public class CPartitionerTest extends TestCase { } public void testSplitPartition2() { - testJoinPartitions2(); fDocumentPartitioningChanged= false; try { - // "xxx\n/*xxx*/\nxxx\n/**xxx*/\nxxx\n/**\nxxx\n/***/\nxxx" fDocument.replace(32, 0, "/"); // "xxx\n/*xxx*/\nxxx\n/**xxx*/\nxxx\n/**/\nxxx\n/***/\nxxx" assertTrue(fDocumentPartitioningChanged); - } catch (BadLocationException x) { assertTrue(false); } @@ -460,11 +433,9 @@ public class CPartitionerTest extends TestCase { } public void testSplitPartition3() { - fDocumentPartitioningChanged= false; try { - // "xxx\n/*xxx*/\nxxx\n/**xxx*/\nxxx\n/**/\nxxx\n/***/\nxxx" fDocument.replace(12, 9, ""); // "xxx\n/*xxx*/\nx*/\nxxx\n/**/\nxxx\n/***/\nxxx" @@ -490,7 +461,6 @@ public class CPartitionerTest extends TestCase { public void testCorruptPartitioning1() { try { - fDocument.replace(0, fDocument.getLength(), "/***/\n/***/"); ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength()); @@ -513,7 +483,6 @@ public class CPartitionerTest extends TestCase { new TypedRegion(14, 1, IDocument.DEFAULT_CONTENT_TYPE), new TypedRegion(15, 7, ICPartitions.C_MULTI_LINE_COMMENT) }; - } catch (BadLocationException x) { assertTrue(false); } @@ -521,7 +490,6 @@ public class CPartitionerTest extends TestCase { public void testCorruptPartitioning2() { try { - fDocument.replace(0, fDocument.getLength(), "/***/\n/***/\n/***/"); ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength()); @@ -548,7 +516,6 @@ public class CPartitionerTest extends TestCase { new TypedRegion(22, 1, IDocument.DEFAULT_CONTENT_TYPE), new TypedRegion(23, 5, ICPartitions.C_MULTI_LINE_COMMENT) }; - } catch (BadLocationException x) { assertTrue(false); } @@ -556,7 +523,6 @@ public class CPartitionerTest extends TestCase { public void testCorruptPartitioning3() { try { - fDocument.replace(0, fDocument.getLength(), "/***/\n/**/"); ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength()); @@ -581,7 +547,6 @@ public class CPartitionerTest extends TestCase { new TypedRegion(17, 1, IDocument.DEFAULT_CONTENT_TYPE), new TypedRegion(18, 5, ICPartitions.C_MULTI_LINE_COMMENT) }; - } catch (BadLocationException x) { assertTrue(false); } @@ -589,7 +554,6 @@ public class CPartitionerTest extends TestCase { public void testOpenPartition1() { try { - fDocument.replace(42, 1, null); // "xxx\n/*xxx*/\nxxx\n/**xxx*/\nxxx\n/**/\nxxx\n/***\nxxx" @@ -616,7 +580,6 @@ public class CPartitionerTest extends TestCase { public void testOpenPartition2() { try { - fDocument.replace(47, 0, "/*"); // "xxx\n/*xxx*/\nxxx\n/**xxx*/\nxxx\n/**/\nxxx\n/***/\nxxx/*" @@ -646,7 +609,6 @@ public class CPartitionerTest extends TestCase { public void testPartitionFinder() { try { - ITypedRegion[] partitioning= fDocument.computePartitioning(0, fDocument.getLength()); for (int i= 0; i < partitioning.length; i++) { @@ -656,7 +618,6 @@ public class CPartitionerTest extends TestCase { assertTrue(expected.equals(result)); } } - } catch (BadLocationException x) { assertTrue(false); } @@ -664,7 +625,6 @@ public class CPartitionerTest extends TestCase { public void testExtendPartition() { try { - fDocument.replace(0, fDocument.getLength(), "/*"); ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength()); @@ -681,7 +641,6 @@ public class CPartitionerTest extends TestCase { }; checkPartitioning(expectation, result); - } catch (BadLocationException x) { assertTrue(false); } @@ -689,7 +648,6 @@ public class CPartitionerTest extends TestCase { public void testTogglePartition() { try { - fDocument.replace(0, fDocument.getLength(), "\t/*\n\tx\n\t/*/\n\ty\n//\t*/"); ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength()); @@ -712,7 +670,6 @@ public class CPartitionerTest extends TestCase { new TypedRegion(10, 12, ICPartitions.C_MULTI_LINE_COMMENT) }; checkPartitioning(expectation2, result); - } catch (BadLocationException x) { assertTrue(false); } @@ -720,7 +677,6 @@ public class CPartitionerTest extends TestCase { public void testEditing1() { try { - fDocument.replace(0, fDocument.getLength(), ""); ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength()); @@ -749,7 +705,6 @@ public class CPartitionerTest extends TestCase { }; checkPartitioning(expectation, result); - } catch (BadLocationException x) { assertTrue(false); } @@ -757,7 +712,6 @@ public class CPartitionerTest extends TestCase { public void testEditing2() { try { - fDocument.replace(0, fDocument.getLength(), ""); ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength()); @@ -794,7 +748,6 @@ public class CPartitionerTest extends TestCase { new TypedRegion(0, fDocument.getLength(), ICPartitions.C_MULTI_LINE_COMMENT) }; checkPartitioning(expectation, result); - } catch (BadLocationException x) { assertTrue(false); } @@ -802,7 +755,6 @@ public class CPartitionerTest extends TestCase { public void testEditing3() { try { - fDocument.replace(0, fDocument.getLength(), ""); ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength()); @@ -831,7 +783,6 @@ public class CPartitionerTest extends TestCase { new TypedRegion(8, 1, IDocument.DEFAULT_CONTENT_TYPE) }; checkPartitioning(expectation, result); - } catch (BadLocationException x) { assertTrue(false); } @@ -839,7 +790,6 @@ public class CPartitionerTest extends TestCase { public void testEditingString() { try { - fDocument.replace(0, fDocument.getLength(), ""); ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength()); @@ -904,7 +854,6 @@ public class CPartitionerTest extends TestCase { new TypedRegion(5, 2, ICPartitions.C_STRING) }; checkPartitioning(expectation, result); - } catch (BadLocationException x) { assertTrue(false); } @@ -912,7 +861,6 @@ public class CPartitionerTest extends TestCase { public void testEditingCharacter() { try { - fDocument.replace(0, fDocument.getLength(), ""); ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength()); @@ -977,7 +925,6 @@ public class CPartitionerTest extends TestCase { new TypedRegion(5, 2, ICPartitions.C_CHARACTER) }; checkPartitioning(expectation, result); - } catch (BadLocationException x) { assertTrue(false); } @@ -985,7 +932,6 @@ public class CPartitionerTest extends TestCase { public void testEditingPreprocessor() { try { - fDocument.replace(0, fDocument.getLength(), ""); ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength()); @@ -1096,7 +1042,6 @@ public class CPartitionerTest extends TestCase { new TypedRegion(33, 1, IDocument.DEFAULT_CONTENT_TYPE) }; checkPartitioning(expectation, result); - } catch (BadLocationException x) { assertTrue(false); } @@ -1104,7 +1049,6 @@ public class CPartitionerTest extends TestCase { public void testLineSplicing_Bug124113() { try { - fDocument.replace(0, fDocument.getLength(), "// comment... \\\\\ncontinued"); ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength()); @@ -1136,7 +1080,6 @@ public class CPartitionerTest extends TestCase { new TypedRegion(0, fDocument.getLength(), ICPartitions.C_CHARACTER) }; checkPartitioning(expectation, result); - } catch (BadLocationException x) { assertTrue(false); } @@ -1144,7 +1087,6 @@ public class CPartitionerTest extends TestCase { public void testCommentInPreprocessorString() { try { - fDocument.replace(0, fDocument.getLength(), "#define S \"http://www.foo.bar\""); ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength()); @@ -1160,7 +1102,6 @@ public class CPartitionerTest extends TestCase { new TypedRegion(0, fDocument.getLength(), ICPartitions.C_PREPROCESSOR) }; checkPartitioning(expectation, result); - } catch (BadLocationException x) { assertTrue(false); } @@ -1168,7 +1109,6 @@ public class CPartitionerTest extends TestCase { public void testString1() { try { - fDocument.replace(0, fDocument.getLength(), "\"[string]\""); ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength()); TypedRegion[] expectation= { @@ -1184,7 +1124,6 @@ public class CPartitionerTest extends TestCase { new TypedRegion(10, 9, ICPartitions.C_STRING) }; checkPartitioning(expectation, result); - } catch (BadLocationException x) { assertTrue(false); } @@ -1192,7 +1131,6 @@ public class CPartitionerTest extends TestCase { public void testString2() { try { - fDocument.replace(0, fDocument.getLength(), "\"string\"RRRRRRRR\"string\"nostring"); ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength()); TypedRegion[] expectation= { @@ -1202,7 +1140,6 @@ public class CPartitionerTest extends TestCase { new TypedRegion(24, 8, IDocument.DEFAULT_CONTENT_TYPE) }; checkPartitioning(expectation, result); - } catch (BadLocationException x) { assertTrue(false); } @@ -1210,7 +1147,6 @@ public class CPartitionerTest extends TestCase { public void testRawString1() { try { - fDocument.replace(0, fDocument.getLength(), "R\"(line 1\n/*line 2*/\nline 3\n)\""); ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength()); TypedRegion[] expectation= { @@ -1235,7 +1171,6 @@ public class CPartitionerTest extends TestCase { new TypedRegion(1, fDocument.getLength() - 1, ICPartitions.C_STRING) }; checkPartitioning(expectation, result); - } catch (BadLocationException x) { assertTrue(false); } @@ -1243,7 +1178,6 @@ public class CPartitionerTest extends TestCase { public void testRawString2() { try { - fDocument.replace(0, fDocument.getLength(), "/***/R\"(line 1\nline 2\nline 3\n)\""); ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength()); TypedRegion[] expectation= { @@ -1261,7 +1195,6 @@ public class CPartitionerTest extends TestCase { new TypedRegion(13, fDocument.getLength() - 13, ICPartitions.C_STRING) }; checkPartitioning(expectation, result); - } catch (BadLocationException x) { assertTrue(false); } @@ -1269,7 +1202,6 @@ public class CPartitionerTest extends TestCase { public void testRawString3() { try { - fDocument.replace(0, fDocument.getLength(), "/***/R\"(line 1\nline 2\nline 3\n)\" \"str\""); ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength()); TypedRegion[] expectation= { @@ -1291,7 +1223,6 @@ public class CPartitionerTest extends TestCase { new TypedRegion(fDocument.getLength() - 5, 5, ICPartitions.C_STRING), }; checkPartitioning(expectation, result); - } catch (BadLocationException x) { assertTrue(false); } @@ -1299,7 +1230,6 @@ public class CPartitionerTest extends TestCase { public void testRawString_Bug352544() { try { - fDocument.replace(0, fDocument.getLength(), "BAR\"(\";"); ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength()); TypedRegion[] expectation= { @@ -1308,7 +1238,6 @@ public class CPartitionerTest extends TestCase { new TypedRegion(6, 1, IDocument.DEFAULT_CONTENT_TYPE), }; checkPartitioning(expectation, result); - } catch (BadLocationException x) { assertTrue(false); } @@ -1316,7 +1245,6 @@ public class CPartitionerTest extends TestCase { public void testEditingRawString1() { try { - fDocument.replace(0, fDocument.getLength(), "/***/R\"(line 1\nline 2\nline 3\n)\" \"str\""); ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength()); TypedRegion[] expectation= { @@ -1351,7 +1279,6 @@ public class CPartitionerTest extends TestCase { new TypedRegion(fDocument.getLength() - 5, 5, ICPartitions.C_STRING), }; checkPartitioning(expectation, result); - } catch (BadLocationException x) { assertTrue(false); } @@ -1359,7 +1286,6 @@ public class CPartitionerTest extends TestCase { public void testEditingRawString2() { try { - fDocument.replace(0, fDocument.getLength(), "/***/R\"(line 1\nline 2\nline 3\n)\" \"str\""); ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength()); TypedRegion[] expectation= { @@ -1402,7 +1328,6 @@ public class CPartitionerTest extends TestCase { new TypedRegion(6, fDocument.getLength() - 6, ICPartitions.C_STRING), }; checkPartitioning(expectation, result); - } catch (BadLocationException x) { assertTrue(false); } @@ -1410,8 +1335,7 @@ public class CPartitionerTest extends TestCase { public void testEditingRawString3() { try { - - fDocument.replace(0, fDocument.getLength(), "/***/R\"(line 1\nline 2\nline 3\n)\" \"str\""); + fDocument.replace(0, fDocument.getLength(), "/***/R\"\"(line 1\nline 2\nline 3\n)\"\" \"str\""); ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength()); TypedRegion[] expectation= { new TypedRegion(0, 5, ICPartitions.C_MULTI_LINE_COMMENT), @@ -1433,7 +1357,6 @@ public class CPartitionerTest extends TestCase { new TypedRegion(fDocument.getLength() - 5, 5, ICPartitions.C_STRING), }; checkPartitioning(expectation, result); - } catch (BadLocationException x) { assertTrue(false); } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/SemanticHighlightingTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/SemanticHighlightingTest.java index a44a925f671..c70d7b77511 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/SemanticHighlightingTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/SemanticHighlightingTest.java @@ -1,11 +1,11 @@ /******************************************************************************* - * Copyright (c) 2000, 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 + * Copyright (c) 2000, 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: + * Contributors: * IBM Corporation - initial API and implementation * Anton Leherbauer (Wind River Systems) - Adapted for CDT *******************************************************************************/ @@ -20,13 +20,12 @@ import org.eclipse.cdt.internal.ui.editor.SemanticHighlightings; /** * Semantic highlighting tests. - * + * *

    Derived from JDT.

    * * @since 4.0 */ public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest { - private static final boolean PRINT_POSITIONS= false; private static final Class THIS= SemanticHighlightingTest.class; @@ -101,7 +100,7 @@ public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest { createPosition(108, 4, 26), createPosition(112, 4, 25), createPosition(117, 4, 32), - }; + }; if (PRINT_POSITIONS) System.out.println(toString(actual)); assertEqualPositions(expected, actual); } @@ -121,10 +120,9 @@ public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest { createPosition(108, 4, 26), createPosition(112, 4, 25), createPosition(117, 4, 32), - createPosition(118, 23, 9), createPosition(122, 4, 15), createPosition(130, 13, 9), - }; + }; Position[] actual= getSemanticHighlightingPositions(); if (PRINT_POSITIONS) System.out.println(toString(actual)); assertEqualPositions(expected, actual); @@ -134,7 +132,7 @@ public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest { setUpSemanticHighlighting(SemanticHighlightings.STATIC_METHOD_INVOCATION); Position[] expected= new Position[] { createPosition(122, 4, 15), - }; + }; Position[] actual= getSemanticHighlightingPositions(); if (PRINT_POSITIONS) System.out.println(toString(actual)); assertEqualPositions(expected, actual); @@ -256,6 +254,7 @@ public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest { createPosition(112, 4, 14), createPosition(117, 4, 14), createPosition(118, 4, 9), + createPosition(118, 23, 9), createPosition(120, 4, 8), createPosition(129, 4, 8), createPosition(147, 42, 7), @@ -297,7 +296,6 @@ public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest { assertEqualPositions(expected, actual); } - public void testGlobalVariableHighlighting() throws Exception { setUpSemanticHighlighting(SemanticHighlightings.GLOBAL_VARIABLE); Position[] actual= getSemanticHighlightingPositions(); @@ -421,5 +419,4 @@ public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest { if (PRINT_POSITIONS) System.out.println(toString(actual)); assertEqualPositions(expected, actual); } - } diff --git a/core/org.eclipse.cdt.ui/plugin.properties b/core/org.eclipse.cdt.ui/plugin.properties index 07940aa01da..61f5ad8de92 100644 --- a/core/org.eclipse.cdt.ui/plugin.properties +++ b/core/org.eclipse.cdt.ui/plugin.properties @@ -608,6 +608,8 @@ excludedFile.name = C/C++ Files and Folders Excluded from Build excludedFile.description = Decorates source files and folders excluded from C/C++ build. includeFolderDecorator.name = C/C++ Missing Include Folders includeFolderDecorator.description = Decorates missing include folders with error/warning indicator. +CustomBuildSettingsDecorator.name= C/C++ Files and Folders with Customized Build Settings +CustomBuildSettingsDecorator.description= Decorates files and folders when build settings are different from parent resource. templatesViewName= Templates @@ -629,9 +631,11 @@ LanguageSettingsProviderAssociationExtensionPoint=Language Settings Provider UI overrideAnnotation.label = C/C++ Override indicators transfer.EditorAppearance.name = C/C++ Editor Appearance -transfer.EditorAppearance.description = Preference related to how the editor presents the edited code to the user (including colors, fonts, hovers, foldings, etc...) +transfer.EditorAppearance.description = Preferences related to how the editor presents the edited code to the user (including colors, fonts, hovers, foldings, etc...) transfer.EditorBehavior.name = C/C++ Editor Behavior -transfer.EditorBehavior.description = Preference related to how the editor process the edited code (typing, save action, etc...) +transfer.EditorBehavior.description = Preferences related to how the editor deals with the edited code (typing, save action, etc...) +transfer.CodeStyle.name = C/C++ Code Style +transfer.CodeStyle.description = C/C++ > Code Style preferences # Refresh Exclusion Contributors RefreshExclusionContributor.name = Resources diff --git a/core/org.eclipse.cdt.ui/plugin.xml b/core/org.eclipse.cdt.ui/plugin.xml index a244e6e268f..7872c7016c1 100644 --- a/core/org.eclipse.cdt.ui/plugin.xml +++ b/core/org.eclipse.cdt.ui/plugin.xml @@ -4167,6 +4167,22 @@ + + %CustomBuildSettingsDecorator.description + + + + + + + @@ -4492,6 +4508,7 @@ @@ -4550,6 +4567,7 @@ @@ -4583,15 +4601,31 @@ - - + %transfer.EditorBehavior.description + + + + + + + + + + + + + %transfer.CodeStyle.description + + true if folding is enabled, false otherwise. diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBViewPart.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBViewPart.java index a1e011e4d9c..7ce213219c7 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBViewPart.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBViewPart.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2011 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2013 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 @@ -8,6 +8,7 @@ * Contributors: * Markus Schorn - initial API and implementation * Ed Swartz (Nokia) + * Martin Oberhuber (Wind River) - bug 398195: consider external API in IB *******************************************************************************/ package org.eclipse.cdt.internal.ui.includebrowser; @@ -81,6 +82,7 @@ import org.eclipse.ui.part.ViewPart; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.index.IIndex; import org.eclipse.cdt.core.index.IIndexFileLocation; +import org.eclipse.cdt.core.index.IIndexManager; import org.eclipse.cdt.core.index.IndexLocationFactory; import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.CoreModel; @@ -214,7 +216,8 @@ public class IBViewPart extends ViewPart implements IShowInSource, IShowInTarget protected IStatus run(IProgressMonitor monitor) { try { final ICProject[] projects= CoreModel.getDefault().getCModel().getCProjects(); - IIndex index= CCorePlugin.getIndexManager().getIndex(projects); + IIndex index= CCorePlugin.getIndexManager().getIndex(projects, + IIndexManager.ADD_EXTENSION_FRAGMENTS_INCLUDE_BROWSER); index.acquireReadLock(); try { if (!IndexUI.isIndexed(index, input)) { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IncludeBrowserUI.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IncludeBrowserUI.java index 0421681c7a8..c78d9c6ea5b 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IncludeBrowserUI.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IncludeBrowserUI.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2013 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 @@ -7,6 +7,7 @@ * * Contributors: * Markus Schorn - initial API and implementation + * Martin Oberhuber (Wind River) - bug 398195: consider external API in IB *******************************************************************************/ package org.eclipse.cdt.internal.ui.includebrowser; @@ -21,6 +22,7 @@ import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.index.IIndex; import org.eclipse.cdt.core.index.IIndexFileLocation; import org.eclipse.cdt.core.index.IIndexInclude; +import org.eclipse.cdt.core.index.IIndexManager; import org.eclipse.cdt.core.model.CoreModelUtil; import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICProject; @@ -70,7 +72,8 @@ public class IncludeBrowserUI { private static ITranslationUnit findTargetTranslationUnit(IInclude input) throws CoreException, InterruptedException { ICProject project= input.getCProject(); if (project != null) { - IIndex index= CCorePlugin.getIndexManager().getIndex(project); + IIndex index= CCorePlugin.getIndexManager().getIndex(project, + IIndexManager.ADD_EXTENSION_FRAGMENTS_INCLUDE_BROWSER); index.acquireReadLock(); try { IIndexInclude include= IndexUI.elementToInclude(index, input); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsProviderTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsProviderTab.java index bced35b4906..078e30ce016 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsProviderTab.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsProviderTab.java @@ -439,9 +439,12 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab { if (event.getChecked()) { if (LanguageSettingsManager.isWorkspaceProvider(checkedProvider) && !LanguageSettingsManager.isPreferShared(id)) { - ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(checkedProvider); - if (rawProvider instanceof ILanguageSettingsEditableProvider) { - newProvider = LanguageSettingsManager.getProviderCopy((ILanguageSettingsEditableProvider) rawProvider, false); + newProvider = getInitialProvider(id); + if(newProvider == null) { + ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(checkedProvider); + if (rawProvider instanceof ILanguageSettingsEditableProvider) { + newProvider = LanguageSettingsManager.getProviderCopy((ILanguageSettingsEditableProvider) rawProvider, false); + } } } } else { @@ -479,13 +482,16 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab { newProvider = LanguageSettingsManager.getWorkspaceProvider(id); } else { // Toggle to configuration-owned provider - try { - ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(provider); - if (rawProvider instanceof ILanguageSettingsEditableProvider) { - newProvider = ((ILanguageSettingsEditableProvider) rawProvider).cloneShallow(); + newProvider = getInitialProvider(id); + if(newProvider == null) { + try { + ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(provider); + if (rawProvider instanceof ILanguageSettingsEditableProvider) { + newProvider = ((ILanguageSettingsEditableProvider) rawProvider).cloneShallow(); + } + } catch (CloneNotSupportedException e) { + CUIPlugin.log("Error cloning provider " + id, e); //$NON-NLS-1$ } - } catch (CloneNotSupportedException e) { - CUIPlugin.log("Error cloning provider " + id, e); //$NON-NLS-1$ } } if (newProvider != null) { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/newui/Messages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/newui/Messages.properties index 4c543c88cd3..fb82cc455f3 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/newui/Messages.properties +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/newui/Messages.properties @@ -202,7 +202,7 @@ LanguageSettingsProviderTab_Reset=Reset LanguageSettingsProviderTab_ProviderOptions=Language Settings Provider Options LanguageSettingsProviderTab_SettingEntries=Setting Entries LanguageSettingsProviderTab_SettingEntriesTooltip=Setting Entries -LanguageSettingsProviderTab_ShareProviders=Share setting entries between projects (global provider) +LanguageSettingsProviderTab_ShareProviders=Use global provider shared between projects LanguageSettingsProviderTab_StoreEntriesInsideProject=Store entries in project settings folder (easing project migration) LanguageSettingsProviderTab_TitleResetProviders=Reset Language Settings Providers LanguageSettingsProviderTab_WorkspaceSettings=Workspace Settings diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigurationBlock.java index f394643dff9..96c64d82e3a 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigurationBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigurationBlock.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2011 IBM Corporation and others. + * Copyright (c) 2000, 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 @@ -10,7 +10,6 @@ * Anton Leherbauer (Wind River Systems * Andrew Ferguson (Symbian) *******************************************************************************/ - package org.eclipse.cdt.internal.ui.preferences; import java.io.BufferedReader; @@ -81,7 +80,6 @@ import org.eclipse.cdt.internal.ui.text.util.CColorManager; * @since 4.0 */ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock { - /** * Item in the highlighting color list. */ @@ -161,7 +159,6 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock { } private static class SemanticHighlightingColorListItem extends HighlightingColorListItem { - /** Enablement preference key */ private final String fEnableKey; @@ -175,7 +172,8 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock { * @param underlineKey the underlineKey preference key * @param enableKey the enable preference key */ - public SemanticHighlightingColorListItem(String displayName, String colorKey, String boldKey, String italicKey, String strikethroughKey, String underlineKey, String enableKey) { + public SemanticHighlightingColorListItem(String displayName, String colorKey, String boldKey, + String italicKey, String strikethroughKey, String underlineKey, String enableKey) { super(displayName, colorKey, boldKey, italicKey, strikethroughKey, underlineKey); fEnableKey= enableKey; } @@ -192,9 +190,6 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock { * Color list label provider. */ private class ColorListLabelProvider extends LabelProvider implements IColorProvider { - /* - * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object) - */ @Override public String getText(Object element) { if (element instanceof String) @@ -202,17 +197,11 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock { return ((HighlightingColorListItem)element).getDisplayName(); } - /* - * @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object) - */ @Override public Color getBackground(Object element) { return null; } - /* - * @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object) - */ @Override public Color getForeground(Object element) { if (element instanceof SemanticHighlightingColorListItem) { @@ -228,25 +217,15 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock { * Color list content provider. */ private class ColorListContentProvider implements ITreeContentProvider { - - /* - * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) - */ @Override public Object[] getElements(Object inputElement) { return new String[] {fCodeCategory, fAssemblyCategory, fCommentsCategory, fPreprocessorCategory, fDoxygenCategory}; } - /* - * @see org.eclipse.jface.viewers.IContentProvider#dispose() - */ @Override public void dispose() { } - /* - * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) - */ @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } @@ -564,7 +543,6 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock { } private Control createSyntaxPage(final Composite parent) { - Composite colorComposite= new Composite(parent, SWT.NONE); GridLayout layout= new GridLayout(); layout.marginHeight= 0; @@ -912,11 +890,11 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock { { createHighlightedRange(13, 16, 4, SemanticHighlightings.ENUMERATOR) }, { createHighlightedRange(13, 22, 3, SemanticHighlightings.ENUMERATOR) }, { createHighlightedRange(13, 27, 3, SemanticHighlightings.ENUMERATOR) }, - { createHighlightedRange(14, 14, 11, SemanticHighlightings.STATIC_FIELD), createHighlightedRange(13, 14, 11, SemanticHighlightings.FIELD) }, + { createHighlightedRange(14, 14, 11, SemanticHighlightings.STATIC_FIELD), createHighlightedRange(14, 14, 11, SemanticHighlightings.FIELD) }, { createHighlightedRange(15, 6, 5, SemanticHighlightings.FIELD) }, { createHighlightedRange(16, 10, 6, SemanticHighlightings.ENUM) }, - { createHighlightedRange(16, 17, 7, SemanticHighlightings.METHOD_DECLARATION), createHighlightedRange(15, 17, 7, SemanticHighlightings.METHOD) }, - { createHighlightedRange(17, 7, 6, SemanticHighlightings.METHOD_DECLARATION), createHighlightedRange(16, 7, 6, SemanticHighlightings.METHOD) }, + { createHighlightedRange(16, 17, 7, SemanticHighlightings.METHOD_DECLARATION), createHighlightedRange(16, 17, 7, SemanticHighlightings.METHOD) }, + { createHighlightedRange(17, 7, 6, SemanticHighlightings.METHOD_DECLARATION), createHighlightedRange(17, 7, 6, SemanticHighlightings.METHOD) }, { createHighlightedRange(17, 14, 6, SemanticHighlightings.ENUM) }, { createHighlightedRange(17, 21, 1, SemanticHighlightings.PARAMETER_VARIABLE) }, { createHighlightedRange(18, 8, 5, SemanticHighlightings.LOCAL_VARIABLE_DECLARATION) }, @@ -925,9 +903,9 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock { { createHighlightedRange(19, 7, 6, SemanticHighlightings.FUNCTION) }, { createHighlightedRange(19, 14, 5, SemanticHighlightings.LOCAL_VARIABLE) }, { createHighlightedRange(20, 4, 7, SemanticHighlightings.METHOD) }, - { createHighlightedRange(21, 4, 12, SemanticHighlightings.STATIC_METHOD_INVOCATION), createHighlightedRange(20, 4, 12, SemanticHighlightings.METHOD) }, + { createHighlightedRange(21, 4, 12, SemanticHighlightings.STATIC_METHOD_INVOCATION), createHighlightedRange(21, 4, 12, SemanticHighlightings.METHOD) }, { createHighlightedRange(22, 4, 7, SemanticHighlightings.PROBLEM) }, - { createHighlightedRange(24, 14, 12, SemanticHighlightings.METHOD_DECLARATION), createHighlightedRange(23, 14, 12, SemanticHighlightings.METHOD) }, + { createHighlightedRange(24, 14, 12, SemanticHighlightings.METHOD_DECLARATION), createHighlightedRange(24, 14, 12, SemanticHighlightings.METHOD) }, }; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringPreferencePage.java index 899beb8ea5d..bb1e7e23b3b 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringPreferencePage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringPreferencePage.java @@ -9,7 +9,6 @@ * IBM Corporation - initial API and implementation * Anton Leherbauer (Wind River Systems) *******************************************************************************/ - package org.eclipse.cdt.internal.ui.preferences; import org.eclipse.swt.widgets.Composite; @@ -19,8 +18,6 @@ import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.internal.ui.ICHelpContextIds; - - /** * Code coloring preference page. *

    @@ -30,41 +27,27 @@ import org.eclipse.cdt.internal.ui.ICHelpContextIds; * @since 4.0 */ public class CEditorColoringPreferencePage extends AbstractConfigurationBlockPreferencePage { - - /* - * @see org.eclipse.ui.internal.editors.text.AbstractConfigureationBlockPreferencePage#getHelpId() - */ @Override protected String getHelpId() { return ICHelpContextIds.C_EDITOR_COLORS_PREF_PAGE; } - /* - * @see org.eclipse.ui.internal.editors.text.AbstractConfigurationBlockPreferencePage#setDescription() - */ @Override protected void setDescription() { String description= PreferencesMessages.CEditorPreferencePage_colors; setDescription(description); } - @Override protected Label createDescriptionLabel(Composite parent) { return null; } - /* - * @see org.org.eclipse.ui.internal.editors.text.AbstractConfigurationBlockPreferencePage#setPreferenceStore() - */ @Override protected void setPreferenceStore() { setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore()); } - /* - * @see org.eclipse.ui.internal.editors.text.AbstractConfigureationBlockPreferencePage#createConfigurationBlock(org.eclipse.ui.internal.editors.text.OverlayPreferenceStore) - */ @Override protected IPreferenceConfigurationBlock createConfigurationBlock(OverlayPreferenceStore overlayPreferenceStore) { return new CEditorColoringConfigurationBlock(overlayPreferenceStore); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CIndenter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CIndenter.java index cb08370dc4e..14fe12bf58d 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CIndenter.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CIndenter.java @@ -1409,8 +1409,17 @@ public final class CIndenter { case Symbols.TokenPRIVATE: case Symbols.TokenPROTECTED: case Symbols.TokenPUBLIC: - case Symbols.TokenVIRTUAL: continue; // Don't stop at colon in a class declaration + + case Symbols.TokenVIRTUAL: + switch (peekToken()) { + case Symbols.TokenPRIVATE: + case Symbols.TokenPROTECTED: + case Symbols.TokenPUBLIC: + break; + default: + continue; + } } int pos= fPreviousPos; if (!isConditional()) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CPreprocessorScanner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CPreprocessorScanner.java index 9df46645426..fc1df9c0ab3 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CPreprocessorScanner.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CPreprocessorScanner.java @@ -32,7 +32,6 @@ import org.eclipse.cdt.internal.ui.text.util.CWordDetector; * @since 4.0 */ public class CPreprocessorScanner extends AbstractCScanner { - /** Properties for tokens. */ private static String[] fgTokenProperties= { ICColorConstants.C_KEYWORD, diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/FastCPartitionScanner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/FastCPartitionScanner.java index e71dc08a7a1..f799aaa4633 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/FastCPartitionScanner.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/FastCPartitionScanner.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2011 IBM Corporation and others. + * Copyright (c) 2000, 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 @@ -10,10 +10,10 @@ * QNX Software System * Anton Leherbauer (Wind River Systems) * Andrew Ferguson (Symbian) + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.ui.text; - import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.rules.ICharacterScanner; @@ -24,13 +24,11 @@ import org.eclipse.jface.text.rules.Token; import org.eclipse.cdt.ui.text.ICPartitions; import org.eclipse.cdt.ui.text.doctools.IDocCommentOwner; - /** * This scanner recognizes the C multi line comments, C single line comments, * C strings, C characters and C preprocessor directives. */ public final class FastCPartitionScanner implements IPartitionTokenScanner, ICPartitions { - // states private static final int CCODE= 0; private static final int SINGLE_LINE_COMMENT= 1; @@ -115,7 +113,6 @@ public final class FastCPartitionScanner implements IPartitionTokenScanner, ICPa */ @Override public IToken nextToken() { - fTokenOffset += fTokenLength; fTokenLength= fPrefixLength; @@ -135,7 +132,6 @@ public final class FastCPartitionScanner implements IPartitionTokenScanner, ICPa fLast= NONE; // ignore last if (fTokenLength > 0) { return preFix(fState, CCODE, NONE, 0); - } else { fPrefixLength= 0; return Token.EOF; @@ -165,7 +161,6 @@ public final class FastCPartitionScanner implements IPartitionTokenScanner, ICPa fState= CCODE; return token; - } else { consume(); continue; @@ -220,7 +215,6 @@ public final class FastCPartitionScanner implements IPartitionTokenScanner, ICPa case STRING: case PREPROCESSOR: case PREPROCESSOR_STRING: - int last; int newState; switch (ch) { @@ -304,7 +298,6 @@ public final class FastCPartitionScanner implements IPartitionTokenScanner, ICPa fTokenLength= fPrefixLength; break; } - } else { fTokenLength++; fLast= SLASH; @@ -321,7 +314,6 @@ public final class FastCPartitionScanner implements IPartitionTokenScanner, ICPa fTokenLength= fPrefixLength; break; } - } else { consume(); break; @@ -527,14 +519,25 @@ public final class FastCPartitionScanner implements IPartitionTokenScanner, ICPa case RAW_STRING: switch (rawStringState) { case OPEN_DELIMITER: - if (ch == '(') { + switch (ch) { + case '(': rawStringState = RawStringState.CONTENT; - } else if (ch == '"') { - return postFix(RAW_STRING); - } else if (ch != ' ' && ch != '\\' && ch != ')' && fRawStringDelimiter.length() < 12) { - fRawStringDelimiter.append((char) ch); - } else { + break; + case ' ': + case '\\': + case ')': + case '\t': + case '\n': + case '\f': + case 11: // Vertical tab fState = STRING; + break; + default: + if (fRawStringDelimiter.length() < 12) { + fRawStringDelimiter.append((char) ch); + } else { + fState = STRING; + } } consume(); break; @@ -603,7 +606,6 @@ public final class FastCPartitionScanner implements IPartitionTokenScanner, ICPa case BACKSLASH_CR: case BACKSLASH_BACKSLASH: return 2; - } } @@ -624,7 +626,6 @@ public final class FastCPartitionScanner implements IPartitionTokenScanner, ICPa return fTokens[interceptTokenState(state)]; } - private final IToken preFix(int state, int newState, int last, int prefixLength) { fTokenLength -= getLastLength(fLast); fLast= last; @@ -634,33 +635,25 @@ public final class FastCPartitionScanner implements IPartitionTokenScanner, ICPa } private static int getState(String contentType) { - - if (contentType == null) + if (contentType == null) { return CCODE; - - else if (contentType.equals(C_SINGLE_LINE_COMMENT)) + } else if (contentType.equals(C_SINGLE_LINE_COMMENT)) { return SINGLE_LINE_COMMENT; - - else if (contentType.equals(C_MULTI_LINE_COMMENT)) + } else if (contentType.equals(C_MULTI_LINE_COMMENT)) { return MULTI_LINE_COMMENT; - - else if (contentType.equals(C_STRING)) + } else if (contentType.equals(C_STRING)) { return STRING; - - else if (contentType.equals(C_CHARACTER)) + } else if (contentType.equals(C_CHARACTER)) { return CHARACTER; - - else if (contentType.equals(C_PREPROCESSOR)) + } else if (contentType.equals(C_PREPROCESSOR)) { return PREPROCESSOR; - - else if (contentType.equals(C_SINGLE_LINE_DOC_COMMENT)) + } else if (contentType.equals(C_SINGLE_LINE_DOC_COMMENT)) { return SINGLE_LINE_COMMENT; // intentionally non-doc state: the state machine is doc-comment unaware - - else if (contentType.equals(C_MULTI_LINE_DOC_COMMENT)) + } else if (contentType.equals(C_MULTI_LINE_DOC_COMMENT)) { return MULTI_LINE_COMMENT; // intentionally non-doc state: the state machine is doc-comment unaware - - else + } else { return CCODE; + } } /* @@ -705,9 +698,6 @@ public final class FastCPartitionScanner implements IPartitionTokenScanner, ICPa } } - /* - * @see ITokenScanner#setRange(IDocument, int, int) - */ @Override public void setRange(IDocument document, int offset, int length) { fDocument= document; @@ -743,15 +733,15 @@ public final class FastCPartitionScanner implements IPartitionTokenScanner, ICPa } private int interceptTokenState(int proposedTokenState) { - if(fOwner!=null) { - switch(proposedTokenState) { + if (fOwner != null) { + switch (proposedTokenState) { case MULTI_LINE_COMMENT: - if(fOwner.getMultilineConfiguration().isDocumentationComment(fDocument, fTokenOffset, fTokenLength)) + if (fOwner.getMultilineConfiguration().isDocumentationComment(fDocument, fTokenOffset, fTokenLength)) return MULTI_LINE_DOC_COMMENT; break; case SINGLE_LINE_COMMENT: - if(fOwner.getSinglelineConfiguration().isDocumentationComment(fDocument, fTokenOffset, fTokenLength)) + if (fOwner.getSinglelineConfiguration().isDocumentationComment(fDocument, fTokenOffset, fTokenLength)) return SINGLE_LINE_DOC_COMMENT; break; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/FastCPartitioner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/FastCPartitioner.java index 6965b4f9c1b..0fdd032e765 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/FastCPartitioner.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/FastCPartitioner.java @@ -23,7 +23,6 @@ import org.eclipse.cdt.ui.text.doctools.IDocCommentOwner; * A slightly adapted FastPartitioner. */ public class FastCPartitioner extends FastPartitioner { - /** * Creates a new partitioner for the given content types. * @@ -72,7 +71,7 @@ public class FastCPartitioner extends FastPartitioner { * @since 5.0 */ public IDocCommentOwner getDocCommentOwner() { - if(fScanner instanceof FastCPartitionScanner) { + if (fScanner instanceof FastCPartitionScanner) { return ((FastCPartitionScanner)fScanner).getDocCommentOwner(); } return null; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CUILabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CUILabelProvider.java index 73ba44c79ae..432971e4673 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CUILabelProvider.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CUILabelProvider.java @@ -32,7 +32,6 @@ import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels; import org.eclipse.cdt.ui.CUIPlugin; public class CUILabelProvider extends LabelProvider implements IColorProvider, IStyledLabelProvider { - protected CElementImageProvider fImageLabelProvider; protected StorageLabelProvider fStorageLabelProvider; @@ -136,9 +135,6 @@ public class CUILabelProvider extends LabelProvider implements IColorProvider, I return image; } - /* (non-Javadoc) - * @see ILabelProvider#getImage - */ @Override public Image getImage(Object element) { Image result= fImageLabelProvider.getImageLabel(element, evaluateImageFlags(element)); @@ -159,10 +155,6 @@ public class CUILabelProvider extends LabelProvider implements IColorProvider, I return text; } - - /* (non-Javadoc) - * @see ILabelProvider#getText - */ @Override public String getText(Object element) { String result= CElementLabels.getTextLabel(element, evaluateTextFlags(element)); @@ -186,10 +178,6 @@ public class CUILabelProvider extends LabelProvider implements IColorProvider, I return string; } - - /* (non-Javadoc) - * @see IBaseLabelProvider#dispose - */ @Override public void dispose() { if (fLabelDecorators != null) { @@ -203,9 +191,6 @@ public class CUILabelProvider extends LabelProvider implements IColorProvider, I fImageLabelProvider.dispose(); } - /* (non-Javadoc) - * @see IBaseLabelProvider#addListener(ILabelProviderListener) - */ @Override public void addListener(ILabelProviderListener listener) { if (fLabelDecorators != null) { @@ -217,17 +202,11 @@ public class CUILabelProvider extends LabelProvider implements IColorProvider, I super.addListener(listener); } - /* (non-Javadoc) - * @see IBaseLabelProvider#isLabelProperty(Object, String) - */ @Override public boolean isLabelProperty(Object element, String property) { return true; } - /* (non-Javadoc) - * @see IBaseLabelProvider#removeListener(ILabelProviderListener) - */ @Override public void removeListener(ILabelProviderListener listener) { if (fLabelDecorators != null) { @@ -252,9 +231,6 @@ public class CUILabelProvider extends LabelProvider implements IColorProvider, I return null; } - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object) - */ @Override public Color getForeground(Object element) { if (element instanceof ISourceReference) { @@ -270,12 +246,8 @@ public class CUILabelProvider extends LabelProvider implements IColorProvider, I return fDefaultColor; } - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object) - */ @Override public Color getBackground(Object element) { return null; } - } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CustomBuildSettingsDecorator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CustomBuildSettingsDecorator.java new file mode 100644 index 00000000000..e526a42d9e5 --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CustomBuildSettingsDecorator.java @@ -0,0 +1,93 @@ +/******************************************************************************* + * 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.ui.viewsupport; + +import java.util.List; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IResource; +import org.eclipse.jface.viewers.IDecoration; +import org.eclipse.jface.viewers.ILabelProviderListener; +import org.eclipse.jface.viewers.ILightweightLabelDecorator; + +import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider; +import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvidersKeeper; +import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager; +import org.eclipse.cdt.core.language.settings.providers.ScannerDiscoveryLegacySupport; +import org.eclipse.cdt.core.model.CoreModel; +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.ICResourceDescription; + +import org.eclipse.cdt.internal.ui.CPluginImages; + +/** + * Determines if a file or folder got customized build settings and if so decorates with the "wrench" overlay. + */ +public class CustomBuildSettingsDecorator implements ILightweightLabelDecorator { + @Override + public void decorate(Object element, IDecoration decoration) { + if (element instanceof IFile || element instanceof IFolder) { + IResource rc = (IResource) element; + ICProjectDescription prjDescription = CoreModel.getDefault().getProjectDescription(rc.getProject(), false); + if (prjDescription != null) { + ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration(); + if (cfgDescription != null) { + if (isCustomizedResource(cfgDescription, rc)) + decoration.addOverlay(CPluginImages.DESC_OVR_SETTING); + } + } + } + } + + private static boolean isCustomizedResource(ICConfigurationDescription cfgDescription, IResource rc) { + if (!ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityEnabled(rc.getProject())) { + ICResourceDescription rcDescription = cfgDescription.getResourceDescription(rc.getProjectRelativePath(), true); + return rcDescription != null; + } + + if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) { + for (ILanguageSettingsProvider provider: ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders()) { + for (String languageId : LanguageSettingsManager.getLanguages(rc, cfgDescription)) { + List list = provider.getSettingEntries(cfgDescription, rc, languageId); + if (list != null) { + List listDefault = provider.getSettingEntries(cfgDescription, rc.getParent(), languageId); + // != is OK here due as the equal lists will have the same reference in WeakHashSet + if (list != listDefault) + return true; + } + } + } + } + return false; + } + + @Override + public void addListener(ILabelProviderListener listener) { + // We don't track state changes + } + + @Override + public void dispose() { + } + + @Override + public boolean isLabelProperty(Object element, String property) { + return false; + } + + @Override + public void removeListener(ILabelProviderListener listener) { + // We don't track state changes + } +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ProblemsLabelDecorator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ProblemsLabelDecorator.java index 21ec525f43c..d7d6f46f710 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ProblemsLabelDecorator.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ProblemsLabelDecorator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2010 IBM Corporation and others. + * Copyright (c) 2000, 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 @@ -7,13 +7,14 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.ui.viewsupport; -import java.util.List; +import java.util.HashMap; +import java.util.Map; import org.eclipse.core.resources.IMarker; -import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResourceStatus; import org.eclipse.core.runtime.CoreException; @@ -30,20 +31,10 @@ import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.ui.texteditor.MarkerUtilities; -import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider; -import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvidersKeeper; -import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager; -import org.eclipse.cdt.core.language.settings.providers.ScannerDiscoveryLegacySupport; -import org.eclipse.cdt.core.model.CModelException; -import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ISourceRange; import org.eclipse.cdt.core.model.ISourceReference; import org.eclipse.cdt.core.model.ITranslationUnit; -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.ICResourceDescription; import org.eclipse.cdt.ui.CElementImageDescriptor; import org.eclipse.cdt.ui.CUIPlugin; @@ -54,7 +45,7 @@ import org.eclipse.cdt.internal.ui.util.ImageDescriptorRegistry; /** * LabelDecorator that decorates an element's image with error and warning overlays that * represent the severity of markers attached to the element's underlying resource. To see - * a problem decoration for a marker, the marker needs to be a subtype of IMarker.PROBLEM. + * a problem decoration for a marker, the marker needs to be a subtype of {@code IMarker.PROBLEM}. *

    * Note: Only images for elements in Java projects are currently updated on marker changes. *

    @@ -62,23 +53,20 @@ import org.eclipse.cdt.internal.ui.util.ImageDescriptorRegistry; * @since 2.0 */ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabelDecorator { - /** - * This is a special LabelProviderChangedEvent carring additional - * information whether the event orgins from a maker change. + * This is a special {@code LabelProviderChangedEvent} carrying additional + * information whether the event originates from a maker change. *

    - * ProblemsLabelChangedEvents are only generated by - * ProblemsLabelDecorators. - *

    + * {@code ProblemsLabelChangedEvent}s are only generated by {@code ProblemsLabelDecorator}s. */ public static class ProblemsLabelChangedEvent extends LabelProviderChangedEvent { - private boolean fMarkerChange; /** * Note: This constructor is for internal use only. Clients should not call this constructor. */ - public ProblemsLabelChangedEvent(IBaseLabelProvider source, IResource[] changedResource, boolean isMarkerChange) { + public ProblemsLabelChangedEvent(IBaseLabelProvider source, IResource[] changedResource, + boolean isMarkerChange) { super(source, changedResource); fMarkerChange= isMarkerChange; } @@ -93,18 +81,45 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe public boolean isMarkerChange() { return fMarkerChange; } + } + private static class MarkersCacheKey { + private IResource res; + private int depth; + + public MarkersCacheKey(IResource res, int depth) { + this.res = res; + this.depth = depth; + } + + @Override + public int hashCode() { + return res.hashCode() + 31 * depth; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + MarkersCacheKey other = (MarkersCacheKey) obj; + return depth == other.depth && res.equals(other.res); + } } private static final int ERRORTICK_WARNING= CElementImageDescriptor.WARNING; private static final int ERRORTICK_ERROR= CElementImageDescriptor.ERROR; - private static final int TICK_CONFIGURATION = CElementImageDescriptor.SETTINGS; + private static final IMarker[] EMPTY_MARKER_ARRAY = {}; private ImageDescriptorRegistry fRegistry; - private boolean fUseNewRegistry= false; + private boolean fUseNewRegistry; private IProblemChangedListener fProblemChangedListener; private ListenerList fListeners; + private Map fMarkersCache = new HashMap(); /** * Creates a new ProblemsLabelDecorator. @@ -114,15 +129,13 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe fUseNewRegistry= true; } - /* + /** * Creates decorator with a shared image registry. + * Note: This constructor is for internal use only. Clients should not call this constructor. * * @param registry The registry to use or null to use the Java plugin's * image registry. */ - /** - * Note: This constructor is for internal use only. Clients should not call this constructor. - */ public ProblemsLabelDecorator(ImageDescriptorRegistry registry) { fRegistry= registry; fProblemChangedListener= null; @@ -135,18 +148,11 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe return fRegistry; } - - /* (non-Javadoc) - * @see ILabelDecorator#decorateText(String, Object) - */ @Override public String decorateText(String text, Object element) { return text; } - /* (non-Javadoc) - * @see ILabelDecorator#decorateImage(Image, Object) - */ @Override public Image decorateImage(Image image, Object obj) { int adornmentFlags= computeAdornmentFlags(obj); @@ -169,9 +175,9 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe switch (type) { case ICElement.C_PROJECT: case ICElement.C_CCONTAINER: - return getErrorTicksFromMarkers(element.getResource(), IResource.DEPTH_INFINITE, null) | getTicks(element.getResource()); + return getErrorTicksFromMarkers(element.getResource(), IResource.DEPTH_INFINITE, null); case ICElement.C_UNIT: - return getErrorTicksFromMarkers(element.getResource(), IResource.DEPTH_ONE, null) | getTicks(element.getResource()); + return getErrorTicksFromMarkers(element.getResource(), IResource.DEPTH_ONE, null); case ICElement.C_FUNCTION: case ICElement.C_CLASS: case ICElement.C_UNION: @@ -185,14 +191,9 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe break; } } else if (obj instanceof IResource) { - return getErrorTicksFromMarkers((IResource) obj, IResource.DEPTH_INFINITE, null) | getTicks((IResource)obj); + return getErrorTicksFromMarkers((IResource) obj, IResource.DEPTH_INFINITE, null); } } catch (CoreException e) { - if (e instanceof CModelException) { -// if (((CModelException) e).isDoesNotExist()) { -// return 0; -// } - } if (e.getStatus().getCode() == IResourceStatus.MARKER_NOT_FOUND) { return 0; } @@ -202,23 +203,29 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe return 0; } - private int getErrorTicksFromMarkers(IResource res, int depth, ISourceReference sourceElement) throws CoreException { + private int getErrorTicksFromMarkers(IResource res, int depth, ISourceReference sourceElement) + throws CoreException { if (res == null || !res.isAccessible()) { return 0; } int info= 0; - IMarker[] markers= res.findMarkers(IMarker.PROBLEM, true, depth); - if (markers != null) { - for (int i= 0; i < markers.length && (info != ERRORTICK_ERROR); i++) { - IMarker curr= markers[i]; - if (sourceElement == null || isMarkerInRange(curr, sourceElement)) { - int priority= curr.getAttribute(IMarker.SEVERITY, -1); - if (priority == IMarker.SEVERITY_WARNING) { - info= ERRORTICK_WARNING; - } else if (priority == IMarker.SEVERITY_ERROR) { - info= ERRORTICK_ERROR; - } + MarkersCacheKey cacheKey = new MarkersCacheKey(res, depth); + IMarker[] markers = fMarkersCache .get(cacheKey); + if (markers == null) { + markers= res.findMarkers(IMarker.PROBLEM, true, depth); + if (markers == null) + markers = EMPTY_MARKER_ARRAY; + fMarkersCache.put(cacheKey, markers); + } + for (int i= 0; i < markers.length && (info != ERRORTICK_ERROR); i++) { + IMarker curr= markers[i]; + if (sourceElement == null || isMarkerInRange(curr, sourceElement)) { + int priority= curr.getAttribute(IMarker.SEVERITY, -1); + if (priority == IMarker.SEVERITY_WARNING) { + info= ERRORTICK_WARNING; + } else if (priority == IMarker.SEVERITY_ERROR) { + info= ERRORTICK_ERROR; } } } @@ -240,42 +247,6 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe return false; } - -// private int getErrorTicksFromWorkingCopy(ITranslationUnit original, ISourceReference sourceElement) throws CoreException { -// int info= 0; -// FileEditorInput editorInput= new FileEditorInput((IFile) original.getResource()); -// IAnnotationModel model= CUIPlugin.getDefault().getTranslationUnitDocumentProvider().getAnnotationModel(editorInput); -// if (model != null) { -// Iterator iter= model.getAnnotationIterator(); -// while ((info != ERRORTICK_ERROR) && iter.hasNext()) { -// Annotation curr= (Annotation) iter.next(); -// IMarker marker= isAnnotationInRange(model, curr, sourceElement); -// if (marker != null) { -// int priority= marker.getAttribute(IMarker.SEVERITY, -1); -// if (priority == IMarker.SEVERITY_WARNING) { -// info= ERRORTICK_WARNING; -// } else if (priority == IMarker.SEVERITY_ERROR) { -// info= ERRORTICK_ERROR; -// } -// } -// } -// } -// return info; -// } - -// private IMarker isAnnotationInRange(IAnnotationModel model, Annotation annot, ISourceReference sourceElement) throws CoreException { -// if (annot instanceof MarkerAnnotation) { -// IMarker marker= ((MarkerAnnotation) annot).getMarker(); -// if (marker.exists() && marker.isSubtypeOf(IMarker.PROBLEM)) { -// Position pos= model.getPosition(annot); -// if (pos != null && (sourceElement == null || isInside(pos.getOffset(), -1, sourceElement))) { -// return marker; -// } -// } -// } -// return null; -// } - /** * Tests if a position is inside the source range of an element. Usually this is done * by looking at the offset. In case the offset equals -1, the line is @@ -291,7 +262,7 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe protected boolean isInside(int offSet, int line, ISourceReference sourceElement) throws CoreException { ISourceRange range= sourceElement.getSourceRange(); if (range != null) { - if (offSet ==-1) { + if (offSet == -1) { return (line >= range.getStartLine() && line <= range.getEndLine()); } int rangeOffset= range.getStartPos(); @@ -300,9 +271,6 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe return false; } - /* (non-Javadoc) - * @see IBaseLabelProvider#dispose() - */ @Override public void dispose() { if (fProblemChangedListener != null) { @@ -314,17 +282,11 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe } } - /* (non-Javadoc) - * @see IBaseLabelProvider#isLabelProperty(Object, String) - */ @Override public boolean isLabelProperty(Object element, String property) { return true; } - /* (non-Javadoc) - * @see IBaseLabelProvider#addListener(ILabelProviderListener) - */ @Override public void addListener(ILabelProviderListener listener) { if (fListeners == null) { @@ -342,9 +304,6 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe } } - /* (non-Javadoc) - * @see IBaseLabelProvider#removeListener(ILabelProviderListener) - */ @Override public void removeListener(ILabelProviderListener listener) { if (fListeners != null) { @@ -357,6 +316,7 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe } protected void fireProblemsChanged(IResource[] changedResources, boolean isMarkerChange) { + fMarkersCache.clear(); if (fListeners != null && !fListeners.isEmpty()) { LabelProviderChangedEvent event= new ProblemsLabelChangedEvent(this, changedResources, isMarkerChange); Object[] listeners= fListeners.getListeners(); @@ -366,68 +326,14 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe } } - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ILightweightLabelDecorator#decorate(java.lang.Object, org.eclipse.jface.viewers.IDecoration) - */ @Override public void decorate(Object element, IDecoration decoration) { int adornmentFlags= computeAdornmentFlags(element); - if ((adornmentFlags & TICK_CONFIGURATION) != 0) { - decoration.addOverlay(CPluginImages.DESC_OVR_SETTING); - adornmentFlags &= ~TICK_CONFIGURATION; - } - if (adornmentFlags == ERRORTICK_ERROR) { decoration.addOverlay(CPluginImages.DESC_OVR_ERROR); } else if (adornmentFlags == ERRORTICK_WARNING) { decoration.addOverlay(CPluginImages.DESC_OVR_WARNING); } } - - private static boolean isCustomizedResource(ICConfigurationDescription cfgDescription, IResource rc) { - if (rc instanceof IProject) - return false; - - if (!ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityEnabled(rc.getProject())) { - ICResourceDescription rcDescription = cfgDescription.getResourceDescription(rc.getProjectRelativePath(), true); - return rcDescription != null; - } - - if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) { - for (ILanguageSettingsProvider provider: ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders()) { - for (String languageId : LanguageSettingsManager.getLanguages(rc, cfgDescription)) { - List list = provider.getSettingEntries(cfgDescription, rc, languageId); - if (list != null) { - List listDefault = provider.getSettingEntries(cfgDescription, rc.getParent(), languageId); - // != is OK here due as the equal lists will have the same reference in WeakHashSet - if (list != listDefault) - return true; - } - } - } - } - return false; - } - - /** - * @param rc - resource to check - * @return flags {@link TICK_CONFIGURATION} if the resource has custom settings and possibly needs - * to be adorned or 0 otherwise. - */ - private int getTicks (IResource rc) { - if (rc == null || rc instanceof IProject) - return 0; - - int result = 0; - ICProjectDescription prjDescription = CoreModel.getDefault().getProjectDescription(rc.getProject(), false); - if (prjDescription != null) { - ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration(); - if (cfgDescription != null) { - if (isCustomizedResource(cfgDescription, rc)) - result |= TICK_CONFIGURATION; - } - } - return result; - } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.java index b2cd29b36cf..c4d0357ad3d 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2011 QNX Software Systems and others. + * Copyright (c) 2004, 2013 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 @@ -29,7 +29,6 @@ public final class NewClassWizardMessages extends NLS { public static String NewClassCreationWizardPage_namespace_label; public static String NewClassCreationWizardPage_namespace_button; public static String NewClassCreationWizardPage_error_EnterNamespace; - public static String NewClassCreationWizardPage_error_EnclosingNamespaceNotExists; public static String NewClassCreationWizardPage_error_NamespaceExistsDifferentCase; public static String NewClassCreationWizardPage_error_TypeMatchingNamespaceExists; public static String NewClassCreationWizardPage_error_TypeMatchingNamespaceExistsDifferentCase; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.properties index ff35ba93539..34b3bdbb72e 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.properties +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.properties @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2004, 2011 QNX Software Systems and others. +# Copyright (c) 2004, 2013 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 @@ -34,11 +34,10 @@ NewClassCreationWizardPage_namespace_label=&Namespace: NewClassCreationWizardPage_namespace_button=Bro&wse... NewClassCreationWizardPage_error_EnterNamespace=Namespace is empty. -NewClassCreationWizardPage_error_EnclosingNamespaceNotExists=Enclosing namespace does not exist. NewClassCreationWizardPage_error_NamespaceExistsDifferentCase=Namespace with the same name exists in a different scope. NewClassCreationWizardPage_error_TypeMatchingNamespaceExists=Another type with the same name as specified namespace exists. NewClassCreationWizardPage_error_TypeMatchingNamespaceExistsDifferentCase=Another type with the same name as specified namespace exists in a different scope. -NewClassCreationWizardPage_warning_NamespaceNotExists=Namespace does not exist. A new namespace will be created. +NewClassCreationWizardPage_warning_NamespaceNotExists=Namespace ''{0}'' does not exist. A new namespace will be created. NewClassCreationWizardPage_error_InvalidNamespace=Namespace is not valid. {0}. NewClassCreationWizardPage_warning_NamespaceDiscouraged=Namespace is discouraged. {0}. diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementImageDescriptor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementImageDescriptor.java index 2b94f32ab4c..41f624f79d7 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementImageDescriptor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementImageDescriptor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 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 @@ -20,6 +20,7 @@ import org.eclipse.swt.graphics.ImageData; import org.eclipse.swt.graphics.Point; import org.eclipse.cdt.internal.ui.CPluginImages; +import org.eclipse.cdt.internal.ui.viewsupport.CustomBuildSettingsDecorator; /** @@ -104,9 +105,13 @@ public class CElementImageDescriptor extends CompositeImageDescriptor { /** Flag to render the 'external file' adornment for translation units */ public static final int EXTERNAL_FILE = 0x40000; - /** Flag to render the 'custom settings' adornment - * @since 5.2 */ - public final static int SETTINGS= 0x80000; + /** Flag to render the 'custom settings' adornment. Do not use, this flag has been discontinued. + * @since 5.2 + * @deprecated The constant has been discontinued since CDT 8.1. The adornment moved to separate class + * {@link CustomBuildSettingsDecorator}. + */ + @Deprecated + public final static int SETTINGS= 0x80000; private ImageDescriptor fBaseImage; private int fFlags; @@ -243,11 +248,6 @@ public class CElementImageDescriptor extends CompositeImageDescriptor { x -= data.width; drawImage(data, x, 0); } - if ((fFlags & SETTINGS) != 0) { - data = CPluginImages.DESC_OVR_SETTING.getImageData(); - x -= data.width; - drawImage(data, x, 0); - } } private void drawBottomRight() { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.java index 4ce3ebc734d..58b995452c2 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2011 QNX Software Systems and others. + * Copyright (c) 2004, 2013 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 @@ -1591,17 +1591,8 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { ICProject project = getCurrentProject(); if (project != null) { - /* search for parent name space first */ - int searchResult; - if (typeName.isQualified()) { - searchResult = NewClassWizardUtil.searchForCppType(typeName.getEnclosingTypeName(),project, ICPPNamespace.class); - if (searchResult != NewClassWizardUtil.SEARCH_MATCH_FOUND_EXACT) { - status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_EnclosingNamespaceNotExists); - return status; - } - } - searchResult = NewClassWizardUtil.searchForCppType(typeName, project, ICPPNamespace.class); - switch(searchResult) { + int searchResult = NewClassWizardUtil.searchForCppType(typeName, project, ICPPNamespace.class); + switch (searchResult) { case NewClassWizardUtil.SEARCH_MATCH_FOUND_EXACT: status.setOK(); return status; @@ -1615,7 +1606,17 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { status.setWarning(NewClassWizardMessages.NewClassCreationWizardPage_error_TypeMatchingNamespaceExistsDifferentCase); return status; case NewClassWizardUtil.SEARCH_MATCH_NOTFOUND: - status.setWarning(NewClassWizardMessages.NewClassCreationWizardPage_warning_NamespaceNotExists); + // Find the highest ancestor namespace that does not exist. + IQualifiedTypeName ns = typeName; + while (ns.isQualified()) { + IQualifiedTypeName ns1 = ns.getEnclosingTypeName(); + if (NewClassWizardUtil.searchForCppType(ns1, project, ICPPNamespace.class) == NewClassWizardUtil.SEARCH_MATCH_FOUND_EXACT) { + break; + } + ns = ns1; + } + status.setWarning(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_warning_NamespaceNotExists, + ns.getFullyQualifiedName())); break; } } @@ -1638,7 +1639,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { StatusInfo status = new StatusInfo(); String className = getClassName(); - // must not be empty + // Must not be empty. if (className == null || className.length() == 0) { status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_EnterClassName); return status; @@ -1669,7 +1670,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { } } int searchResult = NewClassWizardUtil.searchForCppType(fullyQualifiedName, project, ICPPClassType.class); - switch(searchResult) { + switch (searchResult) { case NewClassWizardUtil.SEARCH_MATCH_FOUND_EXACT: status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_ClassNameExists); return status; @@ -1729,7 +1730,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { MultiStatus status = new MultiStatus(CUIPlugin.getPluginId(), IStatus.OK, "", null); //$NON-NLS-1$ IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(project.getProject()); if (provider != null) { - //TODO get the scanner info for the actual source folder + // TODO Get the scanner info for the actual source folder. IScannerInfo info = provider.getScannerInformation(project.getProject()); if (info != null) { String[] includePaths = info.getIncludePaths(); diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IDebugNewExecutableHandler.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IDebugNewExecutableHandler.java new file mode 100644 index 00000000000..ecde45f0427 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IDebugNewExecutableHandler.java @@ -0,0 +1,22 @@ +/******************************************************************************* + * Copyright (c) 2012 Mentor Graphics 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: + * Mentor Graphics - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.cdt.debug.core.model; + +import org.eclipse.debug.core.commands.IDebugCommandHandler; + +/** + * Command handler for the "Debug New Executable" command. + * + * @since 7.3 + */ +public interface IDebugNewExecutableHandler extends IDebugCommandHandler { +} diff --git a/debug/org.eclipse.cdt.debug.ui/icons/obj16/new_exec.gif b/debug/org.eclipse.cdt.debug.ui/icons/obj16/new_exec.gif new file mode 100755 index 00000000000..78ca91c6dab Binary files /dev/null and b/debug/org.eclipse.cdt.debug.ui/icons/obj16/new_exec.gif differ diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.properties b/debug/org.eclipse.cdt.debug.ui/plugin.properties index 34cbb7d2d35..2266d66e86e 100644 --- a/debug/org.eclipse.cdt.debug.ui/plugin.properties +++ b/debug/org.eclipse.cdt.debug.ui/plugin.properties @@ -242,3 +242,9 @@ OpenNewView.name = Open New View # Disassembly Ruler Column extension point extPoint.disassemblyRulerColumn=Disassembly Ruler Column + +# Debug New Executable Command +DebugNewExecutable.name=Debug New Executable +DebugNewExecutable.description=Debug a new executable +DebugNewExecutable.label=Debug New Executable... +DebugNewExecutable.tooltip=Debug a new executable diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.xml b/debug/org.eclipse.cdt.debug.ui/plugin.xml index fa6769bbf67..d2b3fc1b6f1 100644 --- a/debug/org.eclipse.cdt.debug.ui/plugin.xml +++ b/debug/org.eclipse.cdt.debug.ui/plugin.xml @@ -128,17 +128,17 @@ @@ -2012,7 +2012,12 @@ id="org.eclipse.cdt.debug.ui.command.connect" name="%Connect.name"> - + + @@ -2079,6 +2084,10 @@ class="org.eclipse.cdt.debug.internal.ui.commands.ConnectCommandHandler" commandId="org.eclipse.cdt.debug.ui.command.connect"> + + @@ -2520,6 +2529,28 @@ + + + + + getCommandType() { + return IDebugNewExecutableHandler.class; + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/InvalidLaunchableAdapterFactory.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/InvalidLaunchableAdapterFactory.java new file mode 100644 index 00000000000..10ff510a19f --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/InvalidLaunchableAdapterFactory.java @@ -0,0 +1,88 @@ +/******************************************************************************* + * Copyright (c) 2013 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: + * Wind River Systems - initial implementation + *******************************************************************************/ +package org.eclipse.cdt.debug.internal.ui.launch; + +import java.util.ArrayList; + +import org.eclipse.cdt.debug.ui.CDebugUIPlugin; +import org.eclipse.core.runtime.IAdapterFactory; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.debug.ui.actions.ILaunchable; + +/** + * This is an invalid Adapter factory which insures that there are no false + * usages of this class when defining ILaunchable contexts. Please reference + * the ILaunchable interface and Bugzilla : 396822. + */ +public class InvalidLaunchableAdapterFactory implements IAdapterFactory { + + private static final Class[] TYPES = { ILaunchable.class }; + + private static ArrayList currentTraces = new ArrayList(); + + /* + * (non-Javadoc) + * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class) + */ + @Override + @SuppressWarnings("rawtypes") + public Object getAdapter(Object adaptableObject, Class adapterType) { + /* + * Calculate the trace to see if we already have seen this one. We only + * want to report new instances of the violation. + */ + String trace = getStackTrace(); + + if ( ! currentTraces.contains( trace ) ) { + /* + * Note we have seen this one for the first time. + */ + currentTraces.add( trace ); + + /* + * Generate a message for this in the log file. + */ + String msg = LaunchMessages.getString("Launch.ILaunchable.Interface.Error"); //$NON-NLS-1$ + + CDebugUIPlugin.log( new Status( IStatus.INFO, CDebugUIPlugin.PLUGIN_ID, 0, msg, new Throwable( "" ) ) ); //$NON-NLS-1$ + } + + /* + * We do not actually provide an adapter factory for this. + */ + return null; + } + + /* + * Constructs the stack trace for comparison to see if we have seen this exact trace before. + * We only report each unique instance once. + */ + private String getStackTrace() { + String trace = ""; //$NON-NLS-1$ + for (StackTraceElement elem : new Throwable().getStackTrace()) { + trace += elem.getClassName() + elem.getMethodName() + elem.getFileName() + elem.getLineNumber(); + } + return trace; + } + + /* + * Indicates that we are adapting ILaunchable. + * + * (non-Javadoc) + * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList() + */ + @Override + @SuppressWarnings("rawtypes") + public Class[] getAdapterList() { + return TYPES; + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/LaunchMessages.properties b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/LaunchMessages.properties index 65d1b918bef..d83a53bd822 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/LaunchMessages.properties +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/LaunchMessages.properties @@ -32,3 +32,6 @@ CApplicationLaunchShortcut.Launch_failed_no_project_selected=Launch failed no pr Launch.common.BinariesColon=Binaries: Launch.common.QualifierColon=Qualifier: + +Launch.ILaunchable.Interface.Error=An attempt to instantiate an adapter factory for ILaunchable. By API specification this is not allowed. Use hasAdapter() to determine existense. + diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbAdapterFactory.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbAdapterFactory.java index a35c0913306..51d5f2ea88b 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbAdapterFactory.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbAdapterFactory.java @@ -19,6 +19,7 @@ import java.util.WeakHashMap; import org.eclipse.cdt.debug.core.model.ICBreakpoint; import org.eclipse.cdt.debug.core.model.IConnectHandler; +import org.eclipse.cdt.debug.core.model.IDebugNewExecutableHandler; import org.eclipse.cdt.debug.core.model.IResumeWithoutSignalHandler; import org.eclipse.cdt.debug.core.model.IReverseResumeHandler; import org.eclipse.cdt.debug.core.model.IReverseStepIntoHandler; @@ -49,6 +50,7 @@ import org.eclipse.cdt.dsf.gdb.internal.ui.actions.GdbDisconnectCommand; import org.eclipse.cdt.dsf.gdb.internal.ui.actions.GdbRestartCommand; import org.eclipse.cdt.dsf.gdb.internal.ui.actions.GdbSteppingModeTarget; import org.eclipse.cdt.dsf.gdb.internal.ui.commands.GdbConnectCommand; +import org.eclipse.cdt.dsf.gdb.internal.ui.commands.GdbDebugNewExecutableCommand; import org.eclipse.cdt.dsf.gdb.internal.ui.commands.GdbResumeWithoutSignalCommand; import org.eclipse.cdt.dsf.gdb.internal.ui.commands.GdbReverseResumeCommand; import org.eclipse.cdt.dsf.gdb.internal.ui.commands.GdbReverseStepIntoCommand; @@ -114,6 +116,7 @@ public class GdbAdapterFactory final GdbResumeWithoutSignalCommand fResumeWithoutSignalCommand; final GdbRestartCommand fRestartCommand; final DsfTerminateCommand fTerminateCommand; + final GdbDebugNewExecutableCommand fDebugNewExecutableCommand; final GdbConnectCommand fConnectCommand; final GdbDisconnectCommand fDisconnectCommand; final IDebugModelProvider fDebugModelProvider; @@ -162,7 +165,8 @@ public class GdbAdapterFactory fResumeWithoutSignalCommand = new GdbResumeWithoutSignalCommand(session); fRestartCommand = new GdbRestartCommand(session, fLaunch); fTerminateCommand = new DsfTerminateCommand(session); - fConnectCommand = new GdbConnectCommand(session); + fDebugNewExecutableCommand = new GdbDebugNewExecutableCommand(session, fLaunch); + fConnectCommand = new GdbConnectCommand(session, fLaunch); fDisconnectCommand = new GdbDisconnectCommand(session); fSuspendTrigger = new GdbSuspendTrigger(session, fLaunch); fModelSelectionPolicyFactory = new DefaultDsfModelSelectionPolicyFactory(); @@ -189,6 +193,7 @@ public class GdbAdapterFactory session.registerModelAdapter(IRestartHandler.class, fRestartCommand); session.registerModelAdapter(ITerminateHandler.class, fTerminateCommand); session.registerModelAdapter(IConnectHandler.class, fConnectCommand); + session.registerModelAdapter(IDebugNewExecutableHandler.class, fDebugNewExecutableCommand); session.registerModelAdapter(IDisconnectHandler.class, fDisconnectCommand); session.registerModelAdapter(IModelSelectionPolicyFactory.class, fModelSelectionPolicyFactory); session.registerModelAdapter(IRefreshAllTarget.class, fRefreshAllTarget); @@ -249,6 +254,7 @@ public class GdbAdapterFactory session.unregisterModelAdapter(IRestartHandler.class); session.unregisterModelAdapter(ITerminateHandler.class); session.unregisterModelAdapter(IConnectHandler.class); + session.unregisterModelAdapter(IDebugNewExecutableHandler.class); session.unregisterModelAdapter(IDisconnectHandler.class); session.unregisterModelAdapter(IModelSelectionPolicyFactory.class); session.unregisterModelAdapter(IRefreshAllTarget.class); @@ -279,6 +285,7 @@ public class GdbAdapterFactory fRestartCommand.dispose(); fTerminateCommand.dispose(); fConnectCommand.dispose(); + fDebugNewExecutableCommand.dispose(); fDisconnectCommand.dispose(); fSuspendTrigger.dispose(); fReverseToggleTarget.dispose(); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbConnectCommand.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbConnectCommand.java index d797a6e48ae..5a50b774632 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbConnectCommand.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbConnectCommand.java @@ -20,6 +20,7 @@ import java.util.concurrent.CancellationException; import java.util.concurrent.ExecutionException; import java.util.concurrent.RejectedExecutionException; +import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; import org.eclipse.cdt.debug.core.model.IConnectHandler; import org.eclipse.cdt.dsf.concurrent.CountingRequestMonitor; import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; @@ -35,9 +36,11 @@ import org.eclipse.cdt.dsf.debug.service.IProcesses.IProcessDMContext; import org.eclipse.cdt.dsf.debug.service.IProcesses.IThreadDMData; import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService; import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext; +import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants; import org.eclipse.cdt.dsf.gdb.actions.IConnect; import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin; import org.eclipse.cdt.dsf.gdb.internal.ui.actions.ProcessInfo; +import org.eclipse.cdt.dsf.gdb.internal.ui.launching.NewExecutableInfo; import org.eclipse.cdt.dsf.gdb.internal.ui.launching.LaunchUIMessages; import org.eclipse.cdt.dsf.gdb.internal.ui.launching.ProcessPrompter; import org.eclipse.cdt.dsf.gdb.internal.ui.launching.ProcessPrompter.PrompterInfo; @@ -68,7 +71,8 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.progress.UIJob; public class GdbConnectCommand extends AbstractDebugCommand implements IConnectHandler, IConnect { - + + private final GdbLaunch fLaunch; private final DsfExecutor fExecutor; private final DsfServicesTracker fTracker; @@ -82,7 +86,8 @@ public class GdbConnectCommand extends AbstractDebugCommand implements IConnectH // the binary location for a local attach session. private Map fProcessNameToBinaryMap = new HashMap(); - public GdbConnectCommand(DsfSession session) { + public GdbConnectCommand(DsfSession session, GdbLaunch launch) { + fLaunch = launch; fExecutor = session.getExecutor(); fTracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), session.getId()); } @@ -143,10 +148,12 @@ public class GdbConnectCommand extends AbstractDebugCommand implements IConnectH IProcessExtendedInfo[] fProcessList = null; DataRequestMonitor fRequestMonitor; boolean fNewProcessSupported; + boolean fRemote; - public PromptForPidJob(String name, boolean newProcessSupported, IProcessExtendedInfo[] procs, DataRequestMonitor rm) { + public PromptForPidJob(String name, boolean newProcessSupported, boolean remote, IProcessExtendedInfo[] procs, DataRequestMonitor rm) { super(name); fNewProcessSupported = newProcessSupported; + fRemote = remote; fProcessList = procs; fRequestMonitor = rm; } @@ -158,11 +165,11 @@ public class GdbConnectCommand extends AbstractDebugCommand implements IConnectH null); try { - PrompterInfo info = new PrompterInfo(fNewProcessSupported, fProcessList); + PrompterInfo info = new PrompterInfo(fNewProcessSupported, fRemote, fProcessList); Object result = new ProcessPrompter().handleStatus(null, info); if (result == null) { fRequestMonitor.cancel(); - } else if (result instanceof IProcessExtendedInfo[] || result instanceof String) { + } else if (result instanceof IProcessExtendedInfo[] || result instanceof NewExecutableInfo) { fRequestMonitor.setData(result); } else if (result instanceof Integer) { // This is the case where the user typed in a pid number directly @@ -288,9 +295,11 @@ public class GdbConnectCommand extends AbstractDebugCommand implements IConnectH public void run() { final IProcesses procService = fTracker.getService(IProcesses.class); ICommandControlService commandControl = fTracker.getService(ICommandControlService.class); + IGDBBackend backend = fTracker.getService(IGDBBackend.class); - if (procService != null && commandControl != null) { + if (procService != null && commandControl != null && backend != null) { final ICommandControlDMContext controlCtx = commandControl.getContext(); + final boolean remote = backend.getSessionType() == SessionType.REMOTE; // First check if the "New..." button should be enabled. procService.isDebugNewProcessSupported(controlCtx, new DataRequestMonitor(fExecutor, rm) { @@ -314,7 +323,8 @@ public class GdbConnectCommand extends AbstractDebugCommand implements IConnectH // Prompt the user to choose one or more processes, or to start a new one new PromptForPidJob( LaunchUIMessages.getString("ProcessPrompter.PromptJob"), //$NON-NLS-1$ - newProcessSupported, + newProcessSupported, + remote, procInfoList.toArray(new IProcessExtendedInfo[procInfoList.size()]), new DataRequestMonitor(fExecutor, rm) { @Override @@ -325,9 +335,9 @@ public class GdbConnectCommand extends AbstractDebugCommand implements IConnectH @Override protected void handleSuccess() { Object data = getData(); - if (data instanceof String) { + if (data instanceof NewExecutableInfo) { // User wants to start a new process - startNewProcess(controlCtx, (String)data, rm); + startNewProcess(controlCtx, (NewExecutableInfo)data, rm); } else if (data instanceof IProcessExtendedInfo[]) { attachToProcesses(controlCtx, (IProcessExtendedInfo[])data, rm); } else { @@ -412,11 +422,23 @@ public class GdbConnectCommand extends AbstractDebugCommand implements IConnectH }); } - private void startNewProcess(ICommandControlDMContext controlDmc, String binaryPath, RequestMonitor rm) { + private void startNewProcess(ICommandControlDMContext controlDmc, NewExecutableInfo info, RequestMonitor rm) { IGDBProcesses procService = fTracker.getService(IGDBProcesses.class); - procService.debugNewProcess( - controlDmc, binaryPath, - new HashMap(), new DataRequestMonitor(fExecutor, rm)); + try { + @SuppressWarnings("unchecked") + Map attributes = fLaunch.getLaunchConfiguration().getAttributes(); + attributes.put(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_REMOTE_BINARY, info.getTargetPath()); + attributes.put(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, info.getArguments()); + procService.debugNewProcess( + controlDmc, + info.getHostPath(), + attributes, + new DataRequestMonitor(fExecutor, rm)); + } + catch(CoreException e) { + rm.setStatus(e.getStatus()); + rm.done(); + } } private void attachToProcesses(final ICommandControlDMContext controlDmc, IProcessExtendedInfo[] processes, final RequestMonitor rm) { diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbDebugNewExecutableCommand.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbDebugNewExecutableCommand.java new file mode 100644 index 00000000000..4631445ea5c --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbDebugNewExecutableCommand.java @@ -0,0 +1,213 @@ +/******************************************************************************* + * Copyright (c) 2012 Mentor Graphics 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: + * Mentor Graphics - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.cdt.dsf.gdb.internal.ui.commands; + +import java.util.Map; +import java.util.concurrent.CancellationException; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.RejectedExecutionException; + +import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; +import org.eclipse.cdt.debug.core.model.IDebugNewExecutableHandler; +import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; +import org.eclipse.cdt.dsf.concurrent.DsfExecutor; +import org.eclipse.cdt.dsf.concurrent.DsfRunnable; +import org.eclipse.cdt.dsf.concurrent.ImmediateDataRequestMonitor; +import org.eclipse.cdt.dsf.concurrent.Query; +import org.eclipse.cdt.dsf.concurrent.RequestMonitor; +import org.eclipse.cdt.dsf.datamodel.IDMContext; +import org.eclipse.cdt.dsf.debug.service.IProcesses; +import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService; +import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants; +import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin; +import org.eclipse.cdt.dsf.gdb.internal.ui.launching.NewExecutableInfo; +import org.eclipse.cdt.dsf.gdb.internal.ui.launching.NewExecutableDialog; +import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch; +import org.eclipse.cdt.dsf.gdb.service.IGDBBackend; +import org.eclipse.cdt.dsf.gdb.service.SessionType; +import org.eclipse.cdt.dsf.service.DsfServicesTracker; +import org.eclipse.cdt.dsf.service.DsfSession; +import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.IDMVMContext; +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.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.IRequest; +import org.eclipse.debug.core.commands.AbstractDebugCommand; +import org.eclipse.debug.core.commands.IEnabledStateRequest; +import org.eclipse.jface.window.Window; +import org.eclipse.ui.progress.UIJob; + +public class GdbDebugNewExecutableCommand extends AbstractDebugCommand implements IDebugNewExecutableHandler { + + private class PromptJob extends UIJob { + + private DataRequestMonitor fRequestMonitor; + private boolean fRemote = false; + + private PromptJob( boolean remote, DataRequestMonitor rm ) { + super( Messages.GdbDebugNewExecutableCommand_New_Executable_Prompt_Job ); + fRemote = remote; + fRequestMonitor = rm; + } + + @Override + public IStatus runInUIThread( IProgressMonitor monitor ) { + int flags = ( fRemote ) ? NewExecutableDialog.REMOTE : 0; + NewExecutableDialog dialog = new NewExecutableDialog( GdbUIPlugin.getShell(), flags ); + final boolean canceled = dialog.open() == Window.CANCEL; + final NewExecutableInfo info = dialog.getExecutableInfo(); + fExecutor.execute( new DsfRunnable() { + + @Override + public void run() { + if ( canceled ) + fRequestMonitor.cancel(); + else + fRequestMonitor.setData( info ); + fRequestMonitor.done(); + } + } ); + return Status.OK_STATUS; + } + } + + private final GdbLaunch fLaunch; + private final DsfExecutor fExecutor; + private final DsfServicesTracker fTracker; + + public GdbDebugNewExecutableCommand( DsfSession session, GdbLaunch launch ) { + super(); + fLaunch = launch; + fExecutor = session.getExecutor(); + fTracker = new DsfServicesTracker( GdbUIPlugin.getBundleContext(), session.getId() ); + } + + public boolean canDebugNewExecutable() { + + Query canDebugQuery = new Query() { + @Override + public void execute( DataRequestMonitor rm ) { + IProcesses procService = fTracker.getService( IProcesses.class ); + ICommandControlService commandControl = fTracker.getService( ICommandControlService.class ); + + if ( procService == null || commandControl == null ) { + rm.setData( false ); + rm.done(); + return; + } + procService.isDebugNewProcessSupported( commandControl.getContext(), rm ); + } + }; + try { + fExecutor.execute( canDebugQuery ); + return canDebugQuery.get(); + } + catch( InterruptedException e ) { + } + catch( ExecutionException e ) { + } + catch( RejectedExecutionException e ) { + // Can be thrown if the session is shutdown + } + return false; + } + + public void debugNewExecutable( final RequestMonitor rm ) { + IGDBBackend backend = fTracker.getService( IGDBBackend.class ); + final IProcesses procService = fTracker.getService( IProcesses.class ); + final ICommandControlService commandControl = fTracker.getService( ICommandControlService.class ); + if ( backend == null || procService == null || commandControl == null ) { + rm.setStatus( new Status( IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, "Service is not available" ) ); //$NON-NLS-1$ + rm.done(); + return; + } + + PromptJob job = new PromptJob( + backend.getSessionType() == SessionType.REMOTE, + new DataRequestMonitor( fExecutor, rm ){ + + @Override + protected void handleCancel() { + rm.cancel(); + rm.done(); + }; + + @Override + protected void handleSuccess() { + try { + @SuppressWarnings( "unchecked" ) + Map attributes = getLaunchConfiguration().getAttributes(); + attributes.put( IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_REMOTE_BINARY, getData().getTargetPath() ); + attributes.put( ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, getData().getArguments() ); + procService.debugNewProcess( + commandControl.getContext(), + getData().getHostPath(), + attributes, + new ImmediateDataRequestMonitor( rm ) ); + } + catch( CoreException e ) { + rm.setStatus( e.getStatus() ); + rm.done(); + } + }; + } ); + job.schedule(); + } + + @Override + protected void doExecute( Object[] targets, IProgressMonitor monitor, IRequest request ) throws CoreException { + Query query = new Query() { + + @Override + protected void execute( DataRequestMonitor rm ) { + debugNewExecutable( rm ); + } + }; + try { + fExecutor.execute( query ); + query.get(); + } + catch( InterruptedException e ) { + } + catch( ExecutionException e ) { + } + catch( CancellationException e ) { + // Nothing to do, just ignore the command since the user + // cancelled it. + } + catch( RejectedExecutionException e ) { + // Can be thrown if the session is shutdown + } + } + + @Override + protected boolean isExecutable( Object[] targets, IProgressMonitor monitor, IEnabledStateRequest request ) throws CoreException { + return canDebugNewExecutable(); + } + + @Override + protected Object getTarget( Object element ) { + if ( element instanceof GdbLaunch || element instanceof IDMVMContext ) + return element; + return null; + } + + public void dispose() { + fTracker.dispose(); + } + + private ILaunchConfiguration getLaunchConfiguration() { + return fLaunch.getLaunchConfiguration(); + } +} diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/Messages.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/Messages.java new file mode 100644 index 00000000000..a8d5629cd7f --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/Messages.java @@ -0,0 +1,58 @@ +/******************************************************************************* + * Copyright (c) 2012 Mentor Graphics 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: + * Mentor Graphics - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.cdt.dsf.gdb.internal.ui.commands; + +import org.eclipse.osgi.util.NLS; + +public class Messages extends NLS { + + public static String GdbDebugNewExecutableCommand_Arguments; + + public static String GdbDebugNewExecutableCommand_Binary; + + public static String GdbDebugNewExecutableCommand_Binary_file_does_not_exist; + + public static String GdbDebugNewExecutableCommand_Binary_must_be_specified; + + public static String GdbDebugNewExecutableCommand_Binary_on_host; + + public static String GdbDebugNewExecutableCommand_Binary_on_target; + + public static String GdbDebugNewExecutableCommand_Binary_on_target_must_be_specified; + + public static String GdbDebugNewExecutableCommand_Browse; + + public static String GdbDebugNewExecutableCommand_Debug_New_Executable; + + public static String GdbDebugNewExecutableCommand_Host_binary_file_does_not_exist; + + public static String GdbDebugNewExecutableCommand_Host_binary_must_be_specified; + + public static String GdbDebugNewExecutableCommand_Invalid_binary; + + public static String GdbDebugNewExecutableCommand_Invalid_host_binary; + + public static String GdbDebugNewExecutableCommand_New_Executable_Prompt_Job; + + public static String GdbDebugNewExecutableCommand_Select_binaries_on_host_and_target; + + public static String GdbDebugNewExecutableCommand_Select_Binary; + + public static String GdbDebugNewExecutableCommand_Select_binary_and_specify_arguments; + static { + // initialize resource bundle + NLS.initializeMessages( Messages.class.getName(), Messages.class ); + } + + private Messages() { + } +} diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/Messages.properties b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/Messages.properties new file mode 100644 index 00000000000..d601bc6d839 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/Messages.properties @@ -0,0 +1,28 @@ +############################################################################### +# Copyright (c) 2012 Mentor Graphics 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: +# Mentor Graphics - Initial API and implementation +############################################################################### + +GdbDebugNewExecutableCommand_Arguments=Arguments: +GdbDebugNewExecutableCommand_Binary=Binary: +GdbDebugNewExecutableCommand_Binary_file_does_not_exist=Binary file does not exist +GdbDebugNewExecutableCommand_Binary_must_be_specified=Binary must be specified +GdbDebugNewExecutableCommand_Binary_on_host=Binary on host: +GdbDebugNewExecutableCommand_Binary_on_target=Binary on target: +GdbDebugNewExecutableCommand_Binary_on_target_must_be_specified=Binary on target must be specified +GdbDebugNewExecutableCommand_Browse=Browse... +GdbDebugNewExecutableCommand_Debug_New_Executable=Debug New Executable +GdbDebugNewExecutableCommand_Host_binary_file_does_not_exist=Host binary file does not exist +GdbDebugNewExecutableCommand_Host_binary_must_be_specified=Host binary must be specified +GdbDebugNewExecutableCommand_Invalid_binary=Invalid binary +GdbDebugNewExecutableCommand_Invalid_host_binary=Invalid host binary +GdbDebugNewExecutableCommand_New_Executable_Prompt_Job=New Executable Prompt Job +GdbDebugNewExecutableCommand_Select_binaries_on_host_and_target=Select binaries on the host and the target and specify the arguments +GdbDebugNewExecutableCommand_Select_Binary=Select Binary +GdbDebugNewExecutableCommand_Select_binary_and_specify_arguments=Select a binary and specify the arguments diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/NewExecutableDialog.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/NewExecutableDialog.java new file mode 100644 index 00000000000..7c65e7be5eb --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/NewExecutableDialog.java @@ -0,0 +1,169 @@ +/******************************************************************************* + * Copyright (c) 2013 Mentor Graphics 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: + * Mentor Graphics - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.cdt.dsf.gdb.internal.ui.launching; + +import java.io.File; + +import org.eclipse.cdt.dsf.gdb.internal.ui.commands.Messages; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.dialogs.TitleAreaDialog; +import org.eclipse.jface.resource.JFaceResources; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; + +public class NewExecutableDialog extends TitleAreaDialog { + + public static final int REMOTE = 0x1; + + private int fFlags = 0; + private NewExecutableInfo fInfo = null; + + private Text fHostBinaryText; + private Text fTargetBinaryText; + private Text fArgumentsText; + + public NewExecutableDialog( Shell parentShell, int flags ) { + super( parentShell ); + setShellStyle( getShellStyle() | SWT.RESIZE ); + fFlags = flags; + } + + @Override + protected Control createContents( Composite parent ) { + Control control = super.createContents( parent ); + validate(); + return control; + } + + @Override + protected Control createDialogArea( Composite parent ) { + boolean remote = (fFlags & REMOTE) > 0; + + getShell().setText( Messages.GdbDebugNewExecutableCommand_Debug_New_Executable ); + setTitle( Messages.GdbDebugNewExecutableCommand_Select_Binary ); + String message = ( remote ) ? + Messages.GdbDebugNewExecutableCommand_Select_binaries_on_host_and_target : + Messages.GdbDebugNewExecutableCommand_Select_binary_and_specify_arguments; + setMessage( message ); + + Composite control = (Composite)super.createDialogArea( parent ); + Composite comp = new Composite( control, SWT.NONE ); + GridData gd = new GridData( SWT.FILL, SWT.FILL, true, true ); + GridLayout layout = new GridLayout( 3, false ); + comp.setLayout( layout ); + comp.setLayoutData( gd ); + + new Label( comp, SWT.None ).setText( remote ? Messages.GdbDebugNewExecutableCommand_Binary_on_host : Messages.GdbDebugNewExecutableCommand_Binary ); + fHostBinaryText = new Text( comp, SWT.BORDER ); + fHostBinaryText.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false ) ); + fHostBinaryText.addModifyListener( new ModifyListener() { + + @Override + public void modifyText( ModifyEvent e ) { + validate(); + } + } ); + Button browseButton = new Button( comp, SWT.PUSH ); + browseButton.setText( Messages.GdbDebugNewExecutableCommand_Browse ); + browseButton.setFont( JFaceResources.getDialogFont() ); + setButtonLayoutData( browseButton ); + browseButton.addSelectionListener( new SelectionAdapter() { + + @Override + public void widgetSelected( SelectionEvent e ) { + FileDialog dialog = new FileDialog( getShell() ); + dialog.setFileName( fHostBinaryText.getText() ); + String result = dialog.open(); + if ( result != null ) { + fHostBinaryText.setText( result ); + } + } + } ); + + if ( remote ) { + new Label( comp, SWT.None ).setText( Messages.GdbDebugNewExecutableCommand_Binary_on_target ); + fTargetBinaryText = new Text( comp, SWT.BORDER ); + fTargetBinaryText.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false, 2, 1 ) ); + fTargetBinaryText.addModifyListener( new ModifyListener() { + + @Override + public void modifyText( ModifyEvent e ) { + validate(); + } + } ); + } + + new Label( comp, SWT.None ).setText( Messages.GdbDebugNewExecutableCommand_Arguments ); + fArgumentsText = new Text( comp, SWT.BORDER ); + fArgumentsText.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false, 2, 1 ) ); + + return control; + } + + @Override + protected void okPressed() { + String targetPath = ( fTargetBinaryText != null ) ? fTargetBinaryText.getText().trim() : null; + String args = fArgumentsText.getText().trim(); + fInfo = new NewExecutableInfo( fHostBinaryText.getText().trim(), targetPath, args ); + super.okPressed(); + } + + public NewExecutableInfo getExecutableInfo() { + return fInfo; + } + + private void validate() { + boolean remote = (fFlags & REMOTE) > 0; + StringBuilder sb = new StringBuilder(); + String hostBinary = fHostBinaryText.getText().trim(); + if ( hostBinary.isEmpty() ) { + sb.append( ( remote ) ? + Messages.GdbDebugNewExecutableCommand_Host_binary_must_be_specified : + Messages.GdbDebugNewExecutableCommand_Binary_must_be_specified ); + } + else { + File file = new File( hostBinary ); + if ( !file.exists() ) { + sb.append( ( remote ) ? + Messages.GdbDebugNewExecutableCommand_Host_binary_file_does_not_exist : + Messages.GdbDebugNewExecutableCommand_Binary_file_does_not_exist ); + } + else if ( file.isDirectory() ) { + sb.append( ( remote ) ? + Messages.GdbDebugNewExecutableCommand_Invalid_host_binary : + Messages.GdbDebugNewExecutableCommand_Invalid_binary ); + } + } + if ( fTargetBinaryText != null ) { + if ( fTargetBinaryText.getText().trim().length() == 0 ) { + if ( sb.length() != 0 ) { + sb.append( "\n " ); //$NON-NLS-1$ + } + sb.append( Messages.GdbDebugNewExecutableCommand_Binary_on_target_must_be_specified ); + } + } + setErrorMessage( ( sb.length() != 0 ) ? sb.toString() : null ); + getButton( IDialogConstants.OK_ID ).setEnabled( getErrorMessage() == null ); + } +} \ No newline at end of file diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/NewExecutableInfo.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/NewExecutableInfo.java new file mode 100644 index 00000000000..1f88a279bde --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/NewExecutableInfo.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * Copyright (c) 2013 Mentor Graphics 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: + * Mentor Graphics - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.cdt.dsf.gdb.internal.ui.launching; + +/** + * This class provides information required to start + * debugging an executable. + */ +public class NewExecutableInfo { + private String fHostPath; + private String fTargetPath; + private String fArguments; + + public NewExecutableInfo(String hostPath, String targetPath, String args) { + super(); + fHostPath = hostPath; + fTargetPath = targetPath; + fArguments = args; + } + + /** + * Returns the path of the executable on the host + */ + public String getHostPath() { + return fHostPath; + } + + /** + * For remote sessions returns the path of the executable + * on the target. Otherwise returns null. + */ + public String getTargetPath() { + return fTargetPath; + } + + /** + * Returns the arguments to pass to the executable, or null + */ + public String getArguments() { + return fArguments; + } +} \ No newline at end of file diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/ProcessPrompter.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/ProcessPrompter.java index 8df673aa10c..b50e0ce4a68 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/ProcessPrompter.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/ProcessPrompter.java @@ -34,10 +34,12 @@ public class ProcessPrompter implements IStatusHandler { public static class PrompterInfo { public boolean supportsNewProcess; + public boolean remote; public IProcessExtendedInfo[] processList; - public PrompterInfo(boolean supportsNew, IProcessExtendedInfo[] list) { + public PrompterInfo(boolean supportsNew, boolean remote, IProcessExtendedInfo[] list) { supportsNewProcess = supportsNew; + this.remote = remote; processList = list; } } @@ -162,7 +164,8 @@ public class ProcessPrompter implements IStatusHandler { }; // Display the list of processes and have the user choose - ProcessPrompterDialog dialog = new ProcessPrompterDialog(shell, provider, qprovider, prompterInfo.supportsNewProcess); + ProcessPrompterDialog dialog = + new ProcessPrompterDialog(shell, provider, qprovider, prompterInfo.supportsNewProcess, prompterInfo.remote); dialog.setTitle(LaunchUIMessages.getString("LocalAttachLaunchDelegate.Select_Process")); //$NON-NLS-1$ dialog.setMessage(LaunchUIMessages.getString("LocalAttachLaunchDelegate.Select_Process_to_attach_debugger_to")); //$NON-NLS-1$ @@ -172,9 +175,9 @@ public class ProcessPrompter implements IStatusHandler { dialog.setElements(plist); if (dialog.open() == Window.OK) { // First check if the user pressed the New button - String binaryPath = dialog.getBinaryPath(); - if (binaryPath != null) { - return binaryPath; + NewExecutableInfo execInfo = dialog.getExecutableInfo(); + if (execInfo != null) { + return execInfo; } Object[] results = dialog.getResult(); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/ProcessPrompterDialog.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/ProcessPrompterDialog.java index 92f6ee216bd..623c148e386 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/ProcessPrompterDialog.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/ProcessPrompterDialog.java @@ -13,12 +13,12 @@ package org.eclipse.cdt.dsf.gdb.internal.ui.launching; import java.util.Arrays; +import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.FileDialog; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Table; @@ -42,13 +42,15 @@ import org.eclipse.ui.dialogs.TwoPaneElementSelector; */ public class ProcessPrompterDialog extends TwoPaneElementSelector { private static final int NEW_BUTTON_ID = 9876; - private String fBinaryPath; + private NewExecutableInfo fExecInfo; private boolean fSupportsNewProcess; + private boolean fRemote; public ProcessPrompterDialog(Shell parent, ILabelProvider elementRenderer, - ILabelProvider qualifierRenderer, boolean supportsNewProcess) { + ILabelProvider qualifierRenderer, boolean supportsNewProcess, boolean remote) { super(parent, elementRenderer, qualifierRenderer); fSupportsNewProcess = supportsNewProcess; + fRemote = remote; } @Override @@ -62,19 +64,16 @@ public class ProcessPrompterDialog extends TwoPaneElementSelector { @Override protected void buttonPressed(int buttonId) { if (buttonId == NEW_BUTTON_ID) { - FileDialog fd = new FileDialog(getShell(), SWT.NONE); - fBinaryPath = fd.open(); - - setReturnCode(OK); - close(); + NewExecutableDialog dialog = new NewExecutableDialog(getShell(), (fRemote) ? NewExecutableDialog.REMOTE : 0); + if (dialog.open() == IDialogConstants.OK_ID) { + fExecInfo = dialog.getExecutableInfo(); + setReturnCode(OK); + close(); + } } super.buttonPressed(buttonId); } - public String getBinaryPath() { - return fBinaryPath; - } - /* * The result should be every selected element. */ @@ -116,4 +115,8 @@ public class ProcessPrompterDialog extends TwoPaneElementSelector { }); return list; } + + public NewExecutableInfo getExecutableInfo() { + return fExecInfo; + } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/IGDBLaunchConfigurationConstants.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/IGDBLaunchConfigurationConstants.java index 0f1cf56d63b..74bdabda65e 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/IGDBLaunchConfigurationConstants.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/IGDBLaunchConfigurationConstants.java @@ -114,6 +114,13 @@ public class IGDBLaunchConfigurationConstants { */ public static final String ATTR_DEBUGGER_TRACEPOINT_MODE = GdbPlugin.PLUGIN_ID + ".TRACEPOINT_MODE"; //$NON-NLS-1$ + /** + * Launch configuration attribute key. The value is a String specifying the path of the executable + * on the target. + * @since 4.2 + */ + public static final String ATTR_DEBUGGER_REMOTE_BINARY = GdbPlugin.PLUGIN_ID + ".REMOTE_BINARY"; //$NON-NLS-1$ + /** * Launch configuration attribute value. The key is ATTR_DEBUG_NAME. */ diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunch.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunch.java index 87c79a79e94..efaa5bdb475 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunch.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunch.java @@ -19,6 +19,7 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.RejectedExecutionException; import org.eclipse.cdt.debug.core.model.IConnectHandler; +import org.eclipse.cdt.debug.core.model.IDebugNewExecutableHandler; import org.eclipse.cdt.dsf.concurrent.ConfinedToDsfExecutor; import org.eclipse.cdt.dsf.concurrent.DefaultDsfExecutor; import org.eclipse.cdt.dsf.concurrent.DsfExecutor; @@ -295,7 +296,10 @@ public class GdbLaunch extends DsfLaunch if (adapter.equals(IConnectHandler.class)) return getSession().getModelAdapter(adapter); - // Must force adapters to be loaded. + if (adapter.equals(IDebugNewExecutableHandler.class)) + return getSession().getModelAdapter(adapter); + + // Must force adapters to be loaded. Platform.getAdapterManager().loadAdapter(this, adapter.getName()); return super.getAdapter(adapter); } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/DebugNewProcessSequence.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/DebugNewProcessSequence.java index ba0797d0f3b..acd2c10c2cc 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/DebugNewProcessSequence.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/DebugNewProcessSequence.java @@ -200,9 +200,13 @@ public class DebugNewProcessSequence extends ReflectionSequence { @Execute public void stepSetArguments(RequestMonitor rm) { try { - String args = fBackend.getProgramArguments(); + String args = CDebugUtils.getAttribute( + fAttributes, + ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, + ""); //$NON-NLS-1$ - if (args != null) { + if (args.length() != 0) { + args = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(args); String[] argArray = CommandLineUtil.argumentsToArray(args); fCommandControl.queueCommand( fCommandFactory.createMIGDBSetArgs(getContainerContext(), argArray), diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/DebugNewProcessSequence_7_2.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/DebugNewProcessSequence_7_2.java index c7238712b59..40685bb3d89 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/DebugNewProcessSequence_7_2.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/DebugNewProcessSequence_7_2.java @@ -15,15 +15,19 @@ import java.util.Arrays; import java.util.List; import java.util.Map; +import org.eclipse.cdt.debug.core.CDebugUtils; import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; import org.eclipse.cdt.dsf.concurrent.DsfExecutor; import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants; import org.eclipse.cdt.dsf.concurrent.ImmediateDataRequestMonitor; import org.eclipse.cdt.dsf.concurrent.RequestMonitor; import org.eclipse.cdt.dsf.datamodel.IDMContext; +import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants; import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin; import org.eclipse.cdt.dsf.gdb.service.command.IGDBControl; +import org.eclipse.cdt.dsf.mi.service.command.CommandFactory; import org.eclipse.cdt.dsf.mi.service.command.output.MIAddInferiorInfo; +import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo; import org.eclipse.cdt.dsf.service.DsfServicesTracker; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; @@ -40,14 +44,23 @@ public class DebugNewProcessSequence_7_2 extends DebugNewProcessSequence { private IGDBControl fGdbControl; private IGDBProcesses fProcService; + private IGDBBackend fBackend; + private CommandFactory fCommandFactory; private String fSessionId; private final boolean fInitialProcess; + private final Map fAttributes; - public DebugNewProcessSequence_7_2(DsfExecutor executor, boolean isInitial, IDMContext dmc, String file, - Map attributes, DataRequestMonitor rm) { + public DebugNewProcessSequence_7_2( + DsfExecutor executor, + boolean isInitial, + IDMContext dmc, + String file, + Map attributes, + DataRequestMonitor rm) { super(executor, isInitial, dmc, file, attributes, rm); fSessionId = dmc.getSessionId(); fInitialProcess = isInitial; + fAttributes = attributes; } @Override @@ -60,13 +73,14 @@ public class DebugNewProcessSequence_7_2 extends DebugNewProcessSequence { // Now insert our steps right after the initialization of the base class. orderList.add(orderList.indexOf("stepInitializeBaseSequence") + 1, "stepInitializeSequence_7_2"); //$NON-NLS-1$ //$NON-NLS-2$ orderList.add(orderList.indexOf("stepInitializeSequence_7_2") + 1, "stepAddInferior"); //$NON-NLS-1$ //$NON-NLS-2$ + orderList.add(orderList.indexOf("stepSetExecutable") + 1, "stepSetRemoteExecutable"); //$NON-NLS-1$ //$NON-NLS-2$ return orderList.toArray(new String[orderList.size()]); } return null; } - + /** * Initialize the members of the DebugNewProcessSequence_7_2 class. * This step is mandatory for the rest of the sequence to complete. @@ -76,14 +90,17 @@ public class DebugNewProcessSequence_7_2 extends DebugNewProcessSequence { DsfServicesTracker tracker = new DsfServicesTracker(GdbPlugin.getBundleContext(), fSessionId); fGdbControl = tracker.getService(IGDBControl.class); fProcService = tracker.getService(IGDBProcesses.class); + fBackend = tracker.getService(IGDBBackend.class); tracker.dispose(); - if (fGdbControl == null || fProcService == null) { + if (fGdbControl == null || fProcService == null || fBackend == null) { rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, IDsfStatusConstants.INTERNAL_ERROR, "Cannot obtain service", null)); //$NON-NLS-1$ rm.done(); return; } + fCommandFactory = fGdbControl.getCommandFactory(); + rm.done(); } @@ -119,5 +136,37 @@ public class DebugNewProcessSequence_7_2 extends DebugNewProcessSequence { rm.done(); } }); + } + + /** + * Set remote executable. + * @since 4.2 + */ + @Execute + public void stepSetRemoteExecutable(final RequestMonitor rm) { + if (fBackend.getSessionType() == SessionType.REMOTE && fBackend.getIsAttachSession()) { + String remoteBinary = CDebugUtils.getAttribute( + fAttributes, + IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_REMOTE_BINARY, + ""); //$NON-NLS-1$ + if (remoteBinary.length() == 0) { + rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, "Binary on host is not specified")); //$NON-NLS-1$ + rm.done(); + return; + } + + fGdbControl.queueCommand( + fCommandFactory.createMIGDBSet( + getContainerContext(), + new String[] { + "remote", //$NON-NLS-1$ + "exec-file", //$NON-NLS-1$ + remoteBinary, + }), + new ImmediateDataRequestMonitor(rm)); + } + else { + rm.done(); } } +} diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_2.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_2.java index d9ab8bc5851..4a313fc1d95 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_2.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_2.java @@ -469,10 +469,14 @@ public class GDBProcesses_7_2 extends GDBProcesses_7_1 { return false; } - // We don't yet support starting a new process on a remote target - // Bug 344890 - if (type == SessionType.REMOTE && fBackend.getIsAttachSession()) { - return false; + // Multi-process does not work for all-stop right now + IMIRunControl runControl = getServicesTracker().getService(IMIRunControl.class); + if (runControl != null && runControl.getRunMode() == MIRunMode.ALL_STOP) { + // Only one process is allowed in all-stop (for now) + return getNumConnected() == 0; + // NOTE: when we support multi-process in all-stop mode, + // we will need to interrupt the target to when starting + // the new process. } return true; diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/StartOrRestartProcessSequence_7_0.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/StartOrRestartProcessSequence_7_0.java index 6f8a2fd69fd..e88e9b6b3ca 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/StartOrRestartProcessSequence_7_0.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/StartOrRestartProcessSequence_7_0.java @@ -260,10 +260,9 @@ public class StartOrRestartProcessSequence_7_0 extends ReflectionSequence { */ @Execute public void stepInitializeInputOutput(final RequestMonitor rm) { - if (fBackend.getSessionType() == SessionType.REMOTE && !fBackend.getIsAttachSession()) { - // Remote non-attach sessions don't support multi-process and therefore will not - // start new processes. Those sessions will only start the one process, which should - // not have a console, because it's output is handled by GDB server. + if (fBackend.getSessionType() == SessionType.REMOTE) { + // The program input and output for a remote session is handled by gdbserver. + // Therefore, no need to create a pty. fPty = null; rm.done(); } else { @@ -296,11 +295,9 @@ public class StartOrRestartProcessSequence_7_0 extends ReflectionSequence { */ @Execute public void stepCreateConsole(final RequestMonitor rm) { - if (fBackend.getSessionType() == SessionType.REMOTE && !fBackend.getIsAttachSession()) { - // Remote non-attach sessions don't support multi-process and therefore will not - // start new processes. Those sessions will only start the one process, which should - // not have a console, because it's output is handled by GDB server. Therefore, - // no need to create an inferior process and add it to the launch + if (fBackend.getSessionType() == SessionType.REMOTE) { + // The program output for a remote session is handled by gdbserver. Therefore, + // no need to create an inferior process and add it to the launch. rm.done(); return; } diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/build.properties b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/build.properties index 5d3e3b9ad20..90d7029058c 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/build.properties +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/build.properties @@ -9,9 +9,10 @@ # Wind River Systems - initial API and implementation # IBM Corporation ############################################################################### -output.tests.jar = bin/ bin.includes = fragment.xml,\ META-INF/,\ - . + .,\ + data/,\ + about.html source.. = src/ src.includes = about.html diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/Makefile b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/Makefile index 3ac4e9a2ff9..e67f6e886e9 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/Makefile +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/Makefile @@ -1,6 +1,6 @@ src = $(wildcard *.cc *.c) destDir = ../bin -GCCFLAGS = -gdwarf-2 -pthread -m32 +GCCFLAGS = -gdwarf-2 -pthread all: @mkdir -p $(destDir) diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/MultiThread.cc b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/MultiThread.cc index e4d390d5a14..db0bd9ff5d1 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/MultiThread.cc +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/MultiThread.cc @@ -21,8 +21,8 @@ unsigned int __stdcall PrintHello(void *threadid) void *PrintHello(void *threadid) #endif { - int tid = (int)threadid; - printf("Hello World! It's me, thread #%d!\n", tid); + long tid = (long)threadid; + printf("Hello World! It's me, thread #%ld!\n", tid); SLEEP(2); // keep this thread around for a bit; the tests will check for its existence while the main thread is stopped at a breakpoint #ifdef __MINGW32__ diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/MultiThreadRunControl.cc b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/MultiThreadRunControl.cc index f30714744ea..4556b07b6dd 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/MultiThreadRunControl.cc +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/MultiThreadRunControl.cc @@ -14,9 +14,9 @@ typedef pthread_t TID; #endif // Set a breakpoint here so that both threads stop. -void firstBreakpoint(int id) +void firstBreakpoint(long id) { - printf("First breakpoint method from thread %d\n", id); + printf("First breakpoint method from thread %ld\n", id); } @@ -26,7 +26,7 @@ unsigned int __stdcall PrintHello(void *threadid) void *PrintHello(void *threadId) #endif { - int tId = (int)threadId; + long tId = (long)threadId; firstBreakpoint(tId); // Stop a first time SLEEP(1); // Keep state running a little diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/TracepointTestApp.cc b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/TracepointTestApp.cc index 5bfe8649f95..ae8acdff923 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/TracepointTestApp.cc +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/TracepointTestApp.cc @@ -73,8 +73,8 @@ unsigned int __stdcall testTracepoints(void *threadid) void *testTracepoints(void *threadid) #endif { - int tid = (int)threadid; - printf("Hello World! It's me, thread #%d!\n", tid); + long tid = (long)threadid; + printf("Hello World! It's me, thread #%ld!\n", tid); int lIntVar = 12345; double lDoubleVar = 12345.12345; diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/pom.xml b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/pom.xml index 5423cfb4202..5d8009d88db 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/pom.xml +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/pom.xml @@ -24,15 +24,48 @@ --> + + -Dcdt.tests.dsf.gdb.path=/opt/public/download-staging.priv/tools/cdt/gdb + + + + maven-antrun-plugin + + + clean + clean + + + + + + + run + + + + prepare + validate + + + + + + + run + + + + org.eclipse.tycho tycho-surefire-plugin ${tycho-version} true - -Xms256m -Xmx512m -XX:MaxPermSize=256M + -Xms256m -Xmx512m -XX:MaxPermSize=256M ${gdbPathOption} **/AutomatedSuite.* diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/BaseTestCase.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/BaseTestCase.java index 8ba587e339c..9d0bffb8ccf 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/BaseTestCase.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/BaseTestCase.java @@ -21,6 +21,8 @@ import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; import org.eclipse.cdt.dsf.datamodel.IDMEvent; import org.eclipse.cdt.dsf.debug.service.IRunControl.ISuspendedDMEvent; import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants; +import org.eclipse.cdt.dsf.gdb.internal.GdbDebugOptions; +import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin; import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch; import org.eclipse.cdt.dsf.mi.service.command.events.IMIDMEvent; import org.eclipse.cdt.dsf.mi.service.command.events.MIStoppedEvent; @@ -218,10 +220,10 @@ public class BaseTestCase { protected void doLaunch() throws Exception { boolean remote = launchAttributes.get(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE).equals(IGDBLaunchConfigurationConstants.DEBUGGER_MODE_REMOTE); - System.out.println("===================================================================================================="); - System.out.println(String.format("Running test: %s using GDB: %s remote %s", - testName.getMethodName(), launchAttributes.get(IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME), remote ? "on" : "off")); - System.out.println("===================================================================================================="); + if(GdbDebugOptions.DEBUG) GdbDebugOptions.trace("===============================================================================================\n"); + System.out.println(String.format("%s \"%s\" launching %s %s", + GdbPlugin.getDebugTime(), testName.getMethodName(), launchAttributes.get(IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME), remote ? "with gdbserver" : "")); + if(GdbDebugOptions.DEBUG) GdbDebugOptions.trace("===============================================================================================\n"); boolean postMortemLaunch = launchAttributes.get(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE) .equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE); @@ -320,7 +322,7 @@ public class BaseTestCase { BufferedReader reader = new BufferedReader(r); String line; while ((line = reader.readLine()) != null) { - System.out.println(line); + if(GdbDebugOptions.DEBUG) GdbDebugOptions.trace(line + "\n"); line = line.trim(); if (line.startsWith("Listening on port")) { break; @@ -351,8 +353,15 @@ public class BaseTestCase { public static void setGdbProgramNamesLaunchAttributes(String version) { // See bugzilla 303811 for why we have to append ".exe" on Windows boolean isWindows = Platform.getOS().equals(Platform.OS_WIN32); - setGlobalLaunchAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME, "gdb." + version + (isWindows ? ".exe" : "")); - setGlobalLaunchAttribute(ATTR_DEBUG_SERVER_NAME, "gdbserver." + version + (isWindows ? ".exe" : "")); + String gdbPath = System.getProperty("cdt.tests.dsf.gdb.path"); + String debugName = "gdb." + version + (isWindows ? ".exe" : ""); + String debugServerName = "gdbserver." + version + (isWindows ? ".exe" : ""); + if (gdbPath != null) { + debugName = gdbPath + "/" + debugName; + debugServerName = gdbPath + "/" + debugServerName; + } + setGlobalLaunchAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME, debugName); + setGlobalLaunchAttribute(ATTR_DEBUG_SERVER_NAME, debugServerName); } protected void setGdbVersion() { diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/AutomatedSuite.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/AutomatedSuite.java index b1dd875c211..64f7246de54 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/AutomatedSuite.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/AutomatedSuite.java @@ -10,7 +10,7 @@ *******************************************************************************/ package org.eclipse.cdt.tests.dsf.gdb.tests; -import org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_4.Suite_7_4; +import org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_5.Suite_7_5; import org.junit.runner.RunWith; import org.junit.runners.Suite; @@ -21,7 +21,7 @@ import org.junit.runners.Suite; @RunWith(Suite.class) @Suite.SuiteClasses({ - Suite_7_4.class, + Suite_7_5.class, // Can't run the Remote test just yet because they // have the same names on the local tests, which is // not handled by JUnit (https://bugs.eclipse.org/172256) diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/ITestConstants.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/ITestConstants.java index 5bcd5b687bc..3f147b52c13 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/ITestConstants.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/ITestConstants.java @@ -22,4 +22,5 @@ public interface ITestConstants { public static final String SUFFIX_GDB_7_3 = "7.3"; public static final String SUFFIX_GDB_7_4 = "7.4"; public static final String SUFFIX_GDB_7_5 = "7.5"; + public static final String SUFFIX_GDB_7_6 = "7.6"; } diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIBreakpointsTest.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIBreakpointsTest.java index 37dee117646..08fd209f524 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIBreakpointsTest.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIBreakpointsTest.java @@ -37,7 +37,8 @@ import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMContex import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMData; import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext; import org.eclipse.cdt.dsf.debug.service.IStack.IFrameDMContext; -import org.eclipse.cdt.dsf.internal.DsfPlugin; +import org.eclipse.cdt.dsf.gdb.internal.GdbDebugOptions; +import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin; import org.eclipse.cdt.dsf.mi.service.MIBreakpointDMData; import org.eclipse.cdt.dsf.mi.service.MIBreakpoints; import org.eclipse.cdt.dsf.mi.service.MIBreakpoints.MIBreakpointDMContext; @@ -240,7 +241,7 @@ public class MIBreakpointsTest extends BaseTestCase { @DsfServiceEventHandler public void eventDispatched(IBreakpointsAddedEvent e) { synchronized (lock) { - System.out.println(DsfPlugin.getDebugTime() + " Got bp added event"); + if(GdbDebugOptions.DEBUG) GdbDebugOptions.trace(GdbPlugin.getDebugTime() + " Got bp added event\n"); fBreakpointEvents[BP_ADDED]++; fBreakpointEventCount++; fBreakpointRef = ((MIBreakpointDMContext) e.getBreakpoints()[0]).getReference(); @@ -251,7 +252,7 @@ public class MIBreakpointsTest extends BaseTestCase { @DsfServiceEventHandler public void eventDispatched(IBreakpointsUpdatedEvent e) { synchronized (lock) { - System.out.println(DsfPlugin.getDebugTime() + " Got bp updated event"); + if(GdbDebugOptions.DEBUG) GdbDebugOptions.trace(GdbPlugin.getDebugTime() + " Got bp updated event\n"); fBreakpointEvents[BP_UPDATED]++; fBreakpointEventCount++; fBreakpointRef = ((MIBreakpointDMContext) e.getBreakpoints()[0]).getReference(); @@ -262,7 +263,7 @@ public class MIBreakpointsTest extends BaseTestCase { @DsfServiceEventHandler public void eventDispatched(IBreakpointsRemovedEvent e) { synchronized (lock) { - System.out.println(DsfPlugin.getDebugTime() + " Got bp removed event"); + if(GdbDebugOptions.DEBUG) GdbDebugOptions.trace(GdbPlugin.getDebugTime() + " Got bp removed event\n"); fBreakpointEvents[BP_REMOVED]++; fBreakpointEventCount++; fBreakpointRef = ((MIBreakpointDMContext) e.getBreakpoints()[0]).getReference(); @@ -273,7 +274,7 @@ public class MIBreakpointsTest extends BaseTestCase { @DsfServiceEventHandler public void eventDispatched(MIBreakpointHitEvent e) { synchronized (lock) { - System.out.println(DsfPlugin.getDebugTime() + " Got bp hit event"); + if(GdbDebugOptions.DEBUG) GdbDebugOptions.trace(GdbPlugin.getDebugTime() + " Got bp hit event\n"); fBreakpointEvents[BP_HIT]++; fBreakpointEventCount++; fBreakpointRef = e.getNumber(); @@ -284,7 +285,7 @@ public class MIBreakpointsTest extends BaseTestCase { @DsfServiceEventHandler public void eventDispatched(MIWatchpointTriggerEvent e) { synchronized (lock) { - System.out.println(DsfPlugin.getDebugTime() + " Got wp hit event"); + if(GdbDebugOptions.DEBUG) GdbDebugOptions.trace(GdbPlugin.getDebugTime() + " Got wp hit event\n"); fBreakpointEvents[WP_HIT]++; fBreakpointEventCount++; fBreakpointRef = e.getNumber(); @@ -295,7 +296,7 @@ public class MIBreakpointsTest extends BaseTestCase { @DsfServiceEventHandler public void eventDispatched(MIWatchpointScopeEvent e) { synchronized (lock) { - System.out.println(DsfPlugin.getDebugTime() + " Got wp scope event"); + if(GdbDebugOptions.DEBUG) GdbDebugOptions.trace(GdbPlugin.getDebugTime() + " Got wp scope event\n"); fBreakpointEvents[WP_OOS]++; fBreakpointEventCount++; fBreakpointRef = e.getNumber(); diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MICatchpointsTest.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MICatchpointsTest.java index b205d223238..f3e548d4440 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MICatchpointsTest.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MICatchpointsTest.java @@ -43,7 +43,8 @@ import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMContex import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMData; import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext; import org.eclipse.cdt.dsf.debug.service.IStack.IFrameDMContext; -import org.eclipse.cdt.dsf.internal.DsfPlugin; +import org.eclipse.cdt.dsf.gdb.internal.GdbDebugOptions; +import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin; import org.eclipse.cdt.dsf.mi.service.MIBreakpointDMData; import org.eclipse.cdt.dsf.mi.service.MIBreakpoints; import org.eclipse.cdt.dsf.mi.service.MIBreakpoints.MIBreakpointDMContext; @@ -225,7 +226,7 @@ public class MICatchpointsTest extends BaseTestCase { synchronized (fEventHandlerLock) { fBreakpointEvents[BP_ADDED]++; fBreakpointRef = ((MIBreakpointDMContext) e.getBreakpoints()[0]).getReference(); - System.out.println(DsfPlugin.getDebugTime() + " Got bp added event (#" + fBreakpointRef + ")"); + if(GdbDebugOptions.DEBUG) GdbDebugOptions.trace(GdbPlugin.getDebugTime() + " Got bp added event (#" + fBreakpointRef + ")\n"); fEventHandlerLock.notifyAll(); } } @@ -235,7 +236,7 @@ public class MICatchpointsTest extends BaseTestCase { synchronized (fEventHandlerLock) { fBreakpointEvents[BP_UPDATED]++; fBreakpointRef = ((MIBreakpointDMContext) e.getBreakpoints()[0]).getReference(); - System.out.println(DsfPlugin.getDebugTime() + " Got bp updated event (#" + fBreakpointRef + ")"); + if(GdbDebugOptions.DEBUG) GdbDebugOptions.trace(GdbPlugin.getDebugTime() + " Got bp updated event (#" + fBreakpointRef + ")\n"); fEventHandlerLock.notifyAll(); } } @@ -245,7 +246,7 @@ public class MICatchpointsTest extends BaseTestCase { synchronized (fEventHandlerLock) { fBreakpointEvents[BP_REMOVED]++; fBreakpointRef = ((MIBreakpointDMContext) e.getBreakpoints()[0]).getReference(); - System.out.println(DsfPlugin.getDebugTime() + " Got bp removed event (#" + fBreakpointRef + ")"); + if(GdbDebugOptions.DEBUG) GdbDebugOptions.trace(GdbPlugin.getDebugTime() + " Got bp removed event (#" + fBreakpointRef + ")\n"); fEventHandlerLock.notifyAll(); } } @@ -255,7 +256,7 @@ public class MICatchpointsTest extends BaseTestCase { synchronized (fEventHandlerLock) { fBreakpointEvents[BP_HIT]++; fBreakpointRef = e.getNumber(); - System.out.println(DsfPlugin.getDebugTime() + " Got bp hit event (#" + fBreakpointRef + ")"); + if(GdbDebugOptions.DEBUG) GdbDebugOptions.trace(GdbPlugin.getDebugTime() + " Got bp hit event (#" + fBreakpointRef + ")\n"); fEventHandlerLock.notifyAll(); } } diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIRegistersTest.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIRegistersTest.java index bffe6680735..770c169db83 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIRegistersTest.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIRegistersTest.java @@ -14,7 +14,6 @@ package org.eclipse.cdt.tests.dsf.gdb.tests; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import java.util.Arrays; import java.util.LinkedList; import java.util.List; @@ -43,10 +42,12 @@ import org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext; import org.eclipse.cdt.dsf.debug.service.IRunControl.StepType; import org.eclipse.cdt.dsf.debug.service.IStack.IFrameDMContext; import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService; +import org.eclipse.cdt.dsf.mi.service.IMICommandControl; import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext; import org.eclipse.cdt.dsf.mi.service.IMIProcesses; import org.eclipse.cdt.dsf.mi.service.MIProcesses; import org.eclipse.cdt.dsf.mi.service.command.events.MIStoppedEvent; +import org.eclipse.cdt.dsf.mi.service.command.output.MIDataListRegisterNamesInfo; import org.eclipse.cdt.dsf.service.DsfServicesTracker; import org.eclipse.cdt.dsf.service.DsfSession; import org.eclipse.cdt.tests.dsf.gdb.framework.AsyncCompletionWaitor; @@ -54,7 +55,6 @@ import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner; import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase; import org.eclipse.cdt.tests.dsf.gdb.framework.SyncUtil; import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin; -import org.eclipse.core.runtime.Platform; import org.junit.Assert; import org.junit.Ignore; import org.junit.Test; @@ -62,18 +62,40 @@ import org.junit.runner.RunWith; @RunWith(BackgroundRunner.class) public class MIRegistersTest extends BaseTestCase { + // Static list of register names as obtained directly from GDB. + // We make it static it does not get re-set for every test + protected static List fRegisterNames = null; - protected List get_X86_REGS() { - List list = new LinkedList(Arrays.asList("eax","ecx","edx","ebx","esp","ebp","esi","edi","eip","eflags", - "cs","ss","ds","es","fs","gs","st0","st1","st2","st3", - "st4","st5","st6","st7","fctrl","fstat","ftag","fiseg","fioff","foseg", - "fooff","fop","xmm0","xmm1","xmm2","xmm3","xmm4","xmm5","xmm6","xmm7", - "mxcsr","orig_eax","mm0","mm1","mm2","mm3","mm4","mm5","mm6","mm7")); - // On Windows, gdb doesn't report "orig_eax" as a register. Apparently it does on Linux - if (Platform.getOS().equals(Platform.OS_WIN32)) { - list.remove("orig_eax"); - } - return list; + protected List get_X86_REGS() throws Throwable { + if (fRegisterNames == null) { + // The tests must run on different machines, so the set of registers can change. + // To deal with this we ask GDB for the list of registers. + // Note that we send an MI Command in this code and do not use the IRegister service; + // this is because we want to test the service later, comparing it to what we find + // by asking GDB directly. + Query query = new Query() { + @Override + protected void execute(DataRequestMonitor rm) { + IMICommandControl controlService = fServicesTracker.getService(IMICommandControl.class); + controlService.queueCommand( + controlService.getCommandFactory().createMIDataListRegisterNames(fContainerDmc), rm); + } + }; + fSession.getExecutor().execute(query); + + MIDataListRegisterNamesInfo data = query.get(); + String[] names = data.getRegisterNames(); + + // Remove registers with empty names since the service also + // remove them. I don't know why GDB returns such empty names. + fRegisterNames = new LinkedList(); + for (String name : names) { + if (!name.isEmpty()) { + fRegisterNames.add(name); + } + } + } + return fRegisterNames; } /* diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_2/MIRegistersTest_7_2.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_2/MIRegistersTest_7_2.java index a7bcd4d7a8d..d2bac5c558c 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_2/MIRegistersTest_7_2.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_2/MIRegistersTest_7_2.java @@ -10,14 +10,9 @@ *******************************************************************************/ package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_2; -import java.util.Arrays; -import java.util.LinkedList; -import java.util.List; - import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner; import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants; import org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_1.MIRegistersTest_7_1; -import org.eclipse.core.runtime.Platform; import org.junit.runner.RunWith; @RunWith(BackgroundRunner.class) @@ -26,23 +21,4 @@ public class MIRegistersTest_7_2 extends MIRegistersTest_7_1 { protected void setGdbVersion() { setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_2); } - - // GDB's list of registers is different with GDB 7.2 - @Override - protected List get_X86_REGS() { - List list = new LinkedList(Arrays.asList("eax","ecx","edx","ebx","esp","ebp","esi","edi","eip","eflags", - "cs","ss","ds","es","fs","gs","st0","st1","st2","st3", - "st4","st5","st6","st7","fctrl","fstat","ftag","fiseg","fioff","foseg", - "fooff","fop","xmm0","xmm1","xmm2","xmm3","xmm4","xmm5","xmm6","xmm7", - "mxcsr",/*"","","","","","","","",*/"orig_eax", - "al","cl","dl","bl","ah","ch","dh","bh","ax","cx", - "dx","bx",/*"",*/"bp","si","di","mm0","mm1","mm2","mm3", - "mm4","mm5","mm6","mm7")); - // On Windows, gdb doesn't report "orig_eax" as a register. Apparently it does on Linux - if (Platform.getOS().equals(Platform.OS_WIN32)) { - list.remove("orig_eax"); - } - return list; - } - } diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_5/Suite_7_5.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_5/Suite_7_5.java index c541b30eb78..058f7757b64 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_5/Suite_7_5.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_5/Suite_7_5.java @@ -29,6 +29,7 @@ import org.junit.runners.Suite; @RunWith(Suite.class) @Suite.SuiteClasses({ // We need specific name for the tests of this suite, because of bug https://bugs.eclipse.org/172256 + GDBMultiNonStopRunControlTest_7_5.class, MIRegistersTest_7_5.class, MIRunControlTest_7_5.class, MIRunControlTargetAvailableTest_7_5.class, @@ -44,8 +45,7 @@ import org.junit.runners.Suite; OperationsWhileTargetIsRunningTest_7_5.class, OperationsWhileTargetIsRunningNonStopTest_7_5.class, PostMortemCoreTest_7_5.class, - CommandTimeoutTest_7_5.class, - GDBMultiNonStopRunControlTest_7_5.class, +// CommandTimeoutTest_7_5.class, Suite_Sessionless_Tests.class, GDBConsoleBreakpointsTest_7_5.class, /* Add your test class here */ diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/CommandTimeoutTest_7_6.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/CommandTimeoutTest_7_6.java new file mode 100644 index 00000000000..527ba2bd697 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/CommandTimeoutTest_7_6.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2012 Ericsson 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 Khouzam (Ericsson) - Initial implementation of Test cases + *******************************************************************************/ + +package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_6; + +import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner; +import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants; +import org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_5.CommandTimeoutTest_7_5; +import org.junit.runner.RunWith; + +@RunWith(BackgroundRunner.class) +public class CommandTimeoutTest_7_6 extends CommandTimeoutTest_7_5 { + @Override + protected void setGdbVersion() { + setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_6); + } +} diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/GDBConsoleBreakpointsTest_7_6.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/GDBConsoleBreakpointsTest_7_6.java new file mode 100644 index 00000000000..45b34889036 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/GDBConsoleBreakpointsTest_7_6.java @@ -0,0 +1,22 @@ +/******************************************************************************* + * Copyright (c) 2012 Mentor Graphics 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: + * Mentor Graphics - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_6; + +import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants; +import org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_5.GDBConsoleBreakpointsTest_7_5; + +public class GDBConsoleBreakpointsTest_7_6 extends GDBConsoleBreakpointsTest_7_5 { + @Override + protected void setGdbVersion() { + setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_6); + } +} diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/GDBMultiNonStopRunControlTest_7_6.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/GDBMultiNonStopRunControlTest_7_6.java new file mode 100644 index 00000000000..d3b6600e5b0 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/GDBMultiNonStopRunControlTest_7_6.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2012 Ericsson 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 Khouzam (Ericsson) - Initial implementation of Test cases + *******************************************************************************/ +package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_6; + + +import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner; +import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants; +import org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_5.GDBMultiNonStopRunControlTest_7_5; +import org.junit.runner.RunWith; + + +@RunWith(BackgroundRunner.class) +public class GDBMultiNonStopRunControlTest_7_6 extends GDBMultiNonStopRunControlTest_7_5 { + @Override + protected void setGdbVersion() { + setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_6); + } +} diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/GDBPatternMatchingExpressionsTest_7_6.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/GDBPatternMatchingExpressionsTest_7_6.java new file mode 100644 index 00000000000..0578c0ade18 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/GDBPatternMatchingExpressionsTest_7_6.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2012 Ericsson 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 Khouzam (Ericsson) - Initial Implementation + *******************************************************************************/ +package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_6; + +import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner; +import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants; +import org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_5.GDBPatternMatchingExpressionsTest_7_5; +import org.junit.runner.RunWith; + +@RunWith(BackgroundRunner.class) +public class GDBPatternMatchingExpressionsTest_7_6 extends GDBPatternMatchingExpressionsTest_7_5 { + @Override + protected void setGdbVersion() { + setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_6); + } +} diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/GDBProcessesTest_7_6.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/GDBProcessesTest_7_6.java new file mode 100644 index 00000000000..8d061548526 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/GDBProcessesTest_7_6.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2012 Ericsson 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 Khouzam (Ericsson) - Initial implementation of Test cases + *******************************************************************************/ +package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_6; + +import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner; +import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants; +import org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_5.GDBProcessesTest_7_5; +import org.junit.runner.RunWith; + +@RunWith(BackgroundRunner.class) +public class GDBProcessesTest_7_6 extends GDBProcessesTest_7_5 { + @Override + protected void setGdbVersion() { + setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_6); + } +} diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/GDBRemoteTracepointsTest_7_6.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/GDBRemoteTracepointsTest_7_6.java new file mode 100644 index 00000000000..0fae296cebc --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/GDBRemoteTracepointsTest_7_6.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2012 Ericsson 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 Khouzam (Ericsson) - Initial implementation of Test cases + *******************************************************************************/ +package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_6; + + +import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner; +import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants; +import org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_5.GDBRemoteTracepointsTest_7_5; +import org.junit.runner.RunWith; + +@RunWith(BackgroundRunner.class) +public class GDBRemoteTracepointsTest_7_6 extends GDBRemoteTracepointsTest_7_5 { + @Override + protected void setGdbVersion() { + setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_6); + } +} diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/LaunchConfigurationAndRestartTest_7_6.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/LaunchConfigurationAndRestartTest_7_6.java new file mode 100644 index 00000000000..9a9ba6515d7 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/LaunchConfigurationAndRestartTest_7_6.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2012 Ericsson 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 Khouzam (Ericsson) - Initial implementation of Test cases + *******************************************************************************/ +package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_6; + +import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner; +import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants; +import org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_5.LaunchConfigurationAndRestartTest_7_5; +import org.junit.runner.RunWith; + +@RunWith(BackgroundRunner.class) +public class LaunchConfigurationAndRestartTest_7_6 extends LaunchConfigurationAndRestartTest_7_5 { + @Override + protected void setGdbVersion() { + setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_6); + } +} diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/MIBreakpointsTest_7_6.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/MIBreakpointsTest_7_6.java new file mode 100644 index 00000000000..2df73f5beb9 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/MIBreakpointsTest_7_6.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2012 Ericsson 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 Khouzam (Ericsson) - Initial implementation of Test cases + *******************************************************************************/ +package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_6; + +import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner; +import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants; +import org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_5.MIBreakpointsTest_7_5; +import org.junit.runner.RunWith; + +@RunWith(BackgroundRunner.class) +public class MIBreakpointsTest_7_6 extends MIBreakpointsTest_7_5 { + @Override + protected void setGdbVersion() { + setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_6); + } +} diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/MICatchpointsTest_7_6.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/MICatchpointsTest_7_6.java new file mode 100644 index 00000000000..ad3d71a8646 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/MICatchpointsTest_7_6.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2012 Ericsson 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 Khouzam (Ericsson) - Initial implementation of Test cases + *******************************************************************************/ +package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_6; + +import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner; +import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants; +import org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_5.MICatchpointsTest_7_5; +import org.junit.runner.RunWith; + +@RunWith(BackgroundRunner.class) +public class MICatchpointsTest_7_6 extends MICatchpointsTest_7_5 { + @Override + protected void setGdbVersion() { + setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_6); + } +} diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/MIDisassemblyTest_7_6.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/MIDisassemblyTest_7_6.java new file mode 100644 index 00000000000..8d0323207d7 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/MIDisassemblyTest_7_6.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2012 Ericsson 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 Khouzam (Ericsson) - Initial implementation of Test cases + *******************************************************************************/ + +package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_6; + +import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner; +import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants; +import org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_5.MIDisassemblyTest_7_5; +import org.junit.runner.RunWith; + + +@RunWith(BackgroundRunner.class) +public class MIDisassemblyTest_7_6 extends MIDisassemblyTest_7_5 { + @Override + protected void setGdbVersion() { + setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_6); + } +} diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/MIExpressionsTest_7_6.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/MIExpressionsTest_7_6.java new file mode 100644 index 00000000000..167e867998f --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/MIExpressionsTest_7_6.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2012 Ericsson 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 Khouzam (Ericsson) - Initial implementation of Test cases + *******************************************************************************/ +package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_6; + +import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner; +import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants; +import org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_5.MIExpressionsTest_7_5; +import org.junit.runner.RunWith; + +@RunWith(BackgroundRunner.class) +public class MIExpressionsTest_7_6 extends MIExpressionsTest_7_5 { + @Override + protected void setGdbVersion() { + setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_6); + } +} diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/MIMemoryTest_7_6.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/MIMemoryTest_7_6.java new file mode 100644 index 00000000000..9f57887c50c --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/MIMemoryTest_7_6.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2012 Ericsson 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 Khouzam (Ericsson) - Initial implementation of Test cases + *******************************************************************************/ +package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_6; + +import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner; +import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants; +import org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_5.MIMemoryTest_7_5; +import org.junit.runner.RunWith; + +@RunWith(BackgroundRunner.class) +public class MIMemoryTest_7_6 extends MIMemoryTest_7_5 { + @Override + protected void setGdbVersion() { + setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_6); + } +} diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/MIRegistersTest_7_6.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/MIRegistersTest_7_6.java new file mode 100644 index 00000000000..02bc444697e --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/MIRegistersTest_7_6.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2012 Ericsson 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 Khouzam (Ericsson) - Initial implementation of Test cases + *******************************************************************************/ +package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_6; + +import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner; +import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants; +import org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_5.MIRegistersTest_7_5; +import org.junit.runner.RunWith; + +@RunWith(BackgroundRunner.class) +public class MIRegistersTest_7_6 extends MIRegistersTest_7_5 { + @Override + protected void setGdbVersion() { + setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_6); + } +} diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/MIRunControlNonStopTargetAvailableTest_7_6.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/MIRunControlNonStopTargetAvailableTest_7_6.java new file mode 100644 index 00000000000..aa057b614a8 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/MIRunControlNonStopTargetAvailableTest_7_6.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2012 Ericsson 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 Khouzam (Ericsson) - Initial implementation of Test cases + *******************************************************************************/ +package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_6; + + +import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants; +import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner; +import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants; +import org.junit.runner.RunWith; + +@RunWith(BackgroundRunner.class) +public class MIRunControlNonStopTargetAvailableTest_7_6 extends MIRunControlTargetAvailableTest_7_6 { + @Override + protected void setGdbVersion() { + setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_6); + } + + @Override + protected void setLaunchAttributes() { + super.setLaunchAttributes(); + + setLaunchAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_NON_STOP, true); + } +} diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/MIRunControlTargetAvailableTest_7_6.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/MIRunControlTargetAvailableTest_7_6.java new file mode 100644 index 00000000000..e4a8ffaf87d --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/MIRunControlTargetAvailableTest_7_6.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2012 Ericsson 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 Khouzam (Ericsson) - Initial implementation of Test cases + *******************************************************************************/ +package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_6; + + +import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner; +import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants; +import org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_5.MIRunControlTargetAvailableTest_7_5; +import org.junit.runner.RunWith; + +@RunWith(BackgroundRunner.class) +public class MIRunControlTargetAvailableTest_7_6 extends MIRunControlTargetAvailableTest_7_5 { + @Override + protected void setGdbVersion() { + setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_6); + } +} diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/MIRunControlTest_7_6.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/MIRunControlTest_7_6.java new file mode 100644 index 00000000000..6464c7a5c81 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/MIRunControlTest_7_6.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2012 Ericsson 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 Khouzam (Ericsson) - Initial implementation of Test cases + *******************************************************************************/ +package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_6; + + +import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner; +import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants; +import org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_5.MIRunControlTest_7_5; +import org.junit.runner.RunWith; + +@RunWith(BackgroundRunner.class) +public class MIRunControlTest_7_6 extends MIRunControlTest_7_5 { + @Override + protected void setGdbVersion() { + setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_6); + } +} diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/OperationsWhileTargetIsRunningNonStopTest_7_6.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/OperationsWhileTargetIsRunningNonStopTest_7_6.java new file mode 100644 index 00000000000..b8e60258116 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/OperationsWhileTargetIsRunningNonStopTest_7_6.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2012 Ericsson 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 Khouzam (Ericsson) - Initial implementation of Test cases + *******************************************************************************/ +package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_6; + + +import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants; +import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner; +import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants; +import org.junit.runner.RunWith; + +@RunWith(BackgroundRunner.class) +public class OperationsWhileTargetIsRunningNonStopTest_7_6 extends OperationsWhileTargetIsRunningTest_7_6 { + @Override + protected void setGdbVersion() { + setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_6); + } + + @Override + protected void setLaunchAttributes() { + super.setLaunchAttributes(); + + setLaunchAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_NON_STOP, true); + } +} diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/OperationsWhileTargetIsRunningTest_7_6.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/OperationsWhileTargetIsRunningTest_7_6.java new file mode 100644 index 00000000000..21e3e13b164 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/OperationsWhileTargetIsRunningTest_7_6.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2012 Ericsson 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 Khouzam (Ericsson) - Initial implementation of Test cases + *******************************************************************************/ +package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_6; + + +import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner; +import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants; +import org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_5.OperationsWhileTargetIsRunningTest_7_5; +import org.junit.runner.RunWith; + +@RunWith(BackgroundRunner.class) +public class OperationsWhileTargetIsRunningTest_7_6 extends OperationsWhileTargetIsRunningTest_7_5 { + @Override + protected void setGdbVersion() { + setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_6); + } +} diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/PostMortemCoreTest_7_6.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/PostMortemCoreTest_7_6.java new file mode 100644 index 00000000000..89c2855c644 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/PostMortemCoreTest_7_6.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2012 Ericsson 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 Khouzam (Ericsson) - Initial implementation of Test cases + *******************************************************************************/ +package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_6; + +import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner; +import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants; +import org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_5.PostMortemCoreTest_7_5; +import org.junit.runner.RunWith; + +@RunWith(BackgroundRunner.class) +public class PostMortemCoreTest_7_6 extends PostMortemCoreTest_7_5 { + @Override + protected void setGdbVersion() { + setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_6); + } +} diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/Suite_7_6.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/Suite_7_6.java new file mode 100644 index 00000000000..983dc915d30 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/Suite_7_6.java @@ -0,0 +1,60 @@ +/******************************************************************************* + * Copyright (c) 2012 Ericsson 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 Khouzam (Ericsson) - Initial implementation of Test cases + *******************************************************************************/ +package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_6; + +import org.eclipse.cdt.dsf.mi.service.command.commands.Suite_Sessionless_Tests; +import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase; +import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants; +import org.junit.BeforeClass; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +/** + * This class is meant to be empty. It enables us to define + * the annotations which list all the different JUnit class we + * want to run. When creating a new test class, it should be + * added to the list below. + * + * This suite is for tests to be run with GDB 7.6. + */ + +@RunWith(Suite.class) +@Suite.SuiteClasses({ + // We need specific name for the tests of this suite, because of bug https://bugs.eclipse.org/172256 + MIRegistersTest_7_6.class, + MIRunControlTest_7_6.class, + MIRunControlTargetAvailableTest_7_6.class, + MIRunControlNonStopTargetAvailableTest_7_6.class, + MIExpressionsTest_7_6.class, + GDBPatternMatchingExpressionsTest_7_6.class, + MIMemoryTest_7_6.class, + MIBreakpointsTest_7_6.class, + MICatchpointsTest_7_6.class, + MIDisassemblyTest_7_6.class, + GDBProcessesTest_7_6.class, + LaunchConfigurationAndRestartTest_7_6.class, + OperationsWhileTargetIsRunningTest_7_6.class, + OperationsWhileTargetIsRunningNonStopTest_7_6.class, + PostMortemCoreTest_7_6.class, + CommandTimeoutTest_7_6.class, + GDBMultiNonStopRunControlTest_7_6.class, + Suite_Sessionless_Tests.class, + GDBConsoleBreakpointsTest_7_6.class, + /* Add your test class here */ +}) + +public class Suite_7_6 { + @BeforeClass + public static void beforeClassMethod() { + BaseTestCase.setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_6); + BaseTestCase.ignoreIfGDBMissing(); + } +} diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/Suite_Remote_7_6.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/Suite_Remote_7_6.java new file mode 100644 index 00000000000..aa3edd8421e --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/Suite_Remote_7_6.java @@ -0,0 +1,61 @@ +/******************************************************************************* + * Copyright (c) 2012 Ericsson 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 Khouzam (Ericsson) - Initial implementation of Test cases + *******************************************************************************/ +package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_6; + +import org.eclipse.cdt.dsf.mi.service.command.commands.Suite_Sessionless_Tests; +import org.eclipse.cdt.tests.dsf.gdb.framework.BaseRemoteSuite; +import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase; +import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants; +import org.junit.BeforeClass; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +/** + * This class is meant to be empty. It enables us to define + * the annotations which list all the different JUnit class we + * want to run. When creating a new test class, it should be + * added to the list below. + * + * This suite is for tests to be run with GDB 7.6 + */ + +@RunWith(Suite.class) +@Suite.SuiteClasses({ + // We need specific name for the tests of this suite, because of bug https://bugs.eclipse.org/172256 + GDBMultiNonStopRunControlTest_7_6.class, + GDBRemoteTracepointsTest_7_6.class, + MIRegistersTest_7_6.class, + MIRunControlTest_7_6.class, + MIRunControlTargetAvailableTest_7_6.class, + MIRunControlNonStopTargetAvailableTest_7_6.class, + MIExpressionsTest_7_6.class, + GDBPatternMatchingExpressionsTest_7_6.class, + MIMemoryTest_7_6.class, + MIBreakpointsTest_7_6.class, + MICatchpointsTest_7_6.class, + MIDisassemblyTest_7_6.class, + GDBProcessesTest_7_6.class, + OperationsWhileTargetIsRunningTest_7_6.class, + OperationsWhileTargetIsRunningNonStopTest_7_6.class, + CommandTimeoutTest_7_6.class, + Suite_Sessionless_Tests.class, + GDBConsoleBreakpointsTest_7_6.class, + TraceFileTest_7_6.class, + /* Add your test class here */ +}) + +public class Suite_Remote_7_6 extends BaseRemoteSuite { + @BeforeClass + public static void beforeClassMethod() { + BaseTestCase.setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_6); + BaseTestCase.ignoreIfGDBMissing(); + } +} diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/TraceFileTest_7_6.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/TraceFileTest_7_6.java new file mode 100644 index 00000000000..8b437681803 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_6/TraceFileTest_7_6.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright (c) 2012 Mentor Graphics 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: + * Mentor Graphics - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_6; + +import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants; +import org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_5.TraceFileTest_7_5; + +public class TraceFileTest_7_6 extends TraceFileTest_7_5 { + + @Override + protected void setGdbVersion() { + setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_6); + } +} diff --git a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/ParseHelper.java b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/ParseHelper.java index c3e4caf2b12..c4d8134cda3 100644 --- a/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/ParseHelper.java +++ b/lrparser/org.eclipse.cdt.core.lrparser.tests/src/org/eclipse/cdt/core/lrparser/tests/ParseHelper.java @@ -29,7 +29,7 @@ import org.eclipse.cdt.core.parser.IScannerInfo; import org.eclipse.cdt.core.parser.IncludeFileContentProvider; import org.eclipse.cdt.core.parser.ParserUtil; import org.eclipse.cdt.core.parser.ScannerInfo; -import org.eclipse.cdt.core.parser.tests.ast2.AST2BaseTest; +import org.eclipse.cdt.core.parser.tests.ast2.AST2TestBase; import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNameBase; import org.eclipse.core.runtime.CoreException; @@ -136,7 +136,7 @@ public class ParseHelper { public static IASTTranslationUnit parse(char[] code, ILanguage lang, Options options) { - return parse(FileContent.create(AST2BaseTest.TEST_CODE, code), lang, new ScannerInfo(), null, options); + return parse(FileContent.create(AST2TestBase.TEST_CODE, code), lang, new ScannerInfo(), null, options); } @@ -254,7 +254,7 @@ public class ParseHelper { IASTTranslationUnit tu; try { - tu = language.getASTTranslationUnit(FileContent.create(AST2BaseTest.TEST_CODE, code.toCharArray()), new ScannerInfo(), null, null, ILanguage.OPTION_ADD_COMMENTS, ParserUtil.getParserLogService()); + tu = language.getASTTranslationUnit(FileContent.create(AST2TestBase.TEST_CODE, code.toCharArray()), new ScannerInfo(), null, null, ILanguage.OPTION_ADD_COMMENTS, ParserUtil.getParserLogService()); } catch (CoreException e) { throw new AssertionFailedError(e.toString()); } @@ -273,7 +273,7 @@ public class ParseHelper { public static IASTCompletionNode getCompletionNode(String code, ILanguage language, int offset) { try { - return language.getCompletionNode(FileContent.create(AST2BaseTest.TEST_CODE, code.toCharArray()), new ScannerInfo(), null, null, ParserUtil.getParserLogService(), offset); + return language.getCompletionNode(FileContent.create(AST2TestBase.TEST_CODE, code.toCharArray()), new ScannerInfo(), null, null, ParserUtil.getParserLogService(), offset); } catch (CoreException e) { throw new RuntimeException(e); } diff --git a/memory/org.eclipse.cdt.debug.ui.memory.memorybrowser/src/org/eclipse/cdt/debug/ui/memory/memorybrowser/MemoryBrowser.java b/memory/org.eclipse.cdt.debug.ui.memory.memorybrowser/src/org/eclipse/cdt/debug/ui/memory/memorybrowser/MemoryBrowser.java index 8a854788544..21c1584aae9 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory.memorybrowser/src/org/eclipse/cdt/debug/ui/memory/memorybrowser/MemoryBrowser.java +++ b/memory/org.eclipse.cdt.debug.ui.memory.memorybrowser/src/org/eclipse/cdt/debug/ui/memory/memorybrowser/MemoryBrowser.java @@ -994,7 +994,11 @@ public class MemoryBrowser extends ViewPart implements IDebugContextListener, IM CTabFolder tabFolder = fContextFolders.get(retrieval); if(tabFolder != null) { fStackLayout.topControl = tabFolder; - handleTabActivated(tabFolder.getSelection()); + CTabItem tabItem = (CTabItem) tabFolder.getSelection(); + if ( tabItem != null ) { + getSite().getSelectionProvider().setSelection(new StructuredSelection(tabItem.getData(KEY_RENDERING))); + } + handleTabActivated(tabItem); } else { tabFolder = createTabFolder(fRenderingsComposite); diff --git a/memory/org.eclipse.cdt.debug.ui.memory.transport/plugin.xml b/memory/org.eclipse.cdt.debug.ui.memory.transport/plugin.xml index 10e7c942abb..9df3435c186 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory.transport/plugin.xml +++ b/memory/org.eclipse.cdt.debug.ui.memory.transport/plugin.xml @@ -7,17 +7,6 @@ name="%extension.name.0" point="org.eclipse.cdt.debug.ui.memory.transport.memoryTransport"> - - - - - + + + + + diff --git a/memory/org.eclipse.cdt.debug.ui.memory.transport/schema/MemoryTransport.exsd b/memory/org.eclipse.cdt.debug.ui.memory.transport/schema/MemoryTransport.exsd index cf963b11f26..ec7304db8f9 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory.transport/schema/MemoryTransport.exsd +++ b/memory/org.eclipse.cdt.debug.ui.memory.transport/schema/MemoryTransport.exsd @@ -77,6 +77,13 @@ + + + + Maximum size of the addressable memory this exporter can support in bits. + + + @@ -109,6 +116,13 @@ + + + + Maximum size of the addressable memory this importer can support in bits. + + + diff --git a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/ExportMemoryDialog.java b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/ExportMemoryDialog.java index f279b04e2de..af4f639a596 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/ExportMemoryDialog.java +++ b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/ExportMemoryDialog.java @@ -23,6 +23,7 @@ import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.model.IMemoryBlock; +import org.eclipse.debug.core.model.IMemoryBlockExtension; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.swt.SWT; @@ -180,19 +181,46 @@ public class ExportMemoryDialog extends SelectionDialog registry.getExtensionPoint("org.eclipse.cdt.debug.ui.memory.transport.memoryTransport"); //$NON-NLS-1$ IConfigurationElement points[] = extensionPoint.getConfigurationElements(); - + for (int i = 0; i < points.length; i++) { IConfigurationElement element = points[i]; if("exporter".equals(element.getName())) //$NON-NLS-1$ { + String maxSizeStr = element.getAttribute("maxmemorysize"); + if ( maxSizeStr != null ) { + if ( fMemoryBlock instanceof IMemoryBlockExtension ) { + IMemoryBlockExtension memBlock = (IMemoryBlockExtension) fMemoryBlock; + try { + BigInteger endAddress = memBlock.getBigBaseAddress(); + BigInteger length = memBlock.getBigLength(); + if ( length != null && ! length.equals(new BigInteger("-1",10) ) ) { + endAddress = endAddress.add( length ) ; + } + int maxAddressSizeInBits = endAddress.bitLength(); + int maxSupportedAddressSizeInBits = Integer.decode(maxSizeStr); + if ( maxAddressSizeInBits > maxSupportedAddressSizeInBits ) { + continue; + } + } catch (DebugException e1) { + continue; + } + } + else { + int maxSupportedAddressSizeInBits = Integer.decode(maxSizeStr); + if ( maxSupportedAddressSizeInBits < 32 ) { + continue; + } + } + } + try { exporters.addElement((IMemoryExporter) element.createExecutableExtension("class")); //$NON-NLS-1$ } catch(Exception e) { MemoryTransportPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), - DebugException.INTERNAL_ERROR, "Failure", e)); //$NON-NLS-1$ + DebugException.INTERNAL_ERROR, "Failure", e)); //$NON-NLS-1$ } } } diff --git a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/ImportMemoryDialog.java b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/ImportMemoryDialog.java index 32d12aec9ce..4d91238617e 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/ImportMemoryDialog.java +++ b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/ImportMemoryDialog.java @@ -25,6 +25,7 @@ import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.model.IMemoryBlock; +import org.eclipse.debug.core.model.IMemoryBlockExtension; import org.eclipse.debug.ui.memory.IMemoryRendering; import org.eclipse.debug.ui.memory.IMemoryRenderingContainer; import org.eclipse.debug.ui.memory.IMemoryRenderingSite; @@ -219,6 +220,30 @@ public class ImportMemoryDialog extends SelectionDialog IConfigurationElement element = points[i]; if("importer".equals(element.getName())) //$NON-NLS-1$ { + String maxSizeStr = element.getAttribute("maxmemorysize"); + if ( maxSizeStr != null ) { + if ( fMemoryBlock instanceof IMemoryBlockExtension ) { + IMemoryBlockExtension memBlock = (IMemoryBlockExtension) fMemoryBlock; + try { + int maxAddressSizeInBits = memBlock.getAddressSize() * 8; + int maxSupportedAddressSizeInBits = Integer.decode(maxSizeStr); + if ( maxAddressSizeInBits > maxSupportedAddressSizeInBits ) { + continue; + } + } catch (DebugException e1) { + continue; + } + } + else { + int maxSupportedAddressSizeInBits = Integer.decode(maxSizeStr); + if ( maxSupportedAddressSizeInBits < 32 ) { + continue; + } + } + } + + + try { importers.addElement(element.createExecutableExtension("class")); //$NON-NLS-1$ diff --git a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/PlainTextExporter.java b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/PlainTextExporter.java index 2ad02b2260c..d6e5e1d9452 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/PlainTextExporter.java +++ b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/PlainTextExporter.java @@ -69,13 +69,17 @@ public class PlainTextExporter implements IMemoryExporter { @Override public void dispose() { - fProperties.put(TRANSFER_FILE, fFileText.getText()); - fProperties.put(TRANSFER_START, fStartText.getText()); - fProperties.put(TRANSFER_END, fEndText.getText()); + fProperties.put(TRANSFER_FILE, fFileText.getText().trim()); + fProperties.put(TRANSFER_START, fStartText.getText().trim()); + fProperties.put(TRANSFER_END, fEndText.getText().trim()); - fStartAddress = getStartAddress(); - fEndAddress = getEndAddress(); - fOutputFile = getFile(); + try + { + fStartAddress = getStartAddress(); + fEndAddress = getEndAddress(); + fOutputFile = getFile(); + } + catch(Exception e) {} super.dispose(); } @@ -96,7 +100,7 @@ public class PlainTextExporter implements IMemoryExporter { fStartText = new Text(composite, SWT.BORDER); data = new FormData(); data.left = new FormAttachment(startLabel); - data.width = 100; + data.width = 120; fStartText.setLayoutData(data); // end address @@ -112,7 +116,7 @@ public class PlainTextExporter implements IMemoryExporter { data = new FormData(); data.top = new FormAttachment(fStartText, 0, SWT.CENTER); data.left = new FormAttachment(endLabel); - data.width = 100; + data.width = 120; fEndText.setLayoutData(data); // length @@ -128,7 +132,7 @@ public class PlainTextExporter implements IMemoryExporter { data = new FormData(); data.top = new FormAttachment(fStartText, 0, SWT.CENTER); data.left = new FormAttachment(lengthLabel); - data.width = 100; + data.width = 120; fLengthText.setLayoutData(data); // file @@ -145,7 +149,7 @@ public class PlainTextExporter implements IMemoryExporter { data = new FormData(); data.top = new FormAttachment(fileButton, 0, SWT.CENTER); data.left = new FormAttachment(fileLabel); - data.width = 300; + data.width = 360; fFileText.setLayoutData(data); fileButton.setText(Messages.getString("Exporter.Browse")); //$NON-NLS-1$ @@ -159,11 +163,41 @@ public class PlainTextExporter implements IMemoryExporter { textValue = fProperties.get(TRANSFER_START); fStartText.setText(textValue != null ? textValue : "0x0"); //$NON-NLS-1$ + + try + { + getStartAddress(); + } + catch(Exception e) + { + fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } textValue = fProperties.get(TRANSFER_END); fEndText.setText(textValue != null ? textValue : "0x0"); //$NON-NLS-1$ - - fLengthText.setText(getEndAddress().subtract(getStartAddress()).toString()); + + try + { + getEndAddress(); + } + catch(Exception e) + { + fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } + + try + { + BigInteger length = getEndAddress().subtract(getStartAddress()); + fLengthText.setText(length.toString()); + if(length.compareTo(BigInteger.ZERO) <= 0) { + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } + } + catch(Exception e) + { + fLengthText.setText("0"); + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } fileButton.addSelectionListener(new SelectionAdapter() { @@ -173,7 +207,7 @@ public class PlainTextExporter implements IMemoryExporter { dialog.setText(Messages.getString("PlainTextExporter.ChooseFile")); //$NON-NLS-1$ dialog.setFilterExtensions(new String[] { "*.*;*" } ); //$NON-NLS-1$ dialog.setFilterNames(new String[] { Messages.getString("Exporter.AllFiles") } ); //$NON-NLS-1$ - dialog.setFileName(fFileText.getText()); + dialog.setFileName(fFileText.getText().trim()); dialog.open(); String filename = dialog.getFileName(); @@ -189,26 +223,38 @@ public class PlainTextExporter implements IMemoryExporter { fStartText.addKeyListener(new KeyListener() { public void keyReleased(KeyEvent e) { - boolean valid = true; try { - getStartAddress(); + fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); + fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); + + BigInteger startAddress = getStartAddress(); + BigInteger actualLength = getEndAddress().subtract(startAddress); + fLengthText.setText(actualLength.toString()); + + if(actualLength.compareTo(BigInteger.ZERO) <= 0) { + fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } + + if(startAddress.compareTo(BigInteger.ZERO) < 0) { + fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } + + BigInteger endAddress = getEndAddress(); + if(endAddress.compareTo(BigInteger.ZERO) < 0) { + fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } } catch(Exception ex) { - valid = false; + fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); } - fStartText.setForeground(valid ? Display.getDefault().getSystemColor(SWT.COLOR_BLACK) : - Display.getDefault().getSystemColor(SWT.COLOR_RED)); - - // - - BigInteger endAddress = getEndAddress(); - BigInteger startAddress = getStartAddress(); - - fLengthText.setText(endAddress.subtract(startAddress).toString()); - validate(); } @@ -219,20 +265,34 @@ public class PlainTextExporter implements IMemoryExporter { public void keyReleased(KeyEvent e) { try { - getEndAddress(); + fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); + + BigInteger actualLength = getEndAddress().subtract(getStartAddress()); + fLengthText.setText(actualLength.toString()); + + if(actualLength.compareTo(BigInteger.ZERO) <= 0) { + fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } + + BigInteger startAddress = getStartAddress(); + if(startAddress.compareTo(BigInteger.ZERO) < 0) { + fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } BigInteger endAddress = getEndAddress(); - BigInteger startAddress = getStartAddress(); - - String lengthString = endAddress.subtract(startAddress).toString(); - - if(!fLengthText.getText().equals(lengthString)) - fLengthText.setText(lengthString); + if(endAddress.compareTo(BigInteger.ZERO) < 0) { + fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } } catch(Exception ex) { fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); } validate(); @@ -246,22 +306,54 @@ public class PlainTextExporter implements IMemoryExporter { public void keyReleased(KeyEvent e) { try { - BigInteger length = getLength(); + fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); + fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); + + fStartText.setText(fStartText.getText().trim()); + + BigInteger length = getLength(); + String endString; BigInteger startAddress = getStartAddress(); - String endString = "0x" + startAddress.add(length).toString(16); //$NON-NLS-1$ - if(!fEndText.getText().equals(endString)) - fEndText.setText(endString); + BigInteger endAddress = startAddress.add(length); + + if(length.compareTo(BigInteger.ZERO) <= 0) { + if(endAddress.compareTo(BigInteger.ZERO) < 0) { + endString = endAddress.toString(16); //$NON-NLS-1$ + } + else { + endString = "0x" + endAddress.toString(16); //$NON-NLS-1$ + } + } + else { + endString = "0x" + endAddress.toString(16); //$NON-NLS-1$ + } + + fEndText.setText(endString); + + if(length.compareTo(BigInteger.ZERO) <= 0) { + fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } + + if(startAddress.compareTo(BigInteger.ZERO) < 0) { + fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } + + if(endAddress.compareTo(BigInteger.ZERO) < 0) { + fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } } catch(Exception ex) { + if ( fLengthText.getText().trim().length() != 0 ) { + fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); } - + validate(); } - - public void keyPressed(KeyEvent e) { @@ -273,19 +365,33 @@ public class PlainTextExporter implements IMemoryExporter { validate(); } - public void keyPressed(KeyEvent e) { - - } + public void keyPressed(KeyEvent e) {} }); composite.pack(); + /* + * We need to perform a validation. If we do it immediately we will get an exception + * because things are not totally setup. So we schedule an immediate running of the + * validation. For a very brief time the view logically may show a state which does + * not reflect the true state of affairs. But the validate immediately corrects the + * info. In practice the user never sees the invalid state displayed, because of the + * speed of the draw of the dialog. + */ + Display.getDefault().asyncExec(new Runnable(){ + public void run() + { + validate(); + } + }); + return composite; } public BigInteger getEndAddress() { String text = fEndText.getText(); + text = text.trim(); boolean hex = text.startsWith("0x"); //$NON-NLS-1$ BigInteger endAddress = new BigInteger(hex ? text.substring(2) : text, hex ? 16 : 10); @@ -296,6 +402,7 @@ public class PlainTextExporter implements IMemoryExporter { public BigInteger getStartAddress() { String text = fStartText.getText(); + text = text.trim(); boolean hex = text.startsWith("0x"); //$NON-NLS-1$ BigInteger startAddress = new BigInteger(hex ? text.substring(2) : text, hex ? 16 : 10); @@ -306,6 +413,7 @@ public class PlainTextExporter implements IMemoryExporter { public BigInteger getLength() { String text = fLengthText.getText(); + text = text.trim(); boolean hex = text.startsWith("0x"); //$NON-NLS-1$ BigInteger lengthAddress = new BigInteger(hex ? text.substring(2) : text, hex ? 16 : 10); @@ -315,7 +423,7 @@ public class PlainTextExporter implements IMemoryExporter { public File getFile() { - return new File(fFileText.getText()); + return new File(fFileText.getText().trim()); } private void validate() @@ -325,7 +433,6 @@ public class PlainTextExporter implements IMemoryExporter { try { getEndAddress(); - getStartAddress(); BigInteger length = getLength(); @@ -333,8 +440,22 @@ public class PlainTextExporter implements IMemoryExporter { if(length.compareTo(BigInteger.ZERO) <= 0) isValid = false; - if(!getFile().getParentFile().exists()) + if ( fFileText.getText().trim().length() == 0 ) isValid = false; + + File file = getFile(); + if ( file != null ) { + File parentFile = file.getParentFile(); + + if(parentFile != null && ! parentFile.exists() ) + isValid = false; + + if(parentFile != null && parentFile.exists() && ( ! parentFile.canRead() || ! parentFile.isDirectory() ) ) + isValid = false; + + if ( file.isDirectory() ) + isValid = false; + } } catch(Exception e) { @@ -342,9 +463,8 @@ public class PlainTextExporter implements IMemoryExporter { } fParentDialog.setValid(isValid); - } - + public String getId() { return "PlainTextExporter"; //$NON-NLS-1$ diff --git a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/PlainTextImporter.java b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/PlainTextImporter.java index 85de142c2d6..c06fcfeb58e 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/PlainTextImporter.java +++ b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/PlainTextImporter.java @@ -76,13 +76,17 @@ public class PlainTextImporter implements IMemoryImporter { @Override public void dispose() { - fProperties.put(TRANSFER_FILE, fFileText.getText()); - fProperties.put(TRANSFER_START, fStartText.getText()); + fProperties.put(TRANSFER_FILE, fFileText.getText().trim()); + fProperties.put(TRANSFER_START, fStartText.getText().trim()); fProperties.put(TRANSFER_SCROLL_TO_START, fScrollToBeginningOnImportComplete.getSelection()); - fStartAddress = getStartAddress(); - fInputFile = getFile(); - fScrollToStart = getScrollToStart(); + try + { + fStartAddress = getStartAddress(); + fInputFile = getFile(); + fScrollToStart = getScrollToStart(); + } + catch(Exception e) {} super.dispose(); } @@ -113,7 +117,7 @@ public class PlainTextImporter implements IMemoryImporter { data = new FormData(); // data.top = new FormAttachment(fComboRestoreToFileAddress); data.left = new FormAttachment(labelStartText); - data.width = 100; + data.width = 120; fStartText.setLayoutData(data); // file @@ -157,7 +161,7 @@ public class PlainTextImporter implements IMemoryImporter { dialog.setText(Messages.getString("PlainTextImporter.ChooseFile")); //$NON-NLS-1$ dialog.setFilterExtensions(new String[] { "*.*;*" } ); //$NON-NLS-1$ dialog.setFilterNames(new String[] { Messages.getString("Importer.AllFiles") } ); //$NON-NLS-1$ - dialog.setFileName(fFileText.getText()); + dialog.setFileName(fFileText.getText().trim()); dialog.open(); String filename = dialog.getFileName(); @@ -226,8 +230,14 @@ public class PlainTextImporter implements IMemoryImporter { try { getStartAddress(); - if(!getFile().exists()) + + + if ( fFileText.getText().trim().length() == 0 ) isValid = false; + + if(!getFile().exists()) { + isValid = false; + } } catch(Exception e) { @@ -245,6 +255,7 @@ public class PlainTextImporter implements IMemoryImporter { public BigInteger getStartAddress() { String text = fStartText.getText(); + text = text.trim(); boolean hex = text.startsWith("0x"); //$NON-NLS-1$ BigInteger startAddress = new BigInteger(hex ? text.substring(2) : text, hex ? 16 : 10); @@ -254,7 +265,7 @@ public class PlainTextImporter implements IMemoryImporter { public File getFile() { - return new File(fFileText.getText()); + return new File(fFileText.getText().trim()); } public String getId() diff --git a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/RAWBinaryExporter.java b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/RAWBinaryExporter.java index cfa505cdc05..801071fde49 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/RAWBinaryExporter.java +++ b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/RAWBinaryExporter.java @@ -69,13 +69,17 @@ public class RAWBinaryExporter implements IMemoryExporter @Override public void dispose() { - fProperties.put(TRANSFER_FILE, fFileText.getText()); - fProperties.put(TRANSFER_START, fStartText.getText()); - fProperties.put(TRANSFER_END, fEndText.getText()); + fProperties.put(TRANSFER_FILE, fFileText.getText().trim()); + fProperties.put(TRANSFER_START, fStartText.getText().trim()); + fProperties.put(TRANSFER_END, fEndText.getText().trim()); - fStartAddress = getStartAddress(); - fEndAddress = getEndAddress(); - fOutputFile = getFile(); + try + { + fStartAddress = getStartAddress(); + fEndAddress = getEndAddress(); + fOutputFile = getFile(); + } + catch(Exception e) {} super.dispose(); } @@ -95,7 +99,7 @@ public class RAWBinaryExporter implements IMemoryExporter fStartText = new Text(composite, SWT.BORDER); data = new FormData(); data.left = new FormAttachment(startLabel); - data.width = 100; + data.width = 120; fStartText.setLayoutData(data); // end address @@ -111,7 +115,7 @@ public class RAWBinaryExporter implements IMemoryExporter data = new FormData(); data.top = new FormAttachment(fStartText, 0, SWT.CENTER); data.left = new FormAttachment(endLabel); - data.width = 100; + data.width = 120; fEndText.setLayoutData(data); // length @@ -127,7 +131,7 @@ public class RAWBinaryExporter implements IMemoryExporter data = new FormData(); data.top = new FormAttachment(fStartText, 0, SWT.CENTER); data.left = new FormAttachment(lengthLabel); - data.width = 100; + data.width = 120; fLengthText.setLayoutData(data); // file @@ -144,7 +148,7 @@ public class RAWBinaryExporter implements IMemoryExporter data = new FormData(); data.top = new FormAttachment(fileButton, 0, SWT.CENTER); data.left = new FormAttachment(fileLabel); - data.width = 300; + data.width = 360; fFileText.setLayoutData(data); fileButton.setText(Messages.getString("Exporter.Browse")); //$NON-NLS-1$ @@ -158,11 +162,41 @@ public class RAWBinaryExporter implements IMemoryExporter textValue = fProperties.get(TRANSFER_START); fStartText.setText(textValue != null ? textValue : "0x0"); //$NON-NLS-1$ + + try + { + getStartAddress(); + } + catch(Exception e) + { + fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } textValue = fProperties.get(TRANSFER_END); fEndText.setText(textValue != null ? textValue : "0x0"); //$NON-NLS-1$ - - fLengthText.setText(getEndAddress().subtract(getStartAddress()).toString()); + + try + { + getEndAddress(); + } + catch(Exception e) + { + fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } + + try + { + BigInteger length = getEndAddress().subtract(getStartAddress()); + fLengthText.setText(length.toString()); + if(length.compareTo(BigInteger.ZERO) <= 0) { + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } + } + catch(Exception e) + { + fLengthText.setText("0"); + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } fileButton.addSelectionListener(new SelectionListener() { @@ -174,7 +208,7 @@ public class RAWBinaryExporter implements IMemoryExporter dialog.setText(Messages.getString("RAWBinaryExporter.ChooseFile")); //$NON-NLS-1$ dialog.setFilterExtensions(new String[] { "*.*;*" } ); //$NON-NLS-1$ dialog.setFilterNames(new String[] { Messages.getString("Exporter.AllFiles") } ); //$NON-NLS-1$ - dialog.setFileName(fFileText.getText()); + dialog.setFileName(fFileText.getText().trim()); dialog.open(); String filename = dialog.getFileName(); @@ -190,26 +224,38 @@ public class RAWBinaryExporter implements IMemoryExporter fStartText.addKeyListener(new KeyListener() { public void keyReleased(KeyEvent e) { - boolean valid = true; try { - getStartAddress(); + fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); + fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); + + BigInteger startAddress = getStartAddress(); + BigInteger actualLength = getEndAddress().subtract(startAddress); + fLengthText.setText(actualLength.toString()); + + if(actualLength.compareTo(BigInteger.ZERO) <= 0) { + fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } + + if(startAddress.compareTo(BigInteger.ZERO) < 0) { + fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } + + BigInteger endAddress = getEndAddress(); + if(endAddress.compareTo(BigInteger.ZERO) < 0) { + fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } } catch(Exception ex) { - valid = false; + fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); } - fStartText.setForeground(valid ? Display.getDefault().getSystemColor(SWT.COLOR_BLACK) : - Display.getDefault().getSystemColor(SWT.COLOR_RED)); - - // - - BigInteger endAddress = getEndAddress(); - BigInteger startAddress = getStartAddress(); - - fLengthText.setText(endAddress.subtract(startAddress).toString()); - validate(); } @@ -220,20 +266,34 @@ public class RAWBinaryExporter implements IMemoryExporter public void keyReleased(KeyEvent e) { try { - getEndAddress(); + fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); + + BigInteger actualLength = getEndAddress().subtract(getStartAddress()); + fLengthText.setText(actualLength.toString()); + + if(actualLength.compareTo(BigInteger.ZERO) <= 0) { + fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } + + BigInteger startAddress = getStartAddress(); + if(startAddress.compareTo(BigInteger.ZERO) < 0) { + fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } BigInteger endAddress = getEndAddress(); - BigInteger startAddress = getStartAddress(); - - String lengthString = endAddress.subtract(startAddress).toString(); - - if(!fLengthText.getText().equals(lengthString)) - fLengthText.setText(lengthString); + if(endAddress.compareTo(BigInteger.ZERO) < 0) { + fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } } catch(Exception ex) { fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); } validate(); @@ -247,22 +307,54 @@ public class RAWBinaryExporter implements IMemoryExporter public void keyReleased(KeyEvent e) { try { - BigInteger length = getLength(); + fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); + fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); + + fStartText.setText(fStartText.getText().trim()); + + BigInteger length = getLength(); + String endString; BigInteger startAddress = getStartAddress(); - String endString = "0x" + startAddress.add(length).toString(16); //$NON-NLS-1$ - if(!fEndText.getText().equals(endString)) - fEndText.setText(endString); + BigInteger endAddress = startAddress.add(length); + + if(length.compareTo(BigInteger.ZERO) <= 0) { + if(endAddress.compareTo(BigInteger.ZERO) < 0) { + endString = endAddress.toString(16); //$NON-NLS-1$ + } + else { + endString = "0x" + endAddress.toString(16); //$NON-NLS-1$ + } + } + else { + endString = "0x" + endAddress.toString(16); //$NON-NLS-1$ + } + + fEndText.setText(endString); + + if(length.compareTo(BigInteger.ZERO) <= 0) { + fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } + + if(startAddress.compareTo(BigInteger.ZERO) < 0) { + fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } + + if(endAddress.compareTo(BigInteger.ZERO) < 0) { + fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } } catch(Exception ex) { + if ( fLengthText.getText().trim().length() != 0 ) { + fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); } - + validate(); } - - public void keyPressed(KeyEvent e) { @@ -274,9 +366,7 @@ public class RAWBinaryExporter implements IMemoryExporter validate(); } - public void keyPressed(KeyEvent e) { - - } + public void keyPressed(KeyEvent e) {} }); composite.pack(); @@ -303,6 +393,7 @@ public class RAWBinaryExporter implements IMemoryExporter public BigInteger getEndAddress() { String text = fEndText.getText(); + text = text.trim(); boolean hex = text.startsWith("0x"); //$NON-NLS-1$ BigInteger endAddress = new BigInteger(hex ? text.substring(2) : text, hex ? 16 : 10); @@ -313,6 +404,7 @@ public class RAWBinaryExporter implements IMemoryExporter public BigInteger getStartAddress() { String text = fStartText.getText(); + text = text.trim(); boolean hex = text.startsWith("0x"); //$NON-NLS-1$ BigInteger startAddress = new BigInteger(hex ? text.substring(2) : text, hex ? 16 : 10); @@ -323,6 +415,7 @@ public class RAWBinaryExporter implements IMemoryExporter public BigInteger getLength() { String text = fLengthText.getText(); + text = text.trim(); boolean hex = text.startsWith("0x"); //$NON-NLS-1$ BigInteger lengthAddress = new BigInteger(hex ? text.substring(2) : text, hex ? 16 : 10); @@ -332,7 +425,7 @@ public class RAWBinaryExporter implements IMemoryExporter public File getFile() { - return new File(fFileText.getText()); + return new File(fFileText.getText().trim()); } private void validate() @@ -342,7 +435,6 @@ public class RAWBinaryExporter implements IMemoryExporter try { getEndAddress(); - getStartAddress(); BigInteger length = getLength(); @@ -350,8 +442,22 @@ public class RAWBinaryExporter implements IMemoryExporter if(length.compareTo(BigInteger.ZERO) <= 0) isValid = false; - if(!getFile().getParentFile().exists()) + if ( fFileText.getText().trim().length() == 0 ) isValid = false; + + File file = getFile(); + if ( file != null ) { + File parentFile = file.getParentFile(); + + if(parentFile != null && ! parentFile.exists() ) + isValid = false; + + if(parentFile != null && parentFile.exists() && ( ! parentFile.canRead() || ! parentFile.isDirectory() ) ) + isValid = false; + + if ( file.isDirectory() ) + isValid = false; + } } catch(Exception e) { @@ -360,7 +466,6 @@ public class RAWBinaryExporter implements IMemoryExporter fParentDialog.setValid(isValid); } - public String getId() { diff --git a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/RAWBinaryImporter.java b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/RAWBinaryImporter.java index e6337fe2230..e1e2b7e7268 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/RAWBinaryImporter.java +++ b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/RAWBinaryImporter.java @@ -71,13 +71,17 @@ public class RAWBinaryImporter implements IMemoryImporter { @Override public void dispose() { - fProperties.put(TRANSFER_FILE, fFileText.getText()); - fProperties.put(TRANSFER_START, fStartText.getText()); + fProperties.put(TRANSFER_FILE, fFileText.getText().trim()); + fProperties.put(TRANSFER_START, fStartText.getText().trim()); fProperties.put(TRANSFER_SCROLL_TO_START, fScrollToBeginningOnImportComplete.getSelection()); - fStartAddress = getStartAddress(); - fInputFile = getFile(); - fScrollToStart = getScrollToStart(); + try + { + fStartAddress = getStartAddress(); + fInputFile = getFile(); + fScrollToStart = getScrollToStart(); + } + catch(Exception e) {} super.dispose(); } @@ -95,7 +99,7 @@ public class RAWBinaryImporter implements IMemoryImporter { fStartText = new Text(composite, SWT.BORDER); FormData data = new FormData(); data.left = new FormAttachment(labelStartText); - data.width = 100; + data.width = 120; fStartText.setLayoutData(data); // file @@ -137,7 +141,7 @@ public class RAWBinaryImporter implements IMemoryImporter { dialog.setText(Messages.getString("RAWBinaryImporter.ChooseFile")); //$NON-NLS-1$ dialog.setFilterExtensions(new String[] { "*.*;*" } ); //$NON-NLS-1$ dialog.setFilterNames(new String[] { Messages.getString("Importer.AllFiles") } ); //$NON-NLS-1$ - dialog.setFileName(fFileText.getText()); + dialog.setFileName(fFileText.getText().trim()); dialog.open(); String filename = dialog.getFileName(); @@ -206,8 +210,14 @@ public class RAWBinaryImporter implements IMemoryImporter { try { getStartAddress(); - if(!getFile().exists()) + + + if ( fFileText.getText().trim().length() == 0 ) isValid = false; + + if(!getFile().exists()) { + isValid = false; + } } catch(Exception e) { @@ -225,6 +235,7 @@ public class RAWBinaryImporter implements IMemoryImporter { public BigInteger getStartAddress() { String text = fStartText.getText(); + text = text.trim(); boolean hex = text.startsWith("0x"); //$NON-NLS-1$ BigInteger startAddress = new BigInteger(hex ? text.substring(2) : text, hex ? 16 : 10); @@ -234,7 +245,7 @@ public class RAWBinaryImporter implements IMemoryImporter { public File getFile() { - return new File(fFileText.getText()); + return new File(fFileText.getText().trim()); } public String getId() diff --git a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/SRecordExporter.java b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/SRecordExporter.java index f5786fb0cb3..870d0d20ba3 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/SRecordExporter.java +++ b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/SRecordExporter.java @@ -68,9 +68,9 @@ public class SRecordExporter implements IMemoryExporter { public void dispose() { - fProperties.put(TRANSFER_FILE, fFileText.getText()); - fProperties.put(TRANSFER_START, fStartText.getText()); - fProperties.put(TRANSFER_END, fEndText.getText()); + fProperties.put(TRANSFER_FILE, fFileText.getText().trim()); + fProperties.put(TRANSFER_START, fStartText.getText().trim()); + fProperties.put(TRANSFER_END, fEndText.getText().trim()); try { @@ -98,7 +98,7 @@ public class SRecordExporter implements IMemoryExporter fStartText = new Text(composite, SWT.BORDER); data = new FormData(); data.left = new FormAttachment(startLabel); - data.width = 100; + data.width = 120; fStartText.setLayoutData(data); // end address @@ -114,7 +114,7 @@ public class SRecordExporter implements IMemoryExporter data = new FormData(); data.top = new FormAttachment(fStartText, 0, SWT.CENTER); data.left = new FormAttachment(endLabel); - data.width = 100; + data.width = 120; fEndText.setLayoutData(data); // length @@ -130,7 +130,7 @@ public class SRecordExporter implements IMemoryExporter data = new FormData(); data.top = new FormAttachment(fStartText, 0, SWT.CENTER); data.left = new FormAttachment(lengthLabel); - data.width = 100; + data.width = 120; fLengthText.setLayoutData(data); // file @@ -147,7 +147,7 @@ public class SRecordExporter implements IMemoryExporter data = new FormData(); data.top = new FormAttachment(fileButton, 0, SWT.CENTER); data.left = new FormAttachment(fileLabel); - data.width = 300; + data.width = 360; fFileText.setLayoutData(data); fileButton.setText(Messages.getString("Exporter.Browse")); //$NON-NLS-1$ @@ -156,6 +156,24 @@ public class SRecordExporter implements IMemoryExporter data.left = new FormAttachment(fFileText); fileButton.setLayoutData(data); + // Restriction notice about 32-bit support + + Label spacingLabel = new Label(composite, SWT.NONE); + + spacingLabel.setText(""); //$NON-NLS-1$ + data = new FormData(); + data.left = new FormAttachment(0); + data.top = new FormAttachment(fileLabel); + spacingLabel.setLayoutData(data); + + Label restrictionLabel = new Label(composite, SWT.NONE); + + restrictionLabel.setText(Messages.getString("SRecordExporter.32BitLimitationMessage")); //$NON-NLS-1$ + data = new FormData(); + data.left = new FormAttachment(0); + data.top = new FormAttachment(spacingLabel); + restrictionLabel.setLayoutData(data); + String textValue = fProperties.get(TRANSFER_FILE); fFileText.setText(textValue != null ? textValue : ""); //$NON-NLS-1$ @@ -171,7 +189,6 @@ public class SRecordExporter implements IMemoryExporter fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); } - textValue = fProperties.get(TRANSFER_END); fEndText.setText(textValue != null ? textValue : "0x0"); //$NON-NLS-1$ @@ -186,7 +203,11 @@ public class SRecordExporter implements IMemoryExporter try { - fLengthText.setText(getEndAddress().subtract(getStartAddress()).toString()); + BigInteger length = getEndAddress().subtract(getStartAddress()); + fLengthText.setText(length.toString()); + if(length.compareTo(BigInteger.ZERO) <= 0) { + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } } catch(Exception e) { @@ -206,7 +227,7 @@ public class SRecordExporter implements IMemoryExporter dialog.setText(Messages.getString("SRecordExporter.ChooseFile")); //$NON-NLS-1$ dialog.setFilterExtensions(new String[] { "*.*;*" } ); //$NON-NLS-1$ dialog.setFilterNames(new String[] { Messages.getString("Exporter.AllFiles") } ); //$NON-NLS-1$ - dialog.setFileName(fFileText.getText()); + dialog.setFileName(fFileText.getText().trim()); dialog.open(); String filename = dialog.getFileName(); @@ -225,21 +246,36 @@ public class SRecordExporter implements IMemoryExporter try { fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); - BigInteger actualLength = getEndAddress().subtract(getStartAddress()); - String lengthString = actualLength.toString(); + fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); - if(!fLengthText.getText().equals(lengthString)) { - if ( ! actualLength.equals( BigInteger.ZERO ) ) { - fLengthText.setText(lengthString); - } + BigInteger startAddress = getStartAddress(); + BigInteger actualLength = getEndAddress().subtract(startAddress); + fLengthText.setText(actualLength.toString()); + + if(actualLength.compareTo(BigInteger.ZERO) <= 0) { + fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } + + if(startAddress.compareTo(BigInteger.ZERO) < 0) { + fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } + + BigInteger endAddress = getEndAddress(); + if(endAddress.compareTo(BigInteger.ZERO) < 0) { + fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); } - validate(); } catch(Exception ex) { fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); - validate(); + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); } + + validate(); } public void keyPressed(KeyEvent e) {} @@ -249,24 +285,37 @@ public class SRecordExporter implements IMemoryExporter public void keyReleased(KeyEvent e) { try { + fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); BigInteger actualLength = getEndAddress().subtract(getStartAddress()); - String lengthString = actualLength.toString(); + fLengthText.setText(actualLength.toString()); - if(!fLengthText.getText().equals(lengthString)) { - if ( ! actualLength.equals( BigInteger.ZERO ) ) { - fLengthText.setText(lengthString); - } + if(actualLength.compareTo(BigInteger.ZERO) <= 0) { + fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); } - validate(); + BigInteger startAddress = getStartAddress(); + if(startAddress.compareTo(BigInteger.ZERO) < 0) { + fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } + + BigInteger endAddress = getEndAddress(); + if(endAddress.compareTo(BigInteger.ZERO) < 0) { + fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } } catch(Exception ex) { - fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); - validate(); + fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); } + + validate(); } public void keyPressed(KeyEvent e) {} @@ -277,21 +326,53 @@ public class SRecordExporter implements IMemoryExporter public void keyReleased(KeyEvent e) { try { - BigInteger length = getLength(); + fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); + fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); - String endString = "0x" + getStartAddress().add(length).toString(16); //$NON-NLS-1$ - if(!fEndText.getText().equals(endString)) { - if ( ! length.equals( BigInteger.ZERO ) ) { - fEndText.setText(endString); + + fStartText.setText(fStartText.getText().trim()); + + BigInteger length = getLength(); + String endString; + BigInteger startAddress = getStartAddress(); + BigInteger endAddress = startAddress.add(length); + + if(length.compareTo(BigInteger.ZERO) <= 0) { + if(endAddress.compareTo(BigInteger.ZERO) < 0) { + endString = endAddress.toString(16); //$NON-NLS-1$ + } + else { + endString = "0x" + endAddress.toString(16); //$NON-NLS-1$ } } - validate(); + else { + endString = "0x" + endAddress.toString(16); //$NON-NLS-1$ + } + + fEndText.setText(endString); + + if(length.compareTo(BigInteger.ZERO) <= 0) { + fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } + + if(startAddress.compareTo(BigInteger.ZERO) < 0) { + fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } + + if(endAddress.compareTo(BigInteger.ZERO) < 0) { + fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } } catch(Exception ex) { + if ( fLengthText.getText().trim().length() != 0 ) { + fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); - validate(); } + + validate(); } public void keyPressed(KeyEvent e) { @@ -333,6 +414,7 @@ public class SRecordExporter implements IMemoryExporter public BigInteger getEndAddress() { String text = fEndText.getText(); + text = text.trim(); boolean hex = text.startsWith("0x"); //$NON-NLS-1$ BigInteger endAddress = new BigInteger(hex ? text.substring(2) : text, hex ? 16 : 10); @@ -347,6 +429,7 @@ public class SRecordExporter implements IMemoryExporter public BigInteger getStartAddress() { String text = fStartText.getText(); + text = text.trim(); boolean hex = text.startsWith("0x"); //$NON-NLS-1$ BigInteger startAddress = new BigInteger(hex ? text.substring(2) : text, hex ? 16 : 10); @@ -361,6 +444,7 @@ public class SRecordExporter implements IMemoryExporter public BigInteger getLength() { String text = fLengthText.getText(); + text = text.trim(); boolean hex = text.startsWith("0x"); //$NON-NLS-1$ BigInteger lengthAddress = new BigInteger(hex ? text.substring(2) : text, hex ? 16 : 10); @@ -371,7 +455,7 @@ public class SRecordExporter implements IMemoryExporter public File getFile() { - return new File(fFileText.getText()); + return new File(fFileText.getText().trim()); } private void validate() @@ -381,7 +465,6 @@ public class SRecordExporter implements IMemoryExporter try { getEndAddress(); - getStartAddress(); BigInteger length = getLength(); @@ -389,8 +472,22 @@ public class SRecordExporter implements IMemoryExporter if(length.compareTo(BigInteger.ZERO) <= 0) isValid = false; - if(!getFile().getParentFile().exists()) + if ( fFileText.getText().trim().length() == 0 ) isValid = false; + + File file = getFile(); + if ( file != null ) { + File parentFile = file.getParentFile(); + + if(parentFile != null && ! parentFile.exists() ) + isValid = false; + + if(parentFile != null && parentFile.exists() && ( ! parentFile.canRead() || ! parentFile.isDirectory() ) ) + isValid = false; + + if ( file.isDirectory() ) + isValid = false; + } } catch(Exception e) { @@ -399,7 +496,6 @@ public class SRecordExporter implements IMemoryExporter fParentDialog.setValid(isValid); } - public String getId() { diff --git a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/SRecordImporter.java b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/SRecordImporter.java index 0dd47576b25..3795cc6c9df 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/SRecordImporter.java +++ b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/SRecordImporter.java @@ -77,14 +77,20 @@ public class SRecordImporter implements IMemoryImporter { { public void dispose() { - fProperties.put(TRANSFER_FILE, fFileText.getText()); - fProperties.put(TRANSFER_START, fStartText.getText()); + fProperties.put(TRANSFER_FILE, fFileText.getText().trim()); + fProperties.put(TRANSFER_START, fStartText.getText().trim()); fProperties.put(TRANSFER_SCROLL_TO_START, fScrollToBeginningOnImportComplete.getSelection()); fProperties.put(TRANSFER_CUSTOM_START_ADDRESS, fComboRestoreToThisAddress.getSelection()); - fStartAddress = getStartAddress(); - fInputFile = getFile(); - fScrollToStart = getScrollToStart(); + try + { + if(fProperties.getBoolean(TRANSFER_CUSTOM_START_ADDRESS)) { + fStartAddress = getStartAddress(); + } + fInputFile = getFile(); + fScrollToStart = getScrollToStart(); + } + catch(Exception e) {} super.dispose(); } @@ -115,7 +121,7 @@ public class SRecordImporter implements IMemoryImporter { data = new FormData(); data.top = new FormAttachment(fComboRestoreToFileAddress); data.left = new FormAttachment(fComboRestoreToThisAddress); - data.width = 100; + data.width = 120; fStartText.setLayoutData(data); fComboRestoreToFileAddress.addSelectionListener(new SelectionListener() { @@ -168,7 +174,7 @@ public class SRecordImporter implements IMemoryImporter { data.top = new FormAttachment(fStartText); data.left = new FormAttachment(fFileText); fileButton.setLayoutData(data); - + String textValue = fProperties.get(TRANSFER_FILE); fFileText.setText(textValue != null ? textValue : ""); //$NON-NLS-1$ @@ -187,7 +193,7 @@ public class SRecordImporter implements IMemoryImporter { dialog.setText(Messages.getString("SRecordImporter.ChooseFile")); //$NON-NLS-1$ dialog.setFilterExtensions(new String[] { "*.*;*" } ); //$NON-NLS-1$ dialog.setFilterNames(new String[] { Messages.getString("Importer.AllFiles") } ); //$NON-NLS-1$ - dialog.setFileName(fFileText.getText()); + dialog.setFileName(fFileText.getText().trim()); dialog.open(); String filename = dialog.getFileName(); @@ -247,6 +253,24 @@ public class SRecordImporter implements IMemoryImporter { final boolean scrollToStart = fProperties.getBoolean(TRANSFER_SCROLL_TO_START); fScrollToBeginningOnImportComplete.setSelection(scrollToStart); + // Restriction notice about 32-bit support + + Label spacingLabel = new Label(composite, SWT.NONE); + + spacingLabel.setText(""); //$NON-NLS-1$ + data = new FormData(); + data.left = new FormAttachment(0); + data.top = new FormAttachment(fScrollToBeginningOnImportComplete); + spacingLabel.setLayoutData(data); + + Label restrictionLabel = new Label(composite, SWT.NONE); + + restrictionLabel.setText(Messages.getString("SRecordImporter.32BitLimitationMessage")); //$NON-NLS-1$ + data = new FormData(); + data.left = new FormAttachment(0); + data.top = new FormAttachment(spacingLabel); + restrictionLabel.setLayoutData(data); + composite.pack(); parent.pack(); @@ -271,11 +295,11 @@ public class SRecordImporter implements IMemoryImporter { getStartAddress(); } - boolean restoreToAddressFromFile = fComboRestoreToFileAddress.getSelection(); - if ( restoreToAddressFromFile ) { - if(!getFile().exists()) { - isValid = false; - } + if ( fFileText.getText().trim().length() == 0 ) + isValid = false; + + if(!getFile().exists()) { + isValid = false; } } catch(Exception e) @@ -294,6 +318,7 @@ public class SRecordImporter implements IMemoryImporter { public BigInteger getStartAddress() { String text = fStartText.getText(); + text = text.trim(); boolean hex = text.startsWith("0x"); //$NON-NLS-1$ BigInteger startAddress = new BigInteger(hex ? text.substring(2) : text, hex ? 16 : 10); @@ -308,7 +333,7 @@ public class SRecordImporter implements IMemoryImporter { public File getFile() { - return new File(fFileText.getText()); + return new File(fFileText.getText().trim()); } public String getId() diff --git a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/messages.properties b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/messages.properties index 27f4885ad59..30bb04fb2d8 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/messages.properties +++ b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/messages.properties @@ -51,6 +51,7 @@ SRecordExporter.EndAddress=End address: SRecordExporter.Length=Length: SRecordExporter.Name=SRecord SRecordExporter.StartAddress=Start address: +SRecordExporter.32BitLimitationMessage=SRecord format only supports 32-bit address spaces. SRecordImporter.ChecksumFalure=Checksum failure of line = SRecordImporter.ChooseFile=Choose memory import file @@ -62,6 +63,7 @@ SRecordImporter.InvalidData=Invalid file format. Invalid data at line %d SRecordImporter.InvalidLineLength=Invalid file format. Invalid line length at line %d SRecordImporter.Name=SRecord SRecordImporter.ScrollToStart=Scroll to restore address +SRecordImporter.32BitLimitationMessage=SRecord format only supports 32-bit address spaces. RAWBinaryExporter.ChooseFile=Choose memory export file RAWBinaryExporter.EndAddress=End address: diff --git a/qt/org.eclipse.cdt.qt-feature/.project b/qt/org.eclipse.cdt.qt-feature/.project new file mode 100644 index 00000000000..c8573d52a68 --- /dev/null +++ b/qt/org.eclipse.cdt.qt-feature/.project @@ -0,0 +1,17 @@ + + + org.eclipse.cdt.qt-feature + + + + + + org.eclipse.pde.FeatureBuilder + + + + + + org.eclipse.pde.FeatureNature + + diff --git a/qt/org.eclipse.cdt.qt-feature/build.properties b/qt/org.eclipse.cdt.qt-feature/build.properties new file mode 100644 index 00000000000..64f93a9f0b7 --- /dev/null +++ b/qt/org.eclipse.cdt.qt-feature/build.properties @@ -0,0 +1 @@ +bin.includes = feature.xml diff --git a/qt/org.eclipse.cdt.qt-feature/eclipse_update_120.jpg b/qt/org.eclipse.cdt.qt-feature/eclipse_update_120.jpg new file mode 100644 index 00000000000..bfdf708ad61 Binary files /dev/null and b/qt/org.eclipse.cdt.qt-feature/eclipse_update_120.jpg differ diff --git a/qt/org.eclipse.cdt.qt-feature/epl-v10.html b/qt/org.eclipse.cdt.qt-feature/epl-v10.html new file mode 100644 index 00000000000..ed4b196655e --- /dev/null +++ b/qt/org.eclipse.cdt.qt-feature/epl-v10.html @@ -0,0 +1,328 @@ + + + + + + + + +Eclipse Public License - Version 1.0 + + + + + + +
    + +

    Eclipse Public License - v 1.0 +

    + +

    THE ACCOMPANYING PROGRAM IS PROVIDED UNDER +THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, +REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE +OF THIS AGREEMENT.

    + +

    1. DEFINITIONS

    + +

    "Contribution" means:

    + +

    a) +in the case of the initial Contributor, the initial code and documentation +distributed under this Agreement, and
    +b) in the case of each subsequent Contributor:

    + +

    i) +changes to the Program, and

    + +

    ii) +additions to the Program;

    + +

    where +such changes and/or additions to the Program originate from and are distributed +by that particular Contributor. A Contribution 'originates' from a Contributor +if it was added to the Program by such Contributor itself or anyone acting on +such Contributor's behalf. Contributions do not include additions to the +Program which: (i) are separate modules of software distributed in conjunction +with the Program under their own license agreement, and (ii) are not derivative +works of the Program.

    + +

    "Contributor" means any person or +entity that distributes the Program.

    + +

    "Licensed Patents " mean patent +claims licensable by a Contributor which are necessarily infringed by the use +or sale of its Contribution alone or when combined with the Program.

    + +

    "Program" means the Contributions +distributed in accordance with this Agreement.

    + +

    "Recipient" means anyone who +receives the Program under this Agreement, including all Contributors.

    + +

    2. GRANT OF RIGHTS

    + +

    a) +Subject to the terms of this Agreement, each Contributor hereby grants Recipient +a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly +display, publicly perform, distribute and sublicense the Contribution of such +Contributor, if any, and such derivative works, in source code and object code +form.

    + +

    b) +Subject to the terms of this Agreement, each Contributor hereby grants +Recipient a non-exclusive, worldwide, royalty-free +patent license under Licensed Patents to make, use, sell, offer to sell, import +and otherwise transfer the Contribution of such Contributor, if any, in source +code and object code form. This patent license shall apply to the combination +of the Contribution and the Program if, at the time the Contribution is added +by the Contributor, such addition of the Contribution causes such combination +to be covered by the Licensed Patents. The patent license shall not apply to +any other combinations which include the Contribution. No hardware per se is +licensed hereunder.

    + +

    c) +Recipient understands that although each Contributor grants the licenses to its +Contributions set forth herein, no assurances are provided by any Contributor +that the Program does not infringe the patent or other intellectual property +rights of any other entity. Each Contributor disclaims any liability to Recipient +for claims brought by any other entity based on infringement of intellectual +property rights or otherwise. As a condition to exercising the rights and +licenses granted hereunder, each Recipient hereby assumes sole responsibility +to secure any other intellectual property rights needed, if any. For example, +if a third party patent license is required to allow Recipient to distribute +the Program, it is Recipient's responsibility to acquire that license before +distributing the Program.

    + +

    d) +Each Contributor represents that to its knowledge it has sufficient copyright +rights in its Contribution, if any, to grant the copyright license set forth in +this Agreement.

    + +

    3. REQUIREMENTS

    + +

    A Contributor may choose to distribute the +Program in object code form under its own license agreement, provided that: +

    + +

    a) +it complies with the terms and conditions of this Agreement; and

    + +

    b) +its license agreement:

    + +

    i) +effectively disclaims on behalf of all Contributors all warranties and +conditions, express and implied, including warranties or conditions of title +and non-infringement, and implied warranties or conditions of merchantability +and fitness for a particular purpose;

    + +

    ii) +effectively excludes on behalf of all Contributors all liability for damages, +including direct, indirect, special, incidental and consequential damages, such +as lost profits;

    + +

    iii) +states that any provisions which differ from this Agreement are offered by that +Contributor alone and not by any other party; and

    + +

    iv) +states that source code for the Program is available from such Contributor, and +informs licensees how to obtain it in a reasonable manner on or through a +medium customarily used for software exchange.

    + +

    When the Program is made available in source +code form:

    + +

    a) +it must be made available under this Agreement; and

    + +

    b) a +copy of this Agreement must be included with each copy of the Program.

    + +

    Contributors may not remove or alter any +copyright notices contained within the Program.

    + +

    Each Contributor must identify itself as the +originator of its Contribution, if any, in a manner that reasonably allows +subsequent Recipients to identify the originator of the Contribution.

    + +

    4. COMMERCIAL DISTRIBUTION

    + +

    Commercial distributors of software may +accept certain responsibilities with respect to end users, business partners +and the like. While this license is intended to facilitate the commercial use +of the Program, the Contributor who includes the Program in a commercial +product offering should do so in a manner which does not create potential +liability for other Contributors. Therefore, if a Contributor includes the +Program in a commercial product offering, such Contributor ("Commercial +Contributor") hereby agrees to defend and indemnify every other +Contributor ("Indemnified Contributor") against any losses, damages and +costs (collectively "Losses") arising from claims, lawsuits and other +legal actions brought by a third party against the Indemnified Contributor to +the extent caused by the acts or omissions of such Commercial Contributor in +connection with its distribution of the Program in a commercial product +offering. The obligations in this section do not apply to any claims or Losses +relating to any actual or alleged intellectual property infringement. In order +to qualify, an Indemnified Contributor must: a) promptly notify the Commercial +Contributor in writing of such claim, and b) allow the Commercial Contributor +to control, and cooperate with the Commercial Contributor in, the defense and +any related settlement negotiations. The Indemnified Contributor may participate +in any such claim at its own expense.

    + +

    For example, a Contributor might include the +Program in a commercial product offering, Product X. That Contributor is then a +Commercial Contributor. If that Commercial Contributor then makes performance +claims, or offers warranties related to Product X, those performance claims and +warranties are such Commercial Contributor's responsibility alone. Under this +section, the Commercial Contributor would have to defend claims against the +other Contributors related to those performance claims and warranties, and if a +court requires any other Contributor to pay any damages as a result, the +Commercial Contributor must pay those damages.

    + +

    5. NO WARRANTY

    + +

    EXCEPT AS EXPRESSLY SET FORTH IN THIS +AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT +WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, +WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, +MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely +responsible for determining the appropriateness of using and distributing the +Program and assumes all risks associated with its exercise of rights under this +Agreement , including but not limited to the risks and costs of program errors, +compliance with applicable laws, damage to or loss of data, programs or +equipment, and unavailability or interruption of operations.

    + +

    6. DISCLAIMER OF LIABILITY

    + +

    EXCEPT AS EXPRESSLY SET FORTH IN THIS +AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF +THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGES.

    + +

    7. GENERAL

    + +

    If any provision of this Agreement is invalid +or unenforceable under applicable law, it shall not affect the validity or +enforceability of the remainder of the terms of this Agreement, and without +further action by the parties hereto, such provision shall be reformed to the +minimum extent necessary to make such provision valid and enforceable.

    + +

    If Recipient institutes patent litigation +against any entity (including a cross-claim or counterclaim in a lawsuit) +alleging that the Program itself (excluding combinations of the Program with +other software or hardware) infringes such Recipient's patent(s), then such +Recipient's rights granted under Section 2(b) shall terminate as of the date +such litigation is filed.

    + +

    All Recipient's rights under this Agreement +shall terminate if it fails to comply with any of the material terms or +conditions of this Agreement and does not cure such failure in a reasonable +period of time after becoming aware of such noncompliance. If all Recipient's +rights under this Agreement terminate, Recipient agrees to cease use and +distribution of the Program as soon as reasonably practicable. However, +Recipient's obligations under this Agreement and any licenses granted by +Recipient relating to the Program shall continue and survive.

    + +

    Everyone is permitted to copy and distribute +copies of this Agreement, but in order to avoid inconsistency the Agreement is +copyrighted and may only be modified in the following manner. The Agreement +Steward reserves the right to publish new versions (including revisions) of +this Agreement from time to time. No one other than the Agreement Steward has +the right to modify this Agreement. The Eclipse Foundation is the initial +Agreement Steward. The Eclipse Foundation may assign the responsibility to +serve as the Agreement Steward to a suitable separate entity. Each new version +of the Agreement will be given a distinguishing version number. The Program +(including Contributions) may always be distributed subject to the version of +the Agreement under which it was received. In addition, after a new version of +the Agreement is published, Contributor may elect to distribute the Program +(including its Contributions) under the new version. Except as expressly stated +in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to +the intellectual property of any Contributor under this Agreement, whether +expressly, by implication, estoppel or otherwise. All rights in the Program not +expressly granted under this Agreement are reserved.

    + +

    This Agreement is governed by the laws of the +State of New York and the intellectual property laws of the United States of +America. No party to this Agreement will bring a legal action under this +Agreement more than one year after the cause of action arose. Each party waives +its rights to a jury trial in any resulting litigation.

    + +

     

    + +
    + + + + \ No newline at end of file diff --git a/qt/org.eclipse.cdt.qt-feature/feature.xml b/qt/org.eclipse.cdt.qt-feature/feature.xml new file mode 100644 index 00000000000..599e59ae103 --- /dev/null +++ b/qt/org.eclipse.cdt.qt-feature/feature.xml @@ -0,0 +1,34 @@ + + + + + [Enter Feature Description here.] + + + + [Enter Copyright Description here.] + + + + [Enter License Description here.] + + + + + + + diff --git a/qt/org.eclipse.cdt.qt-feature/license.html b/qt/org.eclipse.cdt.qt-feature/license.html new file mode 100644 index 00000000000..f19c483b9c8 --- /dev/null +++ b/qt/org.eclipse.cdt.qt-feature/license.html @@ -0,0 +1,108 @@ + + + + + +Eclipse Foundation Software User Agreement + + + +

    Eclipse Foundation Software User Agreement

    +

    February 1, 2011

    + +

    Usage Of Content

    + +

    THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS + (COLLECTIVELY "CONTENT"). USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE TERMS AND + CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE + OF THE CONTENT IS GOVERNED BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR + NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND + CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU MAY NOT USE THE CONTENT.

    + +

    Applicable Licenses

    + +

    Unless otherwise indicated, all Content made available by the Eclipse Foundation is provided to you under the terms and conditions of the Eclipse Public License Version 1.0 + ("EPL"). A copy of the EPL is provided with this Content and is also available at http://www.eclipse.org/legal/epl-v10.html. + For purposes of the EPL, "Program" will mean the Content.

    + +

    Content includes, but is not limited to, source code, object code, documentation and other files maintained in the Eclipse Foundation source code + repository ("Repository") in software modules ("Modules") and made available as downloadable archives ("Downloads").

    + +
      +
    • Content may be structured and packaged into modules to facilitate delivering, extending, and upgrading the Content. Typical modules may include plug-ins ("Plug-ins"), plug-in fragments ("Fragments"), and features ("Features").
    • +
    • Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java™ ARchive) in a directory named "plugins".
    • +
    • A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material. Each Feature may be packaged as a sub-directory in a directory named "features". Within a Feature, files named "feature.xml" may contain a list of the names and version numbers of the Plug-ins + and/or Fragments associated with that Feature.
    • +
    • Features may also include other Features ("Included Features"). Within a Feature, files named "feature.xml" may contain a list of the names and version numbers of Included Features.
    • +
    + +

    The terms and conditions governing Plug-ins and Fragments should be contained in files named "about.html" ("Abouts"). The terms and conditions governing Features and +Included Features should be contained in files named "license.html" ("Feature Licenses"). Abouts and Feature Licenses may be located in any directory of a Download or Module +including, but not limited to the following locations:

    + +
      +
    • The top-level (root) directory
    • +
    • Plug-in and Fragment directories
    • +
    • Inside Plug-ins and Fragments packaged as JARs
    • +
    • Sub-directories of the directory named "src" of certain Plug-ins
    • +
    • Feature directories
    • +
    + +

    Note: if a Feature made available by the Eclipse Foundation is installed using the Provisioning Technology (as defined below), you must agree to a license ("Feature Update License") during the +installation process. If the Feature contains Included Features, the Feature Update License should either provide you with the terms and conditions governing the Included Features or +inform you where you can locate them. Feature Update Licenses may be found in the "license" property of files named "feature.properties" found within a Feature. +Such Abouts, Feature Licenses, and Feature Update Licenses contain the terms and conditions (or references to such terms and conditions) that govern your use of the associated Content in +that directory.

    + +

    THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS. SOME OF THESE +OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):

    + + + +

    IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR TO USE OF THE CONTENT. If no About, Feature License, or Feature Update License is provided, please +contact the Eclipse Foundation to determine what terms and conditions govern that particular Content.

    + + +

    Use of Provisioning Technology

    + +

    The Eclipse Foundation makes available provisioning software, examples of which include, but are not limited to, p2 and the Eclipse + Update Manager ("Provisioning Technology") for the purpose of allowing users to install software, documentation, information and/or + other materials (collectively "Installable Software"). This capability is provided with the intent of allowing such users to + install, extend and update Eclipse-based products. Information about packaging Installable Software is available at http://eclipse.org/equinox/p2/repository_packaging.html + ("Specification").

    + +

    You may use Provisioning Technology to allow other parties to install Installable Software. You shall be responsible for enabling the + applicable license agreements relating to the Installable Software to be presented to, and accepted by, the users of the Provisioning Technology + in accordance with the Specification. By using Provisioning Technology in such a manner and making it available in accordance with the + Specification, you further acknowledge your agreement to, and the acquisition of all necessary rights to permit the following:

    + +
      +
    1. A series of actions may occur ("Provisioning Process") in which a user may execute the Provisioning Technology + on a machine ("Target Machine") with the intent of installing, extending or updating the functionality of an Eclipse-based + product.
    2. +
    3. During the Provisioning Process, the Provisioning Technology may cause third party Installable Software or a portion thereof to be + accessed and copied to the Target Machine.
    4. +
    5. Pursuant to the Specification, you will provide to the user the terms and conditions that govern the use of the Installable + Software ("Installable Software Agreement") and such Installable Software Agreement shall be accessed from the Target + Machine in accordance with the Specification. Such Installable Software Agreement must inform the user of the terms and conditions that govern + the Installable Software and must solicit acceptance by the end user in the manner prescribed in such Installable Software Agreement. Upon such + indication of agreement by the user, the provisioning Technology will complete installation of the Installable Software.
    6. +
    + +

    Cryptography

    + +

    Content may contain encryption software. The country in which you are currently may have restrictions on the import, possession, and use, and/or re-export to + another country, of encryption software. BEFORE using any encryption software, please check the country's laws, regulations and policies concerning the import, + possession, or use, and re-export of encryption software, to see if this is permitted.

    + +

    Java and all Java-based trademarks are trademarks of Oracle Corporation in the United States, other countries, or both.

    + + diff --git a/qt/org.eclipse.cdt.qt.core/.classpath b/qt/org.eclipse.cdt.qt.core/.classpath new file mode 100644 index 00000000000..ad32c83a788 --- /dev/null +++ b/qt/org.eclipse.cdt.qt.core/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/qt/org.eclipse.cdt.qt.core/.project b/qt/org.eclipse.cdt.qt.core/.project new file mode 100644 index 00000000000..a679b3bf3a9 --- /dev/null +++ b/qt/org.eclipse.cdt.qt.core/.project @@ -0,0 +1,28 @@ + + + org.eclipse.cdt.qt.core + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/qt/org.eclipse.cdt.qt.core/.settings/org.eclipse.jdt.core.prefs b/qt/org.eclipse.cdt.qt.core/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000000..c537b63063c --- /dev/null +++ b/qt/org.eclipse.cdt.qt.core/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/qt/org.eclipse.cdt.qt.core/META-INF/MANIFEST.MF b/qt/org.eclipse.cdt.qt.core/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..b4ca9e8d545 --- /dev/null +++ b/qt/org.eclipse.cdt.qt.core/META-INF/MANIFEST.MF @@ -0,0 +1,13 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: CDT Qt Support Core +Bundle-SymbolicName: org.eclipse.cdt.qt.core;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-Activator: org.eclipse.cdt.qt.core.Activator +Bundle-Vendor: Eclipse CDT +Require-Bundle: org.eclipse.core.runtime, + org.eclipse.core.resources;bundle-version="3.8.100", + org.eclipse.cdt.core +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Bundle-ActivationPolicy: lazy +Bundle-Localization: plugin diff --git a/qt/org.eclipse.cdt.qt.core/about.html b/qt/org.eclipse.cdt.qt.core/about.html new file mode 100644 index 00000000000..d7c511887d6 --- /dev/null +++ b/qt/org.eclipse.cdt.qt.core/about.html @@ -0,0 +1,24 @@ + + +About + + +

    About This Content

    + +

    June 22, 2007

    +

    License

    + +

    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 http://www.eclipse.org/legal/epl-v10.html. +For purposes of the EPL, "Program" will mean the Content.

    + +

    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 http://www.eclipse.org.

    + + \ No newline at end of file diff --git a/qt/org.eclipse.cdt.qt.core/build.properties b/qt/org.eclipse.cdt.qt.core/build.properties new file mode 100644 index 00000000000..09a194a7e88 --- /dev/null +++ b/qt/org.eclipse.cdt.qt.core/build.properties @@ -0,0 +1,8 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.xml,\ + templates/,\ + about.html +src.includes = about.html diff --git a/qt/org.eclipse.cdt.qt.core/plugin.properties b/qt/org.eclipse.cdt.qt.core/plugin.properties new file mode 100644 index 00000000000..0206fd12b0a --- /dev/null +++ b/qt/org.eclipse.cdt.qt.core/plugin.properties @@ -0,0 +1,2 @@ +qtProjectFile.name = Qt Project File +qmlFile.name = QML File diff --git a/qt/org.eclipse.cdt.qt.core/plugin.xml b/qt/org.eclipse.cdt.qt.core/plugin.xml new file mode 100644 index 00000000000..959e78450a5 --- /dev/null +++ b/qt/org.eclipse.cdt.qt.core/plugin.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/Activator.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/Activator.java new file mode 100644 index 00000000000..2e3a4ecd3a4 --- /dev/null +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/Activator.java @@ -0,0 +1,30 @@ +package org.eclipse.cdt.qt.core; + +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; + +public class Activator implements BundleActivator { + + private static BundleContext context; + + static BundleContext getContext() { + return context; + } + + /* + * (non-Javadoc) + * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext bundleContext) throws Exception { + Activator.context = bundleContext; + } + + /* + * (non-Javadoc) + * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext bundleContext) throws Exception { + Activator.context = null; + } + +} diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/QtNature.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/QtNature.java new file mode 100644 index 00000000000..f58e2cd190e --- /dev/null +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/QtNature.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2013 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: + * Doug Schaefer (QNX) - Initial implementation + *******************************************************************************/ +package org.eclipse.cdt.qt.core; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectNature; +import org.eclipse.core.runtime.CoreException; + +public class QtNature implements IProjectNature { + public static final String ID = "org.eclipse.cdt.qt.core.qtNature"; + + private IProject project; + + @Override + public void configure() throws CoreException { + } + + @Override + public void deconfigure() throws CoreException { + } + + @Override + public IProject getProject() { + return project; + } + + @Override + public void setProject(IProject project) { + this.project = project; + } + +} diff --git a/qt/org.eclipse.cdt.qt.core/templates/project/helloWorld/qtQuick2/Basename.cpp b/qt/org.eclipse.cdt.qt.core/templates/project/helloWorld/qtQuick2/Basename.cpp new file mode 100644 index 00000000000..0d4874b0b29 --- /dev/null +++ b/qt/org.eclipse.cdt.qt.core/templates/project/helloWorld/qtQuick2/Basename.cpp @@ -0,0 +1,12 @@ +#include +#include + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + QQuickView viewer(QStringLiteral("$(baseName).qml")); + viewer.show(); + + return app.exec(); +} diff --git a/qt/org.eclipse.cdt.qt.core/templates/project/helloWorld/qtQuick2/Basename.pro b/qt/org.eclipse.cdt.qt.core/templates/project/helloWorld/qtQuick2/Basename.pro new file mode 100644 index 00000000000..d8bd5026732 --- /dev/null +++ b/qt/org.eclipse.cdt.qt.core/templates/project/helloWorld/qtQuick2/Basename.pro @@ -0,0 +1,3 @@ +QT += qml quick + +SOURCES += {{baseName}}.cpp diff --git a/qt/org.eclipse.cdt.qt.core/templates/project/helloWorld/qtQuick2/Basename.qml b/qt/org.eclipse.cdt.qt.core/templates/project/helloWorld/qtQuick2/Basename.qml new file mode 100644 index 00000000000..2ff2ef6170c --- /dev/null +++ b/qt/org.eclipse.cdt.qt.core/templates/project/helloWorld/qtQuick2/Basename.qml @@ -0,0 +1,16 @@ +import QtQuick 2.0 + +Rectangle { + width: 360 + height: 360 + Text { + text: qsTr("Hello World from $(baseName)") + anchors.centerIn: parent + } + MouseArea { + anchors.fill: parent + onClicked: { + Qt.quit(); + } + } +} diff --git a/qt/org.eclipse.cdt.qt.core/templates/project/helloWorld/qtQuick2/Makefile b/qt/org.eclipse.cdt.qt.core/templates/project/helloWorld/qtQuick2/Makefile new file mode 100644 index 00000000000..5a41246df1d --- /dev/null +++ b/qt/org.eclipse.cdt.qt.core/templates/project/helloWorld/qtQuick2/Makefile @@ -0,0 +1,25 @@ +QMAKE = {{qmake}} + +all: debug release + +clean: clean-debug clean-release + +build-debug/Makefile: + @mkdir -p $(dir $@) + $(QMAKE) -o $@ {{baseName}}.pro CONFIG+=debug + +debug: build-debug/Makefile + $(MAKE) -w -C build-debug + +clean-debug: + rm -fr build-debug + +build-release/Makefile: + @mkdir -p $(dir $@) + $(QMAKE) -o $@ {{baseName}}.pro CONFIG+=release + +release: build-release/Makefile + $(MAKE) -w -C build-release + +clean-release: + rm -fr build-release diff --git a/qt/org.eclipse.cdt.qt.core/templates/project/helloWorld/qtQuick2/template.properties b/qt/org.eclipse.cdt.qt.core/templates/project/helloWorld/qtQuick2/template.properties new file mode 100644 index 00000000000..a8695c78663 --- /dev/null +++ b/qt/org.eclipse.cdt.qt.core/templates/project/helloWorld/qtQuick2/template.properties @@ -0,0 +1,18 @@ +############################################################################### +# Copyright (c) 2007 Symbian Software Private Ltd. 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: +# Bala Torati (Symbian) - initial API and implementation +############################################################################### + +#Template Default Values +QtHelloWorld.label=Hello World QtQuick2 Project +QtHelloWorld.description=A Hello World QtQuick2 Project +QtHelloWorld.basics.label=Basic Settings +QtHelloWorld.basics.description=Basic properties of a project +QtHelloWorld.qmake.label=qmake location +QtHelloWorld.qmake.description=Location of the qmake executable diff --git a/qt/org.eclipse.cdt.qt.core/templates/project/helloWorld/qtQuick2/template.xml b/qt/org.eclipse.cdt.qt.core/templates/project/helloWorld/qtQuick2/template.xml new file mode 100644 index 00000000000..58bdd9e8b00 --- /dev/null +++ b/qt/org.eclipse.cdt.qt.core/templates/project/helloWorld/qtQuick2/template.xml @@ -0,0 +1,65 @@ + + diff --git a/qt/org.eclipse.cdt.qt.ui/.classpath b/qt/org.eclipse.cdt.qt.ui/.classpath new file mode 100644 index 00000000000..ad32c83a788 --- /dev/null +++ b/qt/org.eclipse.cdt.qt.ui/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/qt/org.eclipse.cdt.qt.ui/.project b/qt/org.eclipse.cdt.qt.ui/.project new file mode 100644 index 00000000000..83277e4b223 --- /dev/null +++ b/qt/org.eclipse.cdt.qt.ui/.project @@ -0,0 +1,28 @@ + + + org.eclipse.cdt.qt.ui + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/qt/org.eclipse.cdt.qt.ui/.settings/org.eclipse.jdt.core.prefs b/qt/org.eclipse.cdt.qt.ui/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000000..c537b63063c --- /dev/null +++ b/qt/org.eclipse.cdt.qt.ui/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/qt/org.eclipse.cdt.qt.ui/META-INF/MANIFEST.MF b/qt/org.eclipse.cdt.qt.ui/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..50e19770980 --- /dev/null +++ b/qt/org.eclipse.cdt.qt.ui/META-INF/MANIFEST.MF @@ -0,0 +1,11 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: CDT Qt Support UI +Bundle-SymbolicName: org.eclipse.cdt.qt.ui +Bundle-Version: 1.0.0.qualifier +Bundle-Activator: org.eclipse.cdt.qt.ui.Activator +Bundle-Vendor: Eclipse CDT +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Bundle-ActivationPolicy: lazy diff --git a/qt/org.eclipse.cdt.qt.ui/about.html b/qt/org.eclipse.cdt.qt.ui/about.html new file mode 100644 index 00000000000..d7c511887d6 --- /dev/null +++ b/qt/org.eclipse.cdt.qt.ui/about.html @@ -0,0 +1,24 @@ + + +About + + +

    About This Content

    + +

    June 22, 2007

    +

    License

    + +

    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 http://www.eclipse.org/legal/epl-v10.html. +For purposes of the EPL, "Program" will mean the Content.

    + +

    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 http://www.eclipse.org.

    + + \ No newline at end of file diff --git a/qt/org.eclipse.cdt.qt.ui/build.properties b/qt/org.eclipse.cdt.qt.ui/build.properties new file mode 100644 index 00000000000..34d2e4d2dad --- /dev/null +++ b/qt/org.eclipse.cdt.qt.ui/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/qt/ui/Activator.java b/qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/qt/ui/Activator.java new file mode 100644 index 00000000000..5d1039b2ae0 --- /dev/null +++ b/qt/org.eclipse.cdt.qt.ui/src/org/eclipse/cdt/qt/ui/Activator.java @@ -0,0 +1,50 @@ +package org.eclipse.cdt.qt.ui; + +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "org.eclipse.cdt.qt.ui"; //$NON-NLS-1$ + + // The shared instance + private static Activator plugin; + + /** + * The constructor + */ + public Activator() { + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + +} diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/AllXlcErrorParserTests.java b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/AllXlcErrorParserTests.java index f8973e86fb7..4b82f75b2e7 100644 --- a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/AllXlcErrorParserTests.java +++ b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/AllXlcErrorParserTests.java @@ -19,26 +19,34 @@ public class AllXlcErrorParserTests { } public static Test suite() { - TestSuite suite = new TestSuite( - "Testsuite for xlc compiler error parser"); + TestSuite suite = new TestSuite("Testsuite for xlc compiler error parser"); //$JUnit-BEGIN$ - suite.addTestSuite(TestUndeclIdent.class); - suite.addTestSuite(TestMissingArg.class); - suite.addTestSuite(TestFloatingPoint.class); - suite.addTestSuite(TestFuncArg.class); - suite.addTestSuite(TestOperModi.class); - suite.addTestSuite(TestConditional.class); - suite.addTestSuite(TestSyntaxError.class); - suite.addTestSuite(TestNoFuncProto.class); + suite.addTestSuite(TestInformationalMessage_1.class); + suite.addTestSuite(TestInformationalMessage_2.class); + suite.addTestSuite(TestInformationalMessage_3.class); + suite.addTestSuite(TestWarning_1.class); + suite.addTestSuite(TestError_1.class); + suite.addTestSuite(TestSevereError_1.class); + suite.addTestSuite(TestSevereError_2.class); + suite.addTestSuite(TestSevereError_3.class); + suite.addTestSuite(TestSevereError_4.class); + suite.addTestSuite(TestSevereError_5.class); + suite.addTestSuite(TestUnrecoverableError_1.class); + suite.addTestSuite(TestUnrecoverableError_2.class); + suite.addTestSuite(TestUnrecoverableError_3.class); + suite.addTestSuite(TestCompatibility.class); - suite.addTestSuite(TestUnrecoverableError.class); suite.addTestSuite(TestRedefinition.class); suite.addTestSuite(TestRedeclaration.class); + suite.addTestSuite(TestCommandOptionNotRecognized.class); + + suite.addTestSuite(TestLinkerCommandOptionNotRecognized.class); suite.addTestSuite(TestLinkerUndefinedSymbol.class); suite.addTestSuite(TestLinkerDuplicateSymbol.class); suite.addTestSuite(TestLinkerSevereError.class); suite.addTestSuite(TestLinkerErrorWhileReading.class); suite.addTestSuite(TestLinkerInfo.class); + //$JUnit-END$ return suite; } diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestCommandOptionNotRecognized.java b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestCommandOptionNotRecognized.java new file mode 100644 index 00000000000..6a69a3930ae --- /dev/null +++ b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestCommandOptionNotRecognized.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * 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.errorparsers.xlc.tests; + +import junit.framework.TestCase; + +import org.eclipse.cdt.core.IMarkerGenerator; + +public class TestCommandOptionNotRecognized extends TestCase { + String err_msg; + /** + * This function tests parseLine function of the + * XlcErrorParser class. A warning message generated by + * xlc compiler about command options is given as + * input for testing. + */ + public void testparseLine() + { + XlcErrorParserTester aix = new XlcErrorParserTester(); + aix.parseLine(err_msg); + assertEquals("", aix.getFileName(0)); + assertEquals(0, aix.getLineNumber(0)); + assertEquals(IMarkerGenerator.SEVERITY_WARNING, aix.getSeverity(0)); + assertEquals("command option 9 is not recognized - passed to ld",aix.getMessage(0)); + } + public TestCommandOptionNotRecognized(String name) + { + super(name); + err_msg = "/usr/vacpp/bin/xlc: 1501-216 command option 9 is not recognized - passed to ld"; + } +} diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestMissingArg.java b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestError_1.java similarity index 94% rename from xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestMissingArg.java rename to xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestError_1.java index 6038d0b312d..c43dd1743cb 100644 --- a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestMissingArg.java +++ b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestError_1.java @@ -16,7 +16,7 @@ import junit.framework.TestCase; import org.eclipse.cdt.core.IMarkerGenerator; -public class TestMissingArg extends TestCase { +public class TestError_1 extends TestCase { String err_msg; /** * This function tests parseLine function of the @@ -33,7 +33,7 @@ public class TestMissingArg extends TestCase { assertEquals(IMarkerGenerator.SEVERITY_ERROR_RESOURCE, aix.getSeverity(0)); assertEquals("Missing argument(s).",aix.getMessage(0)); } - public TestMissingArg( String name) + public TestError_1( String name) { super(name); err_msg = "\"temp8.c\", line 9.17: 1506-098 (E) " diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestConditional.java b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestInformationalMessage_1.java similarity index 92% rename from xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestConditional.java rename to xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestInformationalMessage_1.java index e75f305d4fe..4751d1a7f30 100644 --- a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestConditional.java +++ b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestInformationalMessage_1.java @@ -16,7 +16,7 @@ import junit.framework.TestCase; import org.eclipse.cdt.core.IMarkerGenerator; -public class TestConditional extends TestCase { +public class TestInformationalMessage_1 extends TestCase { String err_msg; /** * This function tests parseLine function of the @@ -32,7 +32,7 @@ public class TestConditional extends TestCase { assertEquals(IMarkerGenerator.SEVERITY_INFO, aix.getSeverity(0)); assertEquals("The then branch of conditional is an empty statement.",aix.getMessage(0)); } - public TestConditional( String name) + public TestInformationalMessage_1( String name) { super(name); err_msg = "\"temp8.c\", line 12.9: 1506-478 (I) " + diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestInformationalMessage_2.java b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestInformationalMessage_2.java new file mode 100644 index 00000000000..f2096b2794a --- /dev/null +++ b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestInformationalMessage_2.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * 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.errorparsers.xlc.tests; + +import junit.framework.TestCase; + +import org.eclipse.cdt.core.IMarkerGenerator; + +public class TestInformationalMessage_2 extends TestCase { + String err_msg; + /** + * This function tests parseLine function of the + * XlcErrorParser class. A variant of informational message generated by + * xlc compiler with no file or line is given as + * input for testing. + */ + public void testparseLine() + { + XlcErrorParserTester aix = new XlcErrorParserTester(); + aix.parseLine(err_msg); + assertEquals("", aix.getFileName(0)); + assertEquals(0, aix.getLineNumber(0)); + assertEquals(IMarkerGenerator.SEVERITY_INFO, aix.getSeverity(0)); + assertEquals("clazz::fun(): Additional optimization may be attained by recompiling and specifying MAXMEM option with a value greater than 8192.",aix.getMessage(0)); + } + public TestInformationalMessage_2( String name) + { + super(name); + err_msg = " 1500-030: (I) INFORMATION: clazz::fun(): Additional optimization may be attained by recompiling and specifying MAXMEM option with a value greater than 8192."; + } +} diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestInformationalMessage_3.java b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestInformationalMessage_3.java new file mode 100644 index 00000000000..c68072051e5 --- /dev/null +++ b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestInformationalMessage_3.java @@ -0,0 +1,38 @@ +/******************************************************************************* + * 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.errorparsers.xlc.tests; + +import junit.framework.TestCase; + +import org.eclipse.cdt.core.IMarkerGenerator; + +public class TestInformationalMessage_3 extends TestCase { + String err_msg; + /** + * This function tests parseLine function of the + * XlcErrorParser class. A variant of informational message generated by + * xlc compiler is given as input for testing. + */ + public void testparseLine() + { + XlcErrorParserTester aix = new XlcErrorParserTester(); + aix.parseLine(err_msg); + assertEquals("", aix.getFileName(0)); + assertEquals(0, aix.getLineNumber(0)); + assertEquals(IMarkerGenerator.SEVERITY_INFO, aix.getSeverity(0)); + assertEquals("Global variable \"__td __td__Q2_3std13runtime_error\" is not used.",aix.getMessage(0)); + } + public TestInformationalMessage_3( String name) + { + super(name); + err_msg = "1540-5336 (I) Global variable \"__td __td__Q2_3std13runtime_error\" is not used."; + } +} diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestLinkerCommandOptionNotRecognized.java b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestLinkerCommandOptionNotRecognized.java new file mode 100644 index 00000000000..ce83c6d716f --- /dev/null +++ b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestLinkerCommandOptionNotRecognized.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2006, 2009 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 + *******************************************************************************/ + +package org.eclipse.cdt.errorparsers.xlc.tests; + +import junit.framework.TestCase; + +import org.eclipse.cdt.core.IMarkerGenerator; + +public class TestLinkerCommandOptionNotRecognized extends TestCase { + String err_msg; + /** + * This function tests parseLine function of the + * XlcErrorParser class. A warning message generated by + * xlc linker about command options is given as + * input for testing. + */ + public void testparseLine() + { + XlcErrorParserTester aix = new XlcErrorParserTester(); + aix.parseLine(err_msg); + assertEquals("", aix.getFileName(0)); + assertEquals(0, aix.getLineNumber(0)); + assertEquals(IMarkerGenerator.SEVERITY_WARNING, aix.getSeverity(0)); + assertEquals("The -9 flag is not recognized.",aix.getMessage(0)); + } + public TestLinkerCommandOptionNotRecognized(String name) + { + super(name); + err_msg = "ld: 0706-012 The -9 flag is not recognized."; + } +} diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestSyntaxError.java b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestSevereError_1.java similarity index 93% rename from xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestSyntaxError.java rename to xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestSevereError_1.java index 280ee47820d..22d8cec3a3f 100644 --- a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestSyntaxError.java +++ b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestSevereError_1.java @@ -14,7 +14,7 @@ import junit.framework.TestCase; import org.eclipse.cdt.core.IMarkerGenerator; -public class TestSyntaxError extends TestCase { +public class TestSevereError_1 extends TestCase { String err_msg; /** * This function tests parseLine function of the @@ -31,7 +31,7 @@ public class TestSyntaxError extends TestCase { assertEquals(IMarkerGenerator.SEVERITY_ERROR_RESOURCE, aix.getSeverity(0)); assertEquals("Syntax error: possible missing ')'?",aix.getMessage(0)); } - public TestSyntaxError( String name) + public TestSevereError_1( String name) { super(name); err_msg = "\"temp1.c\", line 5.1: 1506-276 (S) " diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestUndeclIdent.java b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestSevereError_2.java similarity index 93% rename from xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestUndeclIdent.java rename to xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestSevereError_2.java index 0fc1b80145b..6f6f3b7e040 100644 --- a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestUndeclIdent.java +++ b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestSevereError_2.java @@ -15,7 +15,7 @@ import junit.framework.TestCase; import org.eclipse.cdt.core.IMarkerGenerator; -public class TestUndeclIdent extends TestCase { +public class TestSevereError_2 extends TestCase { String err_msg; /** * This function tests parseLine function of the @@ -32,7 +32,7 @@ public class TestUndeclIdent extends TestCase { assertEquals(IMarkerGenerator.SEVERITY_ERROR_RESOURCE, aix.getSeverity(0)); assertEquals("Undeclared identifier y.",aix.getMessage(0)); } - public TestUndeclIdent( String name) + public TestSevereError_2( String name) { super(name); err_msg = "\"temp5.c\", line 5.9: 1506-045 (S) " + diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestFloatingPoint.java b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestSevereError_3.java similarity index 93% rename from xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestFloatingPoint.java rename to xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestSevereError_3.java index a48256b88dd..6aebad7b05b 100644 --- a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestFloatingPoint.java +++ b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestSevereError_3.java @@ -16,7 +16,7 @@ import junit.framework.TestCase; import org.eclipse.cdt.core.IMarkerGenerator; -public class TestFloatingPoint extends TestCase { +public class TestSevereError_3 extends TestCase { String err_msg; /** * This function tests parseLine function of the @@ -34,7 +34,7 @@ public class TestFloatingPoint extends TestCase { assertEquals("Floating point constant 10.23.3 is not valid", aix.getMessage(0)); } - public TestFloatingPoint( String name) + public TestSevereError_3( String name) { super(name); err_msg = "\"temp9.c\", line 11.18: 1506-189 (S) " + diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestFuncArg.java b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestSevereError_4.java similarity index 94% rename from xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestFuncArg.java rename to xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestSevereError_4.java index 9a4ee2c56f0..eac63f5e2bf 100644 --- a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestFuncArg.java +++ b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestSevereError_4.java @@ -15,7 +15,7 @@ import junit.framework.TestCase; import org.eclipse.cdt.core.IMarkerGenerator; -public class TestFuncArg extends TestCase { +public class TestSevereError_4 extends TestCase { String err_msg; /** * This function tests parseLine function of the @@ -34,7 +34,7 @@ public class TestFuncArg extends TestCase { "\"int\" and \"char*\" is not allowed.", aix.getMessage(0)); } - public TestFuncArg( String name) + public TestSevereError_4( String name) { super(name); err_msg = "\"temp9.c\", line 12.18: 1506-280 (S) " + diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestOperModi.java b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestSevereError_5.java similarity index 93% rename from xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestOperModi.java rename to xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestSevereError_5.java index fa1f6997896..471ae87a030 100644 --- a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestOperModi.java +++ b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestSevereError_5.java @@ -15,7 +15,7 @@ import junit.framework.TestCase; import org.eclipse.cdt.core.IMarkerGenerator; -public class TestOperModi extends TestCase { +public class TestSevereError_5 extends TestCase { String err_msg; /** * This function tests parseLine function of the @@ -32,7 +32,7 @@ public class TestOperModi extends TestCase { assertEquals(IMarkerGenerator.SEVERITY_ERROR_RESOURCE, aix.getSeverity(0)); assertEquals("Operand must be a modifiable lvalue.",aix.getMessage(0)); } - public TestOperModi( String name) + public TestSevereError_5( String name) { super(name); err_msg = "\"temp9.c\", line 13.9: 1506-025 (S) " + diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestUnrecoverableError.java b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestUnrecoverableError_1.java similarity index 92% rename from xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestUnrecoverableError.java rename to xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestUnrecoverableError_1.java index ee9962c0e7f..19c731ded82 100644 --- a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestUnrecoverableError.java +++ b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestUnrecoverableError_1.java @@ -14,7 +14,7 @@ import junit.framework.TestCase; import org.eclipse.cdt.core.IMarkerGenerator; -public class TestUnrecoverableError extends TestCase { +public class TestUnrecoverableError_1 extends TestCase { String err_msg; /** * This function tests parseLine function of the @@ -31,7 +31,7 @@ public class TestUnrecoverableError extends TestCase { assertEquals(IMarkerGenerator.SEVERITY_ERROR_RESOURCE, aix.getSeverity(0)); assertEquals("INTERNAL COMPILER ERROR",aix.getMessage(0)); } - public TestUnrecoverableError( String name) + public TestUnrecoverableError_1( String name) { super(name); err_msg = "\"temp1.c\", line 5.1: 1506-001 (U) " diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestUnrecoverableError_2.java b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestUnrecoverableError_2.java new file mode 100644 index 00000000000..78521af2ab8 --- /dev/null +++ b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestUnrecoverableError_2.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * 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.errorparsers.xlc.tests; + +import junit.framework.TestCase; + +import org.eclipse.cdt.core.IMarkerGenerator; + +public class TestUnrecoverableError_2 extends TestCase { + String err_msg; + /** + * This function tests parseLine function of the + * XlcErrorParser class. A variant of error message generated by + * xlc compiler with unrecoverable severity (U) is given as + * input for testing. + */ + public void testparseLine() + { + XlcErrorParserTester aix = new XlcErrorParserTester(); + aix.parseLine(err_msg); + assertEquals("", aix.getFileName(0)); + assertEquals(0, aix.getLineNumber(0)); + assertEquals(IMarkerGenerator.SEVERITY_ERROR_RESOURCE, aix.getSeverity(0)); + assertEquals("An error occurred during code generation. The code generation return code was 1.",aix.getMessage(0)); + } + public TestUnrecoverableError_2( String name) + { + super(name); + err_msg = "1586-346 (U) An error occurred during code generation. The code generation return code was 1."; + } +} diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestUnrecoverableError_3.java b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestUnrecoverableError_3.java new file mode 100644 index 00000000000..a26d941a2ec --- /dev/null +++ b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestUnrecoverableError_3.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * 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.errorparsers.xlc.tests; + +import junit.framework.TestCase; + +import org.eclipse.cdt.core.IMarkerGenerator; + +public class TestUnrecoverableError_3 extends TestCase { + String err_msg; + /** + * This function tests parseLine function of the + * XlcErrorParser class. A variant of error message generated by + * xlc compiler with unrecoverable severity (U) is given as + * input for testing. + */ + public void testparseLine() + { + XlcErrorParserTester aix = new XlcErrorParserTester(); + aix.parseLine(err_msg); + assertEquals("", aix.getFileName(0)); + assertEquals(0, aix.getLineNumber(0)); + assertEquals(IMarkerGenerator.SEVERITY_ERROR_RESOURCE, aix.getSeverity(0)); + assertEquals("INTERNAL COMPILER ERROR while compiling ----. Compilation ended. Contact your Service Representative and provide the following information: Internal abort. For more information visit: http://www.ibm.com/support/docview.wss?uid=swg21110810",aix.getMessage(0)); + } + public TestUnrecoverableError_3( String name) + { + super(name); + err_msg = " 1500-004: (U) INTERNAL COMPILER ERROR while compiling ----. Compilation ended. Contact your Service Representative and provide the following information: Internal abort. For more information visit: http://www.ibm.com/support/docview.wss?uid=swg21110810"; + } +} diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestNoFuncProto.java b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestWarning_1.java similarity index 93% rename from xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestNoFuncProto.java rename to xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestWarning_1.java index f212db3e16a..606f601b25f 100644 --- a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestNoFuncProto.java +++ b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/src/org/eclipse/cdt/errorparsers/xlc/tests/TestWarning_1.java @@ -14,7 +14,7 @@ import junit.framework.TestCase; import org.eclipse.cdt.core.IMarkerGenerator; -public class TestNoFuncProto extends TestCase { +public class TestWarning_1 extends TestCase { String err_msg; /** * This function tests parseLine function of the @@ -30,7 +30,7 @@ public class TestNoFuncProto extends TestCase { assertEquals(IMarkerGenerator.SEVERITY_WARNING, aix.getSeverity(0)); assertEquals("No function prototype given for \"printf\".",aix.getMessage(0)); } - public TestNoFuncProto( String name) + public TestWarning_1( String name) { super(name); err_msg = "\"temp1.c\", line 5.9: 1506-304 (W) " diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc/plugin.properties b/xlc/org.eclipse.cdt.errorparsers.xlc/plugin.properties index 405a9e7419a..cef2c77ad87 100644 --- a/xlc/org.eclipse.cdt.errorparsers.xlc/plugin.properties +++ b/xlc/org.eclipse.cdt.errorparsers.xlc/plugin.properties @@ -35,10 +35,19 @@ CDTXLCErrorParser.pattern.redeclaration.crossreference=Redeclaration of $4 diffe CDTXLCErrorParser.pattern.error="?([^"]*)"?, line ([0-9]+)\\.[0-9]+:( [0-9]*-[0-9]*)? \\([USE]\\)\\s*(.*) CDTXLCErrorParser.pattern.warning="?([^"]*)"?, line ([0-9]+)\\.[0-9]+:( [0-9]*-[0-9]*)? \\(W\\)\\s*(.*) CDTXLCErrorParser.pattern.info="?([^"]*)"?, line ([0-9]+)\\.[0-9]+:( [0-9]*-[0-9]*)? \\(I\\)\\s*(.*) +# 1586-346 (U) An error occurred during code generation. The code generation return code was 1. +CDTXLCErrorParser.pattern.error2=\\s*([0-9]*-[0-9]*:?)? \\([USE]\\)\\s*(.*) +# /usr/vacpp/bin/xlc: 1501-216 command option 9 is not recognized - passed to ld +CDTXLCErrorParser.pattern.warning2=/[/\\w]+: [0-9]+-[0-9]+\\s*(.*) +# 1500-030: (I) INFORMATION: clazz::fun(): Additional optimization may be attained by recompiling and specifying MAXMEM option with a value greater than 8192. +# 1540-5336 (I) Global variable "__td __td__Q2_3std13runtime_error" is not used. +CDTXLCErrorParser.pattern.info2=\\s*([0-9]*-[0-9]*:?)? \\(I\\)( INFORMATION:)?\\s*(.*) # ld: 0711-224 WARNING: Duplicate symbol: symboldupe # WARNING, ERROR, SEVERE ERROR etc. CDTXLCErrorParser.pattern.ld.error=ld: ([0-9]+-[0-9]+).*ERROR:\\s*(.*) CDTXLCErrorParser.pattern.ld.warning=ld: ([0-9]+-[0-9]+)\\s*WARNING:\\s*(.*) +# ld: 0706-012 The -9 flag is not recognized. +CDTXLCErrorParser.pattern.ld.warning2=ld: 0706-012\\s*(.*) # ld: 0711-987 Error occurred while reading file CDTXLCErrorParser.pattern.ld.error2=ld: ([0-9]+-[0-9]+)\\s*(Error .*) # ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information. diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc/plugin.xml b/xlc/org.eclipse.cdt.errorparsers.xlc/plugin.xml index 7fde01587b6..dff6bff116d 100644 --- a/xlc/org.eclipse.cdt.errorparsers.xlc/plugin.xml +++ b/xlc/org.eclipse.cdt.errorparsers.xlc/plugin.xml @@ -11,11 +11,15 @@ + + + +