From 758ce684d36feec29b37382a71f804ae5e9fc364 Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Fri, 11 May 2012 17:07:36 -0700 Subject: [PATCH 01/38] Minor comment adjustment. --- .../cdt/internal/core/pdom/indexer/PDOMUpdateTask.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMUpdateTask.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMUpdateTask.java index df8621199c4..8dabd9b1a34 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMUpdateTask.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMUpdateTask.java @@ -260,8 +260,8 @@ public class PDOMUpdateTask implements IPDOMIndexerTask { */ private boolean fileIsNotOlderThanTimestamp(String filename, long timestamp) { // We are subtracting 1 second from the timestamp to account for limited precision - // of File.lastModified() method and possible asynchrony between clocks on multi-CPU - // systems. This may produce false positives, but they are pretty harmless. + // of File.lastModified() method and possible skew between clocks on a multi-CPU + // system. This may produce false positives, but they are pretty harmless. return new File(filename).lastModified() >= timestamp - 1000; } From e9d7946b5a914eba0e625538edcefc95e1c9b7e4 Mon Sep 17 00:00:00 2001 From: Andrew Gvozdev Date: Sat, 12 May 2012 10:45:58 -0400 Subject: [PATCH 02/38] bug 378978: [sd90] Reduce scope of scheduling rule by creating language.settings.xml in advance --- .../LanguageSettingsProvidersSerializer.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsProvidersSerializer.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsProvidersSerializer.java index 9b6224f89f1..c0a2788cc61 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsProvidersSerializer.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsProvidersSerializer.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.language.settings.providers; +import java.io.ByteArrayInputStream; import java.net.URI; import java.util.ArrayList; import java.util.Collection; @@ -916,7 +917,19 @@ public class LanguageSettingsProvidersSerializer { } } if (folder.isAccessible()) { - rule = folder; + // Create dummy file to reduce scheduling to the file itself + if (!fileStorePrj.exists()) { + try { + fileStorePrj.create(new ByteArrayInputStream("".getBytes()), true, null); //$NON-NLS-1$ + } catch (CoreException e) { + CCorePlugin.log(e); + } + } + if (fileStorePrj.exists()) { + rule = fileStorePrj; + } else { + rule = folder; + } } } if (rule == null) { From de2ec5102b69a4e45a7cdc0ae04f27a018923229 Mon Sep 17 00:00:00 2001 From: Andrew Gvozdev Date: Sun, 13 May 2012 08:37:02 -0400 Subject: [PATCH 03/38] Revert "bug 378978: [sd90] Reduce scope of scheduling rule by creating language.settings.xml in advance" This reverts commit e9d7946b5a914eba0e625538edcefc95e1c9b7e4. --- .../LanguageSettingsProvidersSerializer.java | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsProvidersSerializer.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsProvidersSerializer.java index c0a2788cc61..9b6224f89f1 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsProvidersSerializer.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsProvidersSerializer.java @@ -10,7 +10,6 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.language.settings.providers; -import java.io.ByteArrayInputStream; import java.net.URI; import java.util.ArrayList; import java.util.Collection; @@ -917,19 +916,7 @@ public class LanguageSettingsProvidersSerializer { } } if (folder.isAccessible()) { - // Create dummy file to reduce scheduling to the file itself - if (!fileStorePrj.exists()) { - try { - fileStorePrj.create(new ByteArrayInputStream("".getBytes()), true, null); //$NON-NLS-1$ - } catch (CoreException e) { - CCorePlugin.log(e); - } - } - if (fileStorePrj.exists()) { - rule = fileStorePrj; - } else { - rule = folder; - } + rule = folder; } } if (rule == null) { From af1c5c31d1dd6ec111ed9262ca8fdbcb22e2e37f Mon Sep 17 00:00:00 2001 From: Marc-Andre Laperle Date: Sun, 13 May 2012 13:45:31 -0400 Subject: [PATCH 04/38] Bug 368611 - Bogus warning in template partial specialization --- .../ClassMembersInitializationChecker.java | 37 ++++++++++++++++++- ...ClassMembersInitializationCheckerTest.java | 24 ++++++++++++ 2 files changed, 59 insertions(+), 2 deletions(-) diff --git a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/ClassMembersInitializationChecker.java b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/ClassMembersInitializationChecker.java index f73999e63a0..96424e7596f 100644 --- a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/ClassMembersInitializationChecker.java +++ b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/ClassMembersInitializationChecker.java @@ -43,6 +43,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction; import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType; +import org.eclipse.cdt.core.index.IIndex; +import org.eclipse.cdt.core.index.IIndexBinding; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVariableReadWriteFlags; import org.eclipse.cdt.internal.core.pdom.dom.PDOMName; @@ -171,9 +173,10 @@ public class ClassMembersInitializationChecker extends AbstractIndexAstChecker { Set actualConstructorFields = constructorsStack.peek(); if (!actualConstructorFields.isEmpty()) { IBinding binding = name.resolveBinding(); - if (actualConstructorFields.contains(binding)) { + IField equivalentFieldBinding = getContainedEquivalentBinding(actualConstructorFields, binding, name.getTranslationUnit().getIndex()); + if (equivalentFieldBinding != null) { if ((CPPVariableReadWriteFlags.getReadWriteFlags(name) & PDOMName.WRITE_ACCESS) != 0) { - actualConstructorFields.remove(binding); + actualConstructorFields.remove(equivalentFieldBinding); } } } @@ -181,6 +184,36 @@ public class ClassMembersInitializationChecker extends AbstractIndexAstChecker { return PROCESS_CONTINUE; } + private IField getContainedEquivalentBinding(Iterable fields, IBinding binding, IIndex index) { + for (IField field : fields) { + if (areEquivalentBindings(binding, field, index)) { + return field; + } + } + + return null; + } + + private boolean areEquivalentBindings(IBinding binding1, IBinding binding2, IIndex index) { + if (binding1.equals(binding2)) { + return true; + } + if ((binding1 instanceof IIndexBinding) != (binding2 instanceof IIndexBinding) && index != null) { + if (binding1 instanceof IIndexBinding) { + binding2 = index.adaptBinding(binding2); + } else { + binding1 = index.adaptBinding(binding1); + } + if (binding1 == null || binding2 == null) { + return false; + } + if (binding1.equals(binding2)) { + return true; + } + } + return false; + } + /** Checks whether class member of the specified type should be initialized * * @param type Type to check diff --git a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/ClassMembersInitializationCheckerTest.java b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/ClassMembersInitializationCheckerTest.java index 55a23193970..40b6a97aa6f 100644 --- a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/ClassMembersInitializationCheckerTest.java +++ b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/ClassMembersInitializationCheckerTest.java @@ -543,4 +543,28 @@ public class ClassMembersInitializationCheckerTest extends CheckerTestCase { loadCodeAndRun(getAboveComment()); checkNoErrors(); } + + //@file:test.h + //template + //struct B; + + //@file:test.cpp + //#include "test.h" + // + //template + //struct A { + //}; + // + //template + //struct B > { + // const A& obj; + // B(const A& o) : obj(o) {} + //}; + public void testBug368611_templatePartialSpecialization() throws Exception { + CharSequence[] code = getContents(2); + loadcode(code[0].toString()); + loadcode(code[1].toString()); + runOnProject(); + checkNoErrors(); + } } From 0ea6b2101ac0c4d3c02855265f4e4ee4fa930b21 Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Sun, 13 May 2012 13:08:49 -0700 Subject: [PATCH 05/38] Cosmetics. --- .../cdt/core/parser/util/CharArraySet.java | 42 ++++++------- .../cdt/core/parser/util/CharTable.java | 60 +++++++++---------- .../pdom/CProjectDescriptionListener.java | 5 +- 3 files changed, 50 insertions(+), 57 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/CharArraySet.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/CharArraySet.java index 723c5c4b116..70bf26f253b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/CharArraySet.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/CharArraySet.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Andrew Niefer (IBM Corporation) - Initial API and implementation + * Andrew Niefer (IBM Corporation) - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.core.parser.util; @@ -15,47 +15,47 @@ import java.util.List; public class CharArraySet extends CharTable { - public static final CharArraySet EMPTY_SET = new CharArraySet( 0 ){ + public static final CharArraySet EMPTY_SET = new CharArraySet(0) { @Override - public Object clone() { return this; } + public Object clone() { return this; } @Override - public List toList() { return Collections.emptyList(); } + public List toList() { return Collections.emptyList(); } @Override - public void put( char[] key ) { throw new UnsupportedOperationException(); } + public void put(char[] key) { throw new UnsupportedOperationException(); } @Override - public void addAll( List list ) { throw new UnsupportedOperationException(); } + public void addAll(List list) { throw new UnsupportedOperationException(); } @Override - public void addAll( CharArraySet set ) { throw new UnsupportedOperationException(); } + public void addAll(CharArraySet set) { throw new UnsupportedOperationException(); } }; public CharArraySet(int initialSize) { super(initialSize); } - public void put(char[] key ){ + public void put(char[] key) { addIndex(key); } - public void addAll( List list ){ - if( list == null ) + public void addAll(List list) { + if (list == null) return; int size = list.size(); - for( int i = 0; i < size; i++ ){ - addIndex( list.get( i ) ); + for (int i = 0; i < size; i++) { + addIndex(list.get(i)); } } - public void addAll( CharArraySet set ){ - if( set == null ) + public void addAll(CharArraySet set) { + if (set == null) return; int size = set.size(); - for( int i = 0; i < size; i++ ){ - addIndex( set.keyAt( i ) ); + for (int i = 0; i < size; i++) { + addIndex(set.keyAt(i)); } } - final public boolean remove( char[] key ) { + final public boolean remove(char[] key) { int i = lookup(key); if (i < 0) return false; @@ -65,11 +65,11 @@ public class CharArraySet extends CharTable { } @Override - final public void clear(){ - for( int i = 0; i < keyTable.length; i++ ){ + final public void clear() { + for (int i = 0; i < keyTable.length; i++) { keyTable[i] = null; - hashTable[ 2*i ] = 0; - hashTable[ 2*i + 1 ] = 0; + hashTable[2 * i] = 0; + hashTable[2 * i + 1] = 0; nextTable[i] = 0; } currEntry = -1; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/CharTable.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/CharTable.java index 65b338630ec..821a93d9560 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/CharTable.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/CharTable.java @@ -10,7 +10,6 @@ * Markus Schorn (Wind River Systems) * Andrew Ferguson (Symbian) *******************************************************************************/ - package org.eclipse.cdt.core.parser.util; import java.util.ArrayList; @@ -18,7 +17,6 @@ import java.util.List; /** * @author ddaoust - * */ public class CharTable extends HashTable { protected char[][] keyTable; @@ -39,12 +37,12 @@ public class CharTable extends HashTable { @Override public void clear() { super.clear(); - for( int i = 0; i < capacity(); i++ ) + for (int i = 0; i < capacity(); i++) keyTable[i] = null; } @Override - public Object clone(){ + public Object clone() { CharTable newTable = (CharTable) super.clone(); int size = capacity(); @@ -59,53 +57,49 @@ public class CharTable extends HashTable { } @Override - protected final int hash( int pos ){ + protected final int hash(int pos) { return hash(keyTable[pos], 0, keyTable[pos].length); } - protected final int hash( char[] obj ){ - return hash( obj, 0, obj.length ); + protected final int hash(char[] obj) { + return hash(obj, 0, obj.length); } - protected final int addIndex(char[] buffer ) { + protected final int addIndex(char[] buffer) { return addIndex(buffer, 0, buffer.length); } public final int addIndex(char[] buffer, int start, int len) { - if (hashTable != null) - { + if (hashTable != null) { int hash = hash(buffer, start, len); int pos = lookup(buffer, start, len, hash); if (pos != -1) return pos; // key is not here, add it. - if( (currEntry + 1) >= capacity()) { + if ((currEntry + 1) >= capacity()) { resize(); hash = hash(buffer, start, len); } currEntry++; keyTable[currEntry] = CharArrayUtils.extract(buffer, start, len); linkIntoHashTable(currEntry, hash); - } - else - { + } else { int pos = lookup(buffer, start, len); if (pos != -1) return pos; // key is not here, add it. - if( (currEntry + 1) >= capacity()) { + if ((currEntry + 1) >= capacity()) { resize(); - if( capacity() > minHashSize ){ + if (capacity() > minHashSize) { //if we grew from list to hash, then recurse and add as a hashtable - return addIndex( buffer, start, len ); + return addIndex(buffer, start, len); } } currEntry++; keyTable[currEntry] = CharArrayUtils.extract(buffer, start, len); } return currEntry; - } protected void removeEntry(int i) { @@ -120,17 +114,17 @@ public class CharTable extends HashTable { removeEntry(i, hash); } - public List toList(){ - List list = new ArrayList( size() ); + public List toList() { + List list = new ArrayList(size()); int size = size(); - for( int i = 0; i < size; i++ ){ - list.add( keyAt( i ) ); + for (int i = 0; i < size; i++) { + list.add(keyAt(i)); } return list; } - public final char[] keyAt( int i ){ - if( i < 0 || i > currEntry ) + public final char[] keyAt(int i) { + if (i < 0 || i > currEntry) return null; return keyTable[ i ]; @@ -140,25 +134,25 @@ public class CharTable extends HashTable { return lookup(key, start, len) != -1; } - public final boolean containsKey(char[] key){ + public final boolean containsKey(char[] key) { return lookup(key) != -1; } - public final char[] findKey( char[] buffer, int start, int len ){ - int idx = lookup( buffer, start, len ); - if( idx == -1 ) + public final char[] findKey(char[] buffer, int start, int len) { + int idx = lookup(buffer, start, len); + if (idx == -1) return null; return keyTable[ idx ]; } - public int lookup(char[] buffer ){ + public int lookup(char[] buffer) { return lookup(buffer, 0, buffer.length); } protected final int lookup(char[] buffer, int start, int len) { if (hashTable != null) - return lookup(buffer, start, len, hash(buffer, start, len) ); + return lookup(buffer, start, len, hash(buffer, start, len)); for (int i = 0; i <= currEntry; i++) { if (CharArrayUtils.equals(buffer, start, len, keyTable[i])) return i; @@ -182,9 +176,9 @@ public class CharTable extends HashTable { return -1; } - public Object [] keyArray(){ - Object [] keys = new Object[ size() ]; - System.arraycopy( keyTable, 0, keys, 0, keys.length ); + public Object[] keyArray() { + Object[] keys = new Object[ size() ]; + System.arraycopy(keyTable, 0, keys, 0, keys.length); return keys; } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/CProjectDescriptionListener.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/CProjectDescriptionListener.java index 59d20dca1d9..fdb2f461c37 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/CProjectDescriptionListener.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/CProjectDescriptionListener.java @@ -49,8 +49,7 @@ public class CProjectDescriptionListener implements ICProjectDescriptionListener if (project != null) { fIndexerSetupParticipant.notifyIndexerSetup(project); } - } - else if (old != null && changedDefaultSettingConfiguration(old, act)) { + } else if (old != null && changedDefaultSettingConfiguration(old, act)) { ICProject project= getProject(event); if (project != null) { fIndexManager.reindex(project); @@ -86,7 +85,7 @@ public class CProjectDescriptionListener implements ICProjectDescriptionListener // Check for a project that has been created by the new project wizard just // just for the purpose of editing preferences (Advanced button) ICProjectDescription desc= CProjectDescriptionManager.getInstance().getProjectDescription(project.getProject(), false, false); - return desc==null || !desc.isCdtProjectCreating(); + return desc == null || !desc.isCdtProjectCreating(); } private boolean completedProjectCreation(ICProjectDescription old, ICProjectDescription act) { From c253299b8f50e24d5ab08a85374266917e145e25 Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Sun, 13 May 2012 13:44:06 -0700 Subject: [PATCH 06/38] Bug 379337. Prevent miltiple inclusions with Objective-C #import statements. --- .../core/parser/scanner/CPreprocessor.java | 40 ++++++++++++------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/CPreprocessor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/CPreprocessor.java index 46da6f2a30b..3214964ad1b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/CPreprocessor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/CPreprocessor.java @@ -242,11 +242,12 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { private boolean fHandledCompletion= false; private boolean fSplitShiftRightOperator= false; - // state information + // State information private final CharArrayMap fMacroDictionary = new CharArrayMap(512); private final IMacroDictionary fMacroDictionaryFacade = new MacroDictionary(); private final LocationMap fLocationMap; - private CharArraySet fPreventInclusion= new CharArraySet(0); + private CharArraySet fPreventInclusion; + private CharArraySet fImports; private final ScannerContext fRootContext; protected ScannerContext fCurrentContext; @@ -1233,11 +1234,8 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { switch (type) { case IPreprocessorDirective.ppImport: case IPreprocessorDirective.ppInclude: - executeInclude(lexer, startOffset, false, fCurrentContext.getCodeState() == CodeState.eActive, - withinExpansion); - break; case IPreprocessorDirective.ppInclude_next: - executeInclude(lexer, startOffset, true, fCurrentContext.getCodeState() == CodeState.eActive, + executeInclude(lexer, startOffset, type, fCurrentContext.getCodeState() == CodeState.eActive, withinExpansion); break; case IPreprocessorDirective.ppDefine: @@ -1329,7 +1327,7 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { } } - private void executeInclude(final Lexer lexer, int poundOffset, boolean include_next, + private void executeInclude(final Lexer lexer, int poundOffset, int includeType, boolean active, boolean withinExpansion) throws OffsetLimitReachedException { // Make sure to clear the extern include guard. final char[] externGuard= fExternIncludeGuard; @@ -1409,13 +1407,29 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { return; } - if (active && fCurrentContext.getDepth() == MAX_INCLUSION_DEPTH || fPreventInclusion.containsKey(headerName)) { + if (includeType == IPreprocessorDirective.ppImport) { + // Imports are executed only once. + // See http://gcc.gnu.org/onlinedocs/gcc-3.2/cpp/Obsolete-once-only-headers.html. + if (fImports != null && fImports.containsKey(headerName)) + return; + if (active) { + if (fImports == null) + fImports = new CharArraySet(0); + fImports.put(headerName); + } + } + + if ((active && fCurrentContext.getDepth() == MAX_INCLUSION_DEPTH) || + (fPreventInclusion != null && fPreventInclusion.containsKey(headerName))) { handleProblem(IProblem.PREPROCESSOR_EXCEEDS_MAXIMUM_INCLUSION_DEPTH, lexer.getInputChars(poundOffset, condEndOffset), poundOffset, condEndOffset); + if (fPreventInclusion == null) + fPreventInclusion = new CharArraySet(0); fPreventInclusion.put(headerName); return; } - + + boolean includeNext = includeType == IPreprocessorDirective.ppInclude_next; final String includeDirective = new String(headerName); if (!active) { // Inactive include @@ -1429,7 +1443,7 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { // #endif // When the extern guard matches we need to resolve the inclusion. We don't actually // check whether the guard matches. - final IncludeResolution resolved= findInclusion(includeDirective, userInclude, include_next, + final IncludeResolution resolved= findInclusion(includeDirective, userInclude, includeNext, getCurrentFilename(), createPathTester); if (resolved != null) { nominationDelegate = fFileContentProvider.isIncludedWithPragmaOnceSemantics(resolved.fLocation); @@ -1445,7 +1459,7 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { } // Active include - final InternalFileContent fi= findInclusion(includeDirective, userInclude, include_next, + final InternalFileContent fi= findInclusion(includeDirective, userInclude, includeNext, getCurrentFilename(), createCodeReaderTester); if (fi == null) { // Unresolved active include @@ -1824,10 +1838,8 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { switch (type) { case IPreprocessorDirective.ppImport: case IPreprocessorDirective.ppInclude: - executeInclude(lexer, ident.getOffset(), false, false, withinExpansion); - break; case IPreprocessorDirective.ppInclude_next: - executeInclude(lexer, ident.getOffset(), true, false, withinExpansion); + executeInclude(lexer, ident.getOffset(), type, false, withinExpansion); break; case IPreprocessorDirective.ppIfdef: return executeIfdef(lexer, pound.getOffset(), false, withinExpansion); From 4a5e1d6fe199a896d5816614e70cdcd4c1efd575 Mon Sep 17 00:00:00 2001 From: Salvatore Culcasi Date: Mon, 14 May 2012 00:47:54 -0400 Subject: [PATCH 07/38] Bug 322475 - Internal error (NegativeArraySizeException) in Dwarf --- .../utils/org/eclipse/cdt/utils/debug/dwarf/Dwarf.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/debug/dwarf/Dwarf.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/debug/dwarf/Dwarf.java index 1914774515b..032f14b8d6d 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/debug/dwarf/Dwarf.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/debug/dwarf/Dwarf.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 QNX Software Systems and others. + * Copyright (c) 2000, 2012 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,6 +7,7 @@ * * Contributors: * QNX Software Systems - Initial API and implementation + * Salvatore Culcasi - Bug 322475 *******************************************************************************/ package org.eclipse.cdt.utils.debug.dwarf; @@ -476,7 +477,7 @@ public class Dwarf { case DwarfConstants.DW_FORM_block1 : { int size = in.get(); - byte[] bytes = new byte[size]; + byte[] bytes = new byte[size & 0xff]; in.get(bytes); obj = bytes; } @@ -485,7 +486,7 @@ public class Dwarf { case DwarfConstants.DW_FORM_block2 : { int size = read_2_bytes(in); - byte[] bytes = new byte[size]; + byte[] bytes = new byte[size & 0xffff]; in.get(bytes); obj = bytes; } From 12d73e274c63c399fc42fbc92b2bb776ee1a65fd Mon Sep 17 00:00:00 2001 From: Markus Schorn Date: Mon, 14 May 2012 11:01:21 +0200 Subject: [PATCH 08/38] Fixes a few mistakes related to class specializations. --- .../internal/core/dom/parser/cpp/CPPClassInstance.java | 4 +++- .../core/dom/parser/cpp/semantics/BaseClassLookup.java | 2 +- .../internal/core/pdom/dom/cpp/PDOMCPPClassScope.java | 6 ------ .../dom/cpp/PDOMCPPUsingDeclarationSpecialization.java | 2 +- .../cdt/internal/core/pdom/dom/cpp/PDOMClassUtil.java | 9 +++++---- 5 files changed, 10 insertions(+), 13 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstance.java index 06b679f4c7b..6c9a28cc727 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstance.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstance.java @@ -31,7 +31,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates; * The result of instantiating a class template. */ public class CPPClassInstance extends CPPClassSpecialization implements ICPPTemplateInstance { - private ICPPTemplateArgument[] arguments; + private final ICPPTemplateArgument[] arguments; public CPPClassInstance(ICPPClassType orig, IBinding owner, CPPTemplateParameterMap argMap, ICPPTemplateArgument[] args) { super(orig, owner, argMap); @@ -52,6 +52,8 @@ public class CPPClassInstance extends CPPClassSpecialization implements ICPPTemp protected ICPPClassSpecializationScope getSpecializationScope() { // An instance with a declaration has no specialization scope. checkForDefinition(); + if (getDefinition() != null) + return null; final IASTNode[] decls = getDeclarations(); if (decls != null && decls.length > 0 && decls[0] != null) return null; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/BaseClassLookup.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/BaseClassLookup.java index 66a3f4e395b..9691f3e476a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/BaseClassLookup.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/BaseClassLookup.java @@ -250,7 +250,7 @@ class BaseClassLookup { continue; final IName nbaseName = nbase.getBaseClassSpecifierName(); - int cmp= baseName == null ? -1 : CPPSemantics.compareByRelevance(data, baseName, nbaseName); + int cmp= baseName == null ? 0 : CPPSemantics.compareByRelevance(data, baseName, nbaseName); if (cmp <= 0) { if (cmp < 0) { selectedBases.clear(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassScope.java index 4a572add8e3..652b940d467 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassScope.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassScope.java @@ -30,11 +30,9 @@ import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.ICompositeType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor; import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization; import org.eclipse.cdt.core.index.IIndexBinding; import org.eclipse.cdt.core.index.IIndexFileSet; import org.eclipse.cdt.core.index.IIndexName; @@ -140,10 +138,6 @@ class PDOMCPPClassScope implements ICPPClassScope, IIndexScope { } private IBinding getClassNameBinding() { - if (fBinding instanceof ICPPClassTemplatePartialSpecialization) - return ((ICPPClassTemplatePartialSpecialization) fBinding).getPrimaryClassTemplate(); - if (fBinding instanceof ICPPSpecialization) - return ((ICPPSpecialization) fBinding).getSpecializedBinding(); return fBinding; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPUsingDeclarationSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPUsingDeclarationSpecialization.java index 953057620fc..b7cafb643c9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPUsingDeclarationSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPUsingDeclarationSpecialization.java @@ -61,7 +61,7 @@ class PDOMCPPUsingDeclarationSpecialization extends PDOMCPPSpecialization implem @Override public int getNodeType() { - return IIndexCPPBindingConstants.CPP_USING_DECLARATION; + return IIndexCPPBindingConstants.CPP_USING_DECLARATION_SPECIALIZATION; } @Override diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMClassUtil.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMClassUtil.java index eeb07ceb5fb..92bcf23cf77 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMClassUtil.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMClassUtil.java @@ -22,6 +22,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPField; import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance; import org.eclipse.cdt.core.index.IndexFilter; +import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance; import org.eclipse.core.runtime.CoreException; @@ -30,7 +31,7 @@ import org.eclipse.core.runtime.CoreException; */ class PDOMClassUtil { static class FieldCollector implements IPDOMVisitor { - private List fields = new ArrayList(); + private final List fields = new ArrayList(); @Override public boolean visit(IPDOMNode node) throws CoreException { if (node instanceof ICPPField) { @@ -50,7 +51,7 @@ class PDOMClassUtil { } static class ConstructorCollector implements IPDOMVisitor { - private List fConstructors = new ArrayList(); + private final List fConstructors = new ArrayList(); @Override public boolean visit(IPDOMNode node) throws CoreException { if (node instanceof ICPPConstructor) { @@ -108,10 +109,10 @@ class PDOMClassUtil { } static class NestedClassCollector implements IPDOMVisitor { - private List nestedClasses = new ArrayList(); + private final List nestedClasses = new ArrayList(); @Override public boolean visit(IPDOMNode node) throws CoreException { - if (node instanceof ICPPClassType) + if (node instanceof ICPPClassType && !(node instanceof ICPPDeferredClassInstance)) nestedClasses.add(node); return false; } From bd57216cbf569a93a99d9f7140032d6ecaff6d6d Mon Sep 17 00:00:00 2001 From: mhussein Date: Mon, 14 May 2012 10:56:04 +0300 Subject: [PATCH 09/38] Fix Unit test for bug 365718 make getTreeRoot correctly throw an exception if called for non tree nodes. Change-Id: Ief34c469c504cddc0212750bf98f4823774d1990 Reviewed-on: https://git.eclipse.org/r/5969 Reviewed-by: Doug Schaefer IP-Clean: Doug Schaefer Tested-by: Doug Schaefer --- .../eclipse/cdt/managedbuilder/internal/core/Option.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Option.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Option.java index 07d69fe1a73..ea8df262477 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Option.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Option.java @@ -2975,6 +2975,9 @@ public class Option extends BuildObject implements IOption, IBuildPropertiesRest @Override public ITreeRoot getTreeRoot() throws BuildException { + if (getValueType() != TREE) { + throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$ + } if (treeRoot == null) { if (superClass != null) { return superClass.getTreeRoot(); @@ -2982,9 +2985,6 @@ public class Option extends BuildObject implements IOption, IBuildPropertiesRest return null; } } - if (getValueType() != TREE) { - throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$ - } return treeRoot; } From 573dd7fd5b57fbb9dcf7ed06cdc42a4fb3f6f279 Mon Sep 17 00:00:00 2001 From: John Eblen Date: Mon, 7 May 2012 17:04:37 -0400 Subject: [PATCH 10/38] Bug 363612 - [API] Add toolchain accessor functions to MBSWizardHandler Change-Id: I9bfd3f9aa2b6007172466be212f5f45b668c231f Reviewed-on: https://git.eclipse.org/r/5870 Reviewed-by: Chris Recoskie Tested-by: Chris Recoskie IP-Clean: Chris Recoskie --- .../ui/wizards/MBSWizardHandler.java | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSWizardHandler.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSWizardHandler.java index 8d204ec1f7f..34a8ce00fdd 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSWizardHandler.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSWizardHandler.java @@ -271,6 +271,29 @@ public class MBSWizardHandler extends CWizardHandler { return out; } + /** + * Get a map from toolchain names to actual toolchains. + * This list should mirror the list displayed in the wizard. + * Bug #363612 + * + * @since 8.1 + * @return the map + */ + public SortedMap getToolChains() { + Set toolChainNames = this.tc_filter(); + SortedMap toolChainMap = new TreeMap(); + + for (String toolChainName : toolChainNames) { + IToolChain tc = tcs.get(toolChainName); + if (tc == null) { + toolChainMap.put(toolChainName, null); + } else { + toolChainMap.put(tc.getUniqueRealName(), tc); + } + } + return toolChainMap; + } + /** * Checks whether given toolchain can be displayed * @@ -708,6 +731,30 @@ public class MBSWizardHandler extends CWizardHandler { else return entryInfo.tc_filter().size(); } + /** + * Get a map from toolchain names to actual toolchains. + * Bug #363612 + * + * @since 8.1 + * @return the map + */ + public SortedMap getToolChains() { + if (entryInfo == null) + return full_tcs; + else + return entryInfo.getToolChains(); + } + /** + * Get the table that is displayed in the left pane. + * This allow for changes after handler creation. + * Bug #363612 + * + * @since 8.1 + * @return the table + */ + public Table getToolChainsTable() { + return table; + } public String getPropertyId() { return propertyId; } From d5cb9f4f8ff821d26f813d438f9d9df56607927e Mon Sep 17 00:00:00 2001 From: Vivian Kong Date: Mon, 14 May 2012 15:15:51 -0400 Subject: [PATCH 11/38] Bug 379448 - Add "UPC" string to feature name Unified Parallel C - to enable consistent searching --- upc/org.eclipse.cdt.core.parser.upc.feature/feature.properties | 2 +- .../feature.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/upc/org.eclipse.cdt.core.parser.upc.feature/feature.properties b/upc/org.eclipse.cdt.core.parser.upc.feature/feature.properties index ab0136eaf03..91e64354165 100644 --- a/upc/org.eclipse.cdt.core.parser.upc.feature/feature.properties +++ b/upc/org.eclipse.cdt.core.parser.upc.feature/feature.properties @@ -15,7 +15,7 @@ # This file should be translated. # "featureName" property - name of the feature -featureName=Unified Parallel C Support +featureName=Unified Parallel C (UPC) Support # "providerName" property - name of the company that provides the feature providerName=Eclipse CDT diff --git a/upc/org.eclipse.cdt.core.parser.upc.sdk.feature/feature.properties b/upc/org.eclipse.cdt.core.parser.upc.sdk.feature/feature.properties index 3ff424e1035..a39411ad32f 100644 --- a/upc/org.eclipse.cdt.core.parser.upc.sdk.feature/feature.properties +++ b/upc/org.eclipse.cdt.core.parser.upc.sdk.feature/feature.properties @@ -15,7 +15,7 @@ # This file should be translated. # "featureName" property - name of the feature -featureName=Unified Parallel C Support SDK +featureName=Unified Parallel C (UPC) Support SDK # "providerName" property - name of the company that provides the feature providerName=Eclipse CDT From 03d1253f689c45fcc963eff82837595a1e12ce73 Mon Sep 17 00:00:00 2001 From: Eugene Ostroukhov Date: Fri, 11 May 2012 15:40:47 -0700 Subject: [PATCH 12/38] Bug 379317 - This change coalesces runnables into one. This improves perceived performance as repaints are not interleaved with updates. Change-Id: If9674e45adf1aa5b4d8530e22dfcd494d228f329 Reviewed-on: https://git.eclipse.org/r/5956 Reviewed-by: Pawel Piech IP-Clean: Pawel Piech Tested-by: Pawel Piech --- .../ui/concurrent/SimpleDisplayExecutor.java | 80 ++++++++++++++----- 1 file changed, 61 insertions(+), 19 deletions(-) diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/ui/concurrent/SimpleDisplayExecutor.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/ui/concurrent/SimpleDisplayExecutor.java index a6fe2ec256d..e4a12bdf48c 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/ui/concurrent/SimpleDisplayExecutor.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/ui/concurrent/SimpleDisplayExecutor.java @@ -4,15 +4,18 @@ * 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 API and implementation + * NVIDIA - coalesce runnable in the single event loop iteration *******************************************************************************/ package org.eclipse.cdt.dsf.ui.concurrent; import java.util.Collections; import java.util.HashMap; +import java.util.LinkedList; import java.util.Map; +import java.util.Queue; import java.util.concurrent.Executor; import java.util.concurrent.RejectedExecutionException; @@ -22,13 +25,13 @@ import org.eclipse.swt.SWTException; import org.eclipse.swt.widgets.Display; /** - * A simple executor which uses the display thread to run the submitted + * A simple executor which uses the display thread to run the submitted * runnables. It only implements the {@link Executor}, and NOT the more - * sophisticated {@link DsfExecutor} (which extends - * {@link java.util.concurrent.ScheduledExecutorService}). However, this + * sophisticated {@link DsfExecutor} (which extends + * {@link java.util.concurrent.ScheduledExecutorService}). However, this * implementation is much more efficient than DisplayDsfExecutor as it does * not use a separate thread or maintain its own queue. - * + * * @since 1.0 */ public class SimpleDisplayExecutor implements Executor{ @@ -36,13 +39,13 @@ public class SimpleDisplayExecutor implements Executor{ * Internal mapping of display objects to executors. */ private static Map fExecutors = Collections.synchronizedMap( new HashMap() ); - + /** * Factory method for display executors. * @param display Display to create an executor for. * @return The new (or re-used) executor. */ - public static SimpleDisplayExecutor getSimpleDisplayExecutor(Display display) { + public static SimpleDisplayExecutor getSimpleDisplayExecutor(final Display display) { synchronized (fExecutors) { SimpleDisplayExecutor executor = fExecutors.get(display); if (executor == null) { @@ -52,26 +55,65 @@ public class SimpleDisplayExecutor implements Executor{ return executor; } } - + /** - * The display class used by this executor to execute the submitted runnables. + * The display class used by this executor to execute the submitted runnables. */ private final Display fDisplay; - - private SimpleDisplayExecutor(Display display) { + /** + * Runnables waiting for the UI loop iteration + */ + private Queue runnables; + + private SimpleDisplayExecutor(final Display display) { fDisplay = display; } @Override - public void execute(Runnable command) { - try { - fDisplay.asyncExec(command); - } catch (SWTException e) { - if (e.code == SWT.ERROR_DEVICE_DISPOSED) { - throw new RejectedExecutionException("Display " + fDisplay + " is disposed", e); //$NON-NLS-1$ //$NON-NLS-2$ - } else { - throw e; + public void execute(final Runnable command) { + final boolean needsPosting = enqueue(command); + if (needsPosting) { + try { + fDisplay.asyncExec(new Runnable() { + @Override + public void run() { + runInSwtThread(); + } + }); + } catch (final SWTException e) { + if (e.code == SWT.ERROR_DEVICE_DISPOSED) { + throw new RejectedExecutionException("Display " + fDisplay + " is disposed", e); //$NON-NLS-1$ //$NON-NLS-2$ + } else { + throw e; + } } } } + + private synchronized boolean enqueue(final Runnable runnable) { + boolean needsPosting = false; + if (runnables == null) { + runnables = new LinkedList(); + needsPosting = true; + } + runnables.offer(runnable); + return needsPosting; + } + + private synchronized Runnable getNextRunnable() { + final Runnable runnable = runnables.poll(); + if (runnable == null) { + runnables = null; + return null; + } else { + return runnable; + } + } + + protected void runInSwtThread() { + Runnable runnable; + while ((runnable = getNextRunnable()) != null) { + runnable.run(); + } + } } From b83750eae0df3b119136d279ff7e6736d6a3c982 Mon Sep 17 00:00:00 2001 From: Pawel Piech Date: Mon, 14 May 2012 14:27:04 -0700 Subject: [PATCH 13/38] Bug 379317 - SimpleDisplayExecutable posts runnables as separate UI event queue elements Updated the performance test to better simulate debuggers' view model. --- .../cdt/tests/dsf/vm/TestModelVMNode.java | 82 ++++++++++++------- .../cdt/tests/dsf/vm/TestModelVMProvider.java | 17 +++- 2 files changed, 67 insertions(+), 32 deletions(-) diff --git a/dsf/org.eclipse.cdt.tests.dsf/src/org/eclipse/cdt/tests/dsf/vm/TestModelVMNode.java b/dsf/org.eclipse.cdt.tests.dsf/src/org/eclipse/cdt/tests/dsf/vm/TestModelVMNode.java index c7f11ac9988..cde46005a60 100644 --- a/dsf/org.eclipse.cdt.tests.dsf/src/org/eclipse/cdt/tests/dsf/vm/TestModelVMNode.java +++ b/dsf/org.eclipse.cdt.tests.dsf/src/org/eclipse/cdt/tests/dsf/vm/TestModelVMNode.java @@ -15,7 +15,6 @@ import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants; import org.eclipse.cdt.dsf.concurrent.RequestMonitor; import org.eclipse.cdt.dsf.debug.ui.viewmodel.numberformat.FormattedValueLabelText; import org.eclipse.cdt.dsf.ui.viewmodel.AbstractVMNode; -import org.eclipse.cdt.dsf.ui.viewmodel.AbstractVMProvider; import org.eclipse.cdt.dsf.ui.viewmodel.IRootVMNode; import org.eclipse.cdt.dsf.ui.viewmodel.VMDelta; import org.eclipse.cdt.dsf.ui.viewmodel.properties.IElementPropertiesProvider; @@ -60,48 +59,69 @@ public class TestModelVMNode extends AbstractVMNode implements IRootVMNode, IEle fLabelProvider.update(updates); } - public TestModelVMNode(AbstractVMProvider provider) { + public TestModelVMNode(TestModelVMProvider provider) { super(provider); } - public void update(IHasChildrenUpdate[] updates) { - for (IHasChildrenUpdate update : updates) { - if (update.getElement() instanceof TestElementVMContext) { - TestElement element = ((TestElementVMContext)update.getElement()).getElement(); - update.setHasChilren(element.getChildren().length != 0); - } - update.done(); - } + private TestModelVMProvider getTestProvider() { + return (TestModelVMProvider)getVMProvider(); + } - public void update(IChildrenCountUpdate[] updates) { - for (IChildrenCountUpdate update : updates) { - if (update.getElement() instanceof TestElementVMContext) { - TestElement element = ((TestElementVMContext)update.getElement()).getElement(); - update.setChildCount(element.getChildren().length); + public void update(final IHasChildrenUpdate[] updates) { + getTestProvider().getDsfExecutor().execute(new Runnable() { + public void run() { + for (IHasChildrenUpdate update : updates) { + if (update.getElement() instanceof TestElementVMContext) { + TestElement element = ((TestElementVMContext)update.getElement()).getElement(); + update.setHasChilren(element.getChildren().length != 0); + } + update.done(); + } } - update.done(); - } + }); + } + + public void update(final IChildrenCountUpdate[] updates) { + getTestProvider().getDsfExecutor().execute(new Runnable() { + public void run() { + for (IChildrenCountUpdate update : updates) { + if (update.getElement() instanceof TestElementVMContext) { + TestElement element = ((TestElementVMContext)update.getElement()).getElement(); + update.setChildCount(element.getChildren().length); + } + update.done(); + } + } + }); } - public void update(IChildrenUpdate[] updates) { - for (IChildrenUpdate update : updates) { - if (update.getElement() instanceof TestElementVMContext) { - TestElement element = ((TestElementVMContext)update.getElement()).getElement(); - fillUpdateWithTestElements(update, element.getChildren()); + public void update(final IChildrenUpdate[] updates) { + getTestProvider().getDsfExecutor().execute(new Runnable() { + public void run() { + for (IChildrenUpdate update : updates) { + if (update.getElement() instanceof TestElementVMContext) { + TestElement element = ((TestElementVMContext)update.getElement()).getElement(); + fillUpdateWithTestElements(update, element.getChildren()); + } + update.done(); + } } - update.done(); - } + }); } - public void update(IPropertiesUpdate[] updates) { - for (IPropertiesUpdate update : updates) { - if (update.getElement() instanceof TestElementVMContext) { - TestElement element = ((TestElementVMContext)update.getElement()).getElement(); - update.setProperty(PROP_TEST_ELEMENT_LABEL, element.getLabel()); + public void update(final IPropertiesUpdate[] updates) { + getTestProvider().getDsfExecutor().execute(new Runnable() { + public void run() { + for (IPropertiesUpdate update : updates) { + if (update.getElement() instanceof TestElementVMContext) { + TestElement element = ((TestElementVMContext)update.getElement()).getElement(); + update.setProperty(PROP_TEST_ELEMENT_LABEL, element.getLabel()); + } + update.done(); + } } - update.done(); - } + }); } private void fillUpdateWithTestElements(IChildrenUpdate update, TestElement[] elements) { diff --git a/dsf/org.eclipse.cdt.tests.dsf/src/org/eclipse/cdt/tests/dsf/vm/TestModelVMProvider.java b/dsf/org.eclipse.cdt.tests.dsf/src/org/eclipse/cdt/tests/dsf/vm/TestModelVMProvider.java index a53186d1b8e..6a2265a35db 100644 --- a/dsf/org.eclipse.cdt.tests.dsf/src/org/eclipse/cdt/tests/dsf/vm/TestModelVMProvider.java +++ b/dsf/org.eclipse.cdt.tests.dsf/src/org/eclipse/cdt/tests/dsf/vm/TestModelVMProvider.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.cdt.tests.dsf.vm; +import org.eclipse.cdt.dsf.concurrent.DefaultDsfExecutor; +import org.eclipse.cdt.dsf.concurrent.DsfExecutor; import org.eclipse.cdt.dsf.ui.viewmodel.AbstractVMAdapter; import org.eclipse.cdt.dsf.ui.viewmodel.AbstractVMProvider; import org.eclipse.cdt.dsf.ui.viewmodel.IVMModelProxy; @@ -23,14 +25,27 @@ import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationCont */ public class TestModelVMProvider extends AbstractVMProvider { + private DsfExecutor fDsfExecutor; + public TestModelVMProvider(AbstractVMAdapter adapter, IPresentationContext context) { super(adapter, context); + fDsfExecutor = new DefaultDsfExecutor("TestModelVMProvider"); + setRootNode(new TestModelVMNode(this)); addChildNodes(getRootVMNode(), new IVMNode[] { getRootVMNode() }); } - + @Override + public void dispose() { + super.dispose(); + fDsfExecutor.shutdown(); + } + + public DsfExecutor getDsfExecutor() { + return fDsfExecutor; + } + public TestElementVMContext getElementVMContext(IPresentationContext context, TestElement element) { return ((TestModelVMNode)getRootVMNode()).createVMContext(element); } From 747f41471aeb0ebb79bed2ab279c4b567ac9e7ae Mon Sep 17 00:00:00 2001 From: Doug Schaefer Date: Sun, 13 May 2012 21:54:32 -0400 Subject: [PATCH 14/38] Bug 378906 - Give extension-less file names the chance to be binary. Change-Id: I1308f2b8b20884b687b430b89dc5a187acdab9ad Reviewed-on: https://git.eclipse.org/r/5966 Reviewed-by: Doug Schaefer IP-Clean: Doug Schaefer Tested-by: Doug Schaefer --- .../cdt/internal/core/model/BinaryRunner.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryRunner.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryRunner.java index cd4d11c62d0..30b68f9d52e 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryRunner.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryRunner.java @@ -198,13 +198,16 @@ public class BinaryRunner { } // check against known content types + // if the file has an extension String name = proxy.getName(); - IContentType contentType = CCorePlugin.getContentType(project, name); - if (contentType != null && textContentType != null) { - if (contentType.isKindOf(textContentType)) { - return true; - } else if (textContentType.isAssociatedWith(name)) { - return true; + if (name.contains(".")) { + IContentType contentType = CCorePlugin.getContentType(project, name); + if (contentType != null && textContentType != null) { + if (contentType.isKindOf(textContentType)) { + return true; + } else if (textContentType.isAssociatedWith(name)) { + return true; + } } } From 20be45ecfadb8ccb158bd67c3d36e1704dbcbcf3 Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Mon, 14 May 2012 18:23:34 -0700 Subject: [PATCH 15/38] Cosmetics. --- .../eclipse/cdt/core/index/IIndexManager.java | 38 +++++++++---------- .../cdt/core/parser/util/CharArrayUtils.java | 4 +- .../org/eclipse/cdt/core/CConventions.java | 6 +-- .../src/org/eclipse/cdt/core/CCorePlugin.java | 36 +++++++++--------- .../corext/template/c/CContextType.java | 11 +----- .../internal/ui/editor/CDocumentProvider.java | 2 +- .../cdt/internal/ui/editor/CEditor.java | 16 ++++---- .../CodeFormatterConfigurationBlock.java | 2 +- .../cdt/internal/ui/text/CBreakIterator.java | 2 +- .../internal/ui/text/CHeuristicScanner.java | 2 +- 10 files changed, 55 insertions(+), 64 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexManager.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexManager.java index 20b8fc3536b..0b61a345627 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexManager.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexManager.java @@ -33,21 +33,21 @@ public interface IIndexManager extends IPDOMManager { * projects referenced by the set of input projects should also be added * to the resulting index. */ - public final static int ADD_DEPENDENCIES = 0x1; + public static final int ADD_DEPENDENCIES = 0x1; /** * Constant for passing to getIndex methods. This constant, when set, indicates * projects which reference any of the set of input projects should also be * added to the resulting index. */ - public final static int ADD_DEPENDENT = 0x2; + public static final int ADD_DEPENDENT = 0x2; /** * @deprecated Extension fragments are now used depending on their configuration. * Use one of the ADD_EXTENSION_XX flags instead. */ @Deprecated - public final static int SKIP_PROVIDED = 0x4; + public static final int SKIP_PROVIDED = 0x4; /** * Constant for passing to getIndex methods. This constant, when set, indicates that each index @@ -56,7 +56,7 @@ public interface IIndexManager extends IPDOMManager { * * @since 5.4 */ - public final static int ADD_EXTENSION_FRAGMENTS_NAVIGATION = 0x8; + public static final int ADD_EXTENSION_FRAGMENTS_NAVIGATION = 0x8; /** * Constant for passing to getIndex methods. This constant, when set, indicates that the each index @@ -65,7 +65,7 @@ public interface IIndexManager extends IPDOMManager { * * @since 5.4 */ - public final static int ADD_EXTENSION_FRAGMENTS_CONTENT_ASSIST = 0x10; + public static final int ADD_EXTENSION_FRAGMENTS_CONTENT_ASSIST = 0x10; /** * Constant for passing to getIndex methods. This constant, when set, indicates that each index @@ -74,7 +74,7 @@ public interface IIndexManager extends IPDOMManager { * * @since 5.4 */ - public final static int ADD_EXTENSION_FRAGMENTS_ADD_IMPORT = 0x20; + public static final int ADD_EXTENSION_FRAGMENTS_ADD_IMPORT = 0x20; /** * Constant for passing to getIndex methods. This constant, when set, indicates that each index @@ -83,7 +83,7 @@ public interface IIndexManager extends IPDOMManager { * * @since 5.4 */ - public final static int ADD_EXTENSION_FRAGMENTS_CALL_HIERARCHY = 0x40; + public static final int ADD_EXTENSION_FRAGMENTS_CALL_HIERARCHY = 0x40; /** * Constant for passing to getIndex methods. This constant, when set, indicates that each index @@ -92,7 +92,7 @@ public interface IIndexManager extends IPDOMManager { * * @since 5.4 */ - public final static int ADD_EXTENSION_FRAGMENTS_TYPE_HIERARCHY = 0x80; + public static final int ADD_EXTENSION_FRAGMENTS_TYPE_HIERARCHY = 0x80; /** * Constant for passing to getIndex methods. This constant, when set, indicates that each index @@ -101,7 +101,7 @@ public interface IIndexManager extends IPDOMManager { * * @since 5.4 */ - public final static int ADD_EXTENSION_FRAGMENTS_INCLUDE_BROWSER = 0x100; + public static final int ADD_EXTENSION_FRAGMENTS_INCLUDE_BROWSER = 0x100; /** * Constant for passing to getIndex methods. This constant, when set, indicates that each index @@ -110,29 +110,29 @@ public interface IIndexManager extends IPDOMManager { * * @since 5.4 */ - public final static int ADD_EXTENSION_FRAGMENTS_SEARCH = 0x200; + public static final int ADD_EXTENSION_FRAGMENTS_SEARCH = 0x200; /** * Constant for indicating that there is no time out period for joining the indexer job. * @see IIndexManager#joinIndexer(int, IProgressMonitor) */ - public final static int FOREVER= -1; + public static final int FOREVER= -1; /** * Constant for requesting an update of all translation units. */ - public final static int UPDATE_ALL= 0x1; + public static final int UPDATE_ALL= 0x1; /** * Constant for requesting an update of translation units if theit timestamps have changed. */ - public final static int UPDATE_CHECK_TIMESTAMPS= 0x2; + public static final int UPDATE_CHECK_TIMESTAMPS= 0x2; /** * Constant for requesting an update of translation units if their configurations * have changed. The flag currently has no effect. */ - public final static int UPDATE_CHECK_CONFIGURATION= 0x4; + public static final int UPDATE_CHECK_CONFIGURATION= 0x4; /** * Constant for requesting to update the external files for a project, also. This flag works @@ -140,7 +140,7 @@ public interface IIndexManager extends IPDOMManager { * {@link #UPDATE_ALL} or {@link #UPDATE_CHECK_TIMESTAMPS}. * @since 5.1 */ - public final static int UPDATE_EXTERNAL_FILES_FOR_PROJECT= 0x8; + public static final int UPDATE_EXTERNAL_FILES_FOR_PROJECT= 0x8; /** * This flag modifies behavior of UPDATE_CHECK_TIMESTAMPS. Both, the timestamp and the hash @@ -149,7 +149,7 @@ public interface IIndexManager extends IPDOMManager { * generation since generated files are sometimes recreated with identical contents. * @since 5.2 */ - public final static int UPDATE_CHECK_CONTENTS_HASH= 0x10; + public static final int UPDATE_CHECK_CONTENTS_HASH= 0x10; /** * Include files that are otherwise would be excluded from the index. This flag is sticky @@ -157,7 +157,7 @@ public interface IIndexManager extends IPDOMManager { * they remain in the index. * @since 5.3 */ - public final static int FORCE_INDEX_INCLUSION= 0x20; + public static final int FORCE_INDEX_INCLUSION= 0x20; /** * Causes files previously included in the index due to FORCE_INDEX_INCLUSION to loose @@ -165,13 +165,13 @@ public interface IIndexManager extends IPDOMManager { * will be removed from the index. * @since 5.4 */ - public final static int RESET_INDEX_INCLUSION= 0x40; + public static final int RESET_INDEX_INCLUSION= 0x40; /** * Constant for requesting an update of translation units that had unresolved includes. * @since 5.4 */ - public final static int UPDATE_UNRESOLVED_INCLUDES= 0x80; + public static final int UPDATE_UNRESOLVED_INCLUDES= 0x80; /** * Returns the index for the given project. diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/CharArrayUtils.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/CharArrayUtils.java index 54bbb3db73d..b3d27ee7b3d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/CharArrayUtils.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/CharArrayUtils.java @@ -291,7 +291,7 @@ public class CharArrayUtils { return -1; } - final static public char[] trim(char[] chars) { + static final public char[] trim(char[] chars) { if (chars == null) return null; @@ -308,7 +308,7 @@ public class CharArrayUtils { return chars; } - final static public char[] lastSegment(char[] array, char[] separator) { + static final public char[] lastSegment(char[] array, char[] separator) { int pos = lastIndexOf(separator, array); if (pos < 0) return array; diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CConventions.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CConventions.java index 462cc7f39c8..90b06448c56 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CConventions.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CConventions.java @@ -33,10 +33,10 @@ import org.eclipse.osgi.util.NLS; * @noinstantiate This class is not intended to be instantiated by clients. */ public class CConventions { - private final static String scopeResolutionOperator= "::"; //$NON-NLS-1$ - private final static char fgDot= '.'; + private static final String scopeResolutionOperator= "::"; //$NON-NLS-1$ + private static final char fgDot= '.'; - private final static String ILLEGAL_FILE_CHARS = "/\\:<>?*|\""; //$NON-NLS-1$ + private static final String ILLEGAL_FILE_CHARS = "/\\:<>?*|\""; //$NON-NLS-1$ public static boolean isLegalIdentifier(String name) { if (name == null) { diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java index 8e994ecad9e..8ce68747762 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java @@ -109,11 +109,11 @@ public class CCorePlugin extends Plugin { public static final String BUILDER_MODEL_ID = PLUGIN_ID + ".CBuildModel"; //$NON-NLS-1$ public static final String BINARY_PARSER_SIMPLE_ID = "BinaryParser"; //$NON-NLS-1$ - public final static String BINARY_PARSER_UNIQ_ID = PLUGIN_ID + "." + BINARY_PARSER_SIMPLE_ID; //$NON-NLS-1$ - public final static String PREF_BINARY_PARSER = "binaryparser"; //$NON-NLS-1$ - public final static String DEFAULT_BINARY_PARSER_SIMPLE_ID = "ELF"; //$NON-NLS-1$ - public final static String DEFAULT_BINARY_PARSER_UNIQ_ID = PLUGIN_ID + "." + DEFAULT_BINARY_PARSER_SIMPLE_ID; //$NON-NLS-1$ - public final static String PREF_USE_STRUCTURAL_PARSE_MODE = "useStructualParseMode"; //$NON-NLS-1$ + public static final String BINARY_PARSER_UNIQ_ID = PLUGIN_ID + "." + BINARY_PARSER_SIMPLE_ID; //$NON-NLS-1$ + public static final String PREF_BINARY_PARSER = "binaryparser"; //$NON-NLS-1$ + public static final String DEFAULT_BINARY_PARSER_SIMPLE_ID = "ELF"; //$NON-NLS-1$ + public static final String DEFAULT_BINARY_PARSER_UNIQ_ID = PLUGIN_ID + "." + DEFAULT_BINARY_PARSER_SIMPLE_ID; //$NON-NLS-1$ + public static final String PREF_USE_STRUCTURAL_PARSE_MODE = "useStructualParseMode"; //$NON-NLS-1$ public static final String INDEX_SIMPLE_ID = "CIndex"; //$NON-NLS-1$ public static final String INDEX_UNIQ_ID = PLUGIN_ID + "." + INDEX_SIMPLE_ID; //$NON-NLS-1$ @@ -126,23 +126,23 @@ public class CCorePlugin extends Plugin { /** * Name of the extension point for contributing an error parser */ - public final static String ERROR_PARSER_SIMPLE_ID = "ErrorParser"; //$NON-NLS-1$ + public static final String ERROR_PARSER_SIMPLE_ID = "ErrorParser"; //$NON-NLS-1$ /** * Full unique name of the extension point for contributing an error parser */ - public final static String ERROR_PARSER_UNIQ_ID = PLUGIN_ID + "." + ERROR_PARSER_SIMPLE_ID; //$NON-NLS-1$ + public static final String ERROR_PARSER_UNIQ_ID = PLUGIN_ID + "." + ERROR_PARSER_SIMPLE_ID; //$NON-NLS-1$ // default store for pathentry - public final static String DEFAULT_PATHENTRY_STORE_ID = PLUGIN_ID + ".cdtPathEntryStore"; //$NON-NLS-1$ + public static final String DEFAULT_PATHENTRY_STORE_ID = PLUGIN_ID + ".cdtPathEntryStore"; //$NON-NLS-1$ // Build Model Interface Discovery - public final static String BUILD_SCANNER_INFO_SIMPLE_ID = "ScannerInfoProvider"; //$NON-NLS-1$ - public final static String BUILD_SCANNER_INFO_UNIQ_ID = PLUGIN_ID + "." + BUILD_SCANNER_INFO_SIMPLE_ID; //$NON-NLS-1$ + public static final String BUILD_SCANNER_INFO_SIMPLE_ID = "ScannerInfoProvider"; //$NON-NLS-1$ + public static final String BUILD_SCANNER_INFO_UNIQ_ID = PLUGIN_ID + "." + BUILD_SCANNER_INFO_SIMPLE_ID; //$NON-NLS-1$ public static final String DEFAULT_PROVIDER_ID = CCorePlugin.PLUGIN_ID + ".defaultConfigDataProvider"; //$NON-NLS-1$ - private final static String SCANNER_INFO_PROVIDER2_NAME = "ScannerInfoProvider2"; //$NON-NLS-1$ - private final static String SCANNER_INFO_PROVIDER2 = PLUGIN_ID + "." + SCANNER_INFO_PROVIDER2_NAME; //$NON-NLS-1$ + private static final String SCANNER_INFO_PROVIDER2_NAME = "ScannerInfoProvider2"; //$NON-NLS-1$ + private static final String SCANNER_INFO_PROVIDER2 = PLUGIN_ID + "." + SCANNER_INFO_PROVIDER2_NAME; //$NON-NLS-1$ /** * Name of the extension point for contributing a source code formatter @@ -158,27 +158,27 @@ public class CCorePlugin extends Plugin { /** * IContentType id for C Source Unit */ - public final static String CONTENT_TYPE_CSOURCE = "org.eclipse.cdt.core.cSource"; //$NON-NLS-1$ + public static final String CONTENT_TYPE_CSOURCE = "org.eclipse.cdt.core.cSource"; //$NON-NLS-1$ /** * IContentType id for C Header Unit */ - public final static String CONTENT_TYPE_CHEADER = "org.eclipse.cdt.core.cHeader"; //$NON-NLS-1$ + public static final String CONTENT_TYPE_CHEADER = "org.eclipse.cdt.core.cHeader"; //$NON-NLS-1$ /** * IContentType id for C++ Source Unit */ - public final static String CONTENT_TYPE_CXXSOURCE = "org.eclipse.cdt.core.cxxSource"; //$NON-NLS-1$ + public static final String CONTENT_TYPE_CXXSOURCE = "org.eclipse.cdt.core.cxxSource"; //$NON-NLS-1$ /** * IContentType id for C++ Header Unit */ - public final static String CONTENT_TYPE_CXXHEADER = "org.eclipse.cdt.core.cxxHeader"; //$NON-NLS-1$ + public static final String CONTENT_TYPE_CXXHEADER = "org.eclipse.cdt.core.cxxHeader"; //$NON-NLS-1$ /** * IContentType id for ASM Unit */ - public final static String CONTENT_TYPE_ASMSOURCE = "org.eclipse.cdt.core.asmSource"; //$NON-NLS-1$ + public static final String CONTENT_TYPE_ASMSOURCE = "org.eclipse.cdt.core.asmSource"; //$NON-NLS-1$ /** * IContentType id for Binary Files */ - public final static String CONTENT_TYPE_BINARYFILE = "org.eclipse.cdt.core.binaryFile"; //$NON-NLS-1$ + public static final String CONTENT_TYPE_BINARYFILE = "org.eclipse.cdt.core.binaryFile"; //$NON-NLS-1$ /** * Possible configurable option value. diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CContextType.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CContextType.java index dd1e243420b..5226b1c21b7 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CContextType.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CContextType.java @@ -9,7 +9,6 @@ * QNX Software Systems - Initial API and implementation * Anton Leherbauer (Wind River Systems) *******************************************************************************/ - package org.eclipse.cdt.internal.corext.template.c; import org.eclipse.jface.text.IDocument; @@ -21,29 +20,21 @@ import org.eclipse.cdt.core.model.ITranslationUnit; * A context type for C/C++ code. */ public class CContextType extends TranslationUnitContextType { - - public final static String ID = "org.eclipse.cdt.ui.text.templates.c"; //$NON-NLS-1$ + public static final String ID = "org.eclipse.cdt.ui.text.templates.c"; //$NON-NLS-1$ public CContextType() { super(); } - /* - * @see org.eclipse.cdt.internal.corext.template.c.TranslationUnitContextType#createContext(org.eclipse.jface.text.IDocument, int, int, org.eclipse.cdt.core.model.ITranslationUnit) - */ @Override public TranslationUnitContext createContext(IDocument document, int offset, int length, ITranslationUnit translationUnit) { return new CContext(this, document, offset, length, translationUnit); } - /* - * @see org.eclipse.cdt.internal.corext.template.c.TranslationUnitContextType#createContext(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.Position, org.eclipse.cdt.core.model.ITranslationUnit) - */ @Override public TranslationUnitContext createContext(IDocument document, Position position, ITranslationUnit translationUnit) { return new CContext(this, document, position, translationUnit); } - } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CDocumentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CDocumentProvider.java index 02fc42d18e8..ce961ad0d9f 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CDocumentProvider.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CDocumentProvider.java @@ -690,7 +690,7 @@ public class CDocumentProvider extends TextFileDocumentProvider { } /** Preference key for temporary problems */ - private final static String HANDLE_TEMPORARY_PROBLEMS= PreferenceConstants.EDITOR_EVALUATE_TEMPORARY_PROBLEMS; + private static final String HANDLE_TEMPORARY_PROBLEMS= PreferenceConstants.EDITOR_EVALUATE_TEMPORARY_PROBLEMS; /** Internal property changed listener */ private IPropertyChangeListener fPropertyListener; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java index 72b61b990f6..97de48f8931 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java @@ -1336,7 +1336,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi private SurroundWithActionGroup fSurroundWithActionGroup; /** Pairs of brackets, used to match. */ - protected final static char[] BRACKETS = { '{', '}', '(', ')', '[', ']', '<', '>' }; + protected static final char[] BRACKETS = { '{', '}', '(', ')', '[', ']', '<', '>' }; /** Matches the brackets. */ protected CPairMatcher fBracketMatcher = new CPairMatcher(BRACKETS); @@ -1348,24 +1348,24 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi private CEditorErrorTickUpdater fCEditorErrorTickUpdater; /** Preference key for sub-word navigation, aka smart caret positioning */ - public final static String SUB_WORD_NAVIGATION = "subWordNavigation"; //$NON-NLS-1$ + public static final String SUB_WORD_NAVIGATION = "subWordNavigation"; //$NON-NLS-1$ /** Preference key for matching brackets */ - public final static String MATCHING_BRACKETS = "matchingBrackets"; //$NON-NLS-1$ + public static final String MATCHING_BRACKETS = "matchingBrackets"; //$NON-NLS-1$ /** Preference key for matching brackets color */ - public final static String MATCHING_BRACKETS_COLOR = "matchingBracketsColor"; //$NON-NLS-1$ + public static final String MATCHING_BRACKETS_COLOR = "matchingBracketsColor"; //$NON-NLS-1$ /** Preference key for inactive code painter enablement */ public static final String INACTIVE_CODE_ENABLE = "inactiveCodeEnable"; //$NON-NLS-1$ /** Preference key for inactive code painter color */ public static final String INACTIVE_CODE_COLOR = "inactiveCodeColor"; //$NON-NLS-1$ /** Preference key for automatically closing strings */ - private final static String CLOSE_STRINGS = PreferenceConstants.EDITOR_CLOSE_STRINGS; + private static final String CLOSE_STRINGS = PreferenceConstants.EDITOR_CLOSE_STRINGS; /** Preference key for automatically closing brackets and parenthesis */ - private final static String CLOSE_BRACKETS = PreferenceConstants.EDITOR_CLOSE_BRACKETS; + private static final String CLOSE_BRACKETS = PreferenceConstants.EDITOR_CLOSE_BRACKETS; /** Preference key for automatically closing angular brackets */ - private final static String CLOSE_ANGULAR_BRACKETS = PreferenceConstants.EDITOR_CLOSE_ANGULAR_BRACKETS; + private static final String CLOSE_ANGULAR_BRACKETS = PreferenceConstants.EDITOR_CLOSE_ANGULAR_BRACKETS; /** Preference key for compiler task tags */ - private final static String TODO_TASK_TAGS = CCorePreferenceConstants.TODO_TASK_TAGS; + private static final String TODO_TASK_TAGS = CCorePreferenceConstants.TODO_TASK_TAGS; /** * This editor's projection support diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/CodeFormatterConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/CodeFormatterConfigurationBlock.java index 6efbd04161f..346a91df0f7 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/CodeFormatterConfigurationBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/CodeFormatterConfigurationBlock.java @@ -67,7 +67,7 @@ public class CodeFormatterConfigurationBlock extends ProfileConfigurationBlock { /** * Some C++ source code used for preview. */ - private final static String PREVIEW= + private static final String PREVIEW= "/*\n* " + //$NON-NLS-1$ FormatterMessages.CodingStyleConfigurationBlock_preview_title + "\n*/\n" + //$NON-NLS-1$ diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CBreakIterator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CBreakIterator.java index a870b9e4596..87ea1b17a5e 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CBreakIterator.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CBreakIterator.java @@ -151,7 +151,7 @@ public class CBreakIterator extends BreakIterator { private int fState; - private final static int[][] MATRIX= new int[][] { + private static final int[][] MATRIX= new int[][] { // K_INVALID, K_LOWER, K_UPPER, K_UNDERSCORE, K_OTHER { S_EXIT, S_LOWER, S_ONE_CAP, S_UNDERSCORE, S_LOWER }, // S_INIT { S_EXIT, S_LOWER, S_EXIT, S_UNDERSCORE, S_LOWER }, // S_LOWER diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHeuristicScanner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHeuristicScanner.java index 9c142012e8d..4a8a10c2c67 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHeuristicScanner.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHeuristicScanner.java @@ -262,7 +262,7 @@ public final class CHeuristicScanner implements Symbols { /* preset stop conditions */ private final StopCondition fNonWSDefaultPart= new NonWhitespaceDefaultPartition(); - private final static StopCondition fNonWS= new NonWhitespace(); + private static final StopCondition fNonWS= new NonWhitespace(); private final StopCondition fNonIdent= new NonJavaIdentifierPartDefaultPartition(); /** From e02293b2feedd333d03ac8d1b119a73584960c5b Mon Sep 17 00:00:00 2001 From: Marc-Andre Laperle Date: Tue, 15 May 2012 12:46:28 -0400 Subject: [PATCH 16/38] Bug 379490 - [Implement method] NPE when a method needing a parameter input is not selected --- .../implementmethod/ParameterNamesInputPage.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ParameterNamesInputPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ParameterNamesInputPage.java index f66f1b442cc..0de86606430 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ParameterNamesInputPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ParameterNamesInputPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik + * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik * Rapperswil, University of applied sciences and others * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -197,7 +197,14 @@ public class ParameterNamesInputPage extends UserInputWizardPage { } } + /** + * @return true if the preview job could still be running, false otherwise + */ protected boolean cancelPreviewJob() { + if (delayedPreviewUpdater == null) { + return false; + } + // We cannot rely on getState being accurate in all cases so we only use this // as a hint to change the preview text if (delayedPreviewUpdater.getState() != Job.NONE) { @@ -207,6 +214,10 @@ public class ParameterNamesInputPage extends UserInputWizardPage { } protected void joinPreviewJob() { + if (delayedPreviewUpdater == null) { + return; + } + try { delayedPreviewUpdater.join(); } catch (InterruptedException e1) { From a37a37d4c1a8ddfdd70645e36706cf4ca5280d85 Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Tue, 15 May 2012 19:01:08 -0700 Subject: [PATCH 17/38] Cosmetics. --- .../org/eclipse/cdt/core/model/CoreModel.java | 1 - .../dom/ast/IASTCompositeTypeSpecifier.java | 1 - .../dom/ast/IASTElaboratedTypeSpecifier.java | 12 +- .../dom/ast/IASTEnumerationSpecifier.java | 13 +- .../core/dom/ast/IASTNamedTypeSpecifier.java | 6 +- .../core/dom/ast/IASTSimpleDeclSpecifier.java | 10 +- .../core/dom/ast/c/ICASTDeclSpecifier.java | 6 +- .../dom/ast/cpp/ICPPASTDeclSpecifier.java | 20 +- .../dom/ast/gnu/cpp/IGPPASTDeclSpecifier.java | 3 +- .../parser/cpp/CPPASTBaseDeclSpecifier.java | 5 +- .../cpp/CPPASTElaboratedTypeSpecifier.java | 3 +- .../cpp/CPPASTEnumerationSpecifier.java | 16 +- .../parser/cpp/CPPASTNamedTypeSpecifier.java | 15 +- .../parser/cpp/CPPASTSimpleDeclSpecifier.java | 12 +- .../core/parser/token/KeywordSets.java | 922 +++++++++--------- 15 files changed, 493 insertions(+), 552 deletions(-) diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java index b6eda1977bf..313cc76e9e2 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java @@ -376,7 +376,6 @@ public class CoreModel { return null; } - /** * Return true if project has C nature. */ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTCompositeTypeSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTCompositeTypeSpecifier.java index c4c407f62a7..329de465334 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTCompositeTypeSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTCompositeTypeSpecifier.java @@ -17,7 +17,6 @@ package org.eclipse.cdt.core.dom.ast; * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTCompositeTypeSpecifier extends IASTDeclSpecifier, IASTNameOwner, IASTDeclarationListOwner { - /** * TYPE_NAME represents the relationship between an * IASTCompositeTypeSpecifier and its IASTName. diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTElaboratedTypeSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTElaboratedTypeSpecifier.java index 9b6f7879f84..4bb8807777f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTElaboratedTypeSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTElaboratedTypeSpecifier.java @@ -17,7 +17,6 @@ package org.eclipse.cdt.core.dom.ast; * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTElaboratedTypeSpecifier extends IASTDeclSpecifier, IASTNameOwner { - /** * Enumeration. */ @@ -39,17 +38,16 @@ public interface IASTElaboratedTypeSpecifier extends IASTDeclSpecifier, IASTName public static final int k_last = k_union; /** - * Get the kind. + * Returns the kind. * * @return int (kind). */ public int getKind(); /** - * Set the kind. + * Sets the kind. * - * @param value - * int (kind) + * @param value int (kind) */ public void setKind(int value); @@ -61,14 +59,14 @@ public interface IASTElaboratedTypeSpecifier extends IASTDeclSpecifier, IASTName "IASTElaboratedTypeSpecifier.TYPE_NAME - IASTName for IASTElaboratedTypeSpecifier"); //$NON-NLS-1$ /** - * Get the name. + * Returns the name. * * @return IASTName */ public IASTName getName(); /** - * Set the name. + * Sets the name. * * @param name * IASTName diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTEnumerationSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTEnumerationSpecifier.java index db16a75e72f..f61564f2c8d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTEnumerationSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTEnumerationSpecifier.java @@ -6,7 +6,7 @@ * 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.core.dom.ast; @@ -17,7 +17,6 @@ package org.eclipse.cdt.core.dom.ast; * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTEnumerationSpecifier extends IASTDeclSpecifier, IASTNameOwner { - /** * This interface represents an enumerator member of an enum specifier. * @@ -59,14 +58,14 @@ public interface IASTEnumerationSpecifier extends IASTDeclSpecifier, IASTNameOwn "IASTEnumerator.ENUMERATOR_VALUE - IASTExpression (value) for IASTEnumerator"); //$NON-NLS-1$ /** - * Set enumerator value. + * Sets enumerator value. * * @param expression */ public void setValue(IASTExpression expression); /** - * Get enumerator value. + * Returns enumerator value. * * @return IASTExpression value */ @@ -95,7 +94,7 @@ public interface IASTEnumerationSpecifier extends IASTDeclSpecifier, IASTNameOwn "IASTEnumerationSpecifier.ENUMERATOR - nested IASTEnumerator for IASTEnumerationSpecifier"); //$NON-NLS-1$ /** - * Add an enumerator. + * Adds an enumerator. * * @param enumerator * IASTEnumerator @@ -103,7 +102,7 @@ public interface IASTEnumerationSpecifier extends IASTDeclSpecifier, IASTNameOwn public void addEnumerator(IASTEnumerator enumerator); /** - * Get enumerators. + * Returns enumerators. * * @return IASTEnumerator [] array */ @@ -117,7 +116,7 @@ public interface IASTEnumerationSpecifier extends IASTDeclSpecifier, IASTNameOwn "IASTEnumerationSpecifier.ENUMERATION_NAME - IASTName for IASTEnumerationSpecifier"); //$NON-NLS-1$ /** - * Set the enum's name. + * Sets the enum's name. * * @param name */ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTNamedTypeSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTNamedTypeSpecifier.java index 06079daeb77..2b4063958e9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTNamedTypeSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTNamedTypeSpecifier.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Doug Schaefer (IBM) - Initial API and implementation + * Doug Schaefer (IBM) - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.core.dom.ast; @@ -18,11 +18,9 @@ package org.eclipse.cdt.core.dom.ast; * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTNamedTypeSpecifier extends IASTDeclSpecifier, IASTNameOwner { - /** * NAME describes the relationship between an - * IASTNamedTypeSpecifier and its nested - * IASTName. + * IASTNamedTypeSpecifier and its nested IASTName. */ public static final ASTNodeProperty NAME = new ASTNodeProperty("IASTNamedTypeSpecifier.NAME - IASTName for IASTNamedTypeSpecifier"); //$NON-NLS-1$ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTSimpleDeclSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTSimpleDeclSpecifier.java index aa2cf3b3561..b10654669a4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTSimpleDeclSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTSimpleDeclSpecifier.java @@ -6,9 +6,9 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Doug Schaefer (IBM) - Initial API and implementation - * Markus Schorn (Wind River Systems) - * Sergey Prigogin (Google) + * Doug Schaefer (IBM) - Initial API and implementation + * Markus Schorn (Wind River Systems) + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.core.dom.ast; @@ -27,7 +27,6 @@ public interface IASTSimpleDeclSpecifier extends IASTDeclSpecifier { public static final ASTNodeProperty DECLTYPE_EXPRESSION = new ASTNodeProperty( "IASTSimpleDeclSpecifier.EXPRESSION [IASTExpression]"); //$NON-NLS-1$ - /** * Used for omitted declaration specifiers. E.g. for declaration of constructors, * or in plain c, where this defaults to an integer. @@ -109,7 +108,7 @@ public interface IASTSimpleDeclSpecifier extends IASTDeclSpecifier { public IASTSimpleDeclSpecifier copy(); /** - * This returns the built-in type for the declaration. The type is then + * Returns the built-in type for the declaration. The type is then * refined by qualifiers for signed/unsigned and short/long. The type could * also be unspecified which usually means int. */ @@ -231,5 +230,4 @@ public interface IASTSimpleDeclSpecifier extends IASTDeclSpecifier { */ @Deprecated public static final int t_last = t_double; // used only in subclasses - } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTDeclSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTDeclSpecifier.java index 14ba0dc05b3..6828ff1c0a7 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTDeclSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTDeclSpecifier.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Doug Schaefer (IBM) - Initial API and implementation - * Markus Schorn (Wind River Systems) + * Doug Schaefer (IBM) - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.core.dom.ast.c; @@ -20,11 +20,9 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; * @noimplement This interface is not intended to be implemented by clients. */ public interface ICASTDeclSpecifier extends IASTDeclSpecifier { - /** * @since 5.1 */ @Override public ICASTDeclSpecifier copy(); - } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTDeclSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTDeclSpecifier.java index 16567e54292..0374605f39b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTDeclSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTDeclSpecifier.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Doug Schaefer (IBM) - Initial API and implementation - * Markus Schorn (Wind River Systems) + * Doug Schaefer (IBM) - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.core.dom.ast.cpp; @@ -20,7 +20,6 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPASTDeclSpecifier extends IASTDeclSpecifier { - // A declaration in C++ can be a friend declaration /** * Is this a friend declaration? @@ -30,10 +29,9 @@ public interface ICPPASTDeclSpecifier extends IASTDeclSpecifier { public boolean isFriend(); /** - * Set this to be a friend declaration true/false. + * Sets this to be a friend declaration true/false. * - * @param value - * boolean + * @param value the new value */ public void setFriend(boolean value); @@ -45,10 +43,9 @@ public interface ICPPASTDeclSpecifier extends IASTDeclSpecifier { public boolean isVirtual(); /** - * Set this declaration to be virutal. + * Sets this declaration to be virtual. * - * @param value - * boolean + * @param value the new value */ public void setVirtual(boolean value); @@ -60,10 +57,9 @@ public interface ICPPASTDeclSpecifier extends IASTDeclSpecifier { public boolean isExplicit(); /** - * Set this to be an explicit constructor. + * Sets this to be an explicit constructor. * - * @param value - * boolean + * @param value the new value */ public void setExplicit(boolean value); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/IGPPASTDeclSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/IGPPASTDeclSpecifier.java index 9650c5cfc63..5e4a6535109 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/IGPPASTDeclSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/IGPPASTDeclSpecifier.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * John Camelon (IBM) - Initial API and implementation + * John Camelon (IBM) - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.core.dom.ast.gnu.cpp; @@ -21,7 +21,6 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; */ @Deprecated public interface IGPPASTDeclSpecifier extends IASTDeclSpecifier { - /** * @since 5.1 */ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBaseDeclSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBaseDeclSpecifier.java index 189abc2122c..a987b133687 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBaseDeclSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBaseDeclSpecifier.java @@ -6,8 +6,8 @@ * 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; @@ -19,7 +19,6 @@ import org.eclipse.cdt.internal.core.model.ASTStringUtil; * Base for all c++ declaration specifiers */ public abstract class CPPASTBaseDeclSpecifier extends ASTNode implements ICPPASTDeclSpecifier { - private boolean friend; private boolean inline; private boolean isConst; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTElaboratedTypeSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTElaboratedTypeSpecifier.java index a849ef06555..a730058492d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTElaboratedTypeSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTElaboratedTypeSpecifier.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM - Initial API and implementation + * IBM - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -27,7 +27,6 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTInternalNameOwner; */ public class CPPASTElaboratedTypeSpecifier extends CPPASTBaseDeclSpecifier implements ICPPASTElaboratedTypeSpecifier, IASTInternalNameOwner { - private int kind; private IASTName name; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTEnumerationSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTEnumerationSpecifier.java index 9da28755ffa..f91b784b2f8 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTEnumerationSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTEnumerationSpecifier.java @@ -6,8 +6,8 @@ * 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; @@ -24,16 +24,15 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTInternalEnumerationSpecifier */ public class CPPASTEnumerationSpecifier extends CPPASTBaseDeclSpecifier implements IASTInternalEnumerationSpecifier, ICPPASTEnumerationSpecifier { - private boolean fIsScoped; private boolean fIsOpaque; private IASTName fName; private ICPPASTDeclSpecifier fBaseType; - private IASTEnumerator[] fItems = null; - private int fItemPos=-1; + private IASTEnumerator[] fItems; + private int fItemPos= -1; - private boolean fValuesComputed= false; + private boolean fValuesComputed; private CPPEnumScope fScope; public CPPASTEnumerationSpecifier() { @@ -52,8 +51,9 @@ public class CPPASTEnumerationSpecifier extends CPPASTBaseDeclSpecifier @Override public CPPASTEnumerationSpecifier copy(CopyStyle style) { - CPPASTEnumerationSpecifier copy = new CPPASTEnumerationSpecifier(fIsScoped, fName == null - ? null : fName.copy(style), fBaseType == null ? null : fBaseType.copy(style)); + CPPASTEnumerationSpecifier copy = + new CPPASTEnumerationSpecifier(fIsScoped, fName == null ? null : fName.copy(style), + fBaseType == null ? null : fBaseType.copy(style)); copy.fIsOpaque = fIsOpaque; for (IASTEnumerator enumerator : getEnumerators()) copy.addEnumerator(enumerator == null ? null : enumerator.copy(style)); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNamedTypeSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNamedTypeSpecifier.java index e95210e6519..4f9fe0081af 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNamedTypeSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNamedTypeSpecifier.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * John Camelon (IBM) - Initial API and implementation - * Bryan Wilkinson (QNX) + * John Camelon (IBM) - Initial API and implementation + * Bryan Wilkinson (QNX) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -26,12 +26,10 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics; -public class CPPASTNamedTypeSpecifier extends CPPASTBaseDeclSpecifier implements - ICPPASTNamedTypeSpecifier, ICPPASTCompletionContext { - +public class CPPASTNamedTypeSpecifier extends CPPASTBaseDeclSpecifier + implements ICPPASTNamedTypeSpecifier, ICPPASTCompletionContext { private boolean typename; private IASTName name; - public CPPASTNamedTypeSpecifier() { } @@ -47,8 +45,8 @@ public class CPPASTNamedTypeSpecifier extends CPPASTBaseDeclSpecifier implements @Override public CPPASTNamedTypeSpecifier copy(CopyStyle style) { - CPPASTNamedTypeSpecifier copy = new CPPASTNamedTypeSpecifier(name == null ? null - : name.copy(style)); + CPPASTNamedTypeSpecifier copy = + new CPPASTNamedTypeSpecifier(name == null ? null : name.copy(style)); copyBaseDeclSpec(copy); copy.typename = typename; if (style == CopyStyle.withLocations) { @@ -73,7 +71,6 @@ public class CPPASTNamedTypeSpecifier extends CPPASTBaseDeclSpecifier implements return name; } - @Override public void setName(IASTName name) { assertNotFrozen(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleDeclSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleDeclSpecifier.java index 66ff6e4d8e1..bf020df8804 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleDeclSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleDeclSpecifier.java @@ -6,8 +6,8 @@ * 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; @@ -18,16 +18,16 @@ import org.eclipse.cdt.core.dom.ast.IBasicType.Kind; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleDeclSpecifier; import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; -public class CPPASTSimpleDeclSpecifier extends CPPASTBaseDeclSpecifier implements ICPPASTSimpleDeclSpecifier, - IASTAmbiguityParent { +public class CPPASTSimpleDeclSpecifier extends CPPASTBaseDeclSpecifier + implements ICPPASTSimpleDeclSpecifier, IASTAmbiguityParent { private int type; private boolean isSigned; private boolean isUnsigned; private boolean isShort; private boolean isLong; private boolean isLonglong; - private boolean isComplex=false; - private boolean isImaginary=false; + private boolean isComplex; + private boolean isImaginary; private IASTExpression fDeclTypeExpression; @Override diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/token/KeywordSets.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/token/KeywordSets.java index 86cdeedf82b..20553a044b5 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/token/KeywordSets.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/token/KeywordSets.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * John Camelon (IBM Rational Software) - Initial API and implementation - * Markus Schorn (Wind River Systems) + * John Camelon (IBM Rational Software) - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.parser.token; @@ -24,42 +24,40 @@ import org.eclipse.cdt.core.parser.ParserLanguage; public class KeywordSets { - public static Set getKeywords( KeywordSetKey kind, ParserLanguage language ) - { - if( kind == KeywordSetKey.EMPTY ) + public static Set getKeywords(KeywordSetKey kind, ParserLanguage language) { + if (kind == KeywordSetKey.EMPTY) return EMPTY_TABLE; - if( kind == KeywordSetKey.DECL_SPECIFIER_SEQUENCE ) - return DECL_SPECIFIER_SEQUENCE_TABLE.get( language ); - if( kind == KeywordSetKey.DECLARATION ) - return DECLARATION_TABLE.get( language ); - if( kind == KeywordSetKey.STATEMENT ) - return STATEMENT_TABLE.get( language ); - if( kind == KeywordSetKey.BASE_SPECIFIER ) + if (kind == KeywordSetKey.DECL_SPECIFIER_SEQUENCE) + return DECL_SPECIFIER_SEQUENCE_TABLE.get(language); + if (kind == KeywordSetKey.DECLARATION) + return DECLARATION_TABLE.get(language); + if (kind == KeywordSetKey.STATEMENT) + return STATEMENT_TABLE.get(language); + if (kind == KeywordSetKey.BASE_SPECIFIER) return BASE_SPECIFIER_CPP; - if( kind == KeywordSetKey.MEMBER ) - { - if( language == ParserLanguage.CPP ) + if (kind == KeywordSetKey.MEMBER) { + if (language == ParserLanguage.CPP) return CLASS_MEMBER; return EMPTY_TABLE; } - if( kind == KeywordSetKey.POST_USING ) + if (kind == KeywordSetKey.POST_USING) return POST_USING_CPP; - if( kind == KeywordSetKey.FUNCTION_MODIFIER ) - return FUNCTION_MODIFIER_TABLE.get( language ); - if( kind == KeywordSetKey.NAMESPACE_ONLY ) + if (kind == KeywordSetKey.FUNCTION_MODIFIER) + return FUNCTION_MODIFIER_TABLE.get(language); + if (kind == KeywordSetKey.NAMESPACE_ONLY) return NAMESPACE_ONLY_SET; - if( kind == KeywordSetKey.MACRO ) + if (kind == KeywordSetKey.MACRO) return MACRO_ONLY; - if( kind == KeywordSetKey.PP_DIRECTIVE ) - return PP_DIRECTIVES_TABLE.get( language ); - if( kind == KeywordSetKey.EXPRESSION ) - return EXPRESSION_TABLE.get( language ); - if( kind == KeywordSetKey.ALL ) - return ALL_TABLE.get( language ); - if( kind == KeywordSetKey.KEYWORDS ) - return KEYWORDS_TABLE.get( language ); - if( kind == KeywordSetKey.TYPES ) - return TYPES_TABLE.get( language ); + if (kind == KeywordSetKey.PP_DIRECTIVE) + return PP_DIRECTIVES_TABLE.get(language); + if (kind == KeywordSetKey.EXPRESSION) + return EXPRESSION_TABLE.get(language); + if (kind == KeywordSetKey.ALL) + return ALL_TABLE.get(language); + if (kind == KeywordSetKey.KEYWORDS) + return KEYWORDS_TABLE.get(language); + if (kind == KeywordSetKey.TYPES) + return TYPES_TABLE.get(language); //TODO finish this return null; } @@ -67,209 +65,192 @@ public class KeywordSets { private static final Set EMPTY_TABLE = new HashSet(0); private static final Set NAMESPACE_ONLY_SET; - static - { + static { NAMESPACE_ONLY_SET = new HashSet(1); - NAMESPACE_ONLY_SET.add(Keywords.NAMESPACE ); + NAMESPACE_ONLY_SET.add(Keywords.NAMESPACE); } private static final Set MACRO_ONLY; - static - { + static { MACRO_ONLY = new HashSet(1); - MACRO_ONLY.add("defined()" ); //$NON-NLS-1$ + MACRO_ONLY.add("defined()"); //$NON-NLS-1$ } - - + private static final Set DECL_SPECIFIER_SEQUENCE_C; - static - { + static { DECL_SPECIFIER_SEQUENCE_C = new TreeSet(); - DECL_SPECIFIER_SEQUENCE_C.add( Keywords.INLINE ); - DECL_SPECIFIER_SEQUENCE_C.add( Keywords.AUTO); - DECL_SPECIFIER_SEQUENCE_C.add( Keywords.REGISTER); - DECL_SPECIFIER_SEQUENCE_C.add( Keywords.STATIC); - DECL_SPECIFIER_SEQUENCE_C.add( Keywords.EXTERN); - DECL_SPECIFIER_SEQUENCE_C.add( Keywords.MUTABLE); - DECL_SPECIFIER_SEQUENCE_C.add( Keywords.TYPEDEF); - DECL_SPECIFIER_SEQUENCE_C.add( Keywords.CONST); - DECL_SPECIFIER_SEQUENCE_C.add( Keywords.VOLATILE); - DECL_SPECIFIER_SEQUENCE_C.add( Keywords.SIGNED); - DECL_SPECIFIER_SEQUENCE_C.add( Keywords.UNSIGNED); - DECL_SPECIFIER_SEQUENCE_C.add( Keywords.SHORT); - DECL_SPECIFIER_SEQUENCE_C.add( Keywords.LONG); - DECL_SPECIFIER_SEQUENCE_C.add( Keywords._COMPLEX); - DECL_SPECIFIER_SEQUENCE_C.add( Keywords._IMAGINARY); - DECL_SPECIFIER_SEQUENCE_C.add( Keywords.CHAR); - DECL_SPECIFIER_SEQUENCE_C.add( Keywords._BOOL); - DECL_SPECIFIER_SEQUENCE_C.add( Keywords.INT); - DECL_SPECIFIER_SEQUENCE_C.add( Keywords.FLOAT); - DECL_SPECIFIER_SEQUENCE_C.add( Keywords.DOUBLE); - DECL_SPECIFIER_SEQUENCE_C.add( Keywords.VOID); - DECL_SPECIFIER_SEQUENCE_C.add( Keywords.STRUCT); - DECL_SPECIFIER_SEQUENCE_C.add( Keywords.UNION); - DECL_SPECIFIER_SEQUENCE_C.add( Keywords.ENUM); + DECL_SPECIFIER_SEQUENCE_C.add(Keywords.INLINE); + DECL_SPECIFIER_SEQUENCE_C.add(Keywords.AUTO); + DECL_SPECIFIER_SEQUENCE_C.add(Keywords.REGISTER); + DECL_SPECIFIER_SEQUENCE_C.add(Keywords.STATIC); + DECL_SPECIFIER_SEQUENCE_C.add(Keywords.EXTERN); + DECL_SPECIFIER_SEQUENCE_C.add(Keywords.MUTABLE); + DECL_SPECIFIER_SEQUENCE_C.add(Keywords.TYPEDEF); + DECL_SPECIFIER_SEQUENCE_C.add(Keywords.CONST); + DECL_SPECIFIER_SEQUENCE_C.add(Keywords.VOLATILE); + DECL_SPECIFIER_SEQUENCE_C.add(Keywords.SIGNED); + DECL_SPECIFIER_SEQUENCE_C.add(Keywords.UNSIGNED); + DECL_SPECIFIER_SEQUENCE_C.add(Keywords.SHORT); + DECL_SPECIFIER_SEQUENCE_C.add(Keywords.LONG); + DECL_SPECIFIER_SEQUENCE_C.add(Keywords._COMPLEX); + DECL_SPECIFIER_SEQUENCE_C.add(Keywords._IMAGINARY); + DECL_SPECIFIER_SEQUENCE_C.add(Keywords.CHAR); + DECL_SPECIFIER_SEQUENCE_C.add(Keywords._BOOL); + DECL_SPECIFIER_SEQUENCE_C.add(Keywords.INT); + DECL_SPECIFIER_SEQUENCE_C.add(Keywords.FLOAT); + DECL_SPECIFIER_SEQUENCE_C.add(Keywords.DOUBLE); + DECL_SPECIFIER_SEQUENCE_C.add(Keywords.VOID); + DECL_SPECIFIER_SEQUENCE_C.add(Keywords.STRUCT); + DECL_SPECIFIER_SEQUENCE_C.add(Keywords.UNION); + DECL_SPECIFIER_SEQUENCE_C.add(Keywords.ENUM); } private static final Set DECL_SPECIFIER_SEQUENCE_CPP; - static - { + static { DECL_SPECIFIER_SEQUENCE_CPP = new TreeSet(); // add all of C then remove the ones we don't need - DECL_SPECIFIER_SEQUENCE_CPP.addAll( DECL_SPECIFIER_SEQUENCE_C ); - DECL_SPECIFIER_SEQUENCE_CPP.remove( Keywords._COMPLEX); - DECL_SPECIFIER_SEQUENCE_CPP.remove( Keywords._IMAGINARY); - DECL_SPECIFIER_SEQUENCE_CPP.remove( Keywords._BOOL); + DECL_SPECIFIER_SEQUENCE_CPP.addAll(DECL_SPECIFIER_SEQUENCE_C); + DECL_SPECIFIER_SEQUENCE_CPP.remove(Keywords._COMPLEX); + DECL_SPECIFIER_SEQUENCE_CPP.remove(Keywords._IMAGINARY); + DECL_SPECIFIER_SEQUENCE_CPP.remove(Keywords._BOOL); // CPP specific stuff - DECL_SPECIFIER_SEQUENCE_CPP.add( Keywords.WCHAR_T); - DECL_SPECIFIER_SEQUENCE_CPP.add( Keywords.CHAR16_T); - DECL_SPECIFIER_SEQUENCE_CPP.add( Keywords.CHAR32_T); + DECL_SPECIFIER_SEQUENCE_CPP.add(Keywords.WCHAR_T); + DECL_SPECIFIER_SEQUENCE_CPP.add(Keywords.CHAR16_T); + DECL_SPECIFIER_SEQUENCE_CPP.add(Keywords.CHAR32_T); - DECL_SPECIFIER_SEQUENCE_CPP.add( Keywords.VIRTUAL); - DECL_SPECIFIER_SEQUENCE_CPP.add( Keywords.MUTABLE); - DECL_SPECIFIER_SEQUENCE_CPP.add( Keywords.EXPLICIT); - DECL_SPECIFIER_SEQUENCE_CPP.add( Keywords.FRIEND); - DECL_SPECIFIER_SEQUENCE_CPP.add( Keywords.BOOL); - DECL_SPECIFIER_SEQUENCE_CPP.add( Keywords.TYPENAME); - DECL_SPECIFIER_SEQUENCE_CPP.add( Keywords.CLASS); + DECL_SPECIFIER_SEQUENCE_CPP.add(Keywords.VIRTUAL); + DECL_SPECIFIER_SEQUENCE_CPP.add(Keywords.MUTABLE); + DECL_SPECIFIER_SEQUENCE_CPP.add(Keywords.EXPLICIT); + DECL_SPECIFIER_SEQUENCE_CPP.add(Keywords.FRIEND); + DECL_SPECIFIER_SEQUENCE_CPP.add(Keywords.BOOL); + DECL_SPECIFIER_SEQUENCE_CPP.add(Keywords.TYPENAME); + DECL_SPECIFIER_SEQUENCE_CPP.add(Keywords.CLASS); } - private static final Map> DECL_SPECIFIER_SEQUENCE_TABLE; - static - { - DECL_SPECIFIER_SEQUENCE_TABLE = new HashMap>(); - DECL_SPECIFIER_SEQUENCE_TABLE.put( ParserLanguage.CPP, DECL_SPECIFIER_SEQUENCE_CPP ); - DECL_SPECIFIER_SEQUENCE_TABLE.put( ParserLanguage.C, DECL_SPECIFIER_SEQUENCE_C ); + private static final Map> DECL_SPECIFIER_SEQUENCE_TABLE; + static { + DECL_SPECIFIER_SEQUENCE_TABLE = new HashMap>(); + DECL_SPECIFIER_SEQUENCE_TABLE.put(ParserLanguage.CPP, DECL_SPECIFIER_SEQUENCE_CPP); + DECL_SPECIFIER_SEQUENCE_TABLE.put(ParserLanguage.C, DECL_SPECIFIER_SEQUENCE_C); } private static final Set DECLARATION_CPP; - static - { + static { DECLARATION_CPP = new TreeSet(); - DECLARATION_CPP.addAll( DECL_SPECIFIER_SEQUENCE_CPP ); - DECLARATION_CPP.add( Keywords.ASM ); - DECLARATION_CPP.add( Keywords.TEMPLATE ); - DECLARATION_CPP.add( Keywords.USING ); - DECLARATION_CPP.add( Keywords.NAMESPACE ); - DECLARATION_CPP.add( Keywords.EXPORT ); - DECLARATION_CPP.add( Keywords.STATIC_ASSERT ); + DECLARATION_CPP.addAll(DECL_SPECIFIER_SEQUENCE_CPP); + DECLARATION_CPP.add(Keywords.ASM); + DECLARATION_CPP.add(Keywords.TEMPLATE); + DECLARATION_CPP.add(Keywords.USING); + DECLARATION_CPP.add(Keywords.NAMESPACE); + DECLARATION_CPP.add(Keywords.EXPORT); + DECLARATION_CPP.add(Keywords.STATIC_ASSERT); } private static final Set DECLARATION_C; - static - { + static { DECLARATION_C = new TreeSet(); - DECLARATION_C.addAll(DECL_SPECIFIER_SEQUENCE_C ); - DECLARATION_C.add(Keywords.ASM ); + DECLARATION_C.addAll(DECL_SPECIFIER_SEQUENCE_C); + DECLARATION_C.add(Keywords.ASM); } - private static final Map> DECLARATION_TABLE; - static - { - DECLARATION_TABLE = new HashMap>(); - DECLARATION_TABLE.put( ParserLanguage.CPP, DECLARATION_CPP ); - DECLARATION_TABLE.put( ParserLanguage.C, DECLARATION_C ); + private static final Map> DECLARATION_TABLE; + static { + DECLARATION_TABLE = new HashMap>(2); + DECLARATION_TABLE.put(ParserLanguage.CPP, DECLARATION_CPP); + DECLARATION_TABLE.put(ParserLanguage.C, DECLARATION_C); } private static final Set EXPRESSION_C; - static - { + static { EXPRESSION_C = new TreeSet(); - EXPRESSION_C.add( Keywords.CHAR ); - EXPRESSION_C.add( Keywords.SHORT); - EXPRESSION_C.add( Keywords.INT); - EXPRESSION_C.add( Keywords.LONG); - EXPRESSION_C.add( Keywords.SIGNED); - EXPRESSION_C.add( Keywords.UNSIGNED); - EXPRESSION_C.add( Keywords.FLOAT); - EXPRESSION_C.add( Keywords.DOUBLE); - EXPRESSION_C.add( Keywords.SIZEOF ); - + EXPRESSION_C.add(Keywords.CHAR); + EXPRESSION_C.add(Keywords.SHORT); + EXPRESSION_C.add(Keywords.INT); + EXPRESSION_C.add(Keywords.LONG); + EXPRESSION_C.add(Keywords.SIGNED); + EXPRESSION_C.add(Keywords.UNSIGNED); + EXPRESSION_C.add(Keywords.FLOAT); + EXPRESSION_C.add(Keywords.DOUBLE); + EXPRESSION_C.add(Keywords.SIZEOF); } private static final Set EXPRESSION_CPP; - static - { + static { EXPRESSION_CPP = new TreeSet(EXPRESSION_C); - EXPRESSION_CPP.add( Keywords.BOOL ); - EXPRESSION_CPP.add( Keywords.CHAR16_T ); - EXPRESSION_CPP.add( Keywords.CHAR32_T ); - EXPRESSION_CPP.add( Keywords.WCHAR_T ); - EXPRESSION_CPP.add( Keywords.NEW ); - EXPRESSION_CPP.add( Keywords.DELETE ); - EXPRESSION_CPP.add( Keywords.TYPENAME ); - EXPRESSION_CPP.add( Keywords.DYNAMIC_CAST ); - EXPRESSION_CPP.add( Keywords.STATIC_CAST ); - EXPRESSION_CPP.add( Keywords.REINTERPRET_CAST ); - EXPRESSION_CPP.add( Keywords.CONST_CAST ); - EXPRESSION_CPP.add( Keywords.TYPEID ); - EXPRESSION_CPP.add( Keywords.TRUE ); - EXPRESSION_CPP.add( Keywords.FALSE ); - EXPRESSION_CPP.add( Keywords.THIS ); - EXPRESSION_CPP.add( Keywords.OPERATOR ); - EXPRESSION_CPP.add( Keywords.THROW ); + EXPRESSION_CPP.add(Keywords.BOOL); + EXPRESSION_CPP.add(Keywords.CHAR16_T); + EXPRESSION_CPP.add(Keywords.CHAR32_T); + EXPRESSION_CPP.add(Keywords.WCHAR_T); + EXPRESSION_CPP.add(Keywords.NEW); + EXPRESSION_CPP.add(Keywords.DELETE); + EXPRESSION_CPP.add(Keywords.TYPENAME); + EXPRESSION_CPP.add(Keywords.DYNAMIC_CAST); + EXPRESSION_CPP.add(Keywords.STATIC_CAST); + EXPRESSION_CPP.add(Keywords.REINTERPRET_CAST); + EXPRESSION_CPP.add(Keywords.CONST_CAST); + EXPRESSION_CPP.add(Keywords.TYPEID); + EXPRESSION_CPP.add(Keywords.TRUE); + EXPRESSION_CPP.add(Keywords.FALSE); + EXPRESSION_CPP.add(Keywords.THIS); + EXPRESSION_CPP.add(Keywords.OPERATOR); + EXPRESSION_CPP.add(Keywords.THROW); } - private static final Map> EXPRESSION_TABLE; - static - { - EXPRESSION_TABLE = new HashMap>(); - EXPRESSION_TABLE.put( ParserLanguage.CPP, EXPRESSION_CPP ); - EXPRESSION_TABLE.put( ParserLanguage.C, EXPRESSION_C ); + private static final Map> EXPRESSION_TABLE; + static { + EXPRESSION_TABLE = new HashMap>(2); + EXPRESSION_TABLE.put(ParserLanguage.CPP, EXPRESSION_CPP); + EXPRESSION_TABLE.put(ParserLanguage.C, EXPRESSION_C); } private static final Set STATEMENT_C; - static - { + static { STATEMENT_C= new TreeSet(); - STATEMENT_C.addAll( DECLARATION_C ); - STATEMENT_C.addAll( EXPRESSION_C ); - STATEMENT_C.add( Keywords.FOR ); - STATEMENT_C.add( Keywords.BREAK ); - STATEMENT_C.add( Keywords.CASE ); - STATEMENT_C.add( Keywords.GOTO ); - STATEMENT_C.add( Keywords.SWITCH ); - STATEMENT_C.add( Keywords.WHILE ); - STATEMENT_C.add( Keywords.IF); - STATEMENT_C.add( Keywords.CONTINUE); - STATEMENT_C.add( Keywords.DEFAULT); - STATEMENT_C.add( Keywords.RETURN); - STATEMENT_C.add( Keywords.ELSE); - STATEMENT_C.add( Keywords.DO); + STATEMENT_C.addAll(DECLARATION_C); + STATEMENT_C.addAll(EXPRESSION_C); + STATEMENT_C.add(Keywords.FOR); + STATEMENT_C.add(Keywords.BREAK); + STATEMENT_C.add(Keywords.CASE); + STATEMENT_C.add(Keywords.GOTO); + STATEMENT_C.add(Keywords.SWITCH); + STATEMENT_C.add(Keywords.WHILE); + STATEMENT_C.add(Keywords.IF); + STATEMENT_C.add(Keywords.CONTINUE); + STATEMENT_C.add(Keywords.DEFAULT); + STATEMENT_C.add(Keywords.RETURN); + STATEMENT_C.add(Keywords.ELSE); + STATEMENT_C.add(Keywords.DO); } private static final Set STATEMENT_CPP; - static - { - STATEMENT_CPP = new TreeSet( DECLARATION_CPP ); - STATEMENT_CPP.addAll( EXPRESSION_CPP ); - STATEMENT_CPP.add( Keywords.TRY ); - STATEMENT_CPP.add( Keywords.FOR ); - STATEMENT_CPP.add( Keywords.BREAK ); - STATEMENT_CPP.add( Keywords.CASE ); - STATEMENT_CPP.add( Keywords.CATCH ); - STATEMENT_CPP.add( Keywords.GOTO ); - STATEMENT_CPP.add( Keywords.SWITCH ); - STATEMENT_CPP.add( Keywords.WHILE ); - STATEMENT_CPP.add( Keywords.IF); - STATEMENT_CPP.add( Keywords.CONTINUE); - STATEMENT_CPP.add( Keywords.DEFAULT); - STATEMENT_CPP.add( Keywords.RETURN); - STATEMENT_CPP.add( Keywords.ELSE); - STATEMENT_CPP.add( Keywords.DO); + static { + STATEMENT_CPP = new TreeSet(DECLARATION_CPP); + STATEMENT_CPP.addAll(EXPRESSION_CPP); + STATEMENT_CPP.add(Keywords.TRY); + STATEMENT_CPP.add(Keywords.FOR); + STATEMENT_CPP.add(Keywords.BREAK); + STATEMENT_CPP.add(Keywords.CASE); + STATEMENT_CPP.add(Keywords.CATCH); + STATEMENT_CPP.add(Keywords.GOTO); + STATEMENT_CPP.add(Keywords.SWITCH); + STATEMENT_CPP.add(Keywords.WHILE); + STATEMENT_CPP.add(Keywords.IF); + STATEMENT_CPP.add(Keywords.CONTINUE); + STATEMENT_CPP.add(Keywords.DEFAULT); + STATEMENT_CPP.add(Keywords.RETURN); + STATEMENT_CPP.add(Keywords.ELSE); + STATEMENT_CPP.add(Keywords.DO); } - private static final Map> STATEMENT_TABLE; - static - { - STATEMENT_TABLE = new HashMap>(); - STATEMENT_TABLE.put( ParserLanguage.CPP, STATEMENT_CPP); - STATEMENT_TABLE.put( ParserLanguage.C, STATEMENT_C ); + private static final Map> STATEMENT_TABLE; + static { + STATEMENT_TABLE = new HashMap>(); + STATEMENT_TABLE.put(ParserLanguage.CPP, STATEMENT_CPP); + STATEMENT_TABLE.put(ParserLanguage.C, STATEMENT_C); } private static final Set BASE_SPECIFIER_CPP; - static - { + static { BASE_SPECIFIER_CPP = new TreeSet(); BASE_SPECIFIER_CPP.add(Keywords.PUBLIC); BASE_SPECIFIER_CPP.add(Keywords.PROTECTED); @@ -278,8 +259,7 @@ public class KeywordSets { } private static final Set CLASS_MEMBER; - static - { + static { CLASS_MEMBER = new TreeSet(DECL_SPECIFIER_SEQUENCE_CPP); CLASS_MEMBER.add(Keywords.PUBLIC); CLASS_MEMBER.add(Keywords.PROTECTED); @@ -287,8 +267,7 @@ public class KeywordSets { } private static final Set POST_USING_CPP; - static - { + static { POST_USING_CPP = new TreeSet(); POST_USING_CPP.add(Keywords.NAMESPACE); POST_USING_CPP.add(Keywords.TYPENAME); @@ -297,26 +276,23 @@ public class KeywordSets { private static final Set FUNCTION_MODIFIER_C = EMPTY_TABLE; private static final Set FUNCTION_MODIFIER_CPP; - static - { - FUNCTION_MODIFIER_CPP = new TreeSet( FUNCTION_MODIFIER_C ); + static { + FUNCTION_MODIFIER_CPP = new TreeSet(FUNCTION_MODIFIER_C); - FUNCTION_MODIFIER_CPP.add( Keywords.THROW); - FUNCTION_MODIFIER_CPP.add( Keywords.TRY ); - FUNCTION_MODIFIER_CPP.add( Keywords.VOLATILE ); + FUNCTION_MODIFIER_CPP.add(Keywords.THROW); + FUNCTION_MODIFIER_CPP.add(Keywords.TRY); + FUNCTION_MODIFIER_CPP.add(Keywords.VOLATILE); } - private static final Map> FUNCTION_MODIFIER_TABLE; - static - { - FUNCTION_MODIFIER_TABLE= new HashMap>(2); - FUNCTION_MODIFIER_TABLE.put( ParserLanguage.CPP, FUNCTION_MODIFIER_CPP ); - FUNCTION_MODIFIER_TABLE.put( ParserLanguage.C, FUNCTION_MODIFIER_C ); + private static final Map> FUNCTION_MODIFIER_TABLE; + static { + FUNCTION_MODIFIER_TABLE= new HashMap>(2); + FUNCTION_MODIFIER_TABLE.put(ParserLanguage.CPP, FUNCTION_MODIFIER_CPP); + FUNCTION_MODIFIER_TABLE.put(ParserLanguage.C, FUNCTION_MODIFIER_C); } private static final Set PP_DIRECTIVES_C; - static - { + static { PP_DIRECTIVES_C = new TreeSet(); PP_DIRECTIVES_C.add(Directives.POUND_BLANK); PP_DIRECTIVES_C.add(Directives.POUND_DEFINE); @@ -334,11 +310,9 @@ public class KeywordSets { PP_DIRECTIVES_C.add(Directives._PRAGMA); PP_DIRECTIVES_C.add(Directives.DEFINED); } - private static final Set PP_DIRECTIVES_CPP; - static - { + static { PP_DIRECTIVES_CPP = new TreeSet(); PP_DIRECTIVES_CPP.add(Directives.POUND_BLANK); PP_DIRECTIVES_CPP.add(Directives.POUND_DEFINE); @@ -358,307 +332,295 @@ public class KeywordSets { } private static final Set ALL_C; - static - { + static { ALL_C = new TreeSet(PP_DIRECTIVES_CPP); - ALL_C.add( Keywords.AUTO); - ALL_C.add( Keywords.BREAK); - ALL_C.add( Keywords.CASE); - ALL_C.add( Keywords.CHAR); - ALL_C.add( Keywords.CONST); - ALL_C.add( Keywords.CONTINUE); - ALL_C.add( Keywords.DEFAULT); - ALL_C.add( Keywords.DELETE); - ALL_C.add( Keywords.DO); - ALL_C.add( Keywords.DOUBLE); - ALL_C.add( Keywords.ELSE); - ALL_C.add( Keywords.ENUM); - ALL_C.add( Keywords.EXTERN); - ALL_C.add( Keywords.FLOAT); - ALL_C.add( Keywords.FOR); - ALL_C.add( Keywords.GOTO); - ALL_C.add( Keywords.IF); - ALL_C.add( Keywords.INLINE); - ALL_C.add( Keywords.INT); - ALL_C.add( Keywords.LONG); - ALL_C.add( Keywords.REGISTER); - ALL_C.add( Keywords.RESTRICT); - ALL_C.add( Keywords.RETURN); - ALL_C.add( Keywords.SHORT); - ALL_C.add( Keywords.SIGNED); - ALL_C.add( Keywords.SIZEOF); - ALL_C.add( Keywords.STATIC); - ALL_C.add( Keywords.STRUCT); - ALL_C.add( Keywords.SWITCH); - ALL_C.add( Keywords.TYPEDEF); - ALL_C.add( Keywords.UNION); - ALL_C.add( Keywords.UNSIGNED); - ALL_C.add( Keywords.VOID); - ALL_C.add( Keywords.VOLATILE); - ALL_C.add( Keywords.WHILE); - ALL_C.add( Keywords._BOOL); - ALL_C.add( Keywords._COMPLEX); - ALL_C.add( Keywords._IMAGINARY); + ALL_C.add(Keywords.AUTO); + ALL_C.add(Keywords.BREAK); + ALL_C.add(Keywords.CASE); + ALL_C.add(Keywords.CHAR); + ALL_C.add(Keywords.CONST); + ALL_C.add(Keywords.CONTINUE); + ALL_C.add(Keywords.DEFAULT); + ALL_C.add(Keywords.DELETE); + ALL_C.add(Keywords.DO); + ALL_C.add(Keywords.DOUBLE); + ALL_C.add(Keywords.ELSE); + ALL_C.add(Keywords.ENUM); + ALL_C.add(Keywords.EXTERN); + ALL_C.add(Keywords.FLOAT); + ALL_C.add(Keywords.FOR); + ALL_C.add(Keywords.GOTO); + ALL_C.add(Keywords.IF); + ALL_C.add(Keywords.INLINE); + ALL_C.add(Keywords.INT); + ALL_C.add(Keywords.LONG); + ALL_C.add(Keywords.REGISTER); + ALL_C.add(Keywords.RESTRICT); + ALL_C.add(Keywords.RETURN); + ALL_C.add(Keywords.SHORT); + ALL_C.add(Keywords.SIGNED); + ALL_C.add(Keywords.SIZEOF); + ALL_C.add(Keywords.STATIC); + ALL_C.add(Keywords.STRUCT); + ALL_C.add(Keywords.SWITCH); + ALL_C.add(Keywords.TYPEDEF); + ALL_C.add(Keywords.UNION); + ALL_C.add(Keywords.UNSIGNED); + ALL_C.add(Keywords.VOID); + ALL_C.add(Keywords.VOLATILE); + ALL_C.add(Keywords.WHILE); + ALL_C.add(Keywords._BOOL); + ALL_C.add(Keywords._COMPLEX); + ALL_C.add(Keywords._IMAGINARY); } private static final Set ALL_CPP; - static - { + static { ALL_CPP = new TreeSet(PP_DIRECTIVES_CPP); - ALL_CPP.add( Keywords.AND ); - ALL_CPP.add( Keywords.AND_EQ); - ALL_CPP.add( Keywords.ASM); - ALL_CPP.add( Keywords.AUTO); - ALL_CPP.add( Keywords.BITAND); - ALL_CPP.add( Keywords.BITOR); - ALL_CPP.add( Keywords.BOOL); - ALL_CPP.add( Keywords.BREAK); - ALL_CPP.add( Keywords.CASE); - ALL_CPP.add( Keywords.CATCH); - ALL_CPP.add( Keywords.CHAR); - ALL_CPP.add( Keywords.CHAR16_T); - ALL_CPP.add( Keywords.CHAR32_T); - ALL_CPP.add( Keywords.CLASS); - ALL_CPP.add( Keywords.COMPL); - ALL_CPP.add( Keywords.CONST); - ALL_CPP.add( Keywords.CONST_CAST); - ALL_CPP.add( Keywords.CONTINUE); - ALL_CPP.add( Keywords.DECLTYPE); - ALL_CPP.add( Keywords.DEFAULT); - ALL_CPP.add( Keywords.DELETE); - ALL_CPP.add( Keywords.DO); - ALL_CPP.add( Keywords.DOUBLE); - ALL_CPP.add( Keywords.DYNAMIC_CAST); - ALL_CPP.add( Keywords.ELSE); - ALL_CPP.add( Keywords.ENUM); - ALL_CPP.add( Keywords.EXPLICIT); - ALL_CPP.add( Keywords.EXPORT); - ALL_CPP.add( Keywords.EXTERN); - ALL_CPP.add( Keywords.FALSE); - ALL_CPP.add( Keywords.FLOAT); - ALL_CPP.add( Keywords.FOR); - ALL_CPP.add( Keywords.FRIEND); - ALL_CPP.add( Keywords.GOTO); - ALL_CPP.add( Keywords.IF); - ALL_CPP.add( Keywords.INLINE); - ALL_CPP.add( Keywords.INT); - ALL_CPP.add( Keywords.LONG); - ALL_CPP.add( Keywords.MUTABLE); - ALL_CPP.add( Keywords.NAMESPACE); - ALL_CPP.add( Keywords.NEW); - ALL_CPP.add( Keywords.NOT); - ALL_CPP.add( Keywords.NOT_EQ); - ALL_CPP.add( Keywords.NULLPTR); - ALL_CPP.add( Keywords.OPERATOR); - ALL_CPP.add( Keywords.OR); - ALL_CPP.add( Keywords.OR_EQ); - ALL_CPP.add( Keywords.PRIVATE); - ALL_CPP.add( Keywords.PROTECTED); - ALL_CPP.add( Keywords.PUBLIC); - ALL_CPP.add( Keywords.REGISTER); - ALL_CPP.add( Keywords.REINTERPRET_CAST); - ALL_CPP.add( Keywords.RETURN); - ALL_CPP.add( Keywords.SHORT); - ALL_CPP.add( Keywords.SIGNED); - ALL_CPP.add( Keywords.SIZEOF); - ALL_CPP.add( Keywords.STATIC); - ALL_CPP.add( Keywords.STATIC_ASSERT); - ALL_CPP.add( Keywords.STATIC_CAST); - ALL_CPP.add( Keywords.STRUCT); - ALL_CPP.add( Keywords.SWITCH); - ALL_CPP.add( Keywords.TEMPLATE); - ALL_CPP.add( Keywords.THIS); - ALL_CPP.add( Keywords.THROW); - ALL_CPP.add( Keywords.TRUE); - ALL_CPP.add( Keywords.TRY); - ALL_CPP.add( Keywords.TYPEDEF); - ALL_CPP.add( Keywords.TYPEID); - ALL_CPP.add( Keywords.TYPENAME); - ALL_CPP.add( Keywords.UNION); - ALL_CPP.add( Keywords.UNSIGNED); - ALL_CPP.add( Keywords.USING); - ALL_CPP.add( Keywords.VIRTUAL); - ALL_CPP.add( Keywords.VOID); - ALL_CPP.add( Keywords.VOLATILE); - ALL_CPP.add( Keywords.WCHAR_T); - ALL_CPP.add( Keywords.WHILE); - ALL_CPP.add( Keywords.XOR); - ALL_CPP.add( Keywords.XOR_EQ); - + ALL_CPP.add(Keywords.AND); + ALL_CPP.add(Keywords.AND_EQ); + ALL_CPP.add(Keywords.ASM); + ALL_CPP.add(Keywords.AUTO); + ALL_CPP.add(Keywords.BITAND); + ALL_CPP.add(Keywords.BITOR); + ALL_CPP.add(Keywords.BOOL); + ALL_CPP.add(Keywords.BREAK); + ALL_CPP.add(Keywords.CASE); + ALL_CPP.add(Keywords.CATCH); + ALL_CPP.add(Keywords.CHAR); + ALL_CPP.add(Keywords.CHAR16_T); + ALL_CPP.add(Keywords.CHAR32_T); + ALL_CPP.add(Keywords.CLASS); + ALL_CPP.add(Keywords.COMPL); + ALL_CPP.add(Keywords.CONST); + ALL_CPP.add(Keywords.CONST_CAST); + ALL_CPP.add(Keywords.CONTINUE); + ALL_CPP.add(Keywords.DECLTYPE); + ALL_CPP.add(Keywords.DEFAULT); + ALL_CPP.add(Keywords.DELETE); + ALL_CPP.add(Keywords.DO); + ALL_CPP.add(Keywords.DOUBLE); + ALL_CPP.add(Keywords.DYNAMIC_CAST); + ALL_CPP.add(Keywords.ELSE); + ALL_CPP.add(Keywords.ENUM); + ALL_CPP.add(Keywords.EXPLICIT); + ALL_CPP.add(Keywords.EXPORT); + ALL_CPP.add(Keywords.EXTERN); + ALL_CPP.add(Keywords.FALSE); + ALL_CPP.add(Keywords.FLOAT); + ALL_CPP.add(Keywords.FOR); + ALL_CPP.add(Keywords.FRIEND); + ALL_CPP.add(Keywords.GOTO); + ALL_CPP.add(Keywords.IF); + ALL_CPP.add(Keywords.INLINE); + ALL_CPP.add(Keywords.INT); + ALL_CPP.add(Keywords.LONG); + ALL_CPP.add(Keywords.MUTABLE); + ALL_CPP.add(Keywords.NAMESPACE); + ALL_CPP.add(Keywords.NEW); + ALL_CPP.add(Keywords.NOT); + ALL_CPP.add(Keywords.NOT_EQ); + ALL_CPP.add(Keywords.NULLPTR); + ALL_CPP.add(Keywords.OPERATOR); + ALL_CPP.add(Keywords.OR); + ALL_CPP.add(Keywords.OR_EQ); + ALL_CPP.add(Keywords.PRIVATE); + ALL_CPP.add(Keywords.PROTECTED); + ALL_CPP.add(Keywords.PUBLIC); + ALL_CPP.add(Keywords.REGISTER); + ALL_CPP.add(Keywords.REINTERPRET_CAST); + ALL_CPP.add(Keywords.RETURN); + ALL_CPP.add(Keywords.SHORT); + ALL_CPP.add(Keywords.SIGNED); + ALL_CPP.add(Keywords.SIZEOF); + ALL_CPP.add(Keywords.STATIC); + ALL_CPP.add(Keywords.STATIC_ASSERT); + ALL_CPP.add(Keywords.STATIC_CAST); + ALL_CPP.add(Keywords.STRUCT); + ALL_CPP.add(Keywords.SWITCH); + ALL_CPP.add(Keywords.TEMPLATE); + ALL_CPP.add(Keywords.THIS); + ALL_CPP.add(Keywords.THROW); + ALL_CPP.add(Keywords.TRUE); + ALL_CPP.add(Keywords.TRY); + ALL_CPP.add(Keywords.TYPEDEF); + ALL_CPP.add(Keywords.TYPEID); + ALL_CPP.add(Keywords.TYPENAME); + ALL_CPP.add(Keywords.UNION); + ALL_CPP.add(Keywords.UNSIGNED); + ALL_CPP.add(Keywords.USING); + ALL_CPP.add(Keywords.VIRTUAL); + ALL_CPP.add(Keywords.VOID); + ALL_CPP.add(Keywords.VOLATILE); + ALL_CPP.add(Keywords.WCHAR_T); + ALL_CPP.add(Keywords.WHILE); + ALL_CPP.add(Keywords.XOR); + ALL_CPP.add(Keywords.XOR_EQ); } - private static final Map> ALL_TABLE; - static - { - ALL_TABLE = new HashMap>( 2 ); - ALL_TABLE.put( ParserLanguage.C, ALL_C ); - ALL_TABLE.put( ParserLanguage.CPP, ALL_CPP ); + + private static final Map> ALL_TABLE; + static { + ALL_TABLE = new HashMap>(2); + ALL_TABLE.put(ParserLanguage.C, ALL_C); + ALL_TABLE.put(ParserLanguage.CPP, ALL_CPP); } private static final Set KEYWORDS_CPP; - static - { + static { KEYWORDS_CPP = new TreeSet(); - KEYWORDS_CPP.add( Keywords.AND ); - KEYWORDS_CPP.add( Keywords.AND_EQ ); - KEYWORDS_CPP.add( Keywords.ASM ); - KEYWORDS_CPP.add( Keywords.AUTO ); - KEYWORDS_CPP.add( Keywords.BITAND ); - KEYWORDS_CPP.add( Keywords.BITOR ); - KEYWORDS_CPP.add( Keywords.BREAK ); - KEYWORDS_CPP.add( Keywords.CASE ); - KEYWORDS_CPP.add( Keywords.CATCH ); - KEYWORDS_CPP.add( Keywords.CLASS ); - KEYWORDS_CPP.add( Keywords.COMPL ); - KEYWORDS_CPP.add( Keywords.CONST ); - KEYWORDS_CPP.add( Keywords.CONST_CAST ); - KEYWORDS_CPP.add( Keywords.CONTINUE ); - KEYWORDS_CPP.add( Keywords.DECLTYPE); - KEYWORDS_CPP.add( Keywords.DEFAULT ); - KEYWORDS_CPP.add( Keywords.DELETE ); - KEYWORDS_CPP.add( Keywords.DO ); - KEYWORDS_CPP.add( Keywords.DYNAMIC_CAST ); - KEYWORDS_CPP.add( Keywords.ELSE ); - KEYWORDS_CPP.add( Keywords.ENUM ); - KEYWORDS_CPP.add( Keywords.EXPLICIT ); - KEYWORDS_CPP.add( Keywords.EXPORT ); - KEYWORDS_CPP.add( Keywords.EXTERN ); - KEYWORDS_CPP.add( Keywords.FALSE ); - KEYWORDS_CPP.add( Keywords.FOR ); - KEYWORDS_CPP.add( Keywords.FRIEND ); - KEYWORDS_CPP.add( Keywords.GOTO ); - KEYWORDS_CPP.add( Keywords.IF ); - KEYWORDS_CPP.add( Keywords.INLINE ); - KEYWORDS_CPP.add( Keywords.MUTABLE ); - KEYWORDS_CPP.add( Keywords.NAMESPACE ); - KEYWORDS_CPP.add( Keywords.NEW ); - KEYWORDS_CPP.add( Keywords.NOT ); - KEYWORDS_CPP.add( Keywords.NOT_EQ ); - KEYWORDS_CPP.add( Keywords.NULLPTR ); - KEYWORDS_CPP.add( Keywords.OPERATOR ); - KEYWORDS_CPP.add( Keywords.OR ); - KEYWORDS_CPP.add( Keywords.OR_EQ ); - KEYWORDS_CPP.add( Keywords.PRIVATE ); - KEYWORDS_CPP.add( Keywords.PROTECTED ); - KEYWORDS_CPP.add( Keywords.PUBLIC ); - KEYWORDS_CPP.add( Keywords.REGISTER ); - KEYWORDS_CPP.add( Keywords.REINTERPRET_CAST ); - KEYWORDS_CPP.add( Keywords.RESTRICT ); - KEYWORDS_CPP.add( Keywords.RETURN ); - KEYWORDS_CPP.add( Keywords.SIZEOF ); - KEYWORDS_CPP.add( Keywords.STATIC ); - KEYWORDS_CPP.add( Keywords.STATIC_ASSERT ); - KEYWORDS_CPP.add( Keywords.STATIC_CAST ); - KEYWORDS_CPP.add( Keywords.STRUCT ); - KEYWORDS_CPP.add( Keywords.SWITCH ); - KEYWORDS_CPP.add( Keywords.TEMPLATE ); - KEYWORDS_CPP.add( Keywords.THIS ); - KEYWORDS_CPP.add( Keywords.THROW ); - KEYWORDS_CPP.add( Keywords.TRUE ); - KEYWORDS_CPP.add( Keywords.TRY ); - KEYWORDS_CPP.add( Keywords.TYPEDEF ); - KEYWORDS_CPP.add( Keywords.TYPEID ); - KEYWORDS_CPP.add( Keywords.TYPENAME ); - KEYWORDS_CPP.add( Keywords.UNION ); - KEYWORDS_CPP.add( Keywords.USING ); - KEYWORDS_CPP.add( Keywords.VIRTUAL ); - KEYWORDS_CPP.add( Keywords.VOLATILE ); - KEYWORDS_CPP.add( Keywords.WHILE ); - KEYWORDS_CPP.add( Keywords.XOR ); - KEYWORDS_CPP.add( Keywords.XOR_EQ ); - + KEYWORDS_CPP.add(Keywords.AND); + KEYWORDS_CPP.add(Keywords.AND_EQ); + KEYWORDS_CPP.add(Keywords.ASM); + KEYWORDS_CPP.add(Keywords.AUTO); + KEYWORDS_CPP.add(Keywords.BITAND); + KEYWORDS_CPP.add(Keywords.BITOR); + KEYWORDS_CPP.add(Keywords.BREAK); + KEYWORDS_CPP.add(Keywords.CASE); + KEYWORDS_CPP.add(Keywords.CATCH); + KEYWORDS_CPP.add(Keywords.CLASS); + KEYWORDS_CPP.add(Keywords.COMPL); + KEYWORDS_CPP.add(Keywords.CONST); + KEYWORDS_CPP.add(Keywords.CONST_CAST); + KEYWORDS_CPP.add(Keywords.CONTINUE); + KEYWORDS_CPP.add(Keywords.DECLTYPE); + KEYWORDS_CPP.add(Keywords.DEFAULT); + KEYWORDS_CPP.add(Keywords.DELETE); + KEYWORDS_CPP.add(Keywords.DO); + KEYWORDS_CPP.add(Keywords.DYNAMIC_CAST); + KEYWORDS_CPP.add(Keywords.ELSE); + KEYWORDS_CPP.add(Keywords.ENUM); + KEYWORDS_CPP.add(Keywords.EXPLICIT); + KEYWORDS_CPP.add(Keywords.EXPORT); + KEYWORDS_CPP.add(Keywords.EXTERN); + KEYWORDS_CPP.add(Keywords.FALSE); + KEYWORDS_CPP.add(Keywords.FOR); + KEYWORDS_CPP.add(Keywords.FRIEND); + KEYWORDS_CPP.add(Keywords.GOTO); + KEYWORDS_CPP.add(Keywords.IF); + KEYWORDS_CPP.add(Keywords.INLINE); + KEYWORDS_CPP.add(Keywords.MUTABLE); + KEYWORDS_CPP.add(Keywords.NAMESPACE); + KEYWORDS_CPP.add(Keywords.NEW); + KEYWORDS_CPP.add(Keywords.NOT); + KEYWORDS_CPP.add(Keywords.NOT_EQ); + KEYWORDS_CPP.add(Keywords.NULLPTR); + KEYWORDS_CPP.add(Keywords.OPERATOR); + KEYWORDS_CPP.add(Keywords.OR); + KEYWORDS_CPP.add(Keywords.OR_EQ); + KEYWORDS_CPP.add(Keywords.PRIVATE); + KEYWORDS_CPP.add(Keywords.PROTECTED); + KEYWORDS_CPP.add(Keywords.PUBLIC); + KEYWORDS_CPP.add(Keywords.REGISTER); + KEYWORDS_CPP.add(Keywords.REINTERPRET_CAST); + KEYWORDS_CPP.add(Keywords.RESTRICT); + KEYWORDS_CPP.add(Keywords.RETURN); + KEYWORDS_CPP.add(Keywords.SIZEOF); + KEYWORDS_CPP.add(Keywords.STATIC); + KEYWORDS_CPP.add(Keywords.STATIC_ASSERT); + KEYWORDS_CPP.add(Keywords.STATIC_CAST); + KEYWORDS_CPP.add(Keywords.STRUCT); + KEYWORDS_CPP.add(Keywords.SWITCH); + KEYWORDS_CPP.add(Keywords.TEMPLATE); + KEYWORDS_CPP.add(Keywords.THIS); + KEYWORDS_CPP.add(Keywords.THROW); + KEYWORDS_CPP.add(Keywords.TRUE); + KEYWORDS_CPP.add(Keywords.TRY); + KEYWORDS_CPP.add(Keywords.TYPEDEF); + KEYWORDS_CPP.add(Keywords.TYPEID); + KEYWORDS_CPP.add(Keywords.TYPENAME); + KEYWORDS_CPP.add(Keywords.UNION); + KEYWORDS_CPP.add(Keywords.USING); + KEYWORDS_CPP.add(Keywords.VIRTUAL); + KEYWORDS_CPP.add(Keywords.VOLATILE); + KEYWORDS_CPP.add(Keywords.WHILE); + KEYWORDS_CPP.add(Keywords.XOR); + KEYWORDS_CPP.add(Keywords.XOR_EQ); } private static Set KEYWORDS_C; - static - { + static { KEYWORDS_C = new TreeSet(); - KEYWORDS_C.add( Keywords.ASM ); - KEYWORDS_C.add( Keywords.AUTO ); - KEYWORDS_C.add( Keywords.BREAK ); - KEYWORDS_C.add( Keywords.CASE ); - KEYWORDS_C.add( Keywords.CONST ); - KEYWORDS_C.add( Keywords.CONTINUE ); - KEYWORDS_C.add( Keywords.DEFAULT ); - KEYWORDS_C.add( Keywords.DO ); - KEYWORDS_C.add( Keywords.ELSE ); - KEYWORDS_C.add( Keywords.ENUM ); - KEYWORDS_C.add( Keywords.EXTERN ); - KEYWORDS_C.add( Keywords.FOR ); - KEYWORDS_C.add( Keywords.GOTO ); - KEYWORDS_C.add( Keywords.IF ); - KEYWORDS_C.add( Keywords.INLINE ); - KEYWORDS_C.add( Keywords.REGISTER ); - KEYWORDS_C.add( Keywords.RETURN ); - KEYWORDS_C.add( Keywords.RESTRICT ); - KEYWORDS_C.add( Keywords.SIZEOF ); - KEYWORDS_C.add( Keywords.STATIC ); - KEYWORDS_C.add( Keywords.STRUCT ); - KEYWORDS_C.add( Keywords.SWITCH ); - KEYWORDS_C.add( Keywords.TYPEDEF ); - KEYWORDS_C.add( Keywords.UNION ); - KEYWORDS_C.add( Keywords.VOLATILE ); - KEYWORDS_C.add( Keywords.WHILE ); + KEYWORDS_C.add(Keywords.ASM); + KEYWORDS_C.add(Keywords.AUTO); + KEYWORDS_C.add(Keywords.BREAK); + KEYWORDS_C.add(Keywords.CASE); + KEYWORDS_C.add(Keywords.CONST); + KEYWORDS_C.add(Keywords.CONTINUE); + KEYWORDS_C.add(Keywords.DEFAULT); + KEYWORDS_C.add(Keywords.DO); + KEYWORDS_C.add(Keywords.ELSE); + KEYWORDS_C.add(Keywords.ENUM); + KEYWORDS_C.add(Keywords.EXTERN); + KEYWORDS_C.add(Keywords.FOR); + KEYWORDS_C.add(Keywords.GOTO); + KEYWORDS_C.add(Keywords.IF); + KEYWORDS_C.add(Keywords.INLINE); + KEYWORDS_C.add(Keywords.REGISTER); + KEYWORDS_C.add(Keywords.RETURN); + KEYWORDS_C.add(Keywords.RESTRICT); + KEYWORDS_C.add(Keywords.SIZEOF); + KEYWORDS_C.add(Keywords.STATIC); + KEYWORDS_C.add(Keywords.STRUCT); + KEYWORDS_C.add(Keywords.SWITCH); + KEYWORDS_C.add(Keywords.TYPEDEF); + KEYWORDS_C.add(Keywords.UNION); + KEYWORDS_C.add(Keywords.VOLATILE); + KEYWORDS_C.add(Keywords.WHILE); } - - - private static final Map> KEYWORDS_TABLE; - static - { - KEYWORDS_TABLE = new HashMap>(2); - KEYWORDS_TABLE.put( ParserLanguage.C, KEYWORDS_C ); - KEYWORDS_TABLE.put( ParserLanguage.CPP, KEYWORDS_CPP ); + private static final Map> KEYWORDS_TABLE; + static { + KEYWORDS_TABLE = new HashMap>(2); + KEYWORDS_TABLE.put(ParserLanguage.C, KEYWORDS_C); + KEYWORDS_TABLE.put(ParserLanguage.CPP, KEYWORDS_CPP); } private static final Set TYPES_C; - static - { + static { TYPES_C = new TreeSet(); - TYPES_C.add( Keywords.CHAR ); - TYPES_C.add( Keywords.DOUBLE ); - TYPES_C.add( Keywords.FLOAT ); - TYPES_C.add( Keywords.INT ); - TYPES_C.add( Keywords.LONG ); - TYPES_C.add( Keywords.SHORT ); - TYPES_C.add( Keywords.SIGNED ); - TYPES_C.add( Keywords.UNSIGNED ); - TYPES_C.add( Keywords.VOID ); - TYPES_C.add( Keywords._BOOL ); - TYPES_C.add( Keywords._COMPLEX ); - TYPES_C.add( Keywords._IMAGINARY ); + TYPES_C.add(Keywords.CHAR); + TYPES_C.add(Keywords.DOUBLE); + TYPES_C.add(Keywords.FLOAT); + TYPES_C.add(Keywords.INT); + TYPES_C.add(Keywords.LONG); + TYPES_C.add(Keywords.SHORT); + TYPES_C.add(Keywords.SIGNED); + TYPES_C.add(Keywords.UNSIGNED); + TYPES_C.add(Keywords.VOID); + TYPES_C.add(Keywords._BOOL); + TYPES_C.add(Keywords._COMPLEX); + TYPES_C.add(Keywords._IMAGINARY); } + private static final Set TYPES_CPP; - static - { + static { TYPES_CPP = new TreeSet(); - TYPES_CPP.add( Keywords.BOOL ); - TYPES_CPP.add( Keywords.CHAR ); - TYPES_CPP.add( Keywords.CHAR16_T ); - TYPES_CPP.add( Keywords.CHAR32_T ); - TYPES_CPP.add( Keywords.DOUBLE ); - TYPES_CPP.add( Keywords.FLOAT ); - TYPES_CPP.add( Keywords.INT ); - TYPES_CPP.add( Keywords.LONG ); - TYPES_CPP.add( Keywords.SHORT ); - TYPES_CPP.add( Keywords.SIGNED ); - TYPES_CPP.add( Keywords.UNSIGNED ); - TYPES_CPP.add( Keywords.VOID ); - TYPES_CPP.add( Keywords.WCHAR_T ); + TYPES_CPP.add(Keywords.BOOL); + TYPES_CPP.add(Keywords.CHAR); + TYPES_CPP.add(Keywords.CHAR16_T); + TYPES_CPP.add(Keywords.CHAR32_T); + TYPES_CPP.add(Keywords.DOUBLE); + TYPES_CPP.add(Keywords.FLOAT); + TYPES_CPP.add(Keywords.INT); + TYPES_CPP.add(Keywords.LONG); + TYPES_CPP.add(Keywords.SHORT); + TYPES_CPP.add(Keywords.SIGNED); + TYPES_CPP.add(Keywords.UNSIGNED); + TYPES_CPP.add(Keywords.VOID); + TYPES_CPP.add(Keywords.WCHAR_T); } - private static Map> TYPES_TABLE; - static - { - TYPES_TABLE = new HashMap>( 2 ); - TYPES_TABLE.put( ParserLanguage.C, TYPES_C ); - TYPES_TABLE.put( ParserLanguage.CPP, TYPES_CPP ); + private static Map> TYPES_TABLE; + static { + TYPES_TABLE = new HashMap>(2); + TYPES_TABLE.put(ParserLanguage.C, TYPES_C); + TYPES_TABLE.put(ParserLanguage.CPP, TYPES_CPP); } - private static Map> PP_DIRECTIVES_TABLE; - static - { - PP_DIRECTIVES_TABLE = new HashMap>( 2 ); - PP_DIRECTIVES_TABLE.put( ParserLanguage.C, PP_DIRECTIVES_C ); - PP_DIRECTIVES_TABLE.put( ParserLanguage.CPP, PP_DIRECTIVES_CPP ); + private static Map> PP_DIRECTIVES_TABLE; + static { + PP_DIRECTIVES_TABLE = new HashMap>(2); + PP_DIRECTIVES_TABLE.put(ParserLanguage.C, PP_DIRECTIVES_C); + PP_DIRECTIVES_TABLE.put(ParserLanguage.CPP, PP_DIRECTIVES_CPP); } } From e55325538485fe691418c4b50c7a4d947239d95c Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Wed, 16 May 2012 13:27:59 -0700 Subject: [PATCH 18/38] Bug 332829. Parsing support for constexpr keyword. Also added few new C++11 keywords. --- .../parser/tests/ast2/AST2CPPSpecTest.java | 18 +++++++++ .../cdt/core/dom/ast/ASTSignatureUtil.java | 15 ++++++-- .../dom/ast/cpp/ICPPASTDeclSpecifier.java | 16 ++++++++ .../org/eclipse/cdt/core/parser/IToken.java | 7 +++- .../org/eclipse/cdt/core/parser/Keywords.java | 33 +++++++++++++---- .../parser/cpp/CPPASTBaseDeclSpecifier.java | 37 +++++++++++++------ .../cpp/CPPASTCompositeTypeSpecifier.java | 7 +--- .../cpp/CPPASTElaboratedTypeSpecifier.java | 10 ++--- .../cpp/CPPASTEnumerationSpecifier.java | 7 +--- .../parser/cpp/CPPASTNamedTypeSpecifier.java | 6 +-- .../parser/cpp/CPPASTSimpleDeclSpecifier.java | 29 ++++++--------- .../dom/parser/cpp/GNUCPPSourceParser.java | 21 +++++++---- .../parser/cpp/GPPASTSimpleDeclSpecifier.java | 15 +++----- .../dom/rewrite/astwriter/DeclSpecWriter.java | 10 +++-- .../core/parser/token/KeywordSets.java | 6 +++ .../TrailNodeEqualityChecker.java | 27 +++++++------- .../xlc/ast/XlcCPPASTVectorTypeSpecifier.java | 6 +-- 17 files changed, 166 insertions(+), 104 deletions(-) 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 156d1e97c51..c9e3cbc9c99 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 @@ -1184,6 +1184,24 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { assertInstance(d, IASTProblemDeclaration.class); } + // constexpr int square(int x); + // constexpr int bufsz = 1024; + // struct pixel { + // int x; + // int y; + // constexpr pixel(int); + // }; + // constexpr pixel::pixel(int a) + // : x(square(a)), y(square(a)) + // { } + // constexpr int square(int x) { + // return x * x; + // } + // constexpr pixel large(4); + public void test7_1_5s1() throws Exception { + parse(getAboveComment(), ParserLanguage.CPP, true, 0); + } + // int foo() { // const int ci = 3; // cvqualified (initialized as required) // ci = 4; // illformed: attempt to modify const diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTSignatureUtil.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTSignatureUtil.java index 8456fe8b57b..33edb3e4f21 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTSignatureUtil.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTSignatureUtil.java @@ -510,7 +510,16 @@ public class ASTSignatureUtil { } if (declSpec instanceof ICPPASTDeclSpecifier) { - if (((ICPPASTDeclSpecifier) declSpec).isExplicit()) { + ICPPASTDeclSpecifier cppDeclSpec = (ICPPASTDeclSpecifier) declSpec; + if (cppDeclSpec.isConstexpr()) { + if (needSpace) { + result.append(SPACE); + needSpace = false; + } + result.append(Keywords.CONSTEXPR); + needSpace = true; + } + if (cppDeclSpec.isExplicit()) { if (needSpace) { result.append(SPACE); needSpace = false; @@ -518,7 +527,7 @@ public class ASTSignatureUtil { result.append(Keywords.EXPLICIT); needSpace = true; } - if (((ICPPASTDeclSpecifier) declSpec).isFriend()) { + if (cppDeclSpec.isFriend()) { if (needSpace) { result.append(SPACE); needSpace = false; @@ -526,7 +535,7 @@ public class ASTSignatureUtil { result.append(Keywords.FRIEND); needSpace = true; } - if (((ICPPASTDeclSpecifier) declSpec).isVirtual()) { + if (cppDeclSpec.isVirtual()) { if (needSpace) { result.append(SPACE); needSpace = false; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTDeclSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTDeclSpecifier.java index 0374605f39b..761bf1c7fe0 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTDeclSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTDeclSpecifier.java @@ -63,6 +63,22 @@ public interface ICPPASTDeclSpecifier extends IASTDeclSpecifier { */ public void setExplicit(boolean value); + /** + * Is this a constexpr + * + * @return boolean + * @since 5.4 + */ + public boolean isConstexpr(); + + /** + * Sets this to be constexpr. + * + * @param value the new value + * @since 5.4 + */ + public void setConstexpr(boolean value); + /** * @since 5.1 */ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IToken.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IToken.java index e11ac4ca605..887aba558e7 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IToken.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IToken.java @@ -114,7 +114,8 @@ public interface IToken { /** @deprecated use {@link #tBITCOMPLEMENT} */ @Deprecated int tCOMPL= tBITCOMPLEMENT; /** @deprecated use {@link #tBITCOMPLEMENT} */ @Deprecated int t_compl = 66; int t_const = 67; - + + /** @since 5.4 */ int t_constexpr = 5400; int t_const_cast = 69; int t_continue = 70; /** @since 5.2 */ @@ -141,7 +142,8 @@ public interface IToken { int t_mutable = 90; int t_namespace = 91; int t_new = 92; - /** @since 5.4 */ int t_nullptr = 5400; + /** @since 5.4 */ int t_noexcept = 5401; + /** @since 5.4 */ int t_nullptr = 5402; /** @deprecated use {@link #tNOT} */ @Deprecated int t_not = 93; /** @deprecated use {@link #tNOTEQUAL} */ @Deprecated int t_not_eq = 94; int t_operator = 95; @@ -164,6 +166,7 @@ public interface IToken { int t_switch = 110; int t_template = 111; int t_this = 112; + /** @since 5.4 */ int t_thread_local = 5403; int t_throw = 113; int t_true = 114; int t_try = 115; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/Keywords.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/Keywords.java index 2a3c2f16ee1..511699575d9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/Keywords.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/Keywords.java @@ -6,9 +6,9 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * John Camelon (IBM Rational Software) - Initial API and implementation - * Anton Leherbauer (Wind River Systems) - * Markus Schorn (Wind River Systems) + * John Camelon (IBM Rational Software) - Initial API and implementation + * Anton Leherbauer (Wind River Systems) + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.core.parser; @@ -20,9 +20,10 @@ import org.eclipse.cdt.core.parser.util.CharArrayIntMap; */ @SuppressWarnings("nls") public class Keywords { - - public static final String CAST = "cast"; - public static final String ALIGNOF = "alignof"; + public static final String CAST = "cast"; + /** @since 5.4 */ + public static final String ALIGNAS = "alignas"; + public static final String ALIGNOF = "alignof"; public static final String TYPEOF = "typeof"; public static final String _BOOL = "_Bool"; @@ -46,6 +47,8 @@ public class Keywords { public static final String CLASS = "class"; public static final String COMPL = "compl"; public static final String CONST = "const"; + /** @since 5.4 */ + public static final String CONSTEXPR = "constexpr"; public static final String CONST_CAST = "const_cast"; public static final String CONTINUE = "continue"; /** @since 5.2 */ @@ -75,7 +78,9 @@ public class Keywords { /** @since 5.4 */ public static final String NULLPTR = "nullptr"; public static final String NEW = "new"; - public static final String NOT = "not"; + /** @since 5.4 */ + public static final String NOEXCEPT = "noexcept"; + public static final String NOT = "not"; public static final String NOT_EQ = "not_eq"; public static final String OPERATOR = "operator"; public static final String OR = "or"; @@ -98,6 +103,8 @@ public class Keywords { public static final String SWITCH = "switch"; public static final String TEMPLATE = "template"; public static final String THIS = "this"; + /** @since 5.4 */ + public static final String THREAD_LOCAL = "thread_local"; public static final String THROW = "throw"; public static final String TRUE = "true"; public static final String TRY = "try"; @@ -119,6 +126,8 @@ public class Keywords { public static final char[] c_BOOL = "_Bool".toCharArray(); public static final char[] c_COMPLEX = "_Complex".toCharArray(); public static final char[] c_IMAGINARY = "_Imaginary".toCharArray(); + /** @since 5.4 */ + public static final char[] cALIGNAS = "alignas".toCharArray(); /** @since 5.3 */ public static final char[] cALIGNOF = "alignof".toCharArray(); public static final char[] cAND = "and".toCharArray(); @@ -139,6 +148,8 @@ public class Keywords { public static final char[] cCLASS = "class".toCharArray(); public static final char[] cCOMPL = "compl".toCharArray(); public static final char[] cCONST = "const".toCharArray(); + /** @since 5.4 */ + public static final char[] cCONSTEXPR = "constexpr".toCharArray(); public static final char[] cCONST_CAST = "const_cast".toCharArray(); public static final char[] cCONTINUE = "continue".toCharArray(); public static final char[] cDEFAULT = "default".toCharArray(); @@ -167,6 +178,8 @@ public class Keywords { public static final char[] cNEW = "new".toCharArray(); /** @since 5.4 */ public static final char[] cNULLPTR = NULLPTR.toCharArray(); + /** @since 5.4 */ + public static final char[] cNOEXCEPT = "noexcept".toCharArray(); public static final char[] cNOT = "not".toCharArray(); public static final char[] cNOT_EQ = "not_eq".toCharArray(); public static final char[] cOPERATOR = "operator".toCharArray(); @@ -192,6 +205,8 @@ public class Keywords { public static final char[] cSWITCH = "switch".toCharArray(); public static final char[] cTEMPLATE = "template".toCharArray(); public static final char[] cTHIS = "this".toCharArray(); + /** @since 5.4 */ + public static final char[] cTHREAD_LOCAL = "thread_local".toCharArray(); public static final char[] cTHROW = "throw".toCharArray(); public static final char[] cTRUE = "true".toCharArray(); public static final char[] cTRY = "try".toCharArray(); @@ -301,7 +316,6 @@ public class Keywords { addCpp(kw); } - private static void addCommon(CharArrayIntMap words) { words.put(Keywords._Pragma, IToken.t_PRAGMA); words.put(Keywords.cAUTO, IToken.t_auto); @@ -354,6 +368,7 @@ public class Keywords { cppkeywords.put(Keywords.cCHAR16_T, IToken.t_char16_t); cppkeywords.put(Keywords.cCHAR32_T, IToken.t_char32_t); cppkeywords.put(Keywords.cCLASS, IToken.t_class); + cppkeywords.put(Keywords.cCONSTEXPR, IToken.t_constexpr); cppkeywords.put(Keywords.cCONST_CAST, IToken.t_const_cast); cppkeywords.put(Keywords.cDECLTYPE, IToken.t_decltype); cppkeywords.put(Keywords.cDELETE, IToken.t_delete); @@ -365,6 +380,7 @@ public class Keywords { cppkeywords.put(Keywords.cMUTABLE, IToken.t_mutable); cppkeywords.put(Keywords.cNAMESPACE, IToken.t_namespace); cppkeywords.put(Keywords.cNEW, IToken.t_new); + cppkeywords.put(Keywords.cNOEXCEPT, IToken.t_noexcept); cppkeywords.put(Keywords.cNULLPTR, IToken.t_nullptr); cppkeywords.put(Keywords.cOPERATOR, IToken.t_operator); cppkeywords.put(Keywords.cPRIVATE, IToken.t_private); @@ -375,6 +391,7 @@ public class Keywords { cppkeywords.put(Keywords.cSTATIC_CAST, IToken.t_static_cast); cppkeywords.put(Keywords.cTEMPLATE, IToken.t_template); cppkeywords.put(Keywords.cTHIS, IToken.t_this); + cppkeywords.put(Keywords.cTHREAD_LOCAL, IToken.t_thread_local); cppkeywords.put(Keywords.cTHROW, IToken.t_throw); cppkeywords.put(Keywords.cTRUE, IToken.t_true); cppkeywords.put(Keywords.cTRY, IToken.t_try); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBaseDeclSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBaseDeclSpecifier.java index a987b133687..aad5598a91d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBaseDeclSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBaseDeclSpecifier.java @@ -22,6 +22,7 @@ public abstract class CPPASTBaseDeclSpecifier extends ASTNode implements ICPPAST private boolean friend; private boolean inline; private boolean isConst; + private boolean isConstexpr; private boolean isVolatile; private boolean isRestrict; private int sc; @@ -55,6 +56,17 @@ public abstract class CPPASTBaseDeclSpecifier extends ASTNode implements ICPPAST isConst = value; } + @Override + public boolean isConstexpr() { + return isConstexpr; + } + + @Override + public void setConstexpr(boolean value) { + assertNotFrozen(); + isConstexpr = value; + } + @Override public boolean isVolatile() { return isVolatile; @@ -116,18 +128,19 @@ public abstract class CPPASTBaseDeclSpecifier extends ASTNode implements ICPPAST this.explicit = value; } - protected void copyBaseDeclSpec(CPPASTBaseDeclSpecifier other) { - other.friend = friend; - other.inline = inline; - other.isConst = isConst; - other.isVolatile = isVolatile; - other.isRestrict= isRestrict; - other.virtual = virtual; - other.explicit = explicit; - other.sc = sc; - other.setOffsetAndLength(this); - } - + protected T copy(T copy, CopyStyle style) { + copy.friend = friend; + copy.inline = inline; + copy.isConst = isConst; + copy.isConstexpr = isConstexpr; + copy.isVolatile = isVolatile; + copy.isRestrict= isRestrict; + copy.virtual = virtual; + copy.explicit = explicit; + copy.sc = sc; + return super.copy(copy, style); + } + /** * Provided for debugging purposes, only. */ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCompositeTypeSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCompositeTypeSpecifier.java index 20ef93b2382..964f20290da 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCompositeTypeSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCompositeTypeSpecifier.java @@ -61,16 +61,11 @@ public class CPPASTCompositeTypeSpecifier extends CPPASTBaseDeclSpecifier public CPPASTCompositeTypeSpecifier copy(CopyStyle style) { CPPASTCompositeTypeSpecifier copy = new CPPASTCompositeTypeSpecifier(fKey, fName == null ? null : fName.copy(style)); - copyBaseDeclSpec(copy); for (IASTDeclaration member : getMembers()) copy.addMemberDeclaration(member == null ? null : member.copy(style)); for (ICPPASTBaseSpecifier baseSpecifier : getBaseSpecifiers()) copy.addBaseSpecifier(baseSpecifier == null ? null : baseSpecifier.copy(style)); - - if (style == CopyStyle.withLocations) { - copy.setCopyLocation(this); - } - return copy; + return super.copy(copy, style); } @Override diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTElaboratedTypeSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTElaboratedTypeSpecifier.java index a730058492d..acd89eed3e6 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTElaboratedTypeSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTElaboratedTypeSpecifier.java @@ -45,13 +45,9 @@ public class CPPASTElaboratedTypeSpecifier extends CPPASTBaseDeclSpecifier @Override public CPPASTElaboratedTypeSpecifier copy(CopyStyle style) { - CPPASTElaboratedTypeSpecifier copy = new CPPASTElaboratedTypeSpecifier(kind, name == null - ? null : name.copy(style)); - copyBaseDeclSpec(copy); - if (style == CopyStyle.withLocations) { - copy.setCopyLocation(this); - } - return copy; + CPPASTElaboratedTypeSpecifier copy = + new CPPASTElaboratedTypeSpecifier(kind, name == null ? null : name.copy(style)); + return super.copy(copy, style); } @Override diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTEnumerationSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTEnumerationSpecifier.java index f91b784b2f8..b5d58ffd789 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTEnumerationSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTEnumerationSpecifier.java @@ -55,13 +55,10 @@ public class CPPASTEnumerationSpecifier extends CPPASTBaseDeclSpecifier new CPPASTEnumerationSpecifier(fIsScoped, fName == null ? null : fName.copy(style), fBaseType == null ? null : fBaseType.copy(style)); copy.fIsOpaque = fIsOpaque; - for (IASTEnumerator enumerator : getEnumerators()) + for (IASTEnumerator enumerator : getEnumerators()) { copy.addEnumerator(enumerator == null ? null : enumerator.copy(style)); - copyBaseDeclSpec(copy); - if (style == CopyStyle.withLocations) { - copy.setCopyLocation(this); } - return copy; + return super.copy(copy, style); } @Override diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNamedTypeSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNamedTypeSpecifier.java index 4f9fe0081af..bbfc9cd0b12 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNamedTypeSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNamedTypeSpecifier.java @@ -47,12 +47,8 @@ public class CPPASTNamedTypeSpecifier extends CPPASTBaseDeclSpecifier public CPPASTNamedTypeSpecifier copy(CopyStyle style) { CPPASTNamedTypeSpecifier copy = new CPPASTNamedTypeSpecifier(name == null ? null : name.copy(style)); - copyBaseDeclSpec(copy); copy.typename = typename; - if (style == CopyStyle.withLocations) { - copy.setCopyLocation(this); - } - return copy; + return super.copy(copy, style); } @Override diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleDeclSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleDeclSpecifier.java index bf020df8804..45804b803d4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleDeclSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleDeclSpecifier.java @@ -37,27 +37,22 @@ public class CPPASTSimpleDeclSpecifier extends CPPASTBaseDeclSpecifier @Override public CPPASTSimpleDeclSpecifier copy(CopyStyle style) { - CPPASTSimpleDeclSpecifier copy = new CPPASTSimpleDeclSpecifier(); - copySimpleDeclSpec(copy, style); - if (style == CopyStyle.withLocations) { - copy.setCopyLocation(this); - } - return copy; + return copy(new CPPASTSimpleDeclSpecifier(), style); } - protected void copySimpleDeclSpec(CPPASTSimpleDeclSpecifier other, CopyStyle style) { - copyBaseDeclSpec(other); - other.type = type; - other.isSigned = isSigned; - other.isUnsigned = isUnsigned; - other.isShort = isShort; - other.isLong = isLong; - other.isLonglong= isLonglong; - other.isComplex= isComplex; - other.isImaginary= isImaginary; + protected T copy(T copy, CopyStyle style) { + copy.type = type; + copy.isSigned = isSigned; + copy.isUnsigned = isUnsigned; + copy.isShort = isShort; + copy.isLong = isLong; + copy.isLonglong= isLonglong; + copy.isComplex= isComplex; + copy.isImaginary= isImaginary; if (fDeclTypeExpression != null) { - other.setDeclTypeExpression(fDeclTypeExpression.copy(style)); + copy.setDeclTypeExpression(fDeclTypeExpression.copy(style)); } + return super.copy(copy, style); } /** diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java index 7ee540631fb..ff1e01f9025 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java @@ -2593,9 +2593,9 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { } - private final static int INLINE=0x1, CONST=0x2, RESTRICT=0x4, VOLATILE=0x8, - SHORT=0x10, UNSIGNED= 0x20, SIGNED=0x40, COMPLEX=0x80, IMAGINARY=0x100, - VIRTUAL=0x200, EXPLICIT=0x400, FRIEND=0x800; + private final static int INLINE= 0x1, CONST= 0x2, CONSTEXPR= 0x4, RESTRICT= 0x8, VOLATILE= 0x10, + SHORT= 0x20, UNSIGNED= 0x40, SIGNED= 0x80, COMPLEX= 0x100, IMAGINARY= 0x200, + VIRTUAL= 0x400, EXPLICIT= 0x800, FRIEND= 0x1000; private static final int FORBID_IN_EMPTY_DECLSPEC = CONST | RESTRICT | VOLATILE | SHORT | UNSIGNED | SIGNED | COMPLEX | IMAGINARY | FRIEND; @@ -2605,14 +2605,14 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { * the ANSI C++ specification. * declSpecifier : * "register" | "static" | "extern" | "mutable" | - * "inline" | "virtual" | "explicit" | - * "typedef" | "friend" | - * "const" | "volatile" | + * "inline" | "virtual" | "explicit" | + * "typedef" | "friend" | "constexpr" | + * "const" | "volatile" | * "short" | "long" | "signed" | "unsigned" | "int" | * "char" | "wchar_t" | "bool" | "float" | "double" | "void" | * "auto" | - * ("typename")? name | - * { "class" | "struct" | "union" } classSpecifier | + * ("typename")? name | + * { "class" | "struct" | "union" } classSpecifier | * {"enum"} enumSpecifier */ @Override @@ -2707,6 +2707,10 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { options |= FRIEND; endOffset= consume().getEndOffset(); break; + case IToken.t_constexpr: + options |= CONSTEXPR; + endOffset= consume().getEndOffset(); + break; // type specifier case IToken.t_const: options |= CONST; @@ -3007,6 +3011,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { private void configureDeclSpec(ICPPASTDeclSpecifier declSpec, int storageClass, int options) { declSpec.setStorageClass(storageClass); declSpec.setConst((options & CONST) != 0); + declSpec.setConstexpr((options & CONSTEXPR) != 0); declSpec.setVolatile((options & VOLATILE) != 0); declSpec.setInline((options & INLINE) != 0); declSpec.setFriend((options & FRIEND) != 0); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPASTSimpleDeclSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPASTSimpleDeclSpecifier.java index 4d3b7d3344e..5a113ed7b4f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPASTSimpleDeclSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPASTSimpleDeclSpecifier.java @@ -6,8 +6,8 @@ * 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; @@ -18,8 +18,8 @@ import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier; * @deprecated Replaced by {@link CPPASTSimpleDeclSpecifier} */ @Deprecated -public class GPPASTSimpleDeclSpecifier extends CPPASTSimpleDeclSpecifier implements - IGPPASTSimpleDeclSpecifier { +public class GPPASTSimpleDeclSpecifier extends CPPASTSimpleDeclSpecifier + implements IGPPASTSimpleDeclSpecifier { public GPPASTSimpleDeclSpecifier() { } @@ -36,12 +36,7 @@ public class GPPASTSimpleDeclSpecifier extends CPPASTSimpleDeclSpecifier impleme @Override public GPPASTSimpleDeclSpecifier copy(CopyStyle style) { - GPPASTSimpleDeclSpecifier copy = new GPPASTSimpleDeclSpecifier(); - copySimpleDeclSpec(copy, style); - if (style == CopyStyle.withLocations) { - copy.setCopyLocation(this); - } - return copy; + return copy(new GPPASTSimpleDeclSpecifier(), style); } @Override diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclSpecWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclSpecWriter.java index 66d25dd9378..ac0d579a0d0 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclSpecWriter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclSpecWriter.java @@ -54,11 +54,12 @@ public class DeclSpecWriter extends NodeWriter { private static final String STRUCT = "struct"; //$NON-NLS-1$ private static final String CLASS = "class"; //$NON-NLS-1$ private static final String FRIEND = "friend "; //$NON-NLS-1$ + private static final String CONSTEXPR = "constexpr "; //$NON-NLS-1$ private static final String EXPLICIT = "explicit "; //$NON-NLS-1$ private static final String VIRTUAL = "virtual "; //$NON-NLS-1$ private static final String UNION_SPACE = "union "; //$NON-NLS-1$ private static final String STRUCT_SPACE = "struct "; //$NON-NLS-1$ - private static final String ENUM = "enum "; //$NON-NLS-1$ + private static final String ENUM_SPACE = "enum "; //$NON-NLS-1$ private static final String _BOOL = "_Bool"; //$NON-NLS-1$ public DeclSpecWriter(Scribe scribe, ASTWriterVisitor visitor, NodeCommentMap commentMap) { @@ -168,7 +169,7 @@ public class DeclSpecWriter extends NodeWriter { private String getElabTypeString(int kind) { switch (kind) { case IASTElaboratedTypeSpecifier.k_enum: - return ENUM; + return ENUM_SPACE; case IASTElaboratedTypeSpecifier.k_struct: return STRUCT_SPACE; case IASTElaboratedTypeSpecifier.k_union: @@ -185,6 +186,9 @@ public class DeclSpecWriter extends NodeWriter { if (cppDelcSpec.isVirtual()) { scribe.print(VIRTUAL); } + if (cppDelcSpec.isConstexpr()) { + scribe.print(CONSTEXPR); + } if (cppDelcSpec.isExplicit()) { scribe.print(EXPLICIT); } @@ -209,7 +213,7 @@ public class DeclSpecWriter extends NodeWriter { } private void writeEnumSpec(IASTEnumerationSpecifier enumSpec) { - scribe.print(ENUM); + scribe.print(ENUM_SPACE); enumSpec.getName().accept(visitor); scribe.print('{'); scribe.printSpace(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/token/KeywordSets.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/token/KeywordSets.java index 20553a044b5..2328b67a60d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/token/KeywordSets.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/token/KeywordSets.java @@ -393,6 +393,7 @@ public class KeywordSets { ALL_CPP.add(Keywords.CLASS); ALL_CPP.add(Keywords.COMPL); ALL_CPP.add(Keywords.CONST); + ALL_CPP.add(Keywords.CONSTEXPR); ALL_CPP.add(Keywords.CONST_CAST); ALL_CPP.add(Keywords.CONTINUE); ALL_CPP.add(Keywords.DECLTYPE); @@ -418,6 +419,7 @@ public class KeywordSets { ALL_CPP.add(Keywords.MUTABLE); ALL_CPP.add(Keywords.NAMESPACE); ALL_CPP.add(Keywords.NEW); + ALL_CPP.add(Keywords.NOEXCEPT); ALL_CPP.add(Keywords.NOT); ALL_CPP.add(Keywords.NOT_EQ); ALL_CPP.add(Keywords.NULLPTR); @@ -440,6 +442,7 @@ public class KeywordSets { ALL_CPP.add(Keywords.SWITCH); ALL_CPP.add(Keywords.TEMPLATE); ALL_CPP.add(Keywords.THIS); + ALL_CPP.add(Keywords.THREAD_LOCAL); ALL_CPP.add(Keywords.THROW); ALL_CPP.add(Keywords.TRUE); ALL_CPP.add(Keywords.TRY); @@ -480,6 +483,7 @@ public class KeywordSets { KEYWORDS_CPP.add(Keywords.CLASS); KEYWORDS_CPP.add(Keywords.COMPL); KEYWORDS_CPP.add(Keywords.CONST); + KEYWORDS_CPP.add(Keywords.CONSTEXPR); KEYWORDS_CPP.add(Keywords.CONST_CAST); KEYWORDS_CPP.add(Keywords.CONTINUE); KEYWORDS_CPP.add(Keywords.DECLTYPE); @@ -501,6 +505,7 @@ public class KeywordSets { KEYWORDS_CPP.add(Keywords.MUTABLE); KEYWORDS_CPP.add(Keywords.NAMESPACE); KEYWORDS_CPP.add(Keywords.NEW); + KEYWORDS_CPP.add(Keywords.NOEXCEPT); KEYWORDS_CPP.add(Keywords.NOT); KEYWORDS_CPP.add(Keywords.NOT_EQ); KEYWORDS_CPP.add(Keywords.NULLPTR); @@ -522,6 +527,7 @@ public class KeywordSets { KEYWORDS_CPP.add(Keywords.SWITCH); KEYWORDS_CPP.add(Keywords.TEMPLATE); KEYWORDS_CPP.add(Keywords.THIS); + KEYWORDS_CPP.add(Keywords.THREAD_LOCAL); KEYWORDS_CPP.add(Keywords.THROW); KEYWORDS_CPP.add(Keywords.TRUE); KEYWORDS_CPP.add(Keywords.TRY); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/TrailNodeEqualityChecker.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/TrailNodeEqualityChecker.java index d2e70c22c7c..4e5e29f942f 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/TrailNodeEqualityChecker.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/TrailNodeEqualityChecker.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 Institute for Software, HSR Hochschule fuer Technik + * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik * Rapperswil, University of applied sciences and others * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -16,7 +16,6 @@ import java.util.Arrays; import java.util.List; import java.util.Map; -import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.CoreException; import org.eclipse.cdt.core.dom.ast.IASTASMDeclaration; @@ -106,8 +105,7 @@ public class TrailNodeEqualityChecker implements EqualityChecker { } else if (node instanceof IASTName) { return isNameEqual(trailNode, node); } else { - Assert.isLegal(false, "Unexpected node type " + node.getClass().getSimpleName() + //$NON-NLS-1$ - ", this code shoud not be reached"); //$NON-NLS-1$ + CUIPlugin.logError("Unexpected node type " + node.getClass().getSimpleName()); //$NON-NLS-1$ return true; } } @@ -140,10 +138,11 @@ public class TrailNodeEqualityChecker implements EqualityChecker { ICPPASTNamedTypeSpecifier decl = (ICPPASTNamedTypeSpecifier) node; return isDeclSpecifierEqual(trailDecl, decl) && isSameNamedTypeSpecifierName(trailDecl, decl) - && trailDecl.isTypename() == decl.isTypename() - && trailDecl.isExplicit() == decl.isExplicit() - && trailDecl.isFriend() == decl.isFriend() - && trailDecl.isVirtual() == decl.isVirtual(); + && trailDecl.isTypename() == decl.isTypename() + && trailDecl.isConstexpr() == decl.isConstexpr() + && trailDecl.isExplicit() == decl.isExplicit() + && trailDecl.isFriend() == decl.isFriend() + && trailDecl.isVirtual() == decl.isVirtual(); } else if (trailNode instanceof IASTNamedTypeSpecifier) { IASTNamedTypeSpecifier trailDecl = (IASTNamedTypeSpecifier) trailNode; IASTNamedTypeSpecifier decl = (IASTNamedTypeSpecifier) node; @@ -163,9 +162,10 @@ public class TrailNodeEqualityChecker implements EqualityChecker { ICPPASTDeclSpecifier trailDecl = (ICPPASTDeclSpecifier) trailNode; ICPPASTDeclSpecifier decl = (ICPPASTDeclSpecifier) node; return isDeclSpecifierEqual(trailDecl, decl) - && trailDecl.isExplicit() == decl.isExplicit() - && trailDecl.isFriend() == decl.isFriend() - && trailDecl.isVirtual() == decl.isVirtual(); + && trailDecl.isConstexpr() == decl.isConstexpr() + && trailDecl.isExplicit() == decl.isExplicit() + && trailDecl.isFriend() == decl.isFriend() + && trailDecl.isVirtual() == decl.isVirtual(); } else if (trailNode instanceof ICASTDeclSpecifier) { ICASTDeclSpecifier trailDecl = (ICASTDeclSpecifier) trailNode; ICASTDeclSpecifier decl = (ICASTDeclSpecifier) node; @@ -176,7 +176,7 @@ public class TrailNodeEqualityChecker implements EqualityChecker { IASTDeclSpecifier decl = (IASTDeclSpecifier) node; return isDeclSpecifierEqual(trailDecl, decl); } else { - //is same + // The same. return true; } } @@ -315,7 +315,8 @@ public class TrailNodeEqualityChecker implements EqualityChecker { if (trailDeclSpeci instanceof ICPPASTDeclSpecifier) { ICPPASTDeclSpecifier trailCppDecl= (ICPPASTDeclSpecifier) trailDeclSpeci; ICPPASTDeclSpecifier cppDecl= (ICPPASTDeclSpecifier) declSpeci; - if (trailCppDecl.isExplicit() != cppDecl.isExplicit() + if (trailCppDecl.isConstexpr() != cppDecl.isConstexpr() + || trailCppDecl.isExplicit() != cppDecl.isExplicit() || trailCppDecl.isFriend() != cppDecl.isFriend() || trailCppDecl.isVirtual() != cppDecl.isVirtual()) { return false; diff --git a/xlc/org.eclipse.cdt.core.lrparser.xlc/parser/org/eclipse/cdt/internal/core/lrparser/xlc/ast/XlcCPPASTVectorTypeSpecifier.java b/xlc/org.eclipse.cdt.core.lrparser.xlc/parser/org/eclipse/cdt/internal/core/lrparser/xlc/ast/XlcCPPASTVectorTypeSpecifier.java index f3036b962af..1b865bbda59 100644 --- a/xlc/org.eclipse.cdt.core.lrparser.xlc/parser/org/eclipse/cdt/internal/core/lrparser/xlc/ast/XlcCPPASTVectorTypeSpecifier.java +++ b/xlc/org.eclipse.cdt.core.lrparser.xlc/parser/org/eclipse/cdt/internal/core/lrparser/xlc/ast/XlcCPPASTVectorTypeSpecifier.java @@ -30,12 +30,8 @@ public class XlcCPPASTVectorTypeSpecifier extends CPPASTSimpleDeclSpecifier impl @Override public XlcCPPASTVectorTypeSpecifier copy(CopyStyle style) { XlcCPPASTVectorTypeSpecifier copy = new XlcCPPASTVectorTypeSpecifier(); - copySimpleDeclSpec(copy, style); copy.isPixel = isPixel; - if(style == CopyStyle.withLocations) { - copy.setCopyLocation(this); - } - return copy; + return copy(copy, style); } public boolean isPixel() { From 6dd26c152589af2fcf67c2d2c000d8d43b3aa1ab Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Wed, 16 May 2012 13:48:12 -0700 Subject: [PATCH 19/38] Cosmetics. --- .../parser/tests/ast2/AST2CPPSpecTest.java | 176 ++--- .../dom/ast/cpp/ICPPASTDeclSpecifier.java | 22 +- .../org/eclipse/cdt/core/parser/IToken.java | 38 +- .../org/eclipse/cdt/core/parser/Keywords.java | 698 +++++++++--------- 4 files changed, 467 insertions(+), 467 deletions(-) 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 c9e3cbc9c99..f85e9075dfb 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 @@ -53,7 +53,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { public AST2CPPSpecTest(String name) { super(name); } - + public static TestSuite suite() { return suite(AST2CPPSpecTest.class); } @@ -121,7 +121,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // C& operator=(const C& x) { s = x.s; return *this; } // ~C() { } // }; - // + // public void test3_1s4b() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -141,10 +141,10 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // X::X(int = 0) { } // class D: public X { }; // D d2; // X(int) called by D() - public void test3_2s5_a() throws Exception { + public void test3_2s5_a() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } - + // // translation unit 2: // struct X { // X(int); @@ -154,7 +154,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // class D: public X { }; // X(int, int) called by D(); // // D()'s implicit definition // // violates the ODR - public void test3_2s5_b() throws Exception { + public void test3_2s5_b() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -291,7 +291,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { public void test3_4_3s1() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 1); } - + // namespace NS { // class T { }; // void f(T); @@ -391,8 +391,8 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // // resolution chooses Z::h(double) // } public void test3_4_3_2s2() throws Exception { - String[] problems= {"AB::x", "x", "AB::i", "i"}; - parse(getAboveComment(), ParserLanguage.CPP, problems); // qualified names are counted double, so 4 + String[] problems= {"AB::x", "x", "AB::i", "i"}; + parse(getAboveComment(), ParserLanguage.CPP, problems); // qualified names are counted double, so 4 } // namespace A { @@ -423,7 +423,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // { // BD::a++; //OK: S is { A::a, A::a } // } - public void test3_4_3_2s3() throws Exception { + public void test3_4_3_2s3() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -506,7 +506,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // // cannot introduce a qualified type (7.1.5.3) // friend struct Glob; // OK: Refers to (as yet) undeclared Glob // // at global scope. - // + // // }; // struct Base { // struct Data; // OK: Declares nested Data @@ -524,7 +524,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // struct Base::Datum; // error: Datum undefined // struct Base::Data* pBase; // OK: refers to nested Data public void test3_4_4s3() throws Exception { - String[] problems= {"::Glob", "Glob", "Base::Datum", "Datum"}; + String[] problems= {"::Glob", "Glob", "Base::Datum", "Datum"}; parse(getAboveComment(), ParserLanguage.CPP, problems); } @@ -687,7 +687,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // arrpp++; //OK: sizeof UNKA* is known // } // struct X { - // int i; + // int i; // }; // now X is a complete type // int arr[10]; // now the type of arr is complete // X x; @@ -756,7 +756,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } - // class D { // ... + // class D { // ... // }; // D d1; // const D d2; @@ -799,7 +799,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { IASTExpression expr= getExpressionOfStatement(fdef, 0); assertInstance(expr, ICPPASTNewExpression.class); ICPPASTNewExpression newExpr= (ICPPASTNewExpression) expr; - + assertNull(newExpr.getNewPlacement()); assertNull(newExpr.getNewInitializer()); IASTTypeId typeid= newExpr.getTypeId(); @@ -815,7 +815,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // }; public void test5_3_4s12() throws Exception { // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=236856 - + IASTTranslationUnit tu= parse(getAboveComment(), ParserLanguage.CPP, true, 0); IASTFunctionDefinition fdef= getDeclaration(tu, 1); @@ -826,7 +826,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { assertNull(newExpr.getNewPlacement()); assertNull(newExpr.getNewInitializer()); isTypeEqual(CPPVisitor.createType(newExpr.getTypeId()), "int"); - + // new(2,f) T; expr= getExpressionOfStatement(fdef, 1); assertInstance(expr, ICPPASTNewExpression.class); @@ -920,7 +920,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // int x=0; // if (x) // int i; - // + // // if (x) { // int i; // } @@ -937,7 +937,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // int x; // illformed,redeclaration of x // } // } - public void test6_4s3() throws Exception { + public void test6_4s3() throws Exception { // raised bug 90618 // gcc does not report an error, either, so leave it as it is. parse(getAboveComment(), ParserLanguage.CPP, true, 0); @@ -962,7 +962,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // ~A() { } // operator bool() { return val != 0; } // }; - // + // // int foo() { // int i = 1; // while (A a = i) { @@ -997,7 +997,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // goto ly; // OK, jump implies destructor // // call for a followed by construction // // again immediately following label ly - // } + // } public void test6_7s3() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 1); } @@ -1083,7 +1083,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // } // char* g(); // g() has external linkage // static char* g() // error: inconsistent linkage - // { // + // { // // } // void h(); // inline void h(); // external linkage @@ -1138,12 +1138,12 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // typedef int I; // typedef int I; // typedef I I; - public void test7_1_3s2() throws Exception { + public void test7_1_3s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } - // class complex { // + // class complex { // // }; // typedef int complex; // error: redefinition public void test7_1_3s3a() throws Exception { @@ -1151,7 +1151,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { } // typedef int complex; - // class complex { // + // class complex { // // }; // error: redefinition public void test7_1_3s3b() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); @@ -1230,7 +1230,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // X x; // Y(); // }; - // + // // int foo() { // const Y y; // y.x.i++; //wellformed: mutable member can be modified @@ -1578,7 +1578,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // } public void test7_3_3s11() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); - } + } // struct A { int x(); }; // struct B : A { }; @@ -1840,10 +1840,10 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { IASTTranslationUnit tu= parse(getAboveComment(), ParserLanguage.CPP, true, 1); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + assertInstance(col.getName(4), ICPPASTTemplateId.class); assertInstance(((ICPPASTTemplateId)col.getName(4)).getTemplateArguments()[0], IASTTypeId.class); - + final IASTName S_int_1 = col.getName(7); assertInstance(S_int_1, ICPPASTTemplateId.class); assertInstance(((ICPPASTTemplateId)S_int_1).getTemplateArguments()[0], IASTExpression.class); @@ -1879,7 +1879,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { public void test8_2s7a() throws Exception { // TODO raised bug 90633 final String code = getAboveComment(); parse(code, ParserLanguage.CPP, true, 1); - + BindingAssertionHelper ba= new BindingAssertionHelper(code, true); IFunction f= ba.assertNonProblem("f", 1, IFunction.class); isTypeEqual(f.getType(), "void (int (*)(C))"); @@ -1914,7 +1914,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // const int ci = 10, *pc = &ci, *const cpc = pc, **ppc; // int i, *p, *const cp = &i; - // + // // int f() { // i = ci; // *cp = ci; @@ -1996,7 +1996,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // int a; // }; // class Y; - // + // // void f() { // int X::* pmi = &X::a; // void (X::* pmf)(int) = &X::f; @@ -2332,7 +2332,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { } // char msg[] = "Syntax error on line %s"; - public void test8_5_2s1() throws Exception { + public void test8_5_2s1() throws Exception { // raised bug 90647 parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -2545,7 +2545,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // int g() { return a++; } // }; // int s::f() const { return a; } - // + // // void k(s& x, const s& y) // { // x.f(); @@ -2558,8 +2558,8 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { final String code = getAboveComment(); IASTTranslationUnit tu= parse(code, ParserLanguage.CPP, problems); BindingAssertionHelper bh= new BindingAssertionHelper(code, true); - bh.assertNonProblem("g();", 1); - bh.assertProblem("g(); //error", 1); + bh.assertNonProblem("g();", 1); + bh.assertProblem("g(); //error", 1); } // class process { @@ -2606,7 +2606,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // p = "Jennifer"; // // ... // } - public void test9_5s2() throws Exception { + public void test9_5s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -2751,7 +2751,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // class B : public L { }; // class C : public A, public B { void f(); }; // wellformed // class D : public A, public L { void f(); }; // wellformed - // + // public void test10_1s3b() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -3578,7 +3578,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { parse(code, ParserLanguage.CPP, false, 0); BindingAssertionHelper bh= new BindingAssertionHelper(code, true); ICPPFunction dtor= bh.assertNonProblem("~B() {", 2); - + ICPPFunction d= bh.assertNonProblem("~B(); //1", 2); assertSame(dtor, d); d= bh.assertNonProblem("~B(); //2", 2); @@ -3587,7 +3587,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { assertSame(dtor, d); d= bh.assertNonProblem("~B(); //4", 2); assertSame(dtor, d); - + bh.assertProblem("~B_alias(); //5", 8); } @@ -3928,7 +3928,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // void h(int (*)()); // redeclaration of h(int()) // void h(int x()) { } // definition of h(int()) // void h(int (*x)()) { } // illformed: redefinition of h(int()) - public void test12_8s3d() throws Exception { + public void test12_8s3d() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 1); } @@ -4474,7 +4474,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // // ... // }; // Array v1(20); - // typedef complex dcomplex; + // typedef complex dcomplex; // Array v2(30); // Array v3(40); // void bar() { @@ -4677,7 +4677,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // static T s; // }; // template T X::s = 0; - public void test14_5_1_3s1() throws Exception { + public void test14_5_1_3s1() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4693,7 +4693,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // template friend class frd; // // ... // }; - public void test14_5_4s1() throws Exception { + public void test14_5_4s1() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4791,7 +4791,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // template class A { }; // #3 // template class A { }; // #4 // template class A { }; // #5 - // A a5; // ambiguous: matches #3 and #5 : expect problem + // A a5; // ambiguous: matches #3 and #5 : expect problem public void test14_5_5_1s2b() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 1); } @@ -4842,12 +4842,12 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } - // // file1.c + // // file1.c // template // void f(T*); - // void g(int* p) { - // f(p); // call - // // f(int*) + // void g(int* p) { + // f(p); // call + // // f(int*) // } public void test14_5_6_1s1a() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); @@ -4909,7 +4909,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { ICPPSpecialization templateSpecialization = (ICPPSpecialization) inst.getTemplateDefinition(); assertSame(op1, templateSpecialization.getSpecializedBinding()); } - + // template struct A { A(); }; // template void f(T); // template void f(T*); @@ -5115,7 +5115,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // template void N::B::f(C) { // C b; // C is the template parameter, not N::C // } - public void test14_6_1s6() throws Exception { + public void test14_6_1s6() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -5157,7 +5157,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // template struct X : B { // A a; // a has type double // }; - public void test14_6_2s3() throws Exception { + public void test14_6_2s3() throws Exception { final String content= getAboveComment(); IASTTranslationUnit tu= parse(content, ParserLanguage.CPP, true, 0); BindingAssertionHelper bh= new BindingAssertionHelper(content, true); @@ -5236,7 +5236,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // template T X::s = 0; // X aa; // X bb; - public void test14_7s6() throws Exception { + public void test14_7s6() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -5330,7 +5330,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // int i = m.get("Nicholas"); // // ... // } - public void test14_7_1s10() throws Exception { + public void test14_7_1s10() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -5403,7 +5403,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // template class Array { }; // template void sort(Array& v) { } // template<> void sort(Array&) ; - public void test14_7_3s1() throws Exception { + public void test14_7_3s1() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -5687,7 +5687,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { inst= bh.assertNonProblem("f()", -2); assertEquals("", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true)); } - + // struct X { }; // struct Y { // Y(X){} @@ -5698,8 +5698,8 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // X x3 = f(x1, x2); // deduction fails on #1 (cannot add X+X), calls #2 public void test14_8_2s8a() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); - } - + } + // template int f(T[5]); // int I = f(0); // int j = f(0); // invalid array // also no error with gcc @@ -5768,7 +5768,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { BindingAssertionHelper bh= new BindingAssertionHelper(code, true); bh.assertProblem("f", 0); } - + // template int f(int); // int i2 = f(0); // can't conv 1 to int* public void test14_8_2s8g() throws Exception { @@ -5796,14 +5796,14 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { public void test14_8_2_1s1a() throws Exception { final String code= getAboveComment(); BindingAssertionHelper bh= new BindingAssertionHelper(code, true); - + ICPPTemplateInstance inst; inst= bh.assertNonProblem("f({1,2,3})", 1); assertEquals("", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true)); bh.assertProblem("f({1,\"asdf\"})", 1); bh.assertProblem("g({1,2,3})", 1); } - + // template void f(Types& ...); // template void g(T1, Types ...); // void h(int x, float& y) { @@ -5814,14 +5814,14 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { public void test14_8_2_1s1b() throws Exception { final String code= getAboveComment(); BindingAssertionHelper bh= new BindingAssertionHelper(code, true); - + ICPPTemplateInstance inst; inst= bh.assertNonProblem("f(x, y, z)", 1); assertEquals("", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true)); inst= bh.assertNonProblem("g(x, y, z)", 1); assertEquals("", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true)); } - + // template int f(T&&); // template int g(const T&&); // int i; @@ -5853,7 +5853,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { inst= bh.assertNonProblem("f(g)", 1); assertEquals("", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true)); } - + // // Ambiguous deduction causes the second function parameter to be a // // non-deduced context. // template int f(T, T (*p)(T)); @@ -5881,7 +5881,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { inst= bh.assertNonProblem("f(1, g)", 1); assertEquals("", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true)); } - + // struct A { // template operator T***(); // }; @@ -5892,7 +5892,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { public void test14_8_2_3s7() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } - + // template T f(int); // #1 // template T f(U); // #2 // void g() { @@ -5901,7 +5901,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { public void test14_8_2_4s11() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } - + // template struct Tuple { }; // template void g(Tuple); // #1 // template void g(Tuple); // #2 @@ -5910,17 +5910,17 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // g(Tuple<>()); // calls #1 // g(Tuple()); // calls #2 // g(Tuple()); // calls #3 - // g(Tuple()); // calls #3 + // g(Tuple()); // calls #3 // } public void test14_8_2_4s12() throws Exception { final String code= getAboveComment(); parse(code, ParserLanguage.CPP, true, 0); - + BindingAssertionHelper bh= new BindingAssertionHelper(code, true); ICPPFunction g1= bh.assertNonProblem("g(Tuple)", 1); ICPPFunction g2= bh.assertNonProblem("g(Tuple)", 1); ICPPFunction g3= bh.assertNonProblem("g(Tuple)", 1); - + ICPPTemplateInstance x= bh.assertNonProblem("g(Tuple<>())", 1); assertSame(g1, x.getTemplateDefinition()); x= bh.assertNonProblem("g(Tuple())", 1); @@ -5929,8 +5929,8 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { assertSame(g3, x.getTemplateDefinition()); x= bh.assertNonProblem("g(Tuple())", 1); assertSame(g3, x.getTemplateDefinition()); - } - + } + // template void g(T); // void test() { // g({1,2,3}); // error: no argument deduced for T @@ -5999,7 +5999,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { public void test14_8_2_5s7d() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } - + // template void f(T&&); // template <> void f(int&) { } // #1 // template <> void f(int&&) { } // #2 @@ -6076,7 +6076,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { inst= bh.assertNonProblem("f(a1, a2)", 1); assertEquals("<1>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true)); } - + // template class A { // public: // typedef int X; @@ -6100,7 +6100,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } - + // template class A {}; // template void f(A); // void k1() { @@ -6162,7 +6162,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { inst= bh.assertNonProblem("f()", -2); assertEquals("", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true)); } - + // template