1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-09 10:46:02 +02:00

Merge remote-tracking branch 'cdt/master' into sd90

This commit is contained in:
Andrew Gvozdev 2013-03-01 15:54:39 -05:00
commit c19b1ebaea
133 changed files with 5006 additions and 2308 deletions

View file

@ -10195,4 +10195,70 @@ public class AST2CPPTests extends AST2TestBase {
long BSize = SizeofCalculator.getSizeAndAlignment(B, nameB).size; long BSize = SizeofCalculator.getSizeAndAlignment(B, nameB).size;
assertEquals(pointerSize, BSize); assertEquals(pointerSize, BSize);
} }
// namespace NS {
// class Enclosing {
// class Inner {};
// };
// }
public void testNestedClassScopeInlineDefinition_401661() throws Exception {
String code = getAboveComment();
parseAndCheckBindings(code);
BindingAssertionHelper bh = new BindingAssertionHelper(code, true);
ICPPClassType Enclosing = bh.assertNonProblem("Enclosing", 9);
ICPPClassType Inner = bh.assertNonProblem("Inner", 5);
assertEquals(Enclosing.getCompositeScope(), Inner.getScope());
}
// namespace NS {
// class Enclosing {
// class Inner;
// };
// }
// class NS::Enclosing::Inner{};
public void testNestedClassScopeSeparateDefinition_401661() throws Exception {
String code = getAboveComment();
parseAndCheckBindings(code);
BindingAssertionHelper bh = new BindingAssertionHelper(code, true);
ICPPClassType Enclosing = bh.assertNonProblem("Enclosing", 9);
ICPPClassType Inner = bh.assertNonProblem("Inner;", 5);
assertEquals(Enclosing.getCompositeScope(), Inner.getScope());
}
// namespace NS {
// class Inner {};
// }
public void testClassScopeInlineDefinition_401661() throws Exception {
String code = getAboveComment();
parseAndCheckBindings(code);
BindingAssertionHelper bh = new BindingAssertionHelper(code, true);
ICPPNamespace NamespaceNS = bh.assertNonProblem("NS {", 2);
ICPPClassType Inner = bh.assertNonProblem("Inner", 5);
assertEquals(NamespaceNS.getNamespaceScope(), Inner.getScope());
}
// namespace NS {
// class Inner;
// }
// class NS::Inner{};
public void testClassScopeSeparateDefinition_401661() throws Exception {
String code = getAboveComment();
parseAndCheckBindings(code);
BindingAssertionHelper bh = new BindingAssertionHelper(code, true);
ICPPNamespace NamespaceNS = bh.assertNonProblem("NS {", 2);
ICPPClassType Inner = bh.assertNonProblem("Inner;", 5);
assertEquals(NamespaceNS.getNamespaceScope(), Inner.getScope());
}
} }

View file

@ -7205,6 +7205,23 @@ public class AST2TemplateTests extends AST2TestBase {
parseAndCheckBindings(); parseAndCheckBindings();
} }
// int fn(int);
// struct S {
// template <typename... Args>
// auto operator()(Args... args) -> decltype(fn(args...));
// };
// template <typename F>
// int foo(F);
// template <typename T>
// void bar(T);
// int main() {
// S s;
// bar(foo(s(0)));
// }
public void testVariadicTemplatesAndFunctionObjects_401479() throws Exception {
parseAndCheckBindings();
}
// struct S { // struct S {
// void kind(); // void kind();
// }; // };
@ -7312,4 +7329,26 @@ public class AST2TemplateTests extends AST2TestBase {
public void testVariadicNonTypeTemplateParameter_401142() throws Exception { public void testVariadicNonTypeTemplateParameter_401142() throws Exception {
parseAndCheckBindings(); parseAndCheckBindings();
} }
// template <bool... Args>
// struct ice_or;
// template <>
// struct ice_or<> {
// static const bool value = false;
// };
// template <bool First, bool... Rest>
// struct ice_or<First, Rest...> {
// static const bool value = ice_or<Rest...>::value;
// };
// template <bool> struct S {};
// template <>
// struct S<false> {
// typedef int type;
// };
// int main() {
// S<ice_or<false, false>::value>::type t;
// }
public void testVariadicNonTypeTemplateParameter_401400() throws Exception {
parseAndCheckBindings();
}
} }

View file

@ -4,8 +4,10 @@
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Eidsness - Initial implementation
*/ */
package org.eclipse.cdt.internal.pdom.tests; package org.eclipse.cdt.internal.pdom.tests;
import java.io.File; import java.io.File;
@ -18,33 +20,29 @@ import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.cdt.internal.core.pdom.db.PDOMStringSet; import org.eclipse.cdt.internal.core.pdom.db.PDOMStringSet;
// copy/pasted from BTreeTests // copy/pasted from BTreeTests
public class PDOMStringSetTests extends BaseTestCase public class PDOMStringSetTests extends BaseTestCase {
{
protected File dbFile; protected File dbFile;
protected Database db; protected Database db;
protected PDOMStringSet stringSet; protected PDOMStringSet stringSet;
protected int rootRecord; protected int rootRecord;
public static Test suite() public static Test suite() {
{ return suite(PDOMStringSetTests.class);
return suite( PDOMStringSetTests.class );
} }
@Override @Override
protected void setUp() throws Exception protected void setUp() throws Exception {
{
super.setUp(); super.setUp();
dbFile = File.createTempFile( "pdomstringsettest", "db" ); dbFile = File.createTempFile("pdomstringsettest", "db");
db = new Database( dbFile, new ChunkCache(), 0, false ); db = new Database(dbFile, new ChunkCache(), 0, false);
db.setExclusiveLock(); db.setExclusiveLock();
rootRecord = Database.DATA_AREA; rootRecord = Database.DATA_AREA;
stringSet = new PDOMStringSet( db, rootRecord ); stringSet = new PDOMStringSet(db, rootRecord);
} }
@Override @Override
protected void tearDown() throws Exception protected void tearDown() throws Exception {
{
db.close(); db.close();
dbFile.deleteOnExit(); dbFile.deleteOnExit();
@ -52,27 +50,26 @@ public class PDOMStringSetTests extends BaseTestCase
} }
// Quick tests to exercise the basic functionality. // Quick tests to exercise the basic functionality.
public void testInterface() throws Exception public void testInterface() throws Exception {
{ long val1_rec_a = stringSet.add("val1");
long val1_rec_a = stringSet.add( "val1" ); long val2_rec_a = stringSet.add("val2");
long val2_rec_a = stringSet.add( "val2" ); long val1_rec_b = stringSet.add("val1");
long val1_rec_b = stringSet.add( "val1" ); assertTrue(val1_rec_a != 0);
assertTrue( val1_rec_a != 0 ); assertTrue(val2_rec_a != 0);
assertTrue( val2_rec_a != 0 ); assertEquals(val1_rec_a, val1_rec_b);
assertEquals( val1_rec_a, val1_rec_b );
long val1_find = stringSet.find( "val1" ); long val1_find = stringSet.find("val1");
long val2_find = stringSet.find( "val2" ); long val2_find = stringSet.find("val2");
assertEquals( val1_rec_a, val1_find ); assertEquals(val1_rec_a, val1_find);
assertEquals( val2_rec_a, val2_find ); assertEquals(val2_rec_a, val2_find);
long val1_rm = stringSet.remove( "val1" ); long val1_rm = stringSet.remove("val1");
assertEquals( val1_rec_a, val1_rm ); assertEquals(val1_rec_a, val1_rm);
assertEquals( 0, stringSet.find( "val1" ) ); assertEquals(0, stringSet.find("val1"));
assertEquals( val2_rec_a, stringSet.find( "val2" ) ); assertEquals(val2_rec_a, stringSet.find("val2"));
stringSet.clearCaches(); stringSet.clearCaches();
assertEquals( val2_rec_a, stringSet.find( "val2" ) ); assertEquals(val2_rec_a, stringSet.find("val2"));
assertEquals( 0, stringSet.find( "val1" ) ); assertEquals(0, stringSet.find("val1"));
} }
} }

View file

@ -4,8 +4,10 @@
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Eidsness - Initial implementation
*/ */
package org.eclipse.cdt.internal.pdom.tests; package org.eclipse.cdt.internal.pdom.tests;
import java.io.File; import java.io.File;
@ -25,110 +27,119 @@ import org.eclipse.cdt.internal.core.pdom.tag.PDOMTag;
import org.eclipse.cdt.internal.core.pdom.tag.PDOMTagIndex; import org.eclipse.cdt.internal.core.pdom.tag.PDOMTagIndex;
// copy/pasted from BTreeTests // copy/pasted from BTreeTests
public class PDOMTagIndexTests extends BaseTestCase public class PDOMTagIndexTests extends BaseTestCase {
{
private PDOM pdom; private PDOM pdom;
public static Test suite() public static Test suite() {
{ return suite(PDOMTagIndexTests.class);
return suite( PDOMTagIndexTests.class );
} }
private static class MockIndexLocationConverter implements IIndexLocationConverter private static class MockIndexLocationConverter implements
{ IIndexLocationConverter {
@Override public IIndexFileLocation fromInternalFormat( String raw ) { return null; } @Override
@Override public String toInternalFormat( IIndexFileLocation location ) { return null; } public IIndexFileLocation fromInternalFormat(String raw) {
return null;
} }
@Override @Override
protected void setUp() throws Exception public String toInternalFormat(IIndexFileLocation location) {
{ return null;
}
}
@Override
protected void setUp() throws Exception {
super.setUp(); super.setUp();
File tmpFile = File.createTempFile( getClass().getSimpleName() + '.' + Double.toString( Math.random() ).substring( 2 ), null ); // Create a dummy instance of the PDOM for the various tests to operate
pdom = new WritablePDOM( tmpFile, new MockIndexLocationConverter(), LanguageManager.getInstance().getPDOMLinkageFactoryMappings() ); // upon. Also acquire the PDOM's write lock to simulate the condition
// under which the tag index is normally accessed.
File tmpFile = File.createTempFile(getClass().getSimpleName() + '.'
+ Double.toString(Math.random()).substring(2), null);
pdom = new WritablePDOM(tmpFile, new MockIndexLocationConverter(),
LanguageManager.getInstance().getPDOMLinkageFactoryMappings());
pdom.acquireWriteLock();
} }
@Override @Override
protected void tearDown() throws Exception protected void tearDown() throws Exception {
{
pdom.close(); pdom.close();
super.tearDown(); super.tearDown();
} }
// return the nearest valid record that is less than the specified base // return the nearest valid record that is less than the specified base
private static long lastRecordBase = 1000; private static long lastRecordBase = 1000;
private static long computeValidRecord()
{ private static long computeValidRecord() {
lastRecordBase += 1000; lastRecordBase += 1000;
return ( lastRecordBase & ~7L ) | 2; return (lastRecordBase & ~7L) | 2;
} }
// A quick sanity test to confirm basic functionality. // A quick sanity test to confirm basic functionality.
public void testSimple() throws Exception public void testSimple() throws Exception {
{
String tagger = "tagger_a"; String tagger = "tagger_a";
long rec = computeValidRecord(); long rec = computeValidRecord();
assertNotNull( PDOMTagIndex.createTag( pdom, rec, tagger, 1 ) ); assertNotNull(PDOMTagIndex.createTag(pdom, rec, tagger, 1));
assertNotNull( PDOMTagIndex.getTag( pdom, rec, tagger ) ); assertNotNull(PDOMTagIndex.getTag(pdom, rec, tagger));
} }
public void testMultipleTaggers() throws Exception public void testMultipleTaggers() throws Exception {
{
String tagger_a = "tagger_a"; String tagger_a = "tagger_a";
String tagger_b = "tagger_b"; String tagger_b = "tagger_b";
long rec1 = computeValidRecord(); long rec1 = computeValidRecord();
long rec2 = computeValidRecord(); long rec2 = computeValidRecord();
assertNotNull( PDOMTagIndex.createTag( pdom, rec1, tagger_a, 1 ) ); assertNotNull(PDOMTagIndex.createTag(pdom, rec1, tagger_a, 1));
assertNotNull( PDOMTagIndex.createTag( pdom, rec1, tagger_b, 1 ) ); assertNotNull(PDOMTagIndex.createTag(pdom, rec1, tagger_b, 1));
assertNotNull( PDOMTagIndex.createTag( pdom, rec2, tagger_a, 1 ) ); assertNotNull(PDOMTagIndex.createTag(pdom, rec2, tagger_a, 1));
assertNotNull( PDOMTagIndex.getTag( pdom, rec2, tagger_a ) ); assertNotNull(PDOMTagIndex.getTag(pdom, rec2, tagger_a));
assertNull( PDOMTagIndex.getTag( pdom, rec2, tagger_b ) ); assertNull(PDOMTagIndex.getTag(pdom, rec2, tagger_b));
Iterable<ITag> tags1 = PDOMTagIndex.getTags( pdom, rec1 ); Iterable<ITag> tags1 = PDOMTagIndex.getTags(pdom, rec1);
int tag_count = 0; int tag_count = 0;
for( ITag tag : tags1 ) for (ITag tag : tags1) {
{
++tag_count; ++tag_count;
assertTrue( tag.getTaggerId().equals( tagger_a ) || tag.getTaggerId().equals( tagger_b ) ); assertTrue(tag.getTaggerId().equals(tagger_a)
assertEquals( 1, tag.getDataLen() ); || tag.getTaggerId().equals(tagger_b));
assertEquals(1, tag.getDataLen());
} }
assertEquals( 2, tag_count ); assertEquals(2, tag_count);
} }
public void testReplaceTags() throws Exception public void testReplaceTags() throws Exception {
{
String tagger_a = "tagger_a"; String tagger_a = "tagger_a";
String tagger_b = "tagger_b"; String tagger_b = "tagger_b";
long rec = computeValidRecord(); long rec = computeValidRecord();
ITag taga = PDOMTagIndex.createTag( pdom, rec, tagger_a, 2 ); ITag taga = PDOMTagIndex.createTag(pdom, rec, tagger_a, 2);
assertNotNull( taga ); assertNotNull(taga);
assertTrue( taga instanceof PDOMTag ); assertTrue(taga instanceof PDOMTag);
PDOMTag taga_pdom = (PDOMTag)taga; PDOMTag taga_pdom = (PDOMTag) taga;
ITag tagb = PDOMTagIndex.createTag( pdom, rec, tagger_a, 2 ); ITag tagb = PDOMTagIndex.createTag(pdom, rec, tagger_a, 2);
assertNotNull( tagb ); assertNotNull(tagb);
// replacement should delete tags for taggers that are no longer present and shorter tags // replacement should delete tags for taggers that are no longer present
// and shorter tags
// should be modified in place // should be modified in place
PDOMTagIndex.setTags( pdom, rec, Arrays.<ITag>asList( new Tag( tagger_a, 1 ) ) ); PDOMTagIndex.setTags(pdom, rec,
assertNull( PDOMTagIndex.getTag( pdom, rec, tagger_b ) ); Arrays.<ITag> asList(new Tag(tagger_a, 1)));
ITag shorter_ = PDOMTagIndex.getTag( pdom, rec, tagger_a ); assertNull(PDOMTagIndex.getTag(pdom, rec, tagger_b));
assertNotNull( shorter_ ); ITag shorter_ = PDOMTagIndex.getTag(pdom, rec, tagger_a);
assertTrue( shorter_ instanceof PDOMTag ); assertNotNull(shorter_);
PDOMTag shorter_pdom = (PDOMTag)shorter_; assertTrue(shorter_ instanceof PDOMTag);
assertEquals( taga_pdom.getRecord(), shorter_pdom.getRecord() ); PDOMTag shorter_pdom = (PDOMTag) shorter_;
assertEquals(taga_pdom.getRecord(), shorter_pdom.getRecord());
// longer tags should create a new record // longer tags should create a new record
PDOMTagIndex.setTags( pdom, rec, Arrays.<ITag>asList( new Tag( tagger_a, 4 ) ) ); PDOMTagIndex.setTags(pdom, rec,
ITag longer_ = PDOMTagIndex.getTag( pdom, rec, tagger_a ); Arrays.<ITag> asList(new Tag(tagger_a, 4)));
assertNotNull( longer_ ); ITag longer_ = PDOMTagIndex.getTag(pdom, rec, tagger_a);
assertTrue( longer_ instanceof PDOMTag ); assertNotNull(longer_);
PDOMTag longer_pdom = (PDOMTag)longer_; assertTrue(longer_ instanceof PDOMTag);
assertTrue( taga_pdom.getRecord() != longer_pdom.getRecord() ); PDOMTag longer_pdom = (PDOMTag) longer_;
assertTrue(taga_pdom.getRecord() != longer_pdom.getRecord());
// TODO figure out how to confirm that the original tag was free'd // TODO figure out how to confirm that the original tag was free'd
} }

View file

@ -44,6 +44,15 @@ public interface ICPPTemplateParameterMap {
*/ */
public ICPPTemplateArgument[] getPackExpansion(ICPPTemplateParameter param); public ICPPTemplateArgument[] getPackExpansion(ICPPTemplateParameter param);
/**
* If 'param' is not a parameter pack, returns the value for 'param' in the map.
* If 'param' is a parmameter pack, returns the value at position 'packOffset'
* in the pack of values for 'param' in the map.
* Returns <code>null</code> is 'param' is not mapped.
* @since 5.5
*/
public ICPPTemplateArgument getArgument(ICPPTemplateParameter param, int packOffset);
/** /**
* Returns the array of template parameter positions, for which a mapping exists. * Returns the array of template parameter positions, for which a mapping exists.
*/ */

View file

@ -4,31 +4,36 @@
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Eidsness - Initial implementation
*/ */
package org.eclipse.cdt.core.dom.ast.tag; package org.eclipse.cdt.core.dom.ast.tag;
import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
/** /**
* Implementations are contributed with the org.eclipse.cdt.core.tagger extension-point. The implementation * Implementations are contributed with the org.eclipse.cdt.core.tagger extension-point.
* is responsible for populating the tag's data using a given input binding. * The implementation is responsible for populating the tag's data using a given input binding.
* *
* @see #process(ITagWriter, IBinding, IASTName) * @see #process(ITagWriter, IBinding, IASTName)
* @since 5.5 * @since 5.5
*/ */
public interface IBindingTagger public interface IBindingTagger {
{
/** /**
* Examine the given input binding to decide if a tag should be created. Use the given tagWriter * Examines the given input binding to decide if a tag should be created. Use the given
* to create data if needed. Return the tag if one was created and null otherwise. A tagger (as * tagWriter to create data if needed. Return the tag if one was created and null otherwise.
* identified by it's unique id string) is allowed to create only one tag for each binding. * A tagger (as identified by it's unique id string) is allowed to create only one tag for each
* binding.
* *
* @param tagWriter the writer to use for creating new tags * @param tagWriter
* @param binding the binding to examine when populating the tag (if needed) * the writer to use for creating new tags
* @param ast the AST name from which the binding was created * @param binding
* the binding to examine when populating the tag (if needed)
* @param ast
* the AST name from which the binding was created
* @return the tag if one was created and null otherwise * @return the tag if one was created and null otherwise
*/ */
public ITag process( ITagWriter tagWriter, IBinding binding, IASTName ast ); public ITag process(ITagWriter tagWriter, IBinding binding, IASTName ast);
} }

View file

@ -4,38 +4,42 @@
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Eidsness - Initial implementation
*/ */
package org.eclipse.cdt.core.dom.ast.tag; package org.eclipse.cdt.core.dom.ast.tag;
/** /**
* Tags are used to annotate {@link ITagReader}'s with extra information. They are created * Tags are used to annotate {@link ITagReader}'s with extra information. They are created by
* by implementations of {@link IBindingTagger} which are contributed using the * implementations of {@link IBindingTagger} which are contributed using
* org.eclipse.cdt.core.tagger extension point. The base tag interface is read-only, it * the org.eclipse.cdt.core.tagger extension point. The base tag interface is read-only, it is
* is extended by the writable {@link IWritableTag}. * extended by the writable {@link IWritableTag}.
* *
* @see IBindingTagger * @see IBindingTagger
* @see ITagReader * @see ITagReader
* @see IWritableTag * @see IWritableTag
* @since 5.5 * @since 5.5
*/ */
public interface ITag public interface ITag {
{
/** A constant that is returned to indicate a read failure. */ /** A constant that is returned to indicate a read failure. */
public static final int Fail = -1; public static final int FAIL = -1;
/** Return the number of bytes in the tag's data payload. */ /** Returns the number of bytes in the tag's data payload. */
public int getDataLen(); public int getDataLen();
/** Return the globally unique id of the tagger that created the receiver. */ /** Returns the globally unique id of the tagger that created the receiver. */
public String getTaggerId(); public String getTaggerId();
/** Return the byte from the specified offset or {@link #Fail} on failure. */ /** Returns the byte from the specified offset or {@link #FAIL} on failure. */
public int getByte( int offset ); public int getByte(int offset);
/** Return the specified number of bytes from the specified offset. Specify len of -1 to read all /**
* bytes from the specified offset to the end of the payload. Return null on failure. */ * Returns the specified number of bytes from the specified offset. Specify {@code len} of -1
public byte[] getBytes( int offset, int len ); * to read all bytes from the specified offset to the end of the payload. Returns null if
* the given range is not valid. This would be expected if the version of the contributor has
// TODO read methods for all the other types * changed in a way that changes the structure of the data that it stores. Contributors must be
* able to deal with that case.
*/
public byte[] getBytes(int offset, int len);
} }

View file

@ -4,11 +4,12 @@
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Eidsness - Initial implementation
*/ */
package org.eclipse.cdt.core.dom.ast.tag; package org.eclipse.cdt.core.dom.ast.tag;
/** /**
* An interface that provides read-only access to the tags associated with a particular binding. * An interface that provides read-only access to the tags associated with a particular binding.
* *
@ -16,18 +17,19 @@ package org.eclipse.cdt.core.dom.ast.tag;
* @see ITagService * @see ITagService
* @since 5.5 * @since 5.5
*/ */
public interface ITagReader public interface ITagReader {
{
/** /**
* Look for a tag for the receiver, returns null if there is no such tag. * Looks for a tag for the receiver, returns null if there is no such tag.
* *
* @param id A string that uniquely identifies the tag to be returned. This value was provided by the contributor * @param id
* when the tag was created (see {@link ITagWriter#createTag(String, int)}). * A string that uniquely identifies the tag to be returned. This value was provided
* by the contributor when the tag was created
* (see {@link ITagWriter#createTag(String, int)}).
*/ */
public ITag getTag( String id ); public ITag getTag(String id);
/** /**
* Return all tags known to the receiver. Does not return null. * Returns all tags known to the receiver. Does not return null.
*/ */
public Iterable<ITag> getTags(); public Iterable<ITag> getTags();
} }

View file

@ -4,27 +4,29 @@
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Eidsness - Initial implementation
*/ */
package org.eclipse.cdt.core.dom.ast.tag; package org.eclipse.cdt.core.dom.ast.tag;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
/** /**
* Provides ITagReaders for specific bindings. The kind of the reader will vary based on * Provides ITagReaders for specific bindings. The kind of the reader will vary based on the kind
* the kind of the input binding. * of the input binding.
* *
* @see ITag * @see ITag
* @see ITagReader * @see ITagReader
* @since 5.5 * @since 5.5
*/ */
public interface ITagService public interface ITagService {
{
/** /**
* Finds or creates a tag reader for the specified binding or null if a reader cannot * Finds or creates a tag reader for the specified binding or null if a reader cannot be
* be associated with this binding. * associated with this binding.
* *
* @param binding could be null * @param binding
* could be null
*/ */
public ITagReader findTagReader( IBinding binding ); public ITagReader findTagReader(IBinding binding);
} }

View file

@ -4,6 +4,9 @@
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Eidsness - Initial implementation
*/ */
package org.eclipse.cdt.core.dom.ast.tag; package org.eclipse.cdt.core.dom.ast.tag;
@ -15,20 +18,22 @@ package org.eclipse.cdt.core.dom.ast.tag;
* @see ITagService * @see ITagService
* @since 5.5 * @since 5.5
*/ */
public interface ITagWriter public interface ITagWriter {
{
/** /**
* Create and return a new tag for the receiver. E.g., if this writer is associated with a persistent binding, * Creates and returns a new tag for the receiver. E.g., if this writer is associated with
* then returned tag will read and write from the PDOM database. * a persistent binding, then returned tag will read and write from the PDOM database.
* *
* @param id A string that uniquely identifies the tag to be returned. This value will be used by the contributor * @param id
* when to find the tag (see {@link ITagReader#getTag(String)}). * A string that uniquely identifies the tag to be returned. This value will be used
* @param len The number of bytes that should be allocated to store the tag's data. * by the contributor when to find the tag (see {@link ITagReader#getTag(String)}).
* @param len
* The number of bytes that should be allocated to store the tag's data.
*/ */
public IWritableTag createTag( String id, int len ); public IWritableTag createTag(String id, int len);
/** /**
* Sets the receiver's tags to only the ones provided. Deletes existing tags that are not in the argument list. * Sets the receiver's tags to only the ones provided. Deletes existing tags that are not in
* the argument list.
*/ */
public boolean setTags( Iterable<ITag> tags ); public boolean setTags(Iterable<ITag> tags);
} }

View file

@ -4,28 +4,30 @@
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Eidsness - Initial implementation
*/ */
package org.eclipse.cdt.core.dom.ast.tag; package org.eclipse.cdt.core.dom.ast.tag;
/** /**
* Tags are used to annotate {@link ITagWriter}'s with extra information. They are created * Tags are used to annotate {@link ITagWriter}'s with extra information. They are created by
* by implementations of {@link IBindingTagger} which are contributed using the * implementations of {@link IBindingTagger} which are contributed using
* org.eclipse.cdt.core.tagger extension point. * the org.eclipse.cdt.core.tagger extension point.
* *
* @see IBindingTagger * @see IBindingTagger
* @see ITagReader * @see ITagReader
* @see ITagWriter * @see ITagWriter
* @since 5.5 * @since 5.5
*/ */
public interface IWritableTag extends ITag public interface IWritableTag extends ITag {
{ /** Writes the given byte to the given offset in the tag. Returns {@code true} if successful. */
/** Write the given byte to the given offset in the tag. Return true if successful and false otherwise. */ public boolean putByte(int offset, byte data);
public boolean putByte( int offset, byte data );
/** Write the argument buffer into the receiver's payload starting at the specified offset. Write the specified /**
* number of bytes or the full buffer when len is -1. Return true if successful and false otherwise. */ * Writes the argument buffer into the receiver's payload starting at the specified offset.
public boolean putBytes( int offset, byte data[], int len ); * Writes the specified number of bytes or the full buffer when {@code len} is -1. Returns
* {@code true} if successful.
// TODO write for all types */
public boolean putBytes(int offset, byte data[], int len);
} }

View file

@ -4,8 +4,10 @@
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Eidsness - Initial implementation
*/ */
package org.eclipse.cdt.internal.core.dom.ast.tag; package org.eclipse.cdt.internal.core.dom.ast.tag;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator; import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
@ -19,78 +21,68 @@ import org.eclipse.cdt.core.dom.ast.tag.ITagWriter;
import org.eclipse.cdt.core.dom.ast.tag.IWritableTag; import org.eclipse.cdt.core.dom.ast.tag.IWritableTag;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding;
public class NonCachedTaggable implements ITagReader, ITagWriter public class NonCachedTaggable implements ITagReader, ITagWriter {
{
private final IBinding binding; private final IBinding binding;
private IASTName ast; private IASTName ast;
public NonCachedTaggable( IBinding binding ) public NonCachedTaggable(IBinding binding) {
{
this.binding = binding; this.binding = binding;
} }
@Override @Override
public IWritableTag createTag( String id, int len ) public IWritableTag createTag(String id, int len) {
{ return new Tag(id, len);
return new Tag( id, len );
} }
@Override @Override
public ITag getTag( String id ) public ITag getTag(String id) {
{ return TagManager.getInstance().process(id, this, binding, getAST());
return TagManager.getInstance().process( id, this, binding, getAST() );
} }
@Override @Override
public Iterable<ITag> getTags() public Iterable<ITag> getTags() {
{ return TagManager.getInstance().process(this, binding, getAST());
return TagManager.getInstance().process( this, binding, getAST() );
} }
@Override @Override
public boolean setTags( Iterable<ITag> tags ) public boolean setTags(Iterable<ITag> tags) {
{ // This non-caching implementation has nothing to set, the tags will be regenerated
// this non-caching implementation has nothing to set, the tags will be regenerated
// when they are queried // when they are queried
return true; return true;
} }
private IASTName getAST() private IASTName getAST() {
{ if (ast != null)
if( ast != null )
return ast; return ast;
if( ! ( binding instanceof ICPPInternalBinding ) ) if (!(binding instanceof ICPPInternalBinding))
return null; return null;
IASTNode node = getPhysicalNode( (ICPPInternalBinding)binding ); IASTNode node = getPhysicalNode((ICPPInternalBinding) binding);
if( node == null ) if (node == null)
return null; return null;
return ast = getName( node ); return ast = getName(node);
} }
private static IASTNode getPhysicalNode( ICPPInternalBinding binding ) private static IASTNode getPhysicalNode(ICPPInternalBinding binding) {
{
IASTNode node = binding.getDefinition(); IASTNode node = binding.getDefinition();
if( node != null ) if (node != null)
return node; return node;
IASTNode[] nodes = binding.getDeclarations(); IASTNode[] nodes = binding.getDeclarations();
if( nodes == null if (nodes == null || nodes.length <= 0)
|| nodes.length <= 0 )
return null; return null;
return nodes[0]; return nodes[0];
} }
private static IASTName getName( IASTNode node ) private static IASTName getName(IASTNode node) {
{ if (node instanceof IASTName)
if( node instanceof IASTName ) return (IASTName) node;
return (IASTName)node; if (node instanceof ICPPASTCompositeTypeSpecifier)
if( node instanceof ICPPASTCompositeTypeSpecifier ) return ((ICPPASTCompositeTypeSpecifier) node).getName();
return ( (ICPPASTCompositeTypeSpecifier)node ).getName(); if (node instanceof IASTDeclarator)
if( node instanceof IASTDeclarator ) return ((IASTDeclarator) node).getName();
return ( (IASTDeclarator)node ).getName();
return null; return null;
} }
} }

View file

@ -4,8 +4,10 @@
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Eidsness - Initial implementation
*/ */
package org.eclipse.cdt.internal.core.dom.ast.tag; package org.eclipse.cdt.internal.core.dom.ast.tag;
import org.eclipse.cdt.core.dom.ast.tag.ITag; import org.eclipse.cdt.core.dom.ast.tag.ITag;
@ -16,31 +18,32 @@ import org.eclipse.cdt.core.dom.ast.tag.IWritableTag;
* *
* @see NonCachedTaggable * @see NonCachedTaggable
*/ */
public class Tag implements IWritableTag public class Tag implements IWritableTag {
{
private final String taggerId; private final String taggerId;
private final byte[] buff; private final byte[] buff;
public Tag( String taggerId, int dataLen ) public Tag(String taggerId, int dataLen) {
{
this.taggerId = taggerId; this.taggerId = taggerId;
this.buff = new byte[dataLen]; this.buff = new byte[dataLen];
} }
@Override public String getTaggerId() { return taggerId; } @Override
@Override public int getDataLen() { return buff.length; } public String getTaggerId() {
return taggerId;
private boolean isInBounds( int offset, int len )
{
return offset >= 0
&& offset < buff.length
&& ( offset + len ) <= buff.length;
} }
@Override @Override
public boolean putByte( int offset, byte b ) public int getDataLen() {
{ return buff.length;
if( ! isInBounds( offset, 1 ) ) }
private boolean isInBounds(int offset, int len) {
return offset >= 0 && offset < buff.length && (offset + len) <= buff.length;
}
@Override
public boolean putByte(int offset, byte b) {
if (!isInBounds(offset, 1))
return false; return false;
buff[offset] = b; buff[offset] = b;
@ -48,31 +51,28 @@ public class Tag implements IWritableTag
} }
@Override @Override
public boolean putBytes( int offset, byte[] data, int len ) public boolean putBytes(int offset, byte[] data, int len) {
{
len = len >= 0 ? len : data.length; len = len >= 0 ? len : data.length;
if( ! isInBounds( offset, len ) ) if (!isInBounds(offset, len))
return false; return false;
System.arraycopy( data, 0, buff, offset, len ); System.arraycopy(data, 0, buff, offset, len);
return true; return true;
} }
@Override @Override
public int getByte( int offset ) public int getByte(int offset) {
{ return isInBounds(offset, 1) ? buff[offset] : ITag.FAIL;
return isInBounds( offset, 1 ) ? buff[offset] : ITag.Fail;
} }
@Override @Override
public byte[] getBytes( int offset, int len ) public byte[] getBytes(int offset, int len) {
{
len = len >= 0 ? len : buff.length - offset; len = len >= 0 ? len : buff.length - offset;
if( ! isInBounds( offset, len ) ) if (!isInBounds(offset, len))
return null; return null;
byte[] data = new byte[len]; byte[] data = new byte[len];
System.arraycopy( buff, offset, data, 0, len ); System.arraycopy(buff, offset, data, 0, len);
return data; return data;
} }
} }

View file

@ -4,8 +4,10 @@
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Eidsness - Initial implementation
*/ */
package org.eclipse.cdt.internal.core.dom.ast.tag; package org.eclipse.cdt.internal.core.dom.ast.tag;
import java.util.HashMap; import java.util.HashMap;
@ -25,83 +27,75 @@ import org.eclipse.cdt.internal.core.pdom.tag.PDOMTaggable;
import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
public class TagManager public class TagManager {
{ private static final String EXTENSION_POINT = "tagger"; //$NON-NLS-1$
private static TagManager INSTANCE; private static TagManager INSTANCE;
private Map<String, TaggerDescriptor> taggers; private Map<String, TaggerDescriptor> taggers;
public static TagManager getInstance() public static TagManager getInstance() {
{ if (INSTANCE == null)
if( INSTANCE == null )
INSTANCE = new TagManager(); INSTANCE = new TagManager();
return INSTANCE; return INSTANCE;
} }
private TagManager() private TagManager() {
{
taggers = loadExtensions(); taggers = loadExtensions();
} }
private static final String ExtensionPoint = "tagger"; //$NON-NLS-1$ private static Map<String, TaggerDescriptor> loadExtensions() {
private static Map<String, TaggerDescriptor> loadExtensions()
{
Map<String, TaggerDescriptor> taggers = new HashMap<String, TaggerDescriptor>(); Map<String, TaggerDescriptor> taggers = new HashMap<String, TaggerDescriptor>();
// load the extensions // Load the extensions
IConfigurationElement[] elements IConfigurationElement[] elements = Platform.getExtensionRegistry()
= Platform.getExtensionRegistry().getConfigurationElementsFor( CCorePlugin.PLUGIN_ID, ExtensionPoint ); .getConfigurationElementsFor(CCorePlugin.PLUGIN_ID, EXTENSION_POINT);
for (IConfigurationElement element : elements) for (IConfigurationElement element : elements) {
{ TaggerDescriptor desc = new TaggerDescriptor(element);
TaggerDescriptor desc = new TaggerDescriptor( element ); taggers.put(desc.getId(), desc);
taggers.put( desc.getId(), desc );
} }
return taggers; return taggers;
} }
/** Provide an opportunity for the specified tagger to process the given values. The tagger will only /**
* run if its enablement expression returns true for the arguments. */ * Provides an opportunity for the specified tagger to process the given values. The tagger will
public ITag process( String taggerId, ITagWriter tagWriter, IBinding binding, IASTName ast ) * only run if its enablement expression returns true for the arguments.
{ */
TaggerDescriptor desc = taggers.get( taggerId ); public ITag process(String taggerId, ITagWriter tagWriter, IBinding binding, IASTName ast) {
if( desc == null ) TaggerDescriptor desc = taggers.get(taggerId);
if (desc == null)
return null; return null;
IBindingTagger tagger = desc.getBindingTaggerFor( binding, ast ); IBindingTagger tagger = desc.getBindingTaggerFor(binding, ast);
return tagger == null ? null : tagger.process( tagWriter, binding, ast ); return tagger == null ? null : tagger.process(tagWriter, binding, ast);
} }
/** Provide an opportunity for all enabled taggers to process the given values. */ /** Provides an opportunity for all enabled taggers to process the given values. */
public Iterable<ITag> process( ITagWriter tagWriter, IBinding binding, IASTName ast ) public Iterable<ITag> process(ITagWriter tagWriter, IBinding binding, IASTName ast) {
{
List<ITag> tags = new LinkedList<ITag>(); List<ITag> tags = new LinkedList<ITag>();
for( TaggerDescriptor desc : taggers.values() ) for (TaggerDescriptor desc : taggers.values()) {
{ IBindingTagger tagger = desc.getBindingTaggerFor(binding, ast);
IBindingTagger tagger = desc.getBindingTaggerFor( binding, ast ); if (tagger != null) {
if( tagger != null ) ITag tag = tagger.process(tagWriter, binding, ast);
{ if (tag != null)
ITag tag = tagger.process( tagWriter, binding, ast ); tags.add(tag);
if( tag != null )
tags.add( tag );
} }
} }
return tags; return tags;
} }
/** Add or remove tags from the destination to ensure that it has the same tag information as the source. */ /** Adds or removes tags from the destination to ensure that it has the same tag information as the source. */
public void syncTags( IPDOMBinding dst, IBinding src ) public void syncTags(IPDOMBinding dst, IBinding src) {
{ // don't try to copy any tags when there are no contributors to this extension point
if( dst == null ) if (dst == null || taggers.isEmpty())
return; return;
ITagReader tagReader = CCorePlugin.getTagService().findTagReader( src ); ITagReader tagReader = CCorePlugin.getTagService().findTagReader(src);
if( tagReader == null ) if (tagReader == null)
return; return;
ITagWriter tagWriter = new PDOMTaggable( dst.getPDOM(), dst.getRecord() ); ITagWriter tagWriter = new PDOMTaggable(dst.getPDOM(), dst.getRecord());
tagWriter.setTags( tagReader.getTags() ); tagWriter.setTags(tagReader.getTags());
} }
} }

View file

@ -4,32 +4,33 @@
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Eidsness - Initial implementation
*/ */
package org.eclipse.cdt.internal.core.dom.ast.tag; package org.eclipse.cdt.internal.core.dom.ast.tag;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.tag.ITagReader; import org.eclipse.cdt.core.dom.ast.tag.ITagReader;
import org.eclipse.cdt.core.dom.ast.tag.ITagService; import org.eclipse.cdt.core.dom.ast.tag.ITagService;
public class TagService implements ITagService public class TagService implements ITagService {
{
/** /**
* First gives the IBinding instance a chance to convert itself, by calling IAdaptable#getAdapter( ITagReader.class ) * First gives the IBinding instance a chance to convert itself, by calling
* on the binding. If the binding doesn't provide an implementation then a simple, in-memory, non-cached * IAdaptable#getAdapter(ITagReader.class) on the binding. If the binding doesn't provide
* implementation is created and returned. * an implementation then a simple, in-memory, non-cached implementation is created and
* returned.
*/ */
@Override @Override
public ITagReader findTagReader( IBinding binding ) public ITagReader findTagReader(IBinding binding) {
{ if (binding == null)
if( binding == null )
return null; return null;
// let the binding adapt to its own tag reader // Let the binding adapt to its own tag reader
ITagReader tagReader = (ITagReader)binding.getAdapter( ITagReader.class ); ITagReader tagReader = (ITagReader) binding.getAdapter(ITagReader.class);
if( tagReader != null ) if (tagReader != null)
return tagReader; return tagReader;
return new NonCachedTaggable( binding ); return new NonCachedTaggable(binding);
} }
} }

View file

@ -4,8 +4,10 @@
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Eidsness - Initial implementation
*/ */
package org.eclipse.cdt.internal.core.dom.ast.tag; package org.eclipse.cdt.internal.core.dom.ast.tag;
import java.util.Arrays; import java.util.Arrays;
@ -30,12 +32,12 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IConfigurationElement;
/** /**
* Internal container for extensions of org.eclipse.cdt.core.tagger. The implementation of the * Internal container for extensions of org.eclipse.cdt.core.tagger. The implementation of
* tagger is instantiated only after checking the enablement expression (if present) for the * the tagger is instantiated only after checking the enablement expression (if present) for
* specified binding. This avoids activating the contributing plugin until it is actually needed. * the specified binding. This avoids activating the contributing plugin until it is actually
* needed.
*/ */
public class TaggerDescriptor public class TaggerDescriptor {
{
private static final String Attr_LocalId = "local-id"; //$NON-NLS-1$ private static final String Attr_LocalId = "local-id"; //$NON-NLS-1$
private static final String Attr_Class = "class"; //$NON-NLS-1$ private static final String Attr_Class = "class"; //$NON-NLS-1$
@ -46,22 +48,25 @@ public class TaggerDescriptor
private String id; private String id;
private IBindingTagger tagger; private IBindingTagger tagger;
private static final String Var_projectNature = "projectNatures"; //$NON-NLS-1$ private static final String VAR_PROJECTNATURES = "projectNatures"; //$NON-NLS-1$
private static final String Var_languageId = "languageId"; //$NON-NLS-1$ private static final String VAR_LANGUAGEID = "languageId"; //$NON-NLS-1$
/** An empty implementation of the tagger used as a placeholder in descriptors that are unable to /**
* load the contributed class. */ * An empty implementation of the tagger used as a placeholder in descriptors that are unable
private static final IBindingTagger NullTagger = new IBindingTagger() * to load the contributed class.
{ */
@Override public ITag process(ITagWriter tagWriter, IBinding binding, IASTName ast) { return null; } private static final IBindingTagger NULL_TAGGER = new IBindingTagger() {
@Override
public ITag process(ITagWriter tagWriter, IBinding binding, IASTName ast) {
return null;
}
}; };
public TaggerDescriptor( IConfigurationElement element ) public TaggerDescriptor(IConfigurationElement element) {
{
this.element = element; this.element = element;
Expression expr = null; Expression expr = null;
IConfigurationElement[] children = element.getChildren( ExpressionTagNames.ENABLEMENT ); IConfigurationElement[] children = element.getChildren(ExpressionTagNames.ENABLEMENT);
switch (children.length) { switch (children.length) {
case 0: case 0:
fStatus = Boolean.TRUE; fStatus = Boolean.TRUE;
@ -69,114 +74,104 @@ public class TaggerDescriptor
case 1: case 1:
try { try {
ExpressionConverter parser = ExpressionConverter.getDefault(); ExpressionConverter parser = ExpressionConverter.getDefault();
expr = parser.perform( children[0] ); expr = parser.perform(children[0]);
} catch (CoreException e) { } catch (CoreException e) {
CCorePlugin.log( "Error in enablement expression of " + id, e ); //$NON-NLS-1$ CCorePlugin.log("Error in enablement expression of " + id, e); //$NON-NLS-1$
} }
break; break;
default: default:
CCorePlugin.log( "Too many enablement expressions for " + id ); //$NON-NLS-1$ CCorePlugin.log("Too many enablement expressions for " + id); //$NON-NLS-1$
fStatus = Boolean.FALSE; fStatus = Boolean.FALSE;
break; break;
} }
enablementExpression = expr; enablementExpression = expr;
} }
public String getId() public String getId() {
{ if (id != null)
if( id != null )
return id; return id;
String globalId = element.getContributor().getName(); String globalId = element.getContributor().getName();
String localId = element.getAttribute( Attr_LocalId ); String localId = element.getAttribute(Attr_LocalId);
// there must be a valid local id // there must be a valid local id
if( localId == null ) if (localId == null) {
{
String extId = element.getDeclaringExtension().getSimpleIdentifier(); String extId = element.getDeclaringExtension().getSimpleIdentifier();
CCorePlugin.log( "Invalid extension " + globalId + '.' + extId + " must provide tagger's local-id" ); //$NON-NLS-1$ //$NON-NLS-2$ CCorePlugin.log("Invalid extension " + globalId + '.' + extId //$NON-NLS-1$
+ " must provide tagger's local-id"); //$NON-NLS-1$
return null; return null;
} }
// the extension should not include the plugin id, but return immediately if it does // the extension should not include the plugin id, but return immediately if it does
if( localId.startsWith( globalId ) if (localId.startsWith(globalId) && localId.length() > globalId.length())
&& localId.length() > globalId.length() )
return localId; return localId;
// make sure the local id has real content // make sure the local id has real content
if( localId.isEmpty() ) if (localId.isEmpty()) {
{
String extId = element.getDeclaringExtension().getSimpleIdentifier(); String extId = element.getDeclaringExtension().getSimpleIdentifier();
CCorePlugin.log( "Invalid extension " + globalId + '.' + extId + " must provide value for tagger's local-id" ); //$NON-NLS-1$ //$NON-NLS-2$ CCorePlugin.log("Invalid extension " + globalId + '.' + extId //$NON-NLS-1$
+ " must provide value for tagger's local-id"); //$NON-NLS-1$
return null; return null;
} }
// otherwise prepend with the globalId, and ensure a dot between them // otherwise prepend with the globalId, and ensure a dot between them
if( localId.charAt( 0 ) == '.' ) if (localId.charAt(0) == '.')
return globalId + localId; return globalId + localId;
return globalId + '.' + localId; return globalId + '.' + localId;
} }
private boolean matches( ITranslationUnit tu ) private boolean matches(ITranslationUnit tu) {
{ // If the enablement expression is missing or structurally invalid, then return immediately
// if the enablement expression is missing or structurally invalid, then return immediately if (fStatus != null)
if( fStatus != null )
return fStatus.booleanValue(); return fStatus.booleanValue();
// if there is no tu, then the enablement expression cannot be evaluated, assume that all taggers // If there is no tu, then the enablement expression cannot be evaluated, assume that all
// are needed // taggers are needed
if( tu == null ) if (tu == null)
return true; return true;
if( enablementExpression != null ) if (enablementExpression != null)
try try {
{
IProject project = null; IProject project = null;
ICProject cProject = tu.getCProject(); ICProject cProject = tu.getCProject();
if( cProject != null ) if (cProject != null)
project = cProject.getProject(); project = cProject.getProject();
EvaluationContext evalContext = new EvaluationContext( null, project ); EvaluationContext evalContext = new EvaluationContext(null, project);
// if the project is not accessible, then only taggers that don't care about it will // if the project is not accessible, then only taggers that don't care about it will
// get a chance to run // get a chance to run
if( project != null ) if (project != null) {
{
String[] natures = project.getDescription().getNatureIds(); String[] natures = project.getDescription().getNatureIds();
evalContext.addVariable( Var_projectNature, Arrays.asList( natures ) ); evalContext.addVariable(VAR_PROJECTNATURES, Arrays.asList(natures));
} }
ILanguage language = tu.getLanguage(); ILanguage language = tu.getLanguage();
if( language != null ) if (language != null)
evalContext.addVariable( Var_languageId, language.getId() ); evalContext.addVariable(VAR_LANGUAGEID, language.getId());
return enablementExpression.evaluate( evalContext ) == EvaluationResult.TRUE; return enablementExpression.evaluate(evalContext) == EvaluationResult.TRUE;
} } catch (CoreException e) {
catch( CoreException e ) CCorePlugin.log("Error while evaluating enablement expression for " + id, e); //$NON-NLS-1$
{
CCorePlugin.log( "Error while evaluating enablement expression for " + id, e ); //$NON-NLS-1$
} }
fStatus = Boolean.FALSE; fStatus = Boolean.FALSE;
return false; return false;
} }
private IBindingTagger getTagger() private IBindingTagger getTagger() {
{ if (tagger == null)
if( tagger == null ) synchronized (this) {
synchronized( this ) if (tagger == null) {
{ try {
if( tagger == null ) tagger = (IBindingTagger) element.createExecutableExtension(Attr_Class);
{ } catch (CoreException e) {
try { tagger = (IBindingTagger)element.createExecutableExtension( Attr_Class ); }
catch( CoreException e )
{
String id = element.getDeclaringExtension().getNamespaceIdentifier() + '.' String id = element.getDeclaringExtension().getNamespaceIdentifier() + '.'
+ element.getDeclaringExtension().getSimpleIdentifier(); + element.getDeclaringExtension().getSimpleIdentifier();
CCorePlugin.log( "Error in class attribute of " + id, e ); //$NON-NLS-1$ CCorePlugin.log("Error in class attribute of " + id, e); //$NON-NLS-1$
// mark the tagger with an empty implementation to prevent future load attempts // mark the tagger with an empty implementation to prevent future load attempts
tagger = NullTagger; tagger = NULL_TAGGER;
} }
} }
} }
@ -185,18 +180,17 @@ public class TaggerDescriptor
} }
// Activates the plugin if needed. // Activates the plugin if needed.
public IBindingTagger getBindingTaggerFor( IBinding binding, IASTName ast ) public IBindingTagger getBindingTaggerFor(IBinding binding, IASTName ast) {
{
// If there isn't an ast with an AST-TU accessible, then there is no way to defer processing, // If there isn't an ast with an AST-TU accessible, then there is no way to defer processing,
// just return the tagger and let it try to sort things out. E.g., this happens for built-in // just return the tagger and let it try to sort things out. E.g., this happens for built-in
// things. // things.
if( ast == null ) if (ast == null)
return getTagger(); return getTagger();
IASTTranslationUnit astTU = ast.getTranslationUnit(); IASTTranslationUnit astTU = ast.getTranslationUnit();
if( astTU == null ) if (astTU == null)
return getTagger(); return getTagger();
// Otherwise evaluate the enablement expression for this TU // Otherwise evaluate the enablement expression for this TU
return matches( astTU.getOriginatingTranslationUnit() ) ? getTagger() : null; return matches(astTU.getOriginatingTranslationUnit()) ? getTagger() : null;
} }
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2009, 2012 Wind River Systems, Inc. and others. * Copyright (c) 2009, 2013 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -9,6 +9,7 @@
* Markus Schorn - initial API and implementation * Markus Schorn - initial API and implementation
* Thomas Corbat * Thomas Corbat
* Sergey Prigogin (Google) * Sergey Prigogin (Google)
* Nathan Ridge
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser; package org.eclipse.cdt.internal.core.dom.parser;
@ -22,45 +23,56 @@ import org.eclipse.core.runtime.CoreException;
* Buffer for marshalling and unmarshalling types. * Buffer for marshalling and unmarshalling types.
*/ */
public interface ITypeMarshalBuffer { public interface ITypeMarshalBuffer {
final static byte BASIC_TYPE= 1; final static byte BASIC_TYPE = 0x01;
final static byte POINTER_TYPE= 2; final static byte POINTER_TYPE = 0x02;
final static byte ARRAY_TYPE= 3; final static byte ARRAY_TYPE = 0x03;
final static byte CVQUALIFIER_TYPE= 4; final static byte CVQUALIFIER_TYPE = 0x04;
final static byte FUNCTION_TYPE= 5; final static byte FUNCTION_TYPE = 0x05;
final static byte REFERENCE_TYPE= 6; final static byte REFERENCE_TYPE = 0x06;
final static byte POINTER_TO_MEMBER_TYPE= 7; final static byte POINTER_TO_MEMBER_TYPE = 0x07;
final static byte PACK_EXPANSION_TYPE= 8; final static byte PACK_EXPANSION_TYPE = 0x08;
final static byte PROBLEM_TYPE= 9; final static byte PROBLEM_TYPE = 0x09;
final static byte VALUE= 10; final static byte VALUE = 0x0A;
final static byte DEPENDENT_EXPRESSION_TYPE= 11; final static byte DEPENDENT_EXPRESSION_TYPE = 0x0B;
final static byte UNKNOWN_MEMBER= 12; final static byte UNKNOWN_MEMBER = 0x0C;
final static byte UNKNOWN_MEMBER_CLASS_INSTANCE= 13; final static byte UNKNOWN_MEMBER_CLASS_INSTANCE = 0x0D;
final static byte DEFERRED_CLASS_INSTANCE= 14; final static byte DEFERRED_CLASS_INSTANCE = 0x0E;
final static byte ALIAS_TEMPLATE = 15; final static byte ALIAS_TEMPLATE = 0x0F;
// Can add more types up to 0x1C, after that it will collide with TypeMarshalBuffer.UNSTORABLE_TYPE.
final static byte final static byte
EVAL_BINARY= 1, EVAL_BINARY = 0x01,
EVAL_BINARY_TYPE_ID = 2, EVAL_BINARY_TYPE_ID = 0x02,
EVAL_BINDING = 3, EVAL_BINDING = 0x03,
EVAL_COMMA = 4, EVAL_COMMA = 0x04,
EVAL_COMPOUND = 5, EVAL_COMPOUND = 0x05,
EVAL_CONDITIONAL = 6, EVAL_CONDITIONAL = 0x06,
EVAL_FIXED= 7, EVAL_FIXED = 0x07,
EVAL_FUNCTION_CALL= 8, EVAL_FUNCTION_CALL = 0x08,
EVAL_FUNCTION_SET= 9, EVAL_FUNCTION_SET = 0x09,
EVAL_ID= 10, EVAL_ID = 0x0A,
EVAL_INIT_LIST= 11, EVAL_INIT_LIST = 0x0B,
EVAL_MEMBER_ACCESS= 12, EVAL_MEMBER_ACCESS = 0x0C,
EVAL_TYPE_ID= 13, EVAL_PARAMETER_PACK = 0x0D,
EVAL_UNARY= 14, EVAL_TYPE_ID = 0x0E,
EVAL_UNARY_TYPE_ID = 15; EVAL_UNARY = 0x0F,
EVAL_UNARY_TYPE_ID = 0x10;
// Can add more evaluations up to 0x1C, after that it will collide with TypeMarshalBuffer.UNSTORABLE_TYPE.
static final byte KIND_MASK= 15; static final short KIND_MASK = 0x001F;
final static int FLAG1 = 0x10; final static short FIRST_FLAG = 0x0020;
final static int FLAG2 = 0x20;
final static int FLAG3 = 0x40; final static short FLAG1 = 0x0020;
final static int FLAG4 = 0x80; final static short FLAG2 = 0x0040;
final static short FLAG3 = 0x0080;
final static short FLAG4 = 0x0100;
final static short FLAG5 = 0x0200;
final static short FLAG6 = 0x0400;
final static short FLAG7 = 0x0800;
// Can add more flags up to LAST_FLAG.
final static short LAST_FLAG = 0x2000;
CoreException unmarshallingError(); CoreException unmarshallingError();
@ -72,6 +84,11 @@ public interface ITypeMarshalBuffer {
int getByte() throws CoreException; int getByte() throws CoreException;
int getFixedInt() throws CoreException; int getFixedInt() throws CoreException;
/**
* Reads a 16-bit integer stored in the variable length base-128 encoding.
*/
public short getShort() throws CoreException;
/** /**
* Reads a 32-bit integer stored in the variable length base-128 encoding. * Reads a 32-bit integer stored in the variable length base-128 encoding.
*/ */
@ -92,6 +109,12 @@ public interface ITypeMarshalBuffer {
void putByte(byte data); void putByte(byte data);
void putFixedInt(int data); void putFixedInt(int data);
/**
* Writes a 16-bit integer in the variable length base-128 encoding.
* @param value the value to write
*/
public void putShort(short value);
/** /**
* Writes a 32-bit integer in the variable length base-128 encoding. Each byte, except the last * Writes a 32-bit integer in the variable length base-128 encoding. Each byte, except the last
* byte, has the most significant bit set this indicates that there are further bytes to come. * byte, has the most significant bit set this indicates that there are further bytes to come.

View file

@ -28,11 +28,11 @@ public class ProblemFunctionType extends ProblemType implements ICPPFunctionType
@Override @Override
public void marshal(ITypeMarshalBuffer buffer) throws CoreException { public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
buffer.putByte((byte) (ITypeMarshalBuffer.PROBLEM_TYPE | ITypeMarshalBuffer.FLAG1)); buffer.putShort((short) (ITypeMarshalBuffer.PROBLEM_TYPE | ITypeMarshalBuffer.FLAG1));
buffer.putInt(getID()); buffer.putInt(getID());
} }
public static IType unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException { public static IType unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
return new ProblemFunctionType(buffer.getInt()); return new ProblemFunctionType(buffer.getInt());
} }

View file

@ -56,13 +56,13 @@ public class ProblemType implements IProblemType, ISerializableType {
@Override @Override
public void marshal(ITypeMarshalBuffer buffer) throws CoreException { public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
buffer.putByte(ITypeMarshalBuffer.PROBLEM_TYPE); buffer.putShort(ITypeMarshalBuffer.PROBLEM_TYPE);
buffer.putInt(getID()); buffer.putInt(getID());
} }
public static IType unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException { public static IType unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
if ((firstByte & ITypeMarshalBuffer.FLAG1) != 0) if ((firstBytes & ITypeMarshalBuffer.FLAG1) != 0)
return ProblemFunctionType.unmarshal(firstByte, buffer); return ProblemFunctionType.unmarshal(firstBytes, buffer);
return new ProblemType(buffer.getInt()); return new ProblemType(buffer.getInt());
} }

View file

@ -154,41 +154,41 @@ public class Value implements IValue {
return IBinding.EMPTY_BINDING_ARRAY; return IBinding.EMPTY_BINDING_ARRAY;
} }
public void marshall(ITypeMarshalBuffer buf) throws CoreException { public void marshal(ITypeMarshalBuffer buf) throws CoreException {
if (UNKNOWN == this) { if (UNKNOWN == this) {
buf.putByte((byte) (ITypeMarshalBuffer.VALUE | ITypeMarshalBuffer.FLAG1)); buf.putShort((short) (ITypeMarshalBuffer.VALUE | ITypeMarshalBuffer.FLAG1));
} else { } else {
Long num= numericalValue(); Long num= numericalValue();
if (num != null) { if (num != null) {
long lv= num; long lv= num;
if (lv >= 0) { if (lv >= 0) {
buf.putByte((byte) (ITypeMarshalBuffer.VALUE | ITypeMarshalBuffer.FLAG2)); buf.putShort((short) (ITypeMarshalBuffer.VALUE | ITypeMarshalBuffer.FLAG2));
buf.putLong(lv); buf.putLong(lv);
} else { } else {
buf.putByte((byte) (ITypeMarshalBuffer.VALUE | ITypeMarshalBuffer.FLAG3)); buf.putShort((short) (ITypeMarshalBuffer.VALUE | ITypeMarshalBuffer.FLAG3));
buf.putLong(-lv); buf.putLong(-lv);
} }
} else if (fFixedValue != null) { } else if (fFixedValue != null) {
buf.putByte((byte) (ITypeMarshalBuffer.VALUE | ITypeMarshalBuffer.FLAG4)); buf.putShort((short) (ITypeMarshalBuffer.VALUE | ITypeMarshalBuffer.FLAG4));
buf.putCharArray(fFixedValue); buf.putCharArray(fFixedValue);
} else { } else {
buf.putByte((ITypeMarshalBuffer.VALUE)); buf.putShort(ITypeMarshalBuffer.VALUE);
fEvaluation.marshal(buf, true); fEvaluation.marshal(buf, true);
} }
} }
} }
public static IValue unmarshal(ITypeMarshalBuffer buf) throws CoreException { public static IValue unmarshal(ITypeMarshalBuffer buf) throws CoreException {
int firstByte= buf.getByte(); short firstBytes= buf.getShort();
if (firstByte == TypeMarshalBuffer.NULL_TYPE) if (firstBytes == TypeMarshalBuffer.NULL_TYPE)
return null; return null;
if ((firstByte & ITypeMarshalBuffer.FLAG1) != 0) if ((firstBytes & ITypeMarshalBuffer.FLAG1) != 0)
return Value.UNKNOWN; return Value.UNKNOWN;
if ((firstByte & ITypeMarshalBuffer.FLAG2) != 0) if ((firstBytes & ITypeMarshalBuffer.FLAG2) != 0)
return Value.create(buf.getLong()); return Value.create(buf.getLong());
if ((firstByte & ITypeMarshalBuffer.FLAG3) != 0) if ((firstBytes & ITypeMarshalBuffer.FLAG3) != 0)
return Value.create(-buf.getLong()); return Value.create(-buf.getLong());
if ((firstByte & ITypeMarshalBuffer.FLAG4) != 0) if ((firstBytes & ITypeMarshalBuffer.FLAG4) != 0)
return new Value(buf.getCharArray(), null); return new Value(buf.getCharArray(), null);
ISerializableEvaluation eval= buf.unmarshalEvaluation(); ISerializableEvaluation eval= buf.unmarshalEvaluation();
@ -280,6 +280,8 @@ public class Value implements IValue {
} }
public static IValue incrementedValue(IValue value, int increment) { public static IValue incrementedValue(IValue value, int increment) {
if (value == UNKNOWN)
return UNKNOWN;
Long val = value.numericalValue(); Long val = value.numericalValue();
if (val != null) { if (val != null) {
return create(val.longValue() + increment); return create(val.longValue() + increment);

View file

@ -160,35 +160,28 @@ public class CArrayType implements ICArrayType, ITypeContainer, ISerializableTyp
@Override @Override
public void marshal(ITypeMarshalBuffer buffer) throws CoreException { public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
int firstByte= ITypeMarshalBuffer.ARRAY_TYPE; short firstBytes = ITypeMarshalBuffer.ARRAY_TYPE;
int flags= 0;
long nval= -1; long nval= -1;
IValue val= null; IValue val= null;
if (isConst()) flags |= 0x01; if (isConst()) firstBytes |= ITypeMarshalBuffer.FLAG1;
if (isVolatile()) flags |= 0x02; if (isVolatile()) firstBytes |= ITypeMarshalBuffer.FLAG2;
if (isRestrict()) flags |= 0x04; if (isRestrict()) firstBytes |= ITypeMarshalBuffer.FLAG3;
if (isStatic()) flags |= 0x08; if (isStatic()) firstBytes |= ITypeMarshalBuffer.FLAG4;
if (isVariableLength()) flags |= 0x10; if (isVariableLength()) firstBytes |= ITypeMarshalBuffer.FLAG5;
if (flags != 0) {
firstByte |= ITypeMarshalBuffer.FLAG1;
}
val= getSize(); val= getSize();
if (val != null) { if (val != null) {
firstByte |= ITypeMarshalBuffer.FLAG2; firstBytes |= ITypeMarshalBuffer.FLAG6;
Long num= val.numericalValue(); Long num= val.numericalValue();
if (num != null) { if (num != null) {
nval= num; nval= num;
if (nval >= 0) { if (nval >= 0) {
firstByte |= ITypeMarshalBuffer.FLAG3; firstBytes |= ITypeMarshalBuffer.FLAG7;
} }
} }
} }
buffer.putByte((byte) firstByte); buffer.putShort(firstBytes);
if (flags != 0) {
buffer.putByte((byte) flags);
}
if (nval >= 0) { if (nval >= 0) {
buffer.putLong(nval); buffer.putLong(nval);
} else if (val != null) { } else if (val != null) {
@ -197,21 +190,20 @@ public class CArrayType implements ICArrayType, ITypeContainer, ISerializableTyp
buffer.marshalType(getType()); buffer.marshalType(getType());
} }
public static IType unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException { public static IType unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
int flags= 0;
IValue value= null; IValue value= null;
if ((firstByte & ITypeMarshalBuffer.FLAG1) != 0) { if ((firstBytes & ITypeMarshalBuffer.FLAG7) != 0) {
flags= buffer.getByte();
}
if ((firstByte & ITypeMarshalBuffer.FLAG3) != 0) {
value = Value.create(buffer.getLong()); value = Value.create(buffer.getLong());
} else if ((firstByte & ITypeMarshalBuffer.FLAG2) != 0) { } else if ((firstBytes & ITypeMarshalBuffer.FLAG6) != 0) {
value = buffer.unmarshalValue(); value = buffer.unmarshalValue();
} }
IType nested= buffer.unmarshalType(); IType nested= buffer.unmarshalType();
CArrayType result= new CArrayType(nested, (flags & 0x01) != 0, (flags & 0x02) != 0, (flags & 0x04) != 0, value); CArrayType result= new CArrayType(nested,
result.setIsStatic((flags & 0x08) != 0); (firstBytes & ITypeMarshalBuffer.FLAG1) != 0,
result.setIsVariableLength((flags & 0x10) != 0); (firstBytes & ITypeMarshalBuffer.FLAG2) != 0,
(firstBytes & ITypeMarshalBuffer.FLAG3) != 0, value);
result.setIsStatic((firstBytes & ITypeMarshalBuffer.FLAG4) != 0);
result.setIsVariableLength((firstBytes & ITypeMarshalBuffer.FLAG5) != 0);
return result; return result;
} }

View file

@ -60,6 +60,7 @@ public class CBasicType implements ICBasicType, ISerializableType {
} }
private static Kind getKind(ICASTSimpleDeclSpecifier sds) { private static Kind getKind(ICASTSimpleDeclSpecifier sds) {
// Note: when adding a new kind, marshal() and unnmarshal() may need to be revised.
switch (sds.getType()) { switch (sds.getType()) {
case IASTSimpleDeclSpecifier.t_bool: case IASTSimpleDeclSpecifier.t_bool:
return Kind.eBoolean; return Kind.eBoolean;
@ -170,25 +171,21 @@ public class CBasicType implements ICBasicType, ISerializableType {
@Override @Override
public void marshal(ITypeMarshalBuffer buffer) throws CoreException { public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
final int kind= getKind().ordinal(); final int kind= getKind().ordinal();
final int shiftedKind= kind * ITypeMarshalBuffer.FLAG1; final int shiftedKind= kind * ITypeMarshalBuffer.FIRST_FLAG;
final int modifiers= getModifiers(); final int modifiers= getModifiers();
if (shiftedKind < ITypeMarshalBuffer.FLAG4 && modifiers == 0) { if (modifiers == 0) {
buffer.putByte((byte) (ITypeMarshalBuffer.BASIC_TYPE | shiftedKind)); buffer.putShort((short) (ITypeMarshalBuffer.BASIC_TYPE | shiftedKind));
} else { } else {
buffer.putByte((byte) (ITypeMarshalBuffer.BASIC_TYPE | ITypeMarshalBuffer.FLAG4)); buffer.putShort((short) (ITypeMarshalBuffer.BASIC_TYPE | shiftedKind | ITypeMarshalBuffer.LAST_FLAG));
buffer.putByte((byte) kind);
buffer.putByte((byte) modifiers); buffer.putByte((byte) modifiers);
} }
} }
public static IType unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException { public static IType unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
final boolean dense= (firstByte & ITypeMarshalBuffer.FLAG4) == 0; final boolean haveModifiers= (firstBytes & ITypeMarshalBuffer.LAST_FLAG) != 0;
int modifiers= 0; int modifiers= 0;
int kind; int kind= (firstBytes & (ITypeMarshalBuffer.LAST_FLAG-1))/ITypeMarshalBuffer.FIRST_FLAG;
if (dense) { if (haveModifiers) {
kind= (firstByte & (ITypeMarshalBuffer.FLAG4-1))/ITypeMarshalBuffer.FLAG1;
} else {
kind= buffer.getByte();
modifiers= buffer.getByte(); modifiers= buffer.getByte();
} }
return new CBasicType(Kind.values()[kind], modifiers); return new CBasicType(Kind.values()[kind], modifiers);

View file

@ -78,16 +78,16 @@ public class CFunctionType implements IFunctionType, ISerializableType {
@Override @Override
public void marshal(ITypeMarshalBuffer buffer) throws CoreException { public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
int firstByte= ITypeMarshalBuffer.FUNCTION_TYPE; short firstBytes = ITypeMarshalBuffer.FUNCTION_TYPE;
int len= parameters.length & 0xffff; int len= parameters.length & 0xffff;
int codedLen= len * ITypeMarshalBuffer.FLAG1; int codedLen= len * ITypeMarshalBuffer.FIRST_FLAG;
if (codedLen < ITypeMarshalBuffer.FLAG4) { if (codedLen < ITypeMarshalBuffer.LAST_FLAG) {
firstByte |= codedLen; firstBytes |= codedLen;
buffer.putByte((byte) firstByte); buffer.putShort(firstBytes);
} else { } else {
firstByte |= ITypeMarshalBuffer.FLAG4; firstBytes |= ITypeMarshalBuffer.LAST_FLAG;
buffer.putByte((byte) firstByte); buffer.putShort(firstBytes);
buffer.putInt(len); buffer.putInt(len);
} }
@ -97,12 +97,12 @@ public class CFunctionType implements IFunctionType, ISerializableType {
} }
} }
public static IType unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException { public static IType unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
int len; int len;
if (((firstByte & ITypeMarshalBuffer.FLAG4) != 0)) { if (((firstBytes & ITypeMarshalBuffer.LAST_FLAG) != 0)) {
len= buffer.getInt(); len= buffer.getInt();
} else { } else {
len= (firstByte & (ITypeMarshalBuffer.FLAG4-1))/ITypeMarshalBuffer.FLAG1; len= (firstBytes & (ITypeMarshalBuffer.LAST_FLAG-1))/ITypeMarshalBuffer.FIRST_FLAG;
} }
IType rt= buffer.unmarshalType(); IType rt= buffer.unmarshalType();
IType[] pars= new IType[len]; IType[] pars= new IType[len];

View file

@ -94,17 +94,17 @@ public class CPointerType implements ICPointerType, ITypeContainer, ISerializabl
@Override @Override
public void marshal(ITypeMarshalBuffer buffer) throws CoreException { public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
int firstByte= ITypeMarshalBuffer.POINTER_TYPE; short firstBytes = ITypeMarshalBuffer.POINTER_TYPE;
if (isConst()) firstByte |= ITypeMarshalBuffer.FLAG1; if (isConst()) firstBytes |= ITypeMarshalBuffer.FLAG1;
if (isVolatile()) firstByte |= ITypeMarshalBuffer.FLAG2; if (isVolatile()) firstBytes |= ITypeMarshalBuffer.FLAG2;
if (isRestrict()) firstByte |= ITypeMarshalBuffer.FLAG3; if (isRestrict()) firstBytes |= ITypeMarshalBuffer.FLAG3;
buffer.putByte((byte) firstByte); buffer.putShort(firstBytes);
buffer.marshalType(getType()); buffer.marshalType(getType());
} }
public static IType unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException { public static IType unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
IType nested= buffer.unmarshalType(); IType nested= buffer.unmarshalType();
return new CPointerType(nested, firstByte/ITypeMarshalBuffer.FLAG1); return new CPointerType(nested, firstBytes/ITypeMarshalBuffer.FLAG1);
} }
@Override @Override

View file

@ -144,17 +144,17 @@ public class CQualifierType implements ICQualifierType, ITypeContainer, ISeriali
@Override @Override
public void marshal(ITypeMarshalBuffer buffer) throws CoreException { public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
int firstByte= ITypeMarshalBuffer.CVQUALIFIER_TYPE; short firstBytes= ITypeMarshalBuffer.CVQUALIFIER_TYPE;
if (isConst()) firstByte |= ITypeMarshalBuffer.FLAG1; if (isConst()) firstBytes |= ITypeMarshalBuffer.FLAG1;
if (isVolatile()) firstByte |= ITypeMarshalBuffer.FLAG2; if (isVolatile()) firstBytes |= ITypeMarshalBuffer.FLAG2;
if (isRestrict()) firstByte |= ITypeMarshalBuffer.FLAG3; if (isRestrict()) firstBytes |= ITypeMarshalBuffer.FLAG3;
buffer.putByte((byte) firstByte); buffer.putShort(firstBytes);
buffer.marshalType(getType()); buffer.marshalType(getType());
} }
public static IType unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException { public static IType unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
IType nested= buffer.unmarshalType(); IType nested= buffer.unmarshalType();
return new CQualifierType(nested, (firstByte & ITypeMarshalBuffer.FLAG1) != 0, return new CQualifierType(nested, (firstBytes & ITypeMarshalBuffer.FLAG1) != 0,
(firstByte & ITypeMarshalBuffer.FLAG2) != 0, (firstByte & ITypeMarshalBuffer.FLAG3) != 0); (firstBytes & ITypeMarshalBuffer.FLAG2) != 0, (firstBytes & ITypeMarshalBuffer.FLAG3) != 0);
} }
} }

View file

@ -11,8 +11,6 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.PRVALUE;
import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTNode;
@ -21,9 +19,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPackExpansionExpression; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPackExpansionExpression;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
import org.eclipse.cdt.internal.core.dom.parser.ProblemType; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalParameterPack;
import org.eclipse.cdt.internal.core.dom.parser.Value;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalFixed;
/** /**
* Implementation of pack expansion expression. * Implementation of pack expansion expression.
@ -70,13 +66,7 @@ public class CPPASTPackExpansionExpression extends ASTNode implements ICPPASTPac
@Override @Override
public ICPPEvaluation getEvaluation() { public ICPPEvaluation getEvaluation() {
if (fEvaluation == null) { if (fEvaluation == null) {
IType type = fPattern.getExpressionType(); fEvaluation = new EvalParameterPack(((ICPPASTExpression) fPattern).getEvaluation(), this);
if (type == null) {
type= ProblemType.UNKNOWN_FOR_EXPRESSION;
} else {
type= new CPPParameterPackType(type);
}
fEvaluation= new EvalFixed(type, PRVALUE, Value.create(((ICPPASTExpression) fPattern).getEvaluation()));
} }
return fEvaluation; return fEvaluation;
} }

View file

@ -111,14 +111,14 @@ public class CPPAliasTemplateInstance extends PlatformObject
@Override @Override
public void marshal(ITypeMarshalBuffer buffer) throws CoreException { public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
int firstByte = ITypeMarshalBuffer.ALIAS_TEMPLATE; short firstBytes = ITypeMarshalBuffer.ALIAS_TEMPLATE;
buffer.putByte((byte) firstByte); buffer.putShort(firstBytes);
buffer.putCharArray(name); buffer.putCharArray(name);
buffer.marshalType(aliasedType); buffer.marshalType(aliasedType);
buffer.marshalBinding(aliasTemplate); buffer.marshalBinding(aliasTemplate);
} }
public static IType unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException { public static IType unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
char[] name = buffer.getCharArray(); char[] name = buffer.getCharArray();
IType unmarshalledAliasedTypeInstance = buffer.unmarshalType(); IType unmarshalledAliasedTypeInstance = buffer.unmarshalType();
ICPPAliasTemplate unmarshalledAlias = (ICPPAliasTemplate)buffer.unmarshalBinding(); ICPPAliasTemplate unmarshalledAlias = (ICPPAliasTemplate)buffer.unmarshalBinding();

View file

@ -111,11 +111,11 @@ public class CPPArrayType implements IArrayType, ITypeContainer, ISerializableTy
@Override @Override
public void marshal(ITypeMarshalBuffer buffer) throws CoreException { public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
final byte firstByte = ITypeMarshalBuffer.ARRAY_TYPE; final short firstBytes = ITypeMarshalBuffer.ARRAY_TYPE;
IValue val= getSize(); IValue val= getSize();
if (val == null) { if (val == null) {
buffer.putByte(firstByte); buffer.putShort(firstBytes);
buffer.marshalType(getType()); buffer.marshalType(getType());
return; return;
} }
@ -124,22 +124,22 @@ public class CPPArrayType implements IArrayType, ITypeContainer, ISerializableTy
if (num != null) { if (num != null) {
long lnum= num; long lnum= num;
if (lnum >= 0) { if (lnum >= 0) {
buffer.putByte((byte) (firstByte | ITypeMarshalBuffer.FLAG1)); buffer.putShort((short) (firstBytes | ITypeMarshalBuffer.FLAG1));
buffer.putLong(lnum); buffer.putLong(lnum);
buffer.marshalType(getType()); buffer.marshalType(getType());
return; return;
} }
} }
buffer.putByte((byte) (firstByte | ITypeMarshalBuffer.FLAG2)); buffer.putShort((short) (firstBytes | ITypeMarshalBuffer.FLAG2));
buffer.marshalValue(val); buffer.marshalValue(val);
buffer.marshalType(getType()); buffer.marshalType(getType());
} }
public static IType unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException { public static IType unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
IValue value= null; IValue value= null;
if ((firstByte & ITypeMarshalBuffer.FLAG1) != 0) { if ((firstBytes & ITypeMarshalBuffer.FLAG1) != 0) {
value = Value.create(buffer.getLong()); value = Value.create(buffer.getLong());
} else if ((firstByte & ITypeMarshalBuffer.FLAG2) != 0) { } else if ((firstBytes & ITypeMarshalBuffer.FLAG2) != 0) {
value = buffer.unmarshalValue(); value = buffer.unmarshalValue();
} }
IType nested= buffer.unmarshalType(); IType nested= buffer.unmarshalType();

View file

@ -85,6 +85,7 @@ public class CPPBasicType implements ICPPBasicType, ISerializableType {
} }
static Kind getKind(final int simpleDeclSpecType) { static Kind getKind(final int simpleDeclSpecType) {
// Note: when adding a new kind, marshal() and unnmarshal() may need to be revised.
switch (simpleDeclSpecType) { switch (simpleDeclSpecType) {
case IASTSimpleDeclSpecifier.t_bool: case IASTSimpleDeclSpecifier.t_bool:
return Kind.eBoolean; return Kind.eBoolean;
@ -224,25 +225,21 @@ public class CPPBasicType implements ICPPBasicType, ISerializableType {
@Override @Override
public void marshal(ITypeMarshalBuffer buffer) throws CoreException { public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
final int kind= getKind().ordinal(); final int kind= getKind().ordinal();
final int shiftedKind= kind * ITypeMarshalBuffer.FLAG1; final int shiftedKind= kind * ITypeMarshalBuffer.FIRST_FLAG;
final int modifiers= getModifiers(); final int modifiers= getModifiers();
if (shiftedKind < ITypeMarshalBuffer.FLAG4 && modifiers == 0) { if (modifiers == 0) {
buffer.putByte((byte) (ITypeMarshalBuffer.BASIC_TYPE | shiftedKind)); buffer.putShort((short) (ITypeMarshalBuffer.BASIC_TYPE | shiftedKind));
} else { } else {
buffer.putByte((byte) (ITypeMarshalBuffer.BASIC_TYPE | ITypeMarshalBuffer.FLAG4)); buffer.putShort((short) (ITypeMarshalBuffer.BASIC_TYPE | shiftedKind | ITypeMarshalBuffer.LAST_FLAG));
buffer.putByte((byte) kind);
buffer.putByte((byte) modifiers); buffer.putByte((byte) modifiers);
} }
} }
public static IType unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException { public static IType unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
final boolean dense= (firstByte & ITypeMarshalBuffer.FLAG4) == 0; final boolean haveModifiers= (firstBytes & ITypeMarshalBuffer.LAST_FLAG) != 0;
int modifiers= 0; int modifiers= 0;
int kind; int kind= (firstBytes & (ITypeMarshalBuffer.LAST_FLAG - 1)) / ITypeMarshalBuffer.FIRST_FLAG;
if (dense) { if (haveModifiers) {
kind= (firstByte & (ITypeMarshalBuffer.FLAG4 - 1)) / ITypeMarshalBuffer.FLAG1;
} else {
kind= buffer.getByte();
modifiers= buffer.getByte(); modifiers= buffer.getByte();
} }
return new CPPBasicType(Kind.values()[kind], modifiers); return new CPPBasicType(Kind.values()[kind], modifiers);

View file

@ -117,10 +117,7 @@ public class CPPClassType extends PlatformObject implements ICPPInternalClassTyp
private ICPPClassType typeInIndex; private ICPPClassType typeInIndex;
public CPPClassType(IASTName name, IBinding indexBinding) { public CPPClassType(IASTName name, IBinding indexBinding) {
if (name instanceof ICPPASTQualifiedName) { name = stripQualifier(name);
IASTName[] ns = ((ICPPASTQualifiedName) name).getNames();
name = ns[ns.length - 1];
}
IASTNode parent = name.getParent(); IASTNode parent = name.getParent();
while (parent instanceof IASTName) while (parent instanceof IASTName)
parent = parent.getParent(); parent = parent.getParent();
@ -195,6 +192,7 @@ public class CPPClassType extends PlatformObject implements ICPPInternalClassTyp
@Override @Override
public IScope getScope() { public IScope getScope() {
IASTName name = definition != null ? definition : declarations[0]; IASTName name = definition != null ? definition : declarations[0];
name = stripQualifier(name);
IScope scope = CPPVisitor.getContainingScope(name); IScope scope = CPPVisitor.getContainingScope(name);
if (definition == null && name.getPropertyInParent() != ICPPASTQualifiedName.SEGMENT_NAME) { if (definition == null && name.getPropertyInParent() != ICPPASTQualifiedName.SEGMENT_NAME) {
@ -406,4 +404,12 @@ public class CPPClassType extends PlatformObject implements ICPPInternalClassTyp
} }
return false; return false;
} }
private IASTName stripQualifier(IASTName name) {
if (name instanceof ICPPASTQualifiedName) {
IASTName[] ns = ((ICPPASTQualifiedName)name).getNames();
name = ns[ ns.length - 1 ];
}
return name;
}
} }

View file

@ -227,8 +227,8 @@ public class CPPDeferredClassInstance extends CPPUnknownBinding implements ICPPD
@Override @Override
public void marshal(ITypeMarshalBuffer buffer) throws CoreException { public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
int firstByte= ITypeMarshalBuffer.DEFERRED_CLASS_INSTANCE; short firstBytes= ITypeMarshalBuffer.DEFERRED_CLASS_INSTANCE;
buffer.putByte((byte) firstByte); buffer.putShort(firstBytes);
buffer.marshalBinding(fClassTemplate); buffer.marshalBinding(fClassTemplate);
buffer.putInt(fArguments.length); buffer.putInt(fArguments.length);
for (ICPPTemplateArgument arg : fArguments) { for (ICPPTemplateArgument arg : fArguments) {
@ -236,7 +236,7 @@ public class CPPDeferredClassInstance extends CPPUnknownBinding implements ICPPD
} }
} }
public static ICPPDeferredClassInstance unmarshal(IIndexFragment fragment, int firstByte, public static ICPPDeferredClassInstance unmarshal(IIndexFragment fragment, short firstBytes,
ITypeMarshalBuffer buffer) throws CoreException { ITypeMarshalBuffer buffer) throws CoreException {
IBinding template= buffer.unmarshalBinding(); IBinding template= buffer.unmarshalBinding();
int argcount= buffer.getInt(); int argcount= buffer.getInt();

View file

@ -136,12 +136,12 @@ public class CPPFunctionType implements ICPPFunctionType, ISerializableType {
@Override @Override
public void marshal(ITypeMarshalBuffer buffer) throws CoreException { public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
int firstByte= ITypeMarshalBuffer.FUNCTION_TYPE; short firstBytes= ITypeMarshalBuffer.FUNCTION_TYPE;
if (isConst()) firstByte |= ITypeMarshalBuffer.FLAG1; if (isConst()) firstBytes |= ITypeMarshalBuffer.FLAG1;
if (isVolatile()) firstByte |= ITypeMarshalBuffer.FLAG2; if (takesVarArgs()) firstBytes |= ITypeMarshalBuffer.FLAG2;
if (takesVarArgs()) firstByte |= ITypeMarshalBuffer.FLAG3; if (isVolatile()) firstBytes |= ITypeMarshalBuffer.FLAG3;
buffer.putByte((byte) firstByte); buffer.putShort(firstBytes);
buffer.putInt(parameters.length); buffer.putInt(parameters.length);
buffer.marshalType(returnType); buffer.marshalType(returnType);
@ -150,14 +150,16 @@ public class CPPFunctionType implements ICPPFunctionType, ISerializableType {
} }
} }
public static IType unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException { public static IType unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
int len= buffer.getInt(); int len= buffer.getInt();
IType rt= buffer.unmarshalType(); IType rt= buffer.unmarshalType();
IType[] pars= new IType[len]; IType[] pars= new IType[len];
for (int i = 0; i < pars.length; i++) { for (int i = 0; i < pars.length; i++) {
pars[i]= buffer.unmarshalType(); pars[i]= buffer.unmarshalType();
} }
return new CPPFunctionType(rt, pars, (firstByte & ITypeMarshalBuffer.FLAG1) != 0, return new CPPFunctionType(rt, pars,
(firstByte & ITypeMarshalBuffer.FLAG2) != 0, (firstByte & ITypeMarshalBuffer.FLAG3) != 0); (firstBytes & ITypeMarshalBuffer.FLAG1) != 0, // const
(firstBytes & ITypeMarshalBuffer.FLAG3) != 0, // volatile
(firstBytes & ITypeMarshalBuffer.FLAG2) != 0); // takes varargs
} }
} }

View file

@ -72,12 +72,12 @@ public class CPPParameterPackType implements ICPPParameterPackType, ITypeContain
@Override @Override
public void marshal(ITypeMarshalBuffer buffer) throws CoreException { public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
int firstByte= ITypeMarshalBuffer.PACK_EXPANSION_TYPE; short firstBytes= ITypeMarshalBuffer.PACK_EXPANSION_TYPE;
buffer.putByte((byte) firstByte); buffer.putShort(firstBytes);
buffer.marshalType(getType()); buffer.marshalType(getType());
} }
public static IType unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException { public static IType unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
IType nested= buffer.unmarshalType(); IType nested= buffer.unmarshalType();
if (nested == null) if (nested == null)
return new ProblemBinding(null, IProblemBinding.SEMANTIC_INVALID_TYPE); return new ProblemBinding(null, IProblemBinding.SEMANTIC_INVALID_TYPE);

View file

@ -97,20 +97,20 @@ public class CPPPointerToMemberType extends CPPPointerType implements ICPPPointe
@Override @Override
public void marshal(ITypeMarshalBuffer buffer) throws CoreException { public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
int firstByte= ITypeMarshalBuffer.POINTER_TO_MEMBER_TYPE; short firstBytes= ITypeMarshalBuffer.POINTER_TO_MEMBER_TYPE;
if (isConst()) firstByte |= ITypeMarshalBuffer.FLAG1; if (isConst()) firstBytes |= ITypeMarshalBuffer.FLAG1;
if (isVolatile()) firstByte |= ITypeMarshalBuffer.FLAG2; if (isVolatile()) firstBytes |= ITypeMarshalBuffer.FLAG2;
if (isRestrict()) firstByte |= ITypeMarshalBuffer.FLAG3; if (isRestrict()) firstBytes |= ITypeMarshalBuffer.FLAG3;
buffer.putByte((byte) firstByte); buffer.putShort(firstBytes);
buffer.marshalType(getType()); buffer.marshalType(getType());
buffer.marshalType(getMemberOfClass()); buffer.marshalType(getMemberOfClass());
} }
public static IType unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException { public static IType unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
IType nested= buffer.unmarshalType(); IType nested= buffer.unmarshalType();
IType memberOf= buffer.unmarshalType(); IType memberOf= buffer.unmarshalType();
return new CPPPointerToMemberType(nested, memberOf, (firstByte & ITypeMarshalBuffer.FLAG1) != 0, return new CPPPointerToMemberType(nested, memberOf, (firstBytes & ITypeMarshalBuffer.FLAG1) != 0,
(firstByte & ITypeMarshalBuffer.FLAG2) != 0, (firstBytes & ITypeMarshalBuffer.FLAG2) != 0,
(firstByte & ITypeMarshalBuffer.FLAG3) != 0); (firstBytes & ITypeMarshalBuffer.FLAG3) != 0);
} }
} }

View file

@ -108,20 +108,20 @@ public class CPPPointerType implements IPointerType, ITypeContainer, ISerializab
@Override @Override
public void marshal(ITypeMarshalBuffer buffer) throws CoreException { public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
int firstByte= ITypeMarshalBuffer.POINTER_TYPE; short firstBytes= ITypeMarshalBuffer.POINTER_TYPE;
if (isConst()) firstByte |= ITypeMarshalBuffer.FLAG1; if (isConst()) firstBytes |= ITypeMarshalBuffer.FLAG1;
if (isVolatile()) firstByte |= ITypeMarshalBuffer.FLAG2; if (isVolatile()) firstBytes |= ITypeMarshalBuffer.FLAG2;
if (isRestrict()) firstByte |= ITypeMarshalBuffer.FLAG3; if (isRestrict()) firstBytes |= ITypeMarshalBuffer.FLAG3;
buffer.putByte((byte) firstByte); buffer.putShort(firstBytes);
final IType nestedType = getType(); final IType nestedType = getType();
buffer.marshalType(nestedType); buffer.marshalType(nestedType);
} }
public static IType unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException { public static IType unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
IType nested= buffer.unmarshalType(); IType nested= buffer.unmarshalType();
return new CPPPointerType(nested, (firstByte & ITypeMarshalBuffer.FLAG1) != 0, return new CPPPointerType(nested, (firstBytes & ITypeMarshalBuffer.FLAG1) != 0,
(firstByte & ITypeMarshalBuffer.FLAG2) != 0, (firstBytes & ITypeMarshalBuffer.FLAG2) != 0,
(firstByte & ITypeMarshalBuffer.FLAG3) != 0); (firstBytes & ITypeMarshalBuffer.FLAG3) != 0);
} }
@Override @Override

View file

@ -92,16 +92,16 @@ public class CPPQualifierType implements IQualifierType, ITypeContainer, ISerial
@Override @Override
public void marshal(ITypeMarshalBuffer buffer) throws CoreException { public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
int firstByte= ITypeMarshalBuffer.CVQUALIFIER_TYPE; short firstBytes= ITypeMarshalBuffer.CVQUALIFIER_TYPE;
if (isConst()) firstByte |= ITypeMarshalBuffer.FLAG1; if (isConst()) firstBytes |= ITypeMarshalBuffer.FLAG1;
if (isVolatile()) firstByte |= ITypeMarshalBuffer.FLAG2; if (isVolatile()) firstBytes |= ITypeMarshalBuffer.FLAG2;
buffer.putByte((byte) firstByte); buffer.putShort(firstBytes);
buffer.marshalType(getType()); buffer.marshalType(getType());
} }
public static IType unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException { public static IType unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
IType nested= buffer.unmarshalType(); IType nested= buffer.unmarshalType();
return new CPPQualifierType(nested, (firstByte & ITypeMarshalBuffer.FLAG1) != 0, return new CPPQualifierType(nested, (firstBytes & ITypeMarshalBuffer.FLAG1) != 0,
(firstByte & ITypeMarshalBuffer.FLAG2) != 0); (firstBytes & ITypeMarshalBuffer.FLAG2) != 0);
} }
} }

View file

@ -109,16 +109,16 @@ public class CPPReferenceType implements ICPPReferenceType, ITypeContainer, ISer
@Override @Override
public void marshal(ITypeMarshalBuffer buffer) throws CoreException { public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
int firstByte= ITypeMarshalBuffer.REFERENCE_TYPE; short firstBytes= ITypeMarshalBuffer.REFERENCE_TYPE;
if (isRValueReference()) { if (isRValueReference()) {
firstByte |= ITypeMarshalBuffer.FLAG1; firstBytes |= ITypeMarshalBuffer.FLAG1;
} }
buffer.putByte((byte) firstByte); buffer.putShort(firstBytes);
buffer.marshalType(getType()); buffer.marshalType(getType());
} }
public static IType unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException { public static IType unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
IType nested= buffer.unmarshalType(); IType nested= buffer.unmarshalType();
return new CPPReferenceType(nested, (firstByte & ITypeMarshalBuffer.FLAG1) != 0); return new CPPReferenceType(nested, (firstBytes & ITypeMarshalBuffer.FLAG1) != 0);
} }
} }

View file

@ -19,6 +19,7 @@ import org.eclipse.cdt.core.dom.ast.IValue;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameterPackType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameterPackType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalFixed; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalFixed;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalParameterPack;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalTypeId; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalTypeId;
import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.Assert;
@ -90,9 +91,8 @@ public class CPPTemplateNonTypeArgument implements ICPPTemplateArgument {
IType t= ((ICPPParameterPackType) type).getType(); IType t= ((ICPPParameterPackType) type).getType();
if (t != null) { if (t != null) {
ICPPEvaluation evaluation; ICPPEvaluation evaluation;
if (fEvaluation instanceof EvalFixed) { if (fEvaluation instanceof EvalParameterPack) {
EvalFixed fixed = (EvalFixed) fEvaluation; evaluation = ((EvalParameterPack) fEvaluation).getExpansionPattern();
evaluation = new EvalFixed(t, fixed.getValueCategory(), fixed.getValue());
} else { } else {
evaluation = new EvalTypeId(t, fEvaluation.getTemplateDefinition(), fEvaluation); evaluation = new EvalTypeId(t, fEvaluation.getTemplateDefinition(), fEvaluation);
} }

View file

@ -114,6 +114,7 @@ public class CPPTemplateParameterMap implements ICPPTemplateParameterMap {
return null; return null;
} }
@Override
public ICPPTemplateArgument getArgument(ICPPTemplateParameter tpar, int packOffset) { public ICPPTemplateArgument getArgument(ICPPTemplateParameter tpar, int packOffset) {
return getArgument(tpar.getParameterID(), packOffset); return getArgument(tpar.getParameterID(), packOffset);
} }

View file

@ -82,8 +82,8 @@ public class CPPUnknownClassInstance extends CPPUnknownMemberClass implements IC
@Override @Override
public void marshal(ITypeMarshalBuffer buffer) throws CoreException { public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
int firstByte= ITypeMarshalBuffer.UNKNOWN_MEMBER_CLASS_INSTANCE; short firstBytes= ITypeMarshalBuffer.UNKNOWN_MEMBER_CLASS_INSTANCE;
buffer.putByte((byte) firstByte); buffer.putShort(firstBytes);
buffer.marshalType(getOwnerType()); buffer.marshalType(getOwnerType());
buffer.putCharArray(getNameCharArray()); buffer.putCharArray(getNameCharArray());
buffer.putInt(arguments.length); buffer.putInt(arguments.length);
@ -92,7 +92,7 @@ public class CPPUnknownClassInstance extends CPPUnknownMemberClass implements IC
} }
} }
public static ICPPUnknownMemberClassInstance unmarshal(IIndexFragment fragment, int firstByte, ITypeMarshalBuffer buffer) throws CoreException { public static ICPPUnknownMemberClassInstance unmarshal(IIndexFragment fragment, short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
IType owner= buffer.unmarshalType(); IType owner= buffer.unmarshalType();
char[] name = buffer.getCharArray(); char[] name = buffer.getCharArray();
int argcount= buffer.getInt(); int argcount= buffer.getInt();

View file

@ -49,24 +49,24 @@ public class CPPUnknownMember extends CPPUnknownBinding implements ICPPUnknownMe
@Override @Override
public void marshal(ITypeMarshalBuffer buffer) throws CoreException { public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
int firstByte= ITypeMarshalBuffer.UNKNOWN_MEMBER; short firstBytes= ITypeMarshalBuffer.UNKNOWN_MEMBER;
if (this instanceof ICPPField) { if (this instanceof ICPPField) {
firstByte |= ITypeMarshalBuffer.FLAG1; firstBytes |= ITypeMarshalBuffer.FLAG1;
} else if (this instanceof ICPPMethod) { } else if (this instanceof ICPPMethod) {
firstByte |= ITypeMarshalBuffer.FLAG2; firstBytes |= ITypeMarshalBuffer.FLAG2;
} }
buffer.putByte((byte) firstByte); buffer.putShort(firstBytes);
buffer.marshalType(getOwnerType()); buffer.marshalType(getOwnerType());
buffer.putCharArray(getNameCharArray()); buffer.putCharArray(getNameCharArray());
} }
public static IBinding unmarshal(IIndexFragment fragment, int firstByte, ITypeMarshalBuffer buffer) throws CoreException { public static IBinding unmarshal(IIndexFragment fragment, short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
IType owner= buffer.unmarshalType(); IType owner= buffer.unmarshalType();
char[] name = buffer.getCharArray(); char[] name = buffer.getCharArray();
if ((firstByte & ITypeMarshalBuffer.FLAG1) != 0) { if ((firstBytes & ITypeMarshalBuffer.FLAG1) != 0) {
return new PDOMCPPUnknownField(fragment, owner, name); return new PDOMCPPUnknownField(fragment, owner, name);
} else if ((firstByte & ITypeMarshalBuffer.FLAG2) != 0) { } else if ((firstBytes & ITypeMarshalBuffer.FLAG2) != 0) {
return new PDOMCPPUnknownMethod(fragment, owner, name); return new PDOMCPPUnknownMethod(fragment, owner, name);
} }
return new PDOMCPPUnknownMemberClass(fragment, owner, name); return new PDOMCPPUnknownMemberClass(fragment, owner, name);

View file

@ -17,8 +17,11 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer; import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.PlatformObject; import org.eclipse.core.runtime.PlatformObject;
@ -94,6 +97,63 @@ public abstract class CPPDependentEvaluation extends CPPEvaluation {
buffer.marshalBinding(getTemplateDefinition()); buffer.marshalBinding(getTemplateDefinition());
} }
/**
* Instantiate evaluations that represent subexpressions separated by commas.
* If a subexpression is a pack expansion expression, and the template parameter map
* contains a mapping for the parameter pack(s) that occur in its expansion pattern,
* the expansion pattern is instantiated once for each mapped template argument,
* and the resulting evaluations are returned in place of the pack expansion.
*
* This code is similar to CPPTemplates.instantiateArguments(), but applies to evaluations
* rather than template arguments.
*/
protected static ICPPEvaluation[] instantiateCommaSeparatedSubexpressions(
ICPPEvaluation[] subexpressions, ICPPTemplateParameterMap tpMap, int packOffset,
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
ICPPEvaluation[] result = subexpressions;
int resultShift = 0;
for (int i = 0; i < subexpressions.length; i++) {
ICPPEvaluation origEval = subexpressions[i];
ICPPEvaluation newEval;
if (origEval instanceof EvalParameterPack) {
origEval = ((EvalParameterPack) origEval).getExpansionPattern();
if (origEval == null) {
newEval = EvalFixed.INCOMPLETE;
} else {
int packSize = origEval.determinePackSize(tpMap);
if (packSize == CPPTemplates.PACK_SIZE_FAIL || packSize == CPPTemplates.PACK_SIZE_NOT_FOUND) {
newEval = EvalFixed.INCOMPLETE;
} else if (packSize == CPPTemplates.PACK_SIZE_DEFER) {
newEval = origEval;
} else {
int shift = packSize - 1;
ICPPEvaluation[] newResult = new ICPPEvaluation[subexpressions.length + resultShift + shift];
System.arraycopy(result, 0, newResult, 0, i + resultShift);
for (int j = 0; j < packSize; ++j) {
newEval = origEval.instantiate(tpMap, j, within, maxdepth, point);
newResult[i + resultShift + j] = newEval;
}
result = newResult;
resultShift += shift;
continue;
}
}
} else {
newEval = origEval.instantiate(tpMap, packOffset, within, maxdepth, point);
}
if (result != subexpressions)
result[i + resultShift] = newEval;
else if (newEval != origEval) {
assert resultShift == 0;
result = new ICPPEvaluation[subexpressions.length];
System.arraycopy(subexpressions, 0, result, 0, i);
result[i] = newEval;
}
}
return result;
}
/** /**
* Used to defer the resolution of a template definition until it is needed, * Used to defer the resolution of a template definition until it is needed,
* to avoid recursion. The only valid operation on this binding is resolve(). * to avoid recursion. The only valid operation on this binding is resolve().

View file

@ -344,7 +344,7 @@ public class CPPVisitor extends ASTQueries {
if (inScope == null) if (inScope == null)
return false; return false;
IBinding pb= names[names.length-2].resolvePreBinding(); IBinding pb= names[names.length - 2].resolvePreBinding();
if (pb instanceof IProblemBinding) if (pb instanceof IProblemBinding)
return false; return false;
@ -930,11 +930,11 @@ public class CPPVisitor extends ASTQueries {
if (name instanceof ICPPASTQualifiedName) { if (name instanceof ICPPASTQualifiedName) {
IASTName[] names = ((ICPPASTQualifiedName) name).getNames(); IASTName[] names = ((ICPPASTQualifiedName) name).getNames();
if (names.length >= 2) { if (names.length >= 2) {
IBinding b= names[names.length-2].resolvePreBinding(); IBinding b= names[names.length - 2].resolvePreBinding();
if (b instanceof IType) { if (b instanceof IType) {
IType classType= getNestedType((IType) b, TDEF); IType classType= getNestedType((IType) b, TDEF);
if (classType instanceof ICPPClassType) { if (classType instanceof ICPPClassType) {
final char[] dtorName = names[names.length-1].getLookupKey(); final char[] dtorName = names[names.length - 1].getLookupKey();
final char[] className = ((ICPPClassType) classType).getNameCharArray(); final char[] className = ((ICPPClassType) classType).getNameCharArray();
return CharArrayUtils.equals(dtorName, className); return CharArrayUtils.equals(dtorName, className);
} }
@ -1303,7 +1303,7 @@ public class CPPVisitor extends ASTQueries {
IASTName name = findInnermostDeclarator(fnDeclarator).getName(); IASTName name = findInnermostDeclarator(fnDeclarator).getName();
if (name instanceof ICPPASTQualifiedName) { if (name instanceof ICPPASTQualifiedName) {
IASTName[] ns = ((ICPPASTQualifiedName) name).getNames(); IASTName[] ns = ((ICPPASTQualifiedName) name).getNames();
name = ns[ns.length -1]; name = ns[ns.length - 1];
} }
return getContainingScope(name); return getContainingScope(name);
} }

View file

@ -331,14 +331,14 @@ public class EvalBinary extends CPPDependentEvaluation {
@Override @Override
public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException { public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException {
buffer.putByte(ITypeMarshalBuffer.EVAL_BINARY); buffer.putShort(ITypeMarshalBuffer.EVAL_BINARY);
buffer.putByte((byte) fOperator); buffer.putByte((byte) fOperator);
buffer.marshalEvaluation(fArg1, includeValue); buffer.marshalEvaluation(fArg1, includeValue);
buffer.marshalEvaluation(fArg2, includeValue); buffer.marshalEvaluation(fArg2, includeValue);
marshalTemplateDefinition(buffer); marshalTemplateDefinition(buffer);
} }
public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException { public static ISerializableEvaluation unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
int op= buffer.getByte(); int op= buffer.getByte();
ICPPEvaluation arg1= (ICPPEvaluation) buffer.unmarshalEvaluation(); ICPPEvaluation arg1= (ICPPEvaluation) buffer.unmarshalEvaluation();
ICPPEvaluation arg2= (ICPPEvaluation) buffer.unmarshalEvaluation(); ICPPEvaluation arg2= (ICPPEvaluation) buffer.unmarshalEvaluation();

View file

@ -109,14 +109,14 @@ public class EvalBinaryTypeId extends CPPDependentEvaluation {
@Override @Override
public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException { public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException {
buffer.putByte(ITypeMarshalBuffer.EVAL_BINARY_TYPE_ID); buffer.putShort(ITypeMarshalBuffer.EVAL_BINARY_TYPE_ID);
buffer.putByte((byte) fOperator.ordinal()); buffer.putByte((byte) fOperator.ordinal());
buffer.marshalType(fType1); buffer.marshalType(fType1);
buffer.marshalType(fType2); buffer.marshalType(fType2);
marshalTemplateDefinition(buffer); marshalTemplateDefinition(buffer);
} }
public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException { public static ISerializableEvaluation unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
int op= buffer.getByte(); int op= buffer.getByte();
IType arg1= buffer.unmarshalType(); IType arg1= buffer.unmarshalType();
IType arg2= buffer.unmarshalType(); IType arg2= buffer.unmarshalType();

View file

@ -27,6 +27,7 @@ import org.eclipse.cdt.core.dom.ast.IVariable;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameterPackType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
@ -246,6 +247,12 @@ public class EvalBinding extends CPPDependentEvaluation {
} }
if (binding instanceof ICPPTemplateNonTypeParameter) { if (binding instanceof ICPPTemplateNonTypeParameter) {
IType type= ((ICPPTemplateNonTypeParameter) binding).getType(); IType type= ((ICPPTemplateNonTypeParameter) binding).getType();
// If the binding is a non-type parameter pack, it must have been
// referenced from inside the expansion pattern of a pack expansion.
// In such a context, the type of the binding is the type of each
// parameter in the parameter pack, not the type of the pack itself.
if (type instanceof ICPPParameterPackType)
type = ((ICPPParameterPackType) type).getType();
return prvalueType(type); return prvalueType(type);
} }
if (binding instanceof IVariable) { if (binding instanceof IVariable) {
@ -293,24 +300,24 @@ public class EvalBinding extends CPPDependentEvaluation {
@Override @Override
public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException { public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException {
byte firstByte = ITypeMarshalBuffer.EVAL_BINDING; short firstBytes = ITypeMarshalBuffer.EVAL_BINDING;
ICPPFunction parameterOwner = getParameterOwner(); ICPPFunction parameterOwner = getParameterOwner();
if (parameterOwner != null) { if (parameterOwner != null) {
// A function parameter cannot be marshalled directly. We are storing the owning // A function parameter cannot be marshalled directly. We are storing the owning
// function and the parameter position instead. // function and the parameter position instead.
buffer.putByte((byte) (ITypeMarshalBuffer.EVAL_BINDING | ITypeMarshalBuffer.FLAG1)); buffer.putShort((short) (ITypeMarshalBuffer.EVAL_BINDING | ITypeMarshalBuffer.FLAG1));
buffer.marshalBinding(parameterOwner); buffer.marshalBinding(parameterOwner);
buffer.putInt(getFunctionParameterPosition()); buffer.putInt(getFunctionParameterPosition());
} else { } else {
buffer.putByte(firstByte); buffer.putShort(firstBytes);
buffer.marshalBinding(fBinding); buffer.marshalBinding(fBinding);
} }
buffer.marshalType(fFixedType ? fType : null); buffer.marshalType(fFixedType ? fType : null);
marshalTemplateDefinition(buffer); marshalTemplateDefinition(buffer);
} }
public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException { public static ISerializableEvaluation unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
if ((firstByte & ITypeMarshalBuffer.FLAG1) != 0) { if ((firstBytes & ITypeMarshalBuffer.FLAG1) != 0) {
ICPPFunction parameterOwner= (ICPPFunction) buffer.unmarshalBinding(); ICPPFunction parameterOwner= (ICPPFunction) buffer.unmarshalBinding();
int parameterPosition= buffer.getInt(); int parameterPosition= buffer.getInt();
IType type= buffer.unmarshalType(); IType type= buffer.unmarshalType();
@ -329,14 +336,16 @@ public class EvalBinding extends CPPDependentEvaluation {
ICPPClassSpecialization within, int maxdepth, IASTNode point) { ICPPClassSpecialization within, int maxdepth, IASTNode point) {
IBinding origBinding = getBinding(); IBinding origBinding = getBinding();
if (origBinding instanceof ICPPTemplateNonTypeParameter) { if (origBinding instanceof ICPPTemplateNonTypeParameter) {
ICPPTemplateArgument argument = tpMap.getArgument((ICPPTemplateNonTypeParameter) origBinding); ICPPTemplateArgument argument = tpMap.getArgument((ICPPTemplateNonTypeParameter) origBinding, packOffset);
if (argument != null && argument.isNonTypeValue()) { if (argument != null && argument.isNonTypeValue()) {
return argument.getNonTypeEvaluation(); return argument.getNonTypeEvaluation();
} }
// TODO(sprigogin): Do we need something similar for pack expansion?
} else if (origBinding instanceof ICPPParameter) { } else if (origBinding instanceof ICPPParameter) {
ICPPParameter parameter = (ICPPParameter) origBinding; ICPPParameter parameter = (ICPPParameter) origBinding;
IType origType = parameter.getType(); IType origType = parameter.getType();
if (origType instanceof ICPPParameterPackType && packOffset != -1) {
origType = ((ICPPParameterPackType) origType).getType();
}
IType instantiatedType = CPPTemplates.instantiateType(origType, tpMap, packOffset, within, point); IType instantiatedType = CPPTemplates.instantiateType(origType, tpMap, packOffset, within, point);
if (origType != instantiatedType) { if (origType != instantiatedType) {
return new EvalFixed(instantiatedType, ValueCategory.LVALUE, Value.create(this)); return new EvalFixed(instantiatedType, ValueCategory.LVALUE, Value.create(this));
@ -373,6 +382,10 @@ public class EvalBinding extends CPPDependentEvaluation {
if (binding instanceof ICPPUnknownBinding) { if (binding instanceof ICPPUnknownBinding) {
return CPPTemplates.determinePackSize((ICPPUnknownBinding) binding, tpMap); return CPPTemplates.determinePackSize((ICPPUnknownBinding) binding, tpMap);
} }
if (binding instanceof ICPPParameter && ((ICPPParameter) binding).isParameterPack()) {
ICPPParameterPackType type = (ICPPParameterPackType) ((ICPPParameter) binding).getType();
return CPPTemplates.determinePackSize(type.getType(), tpMap);
}
if (binding instanceof ICPPSpecialization) { if (binding instanceof ICPPSpecialization) {
binding = ((ICPPSpecialization) binding).getSpecializedBinding(); binding = ((ICPPSpecialization) binding).getSpecializedBinding();

View file

@ -159,7 +159,7 @@ public class EvalComma extends CPPDependentEvaluation {
@Override @Override
public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException { public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException {
buffer.putByte(ITypeMarshalBuffer.EVAL_COMMA); buffer.putShort(ITypeMarshalBuffer.EVAL_COMMA);
buffer.putInt(fArguments.length); buffer.putInt(fArguments.length);
for (ICPPEvaluation arg : fArguments) { for (ICPPEvaluation arg : fArguments) {
buffer.marshalEvaluation(arg, includeValue); buffer.marshalEvaluation(arg, includeValue);
@ -167,7 +167,7 @@ public class EvalComma extends CPPDependentEvaluation {
marshalTemplateDefinition(buffer); marshalTemplateDefinition(buffer);
} }
public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException { public static ISerializableEvaluation unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
int len= buffer.getInt(); int len= buffer.getInt();
ICPPEvaluation[] args = new ICPPEvaluation[len]; ICPPEvaluation[] args = new ICPPEvaluation[len];
for (int i = 0; i < args.length; i++) { for (int i = 0; i < args.length; i++) {

View file

@ -81,12 +81,12 @@ public class EvalCompound extends CPPDependentEvaluation {
@Override @Override
public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException { public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException {
buffer.putByte(ITypeMarshalBuffer.EVAL_COMPOUND); buffer.putShort(ITypeMarshalBuffer.EVAL_COMPOUND);
buffer.marshalEvaluation(fDelegate, includeValue); buffer.marshalEvaluation(fDelegate, includeValue);
marshalTemplateDefinition(buffer); marshalTemplateDefinition(buffer);
} }
public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException { public static ISerializableEvaluation unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
ICPPEvaluation arg= (ICPPEvaluation) buffer.unmarshalEvaluation(); ICPPEvaluation arg= (ICPPEvaluation) buffer.unmarshalEvaluation();
IBinding templateDefinition= buffer.unmarshalBinding(); IBinding templateDefinition= buffer.unmarshalBinding();
return new EvalCompound(arg, templateDefinition); return new EvalCompound(arg, templateDefinition);

View file

@ -309,22 +309,22 @@ public class EvalConditional extends CPPDependentEvaluation {
@Override @Override
public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException { public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException {
int firstByte = ITypeMarshalBuffer.EVAL_CONDITIONAL; short firstBytes = ITypeMarshalBuffer.EVAL_CONDITIONAL;
if (fPositiveThrows) if (fPositiveThrows)
firstByte |= ITypeMarshalBuffer.FLAG1; firstBytes |= ITypeMarshalBuffer.FLAG1;
if (fNegativeThrows) if (fNegativeThrows)
firstByte |= ITypeMarshalBuffer.FLAG2; firstBytes |= ITypeMarshalBuffer.FLAG2;
buffer.putByte((byte) firstByte); buffer.putShort(firstBytes);
buffer.marshalEvaluation(fCondition, includeValue); buffer.marshalEvaluation(fCondition, includeValue);
buffer.marshalEvaluation(fPositive, includeValue); buffer.marshalEvaluation(fPositive, includeValue);
buffer.marshalEvaluation(fNegative, includeValue); buffer.marshalEvaluation(fNegative, includeValue);
marshalTemplateDefinition(buffer); marshalTemplateDefinition(buffer);
} }
public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException { public static ISerializableEvaluation unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
boolean pth= (firstByte & ITypeMarshalBuffer.FLAG1) != 0; boolean pth= (firstBytes & ITypeMarshalBuffer.FLAG1) != 0;
boolean nth= (firstByte & ITypeMarshalBuffer.FLAG2) != 0; boolean nth= (firstBytes & ITypeMarshalBuffer.FLAG2) != 0;
ICPPEvaluation cond= (ICPPEvaluation) buffer.unmarshalEvaluation(); ICPPEvaluation cond= (ICPPEvaluation) buffer.unmarshalEvaluation();
ICPPEvaluation pos= (ICPPEvaluation) buffer.unmarshalEvaluation(); ICPPEvaluation pos= (ICPPEvaluation) buffer.unmarshalEvaluation();
ICPPEvaluation neg= (ICPPEvaluation) buffer.unmarshalEvaluation(); ICPPEvaluation neg= (ICPPEvaluation) buffer.unmarshalEvaluation();

View file

@ -116,37 +116,37 @@ public class EvalFixed extends CPPEvaluation {
@Override @Override
public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException { public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException {
includeValue= includeValue && fValue != Value.UNKNOWN; includeValue= includeValue && fValue != Value.UNKNOWN;
int firstByte = ITypeMarshalBuffer.EVAL_FIXED; short firstBytes = ITypeMarshalBuffer.EVAL_FIXED;
if (includeValue) if (includeValue)
firstByte |= ITypeMarshalBuffer.FLAG1; firstBytes |= ITypeMarshalBuffer.FLAG1;
switch (fValueCategory) { switch (fValueCategory) {
case LVALUE:
firstByte |= ITypeMarshalBuffer.FLAG2;
break;
case PRVALUE: case PRVALUE:
firstByte |= ITypeMarshalBuffer.FLAG3; firstBytes |= ITypeMarshalBuffer.FLAG2;
break;
case LVALUE:
firstBytes |= ITypeMarshalBuffer.FLAG3;
break; break;
default: default:
break; break;
} }
buffer.putByte((byte) firstByte); buffer.putShort(firstBytes);
buffer.marshalType(fType); buffer.marshalType(fType);
if (includeValue) { if (includeValue) {
buffer.marshalValue(fValue); buffer.marshalValue(fValue);
} }
} }
public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException { public static ISerializableEvaluation unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
final boolean readValue= (firstByte & ITypeMarshalBuffer.FLAG1) != 0; final boolean readValue= (firstBytes & ITypeMarshalBuffer.FLAG1) != 0;
IValue value; IValue value;
ValueCategory cat; ValueCategory cat;
switch (firstByte & (ITypeMarshalBuffer.FLAG2 | ITypeMarshalBuffer.FLAG3)) { switch (firstBytes & (ITypeMarshalBuffer.FLAG2 | ITypeMarshalBuffer.FLAG3)) {
case ITypeMarshalBuffer.FLAG2: case ITypeMarshalBuffer.FLAG2:
cat= LVALUE; cat= PRVALUE;
break; break;
case ITypeMarshalBuffer.FLAG3: case ITypeMarshalBuffer.FLAG3:
cat= PRVALUE; cat= LVALUE;
break; break;
default: default:
cat= XVALUE; cat= XVALUE;

View file

@ -174,7 +174,7 @@ public class EvalFunctionCall extends CPPDependentEvaluation {
@Override @Override
public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException { public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException {
buffer.putByte(ITypeMarshalBuffer.EVAL_FUNCTION_CALL); buffer.putShort(ITypeMarshalBuffer.EVAL_FUNCTION_CALL);
buffer.putInt(fArguments.length); buffer.putInt(fArguments.length);
for (ICPPEvaluation arg : fArguments) { for (ICPPEvaluation arg : fArguments) {
buffer.marshalEvaluation(arg, includeValue); buffer.marshalEvaluation(arg, includeValue);
@ -182,7 +182,7 @@ public class EvalFunctionCall extends CPPDependentEvaluation {
marshalTemplateDefinition(buffer); marshalTemplateDefinition(buffer);
} }
public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException { public static ISerializableEvaluation unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
int len= buffer.getInt(); int len= buffer.getInt();
ICPPEvaluation[] args = new ICPPEvaluation[len]; ICPPEvaluation[] args = new ICPPEvaluation[len];
for (int i = 0; i < args.length; i++) { for (int i = 0; i < args.length; i++) {
@ -195,17 +195,8 @@ public class EvalFunctionCall extends CPPDependentEvaluation {
@Override @Override
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset, public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
ICPPClassSpecialization within, int maxdepth, IASTNode point) { ICPPClassSpecialization within, int maxdepth, IASTNode point) {
ICPPEvaluation[] args = fArguments; ICPPEvaluation[] args = instantiateCommaSeparatedSubexpressions(fArguments, tpMap,
for (int i = 0; i < fArguments.length; i++) { packOffset, within, maxdepth, point);
ICPPEvaluation arg = fArguments[i].instantiate(tpMap, packOffset, within, maxdepth, point);
if (arg != fArguments[i]) {
if (args == fArguments) {
args = new ICPPEvaluation[fArguments.length];
System.arraycopy(fArguments, 0, args, 0, fArguments.length);
}
args[i] = arg;
}
}
if (args == fArguments) if (args == fArguments)
return this; return this;

View file

@ -109,13 +109,13 @@ public class EvalFunctionSet extends CPPDependentEvaluation {
public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException { public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException {
final ICPPFunction[] bindings = fFunctionSet.getBindings(); final ICPPFunction[] bindings = fFunctionSet.getBindings();
final ICPPTemplateArgument[] args = fFunctionSet.getTemplateArguments(); final ICPPTemplateArgument[] args = fFunctionSet.getTemplateArguments();
int firstByte = ITypeMarshalBuffer.EVAL_FUNCTION_SET; short firstBytes = ITypeMarshalBuffer.EVAL_FUNCTION_SET;
if (fAddressOf) if (fAddressOf)
firstByte |= ITypeMarshalBuffer.FLAG1; firstBytes |= ITypeMarshalBuffer.FLAG1;
if (args != null) if (args != null)
firstByte |= ITypeMarshalBuffer.FLAG2; firstBytes |= ITypeMarshalBuffer.FLAG2;
buffer.putByte((byte) firstByte); buffer.putShort(firstBytes);
buffer.putInt(bindings.length); buffer.putInt(bindings.length);
for (ICPPFunction binding : bindings) { for (ICPPFunction binding : bindings) {
buffer.marshalBinding(binding); buffer.marshalBinding(binding);
@ -129,15 +129,15 @@ public class EvalFunctionSet extends CPPDependentEvaluation {
marshalTemplateDefinition(buffer); marshalTemplateDefinition(buffer);
} }
public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException { public static ISerializableEvaluation unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
final boolean addressOf= (firstByte & ITypeMarshalBuffer.FLAG1) != 0; final boolean addressOf= (firstBytes & ITypeMarshalBuffer.FLAG1) != 0;
int bindingCount= buffer.getInt(); int bindingCount= buffer.getInt();
ICPPFunction[] bindings= new ICPPFunction[bindingCount]; ICPPFunction[] bindings= new ICPPFunction[bindingCount];
for (int i = 0; i < bindings.length; i++) { for (int i = 0; i < bindings.length; i++) {
bindings[i]= (ICPPFunction) buffer.unmarshalBinding(); bindings[i]= (ICPPFunction) buffer.unmarshalBinding();
} }
ICPPTemplateArgument[] args= null; ICPPTemplateArgument[] args= null;
if ((firstByte & ITypeMarshalBuffer.FLAG2) != 0) { if ((firstBytes & ITypeMarshalBuffer.FLAG2) != 0) {
int len= buffer.getInt(); int len= buffer.getInt();
args = new ICPPTemplateArgument[len]; args = new ICPPTemplateArgument[len];
for (int i = 0; i < args.length; i++) { for (int i = 0; i < args.length; i++) {

View file

@ -145,15 +145,15 @@ public class EvalID extends CPPDependentEvaluation {
@Override @Override
public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException { public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException {
int firstByte = ITypeMarshalBuffer.EVAL_ID; short firstBytes = ITypeMarshalBuffer.EVAL_ID;
if (fAddressOf) if (fAddressOf)
firstByte |= ITypeMarshalBuffer.FLAG1; firstBytes |= ITypeMarshalBuffer.FLAG1;
if (fQualified) if (fQualified)
firstByte |= ITypeMarshalBuffer.FLAG2; firstBytes |= ITypeMarshalBuffer.FLAG2;
if (fTemplateArgs != null) if (fTemplateArgs != null)
firstByte |= ITypeMarshalBuffer.FLAG3; firstBytes |= ITypeMarshalBuffer.FLAG3;
buffer.putByte((byte) firstByte); buffer.putShort(firstBytes);
buffer.marshalEvaluation(fFieldOwner, false); buffer.marshalEvaluation(fFieldOwner, false);
buffer.putCharArray(fName); buffer.putCharArray(fName);
buffer.marshalBinding(fNameOwner); buffer.marshalBinding(fNameOwner);
@ -166,14 +166,14 @@ public class EvalID extends CPPDependentEvaluation {
marshalTemplateDefinition(buffer); marshalTemplateDefinition(buffer);
} }
public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException { public static ISerializableEvaluation unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
final boolean addressOf= (firstByte & ITypeMarshalBuffer.FLAG1) != 0; final boolean addressOf= (firstBytes & ITypeMarshalBuffer.FLAG1) != 0;
final boolean qualified= (firstByte & ITypeMarshalBuffer.FLAG2) != 0; final boolean qualified= (firstBytes & ITypeMarshalBuffer.FLAG2) != 0;
ICPPEvaluation fieldOwner= (ICPPEvaluation) buffer.unmarshalEvaluation(); ICPPEvaluation fieldOwner= (ICPPEvaluation) buffer.unmarshalEvaluation();
char[] name= buffer.getCharArray(); char[] name= buffer.getCharArray();
IBinding nameOwner= buffer.unmarshalBinding(); IBinding nameOwner= buffer.unmarshalBinding();
ICPPTemplateArgument[] args= null; ICPPTemplateArgument[] args= null;
if ((firstByte & ITypeMarshalBuffer.FLAG3) != 0) { if ((firstBytes & ITypeMarshalBuffer.FLAG3) != 0) {
int len= buffer.getInt(); int len= buffer.getInt();
args = new ICPPTemplateArgument[len]; args = new ICPPTemplateArgument[len];
for (int i = 0; i < args.length; i++) { for (int i = 0; i < args.length; i++) {

View file

@ -91,7 +91,7 @@ public class EvalInitList extends CPPDependentEvaluation {
@Override @Override
public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException { public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException {
buffer.putByte(ITypeMarshalBuffer.EVAL_INIT_LIST); buffer.putShort(ITypeMarshalBuffer.EVAL_INIT_LIST);
buffer.putInt(fClauses.length); buffer.putInt(fClauses.length);
for (ICPPEvaluation arg : fClauses) { for (ICPPEvaluation arg : fClauses) {
buffer.marshalEvaluation(arg, includeValue); buffer.marshalEvaluation(arg, includeValue);
@ -99,7 +99,7 @@ public class EvalInitList extends CPPDependentEvaluation {
marshalTemplateDefinition(buffer); marshalTemplateDefinition(buffer);
} }
public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException { public static ISerializableEvaluation unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
int len= buffer.getInt(); int len= buffer.getInt();
ICPPEvaluation[] args = new ICPPEvaluation[len]; ICPPEvaluation[] args = new ICPPEvaluation[len];
for (int i = 0; i < args.length; i++) { for (int i = 0; i < args.length; i++) {
@ -112,17 +112,8 @@ public class EvalInitList extends CPPDependentEvaluation {
@Override @Override
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset, public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
ICPPClassSpecialization within, int maxdepth, IASTNode point) { ICPPClassSpecialization within, int maxdepth, IASTNode point) {
ICPPEvaluation[] clauses = fClauses; ICPPEvaluation[] clauses = instantiateCommaSeparatedSubexpressions(fClauses, tpMap,
for (int i = 0; i < fClauses.length; i++) { packOffset, within, maxdepth, point);
ICPPEvaluation clause = fClauses[i].instantiate(tpMap, packOffset, within, maxdepth, point);
if (clause != fClauses[i]) {
if (clauses == fClauses) {
clauses = new ICPPEvaluation[fClauses.length];
System.arraycopy(fClauses, 0, clauses, 0, fClauses.length);
}
clauses[i] = clause;
}
}
if (clauses == fClauses) if (clauses == fClauses)
return this; return this;
return new EvalInitList(clauses, getTemplateDefinition()); return new EvalInitList(clauses, getTemplateDefinition());

View file

@ -295,27 +295,27 @@ public class EvalMemberAccess extends CPPDependentEvaluation {
@Override @Override
public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException { public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException {
int firstByte = ITypeMarshalBuffer.EVAL_MEMBER_ACCESS; short firstBytes = ITypeMarshalBuffer.EVAL_MEMBER_ACCESS;
if (fIsPointerDeref) if (fIsPointerDeref)
firstByte |= ITypeMarshalBuffer.FLAG1; firstBytes |= ITypeMarshalBuffer.FLAG1;
if (fOwnerValueCategory == LVALUE) { if (fOwnerValueCategory == LVALUE) {
firstByte |= ITypeMarshalBuffer.FLAG2; firstBytes |= ITypeMarshalBuffer.FLAG2;
} else if (fOwnerValueCategory == XVALUE) { } else if (fOwnerValueCategory == XVALUE) {
firstByte |= ITypeMarshalBuffer.FLAG3; firstBytes |= ITypeMarshalBuffer.FLAG3;
} }
buffer.putByte((byte) firstByte); buffer.putShort(firstBytes);
buffer.marshalType(fOwnerType); buffer.marshalType(fOwnerType);
buffer.marshalBinding(fMember); buffer.marshalBinding(fMember);
marshalTemplateDefinition(buffer); marshalTemplateDefinition(buffer);
} }
public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException { public static ISerializableEvaluation unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
boolean isDeref= (firstByte & ITypeMarshalBuffer.FLAG1) != 0; boolean isDeref= (firstBytes & ITypeMarshalBuffer.FLAG1) != 0;
ValueCategory ownerValueCat; ValueCategory ownerValueCat;
if ((firstByte & ITypeMarshalBuffer.FLAG2) != 0) { if ((firstBytes & ITypeMarshalBuffer.FLAG2) != 0) {
ownerValueCat= LVALUE; ownerValueCat= LVALUE;
} else if ((firstByte & ITypeMarshalBuffer.FLAG3) != 0) { } else if ((firstBytes & ITypeMarshalBuffer.FLAG3) != 0) {
ownerValueCat= XVALUE; ownerValueCat= XVALUE;
} else { } else {
ownerValueCat= PRVALUE; ownerValueCat= PRVALUE;

View file

@ -0,0 +1,131 @@
/*******************************************************************************
* Copyright (c) 2013 Nathan Ridge.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Nathan Ridge - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
import org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IValue;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
import org.eclipse.cdt.internal.core.dom.parser.Value;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPParameterPackType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
import org.eclipse.core.runtime.CoreException;
/**
* Evaluation for a pack expansion expression.
*/
public class EvalParameterPack extends CPPDependentEvaluation {
private ICPPEvaluation fExpansionPattern;
private IType fType;
public EvalParameterPack(ICPPEvaluation expansionPattern, IASTNode pointOfDefinition) {
this(expansionPattern, findEnclosingTemplate(pointOfDefinition));
}
public EvalParameterPack(ICPPEvaluation expansionPattern, IBinding templateDefinition) {
super(templateDefinition);
fExpansionPattern = expansionPattern;
}
public ICPPEvaluation getExpansionPattern() {
return fExpansionPattern;
}
@Override
public boolean isInitializerList() {
return fExpansionPattern.isInitializerList();
}
@Override
public boolean isFunctionSet() {
return fExpansionPattern.isFunctionSet();
}
@Override
public boolean isTypeDependent() {
return fExpansionPattern.isTypeDependent();
}
@Override
public boolean isValueDependent() {
return fExpansionPattern.isValueDependent();
}
@Override
public IType getTypeOrFunctionSet(IASTNode point) {
if (fType == null) {
IType type = fExpansionPattern.getTypeOrFunctionSet(point);
if (type == null) {
fType= ProblemType.UNKNOWN_FOR_EXPRESSION;
} else {
fType= new CPPParameterPackType(type);
}
}
return fType;
}
@Override
public IValue getValue(IASTNode point) {
return Value.create(fExpansionPattern);
}
@Override
public ValueCategory getValueCategory(IASTNode point) {
return ValueCategory.PRVALUE;
}
@Override
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
ICPPEvaluation expansionPattern = fExpansionPattern.instantiate(tpMap, packOffset, within, maxdepth, point);
if (expansionPattern == fExpansionPattern)
return this;
return new EvalParameterPack(expansionPattern, getTemplateDefinition());
}
@Override
public ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap,
int maxdepth, IASTNode point) {
ICPPEvaluation expansionPattern = fExpansionPattern.computeForFunctionCall(parameterMap, maxdepth, point);
if (expansionPattern == fExpansionPattern)
return this;
return new EvalParameterPack(expansionPattern, getTemplateDefinition());
}
@Override
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
return CPPTemplates.PACK_SIZE_NOT_FOUND;
}
@Override
public boolean referencesTemplateParameter() {
return fExpansionPattern.referencesTemplateParameter();
}
@Override
public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException {
buffer.putShort(ITypeMarshalBuffer.EVAL_PARAMETER_PACK);
buffer.marshalEvaluation(fExpansionPattern, includeValue);
marshalTemplateDefinition(buffer);
}
public static ISerializableEvaluation unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
ICPPEvaluation expansionPattern = (ICPPEvaluation) buffer.unmarshalEvaluation();
IBinding templateDefinition = buffer.unmarshalBinding();
return new EvalParameterPack(expansionPattern, templateDefinition);
}
}

View file

@ -121,11 +121,11 @@ public class EvalTypeId extends CPPDependentEvaluation {
@Override @Override
public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException { public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException {
int firstByte = ITypeMarshalBuffer.EVAL_TYPE_ID; short firstBytes = ITypeMarshalBuffer.EVAL_TYPE_ID;
if (includeValue) if (includeValue)
firstByte |= ITypeMarshalBuffer.FLAG1; firstBytes |= ITypeMarshalBuffer.FLAG1;
buffer.putByte((byte) firstByte); buffer.putShort(firstBytes);
buffer.marshalType(fInputType); buffer.marshalType(fInputType);
if (includeValue) { if (includeValue) {
buffer.putInt(fArguments.length); buffer.putInt(fArguments.length);
@ -136,10 +136,10 @@ public class EvalTypeId extends CPPDependentEvaluation {
marshalTemplateDefinition(buffer); marshalTemplateDefinition(buffer);
} }
public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException { public static ISerializableEvaluation unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
IType type= buffer.unmarshalType(); IType type= buffer.unmarshalType();
ICPPEvaluation[] args= null; ICPPEvaluation[] args= null;
if ((firstByte & ITypeMarshalBuffer.FLAG1) != 0) { if ((firstBytes & ITypeMarshalBuffer.FLAG1) != 0) {
int len= buffer.getInt(); int len= buffer.getInt();
args = new ICPPEvaluation[len]; args = new ICPPEvaluation[len];
for (int i = 0; i < args.length; i++) { for (int i = 0; i < args.length; i++) {
@ -153,19 +153,9 @@ public class EvalTypeId extends CPPDependentEvaluation {
@Override @Override
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset, public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
ICPPClassSpecialization within, int maxdepth, IASTNode point) { ICPPClassSpecialization within, int maxdepth, IASTNode point) {
ICPPEvaluation[] args = fArguments; ICPPEvaluation[] args = null;
if (fArguments != null) { if (fArguments != null)
for (int i = 0; i < fArguments.length; i++) { args = instantiateCommaSeparatedSubexpressions(fArguments, tpMap, packOffset, within, maxdepth, point);
ICPPEvaluation arg = fArguments[i].instantiate(tpMap, packOffset, within, maxdepth, point);
if (arg != fArguments[i]) {
if (args == fArguments) {
args = new ICPPEvaluation[fArguments.length];
System.arraycopy(fArguments, 0, args, 0, fArguments.length);
}
args[i] = arg;
}
}
}
IType type = CPPTemplates.instantiateType(fInputType, tpMap, packOffset, within, point); IType type = CPPTemplates.instantiateType(fInputType, tpMap, packOffset, within, point);
if (args == fArguments && type == fInputType) if (args == fArguments && type == fInputType)
return this; return this;

View file

@ -300,14 +300,14 @@ public class EvalUnary extends CPPDependentEvaluation {
@Override @Override
public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException { public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException {
buffer.putByte(ITypeMarshalBuffer.EVAL_UNARY); buffer.putShort(ITypeMarshalBuffer.EVAL_UNARY);
buffer.putByte((byte) fOperator); buffer.putByte((byte) fOperator);
buffer.marshalEvaluation(fArgument, includeValue); buffer.marshalEvaluation(fArgument, includeValue);
buffer.marshalBinding(fAddressOfQualifiedNameBinding); buffer.marshalBinding(fAddressOfQualifiedNameBinding);
marshalTemplateDefinition(buffer); marshalTemplateDefinition(buffer);
} }
public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException { public static ISerializableEvaluation unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
int op= buffer.getByte(); int op= buffer.getByte();
ICPPEvaluation arg= (ICPPEvaluation) buffer.unmarshalEvaluation(); ICPPEvaluation arg= (ICPPEvaluation) buffer.unmarshalEvaluation();
IBinding binding= buffer.unmarshalBinding(); IBinding binding= buffer.unmarshalBinding();

View file

@ -175,13 +175,13 @@ public class EvalUnaryTypeID extends CPPDependentEvaluation {
@Override @Override
public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException { public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException {
buffer.putByte(ITypeMarshalBuffer.EVAL_UNARY_TYPE_ID); buffer.putShort(ITypeMarshalBuffer.EVAL_UNARY_TYPE_ID);
buffer.putByte((byte) fOperator); buffer.putByte((byte) fOperator);
buffer.marshalType(fOrigType); buffer.marshalType(fOrigType);
marshalTemplateDefinition(buffer); marshalTemplateDefinition(buffer);
} }
public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException { public static ISerializableEvaluation unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
int op= buffer.getByte(); int op= buffer.getByte();
IType arg= buffer.unmarshalType(); IType arg= buffer.unmarshalType();
IBinding templateDefinition= buffer.unmarshalBinding(); IBinding templateDefinition= buffer.unmarshalBinding();

View file

@ -64,7 +64,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameterPackType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration; import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.core.parser.util.ArrayUtil;
@ -518,7 +517,7 @@ public class LookupData extends ScopeLookupData {
int count= 0; int count= 0;
if (functionArgs != null) { if (functionArgs != null) {
for (ICPPEvaluation arg : functionArgs) { for (ICPPEvaluation arg : functionArgs) {
if (arg instanceof EvalFixed && arg.getTypeOrFunctionSet(null) instanceof ICPPParameterPackType) if (arg instanceof EvalParameterPack)
count++; count++;
} }
} }

View file

@ -25,8 +25,8 @@ import org.eclipse.cdt.internal.core.dom.parser.Value;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
class SignatureBuilder implements ITypeMarshalBuffer { class SignatureBuilder implements ITypeMarshalBuffer {
private static final byte NULL_TYPE= 0; private static final short NULL_TYPE = 0x0000;
private static final byte UNSTORABLE_TYPE= (byte) -1; private static final short UNSTORABLE_TYPE = 0x001D;
private final StringBuilder fBuffer; private final StringBuilder fBuffer;
@ -51,7 +51,7 @@ class SignatureBuilder implements ITypeMarshalBuffer {
if (binding instanceof ISerializableType) { if (binding instanceof ISerializableType) {
((ISerializableType) binding).marshal(this); ((ISerializableType) binding).marshal(this);
} else if (binding == null) { } else if (binding == null) {
putByte(NULL_TYPE); putShort(NULL_TYPE);
} else { } else {
appendSeparator(); appendSeparator();
if (binding instanceof ICPPBinding) { if (binding instanceof ICPPBinding) {
@ -73,19 +73,19 @@ class SignatureBuilder implements ITypeMarshalBuffer {
if (type instanceof ISerializableType) { if (type instanceof ISerializableType) {
((ISerializableType) type).marshal(this); ((ISerializableType) type).marshal(this);
} else if (type == null) { } else if (type == null) {
putByte(NULL_TYPE); putShort(NULL_TYPE);
} else if (type instanceof IBinding) { } else if (type instanceof IBinding) {
marshalBinding((IBinding) type); marshalBinding((IBinding) type);
} else { } else {
assert false : "Cannot serialize " + ASTTypeUtil.getType(type) + " (" + type.getClass().getName() + ")"; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ assert false : "Cannot serialize " + ASTTypeUtil.getType(type) + " (" + type.getClass().getName() + ")"; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
putByte(UNSTORABLE_TYPE); putShort(UNSTORABLE_TYPE);
} }
} }
@Override @Override
public void marshalEvaluation(ISerializableEvaluation eval, boolean includeValues) throws CoreException { public void marshalEvaluation(ISerializableEvaluation eval, boolean includeValues) throws CoreException {
if (eval == null) { if (eval == null) {
putByte(NULL_TYPE); putShort(NULL_TYPE);
} else { } else {
eval.marshal(this, includeValues); eval.marshal(this, includeValues);
} }
@ -94,16 +94,16 @@ class SignatureBuilder implements ITypeMarshalBuffer {
@Override @Override
public void marshalValue(IValue value) throws CoreException { public void marshalValue(IValue value) throws CoreException {
if (value instanceof Value) { if (value instanceof Value) {
((Value) value).marshall(this); ((Value) value).marshal(this);
} else { } else {
putByte(NULL_TYPE); putShort(NULL_TYPE);
} }
} }
@Override @Override
public void marshalTemplateArgument(ICPPTemplateArgument arg) throws CoreException { public void marshalTemplateArgument(ICPPTemplateArgument arg) throws CoreException {
if (arg.isNonTypeValue()) { if (arg.isNonTypeValue()) {
putByte(VALUE); putShort(VALUE);
arg.getNonTypeEvaluation().marshal(this, true); arg.getNonTypeEvaluation().marshal(this, true);
} else { } else {
marshalType(arg.getTypeValue()); marshalType(arg.getTypeValue());
@ -122,6 +122,12 @@ class SignatureBuilder implements ITypeMarshalBuffer {
fBuffer.append(value); fBuffer.append(value);
} }
@Override
public void putShort(short value) {
appendSeparator();
fBuffer.append(value);
}
@Override @Override
public void putInt(int value) { public void putInt(int value) {
appendSeparator(); appendSeparator();
@ -187,6 +193,11 @@ class SignatureBuilder implements ITypeMarshalBuffer {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public short getShort() throws CoreException {
throw new UnsupportedOperationException();
}
@Override @Override
public int getInt() throws CoreException { public int getInt() throws CoreException {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();

View file

@ -63,11 +63,11 @@ public class TypeOfDependentExpression implements ICPPUnknownType, ISerializable
@Override @Override
public void marshal(ITypeMarshalBuffer buffer) throws CoreException { public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
buffer.putByte(ITypeMarshalBuffer.DEPENDENT_EXPRESSION_TYPE); buffer.putShort(ITypeMarshalBuffer.DEPENDENT_EXPRESSION_TYPE);
buffer.marshalEvaluation(fEvaluation, false); buffer.marshalEvaluation(fEvaluation, false);
} }
public static IType unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException { public static IType unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
ISerializableEvaluation eval= buffer.unmarshalEvaluation(); ISerializableEvaluation eval= buffer.unmarshalEvaluation();
if (eval instanceof ICPPEvaluation) if (eval instanceof ICPPEvaluation)
return new TypeOfDependentExpression((ICPPEvaluation) eval); return new TypeOfDependentExpression((ICPPEvaluation) eval);

View file

@ -85,6 +85,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalFunctionSet;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalID; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalID;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalInitList; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalInitList;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalMemberAccess; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalMemberAccess;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalParameterPack;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalTypeId; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalTypeId;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalUnary; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalUnary;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalUnaryTypeID; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalUnaryTypeID;
@ -375,6 +376,14 @@ public class CPPCompositesFactory extends AbstractCompositeFactory {
e= new EvalMemberAccess(a2, e.getOwnerValueCategory(), b2, e.isPointerDeref(), templateDefinition2); e= new EvalMemberAccess(a2, e.getOwnerValueCategory(), b2, e.isPointerDeref(), templateDefinition2);
return e; return e;
} }
if (eval instanceof EvalParameterPack) {
EvalParameterPack e = (EvalParameterPack) eval;
ICPPEvaluation a = e.getExpansionPattern();
ICPPEvaluation a2 = getCompositeEvaluation(a);
if (a != a2 || templateDefinition != templateDefinition2)
e = new EvalParameterPack(a2, templateDefinition2);
return e;
}
if (eval instanceof EvalTypeId) { if (eval instanceof EvalTypeId) {
EvalTypeId e= (EvalTypeId) eval; EvalTypeId e= (EvalTypeId) eval;
IType a = e.getInputType(); IType a = e.getInputType();
@ -535,6 +544,10 @@ public class CPPCompositesFactory extends AbstractCompositeFactory {
return new CompositeCPPTypedefSpecialization(this, (ICPPBinding) binding); return new CompositeCPPTypedefSpecialization(this, (ICPPBinding) binding);
} else if (binding instanceof ICPPUsingDeclaration) { } else if (binding instanceof ICPPUsingDeclaration) {
return new CompositeCPPUsingDeclarationSpecialization(this, (ICPPUsingDeclaration) binding); return new CompositeCPPUsingDeclarationSpecialization(this, (ICPPUsingDeclaration) binding);
} else if (binding instanceof ICPPEnumeration) {
return new CompositeCPPEnumerationSpecialization(this, (ICPPEnumeration) binding);
} else if (binding instanceof IEnumerator) {
return new CompositeCPPEnumeratorSpecialization(this, (IEnumerator) binding);
} else { } else {
throw new CompositingNotImplementedError("Composite binding unavailable for " + binding + " " + binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$ throw new CompositingNotImplementedError("Composite binding unavailable for " + binding + " " + binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$
} }

View file

@ -0,0 +1,45 @@
/*******************************************************************************
* Copyright (c) 2013 Google, Inc and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sergey Prigogin (Google) - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.index.composite.cpp;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPEnumeration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
import org.eclipse.cdt.core.parser.util.ObjectMap;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateParameterMap;
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
class CompositeCPPEnumerationSpecialization extends CompositeCPPEnumeration implements ICPPSpecialization {
public CompositeCPPEnumerationSpecialization(ICompositesFactory cf, ICPPEnumeration delegate) {
super(cf, delegate);
}
@Override
public IBinding getSpecializedBinding() {
return TemplateInstanceUtil.getSpecializedBinding(cf, rbinding);
}
@Override
public ICPPTemplateParameterMap getTemplateParameterMap() {
IBinding owner= getOwner();
if (owner instanceof ICPPSpecialization) {
return ((ICPPSpecialization) owner).getTemplateParameterMap();
}
return CPPTemplateParameterMap.EMPTY;
}
@Override
@Deprecated
public ObjectMap getArgumentMap() {
return TemplateInstanceUtil.getArgumentMap(cf, rbinding);
}
}

View file

@ -0,0 +1,45 @@
/*******************************************************************************
* Copyright (c) 2013 Google, Inc and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sergey Prigogin (Google) - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.index.composite.cpp;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IEnumerator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
import org.eclipse.cdt.core.parser.util.ObjectMap;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateParameterMap;
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
class CompositeCPPEnumeratorSpecialization extends CompositeCPPEnumerator implements ICPPSpecialization {
public CompositeCPPEnumeratorSpecialization(ICompositesFactory cf, IEnumerator delegate) {
super(cf, delegate);
}
@Override
public IBinding getSpecializedBinding() {
return TemplateInstanceUtil.getSpecializedBinding(cf, rbinding);
}
@Override
public ICPPTemplateParameterMap getTemplateParameterMap() {
IBinding owner= getOwner();
if (owner instanceof ICPPSpecialization) {
return ((ICPPSpecialization) owner).getTemplateParameterMap();
}
return CPPTemplateParameterMap.EMPTY;
}
@Override
@Deprecated
public ObjectMap getArgumentMap() {
return TemplateInstanceUtil.getArgumentMap(cf, rbinding);
}
}

View file

@ -1006,9 +1006,9 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
IASTTranslationUnit ast= createAST(lang, codeReader, scanInfo, isSource, fASTOptions, ctx, pm); IASTTranslationUnit ast= createAST(lang, codeReader, scanInfo, isSource, fASTOptions, ctx, pm);
fStatistics.fParsingTime += System.currentTimeMillis() - start; fStatistics.fParsingTime += System.currentTimeMillis() - start;
if (ast != null) { if (ast != null) {
// Give the new AST-TU a chance to recognize its translation unit before it is written // Give the new AST a chance to recognize its translation unit before it is written
// to the index. // to the index.
( (ASTTranslationUnit)ast ).setOriginatingTranslationUnit( (ITranslationUnit)tu ); ((ASTTranslationUnit) ast).setOriginatingTranslationUnit((ITranslationUnit) tu);
writeToIndex(lang.getLinkageID(), ast, codeReader, ctx, pm); writeToIndex(lang.getLinkageID(), ast, codeReader, ctx, pm);
} }
} catch (CoreException e) { } catch (CoreException e) {

View file

@ -231,12 +231,13 @@ public class PDOM extends PlatformObject implements IPDOM {
* 138.0 - Constexpr functions, bug 395238. * 138.0 - Constexpr functions, bug 395238.
* 139.0 - More efficient and robust storage of types and template arguments, bug 395243. * 139.0 - More efficient and robust storage of types and template arguments, bug 395243.
* 140.0 - Enumerators with dependent values, bug 389009. * 140.0 - Enumerators with dependent values, bug 389009.
* 140.1 - Mechanism for tagging nodes with extended data, bug TODO * 140.1 - Mechanism for tagging nodes with extended data, bug 400020
* 141.0 - Storing enclosing template bindings for evaluations, bug 399829 * 141.0 - Storing enclosing template bindings for evaluations, bug 399829.
* 142.0 - Changed marshalling of evaluations to allow more than 15 evaluation kinds, bug 401479.
*/ */
private static final int MIN_SUPPORTED_VERSION= version(141, 0); private static final int MIN_SUPPORTED_VERSION= version(142, 0);
private static final int MAX_SUPPORTED_VERSION= version(141, Short.MAX_VALUE); private static final int MAX_SUPPORTED_VERSION= version(142, Short.MAX_VALUE);
private static final int DEFAULT_VERSION = version(141, 0); private static final int DEFAULT_VERSION = version(142, 0);
private static int version(int major, int minor) { private static int version(int major, int minor) {
return (major << 16) + minor; return (major << 16) + minor;
@ -465,10 +466,8 @@ public class PDOM extends PlatformObject implements IPDOM {
} }
public PDOMTagIndex getTagIndex() throws CoreException { public PDOMTagIndex getTagIndex() throws CoreException {
if (tagIndex == null) if (tagIndex == null) {
{ tagIndex = new PDOMTagIndex(db, TAG_INDEX);
// tag index can only be stored in database versions 139.1 or greater
tagIndex = new PDOMTagIndex( db.getVersion() >= version( 139, 1 ) ? db : null, TAG_INDEX );
} }
return tagIndex; return tagIndex;
} }
@ -483,7 +482,7 @@ public class PDOM extends PlatformObject implements IPDOM {
} }
/** /**
* Returns the index of files containg unresolved includes. * Returns the index of files containing unresolved includes.
*/ */
public BTree getIndexOfFilesWithUnresolvedIncludes() throws CoreException { public BTree getIndexOfFilesWithUnresolvedIncludes() throws CoreException {
if (indexOfFiledWithUnresolvedIncludes == null) { if (indexOfFiledWithUnresolvedIncludes == null) {

View file

@ -4,6 +4,9 @@
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Eidsness - Initial implementation
*/ */
package org.eclipse.cdt.internal.core.pdom.db; package org.eclipse.cdt.internal.core.pdom.db;
@ -14,27 +17,25 @@ import java.util.Map;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
/** /**
* A container for storing a set of strings in the Database. The container allows only one * A container for storing a set of strings in the Database. The container allows only one instance of each
* instance of each string to be stored. * string to be stored.
* <p> * <p>
* This implementation should only be used when the set is expected to be small. It uses a * This implementation should only be used when the set is expected to be small. It uses a singly linked list
* singly linked list for storing strings in Database. Which means that a linear lookup is needed * for storing strings in Database. Which means that a linear lookup is needed to find strings in the list. An
* to find strings in the list. An in-memory, lazily-loaded, cache is provided so the list will * in-memory, lazily-loaded, cache is provided so the list will only be fully retrieved once in the lifetime
* only be fully retrieved once in the lifetime of this instance. A BTree will be more efficient * of this instance. A BTree will be more efficient for larger sets.
* for larger sets.
*/ */
public class PDOMStringSet public class PDOMStringSet {
{
private final Database db; private final Database db;
private long ptr; private long ptr;
private long head; private long head;
private long loaded; private long loaded;
// A lazily initialized, in-memory cache that maps a persisted string to its storage record.
private Map<String, Long> lazyCache; private Map<String, Long> lazyCache;
public PDOMStringSet( Database db, long ptr ) throws CoreException public PDOMStringSet(Database db, long ptr) throws CoreException {
{
this.db = db; this.db = db;
this.ptr = ptr; this.ptr = ptr;
@ -42,119 +43,107 @@ public class PDOMStringSet
loaded = 0; loaded = 0;
} }
public void clearCaches() public void clearCaches() {
{
head = 0; head = 0;
loaded = 0; loaded = 0;
if( lazyCache != null ) if (lazyCache != null)
lazyCache = null; lazyCache = null;
} }
private long getHead() throws CoreException private long getHead() throws CoreException {
{ if (head == 0)
if( head == 0 ) head = db.getRecPtr(ptr);
head = db.getRecPtr( ptr );
return head; return head;
} }
// A simple enum describing the type of the information that is stored in the Database. Each // A simple enum describing the type of the information that is stored in the Database. Each
// enumerator represents a single field in the persistent structure and is able to answer its // enumerator represents a single field in the persistent structure and is able to answer its
// offset in that structure. // offset in that structure.
private static enum NodeType private static enum NodeType {
{ Next, Item, _last;
Next,
Item,
_last;
// NOTE: All fields are pointers, if that changes then these initializations will need // NOTE: All fields are pointers, if that changes then these initializations will need
// to be updated. // to be updated.
public final long offset = ordinal() * Database.PTR_SIZE; public final long offset = ordinal() * Database.PTR_SIZE;
public static final int sizeof = (int)_last.offset; public static final int sizeof = (int) _last.offset;
/** Return the value of the pointer stored in this field in the given instance. */ /** Return the value of the pointer stored in this field in the given instance. */
public long get( Database db, long instance ) throws CoreException public long get(Database db, long instance) throws CoreException {
{ return db.getRecPtr(instance + offset);
return db.getRecPtr( instance + offset );
} }
/** Store the given pointer into this field in the given instance. */ /** Store the given pointer into this field in the given instance. */
public void put( Database db, long instance, long value ) throws CoreException public void put(Database db, long instance, long value) throws CoreException {
{ db.putRecPtr(instance + offset, value);
db.putRecPtr( instance + offset, value );
} }
} }
/** /**
* Adds the given string to the receiving set. May cause the entire list to be loaded from the * Adds the given string to the receiving set. May cause the entire list to be loaded from the Database
* Database while testing for uniqueness. Returns the record of the string that was inserted into * while testing for uniqueness. Returns the record of the string that was inserted into the list.
* the list.
*/ */
public long add( String str ) throws CoreException public long add(String str) throws CoreException {
{ long record = find(str);
long record = find( str ); if (record != 0)
if( record != 0 )
return record; return record;
IString string = db.newString( str ); IString string = db.newString(str);
record = string.getRecord(); record = string.getRecord();
long new_node = db.malloc( NodeType.sizeof ); long new_node = db.malloc(NodeType.sizeof);
NodeType.Next.put( db, new_node, getHead() ); NodeType.Next.put(db, new_node, getHead());
NodeType.Item.put( db, new_node, record ); NodeType.Item.put(db, new_node, record);
if( lazyCache == null ) if (lazyCache == null)
lazyCache = new HashMap<String, Long>(); lazyCache = new HashMap<String, Long>();
lazyCache.put( str, record ); lazyCache.put(str, record);
// If the Database has already been partially searched, then the loaded pointer will be after the // If the Database has already been partially searched, then the loaded pointer will be after the
// head. Since we've already put this new record into the lazy cache, there is no reason to try to // head. Since we've already put this new record into the lazy cache, there is no reason to try to
// load it again. We put the new node at the start of the list so that it will be before the loaded // load it again. We put the new node at the start of the list so that it will be before the loaded
// pointer. // pointer.
head = new_node; head = new_node;
if( loaded == 0 ) if (loaded == 0)
loaded = new_node; loaded = new_node;
db.putRecPtr( ptr, new_node ); db.putRecPtr(ptr, new_node);
return record; return record;
} }
/** /**
* Search for the given string in the receiver. This could cause the entire list to be loaded from * Search for the given string in the receiver. This could cause the entire list to be loaded from the
* the Database. The results are cached, so the list will only be loaded one time during the lifetime * Database. The results are cached, so the list will only be loaded one time during the lifetime of this
* of this instance. Returns the record of the String. * instance. Returns the record of the String.
*/ */
public long find( String str ) throws CoreException public long find(String str) throws CoreException {
{ if (lazyCache != null) {
if( lazyCache != null ) Long l = lazyCache.get(str);
{ if (l != null)
Long l = lazyCache.get( str );
if( l != null )
return l.longValue(); return l.longValue();
} }
// if there is nothing in the Database, then there is nothing to load // if there is nothing in the Database, then there is nothing to load
if( getHead() == 0 ) if (getHead() == 0)
return 0; return 0;
// otherwise prepare the cache for the data that is about to be loaded // otherwise prepare the cache for the data that is about to be loaded
if( lazyCache == null ) if (lazyCache == null)
lazyCache = new HashMap<String, Long>(); lazyCache = new HashMap<String, Long>();
// if nothing has been loaded, then start loading with the head node, otherwise continue // if nothing has been loaded, then start loading with the head node, otherwise continue
// loading from whatever is after the last loaded node // loading from whatever is after the last loaded node
long curr = loaded == 0 ? getHead() : NodeType.Next.get( db, loaded ); long curr = loaded == 0 ? getHead() : NodeType.Next.get(db, loaded);
while( curr != 0 ) while (curr != 0) {
{ long next = NodeType.Next.get(db, curr);
long next = NodeType.Next.get( db, curr ); long item = NodeType.Item.get(db, curr);
long item = NodeType.Item.get( db, curr );
IString string = db.getString( item ); IString string = db.getString(item);
// put the value into the cache // put the value into the cache
lazyCache.put( string.getString(), Long.valueOf( item ) ); lazyCache.put(string.getString(), Long.valueOf(item));
// return immediately if this is the target // return immediately if this is the target
if( string.compare( str, true ) == 0 ) if (string.compare(str, true) == 0)
return item; return item;
// otherwise keep looking // otherwise keep looking
@ -168,31 +157,27 @@ public class PDOMStringSet
/** /**
* Return a pointer to the record of the String that was removed. * Return a pointer to the record of the String that was removed.
*/ */
public long remove( String str ) throws CoreException public long remove(String str) throws CoreException {
{ if (lazyCache != null)
if( lazyCache != null ) lazyCache.remove(str);
lazyCache.remove( str );
long prev = 0; long prev = 0;
long curr = getHead(); long curr = getHead();
while( curr != 0 ) while (curr != 0) {
{ long next = NodeType.Next.get(db, curr);
long next = NodeType.Next.get( db, curr ); long item = NodeType.Item.get(db, curr);
long item = NodeType.Item.get( db, curr );
IString string = db.getString( item ); IString string = db.getString(item);
if( string.compare( str, true ) == 0 ) if (string.compare(str, true) == 0) {
{ if (head != curr)
if( head != curr ) NodeType.Next.put(db, prev, next);
NodeType.Next.put( db, prev, next ); else {
else db.putRecPtr(ptr, next);
{
db.putRecPtr( ptr, next );
head = next; head = next;
} }
db.free( curr ); db.free(curr);
return item; return item;
} }

View file

@ -35,10 +35,10 @@ import org.eclipse.core.runtime.CoreException;
*/ */
public final class TypeMarshalBuffer implements ITypeMarshalBuffer { public final class TypeMarshalBuffer implements ITypeMarshalBuffer {
public static final byte[] EMPTY= { 0, 0, 0, 0, 0, 0 }; public static final byte[] EMPTY= { 0, 0, 0, 0, 0, 0 };
public static final byte NULL_TYPE= 0; public static final byte NULL_TYPE = 0x00;
public static final byte INDIRECT_TYPE= (byte) -1; public static final byte INDIRECT_TYPE = 0x1F;
public static final byte BINDING_TYPE= (byte) -2; public static final byte BINDING_TYPE = 0x1E;
public static final byte UNSTORABLE_TYPE= (byte) -3; public static final byte UNSTORABLE_TYPE = 0x1D;
public static final IType UNSTORABLE_TYPE_PROBLEM = new ProblemType(ISemanticProblem.TYPE_NOT_PERSISTED); public static final IType UNSTORABLE_TYPE_PROBLEM = new ProblemType(ISemanticProblem.TYPE_NOT_PERSISTED);
@ -83,13 +83,13 @@ public final class TypeMarshalBuffer implements ITypeMarshalBuffer {
if (binding instanceof ISerializableType) { if (binding instanceof ISerializableType) {
((ISerializableType) binding).marshal(this); ((ISerializableType) binding).marshal(this);
} else if (binding == null) { } else if (binding == null) {
putByte(NULL_TYPE); putShort(NULL_TYPE);
} else { } else {
PDOMNode pb= fLinkage.addTypeBinding(binding); PDOMNode pb= fLinkage.addTypeBinding(binding);
if (pb == null) { if (pb == null) {
putByte(UNSTORABLE_TYPE); putShort(UNSTORABLE_TYPE);
} else { } else {
putByte(BINDING_TYPE); putShort(BINDING_TYPE);
putByte((byte) 0); putByte((byte) 0);
putRecordPointer(pb.getRecord()); putRecordPointer(pb.getRecord());
} }
@ -98,19 +98,17 @@ public final class TypeMarshalBuffer implements ITypeMarshalBuffer {
@Override @Override
public IBinding unmarshalBinding() throws CoreException { public IBinding unmarshalBinding() throws CoreException {
if (fPos >= fBuffer.length) int oldPos = fPos;
throw unmarshallingError(); short firstBytes = getShort();
if (firstBytes == BINDING_TYPE) {
byte firstByte= fBuffer[fPos]; fPos += 1;
if (firstByte == BINDING_TYPE) {
fPos += 2;
long rec= getRecordPointer(); long rec= getRecordPointer();
return (IBinding) fLinkage.getNode(rec); return (IBinding) fLinkage.getNode(rec);
} else if (firstByte == NULL_TYPE || firstByte == UNSTORABLE_TYPE) { } else if (firstBytes == NULL_TYPE || firstBytes == UNSTORABLE_TYPE) {
fPos++;
return null; return null;
} }
fPos = oldPos; // fLinkage.unmarshalBinding() will read firstBytes again
return fLinkage.unmarshalBinding(this); return fLinkage.unmarshalBinding(this);
} }
@ -119,40 +117,37 @@ public final class TypeMarshalBuffer implements ITypeMarshalBuffer {
if (type instanceof ISerializableType) { if (type instanceof ISerializableType) {
((ISerializableType) type).marshal(this); ((ISerializableType) type).marshal(this);
} else if (type == null) { } else if (type == null) {
putByte(NULL_TYPE); putShort(NULL_TYPE);
} else if (type instanceof IBinding) { } else if (type instanceof IBinding) {
marshalBinding((IBinding) type); marshalBinding((IBinding) type);
} else { } else {
assert false : "Cannot serialize " + ASTTypeUtil.getType(type) + " (" + type.getClass().getName() + ")"; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ assert false : "Cannot serialize " + ASTTypeUtil.getType(type) + " (" + type.getClass().getName() + ")"; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
putByte(UNSTORABLE_TYPE); putShort(UNSTORABLE_TYPE);
} }
} }
@Override @Override
public IType unmarshalType() throws CoreException { public IType unmarshalType() throws CoreException {
if (fPos >= fBuffer.length) int oldPos = fPos;
throw unmarshallingError(); short firstBytes = getShort();
if (firstBytes == BINDING_TYPE) {
byte firstByte= fBuffer[fPos]; fPos += 1;
if (firstByte == BINDING_TYPE) {
fPos += 2;
long rec= getRecordPointer(); long rec= getRecordPointer();
return (IType) fLinkage.getNode(rec); return (IType) fLinkage.getNode(rec);
} else if (firstByte == NULL_TYPE) { } else if (firstBytes == NULL_TYPE) {
fPos++;
return null; return null;
} else if (firstByte == UNSTORABLE_TYPE) { } else if (firstBytes == UNSTORABLE_TYPE) {
fPos++;
return UNSTORABLE_TYPE_PROBLEM; return UNSTORABLE_TYPE_PROBLEM;
} }
fPos = oldPos; // fLinkage.unmarshalType() will read firstBytes again
return fLinkage.unmarshalType(this); return fLinkage.unmarshalType(this);
} }
@Override @Override
public void marshalEvaluation(ISerializableEvaluation eval, boolean includeValues) throws CoreException { public void marshalEvaluation(ISerializableEvaluation eval, boolean includeValues) throws CoreException {
if (eval == null) { if (eval == null) {
putByte(NULL_TYPE); putShort(NULL_TYPE);
} else { } else {
eval.marshal(this, includeValues); eval.marshal(this, includeValues);
} }
@ -160,23 +155,15 @@ public final class TypeMarshalBuffer implements ITypeMarshalBuffer {
@Override @Override
public ISerializableEvaluation unmarshalEvaluation() throws CoreException { public ISerializableEvaluation unmarshalEvaluation() throws CoreException {
if (fPos >= fBuffer.length)
throw unmarshallingError();
byte firstByte= fBuffer[fPos];
if (firstByte == NULL_TYPE) {
fPos++;
return null;
}
return fLinkage.unmarshalEvaluation(this); return fLinkage.unmarshalEvaluation(this);
} }
@Override @Override
public void marshalValue(IValue value) throws CoreException { public void marshalValue(IValue value) throws CoreException {
if (value instanceof Value) { if (value instanceof Value) {
((Value) value).marshall(this); ((Value) value).marshal(this);
} else { } else {
putByte(NULL_TYPE); putShort(NULL_TYPE);
} }
} }
@ -191,7 +178,7 @@ public final class TypeMarshalBuffer implements ITypeMarshalBuffer {
@Override @Override
public void marshalTemplateArgument(ICPPTemplateArgument arg) throws CoreException { public void marshalTemplateArgument(ICPPTemplateArgument arg) throws CoreException {
if (arg.isNonTypeValue()) { if (arg.isNonTypeValue()) {
putByte(VALUE); putShort(VALUE);
arg.getNonTypeEvaluation().marshal(this, true); arg.getNonTypeEvaluation().marshal(this, true);
} else { } else {
final IType typeValue = arg.getTypeValue(); final IType typeValue = arg.getTypeValue();
@ -207,11 +194,12 @@ public final class TypeMarshalBuffer implements ITypeMarshalBuffer {
@Override @Override
public ICPPTemplateArgument unmarshalTemplateArgument() throws CoreException { public ICPPTemplateArgument unmarshalTemplateArgument() throws CoreException {
int firstByte= getByte(); int oldPos = fPos;
if (firstByte == VALUE) { short firstBytes = getShort();
if (firstBytes == VALUE) {
return new CPPTemplateNonTypeArgument((ICPPEvaluation) unmarshalEvaluation(), null); return new CPPTemplateNonTypeArgument((ICPPEvaluation) unmarshalEvaluation(), null);
} else { } else {
fPos--; fPos = oldPos;
IType type = unmarshalType(); IType type = unmarshalType();
IType originalType = unmarshalType(); IType originalType = unmarshalType();
if (originalType == null || originalType == UNSTORABLE_TYPE_PROBLEM) if (originalType == null || originalType == UNSTORABLE_TYPE_PROBLEM)
@ -284,6 +272,11 @@ public final class TypeMarshalBuffer implements ITypeMarshalBuffer {
return result; return result;
} }
@Override
public void putShort(short value) {
putInt(value);
}
@Override @Override
public void putInt(int value) { public void putInt(int value) {
do { do {
@ -306,6 +299,14 @@ public final class TypeMarshalBuffer implements ITypeMarshalBuffer {
} while (value != 0); } while (value != 0);
} }
@Override
public short getShort() throws CoreException {
int result = getInt();
if (result > Short.MAX_VALUE)
unmarshallingError();
return (short) result;
}
@Override @Override
public int getInt() throws CoreException { public int getInt() throws CoreException {
int b = getByte(); int b = getByte();

View file

@ -69,13 +69,14 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IPDOMBinding
if (adapter.isAssignableFrom(PDOMBinding.class)) if (adapter.isAssignableFrom(PDOMBinding.class))
return this; return this;
// Any PDOMBinding can have a persistent tag. These tags should be deleted when the PDOMBinding // Any PDOMBinding can have a persistent tag. These tags should be deleted when
// is deleted. However, PDOMBinding's don't get deleted, so there is no way to trigger deleting // the PDOMBinding is deleted. However, PDOMBinding's don't get deleted, so there is no way
// of the tags. If the implementation is changed so that PDOMBindings do get deleted, then call: // to trigger deleting of the tags. If the implementation is changed so that PDOMBindings
// PDOMTagIndex.setTags( getPDOM(), pdomBinding.record, Collections.<ITag>emptyList() ); // do get deleted, then it should call:
// PDOMTagIndex.setTags(getPDOM(), pdomBinding.record, Collections.<ITag>emptyList());
// to clear out all tags for the binding. // to clear out all tags for the binding.
if (adapter == ITagReader.class) if (adapter.isAssignableFrom(ITagReader.class))
return new PDOMTaggable( getPDOM(), getRecord() ); return new PDOMTaggable(getPDOM(), getRecord());
return null; return null;
} }

View file

@ -99,9 +99,9 @@ class PDOMCLinkage extends PDOMLinkage implements IIndexCBindingConstants {
getPDOM().putCachedResult(inputBinding, pdomBinding); getPDOM().putCachedResult(inputBinding, pdomBinding);
} }
// Synchronize the tags associated with the persistent binding to match the set that is // Synchronize the tags associated with the persistent binding to match the set that
// associated with the input binding. // is associated with the input binding.
TagManager.getInstance().syncTags( pdomBinding, inputBinding ); TagManager.getInstance().syncTags(pdomBinding, inputBinding);
return pdomBinding; return pdomBinding;
} }
@ -114,9 +114,10 @@ class PDOMCLinkage extends PDOMLinkage implements IIndexCBindingConstants {
pdomBinding.update(this, fromBinding); pdomBinding.update(this, fromBinding);
// Update the tags based on the tags from the new binding. This was in PDOMBinding.update, but // Update the tags based on the tags from the new binding. This cannot be done in
// I found that not all subclasses (e.g., PDOMCPPFunction) call the parent implementation. // PDOMBinding.update, because not all subclasses (e.g., PDOMCFunction) call
TagManager.getInstance().syncTags( pdomBinding, fromBinding ); // the superclass implementation.
TagManager.getInstance().syncTags(pdomBinding, fromBinding);
} }
return pdomBinding; return pdomBinding;
} }
@ -344,23 +345,23 @@ class PDOMCLinkage extends PDOMLinkage implements IIndexCBindingConstants {
@Override @Override
public IType unmarshalType(ITypeMarshalBuffer buffer) throws CoreException { public IType unmarshalType(ITypeMarshalBuffer buffer) throws CoreException {
int firstByte= buffer.getByte(); short firstBytes= buffer.getShort();
switch((firstByte & ITypeMarshalBuffer.KIND_MASK)) { switch((firstBytes & ITypeMarshalBuffer.KIND_MASK)) {
case ITypeMarshalBuffer.ARRAY_TYPE: case ITypeMarshalBuffer.ARRAY_TYPE:
return CArrayType.unmarshal(firstByte, buffer); return CArrayType.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.BASIC_TYPE: case ITypeMarshalBuffer.BASIC_TYPE:
return CBasicType.unmarshal(firstByte, buffer); return CBasicType.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.CVQUALIFIER_TYPE: case ITypeMarshalBuffer.CVQUALIFIER_TYPE:
return CQualifierType.unmarshal(firstByte, buffer); return CQualifierType.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.FUNCTION_TYPE: case ITypeMarshalBuffer.FUNCTION_TYPE:
return CFunctionType.unmarshal(firstByte, buffer); return CFunctionType.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.POINTER_TYPE: case ITypeMarshalBuffer.POINTER_TYPE:
return CPointerType.unmarshal(firstByte, buffer); return CPointerType.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.PROBLEM_TYPE: case ITypeMarshalBuffer.PROBLEM_TYPE:
return ProblemType.unmarshal(firstByte, buffer); return ProblemType.unmarshal(firstBytes, buffer);
} }
throw new CoreException(CCorePlugin.createStatus("Cannot unmarshal a type, first byte=" + firstByte)); //$NON-NLS-1$ throw new CoreException(CCorePlugin.createStatus("Cannot unmarshal a type, first bytes=" + firstBytes)); //$NON-NLS-1$
} }
@Override @Override

View file

@ -111,6 +111,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalFunctionSet;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalID; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalID;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalInitList; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalInitList;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalMemberAccess; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalMemberAccess;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalParameterPack;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalTypeId; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalTypeId;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalUnary; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalUnary;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalUnaryTypeID; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalUnaryTypeID;
@ -122,6 +123,7 @@ import org.eclipse.cdt.internal.core.pdom.WritablePDOM;
import org.eclipse.cdt.internal.core.pdom.db.BTree; import org.eclipse.cdt.internal.core.pdom.db.BTree;
import org.eclipse.cdt.internal.core.pdom.db.Database; import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.cdt.internal.core.pdom.db.IBTreeComparator; import org.eclipse.cdt.internal.core.pdom.db.IBTreeComparator;
import org.eclipse.cdt.internal.core.pdom.db.TypeMarshalBuffer;
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner; import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMASTAdapter; import org.eclipse.cdt.internal.core.pdom.dom.PDOMASTAdapter;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding; import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
@ -360,9 +362,9 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
addImplicitMethods(pdomBinding, (ICPPClassType) binding, fromName); addImplicitMethods(pdomBinding, (ICPPClassType) binding, fromName);
} }
// Synchronize the tags associated with the persistent binding to match the set that is // Synchronize the tags associated with the persistent binding to match
// associated with the input binding. // the set that is associated with the input binding.
TagManager.getInstance().syncTags( pdomBinding, inputBinding ); TagManager.getInstance().syncTags(pdomBinding, inputBinding);
} }
} catch (DOMException e) { } catch (DOMException e) {
throw new CoreException(Util.createStatus(e)); throw new CoreException(Util.createStatus(e));
@ -376,9 +378,10 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
pdomBinding.update(this, fromBinding); pdomBinding.update(this, fromBinding);
// Update the tags based on the tags from the new binding. This was in PDOMBinding.update, but // Update the tags based on the tags from the new binding. This cannot be done in
// I found that not all subclasses (e.g., PDOMCPPFunction) call the parent implementation. // PDOMBinding.update, because not all subclasses (e.g., PDOMCPPFunction) call
TagManager.getInstance().syncTags( pdomBinding, fromBinding ); // the superclass implementation.
TagManager.getInstance().syncTags(pdomBinding, fromBinding);
} }
return pdomBinding; return pdomBinding;
@ -1105,94 +1108,98 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
@Override @Override
public IType unmarshalType(ITypeMarshalBuffer buffer) throws CoreException { public IType unmarshalType(ITypeMarshalBuffer buffer) throws CoreException {
int firstByte= buffer.getByte(); short firstBytes= buffer.getShort();
switch ((firstByte & ITypeMarshalBuffer.KIND_MASK)) { switch ((firstBytes & ITypeMarshalBuffer.KIND_MASK)) {
case ITypeMarshalBuffer.ARRAY_TYPE: case ITypeMarshalBuffer.ARRAY_TYPE:
return CPPArrayType.unmarshal(firstByte, buffer); return CPPArrayType.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.BASIC_TYPE: case ITypeMarshalBuffer.BASIC_TYPE:
return CPPBasicType.unmarshal(firstByte, buffer); return CPPBasicType.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.CVQUALIFIER_TYPE: case ITypeMarshalBuffer.CVQUALIFIER_TYPE:
return CPPQualifierType.unmarshal(firstByte, buffer); return CPPQualifierType.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.FUNCTION_TYPE: case ITypeMarshalBuffer.FUNCTION_TYPE:
return CPPFunctionType.unmarshal(firstByte, buffer); return CPPFunctionType.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.POINTER_TYPE: case ITypeMarshalBuffer.POINTER_TYPE:
return CPPPointerType.unmarshal(firstByte, buffer); return CPPPointerType.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.PROBLEM_TYPE: case ITypeMarshalBuffer.PROBLEM_TYPE:
return ProblemType.unmarshal(firstByte, buffer); return ProblemType.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.REFERENCE_TYPE: case ITypeMarshalBuffer.REFERENCE_TYPE:
return CPPReferenceType.unmarshal(firstByte, buffer); return CPPReferenceType.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.PACK_EXPANSION_TYPE: case ITypeMarshalBuffer.PACK_EXPANSION_TYPE:
return CPPParameterPackType.unmarshal(firstByte, buffer); return CPPParameterPackType.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.POINTER_TO_MEMBER_TYPE: case ITypeMarshalBuffer.POINTER_TO_MEMBER_TYPE:
return CPPPointerToMemberType.unmarshal(firstByte, buffer); return CPPPointerToMemberType.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.DEPENDENT_EXPRESSION_TYPE: case ITypeMarshalBuffer.DEPENDENT_EXPRESSION_TYPE:
return TypeOfDependentExpression.unmarshal(firstByte, buffer); return TypeOfDependentExpression.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.UNKNOWN_MEMBER: case ITypeMarshalBuffer.UNKNOWN_MEMBER:
IBinding binding= CPPUnknownMember.unmarshal(getPDOM(), firstByte, buffer); IBinding binding= CPPUnknownMember.unmarshal(getPDOM(), firstBytes, buffer);
if (binding instanceof IType) if (binding instanceof IType)
return (IType) binding; return (IType) binding;
break; break;
case ITypeMarshalBuffer.UNKNOWN_MEMBER_CLASS_INSTANCE: case ITypeMarshalBuffer.UNKNOWN_MEMBER_CLASS_INSTANCE:
return CPPUnknownClassInstance.unmarshal(getPDOM(), firstByte, buffer); return CPPUnknownClassInstance.unmarshal(getPDOM(), firstBytes, buffer);
case ITypeMarshalBuffer.DEFERRED_CLASS_INSTANCE: case ITypeMarshalBuffer.DEFERRED_CLASS_INSTANCE:
return CPPDeferredClassInstance.unmarshal(getPDOM(), firstByte, buffer); return CPPDeferredClassInstance.unmarshal(getPDOM(), firstBytes, buffer);
case ITypeMarshalBuffer.ALIAS_TEMPLATE: case ITypeMarshalBuffer.ALIAS_TEMPLATE:
return CPPAliasTemplateInstance.unmarshal(firstByte, buffer); return CPPAliasTemplateInstance.unmarshal(firstBytes, buffer);
} }
throw new CoreException(CCorePlugin.createStatus("Cannot unmarshal a type, first byte=" + firstByte)); //$NON-NLS-1$ throw new CoreException(CCorePlugin.createStatus("Cannot unmarshal a type, first bytes=" + firstBytes)); //$NON-NLS-1$
} }
@Override @Override
public IBinding unmarshalBinding(ITypeMarshalBuffer buffer) throws CoreException { public IBinding unmarshalBinding(ITypeMarshalBuffer buffer) throws CoreException {
int firstByte= buffer.getByte(); short firstBytes= buffer.getShort();
switch ((firstByte & ITypeMarshalBuffer.KIND_MASK)) { switch ((firstBytes & ITypeMarshalBuffer.KIND_MASK)) {
case ITypeMarshalBuffer.UNKNOWN_MEMBER: case ITypeMarshalBuffer.UNKNOWN_MEMBER:
return CPPUnknownMember.unmarshal(getPDOM(), firstByte, buffer); return CPPUnknownMember.unmarshal(getPDOM(), firstBytes, buffer);
case ITypeMarshalBuffer.UNKNOWN_MEMBER_CLASS_INSTANCE: case ITypeMarshalBuffer.UNKNOWN_MEMBER_CLASS_INSTANCE:
return CPPUnknownClassInstance.unmarshal(getPDOM(), firstByte, buffer); return CPPUnknownClassInstance.unmarshal(getPDOM(), firstBytes, buffer);
case ITypeMarshalBuffer.DEFERRED_CLASS_INSTANCE: case ITypeMarshalBuffer.DEFERRED_CLASS_INSTANCE:
return CPPDeferredClassInstance.unmarshal(getPDOM(), firstByte, buffer); return CPPDeferredClassInstance.unmarshal(getPDOM(), firstBytes, buffer);
} }
throw new CoreException(CCorePlugin.createStatus("Cannot unmarshal a type, first byte=" + firstByte)); //$NON-NLS-1$ throw new CoreException(CCorePlugin.createStatus("Cannot unmarshal a type, first bytes=" + firstBytes)); //$NON-NLS-1$
} }
@Override @Override
public ISerializableEvaluation unmarshalEvaluation(ITypeMarshalBuffer buffer) throws CoreException { public ISerializableEvaluation unmarshalEvaluation(ITypeMarshalBuffer buffer) throws CoreException {
int firstByte= buffer.getByte(); short firstBytes= buffer.getShort();
switch ((firstByte & ITypeMarshalBuffer.KIND_MASK)) { if (firstBytes == TypeMarshalBuffer.NULL_TYPE)
return null;
switch ((firstBytes & ITypeMarshalBuffer.KIND_MASK)) {
case ITypeMarshalBuffer.EVAL_BINARY: case ITypeMarshalBuffer.EVAL_BINARY:
return EvalBinary.unmarshal(firstByte, buffer); return EvalBinary.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.EVAL_BINARY_TYPE_ID: case ITypeMarshalBuffer.EVAL_BINARY_TYPE_ID:
return EvalBinaryTypeId.unmarshal(firstByte, buffer); return EvalBinaryTypeId.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.EVAL_BINDING: case ITypeMarshalBuffer.EVAL_BINDING:
return EvalBinding.unmarshal(firstByte, buffer); return EvalBinding.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.EVAL_COMMA: case ITypeMarshalBuffer.EVAL_COMMA:
return EvalComma.unmarshal(firstByte, buffer); return EvalComma.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.EVAL_COMPOUND: case ITypeMarshalBuffer.EVAL_COMPOUND:
return EvalCompound.unmarshal(firstByte, buffer); return EvalCompound.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.EVAL_CONDITIONAL: case ITypeMarshalBuffer.EVAL_CONDITIONAL:
return EvalConditional.unmarshal(firstByte, buffer); return EvalConditional.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.EVAL_FIXED: case ITypeMarshalBuffer.EVAL_FIXED:
return EvalFixed.unmarshal(firstByte, buffer); return EvalFixed.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.EVAL_FUNCTION_CALL: case ITypeMarshalBuffer.EVAL_FUNCTION_CALL:
return EvalFunctionCall.unmarshal(firstByte, buffer); return EvalFunctionCall.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.EVAL_FUNCTION_SET: case ITypeMarshalBuffer.EVAL_FUNCTION_SET:
return EvalFunctionSet.unmarshal(firstByte, buffer); return EvalFunctionSet.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.EVAL_ID: case ITypeMarshalBuffer.EVAL_ID:
return EvalID.unmarshal(firstByte, buffer); return EvalID.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.EVAL_INIT_LIST: case ITypeMarshalBuffer.EVAL_INIT_LIST:
return EvalInitList.unmarshal(firstByte, buffer); return EvalInitList.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.EVAL_MEMBER_ACCESS: case ITypeMarshalBuffer.EVAL_MEMBER_ACCESS:
return EvalMemberAccess.unmarshal(firstByte, buffer); return EvalMemberAccess.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.EVAL_PARAMETER_PACK:
return EvalParameterPack.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.EVAL_TYPE_ID: case ITypeMarshalBuffer.EVAL_TYPE_ID:
return EvalTypeId.unmarshal(firstByte, buffer); return EvalTypeId.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.EVAL_UNARY: case ITypeMarshalBuffer.EVAL_UNARY:
return EvalUnary.unmarshal(firstByte, buffer); return EvalUnary.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.EVAL_UNARY_TYPE_ID: case ITypeMarshalBuffer.EVAL_UNARY_TYPE_ID:
return EvalUnaryTypeID.unmarshal(firstByte, buffer); return EvalUnaryTypeID.unmarshal(firstBytes, buffer);
} }
throw new CoreException(CCorePlugin.createStatus("Cannot unmarshal an evaluation, first byte=" + firstByte)); //$NON-NLS-1$ throw new CoreException(CCorePlugin.createStatus("Cannot unmarshal an evaluation, first bytes=" + firstBytes)); //$NON-NLS-1$
} }
} }

View file

@ -4,8 +4,10 @@
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Eidsness - Initial implementation
*/ */
package org.eclipse.cdt.internal.core.pdom.tag; package org.eclipse.cdt.internal.core.pdom.tag;
import java.util.Collections; import java.util.Collections;
@ -18,61 +20,67 @@ import org.eclipse.cdt.internal.core.pdom.db.BTree;
import org.eclipse.cdt.internal.core.pdom.db.IBTreeVisitor; import org.eclipse.cdt.internal.core.pdom.db.IBTreeVisitor;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
public class BTreeIterable<T> implements Iterable<T> public class BTreeIterable<T> implements Iterable<T> {
{ public static interface Descriptor<T> {
public static interface Descriptor<T> public int compare(long record) throws CoreException;
{
public int compare( long record ) throws CoreException; public T create(long record);
public T create( long record );
} }
private final BTree btree; private final BTree btree;
private final Descriptor<T> descriptor; private final Descriptor<T> descriptor;
public BTreeIterable( BTree btree, Descriptor<T> descriptor ) public BTreeIterable(BTree btree, Descriptor<T> descriptor) {
{
this.btree = btree; this.btree = btree;
this.descriptor = descriptor; this.descriptor = descriptor;
} }
@Override @Override
public Iterator<T> iterator() public Iterator<T> iterator() {
{
Visitor v = new Visitor(); Visitor v = new Visitor();
try { btree.accept( v ); } try {
catch( CoreException e ) { CCorePlugin.log( e ); return Collections.<T>emptyList().iterator(); } btree.accept(v);
return new BTreeIterator( v.records ); } catch (CoreException e) {
CCorePlugin.log(e);
return Collections.<T> emptyList().iterator();
}
return new BTreeIterator(v.records);
} }
private class Visitor implements IBTreeVisitor private class Visitor implements IBTreeVisitor {
{
public final List<Long> records = new LinkedList<Long>(); public final List<Long> records = new LinkedList<Long>();
@Override @Override
public int compare( long record ) throws CoreException public int compare(long record) throws CoreException {
{ return BTreeIterable.this.descriptor.compare(record);
return BTreeIterable.this.descriptor.compare( record );
} }
@Override @Override
public boolean visit( long record ) throws CoreException public boolean visit(long record) throws CoreException {
{ records.add(Long.valueOf(record));
records.add( Long.valueOf( record ) );
return true; return true;
} }
} }
private class BTreeIterator implements Iterator<T> private class BTreeIterator implements Iterator<T> {
{
private final Iterator<Long> records; private final Iterator<Long> records;
public BTreeIterator( Iterable<Long> records ) public BTreeIterator(Iterable<Long> records) {
{
this.records = records.iterator(); this.records = records.iterator();
} }
@Override public void remove() { } @Override
@Override public boolean hasNext() { return records.hasNext(); } public void remove() {
@Override public T next() { return BTreeIterable.this.descriptor.create( records.next() ); } }
@Override
public boolean hasNext() {
return records.hasNext();
}
@Override
public T next() {
return BTreeIterable.this.descriptor.create(records.next());
}
} }
} }

View file

@ -4,6 +4,9 @@
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Eidsness - Initial implementation
*/ */
package org.eclipse.cdt.internal.core.pdom.tag; package org.eclipse.cdt.internal.core.pdom.tag;
@ -15,185 +18,192 @@ import org.eclipse.cdt.internal.core.pdom.db.IBTreeComparator;
import org.eclipse.cdt.internal.core.pdom.db.IBTreeVisitor; import org.eclipse.cdt.internal.core.pdom.db.IBTreeVisitor;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
public class PDOMTag implements IWritableTag /**
{ * A container for storing tags in the PDOM. The storage format is as follows:
*
* <pre>
* PDOMTag
* {
* u4 node_record; # pointer to the node that is being tagged
* u4 tagger_id; # pointer to the string that identifies the tagger that
* # created this tag
* u4 data_len; # number of bytes stored in this tag's payload
* u1[]; # a buffer for storing the tag's payload
* };
* </pre>
*
* Each tag points to the contributing tagger id, the record that is being tagged. Finally, it stores a buffer
* for the tag's payload. The buffer is read and written by the contributor of the tag.
*/
public class PDOMTag implements IWritableTag {
private final Database db; private final Database db;
private final long record; private final long record;
private String taggerId; private String taggerId;
private int dataLen = -1; private int dataLen = -1;
private static enum Fields private static enum Fields {
{ Node, TaggerId, DataLen, Data;
Node,
TaggerId,
DataLen,
Data;
public final long offset = ordinal() * Database.PTR_SIZE; public final long offset = ordinal() * Database.PTR_SIZE;
public static int sizeof( int datalen ) { return (int)Data.offset + datalen; }
public long getRecPtr( Database db, long instance, long data_offset ) throws CoreException public static int sizeof(int datalen) {
{ return (int) Data.offset + datalen;
return db.getRecPtr( instance + offset + data_offset );
} }
public void putRecPtr( Database db, long instance, long data_offset, long value ) throws CoreException public long getRecPtr(Database db, long instance, long data_offset) throws CoreException {
{ return db.getRecPtr(instance + offset + data_offset);
db.putRecPtr( instance + offset + data_offset, value );
} }
public void put( Database db, long instance, long data_offset, byte value ) throws CoreException public void putRecPtr(Database db, long instance, long data_offset, long value)
{ throws CoreException {
db.putByte( instance + offset + data_offset, value ); db.putRecPtr(instance + offset + data_offset, value);
} }
public void put( Database db, long instance, byte[] data, long data_offset, int len ) throws CoreException public void put(Database db, long instance, long data_offset, byte value)
{ throws CoreException {
db.putBytes( instance + offset + data_offset, data, len ); db.putByte(instance + offset + data_offset, value);
} }
public byte getByte( Database db, long instance, long data_offset ) throws CoreException public void put(Database db, long instance, byte[] data, long data_offset, int len)
{ throws CoreException {
return db.getByte( instance + offset + data_offset ); db.putBytes(instance + offset + data_offset, data, len);
} }
public byte[] getBytes( Database db, long instance, long data_offset, int len ) throws CoreException public byte getByte(Database db, long instance, long data_offset) throws CoreException {
{ return db.getByte(instance + offset + data_offset);
}
public byte[] getBytes(Database db, long instance, long data_offset, int len)
throws CoreException {
byte[] data = new byte[len]; byte[] data = new byte[len];
db.getBytes( instance + offset + data_offset, data ); db.getBytes(instance + offset + data_offset, data);
return data; return data;
} }
public void put( Database db, long instance, long data_offset, int value ) throws CoreException public void put(Database db, long instance, long data_offset, int value)
{ throws CoreException {
db.putInt( instance + offset + data_offset, value ); db.putInt(instance + offset + data_offset, value);
} }
public int getInt( Database db, long instance, long data_offset ) throws CoreException public int getInt(Database db, long instance, long data_offset) throws CoreException {
{ return db.getInt(instance + offset + data_offset);
return db.getInt( instance + offset + data_offset );
} }
} }
public PDOMTag( Database db, long record ) public PDOMTag(Database db, long record) {
{
this.db = db; this.db = db;
this.record = record; this.record = record;
} }
public PDOMTag( Database db, int dataLen ) throws CoreException public PDOMTag(Database db, int dataLen) throws CoreException {
{
this.db = db; this.db = db;
this.record = db.malloc( Fields.sizeof( dataLen ) ); this.record = db.malloc(Fields.sizeof(dataLen));
this.dataLen = dataLen; this.dataLen = dataLen;
Fields.DataLen.put( db, record, 0, dataLen ); Fields.DataLen.put(db, record, 0, dataLen);
} }
public long getNode() throws CoreException public long getNode() throws CoreException {
{ return Fields.Node.getRecPtr(db, record, 0);
return Fields.Node.getRecPtr( db, record, 0 );
} }
@Override @Override
public String getTaggerId() public String getTaggerId() {
{ if (taggerId == null)
if( taggerId == null ) try {
try long taggerIdRecord = Fields.TaggerId.getRecPtr(db, record, 0);
{ taggerId = taggerIdRecord == 0L ? new String() : db.getString(taggerIdRecord)
long taggerIdRecord = Fields.TaggerId.getRecPtr( db, record, 0 ); .getString();
taggerId = taggerIdRecord == 0L ? new String() : db.getString( taggerIdRecord ).getString(); } catch (CoreException e) {
} CCorePlugin.log(e);
catch( CoreException e )
{
CCorePlugin.log( e );
} }
return taggerId; return taggerId;
} }
@Override @Override
public int getDataLen() public int getDataLen() {
{ if (dataLen < 0)
if( dataLen < 0 ) try {
try { dataLen = Fields.DataLen.getInt( db, record, 0 ); } dataLen = Fields.DataLen.getInt(db, record, 0);
catch( CoreException e ) { CCorePlugin.log( e ); return 0; } } catch (CoreException e) {
CCorePlugin.log(e);
return 0;
}
return dataLen; return dataLen;
} }
public long getRecord() { return record; } public long getRecord() {
return record;
}
/** /**
* Create and return a new PDOMTag that has the same node/taggerId as the receiver but with the * Create and return a new PDOMTag that has the same node/taggerId as the receiver but with the specified
* specified data. Return null on failure. * data. Return null on failure.
*/ */
public PDOMTag cloneWith( byte[] data ) throws CoreException public PDOMTag cloneWith(byte[] data) throws CoreException {
{
PDOMTag partialTag = null; PDOMTag partialTag = null;
try try {
{ long existing_node = Fields.Node.getRecPtr(db, record, 0);
long existing_node = Fields.Node.getRecPtr( db, record, 0 ); long existing_id = Fields.TaggerId.getRecPtr(db, record, 0);
long existing_id = Fields.TaggerId.getRecPtr( db, record, 0 );
partialTag = new PDOMTag( db, data.length ); partialTag = new PDOMTag(db, data.length);
Fields.Node.putRecPtr( db, partialTag.record, 0, existing_node ); Fields.Node.putRecPtr(db, partialTag.record, 0, existing_node);
Fields.TaggerId.putRecPtr( db, partialTag.record, 0, existing_id ); Fields.TaggerId.putRecPtr(db, partialTag.record, 0, existing_id);
if( partialTag.putBytes( 0, data, data.length ) ) if (partialTag.putBytes(0, data, data.length)) {
{
PDOMTag tag = partialTag; PDOMTag tag = partialTag;
partialTag = null; partialTag = null;
return tag; return tag;
} }
} } finally {
finally if (partialTag != null)
{
if( partialTag != null )
partialTag.delete(); partialTag.delete();
} }
return null; return null;
} }
public void delete() public void delete() {
{ if (db != null && record != 0)
if( db != null try {
&& record != 0 ) db.free(record);
try { db.free( record ); } } catch (CoreException e) {
catch( CoreException e ) { CCorePlugin.log( e ); } CCorePlugin.log(e);
}
} }
public static class BTreeComparator implements IBTreeComparator public static class BTreeComparator implements IBTreeComparator {
{
private final Database db; private final Database db;
public BTreeComparator( Database db ) { this.db = db; }
public BTreeComparator(Database db) {
this.db = db;
}
@Override @Override
public int compare(long record1, long record2) throws CoreException public int compare(long record1, long record2) throws CoreException {
{ if (record1 == record2)
if( record1 == record2 )
return 0; return 0;
long node1 = Fields.Node.getRecPtr( db, record1, 0 ); long node1 = Fields.Node.getRecPtr(db, record1, 0);
long node2 = Fields.Node.getRecPtr( db, record2, 0 ); long node2 = Fields.Node.getRecPtr(db, record2, 0);
if( node1 < node2 ) if (node1 < node2)
return -1; return -1;
if( node1 > node2 ) if (node1 > node2)
return 1; return 1;
long tagger1 = Fields.TaggerId.getRecPtr( db, record1, 0 ); long tagger1 = Fields.TaggerId.getRecPtr(db, record1, 0);
long tagger2 = Fields.TaggerId.getRecPtr( db, record2, 0 ); long tagger2 = Fields.TaggerId.getRecPtr(db, record2, 0);
if( tagger1 < tagger2 ) if (tagger1 < tagger2)
return -1; return -1;
if( tagger1 > tagger2 ) if (tagger1 > tagger2)
return 1; return 1;
return 0; return 0;
} }
} }
public static class BTreeVisitor implements IBTreeVisitor public static class BTreeVisitor implements IBTreeVisitor {
{
private final Database db; private final Database db;
private final long node2; private final long node2;
private final long tagger2; private final long tagger2;
@ -201,8 +211,7 @@ public class PDOMTag implements IWritableTag
public boolean hasResult = false; public boolean hasResult = false;
public long tagRecord = 0; public long tagRecord = 0;
public BTreeVisitor( Database db, long node2, long tagger2 ) public BTreeVisitor(Database db, long node2, long tagger2) {
{
this.db = db; this.db = db;
this.node2 = node2; this.node2 = node2;
this.tagger2 = tagger2; this.tagger2 = tagger2;
@ -210,16 +219,16 @@ public class PDOMTag implements IWritableTag
@Override @Override
public int compare(long record1) throws CoreException { public int compare(long record1) throws CoreException {
long node1 = Fields.Node.getRecPtr( db, record1, 0 ); long node1 = Fields.Node.getRecPtr(db, record1, 0);
if( node1 < node2 ) if (node1 < node2)
return -1; return -1;
if( node1 > node2 ) if (node1 > node2)
return 1; return 1;
long tagger1 = Fields.TaggerId.getRecPtr( db, record1, 0 ); long tagger1 = Fields.TaggerId.getRecPtr(db, record1, 0);
if( tagger1 < tagger2 ) if (tagger1 < tagger2)
return -1; return -1;
if( tagger1 > tagger2 ) if (tagger1 > tagger2)
return 1; return 1;
return 0; return 0;
@ -233,80 +242,82 @@ public class PDOMTag implements IWritableTag
} }
} }
public void setNode( long node ) throws CoreException public void setNode(long node) throws CoreException {
{ Fields.Node.putRecPtr(db, record, 0, node);
Fields.Node.putRecPtr( db, record, 0, node );
} }
public void setTaggerId( long idRecord ) throws CoreException public void setTaggerId(long idRecord) throws CoreException {
{ Fields.TaggerId.putRecPtr(db, record, 0, idRecord);
Fields.TaggerId.putRecPtr( db, record, 0, idRecord );
} }
private boolean isInBounds( int offset, int len ) private boolean isInBounds(int offset, int len) {
{
int data_len = getDataLen(); int data_len = getDataLen();
return offset >= 0 return offset >= 0 && offset < data_len && (offset + len) <= data_len;
&& offset < data_len
&& ( offset + len ) <= data_len;
} }
@Override @Override
public boolean putByte( int offset, byte data ) public boolean putByte(int offset, byte data) {
{ if (!isInBounds(offset, 1))
if( ! isInBounds( offset, 1 ) )
return false; return false;
try { Fields.Data.put( db, record, offset, data ); return true; } try {
catch( CoreException e ) { CCorePlugin.log( e ); return false; } Fields.Data.put(db, record, offset, data);
return true;
} catch (CoreException e) {
CCorePlugin.log(e);
return false;
}
} }
@Override @Override
public boolean putBytes( int offset, byte[] data, int len ) public boolean putBytes(int offset, byte[] data, int len) {
{
boolean fullWrite = len < 0; boolean fullWrite = len < 0;
if( fullWrite ) if (fullWrite)
len = data.length; len = data.length;
if( ! isInBounds( offset, len ) ) if (!isInBounds(offset, len))
return false; return false;
try try {
{ Fields.Data.put(db, record, data, offset, len);
Fields.Data.put( db, record, data, offset, len );
// if the new buffer replaces all of the existing one, then modify the receiver's stored length // if the new buffer replaces all of the existing one, then modify the receiver's stored length
int currLen = getDataLen(); int currLen = getDataLen();
if( fullWrite if (fullWrite && offset == 0 && currLen > len) {
&& offset == 0 Fields.DataLen.put(db, record, 0, len);
&& currLen > len )
{
Fields.DataLen.put( db, record, 0, len );
dataLen = len; dataLen = len;
} }
return true; return true;
} catch (CoreException e) {
CCorePlugin.log(e);
return false;
} }
catch( CoreException e ) { CCorePlugin.log( e ); return false; }
} }
@Override @Override
public int getByte( int offset ) public int getByte(int offset) {
{ if (!isInBounds(offset, 1))
if( ! isInBounds( offset, 1 ) ) return FAIL;
return Fail;
try { return Fields.Data.getByte( db, record, offset ); } try {
catch( CoreException e ) { CCorePlugin.log( e ); return Fail; } return Fields.Data.getByte(db, record, offset);
} catch (CoreException e) {
CCorePlugin.log(e);
return FAIL;
}
} }
@Override @Override
public byte[] getBytes( int offset, int len ) public byte[] getBytes(int offset, int len) {
{
len = len >= 0 ? len : getDataLen() - offset; len = len >= 0 ? len : getDataLen() - offset;
if( ! isInBounds( offset, len ) ) if (!isInBounds(offset, len))
return null; return null;
try { return Fields.Data.getBytes( db, record, offset, len ); } try {
catch( CoreException e ) { CCorePlugin.log( e ); return null; } return Fields.Data.getBytes(db, record, offset, len);
} catch (CoreException e) {
CCorePlugin.log(e);
return null;
}
} }
} }

View file

@ -4,6 +4,9 @@
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Eidsness - Initial implementation
*/ */
package org.eclipse.cdt.internal.core.pdom.tag; package org.eclipse.cdt.internal.core.pdom.tag;
@ -24,17 +27,13 @@ import org.eclipse.core.runtime.CoreException;
/** /**
* Not thread-safe. * Not thread-safe.
*/ */
public class PDOMTagIndex public class PDOMTagIndex {
{
private final Database db; private final Database db;
private final long ptr; private final long ptr;
private long rootRecord; private long rootRecord;
private static enum Fields private static enum Fields {
{ TaggerIds, Tags, _last;
TaggerIds,
Tags,
_last;
public final long offset = ordinal() * Database.PTR_SIZE; public final long offset = ordinal() * Database.PTR_SIZE;
public static int sizeof = _last.ordinal() * Database.PTR_SIZE; public static int sizeof = _last.ordinal() * Database.PTR_SIZE;
@ -43,89 +42,75 @@ public class PDOMTagIndex
private PDOMStringSet taggerIds; private PDOMStringSet taggerIds;
private BTree tags; private BTree tags;
public PDOMTagIndex( Database db, long ptr ) throws CoreException public PDOMTagIndex(Database db, long ptr) throws CoreException {
{
this.db = db; this.db = db;
this.ptr = ptr; this.ptr = ptr;
this.rootRecord = 0; this.rootRecord = 0;
} }
private long getFieldAddress( Fields field ) throws CoreException private long getFieldAddress(Fields field) throws CoreException {
{ if (rootRecord == 0)
if( rootRecord == 0 ) rootRecord = db.getRecPtr(ptr);
rootRecord = db.getRecPtr( ptr );
if( rootRecord == 0 ) if (rootRecord == 0) {
{ rootRecord = db.malloc(Fields.sizeof);
rootRecord = db.malloc( Fields.sizeof ); db.putRecPtr(ptr, rootRecord);
db.putRecPtr( ptr, rootRecord );
} }
return rootRecord + field.offset; return rootRecord + field.offset;
} }
private PDOMStringSet getTaggerIds() throws CoreException private PDOMStringSet getTaggerIds() throws CoreException {
{ if (taggerIds == null)
if( taggerIds == null ) taggerIds = new PDOMStringSet(db, getFieldAddress(Fields.TaggerIds));
taggerIds = new PDOMStringSet( db, getFieldAddress( Fields.TaggerIds ) );
return taggerIds; return taggerIds;
} }
private BTree getTagsBTree() throws CoreException private BTree getTagsBTree() throws CoreException {
{ if (tags == null)
if( tags == null ) tags = new BTree(db, getFieldAddress(Fields.Tags), new PDOMTag.BTreeComparator(db));
tags = new BTree( db, getFieldAddress( Fields.Tags ), new PDOMTag.BTreeComparator( db ) );
return tags; return tags;
} }
/** /**
* Return the record storing the specified tagger id. Create a new record if needed. * Return the record storing the specified tagger id. Create a new record if needed.
*/ */
private long getIdRecord( String taggerId, boolean createIfNeeded ) private long getIdRecord(String taggerId, boolean createIfNeeded) {
{
assert taggerId != null; assert taggerId != null;
assert ! taggerId.isEmpty(); assert !taggerId.isEmpty();
if( db == null if (db == null || taggerId == null || taggerId.isEmpty()
|| taggerId == null || (taggerIds == null && !createIfNeeded))
|| taggerId.isEmpty()
|| ( taggerIds == null && ! createIfNeeded ) )
return 0L; return 0L;
try try {
{ long record = getTaggerIds().find(taggerId);
long record = getTaggerIds().find( taggerId ); if (record == 0 && createIfNeeded)
if( record == 0 record = getTaggerIds().add(taggerId);
&& createIfNeeded )
record = getTaggerIds().add( taggerId );
return record; return record;
} } catch (CoreException e) {
catch( CoreException e ) CCorePlugin.log(e);
{
CCorePlugin.log( e );
} }
return 0L; return 0L;
} }
private IWritableTag createTag( long record, String id, int len ) private IWritableTag createTag(long record, String id, int len) {
{ if (db == null)
if( db == null )
return null; return null;
long idRecord = getIdRecord( id, true ); long idRecord = getIdRecord(id, true);
if( idRecord == 0L ) if (idRecord == 0L)
return null; return null;
try try {
{ PDOMTag tag = new PDOMTag(db, len);
PDOMTag tag = new PDOMTag( db, len ); tag.setNode(record);
tag.setNode( record ); tag.setTaggerId(idRecord);
tag.setTaggerId( idRecord );
// return the tag if it was properly inserted // return the tag if it was properly inserted
long inserted = getTagsBTree().insert( tag.getRecord() ); long inserted = getTagsBTree().insert(tag.getRecord());
if( inserted == tag.getRecord() ) if (inserted == tag.getRecord())
return tag; return tag;
// TODO check that the existing record has the same length // TODO check that the existing record has the same length
@ -133,58 +118,59 @@ public class PDOMTagIndex
// otherwise destroy this provisional one and return the tag that was actually inserted // otherwise destroy this provisional one and return the tag that was actually inserted
// TODO figure out what this case means // TODO figure out what this case means
tag.delete(); tag.delete();
return inserted == 0 ? null : new PDOMTag( db, inserted ); return inserted == 0 ? null : new PDOMTag(db, inserted);
} } catch (CoreException e) {
catch( CoreException e ) CCorePlugin.log(e);
{
CCorePlugin.log( e );
} }
return null; return null;
} }
private ITag getTag( long record, String id ) private ITag getTag(long record, String id) {
{ if (db == null)
if( db == null )
return null; return null;
long idRecord = getIdRecord( id, false ); long idRecord = getIdRecord(id, false);
if( idRecord == 0L ) if (idRecord == 0L)
return null; return null;
PDOMTag.BTreeVisitor v = new PDOMTag.BTreeVisitor( db, record, idRecord ); PDOMTag.BTreeVisitor v = new PDOMTag.BTreeVisitor(db, record, idRecord);
try { getTagsBTree().accept( v ); } try {
catch( CoreException e ) { CCorePlugin.log( e ); } getTagsBTree().accept(v);
} catch (CoreException e) {
return v.hasResult ? new PDOMTag( db, v.tagRecord ) : null; CCorePlugin.log(e);
} }
private Iterable<ITag> getTags( long binding_record ) return v.hasResult ? new PDOMTag(db, v.tagRecord) : null;
{ }
private Iterable<ITag> getTags(long binding_record) {
BTree btree = null; BTree btree = null;
try { btree = getTagsBTree(); } try {
catch( CoreException e ) { CCorePlugin.log( e ); return Collections.emptyList(); } btree = getTagsBTree();
} catch (CoreException e) {
CCorePlugin.log(e);
return Collections.emptyList();
}
final Long bindingRecord = Long.valueOf( binding_record ); final Long bindingRecord = Long.valueOf(binding_record);
return return new BTreeIterable<ITag>(btree, new BTreeIterable.Descriptor<ITag>() {
new BTreeIterable<ITag>(
btree,
new BTreeIterable.Descriptor<ITag>()
{
@Override public ITag create( long record ) { return new PDOMTag( db, record ); }
@Override @Override
public int compare( long test_record ) throws CoreException public ITag create(long record) {
{ return new PDOMTag(db, record);
long test_node = new PDOMTag( db, test_record ).getNode(); }
@Override
public int compare(long test_record) throws CoreException {
long test_node = new PDOMTag(db, test_record).getNode();
// -1 if record < key, 0 if record == key, 1 if record > key // -1 if record < key, 0 if record == key, 1 if record > key
return Long.valueOf( test_node ).compareTo( bindingRecord ); return Long.valueOf(test_node).compareTo(bindingRecord);
} }
} ); });
} }
private boolean setTags( long binding_record, Iterable<ITag> tags ) private boolean setTags(long binding_record, Iterable<ITag> tags) {
{
// There could be several tags for the given record in the database, one for each taggerId. We need // There could be several tags for the given record in the database, one for each taggerId. We need
// to delete all of those tags and replace them with given list. The incoming tags are first put // to delete all of those tags and replace them with given list. The incoming tags are first put
// into a map, indexed by their taggerId. Then we examine the btree of tags to find all tags for this // into a map, indexed by their taggerId. Then we examine the btree of tags to find all tags for this
@ -192,88 +178,92 @@ public class PDOMTagIndex
// updated in place, otherwise the tag needs to be deleted and recreated. // updated in place, otherwise the tag needs to be deleted and recreated.
final Map<String, ITag> newTags = new HashMap<String, ITag>(); final Map<String, ITag> newTags = new HashMap<String, ITag>();
for( ITag tag : tags ) for (ITag tag : tags) {
{ ITag dupTag = newTags.put(tag.getTaggerId(), tag);
ITag dupTag = newTags.put( tag.getTaggerId(), tag ); if (dupTag != null)
if( dupTag != null ) CCorePlugin
CCorePlugin.log( "Duplicate incoming tag for record " + binding_record + " from taggerId " + tag.getTaggerId() ); //$NON-NLS-1$ //$NON-NLS-2$ .log("Duplicate incoming tag for record " + binding_record + " from taggerId " + tag.getTaggerId()); //$NON-NLS-1$ //$NON-NLS-2$
} }
BTree btree = null; BTree btree = null;
try { btree = getTagsBTree(); } try {
catch( CoreException e ) { CCorePlugin.log( e ); return false; } btree = getTagsBTree();
} catch (CoreException e) {
CCorePlugin.log(e);
return false;
}
PDOMTagSynchronizer sync = new PDOMTagSynchronizer( db, Long.valueOf( binding_record ), newTags ); PDOMTagSynchronizer sync = new PDOMTagSynchronizer(db, Long.valueOf(binding_record),
newTags);
// visit the full tree, then return true on success and false on failure // visit the full tree, then return true on success and false on failure
try { btree.accept( sync ); } try {
catch( CoreException e ) { CCorePlugin.log( e ); return false; } btree.accept(sync);
} catch (CoreException e) {
CCorePlugin.log(e);
return false;
}
// Complete the synchronization (delete/insert the records that could not be modified in-place). This // Complete the synchronization (delete/insert the records that could not be modified in-place). This
// will only have something to do when a tag has changed length, which should be a rare. // will only have something to do when a tag has changed length, which should be a rare.
sync.synchronize( btree ); sync.synchronize(btree);
// insert any new tags that are left in the incoming list // insert any new tags that are left in the incoming list
for( ITag newTag : newTags.values() ) for (ITag newTag : newTags.values()) {
{ IWritableTag pdomTag = createTag(binding_record, newTag.getTaggerId(),
IWritableTag pdomTag = createTag( binding_record, newTag.getTaggerId(), newTag.getDataLen() ); newTag.getDataLen());
pdomTag.putBytes( 0, newTag.getBytes( 0, -1 ), -1 ); pdomTag.putBytes(0, newTag.getBytes(0, -1), -1);
} }
return true; return true;
} }
private static PDOMTagIndex getTagIndex( PDOM pdom ) private static PDOMTagIndex getTagIndex(PDOM pdom) {
{ if (pdom == null)
if( pdom == null )
return null; return null;
try try {
{
PDOMTagIndex index = pdom.getTagIndex(); PDOMTagIndex index = pdom.getTagIndex();
return index.db == null ? null : index; return index.db == null ? null : index;
} catch (CoreException e) {
CCorePlugin.log(e);
} }
catch( CoreException e ) { CCorePlugin.log(e); }
return null; return null;
} }
// common implementations // common implementations
public static IWritableTag createTag( PDOM pdom, long record, String id, int len ) public static IWritableTag createTag(PDOM pdom, long record, String id, int len) {
{ PDOMTagIndex index = getTagIndex(pdom);
PDOMTagIndex index = getTagIndex( pdom ); if (index == null)
if( index == null )
return null; return null;
return index.createTag( record, id, len ); return index.createTag(record, id, len);
} }
public static ITag getTag( PDOM pdom, long record, String id ) public static ITag getTag(PDOM pdom, long record, String id) {
{ PDOMTagIndex index = getTagIndex(pdom);
PDOMTagIndex index = getTagIndex( pdom ); if (index == null)
if( index == null )
return null; return null;
return index.getTag( record, id ); return index.getTag(record, id);
} }
public static Iterable<ITag> getTags( PDOM pdom, long record ) public static Iterable<ITag> getTags(PDOM pdom, long record) {
{ PDOMTagIndex index = getTagIndex(pdom);
PDOMTagIndex index = getTagIndex( pdom ); if (index == null)
if( index == null )
return Collections.emptyList(); return Collections.emptyList();
return index.getTags( record ); return index.getTags(record);
} }
public static boolean setTags( PDOM pdom, long record, Iterable<ITag> tags ) public static boolean setTags(PDOM pdom, long record, Iterable<ITag> tags) {
{ if (record == 0)
if( record == 0 )
return true; return true;
PDOMTagIndex index = getTagIndex( pdom ); PDOMTagIndex index = getTagIndex(pdom);
if( index == null ) if (index == null)
return false; return false;
return index.setTags( record, tags ); return index.setTags(record, tags);
} }
} }

View file

@ -4,6 +4,9 @@
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Eidsness - Initial implementation
*/ */
package org.eclipse.cdt.internal.core.pdom.tag; package org.eclipse.cdt.internal.core.pdom.tag;
@ -19,8 +22,10 @@ import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.cdt.internal.core.pdom.db.IBTreeVisitor; import org.eclipse.cdt.internal.core.pdom.db.IBTreeVisitor;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
public class PDOMTagSynchronizer implements IBTreeVisitor /**
{ * An implementation utility for synchronizing the tags between source and destination nodes.
*/
public class PDOMTagSynchronizer implements IBTreeVisitor {
private final Database db; private final Database db;
private final Long searchRecord; private final Long searchRecord;
private final Map<String, ITag> newTags; private final Map<String, ITag> newTags;
@ -28,39 +33,37 @@ public class PDOMTagSynchronizer implements IBTreeVisitor
private final List<Long> toRemove = new LinkedList<Long>(); private final List<Long> toRemove = new LinkedList<Long>();
private final List<Long> toInsert = new LinkedList<Long>(); private final List<Long> toInsert = new LinkedList<Long>();
public PDOMTagSynchronizer( Database db, Long searchRecord, Map<String, ITag> newTags ) public PDOMTagSynchronizer(Database db, Long searchRecord, Map<String, ITag> newTags) {
{
this.db = db; this.db = db;
this.searchRecord = searchRecord; this.searchRecord = searchRecord;
this.newTags = newTags; this.newTags = newTags;
} }
/** /**
* Complete the synchronization by deleting and inserting all required records. Return * Complete the synchronization by deleting and inserting all required records. Return true if successful
* true if successful and false otherwise. * and false otherwise.
*/ */
public boolean synchronize( BTree tree ) public boolean synchronize(BTree tree) {
{ for (Long rm : toRemove)
for( Long rm : toRemove ) try {
try
{
long record = rm.longValue(); long record = rm.longValue();
tree.delete( record ); tree.delete(record);
db.free( record ); db.free(record);
} } catch (CoreException e) {
catch( CoreException e ) CCorePlugin.log(e);
{
CCorePlugin.log( e );
} }
toRemove.clear(); toRemove.clear();
for( Long insert : toInsert ) for (Long insert : toInsert)
try { tree.insert( insert.longValue() ); } try {
catch( CoreException e ) tree.insert(insert.longValue());
{ } catch (CoreException e) {
CCorePlugin.log( e ); CCorePlugin.log(e);
try { db.free( insert.longValue() ); } try {
catch( CoreException e1 ) { CCorePlugin.log( e1 ); } db.free(insert.longValue());
} catch (CoreException e1) {
CCorePlugin.log(e1);
}
} }
toInsert.clear(); toInsert.clear();
@ -68,35 +71,32 @@ public class PDOMTagSynchronizer implements IBTreeVisitor
} }
@Override @Override
public int compare( long test_record ) throws CoreException public int compare(long test_record) throws CoreException {
{
// TODO this is the same as BTreeIterable.Descriptor.compare // TODO this is the same as BTreeIterable.Descriptor.compare
long test_node = new PDOMTag( db, test_record ).getNode(); long test_node = new PDOMTag(db, test_record).getNode();
// -1 if record < key, 0 if record == key, 1 if record > key // -1 if record < key, 0 if record == key, 1 if record > key
return Long.valueOf( test_node ).compareTo( searchRecord ); return Long.valueOf(test_node).compareTo(searchRecord);
} }
@Override @Override
public boolean visit( long existing_record ) throws CoreException public boolean visit(long existing_record) throws CoreException {
{ PDOMTag existingTag = new PDOMTag(db, existing_record);
PDOMTag existingTag = new PDOMTag( db, existing_record );
String taggerId = existingTag.getTaggerId(); String taggerId = existingTag.getTaggerId();
ITag newTag = newTags.remove( taggerId ); ITag newTag = newTags.remove(taggerId);
if( newTag == null ) if (newTag == null) {
toRemove.add( Long.valueOf( existing_record ) ); toRemove.add(Long.valueOf(existing_record));
else if( newTag.getDataLen() > existingTag.getDataLen() ) } else if (newTag.getDataLen() > existingTag.getDataLen()) {
{ toRemove.add(Long.valueOf(existing_record));
toRemove.add( Long.valueOf( existing_record ) );
PDOMTag pdomTag = existingTag.cloneWith( newTag.getBytes( 0, -1 ) ); PDOMTag pdomTag = existingTag.cloneWith(newTag.getBytes(0, -1));
if( pdomTag != null ) if (pdomTag != null)
toInsert.add( Long.valueOf( pdomTag.getRecord() ) ); toInsert.add(Long.valueOf(pdomTag.getRecord()));
} } else if (!existingTag.putBytes(0, newTag.getBytes(0, -1), -1))
else if( ! existingTag.putBytes( 0, newTag.getBytes( 0, -1 ), -1 ) ) CCorePlugin
CCorePlugin.log( "Unable to modify data of tag record " + existing_record + " from taggerId " + taggerId ); //$NON-NLS-1$ //$NON-NLS-2$ .log("Unable to modify data of tag record " + existing_record + " from taggerId " + taggerId); //$NON-NLS-1$ //$NON-NLS-2$
// try to visit the full tree // try to visit the full tree
return true; return true;

View file

@ -4,6 +4,9 @@
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Eidsness - Initial implementation
*/ */
package org.eclipse.cdt.internal.core.pdom.tag; package org.eclipse.cdt.internal.core.pdom.tag;
@ -14,38 +17,35 @@ import org.eclipse.cdt.core.dom.ast.tag.ITagWriter;
import org.eclipse.cdt.core.dom.ast.tag.IWritableTag; import org.eclipse.cdt.core.dom.ast.tag.IWritableTag;
import org.eclipse.cdt.internal.core.pdom.PDOM; import org.eclipse.cdt.internal.core.pdom.PDOM;
public class PDOMTaggable implements ITagReader, ITagWriter /**
{ * A container for things that can be tagged and then stored in the index database.
*/
public class PDOMTaggable implements ITagReader, ITagWriter {
private final PDOM pdom; private final PDOM pdom;
private final long record; private final long record;
public PDOMTaggable( PDOM pdom, long record ) public PDOMTaggable(PDOM pdom, long record) {
{
this.pdom = pdom; this.pdom = pdom;
this.record = record; this.record = record;
} }
@Override @Override
public IWritableTag createTag( String id, int len ) public IWritableTag createTag(String id, int len) {
{ return PDOMTagIndex.createTag(pdom, record, id, len);
return PDOMTagIndex.createTag( pdom, record, id, len );
} }
@Override @Override
public ITag getTag( String id ) public ITag getTag(String id) {
{ return PDOMTagIndex.getTag(pdom, record, id);
return PDOMTagIndex.getTag( pdom, record, id );
} }
@Override @Override
public Iterable<ITag> getTags() public Iterable<ITag> getTags() {
{ return PDOMTagIndex.getTags(pdom, record);
return PDOMTagIndex.getTags( pdom, record );
} }
@Override @Override
public boolean setTags( Iterable<ITag> tags ) public boolean setTags(Iterable<ITag> tags) {
{ return PDOMTagIndex.setTags(pdom, record, tags);
return PDOMTagIndex.setTags( pdom, record, tags );
} }
} }

View file

@ -208,7 +208,7 @@ public class CCorePlugin extends Plugin {
/** /**
* @noreference This field is not intended to be referenced by clients. * @noreference This field is not intended to be referenced by clients.
*/ */
public CDTLogWriter cdtLog = null; public CDTLogWriter cdtLog;
private volatile CProjectDescriptionManager fNewCProjectDescriptionManager; private volatile CProjectDescriptionManager fNewCProjectDescriptionManager;

View file

@ -283,11 +283,15 @@ public class UserDefinedEnvironmentSupplier extends
} }
public boolean setWorkspaceEnvironment(StorableEnvironment env) { public boolean setWorkspaceEnvironment(StorableEnvironment env) {
StorableEnvironment oldEnv = getEnvironment(null); IEnvironmentVariable[] oldVariables = fWorkspaceVariables.getVariables();
IEnvironmentVariable[] newVariables = env.getVariables();
fWorkspaceVariables = new StorableEnvironment(env, false); fWorkspaceVariables.deleteAll();
fWorkspaceVariables.setVariales(newVariables);
fWorkspaceVariables.setAppendEnvironment(env.appendEnvironment());
fWorkspaceVariables.setAppendContributedEnvironment(env.appendContributedEnvironment());
EnvironmentChangeEvent event = createEnvironmentChangeEvent(fWorkspaceVariables.getVariables(), oldEnv.getVariables()); EnvironmentChangeEvent event = createEnvironmentChangeEvent(newVariables, oldVariables);
storeWorkspaceEnvironment(true); storeWorkspaceEnvironment(true);

View file

@ -2467,6 +2467,9 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
} }
private int visit(IASTTypeIdExpression node) { private int visit(IASTTypeIdExpression node) {
if (enclosedInMacroExpansion(node)) {
return PROCESS_SKIP;
}
scribe.printNextToken(peekNextToken()); scribe.printNextToken(peekNextToken());
scribe.printNextToken(Token.tLPAREN); scribe.printNextToken(Token.tLPAREN);
node.getTypeId().accept(this); node.getTypeId().accept(this);
@ -2598,6 +2601,9 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
} }
private int visit(IASTUnaryExpression node) { private int visit(IASTUnaryExpression node) {
if (enclosedInMacroExpansion(node)) {
return PROCESS_SKIP;
}
final IASTExpression operand= node.getOperand(); final IASTExpression operand= node.getOperand();
final int operator= node.getOperator(); final int operator= node.getOperator();
switch (operator) { switch (operator) {

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2002, 2010 QNX Software Systems and others. * Copyright (c) 2002, 2013 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -31,22 +31,18 @@ import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.internal.corext.util.Strings; import org.eclipse.cdt.internal.corext.util.Strings;
import org.eclipse.cdt.internal.ui.newui.LanguageSettingsImages; import org.eclipse.cdt.internal.ui.language.settings.providers.LanguageSettingsImages;
import org.eclipse.cdt.internal.ui.viewsupport.AppearanceAwareLabelProvider; import org.eclipse.cdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider; import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
/* /**
* CViewLabelProvider * Label provider for "C/C++ Projects" view.
*/ */
public class CViewLabelProvider extends AppearanceAwareLabelProvider { public class CViewLabelProvider extends AppearanceAwareLabelProvider {
public CViewLabelProvider(long textFlags, int imageFlags) { public CViewLabelProvider(long textFlags, int imageFlags) {
super(textFlags, imageFlags); super(textFlags, imageFlags);
} }
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
*/
@Override @Override
public String getText(Object element) { public String getText(Object element) {
if (element instanceof IncludeReferenceProxy) { if (element instanceof IncludeReferenceProxy) {
@ -103,22 +99,23 @@ public class CViewLabelProvider extends AppearanceAwareLabelProvider {
return Strings.markLTR(new StyledString(getText(element))); return Strings.markLTR(new StyledString(getText(element)));
} }
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
*/
@Override @Override
public Image getImage(Object element) { public Image getImage(Object element) {
String imageKey = null; String imageKey = null;
if (element instanceof IncludeReferenceProxy) { if (element instanceof IncludeReferenceProxy) {
IIncludeReference reference = ((IncludeReferenceProxy)element).getReference(); IIncludeReference reference = ((IncludeReferenceProxy)element).getReference();
IContainer containerInclude = ResourcesPlugin.getWorkspace().getRoot().getContainerForLocation(reference.getPath()); IPath path = reference.getPath();
if (containerInclude != null) {
ICProject cproject = reference.getCProject(); ICProject cproject = reference.getCProject();
IProject project = (cproject != null) ? cproject.getProject() : null; IProject project = (cproject != null) ? cproject.getProject() : null;
for (IContainer containerInclude : ResourcesPlugin.getWorkspace().getRoot().findContainersForLocationURI(URIUtil.toURI(path.makeAbsolute()))) {
IProject projectInclude = containerInclude.getProject(); IProject projectInclude = containerInclude.getProject();
boolean isProjectRelative = projectInclude != null && projectInclude.equals(project); boolean isProjectRelative = projectInclude != null && projectInclude.equals(project);
imageKey = LanguageSettingsImages.getImageKey(ICSettingEntry.INCLUDE_PATH, ICSettingEntry.VALUE_WORKSPACE_PATH, isProjectRelative); imageKey = LanguageSettingsImages.getImageKey(ICSettingEntry.INCLUDE_PATH, ICSettingEntry.VALUE_WORKSPACE_PATH, isProjectRelative);
} else { if (isProjectRelative) {
break;
}
}
if (imageKey == null) {
imageKey = CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER; imageKey = CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER;
} }
} else if (element instanceof IIncludeReference) { } else if (element instanceof IIncludeReference) {

View file

@ -38,7 +38,6 @@ import org.eclipse.cdt.ui.newui.AbstractCPropertyTab;
import org.eclipse.cdt.ui.newui.AbstractPropertyDialog; import org.eclipse.cdt.ui.newui.AbstractPropertyDialog;
import org.eclipse.cdt.internal.ui.ImageCombo; import org.eclipse.cdt.internal.ui.ImageCombo;
import org.eclipse.cdt.internal.ui.newui.LanguageSettingsImages;
import org.eclipse.cdt.internal.ui.newui.Messages; import org.eclipse.cdt.internal.ui.newui.Messages;
/** /**
@ -47,11 +46,11 @@ import org.eclipse.cdt.internal.ui.newui.Messages;
public class LanguageSettingEntryDialog extends AbstractPropertyDialog { public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
private static final String SLASH = "/"; //$NON-NLS-1$ private static final String SLASH = "/"; //$NON-NLS-1$
private ICConfigurationDescription cfgDescription; private final ICConfigurationDescription cfgDescription;
private IProject project; private final IProject project;
private ICLanguageSettingEntry entry; private final ICLanguageSettingEntry initialEntry;
private boolean clearValue; private final int initialKind;
private int kind; private final boolean clearValue;
private Composite compositeArea; private Composite compositeArea;
private Label iconComboKind; private Label iconComboKind;
@ -116,9 +115,9 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
super(parent, ""); //$NON-NLS-1$ super(parent, ""); //$NON-NLS-1$
this.cfgDescription = cfgDescription; this.cfgDescription = cfgDescription;
this.project = cfgDescription.getProjectDescription().getProject(); this.project = cfgDescription.getProjectDescription().getProject();
this.entry = null; this.initialEntry = null;
this.initialKind = kind;
this.clearValue = true; this.clearValue = true;
this.kind = kind;
} }
/** /**
@ -129,8 +128,8 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
super(parent, ""); //$NON-NLS-1$ super(parent, ""); //$NON-NLS-1$
this.cfgDescription = cfgDescription; this.cfgDescription = cfgDescription;
this.project = cfgDescription.getProjectDescription().getProject(); this.project = cfgDescription.getProjectDescription().getProject();
this.entry = entry; this.initialEntry = entry;
this.kind = entry != null ? entry.getKind() : ICSettingEntry.INCLUDE_PATH; this.initialKind = entry != null ? entry.getKind() : ICSettingEntry.INCLUDE_PATH;
this.clearValue = clearValue; this.clearValue = clearValue;
} }
@ -211,7 +210,7 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
gd.horizontalAlignment = SWT.RIGHT; gd.horizontalAlignment = SWT.RIGHT;
iconComboKind.setLayoutData(gd); iconComboKind.setLayoutData(gd);
iconComboKind.setText(Messages.LanguageSettingEntryDialog_SelectKind); iconComboKind.setText(Messages.LanguageSettingEntryDialog_SelectKind);
int kindToComboIndex = kindToComboIndex(kind); int kindToComboIndex = kindToComboIndex(initialKind);
iconComboKind.setImage(comboKindImages[kindToComboIndex]); iconComboKind.setImage(comboKindImages[kindToComboIndex]);
// Combo for the setting entry kind // Combo for the setting entry kind
@ -248,14 +247,14 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
comboPathCategory.add(pathCategories[i], pathCategoryImages[i]); comboPathCategory.add(pathCategories[i], pathCategoryImages[i]);
} }
int pcindex = COMBO_PATH_INDEX_PROJECT; int pcindex = COMBO_PATH_INDEX_PROJECT;
if (entry != null) { if (initialEntry != null) {
if ((entry.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH) == 0) { if ((initialEntry.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH) == 0) {
pcindex = COMBO_PATH_INDEX_FILESYSTEM; pcindex = COMBO_PATH_INDEX_FILESYSTEM;
} else { } else {
if (entry.getName().startsWith(SLASH)) { if (LanguageSettingsImages.isProjectRelative(initialEntry)) {
pcindex = COMBO_PATH_INDEX_WORKSPACE;
} else {
pcindex = COMBO_PATH_INDEX_PROJECT; pcindex = COMBO_PATH_INDEX_PROJECT;
} else {
pcindex = COMBO_PATH_INDEX_WORKSPACE;
} }
} }
} }
@ -286,8 +285,12 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
// Dir/File/Name input // Dir/File/Name input
inputName = new Text(compositeArea, SWT.SINGLE | SWT.BORDER); inputName = new Text(compositeArea, SWT.SINGLE | SWT.BORDER);
if (entry!=null && !clearValue) { if (initialEntry != null && !clearValue) {
inputName.setText(entry.getName()); String name = initialEntry.getName();
if (pcindex == COMBO_PATH_INDEX_PROJECT && LanguageSettingsImages.isProjectRelative(initialEntry)) {
name = LanguageSettingsImages.toProjectRelative(name);
}
inputName.setText(name);
} }
gd = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); gd = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
gd.horizontalSpan = 2; gd.horizontalSpan = 2;
@ -334,14 +337,14 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
// Value input. Located after the other controls to get sufficient width // Value input. Located after the other controls to get sufficient width
int comboPathWidth = comboPathCategory.computeSize(SWT.DEFAULT, SWT.NONE).x; int comboPathWidth = comboPathCategory.computeSize(SWT.DEFAULT, SWT.NONE).x;
inputValue = new Text(compositeArea, SWT.SINGLE | SWT.BORDER); inputValue = new Text(compositeArea, SWT.SINGLE | SWT.BORDER);
if (entry != null && !clearValue) { if (initialEntry != null && !clearValue) {
inputValue.setText(entry.getValue()); inputValue.setText(initialEntry.getValue());
} }
gd = new GridData(SWT.FILL, SWT.NONE, false, false); gd = new GridData(SWT.FILL, SWT.NONE, false, false);
gd.widthHint = comboPathWidth; gd.widthHint = comboPathWidth;
inputValue.setLayoutData(gd); inputValue.setLayoutData(gd);
if (entry != null && kind == ICSettingEntry.MACRO && !clearValue) { if (initialEntry != null && initialKind == ICSettingEntry.MACRO && !clearValue) {
inputValue.setFocus(); inputValue.setFocus();
inputValue.setSelection(0, inputValue.getText().length()); inputValue.setSelection(0, inputValue.getText().length());
} }
@ -357,7 +360,7 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
// Checkbox "Built-In" // Checkbox "Built-In"
checkBoxBuiltIn = new Button(compCheckboxes, SWT.CHECK); checkBoxBuiltIn = new Button(compCheckboxes, SWT.CHECK);
checkBoxBuiltIn.setText(Messages.LanguageSettingEntryDialog_BuiltInFlag); checkBoxBuiltIn.setText(Messages.LanguageSettingEntryDialog_BuiltInFlag);
checkBoxBuiltIn.setSelection(entry != null && (entry.getFlags() & ICSettingEntry.BUILTIN) != 0); checkBoxBuiltIn.setSelection(initialEntry != null && (initialEntry.getFlags() & ICSettingEntry.BUILTIN) != 0);
gd = new GridData(GridData.FILL_HORIZONTAL); gd = new GridData(GridData.FILL_HORIZONTAL);
checkBoxBuiltIn.setLayoutData(gd); checkBoxBuiltIn.setLayoutData(gd);
checkBoxBuiltIn.addSelectionListener(new SelectionListener() { checkBoxBuiltIn.addSelectionListener(new SelectionListener() {
@ -375,7 +378,7 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
// Checkbox "Contains system includes" // Checkbox "Contains system includes"
checkBoxSystem = new Button(compCheckboxes, SWT.CHECK); checkBoxSystem = new Button(compCheckboxes, SWT.CHECK);
checkBoxSystem.setText(Messages.LanguageSettingEntryDialog_ContainsSystemHeaders); checkBoxSystem.setText(Messages.LanguageSettingEntryDialog_ContainsSystemHeaders);
checkBoxSystem.setSelection(entry != null && (entry.getFlags() & ICSettingEntry.LOCAL) == 0); checkBoxSystem.setSelection(initialEntry != null && (initialEntry.getFlags() & ICSettingEntry.LOCAL) == 0);
gd = new GridData(GridData.FILL_HORIZONTAL); gd = new GridData(GridData.FILL_HORIZONTAL);
checkBoxSystem.setLayoutData(gd); checkBoxSystem.setLayoutData(gd);
checkBoxSystem.addSelectionListener(new SelectionListener() { checkBoxSystem.addSelectionListener(new SelectionListener() {
@ -393,7 +396,7 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
// Checkbox "Framework folder" // Checkbox "Framework folder"
checkBoxFramework = new Button(compCheckboxes, SWT.CHECK); checkBoxFramework = new Button(compCheckboxes, SWT.CHECK);
checkBoxFramework.setText(Messages.LanguageSettingEntryDialog_FrameworkFolder); checkBoxFramework.setText(Messages.LanguageSettingEntryDialog_FrameworkFolder);
checkBoxFramework.setSelection(entry != null && (entry.getFlags() & ICSettingEntry.FRAMEWORKS_MAC) != 0); checkBoxFramework.setSelection(initialEntry != null && (initialEntry.getFlags() & ICSettingEntry.FRAMEWORKS_MAC) != 0);
gd = new GridData(GridData.FILL_HORIZONTAL); gd = new GridData(GridData.FILL_HORIZONTAL);
checkBoxFramework.setLayoutData(gd); checkBoxFramework.setLayoutData(gd);
checkBoxFramework.addSelectionListener(new SelectionListener() { checkBoxFramework.addSelectionListener(new SelectionListener() {
@ -515,28 +518,38 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
public void buttonPressed(SelectionEvent e) { public void buttonPressed(SelectionEvent e) {
String str = null; String str = null;
if (e.widget.equals(buttonOk)) { if (e.widget.equals(buttonOk)) {
String name = inputName.getText().trim(); text1 = inputName.getText().trim();
text1 = name;
String value = inputValue.getText().trim();
result = true; result = true;
String name = text1;
int flagBuiltIn = checkBoxBuiltIn.isVisible() && checkBoxBuiltIn.getSelection() ? ICSettingEntry.BUILTIN : 0; int flagBuiltIn = checkBoxBuiltIn.isVisible() && checkBoxBuiltIn.getSelection() ? ICSettingEntry.BUILTIN : 0;
int flags = flagBuiltIn;
int kind = comboKind.getSelectionIndex();
if (kind != COMBO_INDEX_MACRO) {
int flagSystem = checkBoxSystem.isVisible() && checkBoxSystem.getSelection() ? 0 : ICSettingEntry.LOCAL; int flagSystem = checkBoxSystem.isVisible() && checkBoxSystem.getSelection() ? 0 : ICSettingEntry.LOCAL;
int flagFramework = checkBoxFramework.isVisible() && checkBoxFramework.getSelection() ? ICSettingEntry.FRAMEWORKS_MAC : 0; int flagFramework = checkBoxFramework.isVisible() && checkBoxFramework.getSelection() ? ICSettingEntry.FRAMEWORKS_MAC : 0;
int indexPathKind = comboPathCategory.getSelectionIndex(); int indexPathKind = comboPathCategory.getSelectionIndex();
int kind = comboKind.getSelectionIndex();
boolean isProjectPath = indexPathKind == COMBO_PATH_INDEX_PROJECT; boolean isProjectPath = indexPathKind == COMBO_PATH_INDEX_PROJECT;
boolean isWorkspacePath = (kind != COMBO_INDEX_MACRO) && (isProjectPath || indexPathKind == COMBO_PATH_INDEX_WORKSPACE); boolean isWorkspacePath = indexPathKind == COMBO_PATH_INDEX_WORKSPACE;
int flagWorkspace = isWorkspacePath ? ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED : 0; int flagWorkspace = (isWorkspacePath || isProjectPath) ? ICSettingEntry.VALUE_WORKSPACE_PATH : 0;
int flags = flagBuiltIn | flagWorkspace | flagSystem | flagFramework; int flagResolved = isWorkspacePath && !name.contains("$") ? ICSettingEntry.RESOLVED : 0; //$NON-NLS-1$
flags = flagBuiltIn | flagWorkspace | flagResolved | flagSystem | flagFramework;
if (isProjectPath) {
name = LanguageSettingsImages.fromProjectRelative(name);
}
}
ICLanguageSettingEntry entry = null; ICLanguageSettingEntry entry = null;
switch (kind) { switch (comboKind.getSelectionIndex()) {
case COMBO_INDEX_INCLUDE_DIR: case COMBO_INDEX_INCLUDE_DIR:
entry = CDataUtil.createCIncludePathEntry(name, flags); entry = CDataUtil.createCIncludePathEntry(name, flags);
break; break;
case COMBO_INDEX_MACRO: case COMBO_INDEX_MACRO:
// Note that value=null is not supported by CMacroEntry // Note that value=null is not supported by CMacroEntry
String value = inputValue.getText().trim();
entry = CDataUtil.createCMacroEntry(name, value, flags); entry = CDataUtil.createCMacroEntry(name, value, flags);
break; break;
case COMBO_INDEX_INCLUDE_FILE: case COMBO_INDEX_INCLUDE_FILE:

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2010, 2012 Andrew Gvozdev and others. * Copyright (c) 2010, 2013 Andrew Gvozdev and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -58,7 +58,6 @@ import org.eclipse.cdt.ui.CDTSharedImages;
import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.newui.AbstractCPropertyTab; import org.eclipse.cdt.ui.newui.AbstractCPropertyTab;
import org.eclipse.cdt.internal.ui.newui.LanguageSettingsImages;
import org.eclipse.cdt.internal.ui.newui.Messages; import org.eclipse.cdt.internal.ui.newui.Messages;
import org.eclipse.cdt.internal.ui.newui.StatusMessageLine; import org.eclipse.cdt.internal.ui.newui.StatusMessageLine;
@ -156,11 +155,15 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
public String getText(Object element) { public String getText(Object element) {
if (element instanceof ICLanguageSettingEntry) { if (element instanceof ICLanguageSettingEntry) {
ICLanguageSettingEntry entry = (ICLanguageSettingEntry) element; ICLanguageSettingEntry entry = (ICLanguageSettingEntry) element;
String s = entry.getName(); String text = entry.getName();
if ((entry.getKind() == ICSettingEntry.MACRO) && (entry.getFlags()&ICSettingEntry.UNDEFINED) == 0) { if (entry.getKind() == ICSettingEntry.MACRO) {
s = s + '=' + entry.getValue(); if ((entry.getFlags() & ICSettingEntry.UNDEFINED) == 0) {
text = text + '=' + entry.getValue();
} }
return s; } else if (LanguageSettingsImages.isProjectRelative(entry)) {
text = LanguageSettingsImages.toProjectRelative(text);
}
return text;
} }
return super.getText(element); return super.getText(element);

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2010, 2012 Andrew Gvozdev and others. * Copyright (c) 2010, 2013 Andrew Gvozdev and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -8,10 +8,8 @@
* Contributors: * Contributors:
* Andrew Gvozdev - Initial API and implementation * Andrew Gvozdev - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.ui.language.settings.providers;
package org.eclipse.cdt.internal.ui.newui;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
@ -24,17 +22,66 @@ import org.eclipse.swt.graphics.Image;
import org.eclipse.cdt.core.settings.model.ACPathEntry; import org.eclipse.cdt.core.settings.model.ACPathEntry;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.core.settings.model.ICSettingEntry; import org.eclipse.cdt.core.settings.model.ICSettingEntry;
import org.eclipse.cdt.core.settings.model.util.CDataUtil; import org.eclipse.cdt.core.settings.model.util.CDataUtil;
import org.eclipse.cdt.ui.CDTSharedImages; import org.eclipse.cdt.ui.CDTSharedImages;
import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.utils.UNCPathConverter; import org.eclipse.cdt.utils.UNCPathConverter;
import org.eclipse.cdt.internal.ui.newui.Messages;
/** /**
* Helper class to provide unified images for {@link ICLanguageSettingEntry}. * Helper class to provide unified images for {@link ICLanguageSettingEntry}.
*/ */
public class LanguageSettingsImages { public class LanguageSettingsImages {
private static final String PROJ_NAME_PREFIX = "/${ProjName}/"; //$NON-NLS-1$
/**
* Check if the language settings entry should be presented as "project-relative" in UI.
*
* @param entry - language settings entry to check.
* @return {@code true} if the entry should be displayed as "project-relative", {@code false} otherwise.
*/
public static boolean isProjectRelative(ICLanguageSettingEntry entry) {
if (entry instanceof ACPathEntry) {
String path = entry.getName();
return ((ACPathEntry) entry).isValueWorkspacePath() && path.startsWith(PROJ_NAME_PREFIX);
}
return false;
}
/**
* Convert path used by {@link ICLanguageSettingEntry} to label representing project-relative portion.
*
* @param path - path to convert to label in project-relative format.
* @return label to be used to display the path in UI.
*/
public static String toProjectRelative(String path) {
if (path.startsWith(LanguageSettingsImages.PROJ_NAME_PREFIX)) {
return path.substring(LanguageSettingsImages.PROJ_NAME_PREFIX.length());
}
return path;
}
/**
* Convert label for project-relative path back to path representation carried by {@link ICLanguageSettingEntry}.
*
* @param label - label in project-relative format.
* @return path to be used by {@link ICLanguageSettingEntry}.
*/
public static String fromProjectRelative(String label) {
return LanguageSettingsImages.PROJ_NAME_PREFIX + label;
}
/**
* Returns image for the given {@link ICLanguageSettingEntry} from internally managed repository including
* necessary overlays for given configuration description.
*
* @param kind - kind of {@link ICLanguageSettingEntry}, i.e. {@link ICSettingEntry#INCLUDE_PATH} etc.
* @param flags - flags of {@link ICSettingEntry}.
* @param isProjectRelative specifies if the image should present "project-relative" icon.
* @return the image for the entry with appropriate overlays.
*/
public static Image getImage(int kind, int flags, boolean isProjectRelative) { public static Image getImage(int kind, int flags, boolean isProjectRelative) {
String imageKey = getImageKey(kind, flags, isProjectRelative); String imageKey = getImageKey(kind, flags, isProjectRelative);
if (imageKey != null) { if (imageKey != null) {
@ -52,19 +99,35 @@ public class LanguageSettingsImages {
* @return the image for the entry with appropriate overlays. * @return the image for the entry with appropriate overlays.
*/ */
public static Image getImage(ICLanguageSettingEntry entry, ICConfigurationDescription cfgDescription) { public static Image getImage(ICLanguageSettingEntry entry, ICConfigurationDescription cfgDescription) {
String projectName = null; int kind = entry.getKind();
int flags = entry.getFlags();
boolean isProjectRelative = isProjectRelative(entry);
if (cfgDescription != null) { String imageKey = getImageKey(kind, flags, isProjectRelative);
ICProjectDescription prjDescription = cfgDescription.getProjectDescription(); if (imageKey != null) {
if (prjDescription != null) { if ((flags & ICSettingEntry.UNDEFINED) != 0) {
IProject project = prjDescription.getProject(); return CDTSharedImages.getImageOverlaid(imageKey, CDTSharedImages.IMG_OVR_INACTIVE, IDecoration.BOTTOM_LEFT);
if (project != null) {
projectName = project.getName();
}
}
} }
return getImage(entry, projectName, cfgDescription); String overlayKey=null;
IStatus status = getStatus(entry, cfgDescription);
switch (status.getSeverity()) {
case IStatus.ERROR:
overlayKey = CDTSharedImages.IMG_OVR_ERROR;
break;
case IStatus.WARNING:
overlayKey = CDTSharedImages.IMG_OVR_WARNING;
break;
case IStatus.INFO:
overlayKey = CDTSharedImages.IMG_OVR_WARNING;
break;
}
if (overlayKey != null) {
return CDTSharedImages.getImageOverlaid(imageKey, overlayKey, IDecoration.BOTTOM_LEFT);
}
return CDTSharedImages.getImage(imageKey);
}
return null;
} }
/** /**
@ -114,50 +177,6 @@ public class LanguageSettingsImages {
return imageKey; return imageKey;
} }
/**
* Returns image for the given entry from internally managed repository including
* necessary overlays.
*
* @param entry - language settings entry to get an image for.
* @param projectName - pass project name if available. That lets put "project" metaphor
* on the image. Pass {@code null} if no project name is available.
* @param cfgDescription - configuration description of the entry.
* @return the image for the entry with appropriate overlays.
*/
private static Image getImage(ICLanguageSettingEntry entry, String projectName, ICConfigurationDescription cfgDescription) {
int kind = entry.getKind();
int flags = entry.getFlags();
boolean isWorkspacePath = (flags & ICSettingEntry.VALUE_WORKSPACE_PATH) != 0;
String path = entry.getName();
boolean isProjectRelative = (projectName != null) && isWorkspacePath && path.startsWith(IPath.SEPARATOR + projectName + IPath.SEPARATOR);
String imageKey = getImageKey(kind, flags, isProjectRelative);
if (imageKey != null) {
if ((flags & ICSettingEntry.UNDEFINED) != 0) {
return CDTSharedImages.getImageOverlaid(imageKey, CDTSharedImages.IMG_OVR_INACTIVE, IDecoration.BOTTOM_LEFT);
}
if (entry instanceof ACPathEntry) {
String overlayKey=null;
IStatus status = getStatus(entry, cfgDescription);
switch (status.getSeverity()) {
case IStatus.ERROR:
overlayKey = CDTSharedImages.IMG_OVR_ERROR;
break;
case IStatus.WARNING:
overlayKey = CDTSharedImages.IMG_OVR_WARNING;
break;
case IStatus.INFO:
overlayKey = CDTSharedImages.IMG_OVR_WARNING;
break;
}
return CDTSharedImages.getImageOverlaid(imageKey, overlayKey, IDecoration.BOTTOM_LEFT);
}
return CDTSharedImages.getImage(imageKey);
}
return null;
}
/** /**
* Checking if the entry points to existing or accessible location. * Checking if the entry points to existing or accessible location.
* @param entry - resolved entry * @param entry - resolved entry

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2009, 2010 Andrew Gvozdev and others. * Copyright (c) 2009, 2013 Andrew Gvozdev and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
* *
* Contributors: * Contributors:
* Andrew Gvozdev - Initial API and implementation * Andrew Gvozdev - Initial API and implementation
* IBM Corporation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.ui.dialogs; package org.eclipse.cdt.ui.dialogs;
@ -24,12 +25,18 @@ import org.eclipse.jface.text.FindReplaceDocumentAdapterContentProposalProvider;
import org.eclipse.jface.viewers.ArrayContentProvider; import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.CellEditor; import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.ColumnLabelProvider; import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.ColumnViewerEditor;
import org.eclipse.jface.viewers.ColumnViewerEditorActivationEvent;
import org.eclipse.jface.viewers.ColumnViewerEditorActivationStrategy;
import org.eclipse.jface.viewers.ColumnWeightData; import org.eclipse.jface.viewers.ColumnWeightData;
import org.eclipse.jface.viewers.ComboBoxCellEditor; import org.eclipse.jface.viewers.ComboBoxCellEditor;
import org.eclipse.jface.viewers.EditingSupport; import org.eclipse.jface.viewers.EditingSupport;
import org.eclipse.jface.viewers.FocusCellOwnerDrawHighlighter;
import org.eclipse.jface.viewers.TableLayout; import org.eclipse.jface.viewers.TableLayout;
import org.eclipse.jface.viewers.TableViewer; import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TableViewerColumn; import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.jface.viewers.TableViewerEditor;
import org.eclipse.jface.viewers.TableViewerFocusCellManager;
import org.eclipse.jface.viewers.TextCellEditor; import org.eclipse.jface.viewers.TextCellEditor;
import org.eclipse.jface.window.Window; import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
@ -327,6 +334,22 @@ public final class RegexErrorParserOptionPage extends AbstractCOptionPage {
fTableViewer.setUseHashlookup(true); fTableViewer.setUseHashlookup(true);
fTableViewer.setContentProvider(new ArrayContentProvider()); fTableViewer.setContentProvider(new ArrayContentProvider());
//Bug 307542 - [Accessibility] Error Parser Options table should be accessible by keyboard
TableViewerFocusCellManager focusCellManager = new TableViewerFocusCellManager(fTableViewer,new FocusCellOwnerDrawHighlighter(fTableViewer));
ColumnViewerEditorActivationStrategy actSupport = new ColumnViewerEditorActivationStrategy(fTableViewer) {
@Override
protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) {
return event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL
|| event.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION
|| (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED && (event.keyCode == SWT.CR || event.character == ' '))
|| event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC;
}
};
TableViewerEditor.create(fTableViewer, focusCellManager, actSupport, ColumnViewerEditor.TABBING_HORIZONTAL
| ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR
| ColumnViewerEditor.TABBING_VERTICAL | ColumnViewerEditor.KEYBOARD_ACTIVATION);
createSeverityColumn(); createSeverityColumn();
createPatternColumn(); createPatternColumn();
createFileColumn(); createFileColumn();

View file

@ -72,8 +72,8 @@ import org.eclipse.cdt.core.settings.model.MultiLanguageSetting;
import org.eclipse.cdt.core.settings.model.util.CDataUtil; import org.eclipse.cdt.core.settings.model.util.CDataUtil;
import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.internal.ui.language.settings.providers.LanguageSettingsImages;
import org.eclipse.cdt.internal.ui.language.settings.providers.LanguageSettingsProvidersPage; import org.eclipse.cdt.internal.ui.language.settings.providers.LanguageSettingsProvidersPage;
import org.eclipse.cdt.internal.ui.newui.LanguageSettingsImages;
import org.eclipse.cdt.internal.ui.newui.Messages; import org.eclipse.cdt.internal.ui.newui.Messages;
import org.eclipse.cdt.internal.ui.newui.StatusMessageLine; import org.eclipse.cdt.internal.ui.newui.StatusMessageLine;

View file

@ -593,6 +593,7 @@ public class EnvironmentTab extends AbstractCPropertyTab {
} }
vars = null; vars = null;
super.performOK(); super.performOK();
updateData();
} }
@Override @Override

3
doc/org.eclipse.cdt.doc.user/help.css Normal file → Executable file
View file

@ -42,6 +42,9 @@ th { font-weight: bold }
display: none; display: none;
} }
.menu td { vertical-align: top; }
td.menu_name {font-weight: bold;}
/* Mike Behm's addition to the style sheet */ /* Mike Behm's addition to the style sheet */
.userinput { font-family: monospace; } .userinput { font-family: monospace; }
.guitab, .important, .guibutton, .selectblue, .guimenu, .guilabel, .guitab, .important, .guibutton, .selectblue, .guimenu, .guilabel,

BIN
doc/org.eclipse.cdt.doc.user/images/cdt_menu_edit.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.8 KiB

After

Width:  |  Height:  |  Size: 19 KiB

2
doc/org.eclipse.cdt.doc.user/reference/cdt_o_menu.htm Normal file → Executable file
View file

@ -19,6 +19,8 @@ alt="CDT main menu">
<img src="../images/trans.gif" width="25" height="1" alt=""> <img src="../images/trans.gif" width="25" height="1" alt="">
<a style="text-decoration:none" href="cdt_u_m_edit.htm">Edit Menu actions</a><br> <a style="text-decoration:none" href="cdt_u_m_edit.htm">Edit Menu actions</a><br>
<img src="../images/trans.gif" width="25" height="1" alt=""> <img src="../images/trans.gif" width="25" height="1" alt="">
<a style="text-decoration:none" href="cdt_u_m_source.htm">Source Menu actions</a><br>
<img src="../images/trans.gif" width="25" height="1" alt="">
<a style="text-decoration:none" href="cdt_u_m_refactor.htm">Refactor Menu actions</a><br> <a style="text-decoration:none" href="cdt_u_m_refactor.htm">Refactor Menu actions</a><br>
<img src="../images/trans.gif" width="25" height="1" alt=""> <img src="../images/trans.gif" width="25" height="1" alt="">
<a style="text-decoration:none" href="cdt_u_m_navigate.htm">Navigate Menu actions</a><br> <a style="text-decoration:none" href="cdt_u_m_navigate.htm">Navigate Menu actions</a><br>

367
doc/org.eclipse.cdt.doc.user/reference/cdt_u_m_edit.htm Normal file → Executable file
View file

@ -1,6 +1,5 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en"> <html lang="en">
<head> <head>
<meta http-equiv="Content-Language" content="en-us"> <meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
@ -8,189 +7,213 @@
<link rel="stylesheet" type="text/css" href="../help.css"> <link rel="stylesheet" type="text/css" href="../help.css">
</head> </head>
<body> <body>
<div role="main"><h1>Edit Menu actions</h1> <div role="main">
<h1>Edit Menu actions</h1>
<p><img src="../images/cdt_menu_edit.png" alt="Selecting Edit Menu" ></p> <p>
<p> <img src="../images/cdt_menu_edit.png" alt="Selecting Edit Menu">
<table border="1" cellspacing="0" cellpadding="3"> <tbody> </p>
<tr> <table class="menu" border="1" cellspacing="0">
<thead>
<tr>
<th id="name">Name</th> <th id="name">Name</th>
<th id="function">Function</th> <th id="function">Function</th>
<th id="keyboard">Keyboard Shortcut</th> <th id="keyboard">Keyboard Shortcut</th>
</tr>
<tr style="text-align:left" valign="top">
<td style="text-align:left" valign="top" headers="name"><strong>Undo</strong></td>
<td style="text-align:left" valign="top" headers="function">Revert the last change in the editor</td>
<td headers="keyboard"> Ctrl+Z</td>
</tr>
<tr>
<td style="text-align:left" valign="top" headers="name"><strong>Redo </strong></td>
<td style="text-align:left" valign="top" headers="function">Revert an undone change</td>
<td headers="keyboard"> Ctrl+Y</td>
</tr> </tr>
</thead>
<tr> <tbody>
<td style="text-align:left" valign="top" headers="name"><strong>Cut</strong></td> <tr>
<td style="text-align:left" valign="top" headers="function">Copies the currently selected text or element to the clipboard and removes the element. On elements, the remove is not performed before the clipboard is pasted.</td> <td class="menu_name" headers="name">Undo</td>
<td headers="keyboard"> Ctrl+X</td> <td headers="function">Reverts the last change made in the
</tr> editor</td>
<td headers="keyboard">Ctrl+Z</td>
<tr>
<td style="text-align:left" valign="top" headers="name"><strong>Copy</strong></td>
<td style="text-align:left" valign="top" headers="function">Copies the currently selected text or elements to the clipboard</td>
<td headers="keyboard"> Ctrl+C</td>
</tr>
<tr>
<td style="text-align:left" valign="top" headers="name"><strong>Paste </strong></td>
<td style="text-align:left" valign="top" headers="function">Paste the current content as text to the editor, or as a sibling or child element to the a currently selected element.&nbsp;</td>
<td headers="keyboard"> Ctrl+V</td>
</tr>
<tr>
<td headers="name"><strong>Delete </strong></td>
<td headers="function">Delete the current text or element selection.</td>
<td headers="keyboard"> Delete</td>
</tr>
<tr style="text-align:left" valign="top">
<td headers="name"><strong>Select All</strong></td>
<td headers="function">Select all the editor content..</td>
<td headers="keyboard"> Ctrl+A</td>
</tr>
<tr style="text-align:left" valign="top">
<td headers="name"><strong>Find / Replace</strong></td>
<td headers="function">Open the Find / Replace dialog. Editor only.</td>
<td headers="keyboard"> Ctrl+F</td>
</tr> </tr>
<tr>
<tr style="text-align:left" valign="top"> <td class="menu_name" headers="name">Redo</td>
<td headers="name"><strong>Find Next</strong></td> <td headers="function">Re-applies a change previously reverted
<td headers="function">Finds the next occurrence of the currently selected text. Editor only.</td> with Undo</td>
<td headers="keyboard"> Ctrl+K</td> <td headers="keyboard">Ctrl+Y</td>
</tr>
<tr>
<td headers="name"><strong>Find Previous</strong></td>
<td headers="function">Finds the previous occurrence of the currently selected text. Editor only.</td>
<td headers="keyboard"> Ctrl+Shift+K</td>
</tr>
<tr>
<td headers="name"><strong>Incremental Find Next</strong></td>
<td headers="function">Starts the incremental find mode. After invocation, enter the search text as instructed in the status bar. Editor only.</td>
<td headers="keyboard"> Ctrl+J</td>
</tr>
<tr>
<td headers="name"><strong>Incremental Find Previous</strong></td>
<td headers="function">Starts the incremental find mode. After invocation, enter the search text as instructed in the status bar. Editor only.</td>
<td headers="keyboard"> Ctrl+Shift+J</td>
</tr>
<tr style="text-align:left" valign="top">
<td headers="name"><strong>Add Bookmark...</strong></td>
<td headers="function">Add a bookmark to the current text selection or selected element.</td>
<td headers="keyboard">&nbsp; </td>
</tr> </tr>
<tr>
<tr style="text-align:left" valign="top"> <td class="menu_name" headers="name">Cut</td>
<td headers="name"><strong>Add Task...</strong></td> <td headers="function">Copies the currently selected text to
<td headers="function">Add a user defined task to the current text selection or selected element.</td> the clipboard and removes it from the editor</td>
<td headers="keyboard"> Alt+Enter</td> <td headers="keyboard">Ctrl+X</td>
</tr> </tr>
<tr>
<tr style="text-align:left" valign="top"> <td class="menu_name" headers="name">Copy</td>
<td headers="name"><strong>Add to working set</strong></td> <td headers="function">Copies the currently selected text to
<td headers="function">Add current resource to selected Working Set</td> the clipboard</td>
<td headers="keyboard"> Ctrl+I</td> <td headers="keyboard">Ctrl+C</td>
</tr> </tr>
<tr>
<tr> <td class="menu_name" headers="name">Paste</td>
<td headers="name"><strong>Remove from working set</strong></td> <td headers="function">Pastes the contents of the clipboard,
<td headers="function">Remove current resource from Working Set</td> as text, to the currently active editor window</td>
<td headers="keyboard"> Ctrl+Shift+I</td> <td headers="keyboard">Ctrl+V</td>
</tr> </tr>
<tr>
<tr> <td class="menu_name" headers="name">Delete</td>
<td headers="name"><strong>Smart Insert Mode</strong></td> <td headers="function">Deletes the currently selected text</td>
<td headers="function">Toggles editor's Smart Insert Mode</td> <td headers="keyboard">Delete</td>
<td headers="keyboard"> Ctrl+Shift+Insert</td> </tr>
</tr> <tr>
<td class="menu_name" headers="name">Select All</td>
<tr> <td headers="function">Selects all the text in the currently
<td headers="name"><strong>Show Tooltip Description</strong></td> active editor window</td>
<td headers="function">Displays tooltip description, where applicable.</td> <td headers="keyboard">Ctrl+A</td>
</tr>
<tr>
<td rowspan="5" class="menu_name" headers="name">Expand
Selection To</td>
<td headers="function"><p>Expands the selection (or
creates a selection starting from the cursor) in the following
ways:</p></td>
<td headers="keyboard">Alt+Shift+<i>Arrow Keys</i></td>
</tr>
<tr>
<td headers="function">
<dl>
<dt>Enclosing Element</dt>
<dd>Adds the enclosing expression or block to the selection
(It relies on the embedded parser, so may fail when syntax
errors are present.)</dd>
</dl>
</td>
<td headers="keyboard">Alt+Shift+Up</td>
</tr>
<tr>
<td headers="function">
<dl>
<dt>Next Element</dt>
<dd>Adds the following element to the selection</dd>
</dl>
</td>
<td headers="keyboard">Alt+Shift+Right</td>
</tr>
<tr>
<td headers="function">
<dl>
<dt>Previous Element</dt>
<dd>Adds the preceding element to the selection</dd>
</dl>
</td>
<td headers="keyboard">Alt+Shift+Left</td>
</tr>
<tr>
<td headers="function">
<dl>
<dt>Restore Last Selection</dt>
<dd>
Restores the previous selection after an invocation of <strong>Expand
Selection To</strong>.
</dd>
</dl>
</td>
<td headers="keyboard">Alt+Shift+Down</td>
</tr>
<tr>
<td class="menu_name" headers="name">Find / Replace...</td>
<td headers="function">Opens the basic in-editor Find /
Replace dialog</td>
<td headers="keyboard">Ctrl+F</td>
</tr>
<tr>
<td class="menu_name" headers="name">Find Word</td>
<td headers="function">Finds the next occurrence of either the
word containing the cursor, or the first word of the current
selection, if it covers multiple words (Added for Visual Studio
compatibility.)</td>
<td headers="keyboard">&nbsp;</td>
</tr>
<tr>
<td class="menu_name" headers="name">Find Next</td>
<td headers="function">Finds the next occurrence of the
currently selected text, or the last text searched for, if there
is no selection</td>
<td headers="keyboard">Ctrl+K</td>
</tr>
<tr>
<td class="menu_name" headers="name">Find Previous</td>
<td headers="function">Finds the previous occurrence of the
currently selected text, or the last text searched for, if there
is no selection</td>
<td headers="keyboard">Ctrl+Shift+K</td>
</tr>
<tr>
<td class="menu_name" headers="name">Incremental Find Next</td>
<td headers="function">Starts the incremental find mode
(Whatever is typed afterward will be searched for.)</td>
<td headers="keyboard">Ctrl+J</td>
</tr>
<tr>
<td class="menu_name" headers="name">Incremental Find Previous</td>
<td headers="function">Starts the incremental find mode,
looking backward</td>
<td headers="keyboard">Ctrl+Shift+J</td>
</tr>
<tr>
<td class="menu_name" headers="name">Add Bookmark...</td>
<td headers="function">Adds a bookmark pointing to the current
cursor position or selected text</td>
<td headers="keyboard">&nbsp;</td>
</tr>
<tr>
<td class="menu_name" headers="name">Add Task...</td>
<td headers="function">Adds a user defined task located at the
current line</td>
<td headers="keyboard">&nbsp;</td>
</tr>
<tr>
<td class="menu_name" headers="name">Smart Insert Mode</td>
<td headers="function">Toggles the Smart Insert mode (i.e. the
auto-completion features defined in <strong>C/C++ &gt;
Editor &gt; Typing</strong>)
</td>
<td headers="keyboard">Ctrl+Shift+Insert</td>
</tr>
<tr>
<td class="menu_name" headers="name">Show Tooltip Description</td>
<td headers="function">Displays the tooltip appropriate to the
cursor position.</td>
<td headers="keyboard">F2</td> <td headers="keyboard">F2</td>
</tr> </tr>
<tr>
<tr> <td class="menu_name" headers="name">Word Completion</td>
<td headers="name"><strong>Word Completion</strong></td> <td headers="function">Completes the word containing the
<td headers="function">Completes current word in editor.</td> cursor using the next available completion (If invoked repeatedly
it will cycle through the possibilities.)</td>
<td headers="keyboard">Alt+/</td> <td headers="keyboard">Alt+/</td>
</tr> </tr>
<tr>
<tr> <td class="menu_name" headers="name">Quick Fix</td>
<td headers="name"><strong>Quick fix</strong></td> <td headers="function">Displays the Quick Fix dialog
<td headers="function">Call quick fix dialog for selected warning/error.</td> appropriate to the cursor position.</td>
<td headers="keyboard"> Ctrl+1</td> <td headers="keyboard">Ctrl+1</td>
</tr> </tr>
<tr>
<tr> <td class="menu_name" headers="name">Content Assist</td>
<td headers="name"><strong>Content Assist</strong></td> <td headers="function">Displays the Content Assist dialog
<td headers="function">Opens a context assist dialog at the current cursor position to bring up Java code assist proposals and templates. See the Templates preference page for available templates appropriate to the cursor position (If invoked repeatedly it will
<strong>Window &gt; Preferences &gt; C/C++ &gt; Editor &gt; Templates</strong> and go to the Editor preference page cycle through the available proposal types.)</td>
<strong>Window &gt; Preferences &gt; C/C++ &gt; Editor &gt; Content Assist</strong> for configuring the behavior of content assist.</td> <td headers="keyboard">Ctrl+Space</td>
<td headers="keyboard"> Ctrl+Space</td> </tr>
</tr> <tr>
<td class="menu_name" headers="name">Parameter Hints</td>
<tr> <td headers="function">Displays the possible signatures in a
<td headers="name"><strong>Parameter Hints</strong></td> tooltip (Enabled when the cursor is in a parameter list)</td>
<td headers="function">Opens Parameter Hints dialog. Editor only</td>
<td headers="keyboard">Ctrl+Shift+Space</td> <td headers="keyboard">Ctrl+Shift+Space</td>
</tr> </tr>
<tr>
<td class="menu_name" headers="name">Set Encoding...</td>
<tr style="text-align:left" valign="top"> <td headers="function">Displays a dialog in which the encoding
<td headers="name"><strong>Shift Right</strong></td> of the active editor can be specified</td>
<td headers="function">Shifts text Right. Editor only</td>
<td headers="keyboard">&nbsp;</td>
</tr>
<tr>
<td headers="name"><strong>Shift Left</strong></td>
<td headers="function">Shifts text Right. Editor only</td>
<td headers="keyboard">&nbsp;</td>
</tr>
<tr>
<td headers="name"><strong>Format</strong></td>
<td headers="function">Formats text. Editor only</td>
<td headers="keyboard">Ctrl+Shift+F</td>
</tr>
<tr>
<td headers="name"><strong>Add Include</strong></td>
<td headers="function">Add include to current file. Editor only </td>
<td headers="keyboard">Ctrl+Shift+N</td>
</tr>
<tr>
<td headers="name"><strong>Set Encoding... </strong></td>
<td headers="function">Toggles the encoding of the currently shown text content.</td>
<td headers="keyboard">&nbsp;</td> <td headers="keyboard">&nbsp;</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
<p></p> <p>
<img alt="IBM Copyright Statement" src="../images/ng00_04a.gif">
</p>
<p><strong>Note: </strong> Other <strong>Edit</strong> options are used with the JDT. Refer to the <em>Java Development User Guide</em> for details. </p> </div>
</body>
<p>
<IMG alt="IBM Copyright Statement" src="../images/ng00_04a.gif" border=0>
</p>
</div></body>
</html> </html>

231
doc/org.eclipse.cdt.doc.user/reference/cdt_u_m_file.htm Normal file → Executable file
View file

@ -1,141 +1,148 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en"> <html lang="en">
<head> <head>
<meta http-equiv="Content-Language" content="en-us"> <meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>File Menu actions</title> <title>File Menu actions</title>
<link rel="stylesheet" type="text/css" href="../help.css"> <link rel="stylesheet" type="text/css" href="../help.css">
</head> </head>
<body> <body>
<div role="main">
<div role="main"><h1>File Menu actions</h1> <h1>File Menu actions</h1>
<p><img src="../images/cdt_menu_file.png" alt="Selecting File Menu" ></p> <p>
<img src="../images/cdt_menu_file.png" alt="Selecting File Menu">
<p> </p>
<table border="1" cellspacing="0" cellpadding="3"> <table class="menu" border="1" cellspacing="0">
<tbody> <thead>
<tr><th id="name">Name</th><th id="function">Function</th><th id="keyboard">Keyboard Shortcut</th></tr>
<tr valign="top">
<td valign="top" headers="name"><strong>New</strong></td>
<td valign="top" headers="function">Create a new project, folder, or file.</td>
<td valign="top" headers="keyboard">Alt+Shift+N</td>
</tr>
<tr valign="top">
<td valign="top" headers="name"><strong>Open File...</strong></td>
<td valign="top" headers="function">Open existing file.</td>
<td valign="top" headers="keyboard">&nbsp;</td>
</tr>
<tr> <tr>
<td valign="top" headers="name"><strong>Close</strong></td> <th id="name">Name</th>
<td valign="top" headers="function">Close the current editor. <th id="function">Function</th>
If the editor contains unsaved data, a save request dialog is shown.</td> <th id="keyboard">Keyboard Shortcut</th>
<td valign="top" headers="keyboard">Ctrl+F4</td>
</tr> </tr>
</thead>
<tbody>
<tr> <tr>
<td valign="top" headers="name"><strong>Close All</strong></td> <td class="menu_name" headers="name">New (submenu)</td>
<td valign="top" headers="function">Close all editors. <td headers="function">Creates a new project, folder, or file</td>
If editors contains unsaved data, a save request dialog will be shown.</td> <td headers="keyboard">Alt+Shift+N</td>
<td valign="top" headers="keyboard">Ctrl+Shift+F4</td>
</tr> </tr>
<tr> <tr>
<td valign="top" headers="name"><strong>Save</strong></td> <td class="menu_name" headers="name">Open File...</td>
<td valign="top" headers="function">Save the content of the current editor. <td headers="function">Opens an existing file</td>
Disabled if the editor does not contain unsaved changes.</td> <td headers="keyboard">&nbsp;</td>
<td valign="top" headers="keyboard">Ctrl+S</td>
</tr> </tr>
<tr> <tr>
<td valign="top" headers="name"><strong>Save As</strong></td> <td class="menu_name" headers="name">Close</td>
<td valign="top" headers="function">Save the content of the current editor under a new name.</td> <td headers="function">Closes the current editor (If the
<td valign="top" headers="keyboard">&nbsp;</td> editor contains unsaved data, a save request dialog is shown.)</td>
<td headers="keyboard">Ctrl+W</td>
</tr> </tr>
<tr> <tr>
<td valign="top" headers="name"><strong>Save All</strong></td> <td class="menu_name" headers="name">Close All</td>
<td valign="top" headers="function">Save the content of the current editor. <td headers="function">Closes all editors (If any editors
Disabled if no editor contains unsaved changes.</td> contain unsaved data, save request dialogs will be shown for
<td valign="top" headers="keyboard">Ctrl+Shift+S</td> them.)</td>
<td headers="keyboard">Ctrl+Shift+W</td>
</tr> </tr>
<tr valign="top">
<td valign="top" headers="name"><strong>Revert</strong></td>
<td valign="top" headers="function">Revert the content of the current editor back to the content of the saved file.
Disabled if the editor does not contain unsaved changes.</td>
<td valign="top" headers="keyboard">&nbsp;</td>
</tr>
<tr valign="top">
<td valign="top" headers="name"><strong>Move</strong></td>
<td valign="top" headers="function">Move a resource.</td>
<td valign="top" headers="keyboard">&nbsp;</td>
</tr>
<tr valign="top">
<td valign="top" headers="name"><strong>Rename</strong></td>
<td valign="top" headers="function">Renames a resource.</td>
<td valign="top" headers="keyboard">F2</td>
</tr>
<tr> <tr>
<td valign="top" headers="name"><strong>Refresh</strong></td> <td class="menu_name" headers="name">Save</td>
<td valign="top" headers="function">Refreshes the content of the selected element with the local file system. <td headers="function">Saves the content of the current editor
When launched from no specific selection, this command refreshes all projects.</td> (Disabled if the editor does not contain unsaved changes.)</td>
<td valign="top" headers="keyboard">F5</td> <td headers="keyboard">Ctrl+S</td>
</tr> </tr>
<tr valign="top">
<td valign="top" headers="name"><strong>Convert Line Delimiters to (submenu)</strong></td>
<td valign="top" headers="function">Changes line delimiters either to Windows, or UNIX, or Mac OS9 format.</td>
<td valign="top" headers="keyboard">&nbsp;</td>
</tr>
<tr> <tr>
<td valign="top" headers="name"><strong>Print</strong></td> <td class="menu_name" headers="name">Save As...</td>
<td valign="top" headers="function">Prints the content of the current editor. Enabled when an editor has the focus.</td> <td headers="function">Saves the content of the current editor
<td valign="top" headers="keyboard">Ctrl+P</td> under a new name</td>
<td headers="keyboard">&nbsp;</td>
</tr> </tr>
<tr valign="top">
<td valign="top" headers="name"><strong>Switch workspace...</strong></td>
<td valign="top" headers="function">Relaunches Eclipse with a new workspace.</td>
<td valign="top" headers="keyboard">&nbsp;</td>
</tr>
<tr> <tr>
<td valign="top" headers="name"><strong>Import</strong></td> <td class="menu_name" headers="name">Save All</td>
<td valign="top" headers="function">Opens the <strong>Import</strong> dialog and shows all import wizards.</td> <td headers="function">Saves the content of all open editor
<td valign="top" headers="keyboard">&nbsp;</td> windows (Disabled if no editor contains unsaved changes.)</td>
<td headers="keyboard">Ctrl+Shift+S</td>
</tr> </tr>
<tr>
<tr valign="top"> <td class="menu_name" headers="name">Revert</td>
<td valign="top" headers="name"><strong>Export</strong></td> <td headers="function">Reverts the content of the current
<td valign="top" headers="function">Opens the <strong>Export</strong> dialog and shows all export wizards.</td> editor back to its most recently saved state (Disabled if the
<td valign="top" headers="keyboard">&nbsp;</td> editor does not contain unsaved changes.)</td>
<td headers="keyboard">&nbsp;</td>
</tr> </tr>
<tr>
<tr valign="top"> <td class="menu_name" headers="name">Move...</td>
<td valign="top" headers="name"><strong>Properties</strong></td> <td headers="function">Moves a resource</td>
<td valign="top" headers="function">Opens the property pages of the select elements.</td> <td headers="keyboard">&nbsp;</td>
<td valign="top" headers="keyboard">Alt+Enter</td>
</tr> </tr>
<tr>
<tr valign="top"> <td class="menu_name" headers="name">Rename...</td>
<td valign="top" headers="name"><strong>Exit</strong></td> <td headers="function">Renames a resource</td>
<td valign="top" headers="function">Exit Eclipse</td> <td headers="keyboard">F2</td>
<td valign="top" headers="keyboard">&nbsp;</td>
</tr> </tr>
</tbody></table> <tr>
<p></p> <td class="menu_name" headers="name">Refresh</td>
<td headers="function">Refreshes the selected element against
<p> the local file system (If nothing is selected, all open projects
<img src="../images/ng00_04a.gif" ALT="IBM Copyright Statement" > are refreshed.)</td>
</p> <td headers="keyboard">F5</td>
</div></body> </tr>
<tr>
<td class="menu_name" headers="name">Convert Line Delimiters
to (submenu)</td>
<td headers="function">Changes the line delimiters of the
current editor to Windows (\r\n), or UNIX (\n) format</td>
<td headers="keyboard">&nbsp;</td>
</tr>
<tr>
<td class="menu_name" headers="name">Print...</td>
<td headers="function">Prints the content of the current
editor (Enabled when an editor has the focus.)</td>
<td headers="keyboard">Ctrl+P</td>
</tr>
<tr>
<td class="menu_name" headers="name">Switch workspace
(submenu)</td>
<td headers="function">Changes the active workspace (The
submenu contains a list of recently used workspaces, and <strong>Other...</strong>,
which brings up a workspace selection dialog)
</td>
<td headers="keyboard">&nbsp;</td>
</tr>
<tr>
<td class="menu_name" headers="name">Restart</td>
<td headers="function">Relaunches Eclipse</td>
<td headers="keyboard">&nbsp;</td>
</tr>
<tr>
<td class="menu_name" headers="name">Import...</td>
<td headers="function">Opens the <strong>Import</strong>
dialog, which allows the selection of an Import wizard
</td>
<td headers="keyboard">&nbsp;</td>
</tr>
<tr>
<td class="menu_name" headers="name">Export</td>
<td headers="function">Opens the <strong>Export</strong>
dialog, which allows the selection of an Export wizard
</td>
<td headers="keyboard">&nbsp;</td>
</tr>
<tr>
<td class="menu_name" headers="name">Properties</td>
<td headers="function">Opens the property page for the
selected element</td>
<td headers="keyboard">Alt+Enter</td>
</tr>
<tr>
<td class="menu_name" headers="name">Exit</td>
<td headers="function">Exits Eclipse</td>
<td headers="keyboard">&nbsp;</td>
</tr>
</tbody>
</table>
<p>
<img alt="IBM Copyright Statement" src="../images/ng00_04a.gif">
</p>
</div>
</body>
</html> </html>

View file

@ -13,21 +13,21 @@
<p><img src="../images/cdt_menu_navigate.png" alt="Selecting Navigate Menu" ></p> <p><img src="../images/cdt_menu_navigate.png" alt="Selecting Navigate Menu" ></p>
<p> <p>
<table border="1" cellspacing="0" cellpadding="3"> <table class="menu" border="1" cellspacing="0" cellpadding="3">
<tbody> <tbody>
<tr><th id="name">Name</th><th id="function">Function</th><th id="keyboard">Keyboard Shortcut</th></tr> <tr><th id="name">Name</th><th id="function">Function</th><th id="keyboard">Keyboard Shortcut</th></tr>
<tr> <tr>
<td valign="top" headers="name"><strong>Go Into</strong></td> <td class="menu_name" headers="name">Go Into</td>
<td valign="top" headers="function">Sets the view input to the currently selected element.</td> <td headers="function">Sets the view input to the currently selected element.</td>
<td valign="top" headers="keyboard">&nbsp;</td> <td headers="keyboard">&nbsp;</td>
</tr> </tr>
<tr> <tr>
<td valign="top" headers="name"><strong>Go To</strong></td> <td class="menu_name" headers="name">Go To</td>
<td valign="top" headers="function"><ul> <td headers="function"><ul>
<li><strong>Back</strong>:&nbsp; This command displays the hierarchy that was displayed immediately prior to the current display.&nbsp; <li><strong>Back</strong>:&nbsp; This command displays the hierarchy that was displayed immediately prior to the current display.&nbsp;
For example, if you Go Into a resource, then the Back command in the resulting display returns the view to the same hierarchy from which you activated the Go Into command.&nbsp; For example, if you Go Into a resource, then the Back command in the resulting display returns the view to the same hierarchy from which you activated the Go Into command.&nbsp;
This command is similar to the Back button in an HTML browser.</li> This command is similar to the Back button in an HTML browser.</li>
@ -38,100 +38,100 @@
<li><strong>Resource</strong>: This command allows you to navigate quickly to a resource. For more information see the links to related tasks below.</li> <li><strong>Resource</strong>: This command allows you to navigate quickly to a resource. For more information see the links to related tasks below.</li>
</ul> </ul>
</td> </td>
<td valign="top" headers="keyboard">&nbsp;</td> <td headers="keyboard">&nbsp;</td>
</tr> </tr>
<tr> <tr>
<td valign="top" headers="name"><strong>Open Type Hierarchy</strong></td> <td class="menu_name" headers="name">Open Type Hierarchy</td>
<td valign="top" headers="function">Opens Type Hierarchy view for selected object</td> <td headers="function">Opens Type Hierarchy view for selected object</td>
<td valign="top" headers="keyboard">F4</td> <td headers="keyboard">F4</td>
</tr> </tr>
<tr> <tr>
<td valign="top" headers="name"><strong>Open Call Hierarchy</strong></td> <td class="menu_name" headers="name">Open Call Hierarchy</td>
<td valign="top" headers="function">Opens Call Hierarchy view for selected object</td> <td headers="function">Opens Call Hierarchy view for selected object</td>
<td valign="top" headers="keyboard">Ctrl+Alt+H</td> <td headers="keyboard">Ctrl+Alt+H</td>
</tr> </tr>
<tr> <tr>
<td valign="top" headers="name"><strong>Open Declaration</strong></td> <td class="menu_name" headers="name">Open Declaration</td>
<td valign="top" headers="function">Opens Declaration for selected object (class, variable...)</td> <td headers="function">Opens Declaration for selected object (class, variable...)</td>
<td valign="top" headers="keyboard">F3</td> <td headers="keyboard">F3</td>
</tr> </tr>
<tr> <tr>
<td valign="top" headers="name"><strong>Toggle Source/Header</strong></td> <td class="menu_name" headers="name">Toggle Source/Header</td>
<td valign="top" headers="function">Switches between source and corresponding header files.</td> <td headers="function">Switches between source and corresponding header files.</td>
<td valign="top" headers="keyboard">&nbsp;</td> <td headers="keyboard">&nbsp;</td>
</tr> </tr>
<tr> <tr>
<td valign="top" headers="name"><strong>Open Element...</strong></td> <td class="menu_name" headers="name">Open Element...</td>
<td valign="top" headers="function">Brings up the Open Element selection dialog to open an element in the editor. This dialog shows all types existing in the workspace. </td> <td headers="function">Brings up the Open Element selection dialog to open an element in the editor. This dialog shows all types existing in the workspace. </td>
<td valign="top" headers="keyboard">Ctrl+Shift+T</td> <td headers="keyboard">Ctrl+Shift+T</td>
</tr> </tr>
<tr> <tr>
<td valign="top" headers="name"><strong>Open Resource</strong></td> <td class="menu_name" headers="name">Open Resource</td>
<td valign="top" headers="function">This command displays a dialog that lets you select any resource in the workspace to open it in an editor. <td headers="function">This command displays a dialog that lets you select any resource in the workspace to open it in an editor.
</td> </td>
<td valign="top" headers="keyboard">Ctrl+Shift+R</td> <td headers="keyboard">Ctrl+Shift+R</td>
</tr> </tr>
<tr> <tr>
<td valign="top" headers="name"><strong>Show In</strong></td> <td class="menu_name" headers="name">Show In</td>
<td valign="top" headers="function">This sub-menu is used to find and select the currently selected resource in another view. If an editor is active, these commands are used to select the resource currently being edited in another view.</td> <td headers="function">This sub-menu is used to find and select the currently selected resource in another view. If an editor is active, these commands are used to select the resource currently being edited in another view.</td>
<td valign="top" headers="keyboard">Ctrl+Shift+W</td> <td headers="keyboard">Ctrl+Shift+W</td>
</tr> </tr>
<tr> <tr>
<td valign="top" headers="name"><strong>Quick Outline</strong></td> <td class="menu_name" headers="name">Quick Outline</td>
<td valign="top" headers="function">Displays outline view for current source file.</td> <td headers="function">Displays outline view for current source file.</td>
<td valign="top" headers="keyboard">&nbsp;</td> <td headers="keyboard">&nbsp;</td>
</tr> </tr>
<tr> <tr>
<td valign="top" headers="name"><strong>Next</strong></td> <td class="menu_name" headers="name">Next</td>
<td valign="top" headers="function">The &quot;next&quot; definition is based on where the focus is. For example, during a search this entry becomes <strong>Next Match</strong>.</td> <td headers="function">The &quot;next&quot; definition is based on where the focus is. For example, during a search this entry becomes <strong>Next Match</strong>.</td>
<td valign="top" headers="keyboard">Ctrl+.</td> <td headers="keyboard">Ctrl+.</td>
</tr> </tr>
<tr> <tr>
<td valign="top" headers="name"><strong>Previous</strong></td> <td class="menu_name" headers="name">Previous</td>
<td valign="top" headers="function">The &quot;previous&quot; definition is based on <td headers="function">The &quot;previous&quot; definition is based on
where the focus is. where the focus is.
For example, during a search this entry becomes <strong>Previous Match</strong>.</td> For example, during a search this entry becomes <strong>Previous Match</strong>.</td>
<td valign="top" headers="keyboard">Ctrl+,</td> <td headers="keyboard">Ctrl+,</td>
</tr> </tr>
<tr> <tr>
<td valign="top" headers="name"><strong>Last Edit Location</strong></td> <td class="menu_name" headers="name">Last Edit Location</td>
<td valign="top" headers="function">Moves the cursor to the line that contains the last edit. <td headers="function">Moves the cursor to the line that contains the last edit.
Editor only.</td> Editor only.</td>
<td valign="top" headers="keyboard">Ctrl+Q</td> <td headers="keyboard">Ctrl+Q</td>
</tr> </tr>
<tr> <tr>
<td valign="top" headers="name"><strong>Go to Line</strong></td> <td class="menu_name" headers="name">Go to Line</td>
<td valign="top" headers="function">Open a dialog where you can specify the line number <td headers="function">Open a dialog where you can specify the line number
to which to move the cursor. to which to move the cursor.
Editor only.</td> Editor only.</td>
<td valign="top" headers="keyboard">Ctrl+L</td> <td headers="keyboard">Ctrl+L</td>
</tr> </tr>
<tr> <tr>
<td valign="top" headers="name"><strong>Back</strong></td> <td class="menu_name" headers="name">Back</td>
<td valign="top" headers="function">Moves the focus to the previous file. <td headers="function">Moves the focus to the previous file.
Editor only.</td> Editor only.</td>
<td valign="top" headers="keyboard">Ctrl+Q</td> <td headers="keyboard">Ctrl+Q</td>
</tr> </tr>
<tr> <tr>
<td valign="top" headers="name"><strong>Forward</strong></td> <td class="menu_name" headers="name">Forward</td>
<td valign="top" headers="function">Returns the focus from the previous file. <td headers="function">Returns the focus from the previous file.
Editor only.</td> Editor only.</td>
<td valign="top" headers="keyboard">Ctrl+Q</td> <td headers="keyboard">Ctrl+Q</td>
</tr> </tr>
</tbody> </tbody>

View file

@ -14,31 +14,31 @@
<p><img src="../images/cdt_menu_project.png" alt="Selecting Project Menu" ></p> <p><img src="../images/cdt_menu_project.png" alt="Selecting Project Menu" ></p>
<p><table border="1" cellspacing="0"> <p><table class="menu" border="1" cellspacing="0">
<tr><th id="name">Name</th><th id="function">Function</th><th id="keyboard">Keyboard Shortcut</th></tr> <tr><th id="name">Name</th><th id="function">Function</th><th id="keyboard">Keyboard Shortcut</th></tr>
<tr> <tr>
<td headers="name"><strong>Open Project</strong></td> <td class="menu_name" headers="name">Open Project</td>
<td headers="function">Shows a dialog that can be used to select a closed project and open it.</td> <td headers="function">Shows a dialog that can be used to select a closed project and open it.</td>
<td headers="keyboard">&nbsp;</td> <td headers="keyboard">&nbsp;</td>
</tr> </tr>
<tr> <tr>
<td headers="name"><strong>Close Project</strong></td> <td class="menu_name" headers="name">Close Project</td>
<td headers="function">Closes the currently selected projects.</td> <td headers="function">Closes the currently selected projects.</td>
<td headers="keyboard">&nbsp;</td> <td headers="keyboard">&nbsp;</td>
</tr> </tr>
<tr> <tr>
<td headers="name"><strong>Build All</strong></td> <td class="menu_name" headers="name">Build All</td>
<td headers="function">Builds all projects in the workspace. This is a full build; all files are built.</td> <td headers="function">Builds all projects in the workspace. This is a full build; all files are built.</td>
<td headers="keyboard">Ctrl+B</td> <td headers="keyboard">Ctrl+B</td>
</tr> </tr>
<tr> <tr>
<td headers="name"><strong>Build parallel</strong></td> <td class="menu_name" headers="name">Build parallel</td>
<td headers="function">Builds all (or selected) configurations of given project(s). Each configuration is built as separate parallel task.</td> <td headers="function">Builds all (or selected) configurations of given project(s). Each configuration is built as separate parallel task.</td>
<td headers="keyboard">&nbsp;</td> <td headers="keyboard">&nbsp;</td>
</tr> </tr>
<tr> <tr>
<td headers="name"><strong>Build Configurations</strong></td> <td class="menu_name" headers="name">Build Configurations</td>
<td headers="function">Submenu which allows to: <td headers="function">Submenu which allows to:
<ul> <ul>
<li>Delete resource configuration for file/folder <li>Delete resource configuration for file/folder
@ -49,32 +49,32 @@
<td headers="keyboard">&nbsp;</td> <td headers="keyboard">&nbsp;</td>
</tr> </tr>
<tr> <tr>
<td headers="name"><strong>Build Project</strong></td> <td class="menu_name" headers="name">Build Project</td>
<td headers="function">Builds the currently selected project. This is a full build; all files in the project are built. </td> <td headers="function">Builds the currently selected project. This is a full build; all files in the project are built. </td>
<td headers="keyboard">&nbsp;</td> <td headers="keyboard">&nbsp;</td>
</tr> </tr>
<tr> <tr>
<td headers="name"><strong>Build Working Set</strong></td> <td class="menu_name" headers="name">Build Working Set</td>
<td headers="function">Builds the current working set.</td> <td headers="function">Builds the current working set.</td>
<td headers="keyboard">&nbsp;</td> <td headers="keyboard">&nbsp;</td>
</tr> </tr>
<tr> <tr>
<td headers="name"><strong>Clean</strong></td> <td class="menu_name" headers="name">Clean</td>
<td headers="function">Invokes the make clean defined in the makefile</td> <td headers="function">Invokes the make clean defined in the makefile</td>
<td headers="keyboard">&nbsp;</td> <td headers="keyboard">&nbsp;</td>
</tr> </tr>
<tr> <tr>
<td headers="name"><strong>Build Automatically</strong></td> <td class="menu_name" headers="name">Build Automatically</td>
<td headers="function">When checked, the CDT will perform a build whenever a file in a project is saved. You should turn this feature off for very large projects.</td> <td headers="function">When checked, the CDT will perform a build whenever a file in a project is saved. You should turn this feature off for very large projects.</td>
<td headers="keyboard">&nbsp;</td> <td headers="keyboard">&nbsp;</td>
</tr> </tr>
<tr> <tr>
<td headers="name"><strong>Make Target</strong></td> <td class="menu_name" headers="name">Make Target</td>
<td headers="function">Submenu which allows create or build a target in the <strong>Make Targets</strong> view.</td> <td headers="function">Submenu which allows create or build a target in the <strong>Make Targets</strong> view.</td>
<td headers="keyboard">&nbsp;</td> <td headers="keyboard">&nbsp;</td>
</tr> </tr>
<tr> <tr>
<td headers="name"><strong>Properties</strong></td> <td class="menu_name" headers="name">Properties</td>
<td headers="function">Displays the <strong>Properties</strong> dialog. From that dialog you can display the properties of resources in <strong>Info</strong>, <td headers="function">Displays the <strong>Properties</strong> dialog. From that dialog you can display the properties of resources in <strong>Info</strong>,
<strong>External Tools Builders</strong>, <strong>C/C++ Build</strong> (managed only) <strong>File Types</strong>, <strong>Indexer options</strong>, <strong>External Tools Builders</strong>, <strong>C/C++ Build</strong> (managed only) <strong>File Types</strong>, <strong>Indexer options</strong>,
<strong>C/C++ Make Project</strong> (standard only), <strong>C/C++ Project Paths</strong> (standard only), <strong>C/C++ Make Project</strong> (standard only), <strong>C/C++ Project Paths</strong> (standard only),

View file

@ -17,55 +17,55 @@
alt="Selecting Refactor Menu"> alt="Selecting Refactor Menu">
</p> </p>
<table border="1" cellspacing="0"> <table class="menu" border="1" cellspacing="0">
<tr> <tr>
<th id="name">Name</th> <th id="name">Name</th>
<th id="function">Function</th> <th id="function">Function</th>
<th id="keyboard">Keyboard Shortcut</th> <th id="keyboard">Keyboard Shortcut</th>
</tr> </tr>
<tr> <tr>
<td headers="name"><strong>Apply Script...</strong></td> <td class="menu_name" headers="name">Apply Script...</td>
<td headers="function">Applies a previously saved list of refactorings.</td> <td headers="function">Applies a previously saved list of refactorings.</td>
<td headers="keyboard">&nbsp;</td> <td headers="keyboard">&nbsp;</td>
</tr> </tr>
<tr> <tr>
<td headers="name"><strong>Create Script...</strong></td> <td class="menu_name" headers="name">Create Script...</td>
<td headers="function">Exports a list of previously done refactorings for later use.</td> <td headers="function">Exports a list of previously done refactorings for later use.</td>
<td headers="keyboard">&nbsp;</td> <td headers="keyboard">&nbsp;</td>
</tr> </tr>
<tr> <tr>
<td headers="name"><strong>History...</strong></td> <td class="menu_name" headers="name">History...</td>
<td headers="function">Displays a history of refactorings.</td> <td headers="function">Displays a history of refactorings.</td>
<td headers="keyboard">&nbsp;</td> <td headers="keyboard">&nbsp;</td>
</tr> </tr>
<tr> <tr>
<td headers="name"><strong>Rename...</strong></td> <td class="menu_name" headers="name">Rename...</td>
<td headers="function">Renames selected object (variable, <td headers="function">Renames selected object (variable,
method, etc...) and propagates changes to other files in project.</td> method, etc...) and propagates changes to other files in project.</td>
<td headers="keyboard">Alt+Shift+R</td> <td headers="keyboard">Alt+Shift+R</td>
</tr> </tr>
<tr> <tr>
<td headers="name"><strong>Extract Local Variable...</strong></td> <td class="menu_name" headers="name">Extract Local Variable...</td>
<td headers="function">Extracts selected subexpression into a new local variable.</td> <td headers="function">Extracts selected subexpression into a new local variable.</td>
<td headers="keyboard">Alt+Shift+L</td> <td headers="keyboard">Alt+Shift+L</td>
</tr> </tr>
<tr> <tr>
<td headers="name"><strong>Extract Constant...</strong></td> <td class="menu_name" headers="name">Extract Constant...</td>
<td headers="function">Replaces all instances of selected literal with a named constant.</td> <td headers="function">Replaces all instances of selected literal with a named constant.</td>
<td headers="keyboard">Alt+C</td> <td headers="keyboard">Alt+C</td>
</tr> </tr>
<tr> <tr>
<td headers="name"><strong>Extract Function...</strong></td> <td class="menu_name" headers="name">Extract Function...</td>
<td headers="function">Replaces selected statements with a call to a new function containing them.</td> <td headers="function">Replaces selected statements with a call to a new function containing them.</td>
<td headers="keyboard">Alt+Shift+M</td> <td headers="keyboard">Alt+Shift+M</td>
</tr> </tr>
<tr> <tr>
<td headers="name"><strong>Toggle Function Definition</strong></td> <td class="menu_name" headers="name">Toggle Function Definition</td>
<td headers="function">Moves selected function definition from a header file (in- or outside a class definition) to an implementation file, or back.</td> <td headers="function">Moves selected function definition from a header file (in- or outside a class definition) to an implementation file, or back.</td>
<td headers="keyboard">Alt+Shift+T</td> <td headers="keyboard">Alt+Shift+T</td>
</tr> </tr>
<tr> <tr>
<td headers="name"><strong>Hide Method...</strong></td> <td class="menu_name" headers="name">Hide Method...</td>
<td headers="function">Makes selected method private.</td> <td headers="function">Makes selected method private.</td>
<td headers="keyboard">&nbsp;</td> <td headers="keyboard">&nbsp;</td>
</tr> </tr>

66
doc/org.eclipse.cdt.doc.user/reference/cdt_u_m_run.htm Normal file → Executable file
View file

@ -14,61 +14,61 @@
<p><img src="../images/cdt_menu_run.png" alt="Run Menu" ></p> <p><img src="../images/cdt_menu_run.png" alt="Run Menu" ></p>
<p><table border="1" cellspacing="0" cellpadding="3"> <p><table class="menu" border="1" cellspacing="0" cellpadding="3">
<tr><th id="name">Name</th><th id="function">Function</th><th id="keyboard">Keyboard Shortcut</th></tr> <tr><th id="name">Name</th><th id="function">Function</th><th id="keyboard">Keyboard Shortcut</th></tr>
<tr valign="top"> <tr>
<td valign="top" headers="name"><strong>Run</strong></td> <td class="menu_name" headers="name">Run</td>
<td valign="top" headers="function"> This command allows you to quickly repeat the most recent launch in run mode.</td> <td headers="function"> This command allows you to quickly repeat the most recent launch in run mode.</td>
<td valign="top" headers="keyboard"> Ctrl+F11</td> <td headers="keyboard"> Ctrl+F11</td>
</tr>
<tr valign="top">
<td valign="top" headers="name"><strong>Debug</strong></td>
<td valign="top" headers="function"> This command allows you to quickly repeat the most recent launch in debug mode.</td>
<td valign="top" headers="keyboard"> F11</td>
</tr> </tr>
<tr> <tr>
<td valign="top" headers="name"><strong>Run History</strong></td> <td class="menu_name" headers="name">Debug</td>
<td valign="top" headers="function"> Presents a sub menu of the recent history of launch configurations launched in run mode.</td> <td headers="function"> This command allows you to quickly repeat the most recent launch in debug mode.</td>
<td valign="top" headers="keyboard"> &nbsp;</td> <td headers="keyboard"> F11</td>
</tr> </tr>
<tr> <tr>
<td valign="top" headers="name"><strong>Run As</strong></td> <td class="menu_name" headers="name">Run History</td>
<td valign="top" headers="function"> Presents a sub menu of registered run launch shortcuts. Launch shortcuts provide support for workbench or active editor selection sensitive launching.</td> <td headers="function"> Presents a sub menu of the recent history of launch configurations launched in run mode.</td>
<td valign="top" headers="keyboard"> &nbsp;</td> <td headers="keyboard"> &nbsp;</td>
</tr> </tr>
<tr> <tr>
<td valign="top" headers="name"><strong>Open Run Dialog...</strong></td> <td class="menu_name" headers="name">Run As</td>
<td valign="top" headers="function"> This command realizes the launch configuration dialog to manage run mode launch configurations. </td> <td headers="function"> Presents a sub menu of registered run launch shortcuts. Launch shortcuts provide support for workbench or active editor selection sensitive launching.</td>
<td valign="top" headers="keyboard"> &nbsp;</td> <td headers="keyboard"> &nbsp;</td>
</tr> </tr>
<tr> <tr>
<td valign="top" headers="name"><strong>Debug History</strong></td> <td class="menu_name" headers="name">Open Run Dialog...</td>
<td valign="top" headers="function"> Presents a sub menu of the recent history of launch configurations launched in debug mode.</td> <td headers="function"> This command realizes the launch configuration dialog to manage run mode launch configurations. </td>
<td valign="top" headers="keyboard"> &nbsp;</td> <td headers="keyboard"> &nbsp;</td>
</tr> </tr>
<tr> <tr>
<td valign="top" headers="name"><strong>Debug As</strong></td> <td class="menu_name" headers="name">Debug History</td>
<td valign="top" headers="function"> Presents a sub menu of registered debug launch shortcuts. Launch shortcuts provide support for workbench or active editor selection sensitive launching.</td> <td headers="function"> Presents a sub menu of the recent history of launch configurations launched in debug mode.</td>
<td valign="top" headers="keyboard"> &nbsp;</td> <td headers="keyboard"> &nbsp;</td>
</tr> </tr>
<tr> <tr>
<td valign="top" headers="name"><strong>Open Debug Dialog...</strong></td> <td class="menu_name" headers="name">Debug As</td>
<td valign="top" headers="function"> This command realizes the launch configuration dialog to manage debug mode launch configurations.</td> <td headers="function"> Presents a sub menu of registered debug launch shortcuts. Launch shortcuts provide support for workbench or active editor selection sensitive launching.</td>
<td valign="top" headers="keyboard"> &nbsp;</td> <td headers="keyboard"> &nbsp;</td>
</tr> </tr>
<tr valign="top"> <tr>
<td valign="top" headers="name"><strong>External Tools</strong></td> <td class="menu_name" headers="name">Open Debug Dialog...</td>
<td valign="top" headers="function"> Presents a sub menu of links to external run configuration dialogs to manage run mode launch configurations.</td> <td headers="function"> This command realizes the launch configuration dialog to manage debug mode launch configurations.</td>
<td valign="top" headers="keyboard"> &nbsp;</td> <td headers="keyboard"> &nbsp;</td>
</tr>
<tr>
<td class="menu_name" headers="name">External Tools</td>
<td headers="function"> Presents a sub menu of links to external run configuration dialogs to manage run mode launch configurations.</td>
<td headers="keyboard"> &nbsp;</td>
</tr> </tr>
</table> </table>

View file

@ -19,29 +19,29 @@
<p><img src="../images/cdt_menu_search.png" alt="Selecting Search Menu" ></p> <p><img src="../images/cdt_menu_search.png" alt="Selecting Search Menu" ></p>
<table border="1" cellspacing="0"> <table class="menu" border="1" cellspacing="0">
<tr> <tr>
<th id="name">Name</th> <th id="name">Name</th>
<th id="function">Function</th> <th id="function">Function</th>
<th id="keyboard">Keyboard Shortcut</th> <th id="keyboard">Keyboard Shortcut</th>
</tr> </tr>
<tr> <tr>
<td headers="name"><strong>C/C++...</strong></td> <td class="menu_name" headers="name">C/C++...</td>
<td headers="function">Opens the search dialog on the C/C++ search page</td> <td headers="function">Opens the search dialog on the C/C++ search page</td>
<td headers="keyboard">&nbsp;</td> <td headers="keyboard">&nbsp;</td>
</tr> </tr>
<tr> <tr>
<td headers="name"><strong>Search...</strong></td> <td class="menu_name" headers="name">Search...</td>
<td headers="function">Opens the search dialog for your current editor</td> <td headers="function">Opens the search dialog for your current editor</td>
<td headers="keyboard">Ctrl + H </td> <td headers="keyboard">Ctrl + H </td>
</tr> </tr>
<tr> <tr>
<td headers="name"><strong>File...</strong></td> <td class="menu_name" headers="name">File...</td>
<td headers="function">Opens the search dialog on the File search page</td> <td headers="function">Opens the search dialog on the File search page</td>
<td headers="keyboard">&nbsp;</td> <td headers="keyboard">&nbsp;</td>
</tr> </tr>
<tr> <tr>
<td headers="name"><strong>Text</strong></td> <td class="menu_name" headers="name">Text</td>
<td headers="function">Opens the submenu for full-text search in given scope (workspace, project, file or working set)</td> <td headers="function">Opens the submenu for full-text search in given scope (workspace, project, file or working set)</td>
<td headers="keyboard">&nbsp;</td> <td headers="keyboard">&nbsp;</td>
</tr> </tr>

Some files were not shown because too many files have changed in this diff Show more