1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 18:26:01 +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;
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();
}
// 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 {
// void kind();
// };
@ -7312,4 +7329,26 @@ public class AST2TemplateTests extends AST2TestBase {
public void testVariadicNonTypeTemplateParameter_401142() throws Exception {
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
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Eidsness - Initial implementation
*/
package org.eclipse.cdt.internal.pdom.tests;
import java.io.File;
@ -18,61 +20,56 @@ import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.cdt.internal.core.pdom.db.PDOMStringSet;
// copy/pasted from BTreeTests
public class PDOMStringSetTests extends BaseTestCase
{
public class PDOMStringSetTests extends BaseTestCase {
protected File dbFile;
protected Database db;
protected PDOMStringSet stringSet;
protected int rootRecord;
public static Test suite()
{
return suite( PDOMStringSetTests.class );
public static Test suite() {
return suite(PDOMStringSetTests.class);
}
@Override
protected void setUp() throws Exception
{
super.setUp();
protected void setUp() throws Exception {
super.setUp();
dbFile = File.createTempFile( "pdomstringsettest", "db" );
db = new Database( dbFile, new ChunkCache(), 0, false );
dbFile = File.createTempFile("pdomstringsettest", "db");
db = new Database(dbFile, new ChunkCache(), 0, false);
db.setExclusiveLock();
rootRecord = Database.DATA_AREA;
stringSet = new PDOMStringSet( db, rootRecord );
stringSet = new PDOMStringSet(db, rootRecord);
}
@Override
protected void tearDown() throws Exception
{
protected void tearDown() throws Exception {
db.close();
dbFile.deleteOnExit();
super.tearDown();
super.tearDown();
}
// Quick tests to exercise the basic functionality.
public void testInterface() throws Exception
{
long val1_rec_a = stringSet.add( "val1" );
long val2_rec_a = stringSet.add( "val2" );
long val1_rec_b = stringSet.add( "val1" );
assertTrue( val1_rec_a != 0 );
assertTrue( val2_rec_a != 0 );
assertEquals( val1_rec_a, val1_rec_b );
public void testInterface() throws Exception {
long val1_rec_a = stringSet.add("val1");
long val2_rec_a = stringSet.add("val2");
long val1_rec_b = stringSet.add("val1");
assertTrue(val1_rec_a != 0);
assertTrue(val2_rec_a != 0);
assertEquals(val1_rec_a, val1_rec_b);
long val1_find = stringSet.find( "val1" );
long val2_find = stringSet.find( "val2" );
assertEquals( val1_rec_a, val1_find );
assertEquals( val2_rec_a, val2_find );
long val1_find = stringSet.find("val1");
long val2_find = stringSet.find("val2");
assertEquals(val1_rec_a, val1_find);
assertEquals(val2_rec_a, val2_find);
long val1_rm = stringSet.remove( "val1" );
assertEquals( val1_rec_a, val1_rm );
assertEquals( 0, stringSet.find( "val1" ) );
assertEquals( val2_rec_a, stringSet.find( "val2" ) );
long val1_rm = stringSet.remove("val1");
assertEquals(val1_rec_a, val1_rm);
assertEquals(0, stringSet.find("val1"));
assertEquals(val2_rec_a, stringSet.find("val2"));
stringSet.clearCaches();
assertEquals( val2_rec_a, stringSet.find( "val2" ) );
assertEquals( 0, stringSet.find( "val1" ) );
stringSet.clearCaches();
assertEquals(val2_rec_a, stringSet.find("val2"));
assertEquals(0, stringSet.find("val1"));
}
}

View file

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

View file

@ -4,31 +4,36 @@
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Eidsness - Initial implementation
*/
package org.eclipse.cdt.core.dom.ast.tag;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IBinding;
/**
* Implementations are contributed with the org.eclipse.cdt.core.tagger extension-point. The implementation
* is responsible for populating the tag's data using a given input binding.
* Implementations are contributed with the org.eclipse.cdt.core.tagger extension-point.
* The implementation is responsible for populating the tag's data using a given input binding.
*
* @see #process(ITagWriter, IBinding, IASTName)
* @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
* to create data if needed. Return the tag if one was created and null otherwise. A tagger (as
* identified by it's unique id string) is allowed to create only one tag for each binding.
* Examines the given input binding to decide if a tag should be created. Use the given
* tagWriter to create data if needed. Return the tag if one was created and null otherwise.
* 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 binding the binding to examine when populating the tag (if needed)
* @param ast the AST name from which the binding was created
* @param tagWriter
* the writer to use for creating new tags
* @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
*/
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
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Eidsness - Initial implementation
*/
package org.eclipse.cdt.core.dom.ast.tag;
/**
* Tags are used to annotate {@link ITagReader}'s with extra information. They are created
* by implementations of {@link IBindingTagger} which are contributed using the
* org.eclipse.cdt.core.tagger extension point. The base tag interface is read-only, it
* is extended by the writable {@link IWritableTag}.
* Tags are used to annotate {@link ITagReader}'s with extra information. They are created by
* implementations of {@link IBindingTagger} which are contributed using
* the org.eclipse.cdt.core.tagger extension point. The base tag interface is read-only, it is
* extended by the writable {@link IWritableTag}.
*
* @see IBindingTagger
* @see ITagReader
* @see IWritableTag
* @since 5.5
*/
public interface ITag
{
public interface ITag {
/** 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();
/** 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();
/** Return the byte from the specified offset or {@link #Fail} on failure. */
public int getByte( int offset );
/** Returns the byte from the specified offset or {@link #FAIL} on failure. */
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. */
public byte[] getBytes( int offset, int len );
// TODO read methods for all the other types
/**
* Returns the specified number of bytes from the specified offset. Specify {@code len} of -1
* 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
* 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
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Eidsness - Initial implementation
*/
package org.eclipse.cdt.core.dom.ast.tag;
/**
* 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
* @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
* when the tag was created (see {@link ITagWriter#createTag(String, int)}).
* @param id
* 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();
}

View file

@ -4,27 +4,29 @@
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Eidsness - Initial implementation
*/
package org.eclipse.cdt.core.dom.ast.tag;
import org.eclipse.cdt.core.dom.ast.IBinding;
/**
* Provides ITagReaders for specific bindings. The kind of the reader will vary based on
* the kind of the input binding.
* Provides ITagReaders for specific bindings. The kind of the reader will vary based on the kind
* of the input binding.
*
* @see ITag
* @see ITagReader
* @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
* be associated with this binding.
* Finds or creates a tag reader for the specified binding or null if a reader cannot be
* 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
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Eidsness - Initial implementation
*/
package org.eclipse.cdt.core.dom.ast.tag;
@ -15,20 +18,22 @@ package org.eclipse.cdt.core.dom.ast.tag;
* @see ITagService
* @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,
* then returned tag will read and write from the PDOM database.
* Creates and returns a new tag for the receiver. E.g., if this writer is associated with
* 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
* 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.
* @param id
* A string that uniquely identifies the tag to be returned. This value will be used
* 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
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Eidsness - Initial implementation
*/
package org.eclipse.cdt.core.dom.ast.tag;
/**
* Tags are used to annotate {@link ITagWriter}'s with extra information. They are created
* by implementations of {@link IBindingTagger} which are contributed using the
* org.eclipse.cdt.core.tagger extension point.
* Tags are used to annotate {@link ITagWriter}'s with extra information. They are created by
* implementations of {@link IBindingTagger} which are contributed using
* the org.eclipse.cdt.core.tagger extension point.
*
* @see IBindingTagger
* @see ITagReader
* @see ITagWriter
* @since 5.5
*/
public interface IWritableTag extends ITag
{
/** 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 interface IWritableTag extends ITag {
/** Writes the given byte to the given offset in the tag. Returns {@code true} if successful. */
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. */
public boolean putBytes( int offset, byte data[], int len );
// TODO write for all types
/**
* Writes the argument buffer into the receiver's payload starting at the specified offset.
* Writes the specified number of bytes or the full buffer when {@code len} is -1. Returns
* {@code true} if successful.
*/
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
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Eidsness - Initial implementation
*/
package org.eclipse.cdt.internal.core.dom.ast.tag;
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.internal.core.dom.parser.cpp.ICPPInternalBinding;
public class NonCachedTaggable implements ITagReader, ITagWriter
{
public class NonCachedTaggable implements ITagReader, ITagWriter {
private final IBinding binding;
private IASTName ast;
public NonCachedTaggable( IBinding binding )
{
public NonCachedTaggable(IBinding binding) {
this.binding = binding;
}
@Override
public IWritableTag createTag( String id, int len )
{
return new Tag( id, len );
public IWritableTag createTag(String id, int len) {
return new Tag(id, len);
}
@Override
public ITag getTag( String id )
{
return TagManager.getInstance().process( id, this, binding, getAST() );
public ITag getTag(String id) {
return TagManager.getInstance().process(id, this, binding, getAST());
}
@Override
public Iterable<ITag> getTags()
{
return TagManager.getInstance().process( this, binding, getAST() );
public Iterable<ITag> getTags() {
return TagManager.getInstance().process(this, binding, getAST());
}
@Override
public boolean setTags( Iterable<ITag> tags )
{
// this non-caching implementation has nothing to set, the tags will be regenerated
public boolean setTags(Iterable<ITag> tags) {
// This non-caching implementation has nothing to set, the tags will be regenerated
// when they are queried
return true;
}
private IASTName getAST()
{
if( ast != null )
private IASTName getAST() {
if (ast != null)
return ast;
if( ! ( binding instanceof ICPPInternalBinding ) )
if (!(binding instanceof ICPPInternalBinding))
return null;
IASTNode node = getPhysicalNode( (ICPPInternalBinding)binding );
if( node == null )
IASTNode node = getPhysicalNode((ICPPInternalBinding) binding);
if (node == 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();
if( node != null )
if (node != null)
return node;
IASTNode[] nodes = binding.getDeclarations();
if( nodes == null
|| nodes.length <= 0 )
if (nodes == null || nodes.length <= 0)
return null;
return nodes[0];
}
private static IASTName getName( IASTNode node )
{
if( node instanceof IASTName )
return (IASTName)node;
if( node instanceof ICPPASTCompositeTypeSpecifier )
return ( (ICPPASTCompositeTypeSpecifier)node ).getName();
if( node instanceof IASTDeclarator )
return ( (IASTDeclarator)node ).getName();
private static IASTName getName(IASTNode node) {
if (node instanceof IASTName)
return (IASTName) node;
if (node instanceof ICPPASTCompositeTypeSpecifier)
return ((ICPPASTCompositeTypeSpecifier) node).getName();
if (node instanceof IASTDeclarator)
return ((IASTDeclarator) node).getName();
return null;
}
}

View file

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

View file

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

View file

@ -4,32 +4,33 @@
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Eidsness - Initial implementation
*/
package org.eclipse.cdt.internal.core.dom.ast.tag;
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.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 )
* on the binding. If the binding doesn't provide an implementation then a simple, in-memory, non-cached
* implementation is created and returned.
* First gives the IBinding instance a chance to convert itself, by calling
* IAdaptable#getAdapter(ITagReader.class) on the binding. If the binding doesn't provide
* an implementation then a simple, in-memory, non-cached implementation is created and
* returned.
*/
@Override
public ITagReader findTagReader( IBinding binding )
{
if( binding == null )
public ITagReader findTagReader(IBinding binding) {
if (binding == null)
return null;
// let the binding adapt to its own tag reader
ITagReader tagReader = (ITagReader)binding.getAdapter( ITagReader.class );
if( tagReader != null )
// Let the binding adapt to its own tag reader
ITagReader tagReader = (ITagReader) binding.getAdapter(ITagReader.class);
if (tagReader != null)
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
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Eidsness - Initial implementation
*/
package org.eclipse.cdt.internal.core.dom.ast.tag;
import java.util.Arrays;
@ -30,12 +32,12 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
/**
* Internal container for extensions of org.eclipse.cdt.core.tagger. The implementation of the
* tagger is instantiated only after checking the enablement expression (if present) for the
* specified binding. This avoids activating the contributing plugin until it is actually needed.
* Internal container for extensions of org.eclipse.cdt.core.tagger. The implementation of
* the tagger is instantiated only after checking the enablement expression (if present) for
* 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_Class = "class"; //$NON-NLS-1$
@ -46,22 +48,25 @@ public class TaggerDescriptor
private String id;
private IBindingTagger tagger;
private static final String Var_projectNature = "projectNatures"; //$NON-NLS-1$
private static final String Var_languageId = "languageId"; //$NON-NLS-1$
private static final String VAR_PROJECTNATURES = "projectNatures"; //$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. */
private static final IBindingTagger NullTagger = new IBindingTagger()
{
@Override public ITag process(ITagWriter tagWriter, IBinding binding, IASTName ast) { return null; }
/**
* An empty implementation of the tagger used as a placeholder in descriptors that are unable
* to load the contributed class.
*/
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;
Expression expr = null;
IConfigurationElement[] children = element.getChildren( ExpressionTagNames.ENABLEMENT );
IConfigurationElement[] children = element.getChildren(ExpressionTagNames.ENABLEMENT);
switch (children.length) {
case 0:
fStatus = Boolean.TRUE;
@ -69,114 +74,104 @@ public class TaggerDescriptor
case 1:
try {
ExpressionConverter parser = ExpressionConverter.getDefault();
expr = parser.perform( children[0] );
expr = parser.perform(children[0]);
} 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;
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;
break;
}
enablementExpression = expr;
}
public String getId()
{
if( id != null )
public String getId() {
if (id != null)
return id;
String globalId = element.getContributor().getName();
String localId = element.getAttribute( Attr_LocalId );
String localId = element.getAttribute(Attr_LocalId);
// there must be a valid local id
if( localId == null )
{
if (localId == null) {
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;
}
// the extension should not include the plugin id, but return immediately if it does
if( localId.startsWith( globalId )
&& localId.length() > globalId.length() )
if (localId.startsWith(globalId) && localId.length() > globalId.length())
return localId;
// make sure the local id has real content
if( localId.isEmpty() )
{
if (localId.isEmpty()) {
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;
}
// 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;
}
private boolean matches( ITranslationUnit tu )
{
// if the enablement expression is missing or structurally invalid, then return immediately
if( fStatus != null )
private boolean matches(ITranslationUnit tu) {
// If the enablement expression is missing or structurally invalid, then return immediately
if (fStatus != null)
return fStatus.booleanValue();
// if there is no tu, then the enablement expression cannot be evaluated, assume that all taggers
// are needed
if( tu == null )
// If there is no tu, then the enablement expression cannot be evaluated, assume that all
// taggers are needed
if (tu == null)
return true;
if( enablementExpression != null )
try
{
if (enablementExpression != null)
try {
IProject project = null;
ICProject cProject = tu.getCProject();
if( cProject != null )
if (cProject != null)
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
// get a chance to run
if( project != null )
{
if (project != null) {
String[] natures = project.getDescription().getNatureIds();
evalContext.addVariable( Var_projectNature, Arrays.asList( natures ) );
evalContext.addVariable(VAR_PROJECTNATURES, Arrays.asList(natures));
}
ILanguage language = tu.getLanguage();
if( language != null )
evalContext.addVariable( Var_languageId, language.getId() );
if (language != null)
evalContext.addVariable(VAR_LANGUAGEID, language.getId());
return enablementExpression.evaluate( evalContext ) == EvaluationResult.TRUE;
}
catch( CoreException e )
{
CCorePlugin.log( "Error while evaluating enablement expression for " + id, e ); //$NON-NLS-1$
return enablementExpression.evaluate(evalContext) == EvaluationResult.TRUE;
} catch (CoreException e) {
CCorePlugin.log("Error while evaluating enablement expression for " + id, e); //$NON-NLS-1$
}
fStatus = Boolean.FALSE;
return false;
}
private IBindingTagger getTagger()
{
if( tagger == null )
synchronized( this )
{
if( tagger == null )
{
try { tagger = (IBindingTagger)element.createExecutableExtension( Attr_Class ); }
catch( CoreException e )
{
private IBindingTagger getTagger() {
if (tagger == null)
synchronized (this) {
if (tagger == null) {
try {
tagger = (IBindingTagger) element.createExecutableExtension(Attr_Class);
} catch (CoreException e) {
String id = element.getDeclaringExtension().getNamespaceIdentifier() + '.'
+ element.getDeclaringExtension().getSimpleIdentifier();
CCorePlugin.log( "Error in class attribute of " + id, e ); //$NON-NLS-1$
+ element.getDeclaringExtension().getSimpleIdentifier();
CCorePlugin.log("Error in class attribute of " + id, e); //$NON-NLS-1$
// 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.
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,
// 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.
if( ast == null )
if (ast == null)
return getTagger();
IASTTranslationUnit astTU = ast.getTranslationUnit();
if( astTU == null )
if (astTU == null)
return getTagger();
// 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
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -9,6 +9,7 @@
* Markus Schorn - initial API and implementation
* Thomas Corbat
* Sergey Prigogin (Google)
* Nathan Ridge
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser;
@ -22,45 +23,56 @@ import org.eclipse.core.runtime.CoreException;
* Buffer for marshalling and unmarshalling types.
*/
public interface ITypeMarshalBuffer {
final static byte BASIC_TYPE= 1;
final static byte POINTER_TYPE= 2;
final static byte ARRAY_TYPE= 3;
final static byte CVQUALIFIER_TYPE= 4;
final static byte FUNCTION_TYPE= 5;
final static byte REFERENCE_TYPE= 6;
final static byte POINTER_TO_MEMBER_TYPE= 7;
final static byte PACK_EXPANSION_TYPE= 8;
final static byte PROBLEM_TYPE= 9;
final static byte VALUE= 10;
final static byte DEPENDENT_EXPRESSION_TYPE= 11;
final static byte UNKNOWN_MEMBER= 12;
final static byte UNKNOWN_MEMBER_CLASS_INSTANCE= 13;
final static byte DEFERRED_CLASS_INSTANCE= 14;
final static byte ALIAS_TEMPLATE = 15;
final static byte BASIC_TYPE = 0x01;
final static byte POINTER_TYPE = 0x02;
final static byte ARRAY_TYPE = 0x03;
final static byte CVQUALIFIER_TYPE = 0x04;
final static byte FUNCTION_TYPE = 0x05;
final static byte REFERENCE_TYPE = 0x06;
final static byte POINTER_TO_MEMBER_TYPE = 0x07;
final static byte PACK_EXPANSION_TYPE = 0x08;
final static byte PROBLEM_TYPE = 0x09;
final static byte VALUE = 0x0A;
final static byte DEPENDENT_EXPRESSION_TYPE = 0x0B;
final static byte UNKNOWN_MEMBER = 0x0C;
final static byte UNKNOWN_MEMBER_CLASS_INSTANCE = 0x0D;
final static byte DEFERRED_CLASS_INSTANCE = 0x0E;
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
EVAL_BINARY= 1,
EVAL_BINARY_TYPE_ID = 2,
EVAL_BINDING = 3,
EVAL_COMMA = 4,
EVAL_COMPOUND = 5,
EVAL_CONDITIONAL = 6,
EVAL_FIXED= 7,
EVAL_FUNCTION_CALL= 8,
EVAL_FUNCTION_SET= 9,
EVAL_ID= 10,
EVAL_INIT_LIST= 11,
EVAL_MEMBER_ACCESS= 12,
EVAL_TYPE_ID= 13,
EVAL_UNARY= 14,
EVAL_UNARY_TYPE_ID = 15;
EVAL_BINARY = 0x01,
EVAL_BINARY_TYPE_ID = 0x02,
EVAL_BINDING = 0x03,
EVAL_COMMA = 0x04,
EVAL_COMPOUND = 0x05,
EVAL_CONDITIONAL = 0x06,
EVAL_FIXED = 0x07,
EVAL_FUNCTION_CALL = 0x08,
EVAL_FUNCTION_SET = 0x09,
EVAL_ID = 0x0A,
EVAL_INIT_LIST = 0x0B,
EVAL_MEMBER_ACCESS = 0x0C,
EVAL_PARAMETER_PACK = 0x0D,
EVAL_TYPE_ID = 0x0E,
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 int FLAG2 = 0x20;
final static int FLAG3 = 0x40;
final static int FLAG4 = 0x80;
final static short FIRST_FLAG = 0x0020;
final static short FLAG1 = 0x0020;
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();
@ -72,6 +84,11 @@ public interface ITypeMarshalBuffer {
int getByte() 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.
*/
@ -92,6 +109,12 @@ public interface ITypeMarshalBuffer {
void putByte(byte 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
* 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
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());
}
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());
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -94,17 +94,17 @@ public class CPointerType implements ICPointerType, ITypeContainer, ISerializabl
@Override
public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
int firstByte= ITypeMarshalBuffer.POINTER_TYPE;
if (isConst()) firstByte |= ITypeMarshalBuffer.FLAG1;
if (isVolatile()) firstByte |= ITypeMarshalBuffer.FLAG2;
if (isRestrict()) firstByte |= ITypeMarshalBuffer.FLAG3;
buffer.putByte((byte) firstByte);
short firstBytes = ITypeMarshalBuffer.POINTER_TYPE;
if (isConst()) firstBytes |= ITypeMarshalBuffer.FLAG1;
if (isVolatile()) firstBytes |= ITypeMarshalBuffer.FLAG2;
if (isRestrict()) firstBytes |= ITypeMarshalBuffer.FLAG3;
buffer.putShort(firstBytes);
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();
return new CPointerType(nested, firstByte/ITypeMarshalBuffer.FLAG1);
return new CPointerType(nested, firstBytes/ITypeMarshalBuffer.FLAG1);
}
@Override

View file

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

View file

@ -11,8 +11,6 @@
*******************************************************************************/
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.IASTExpression;
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.internal.core.dom.parser.ASTNode;
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.Value;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalFixed;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalParameterPack;
/**
* Implementation of pack expansion expression.
@ -70,13 +66,7 @@ public class CPPASTPackExpansionExpression extends ASTNode implements ICPPASTPac
@Override
public ICPPEvaluation getEvaluation() {
if (fEvaluation == null) {
IType type = fPattern.getExpressionType();
if (type == null) {
type= ProblemType.UNKNOWN_FOR_EXPRESSION;
} else {
type= new CPPParameterPackType(type);
}
fEvaluation= new EvalFixed(type, PRVALUE, Value.create(((ICPPASTExpression) fPattern).getEvaluation()));
fEvaluation = new EvalParameterPack(((ICPPASTExpression) fPattern).getEvaluation(), this);
}
return fEvaluation;
}

View file

@ -111,14 +111,14 @@ public class CPPAliasTemplateInstance extends PlatformObject
@Override
public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
int firstByte = ITypeMarshalBuffer.ALIAS_TEMPLATE;
buffer.putByte((byte) firstByte);
short firstBytes = ITypeMarshalBuffer.ALIAS_TEMPLATE;
buffer.putShort(firstBytes);
buffer.putCharArray(name);
buffer.marshalType(aliasedType);
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();
IType unmarshalledAliasedTypeInstance = buffer.unmarshalType();
ICPPAliasTemplate unmarshalledAlias = (ICPPAliasTemplate)buffer.unmarshalBinding();

View file

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

View file

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

View file

@ -117,10 +117,7 @@ public class CPPClassType extends PlatformObject implements ICPPInternalClassTyp
private ICPPClassType typeInIndex;
public CPPClassType(IASTName name, IBinding indexBinding) {
if (name instanceof ICPPASTQualifiedName) {
IASTName[] ns = ((ICPPASTQualifiedName) name).getNames();
name = ns[ns.length - 1];
}
name = stripQualifier(name);
IASTNode parent = name.getParent();
while (parent instanceof IASTName)
parent = parent.getParent();
@ -195,6 +192,7 @@ public class CPPClassType extends PlatformObject implements ICPPInternalClassTyp
@Override
public IScope getScope() {
IASTName name = definition != null ? definition : declarations[0];
name = stripQualifier(name);
IScope scope = CPPVisitor.getContainingScope(name);
if (definition == null && name.getPropertyInParent() != ICPPASTQualifiedName.SEGMENT_NAME) {
@ -406,4 +404,12 @@ public class CPPClassType extends PlatformObject implements ICPPInternalClassTyp
}
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
public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
int firstByte= ITypeMarshalBuffer.DEFERRED_CLASS_INSTANCE;
buffer.putByte((byte) firstByte);
short firstBytes= ITypeMarshalBuffer.DEFERRED_CLASS_INSTANCE;
buffer.putShort(firstBytes);
buffer.marshalBinding(fClassTemplate);
buffer.putInt(fArguments.length);
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 {
IBinding template= buffer.unmarshalBinding();
int argcount= buffer.getInt();

View file

@ -136,12 +136,12 @@ public class CPPFunctionType implements ICPPFunctionType, ISerializableType {
@Override
public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
int firstByte= ITypeMarshalBuffer.FUNCTION_TYPE;
if (isConst()) firstByte |= ITypeMarshalBuffer.FLAG1;
if (isVolatile()) firstByte |= ITypeMarshalBuffer.FLAG2;
if (takesVarArgs()) firstByte |= ITypeMarshalBuffer.FLAG3;
short firstBytes= ITypeMarshalBuffer.FUNCTION_TYPE;
if (isConst()) firstBytes |= ITypeMarshalBuffer.FLAG1;
if (takesVarArgs()) firstBytes |= ITypeMarshalBuffer.FLAG2;
if (isVolatile()) firstBytes |= ITypeMarshalBuffer.FLAG3;
buffer.putByte((byte) firstByte);
buffer.putShort(firstBytes);
buffer.putInt(parameters.length);
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();
IType rt= buffer.unmarshalType();
IType[] pars= new IType[len];
for (int i = 0; i < pars.length; i++) {
pars[i]= buffer.unmarshalType();
}
return new CPPFunctionType(rt, pars, (firstByte & ITypeMarshalBuffer.FLAG1) != 0,
(firstByte & ITypeMarshalBuffer.FLAG2) != 0, (firstByte & ITypeMarshalBuffer.FLAG3) != 0);
return new CPPFunctionType(rt, pars,
(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
public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
int firstByte= ITypeMarshalBuffer.PACK_EXPANSION_TYPE;
buffer.putByte((byte) firstByte);
short firstBytes= ITypeMarshalBuffer.PACK_EXPANSION_TYPE;
buffer.putShort(firstBytes);
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();
if (nested == null)
return new ProblemBinding(null, IProblemBinding.SEMANTIC_INVALID_TYPE);

View file

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

View file

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

View file

@ -92,16 +92,16 @@ public class CPPQualifierType implements IQualifierType, ITypeContainer, ISerial
@Override
public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
int firstByte= ITypeMarshalBuffer.CVQUALIFIER_TYPE;
if (isConst()) firstByte |= ITypeMarshalBuffer.FLAG1;
if (isVolatile()) firstByte |= ITypeMarshalBuffer.FLAG2;
buffer.putByte((byte) firstByte);
short firstBytes= ITypeMarshalBuffer.CVQUALIFIER_TYPE;
if (isConst()) firstBytes |= ITypeMarshalBuffer.FLAG1;
if (isVolatile()) firstBytes |= ITypeMarshalBuffer.FLAG2;
buffer.putShort(firstBytes);
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();
return new CPPQualifierType(nested, (firstByte & ITypeMarshalBuffer.FLAG1) != 0,
(firstByte & ITypeMarshalBuffer.FLAG2) != 0);
return new CPPQualifierType(nested, (firstBytes & ITypeMarshalBuffer.FLAG1) != 0,
(firstBytes & ITypeMarshalBuffer.FLAG2) != 0);
}
}

View file

@ -109,16 +109,16 @@ public class CPPReferenceType implements ICPPReferenceType, ITypeContainer, ISer
@Override
public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
int firstByte= ITypeMarshalBuffer.REFERENCE_TYPE;
short firstBytes= ITypeMarshalBuffer.REFERENCE_TYPE;
if (isRValueReference()) {
firstByte |= ITypeMarshalBuffer.FLAG1;
firstBytes |= ITypeMarshalBuffer.FLAG1;
}
buffer.putByte((byte) firstByte);
buffer.putShort(firstBytes);
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();
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.ICPPTemplateArgument;
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.core.runtime.Assert;
@ -90,9 +91,8 @@ public class CPPTemplateNonTypeArgument implements ICPPTemplateArgument {
IType t= ((ICPPParameterPackType) type).getType();
if (t != null) {
ICPPEvaluation evaluation;
if (fEvaluation instanceof EvalFixed) {
EvalFixed fixed = (EvalFixed) fEvaluation;
evaluation = new EvalFixed(t, fixed.getValueCategory(), fixed.getValue());
if (fEvaluation instanceof EvalParameterPack) {
evaluation = ((EvalParameterPack) fEvaluation).getExpansionPattern();
} else {
evaluation = new EvalTypeId(t, fEvaluation.getTemplateDefinition(), fEvaluation);
}

View file

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

View file

@ -82,8 +82,8 @@ public class CPPUnknownClassInstance extends CPPUnknownMemberClass implements IC
@Override
public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
int firstByte= ITypeMarshalBuffer.UNKNOWN_MEMBER_CLASS_INSTANCE;
buffer.putByte((byte) firstByte);
short firstBytes= ITypeMarshalBuffer.UNKNOWN_MEMBER_CLASS_INSTANCE;
buffer.putShort(firstBytes);
buffer.marshalType(getOwnerType());
buffer.putCharArray(getNameCharArray());
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();
char[] name = buffer.getCharArray();
int argcount= buffer.getInt();

View file

@ -49,24 +49,24 @@ public class CPPUnknownMember extends CPPUnknownBinding implements ICPPUnknownMe
@Override
public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
int firstByte= ITypeMarshalBuffer.UNKNOWN_MEMBER;
short firstBytes= ITypeMarshalBuffer.UNKNOWN_MEMBER;
if (this instanceof ICPPField) {
firstByte |= ITypeMarshalBuffer.FLAG1;
firstBytes |= ITypeMarshalBuffer.FLAG1;
} else if (this instanceof ICPPMethod) {
firstByte |= ITypeMarshalBuffer.FLAG2;
firstBytes |= ITypeMarshalBuffer.FLAG2;
}
buffer.putByte((byte) firstByte);
buffer.putShort(firstBytes);
buffer.marshalType(getOwnerType());
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();
char[] name = buffer.getCharArray();
if ((firstByte & ITypeMarshalBuffer.FLAG1) != 0) {
if ((firstBytes & ITypeMarshalBuffer.FLAG1) != 0) {
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 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.IScope;
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.ICPPTemplateParameterMap;
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.PlatformObject;
@ -94,6 +97,63 @@ public abstract class CPPDependentEvaluation extends CPPEvaluation {
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,
* 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)
return false;
IBinding pb= names[names.length-2].resolvePreBinding();
IBinding pb= names[names.length - 2].resolvePreBinding();
if (pb instanceof IProblemBinding)
return false;
@ -930,11 +930,11 @@ public class CPPVisitor extends ASTQueries {
if (name instanceof ICPPASTQualifiedName) {
IASTName[] names = ((ICPPASTQualifiedName) name).getNames();
if (names.length >= 2) {
IBinding b= names[names.length-2].resolvePreBinding();
IBinding b= names[names.length - 2].resolvePreBinding();
if (b instanceof IType) {
IType classType= getNestedType((IType) b, TDEF);
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();
return CharArrayUtils.equals(dtorName, className);
}
@ -1303,7 +1303,7 @@ public class CPPVisitor extends ASTQueries {
IASTName name = findInnermostDeclarator(fnDeclarator).getName();
if (name instanceof ICPPASTQualifiedName) {
IASTName[] ns = ((ICPPASTQualifiedName) name).getNames();
name = ns[ns.length -1];
name = ns[ns.length - 1];
}
return getContainingScope(name);
}

View file

@ -331,14 +331,14 @@ public class EvalBinary extends CPPDependentEvaluation {
@Override
public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException {
buffer.putByte(ITypeMarshalBuffer.EVAL_BINARY);
buffer.putShort(ITypeMarshalBuffer.EVAL_BINARY);
buffer.putByte((byte) fOperator);
buffer.marshalEvaluation(fArg1, includeValue);
buffer.marshalEvaluation(fArg2, includeValue);
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();
ICPPEvaluation arg1= (ICPPEvaluation) buffer.unmarshalEvaluation();
ICPPEvaluation arg2= (ICPPEvaluation) buffer.unmarshalEvaluation();

View file

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

View file

@ -159,7 +159,7 @@ public class EvalComma extends CPPDependentEvaluation {
@Override
public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException {
buffer.putByte(ITypeMarshalBuffer.EVAL_COMMA);
buffer.putShort(ITypeMarshalBuffer.EVAL_COMMA);
buffer.putInt(fArguments.length);
for (ICPPEvaluation arg : fArguments) {
buffer.marshalEvaluation(arg, includeValue);
@ -167,7 +167,7 @@ public class EvalComma extends CPPDependentEvaluation {
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();
ICPPEvaluation[] args = new ICPPEvaluation[len];
for (int i = 0; i < args.length; i++) {

View file

@ -81,12 +81,12 @@ public class EvalCompound extends CPPDependentEvaluation {
@Override
public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException {
buffer.putByte(ITypeMarshalBuffer.EVAL_COMPOUND);
buffer.putShort(ITypeMarshalBuffer.EVAL_COMPOUND);
buffer.marshalEvaluation(fDelegate, includeValue);
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();
IBinding templateDefinition= buffer.unmarshalBinding();
return new EvalCompound(arg, templateDefinition);

View file

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

View file

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

View file

@ -174,7 +174,7 @@ public class EvalFunctionCall extends CPPDependentEvaluation {
@Override
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);
for (ICPPEvaluation arg : fArguments) {
buffer.marshalEvaluation(arg, includeValue);
@ -182,7 +182,7 @@ public class EvalFunctionCall extends CPPDependentEvaluation {
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();
ICPPEvaluation[] args = new ICPPEvaluation[len];
for (int i = 0; i < args.length; i++) {
@ -195,17 +195,8 @@ public class EvalFunctionCall extends CPPDependentEvaluation {
@Override
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
ICPPEvaluation[] args = fArguments;
for (int i = 0; i < fArguments.length; i++) {
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;
}
}
ICPPEvaluation[] args = instantiateCommaSeparatedSubexpressions(fArguments, tpMap,
packOffset, within, maxdepth, point);
if (args == fArguments)
return this;

View file

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

View file

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

View file

@ -91,7 +91,7 @@ public class EvalInitList extends CPPDependentEvaluation {
@Override
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);
for (ICPPEvaluation arg : fClauses) {
buffer.marshalEvaluation(arg, includeValue);
@ -99,7 +99,7 @@ public class EvalInitList extends CPPDependentEvaluation {
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();
ICPPEvaluation[] args = new ICPPEvaluation[len];
for (int i = 0; i < args.length; i++) {
@ -112,17 +112,8 @@ public class EvalInitList extends CPPDependentEvaluation {
@Override
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
ICPPEvaluation[] clauses = fClauses;
for (int i = 0; i < fClauses.length; i++) {
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;
}
}
ICPPEvaluation[] clauses = instantiateCommaSeparatedSubexpressions(fClauses, tpMap,
packOffset, within, maxdepth, point);
if (clauses == fClauses)
return this;
return new EvalInitList(clauses, getTemplateDefinition());

View file

@ -295,27 +295,27 @@ public class EvalMemberAccess extends CPPDependentEvaluation {
@Override
public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException {
int firstByte = ITypeMarshalBuffer.EVAL_MEMBER_ACCESS;
short firstBytes = ITypeMarshalBuffer.EVAL_MEMBER_ACCESS;
if (fIsPointerDeref)
firstByte |= ITypeMarshalBuffer.FLAG1;
firstBytes |= ITypeMarshalBuffer.FLAG1;
if (fOwnerValueCategory == LVALUE) {
firstByte |= ITypeMarshalBuffer.FLAG2;
firstBytes |= ITypeMarshalBuffer.FLAG2;
} else if (fOwnerValueCategory == XVALUE) {
firstByte |= ITypeMarshalBuffer.FLAG3;
firstBytes |= ITypeMarshalBuffer.FLAG3;
}
buffer.putByte((byte) firstByte);
buffer.putShort(firstBytes);
buffer.marshalType(fOwnerType);
buffer.marshalBinding(fMember);
marshalTemplateDefinition(buffer);
}
public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
boolean isDeref= (firstByte & ITypeMarshalBuffer.FLAG1) != 0;
public static ISerializableEvaluation unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
boolean isDeref= (firstBytes & ITypeMarshalBuffer.FLAG1) != 0;
ValueCategory ownerValueCat;
if ((firstByte & ITypeMarshalBuffer.FLAG2) != 0) {
if ((firstBytes & ITypeMarshalBuffer.FLAG2) != 0) {
ownerValueCat= LVALUE;
} else if ((firstByte & ITypeMarshalBuffer.FLAG3) != 0) {
} else if ((firstBytes & ITypeMarshalBuffer.FLAG3) != 0) {
ownerValueCat= XVALUE;
} else {
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
public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException {
int firstByte = ITypeMarshalBuffer.EVAL_TYPE_ID;
short firstBytes = ITypeMarshalBuffer.EVAL_TYPE_ID;
if (includeValue)
firstByte |= ITypeMarshalBuffer.FLAG1;
firstBytes |= ITypeMarshalBuffer.FLAG1;
buffer.putByte((byte) firstByte);
buffer.putShort(firstBytes);
buffer.marshalType(fInputType);
if (includeValue) {
buffer.putInt(fArguments.length);
@ -136,10 +136,10 @@ public class EvalTypeId extends CPPDependentEvaluation {
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();
ICPPEvaluation[] args= null;
if ((firstByte & ITypeMarshalBuffer.FLAG1) != 0) {
if ((firstBytes & ITypeMarshalBuffer.FLAG1) != 0) {
int len= buffer.getInt();
args = new ICPPEvaluation[len];
for (int i = 0; i < args.length; i++) {
@ -153,19 +153,9 @@ public class EvalTypeId extends CPPDependentEvaluation {
@Override
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
ICPPEvaluation[] args = fArguments;
if (fArguments != null) {
for (int i = 0; i < fArguments.length; i++) {
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;
}
}
}
ICPPEvaluation[] args = null;
if (fArguments != null)
args = instantiateCommaSeparatedSubexpressions(fArguments, tpMap, packOffset, within, maxdepth, point);
IType type = CPPTemplates.instantiateType(fInputType, tpMap, packOffset, within, point);
if (args == fArguments && type == fInputType)
return this;

View file

@ -300,14 +300,14 @@ public class EvalUnary extends CPPDependentEvaluation {
@Override
public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException {
buffer.putByte(ITypeMarshalBuffer.EVAL_UNARY);
buffer.putShort(ITypeMarshalBuffer.EVAL_UNARY);
buffer.putByte((byte) fOperator);
buffer.marshalEvaluation(fArgument, includeValue);
buffer.marshalBinding(fAddressOfQualifiedNameBinding);
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();
ICPPEvaluation arg= (ICPPEvaluation) buffer.unmarshalEvaluation();
IBinding binding= buffer.unmarshalBinding();

View file

@ -175,13 +175,13 @@ public class EvalUnaryTypeID extends CPPDependentEvaluation {
@Override
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.marshalType(fOrigType);
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();
IType arg= buffer.unmarshalType();
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.ICPPMethod;
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.ICPPUsingDeclaration;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
@ -518,7 +517,7 @@ public class LookupData extends ScopeLookupData {
int count= 0;
if (functionArgs != null) {
for (ICPPEvaluation arg : functionArgs) {
if (arg instanceof EvalFixed && arg.getTypeOrFunctionSet(null) instanceof ICPPParameterPackType)
if (arg instanceof EvalParameterPack)
count++;
}
}

View file

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

View file

@ -63,11 +63,11 @@ public class TypeOfDependentExpression implements ICPPUnknownType, ISerializable
@Override
public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
buffer.putByte(ITypeMarshalBuffer.DEPENDENT_EXPRESSION_TYPE);
buffer.putShort(ITypeMarshalBuffer.DEPENDENT_EXPRESSION_TYPE);
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();
if (eval instanceof ICPPEvaluation)
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.EvalInitList;
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.EvalUnary;
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);
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) {
EvalTypeId e= (EvalTypeId) eval;
IType a = e.getInputType();
@ -535,6 +544,10 @@ public class CPPCompositesFactory extends AbstractCompositeFactory {
return new CompositeCPPTypedefSpecialization(this, (ICPPBinding) binding);
} else if (binding instanceof ICPPUsingDeclaration) {
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 {
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

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Ferguson (Symbian) - Initial implementation
* Markus Schorn (Wind River Systems)
* Andrew Ferguson (Symbian) - Initial implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.index.composite.cpp;

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Ferguson (Symbian) - Initial implementation
* Markus Schorn (Wind River Systems)
* Andrew Ferguson (Symbian) - Initial implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.index.composite.cpp;

View file

@ -1006,9 +1006,9 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
IASTTranslationUnit ast= createAST(lang, codeReader, scanInfo, isSource, fASTOptions, ctx, pm);
fStatistics.fParsingTime += System.currentTimeMillis() - start;
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.
( (ASTTranslationUnit)ast ).setOriginatingTranslationUnit( (ITranslationUnit)tu );
((ASTTranslationUnit) ast).setOriginatingTranslationUnit((ITranslationUnit) tu);
writeToIndex(lang.getLinkageID(), ast, codeReader, ctx, pm);
}
} catch (CoreException e) {

View file

@ -231,12 +231,13 @@ public class PDOM extends PlatformObject implements IPDOM {
* 138.0 - Constexpr functions, bug 395238.
* 139.0 - More efficient and robust storage of types and template arguments, bug 395243.
* 140.0 - Enumerators with dependent values, bug 389009.
* 140.1 - Mechanism for tagging nodes with extended data, bug TODO
* 141.0 - Storing enclosing template bindings for evaluations, bug 399829
* 140.1 - Mechanism for tagging nodes with extended data, bug 400020
* 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 MAX_SUPPORTED_VERSION= version(141, Short.MAX_VALUE);
private static final int DEFAULT_VERSION = version(141, 0);
private static final int MIN_SUPPORTED_VERSION= version(142, 0);
private static final int MAX_SUPPORTED_VERSION= version(142, Short.MAX_VALUE);
private static final int DEFAULT_VERSION = version(142, 0);
private static int version(int major, int minor) {
return (major << 16) + minor;
@ -465,10 +466,8 @@ public class PDOM extends PlatformObject implements IPDOM {
}
public PDOMTagIndex getTagIndex() throws CoreException {
if (tagIndex == null)
{
// 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 );
if (tagIndex == null) {
tagIndex = new PDOMTagIndex(db, TAG_INDEX);
}
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 {
if (indexOfFiledWithUnresolvedIncludes == null) {

View file

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

View file

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

View file

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

View file

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

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.EvalInitList;
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.EvalUnary;
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.Database;
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.PDOMASTAdapter;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
@ -360,9 +362,9 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
addImplicitMethods(pdomBinding, (ICPPClassType) binding, fromName);
}
// Synchronize the tags associated with the persistent binding to match the set that is
// associated with the input binding.
TagManager.getInstance().syncTags( pdomBinding, inputBinding );
// Synchronize the tags associated with the persistent binding to match
// the set that is associated with the input binding.
TagManager.getInstance().syncTags(pdomBinding, inputBinding);
}
} catch (DOMException e) {
throw new CoreException(Util.createStatus(e));
@ -376,9 +378,10 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
pdomBinding.update(this, fromBinding);
// Update the tags based on the tags from the new binding. This was in PDOMBinding.update, but
// I found that not all subclasses (e.g., PDOMCPPFunction) call the parent implementation.
TagManager.getInstance().syncTags( pdomBinding, fromBinding );
// Update the tags based on the tags from the new binding. This cannot be done in
// PDOMBinding.update, because not all subclasses (e.g., PDOMCPPFunction) call
// the superclass implementation.
TagManager.getInstance().syncTags(pdomBinding, fromBinding);
}
return pdomBinding;
@ -1105,94 +1108,98 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
@Override
public IType unmarshalType(ITypeMarshalBuffer buffer) throws CoreException {
int firstByte= buffer.getByte();
switch ((firstByte & ITypeMarshalBuffer.KIND_MASK)) {
short firstBytes= buffer.getShort();
switch ((firstBytes & ITypeMarshalBuffer.KIND_MASK)) {
case ITypeMarshalBuffer.ARRAY_TYPE:
return CPPArrayType.unmarshal(firstByte, buffer);
return CPPArrayType.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.BASIC_TYPE:
return CPPBasicType.unmarshal(firstByte, buffer);
return CPPBasicType.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.CVQUALIFIER_TYPE:
return CPPQualifierType.unmarshal(firstByte, buffer);
return CPPQualifierType.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.FUNCTION_TYPE:
return CPPFunctionType.unmarshal(firstByte, buffer);
return CPPFunctionType.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.POINTER_TYPE:
return CPPPointerType.unmarshal(firstByte, buffer);
return CPPPointerType.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.PROBLEM_TYPE:
return ProblemType.unmarshal(firstByte, buffer);
return ProblemType.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.REFERENCE_TYPE:
return CPPReferenceType.unmarshal(firstByte, buffer);
return CPPReferenceType.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.PACK_EXPANSION_TYPE:
return CPPParameterPackType.unmarshal(firstByte, buffer);
return CPPParameterPackType.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.POINTER_TO_MEMBER_TYPE:
return CPPPointerToMemberType.unmarshal(firstByte, buffer);
return CPPPointerToMemberType.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.DEPENDENT_EXPRESSION_TYPE:
return TypeOfDependentExpression.unmarshal(firstByte, buffer);
return TypeOfDependentExpression.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.UNKNOWN_MEMBER:
IBinding binding= CPPUnknownMember.unmarshal(getPDOM(), firstByte, buffer);
IBinding binding= CPPUnknownMember.unmarshal(getPDOM(), firstBytes, buffer);
if (binding instanceof IType)
return (IType) binding;
break;
case ITypeMarshalBuffer.UNKNOWN_MEMBER_CLASS_INSTANCE:
return CPPUnknownClassInstance.unmarshal(getPDOM(), firstByte, buffer);
return CPPUnknownClassInstance.unmarshal(getPDOM(), firstBytes, buffer);
case ITypeMarshalBuffer.DEFERRED_CLASS_INSTANCE:
return CPPDeferredClassInstance.unmarshal(getPDOM(), firstByte, buffer);
return CPPDeferredClassInstance.unmarshal(getPDOM(), firstBytes, buffer);
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
public IBinding unmarshalBinding(ITypeMarshalBuffer buffer) throws CoreException {
int firstByte= buffer.getByte();
switch ((firstByte & ITypeMarshalBuffer.KIND_MASK)) {
short firstBytes= buffer.getShort();
switch ((firstBytes & ITypeMarshalBuffer.KIND_MASK)) {
case ITypeMarshalBuffer.UNKNOWN_MEMBER:
return CPPUnknownMember.unmarshal(getPDOM(), firstByte, buffer);
return CPPUnknownMember.unmarshal(getPDOM(), firstBytes, buffer);
case ITypeMarshalBuffer.UNKNOWN_MEMBER_CLASS_INSTANCE:
return CPPUnknownClassInstance.unmarshal(getPDOM(), firstByte, buffer);
return CPPUnknownClassInstance.unmarshal(getPDOM(), firstBytes, buffer);
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
public ISerializableEvaluation unmarshalEvaluation(ITypeMarshalBuffer buffer) throws CoreException {
int firstByte= buffer.getByte();
switch ((firstByte & ITypeMarshalBuffer.KIND_MASK)) {
short firstBytes= buffer.getShort();
if (firstBytes == TypeMarshalBuffer.NULL_TYPE)
return null;
switch ((firstBytes & ITypeMarshalBuffer.KIND_MASK)) {
case ITypeMarshalBuffer.EVAL_BINARY:
return EvalBinary.unmarshal(firstByte, buffer);
return EvalBinary.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.EVAL_BINARY_TYPE_ID:
return EvalBinaryTypeId.unmarshal(firstByte, buffer);
return EvalBinaryTypeId.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.EVAL_BINDING:
return EvalBinding.unmarshal(firstByte, buffer);
return EvalBinding.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.EVAL_COMMA:
return EvalComma.unmarshal(firstByte, buffer);
return EvalComma.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.EVAL_COMPOUND:
return EvalCompound.unmarshal(firstByte, buffer);
return EvalCompound.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.EVAL_CONDITIONAL:
return EvalConditional.unmarshal(firstByte, buffer);
return EvalConditional.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.EVAL_FIXED:
return EvalFixed.unmarshal(firstByte, buffer);
return EvalFixed.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.EVAL_FUNCTION_CALL:
return EvalFunctionCall.unmarshal(firstByte, buffer);
return EvalFunctionCall.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.EVAL_FUNCTION_SET:
return EvalFunctionSet.unmarshal(firstByte, buffer);
return EvalFunctionSet.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.EVAL_ID:
return EvalID.unmarshal(firstByte, buffer);
return EvalID.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.EVAL_INIT_LIST:
return EvalInitList.unmarshal(firstByte, buffer);
return EvalInitList.unmarshal(firstBytes, buffer);
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:
return EvalTypeId.unmarshal(firstByte, buffer);
return EvalTypeId.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.EVAL_UNARY:
return EvalUnary.unmarshal(firstByte, buffer);
return EvalUnary.unmarshal(firstBytes, buffer);
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
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Eidsness - Initial implementation
*/
package org.eclipse.cdt.internal.core.pdom.tag;
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.core.runtime.CoreException;
public class BTreeIterable<T> implements Iterable<T>
{
public static interface Descriptor<T>
{
public int compare( long record ) throws CoreException;
public T create( long record );
public class BTreeIterable<T> implements Iterable<T> {
public static interface Descriptor<T> {
public int compare(long record) throws CoreException;
public T create(long record);
}
private final BTree btree;
private final Descriptor<T> descriptor;
public BTreeIterable( BTree btree, Descriptor<T> descriptor )
{
public BTreeIterable(BTree btree, Descriptor<T> descriptor) {
this.btree = btree;
this.descriptor = descriptor;
}
@Override
public Iterator<T> iterator()
{
public Iterator<T> iterator() {
Visitor v = new Visitor();
try { btree.accept( v ); }
catch( CoreException e ) { CCorePlugin.log( e ); return Collections.<T>emptyList().iterator(); }
return new BTreeIterator( v.records );
try {
btree.accept(v);
} 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>();
@Override
public int compare( long record ) throws CoreException
{
return BTreeIterable.this.descriptor.compare( record );
public int compare(long record) throws CoreException {
return BTreeIterable.this.descriptor.compare(record);
}
@Override
public boolean visit( long record ) throws CoreException
{
records.add( Long.valueOf( record ) );
public boolean visit(long record) throws CoreException {
records.add(Long.valueOf(record));
return true;
}
}
private class BTreeIterator implements Iterator<T>
{
private class BTreeIterator implements Iterator<T> {
private final Iterator<Long> records;
public BTreeIterator( Iterable<Long> records )
{
public BTreeIterator(Iterable<Long> records) {
this.records = records.iterator();
}
@Override public void remove() { }
@Override public boolean hasNext() { return records.hasNext(); }
@Override public T next() { return BTreeIterable.this.descriptor.create( records.next() ); }
@Override
public void remove() {
}
@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
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Eidsness - Initial implementation
*/
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.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 long record;
private String taggerId;
private int dataLen = -1;
private static enum Fields
{
Node,
TaggerId,
DataLen,
Data;
private static enum Fields {
Node, TaggerId, DataLen, Data;
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
{
return db.getRecPtr( instance + offset + data_offset );
public static int sizeof(int datalen) {
return (int) Data.offset + datalen;
}
public void putRecPtr( Database db, long instance, long data_offset, long value ) throws CoreException
{
db.putRecPtr( instance + offset + data_offset, value );
public long getRecPtr(Database db, long instance, long data_offset) throws CoreException {
return db.getRecPtr(instance + offset + data_offset);
}
public void put( Database db, long instance, long data_offset, byte value ) throws CoreException
{
db.putByte( instance + offset + data_offset, value );
public void putRecPtr(Database db, long instance, long data_offset, long value)
throws CoreException {
db.putRecPtr(instance + offset + data_offset, value);
}
public void put( Database db, long instance, byte[] data, long data_offset, int len ) throws CoreException
{
db.putBytes( instance + offset + data_offset, data, len );
public void put(Database db, long instance, long data_offset, byte value)
throws CoreException {
db.putByte(instance + offset + data_offset, value);
}
public byte getByte( Database db, long instance, long data_offset ) throws CoreException
{
return db.getByte( instance + offset + data_offset );
public void put(Database db, long instance, byte[] data, long data_offset, int len)
throws CoreException {
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];
db.getBytes( instance + offset + data_offset, data );
db.getBytes(instance + offset + data_offset, data);
return data;
}
public void put( Database db, long instance, long data_offset, int value ) throws CoreException
{
db.putInt( instance + offset + data_offset, value );
public void put(Database db, long instance, long data_offset, int value)
throws CoreException {
db.putInt(instance + offset + data_offset, value);
}
public int getInt( Database db, long instance, long data_offset ) throws CoreException
{
return db.getInt( instance + offset + data_offset );
public int getInt(Database db, long instance, long data_offset) throws CoreException {
return db.getInt(instance + offset + data_offset);
}
}
public PDOMTag( Database db, long record )
{
public PDOMTag(Database db, long record) {
this.db = db;
this.record = record;
}
public PDOMTag( Database db, int dataLen ) throws CoreException
{
public PDOMTag(Database db, int dataLen) throws CoreException {
this.db = db;
this.record = db.malloc( Fields.sizeof( dataLen ) );
this.record = db.malloc(Fields.sizeof(dataLen));
this.dataLen = dataLen;
Fields.DataLen.put( db, record, 0, dataLen );
Fields.DataLen.put(db, record, 0, dataLen);
}
public long getNode() throws CoreException
{
return Fields.Node.getRecPtr( db, record, 0 );
public long getNode() throws CoreException {
return Fields.Node.getRecPtr(db, record, 0);
}
@Override
public String getTaggerId()
{
if( taggerId == null )
try
{
long taggerIdRecord = Fields.TaggerId.getRecPtr( db, record, 0 );
taggerId = taggerIdRecord == 0L ? new String() : db.getString( taggerIdRecord ).getString();
}
catch( CoreException e )
{
CCorePlugin.log( e );
public String getTaggerId() {
if (taggerId == null)
try {
long taggerIdRecord = Fields.TaggerId.getRecPtr(db, record, 0);
taggerId = taggerIdRecord == 0L ? new String() : db.getString(taggerIdRecord)
.getString();
} catch (CoreException e) {
CCorePlugin.log(e);
}
return taggerId;
}
@Override
public int getDataLen()
{
if( dataLen < 0 )
try { dataLen = Fields.DataLen.getInt( db, record, 0 ); }
catch( CoreException e ) { CCorePlugin.log( e ); return 0; }
public int getDataLen() {
if (dataLen < 0)
try {
dataLen = Fields.DataLen.getInt(db, record, 0);
} catch (CoreException e) {
CCorePlugin.log(e);
return 0;
}
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
* specified data. Return null on failure.
* Create and return a new PDOMTag that has the same node/taggerId as the receiver but with the specified
* data. Return null on failure.
*/
public PDOMTag cloneWith( byte[] data ) throws CoreException
{
public PDOMTag cloneWith(byte[] data) throws CoreException {
PDOMTag partialTag = null;
try
{
long existing_node = Fields.Node.getRecPtr( db, record, 0 );
long existing_id = Fields.TaggerId.getRecPtr( db, record, 0 );
try {
long existing_node = Fields.Node.getRecPtr(db, record, 0);
long existing_id = Fields.TaggerId.getRecPtr(db, record, 0);
partialTag = new PDOMTag( db, data.length );
Fields.Node.putRecPtr( db, partialTag.record, 0, existing_node );
Fields.TaggerId.putRecPtr( db, partialTag.record, 0, existing_id );
if( partialTag.putBytes( 0, data, data.length ) )
{
partialTag = new PDOMTag(db, data.length);
Fields.Node.putRecPtr(db, partialTag.record, 0, existing_node);
Fields.TaggerId.putRecPtr(db, partialTag.record, 0, existing_id);
if (partialTag.putBytes(0, data, data.length)) {
PDOMTag tag = partialTag;
partialTag = null;
return tag;
}
}
finally
{
if( partialTag != null )
} finally {
if (partialTag != null)
partialTag.delete();
}
return null;
}
public void delete()
{
if( db != null
&& record != 0 )
try { db.free( record ); }
catch( CoreException e ) { CCorePlugin.log( e ); }
public void delete() {
if (db != null && record != 0)
try {
db.free(record);
} catch (CoreException e) {
CCorePlugin.log(e);
}
}
public static class BTreeComparator implements IBTreeComparator
{
public static class BTreeComparator implements IBTreeComparator {
private final Database db;
public BTreeComparator( Database db ) { this.db = db; }
public BTreeComparator(Database db) {
this.db = db;
}
@Override
public int compare(long record1, long record2) throws CoreException
{
if( record1 == record2 )
public int compare(long record1, long record2) throws CoreException {
if (record1 == record2)
return 0;
long node1 = Fields.Node.getRecPtr( db, record1, 0 );
long node2 = Fields.Node.getRecPtr( db, record2, 0 );
if( node1 < node2 )
long node1 = Fields.Node.getRecPtr(db, record1, 0);
long node2 = Fields.Node.getRecPtr(db, record2, 0);
if (node1 < node2)
return -1;
if( node1 > node2 )
if (node1 > node2)
return 1;
long tagger1 = Fields.TaggerId.getRecPtr( db, record1, 0 );
long tagger2 = Fields.TaggerId.getRecPtr( db, record2, 0 );
if( tagger1 < tagger2 )
long tagger1 = Fields.TaggerId.getRecPtr(db, record1, 0);
long tagger2 = Fields.TaggerId.getRecPtr(db, record2, 0);
if (tagger1 < tagger2)
return -1;
if( tagger1 > tagger2 )
if (tagger1 > tagger2)
return 1;
return 0;
}
}
public static class BTreeVisitor implements IBTreeVisitor
{
public static class BTreeVisitor implements IBTreeVisitor {
private final Database db;
private final long node2;
private final long tagger2;
@ -201,8 +211,7 @@ public class PDOMTag implements IWritableTag
public boolean hasResult = false;
public long tagRecord = 0;
public BTreeVisitor( Database db, long node2, long tagger2 )
{
public BTreeVisitor(Database db, long node2, long tagger2) {
this.db = db;
this.node2 = node2;
this.tagger2 = tagger2;
@ -210,16 +219,16 @@ public class PDOMTag implements IWritableTag
@Override
public int compare(long record1) throws CoreException {
long node1 = Fields.Node.getRecPtr( db, record1, 0 );
if( node1 < node2 )
long node1 = Fields.Node.getRecPtr(db, record1, 0);
if (node1 < node2)
return -1;
if( node1 > node2 )
if (node1 > node2)
return 1;
long tagger1 = Fields.TaggerId.getRecPtr( db, record1, 0 );
if( tagger1 < tagger2 )
long tagger1 = Fields.TaggerId.getRecPtr(db, record1, 0);
if (tagger1 < tagger2)
return -1;
if( tagger1 > tagger2 )
if (tagger1 > tagger2)
return 1;
return 0;
@ -233,80 +242,82 @@ public class PDOMTag implements IWritableTag
}
}
public void setNode( long node ) throws CoreException
{
Fields.Node.putRecPtr( db, record, 0, node );
public void setNode(long node) throws CoreException {
Fields.Node.putRecPtr(db, record, 0, node);
}
public void setTaggerId( long idRecord ) throws CoreException
{
Fields.TaggerId.putRecPtr( db, record, 0, idRecord );
public void setTaggerId(long idRecord) throws CoreException {
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();
return offset >= 0
&& offset < data_len
&& ( offset + len ) <= data_len;
return offset >= 0 && offset < data_len && (offset + len) <= data_len;
}
@Override
public boolean putByte( int offset, byte data )
{
if( ! isInBounds( offset, 1 ) )
public boolean putByte(int offset, byte data) {
if (!isInBounds(offset, 1))
return false;
try { Fields.Data.put( db, record, offset, data ); return true; }
catch( CoreException e ) { CCorePlugin.log( e ); return false; }
try {
Fields.Data.put(db, record, offset, data);
return true;
} catch (CoreException e) {
CCorePlugin.log(e);
return false;
}
}
@Override
public boolean putBytes( int offset, byte[] data, int len )
{
public boolean putBytes(int offset, byte[] data, int len) {
boolean fullWrite = len < 0;
if( fullWrite )
if (fullWrite)
len = data.length;
if( ! isInBounds( offset, len ) )
if (!isInBounds(offset, len))
return false;
try
{
Fields.Data.put( db, record, data, offset, len );
try {
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
int currLen = getDataLen();
if( fullWrite
&& offset == 0
&& currLen > len )
{
Fields.DataLen.put( db, record, 0, len );
if (fullWrite && offset == 0 && currLen > len) {
Fields.DataLen.put(db, record, 0, len);
dataLen = len;
}
return true;
} catch (CoreException e) {
CCorePlugin.log(e);
return false;
}
catch( CoreException e ) { CCorePlugin.log( e ); return false; }
}
@Override
public int getByte( int offset )
{
if( ! isInBounds( offset, 1 ) )
return Fail;
public int getByte(int offset) {
if (!isInBounds(offset, 1))
return FAIL;
try { return Fields.Data.getByte( db, record, offset ); }
catch( CoreException e ) { CCorePlugin.log( e ); return Fail; }
try {
return Fields.Data.getByte(db, record, offset);
} catch (CoreException e) {
CCorePlugin.log(e);
return FAIL;
}
}
@Override
public byte[] getBytes( int offset, int len )
{
public byte[] getBytes(int offset, int len) {
len = len >= 0 ? len : getDataLen() - offset;
if( ! isInBounds( offset, len ) )
if (!isInBounds(offset, len))
return null;
try { return Fields.Data.getBytes( db, record, offset, len ); }
catch( CoreException e ) { CCorePlugin.log( e ); return null; }
try {
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
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Eidsness - Initial implementation
*/
package org.eclipse.cdt.internal.core.pdom.tag;
@ -24,17 +27,13 @@ import org.eclipse.core.runtime.CoreException;
/**
* Not thread-safe.
*/
public class PDOMTagIndex
{
public class PDOMTagIndex {
private final Database db;
private final long ptr;
private long rootRecord;
private static enum Fields
{
TaggerIds,
Tags,
_last;
private static enum Fields {
TaggerIds, Tags, _last;
public final long offset = ordinal() * Database.PTR_SIZE;
public static int sizeof = _last.ordinal() * Database.PTR_SIZE;
@ -43,89 +42,75 @@ public class PDOMTagIndex
private PDOMStringSet taggerIds;
private BTree tags;
public PDOMTagIndex( Database db, long ptr ) throws CoreException
{
public PDOMTagIndex(Database db, long ptr) throws CoreException {
this.db = db;
this.ptr = ptr;
this.rootRecord = 0;
}
private long getFieldAddress( Fields field ) throws CoreException
{
if( rootRecord == 0 )
rootRecord = db.getRecPtr( ptr );
private long getFieldAddress(Fields field) throws CoreException {
if (rootRecord == 0)
rootRecord = db.getRecPtr(ptr);
if( rootRecord == 0 )
{
rootRecord = db.malloc( Fields.sizeof );
db.putRecPtr( ptr, rootRecord );
if (rootRecord == 0) {
rootRecord = db.malloc(Fields.sizeof);
db.putRecPtr(ptr, rootRecord);
}
return rootRecord + field.offset;
}
private PDOMStringSet getTaggerIds() throws CoreException
{
if( taggerIds == null )
taggerIds = new PDOMStringSet( db, getFieldAddress( Fields.TaggerIds ) );
private PDOMStringSet getTaggerIds() throws CoreException {
if (taggerIds == null)
taggerIds = new PDOMStringSet(db, getFieldAddress(Fields.TaggerIds));
return taggerIds;
}
private BTree getTagsBTree() throws CoreException
{
if( tags == null )
tags = new BTree( db, getFieldAddress( Fields.Tags ), new PDOMTag.BTreeComparator( db ) );
private BTree getTagsBTree() throws CoreException {
if (tags == null)
tags = new BTree(db, getFieldAddress(Fields.Tags), new PDOMTag.BTreeComparator(db));
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.isEmpty();
assert !taggerId.isEmpty();
if( db == null
|| taggerId == null
|| taggerId.isEmpty()
|| ( taggerIds == null && ! createIfNeeded ) )
if (db == null || taggerId == null || taggerId.isEmpty()
|| (taggerIds == null && !createIfNeeded))
return 0L;
try
{
long record = getTaggerIds().find( taggerId );
if( record == 0
&& createIfNeeded )
record = getTaggerIds().add( taggerId );
try {
long record = getTaggerIds().find(taggerId);
if (record == 0 && createIfNeeded)
record = getTaggerIds().add(taggerId);
return record;
}
catch( CoreException e )
{
CCorePlugin.log( e );
} catch (CoreException e) {
CCorePlugin.log(e);
}
return 0L;
}
private IWritableTag createTag( long record, String id, int len )
{
if( db == null )
private IWritableTag createTag(long record, String id, int len) {
if (db == null)
return null;
long idRecord = getIdRecord( id, true );
if( idRecord == 0L )
long idRecord = getIdRecord(id, true);
if (idRecord == 0L)
return null;
try
{
PDOMTag tag = new PDOMTag( db, len );
tag.setNode( record );
tag.setTaggerId( idRecord );
try {
PDOMTag tag = new PDOMTag(db, len);
tag.setNode(record);
tag.setTaggerId(idRecord);
// return the tag if it was properly inserted
long inserted = getTagsBTree().insert( tag.getRecord() );
if( inserted == tag.getRecord() )
long inserted = getTagsBTree().insert(tag.getRecord());
if (inserted == tag.getRecord())
return tag;
// TODO check that the existing record has the same length
@ -133,147 +118,152 @@ public class PDOMTagIndex
// otherwise destroy this provisional one and return the tag that was actually inserted
// TODO figure out what this case means
tag.delete();
return inserted == 0 ? null : new PDOMTag( db, inserted );
}
catch( CoreException e )
{
CCorePlugin.log( e );
return inserted == 0 ? null : new PDOMTag(db, inserted);
} catch (CoreException e) {
CCorePlugin.log(e);
}
return null;
}
private ITag getTag( long record, String id )
{
if( db == null )
private ITag getTag(long record, String id) {
if (db == null)
return null;
long idRecord = getIdRecord( id, false );
if( idRecord == 0L )
long idRecord = getIdRecord(id, false);
if (idRecord == 0L)
return null;
PDOMTag.BTreeVisitor v = new PDOMTag.BTreeVisitor( db, record, idRecord );
try { getTagsBTree().accept( v ); }
catch( CoreException e ) { CCorePlugin.log( e ); }
PDOMTag.BTreeVisitor v = new PDOMTag.BTreeVisitor(db, record, idRecord);
try {
getTagsBTree().accept(v);
} catch (CoreException e) {
CCorePlugin.log(e);
}
return v.hasResult ? new PDOMTag( db, v.tagRecord ) : null;
return v.hasResult ? new PDOMTag(db, v.tagRecord) : null;
}
private Iterable<ITag> getTags( long binding_record )
{
private Iterable<ITag> getTags(long binding_record) {
BTree btree = null;
try { btree = getTagsBTree(); }
catch( CoreException e ) { CCorePlugin.log( e ); return Collections.emptyList(); }
try {
btree = getTagsBTree();
} catch (CoreException e) {
CCorePlugin.log(e);
return Collections.emptyList();
}
final Long bindingRecord = Long.valueOf( binding_record );
return
new BTreeIterable<ITag>(
btree,
new BTreeIterable.Descriptor<ITag>()
{
@Override public ITag create( long record ) { return new PDOMTag( db, record ); }
@Override
public int compare( long test_record ) throws CoreException
{
long test_node = new PDOMTag( db, test_record ).getNode();
final Long bindingRecord = Long.valueOf(binding_record);
return new BTreeIterable<ITag>(btree, new BTreeIterable.Descriptor<ITag>() {
@Override
public ITag create(long record) {
return new PDOMTag(db, record);
}
// -1 if record < key, 0 if record == key, 1 if record > key
return Long.valueOf( test_node ).compareTo( bindingRecord );
}
} );
@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
return Long.valueOf(test_node).compareTo(bindingRecord);
}
});
}
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
// 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
// record. In each case we decide whether to delete or update the tag. Tags of the same size can be
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
// 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
// record. In each case we decide whether to delete or update the tag. Tags of the same size can be
// updated in place, otherwise the tag needs to be deleted and recreated.
final Map<String, ITag> newTags = new HashMap<String, ITag>();
for( ITag tag : tags )
{
ITag dupTag = newTags.put( tag.getTaggerId(), tag );
if( dupTag != null )
CCorePlugin.log( "Duplicate incoming tag for record " + binding_record + " from taggerId " + tag.getTaggerId() ); //$NON-NLS-1$ //$NON-NLS-2$
for (ITag tag : tags) {
ITag dupTag = newTags.put(tag.getTaggerId(), tag);
if (dupTag != null)
CCorePlugin
.log("Duplicate incoming tag for record " + binding_record + " from taggerId " + tag.getTaggerId()); //$NON-NLS-1$ //$NON-NLS-2$
}
BTree btree = null;
try { btree = getTagsBTree(); }
catch( CoreException e ) { CCorePlugin.log( e ); return false; }
try {
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
try { btree.accept( sync ); }
catch( CoreException e ) { CCorePlugin.log( e ); return false; }
try {
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.
sync.synchronize( btree );
sync.synchronize(btree);
// insert any new tags that are left in the incoming list
for( ITag newTag : newTags.values() )
{
IWritableTag pdomTag = createTag( binding_record, newTag.getTaggerId(), newTag.getDataLen() );
pdomTag.putBytes( 0, newTag.getBytes( 0, -1 ), -1 );
for (ITag newTag : newTags.values()) {
IWritableTag pdomTag = createTag(binding_record, newTag.getTaggerId(),
newTag.getDataLen());
pdomTag.putBytes(0, newTag.getBytes(0, -1), -1);
}
return true;
}
private static PDOMTagIndex getTagIndex( PDOM pdom )
{
if( pdom == null )
private static PDOMTagIndex getTagIndex(PDOM pdom) {
if (pdom == null)
return null;
try
{
try {
PDOMTagIndex index = pdom.getTagIndex();
return index.db == null ? null : index;
} catch (CoreException e) {
CCorePlugin.log(e);
}
catch( CoreException e ) { CCorePlugin.log(e); }
return null;
}
// common implementations
public static IWritableTag createTag( PDOM pdom, long record, String id, int len )
{
PDOMTagIndex index = getTagIndex( pdom );
if( index == null )
public static IWritableTag createTag(PDOM pdom, long record, String id, int len) {
PDOMTagIndex index = getTagIndex(pdom);
if (index == 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 )
{
PDOMTagIndex index = getTagIndex( pdom );
if( index == null )
public static ITag getTag(PDOM pdom, long record, String id) {
PDOMTagIndex index = getTagIndex(pdom);
if (index == null)
return null;
return index.getTag( record, id );
return index.getTag(record, id);
}
public static Iterable<ITag> getTags( PDOM pdom, long record )
{
PDOMTagIndex index = getTagIndex( pdom );
if( index == null )
public static Iterable<ITag> getTags(PDOM pdom, long record) {
PDOMTagIndex index = getTagIndex(pdom);
if (index == null)
return Collections.emptyList();
return index.getTags( record );
return index.getTags(record);
}
public static boolean setTags( PDOM pdom, long record, Iterable<ITag> tags )
{
if( record == 0 )
public static boolean setTags(PDOM pdom, long record, Iterable<ITag> tags) {
if (record == 0)
return true;
PDOMTagIndex index = getTagIndex( pdom );
if( index == null )
PDOMTagIndex index = getTagIndex(pdom);
if (index == null)
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
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Eidsness - Initial implementation
*/
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.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 Long searchRecord;
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> 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.searchRecord = searchRecord;
this.newTags = newTags;
}
/**
* Complete the synchronization by deleting and inserting all required records. Return
* true if successful and false otherwise.
* Complete the synchronization by deleting and inserting all required records. Return true if successful
* and false otherwise.
*/
public boolean synchronize( BTree tree )
{
for( Long rm : toRemove )
try
{
public boolean synchronize(BTree tree) {
for (Long rm : toRemove)
try {
long record = rm.longValue();
tree.delete( record );
db.free( record );
}
catch( CoreException e )
{
CCorePlugin.log( e );
tree.delete(record);
db.free(record);
} catch (CoreException e) {
CCorePlugin.log(e);
}
toRemove.clear();
for( Long insert : toInsert )
try { tree.insert( insert.longValue() ); }
catch( CoreException e )
{
CCorePlugin.log( e );
try { db.free( insert.longValue() ); }
catch( CoreException e1 ) { CCorePlugin.log( e1 ); }
for (Long insert : toInsert)
try {
tree.insert(insert.longValue());
} catch (CoreException e) {
CCorePlugin.log(e);
try {
db.free(insert.longValue());
} catch (CoreException e1) {
CCorePlugin.log(e1);
}
}
toInsert.clear();
@ -68,35 +71,32 @@ public class PDOMTagSynchronizer implements IBTreeVisitor
}
@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
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
return Long.valueOf( test_node ).compareTo( searchRecord );
return Long.valueOf(test_node).compareTo(searchRecord);
}
@Override
public boolean visit( long existing_record ) throws CoreException
{
PDOMTag existingTag = new PDOMTag( db, existing_record );
public boolean visit(long existing_record) throws CoreException {
PDOMTag existingTag = new PDOMTag(db, existing_record);
String taggerId = existingTag.getTaggerId();
ITag newTag = newTags.remove( taggerId );
if( newTag == null )
toRemove.add( Long.valueOf( existing_record ) );
else if( newTag.getDataLen() > existingTag.getDataLen() )
{
toRemove.add( Long.valueOf( existing_record ) );
ITag newTag = newTags.remove(taggerId);
if (newTag == null) {
toRemove.add(Long.valueOf(existing_record));
} else if (newTag.getDataLen() > existingTag.getDataLen()) {
toRemove.add(Long.valueOf(existing_record));
PDOMTag pdomTag = existingTag.cloneWith( newTag.getBytes( 0, -1 ) );
if( pdomTag != null )
toInsert.add( Long.valueOf( pdomTag.getRecord() ) );
}
else if( ! existingTag.putBytes( 0, newTag.getBytes( 0, -1 ), -1 ) )
CCorePlugin.log( "Unable to modify data of tag record " + existing_record + " from taggerId " + taggerId ); //$NON-NLS-1$ //$NON-NLS-2$
PDOMTag pdomTag = existingTag.cloneWith(newTag.getBytes(0, -1));
if (pdomTag != null)
toInsert.add(Long.valueOf(pdomTag.getRecord()));
} else if (!existingTag.putBytes(0, newTag.getBytes(0, -1), -1))
CCorePlugin
.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
return true;

View file

@ -4,6 +4,9 @@
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Eidsness - Initial implementation
*/
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.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 long record;
public PDOMTaggable( PDOM pdom, long record )
{
public PDOMTaggable(PDOM pdom, long record) {
this.pdom = pdom;
this.record = record;
}
@Override
public IWritableTag createTag( String id, int len )
{
return PDOMTagIndex.createTag( pdom, record, id, len );
public IWritableTag createTag(String id, int len) {
return PDOMTagIndex.createTag(pdom, record, id, len);
}
@Override
public ITag getTag( String id )
{
return PDOMTagIndex.getTag( pdom, record, id );
public ITag getTag(String id) {
return PDOMTagIndex.getTag(pdom, record, id);
}
@Override
public Iterable<ITag> getTags()
{
return PDOMTagIndex.getTags( pdom, record );
public Iterable<ITag> getTags() {
return PDOMTagIndex.getTags(pdom, record);
}
@Override
public boolean setTags( Iterable<ITag> tags )
{
return PDOMTagIndex.setTags( pdom, record, tags );
public boolean setTags(Iterable<ITag> 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.
*/
public CDTLogWriter cdtLog = null;
public CDTLogWriter cdtLog;
private volatile CProjectDescriptionManager fNewCProjectDescriptionManager;

View file

@ -283,11 +283,15 @@ public class UserDefinedEnvironmentSupplier extends
}
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);

View file

@ -2467,6 +2467,9 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
}
private int visit(IASTTypeIdExpression node) {
if (enclosedInMacroExpansion(node)) {
return PROCESS_SKIP;
}
scribe.printNextToken(peekNextToken());
scribe.printNextToken(Token.tLPAREN);
node.getTypeId().accept(this);
@ -2598,6 +2601,9 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
}
private int visit(IASTUnaryExpression node) {
if (enclosedInMacroExpansion(node)) {
return PROCESS_SKIP;
}
final IASTExpression operand= node.getOperand();
final int operator= node.getOperator();
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
* are made available under the terms of the Eclipse Public License v1.0
* 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.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.CElementImageProvider;
/*
* CViewLabelProvider
/**
* Label provider for "C/C++ Projects" view.
*/
public class CViewLabelProvider extends AppearanceAwareLabelProvider {
public CViewLabelProvider(long textFlags, int imageFlags) {
super(textFlags, imageFlags);
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
*/
@Override
public String getText(Object element) {
if (element instanceof IncludeReferenceProxy) {
@ -103,22 +99,23 @@ public class CViewLabelProvider extends AppearanceAwareLabelProvider {
return Strings.markLTR(new StyledString(getText(element)));
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
*/
@Override
public Image getImage(Object element) {
String imageKey = null;
if (element instanceof IncludeReferenceProxy) {
IIncludeReference reference = ((IncludeReferenceProxy)element).getReference();
IContainer containerInclude = ResourcesPlugin.getWorkspace().getRoot().getContainerForLocation(reference.getPath());
if (containerInclude != null) {
ICProject cproject = reference.getCProject();
IProject project = (cproject != null) ? cproject.getProject() : null;
IPath path = reference.getPath();
ICProject cproject = reference.getCProject();
IProject project = (cproject != null) ? cproject.getProject() : null;
for (IContainer containerInclude : ResourcesPlugin.getWorkspace().getRoot().findContainersForLocationURI(URIUtil.toURI(path.makeAbsolute()))) {
IProject projectInclude = containerInclude.getProject();
boolean isProjectRelative = projectInclude != null && projectInclude.equals(project);
imageKey = LanguageSettingsImages.getImageKey(ICSettingEntry.INCLUDE_PATH, ICSettingEntry.VALUE_WORKSPACE_PATH, isProjectRelative);
} else {
if (isProjectRelative) {
break;
}
}
if (imageKey == null) {
imageKey = CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER;
}
} 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.internal.ui.ImageCombo;
import org.eclipse.cdt.internal.ui.newui.LanguageSettingsImages;
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 {
private static final String SLASH = "/"; //$NON-NLS-1$
private ICConfigurationDescription cfgDescription;
private IProject project;
private ICLanguageSettingEntry entry;
private boolean clearValue;
private int kind;
private final ICConfigurationDescription cfgDescription;
private final IProject project;
private final ICLanguageSettingEntry initialEntry;
private final int initialKind;
private final boolean clearValue;
private Composite compositeArea;
private Label iconComboKind;
@ -116,9 +115,9 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
super(parent, ""); //$NON-NLS-1$
this.cfgDescription = cfgDescription;
this.project = cfgDescription.getProjectDescription().getProject();
this.entry = null;
this.initialEntry = null;
this.initialKind = kind;
this.clearValue = true;
this.kind = kind;
}
/**
@ -129,8 +128,8 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
super(parent, ""); //$NON-NLS-1$
this.cfgDescription = cfgDescription;
this.project = cfgDescription.getProjectDescription().getProject();
this.entry = entry;
this.kind = entry != null ? entry.getKind() : ICSettingEntry.INCLUDE_PATH;
this.initialEntry = entry;
this.initialKind = entry != null ? entry.getKind() : ICSettingEntry.INCLUDE_PATH;
this.clearValue = clearValue;
}
@ -211,7 +210,7 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
gd.horizontalAlignment = SWT.RIGHT;
iconComboKind.setLayoutData(gd);
iconComboKind.setText(Messages.LanguageSettingEntryDialog_SelectKind);
int kindToComboIndex = kindToComboIndex(kind);
int kindToComboIndex = kindToComboIndex(initialKind);
iconComboKind.setImage(comboKindImages[kindToComboIndex]);
// Combo for the setting entry kind
@ -248,14 +247,14 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
comboPathCategory.add(pathCategories[i], pathCategoryImages[i]);
}
int pcindex = COMBO_PATH_INDEX_PROJECT;
if (entry != null) {
if ((entry.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH) == 0) {
if (initialEntry != null) {
if ((initialEntry.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH) == 0) {
pcindex = COMBO_PATH_INDEX_FILESYSTEM;
} else {
if (entry.getName().startsWith(SLASH)) {
pcindex = COMBO_PATH_INDEX_WORKSPACE;
} else {
if (LanguageSettingsImages.isProjectRelative(initialEntry)) {
pcindex = COMBO_PATH_INDEX_PROJECT;
} else {
pcindex = COMBO_PATH_INDEX_WORKSPACE;
}
}
}
@ -286,8 +285,12 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
// Dir/File/Name input
inputName = new Text(compositeArea, SWT.SINGLE | SWT.BORDER);
if (entry!=null && !clearValue) {
inputName.setText(entry.getName());
if (initialEntry != null && !clearValue) {
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.horizontalSpan = 2;
@ -334,14 +337,14 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
// Value input. Located after the other controls to get sufficient width
int comboPathWidth = comboPathCategory.computeSize(SWT.DEFAULT, SWT.NONE).x;
inputValue = new Text(compositeArea, SWT.SINGLE | SWT.BORDER);
if (entry != null && !clearValue) {
inputValue.setText(entry.getValue());
if (initialEntry != null && !clearValue) {
inputValue.setText(initialEntry.getValue());
}
gd = new GridData(SWT.FILL, SWT.NONE, false, false);
gd.widthHint = comboPathWidth;
inputValue.setLayoutData(gd);
if (entry != null && kind == ICSettingEntry.MACRO && !clearValue) {
if (initialEntry != null && initialKind == ICSettingEntry.MACRO && !clearValue) {
inputValue.setFocus();
inputValue.setSelection(0, inputValue.getText().length());
}
@ -357,7 +360,7 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
// Checkbox "Built-In"
checkBoxBuiltIn = new Button(compCheckboxes, SWT.CHECK);
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);
checkBoxBuiltIn.setLayoutData(gd);
checkBoxBuiltIn.addSelectionListener(new SelectionListener() {
@ -375,7 +378,7 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
// Checkbox "Contains system includes"
checkBoxSystem = new Button(compCheckboxes, SWT.CHECK);
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);
checkBoxSystem.setLayoutData(gd);
checkBoxSystem.addSelectionListener(new SelectionListener() {
@ -393,7 +396,7 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
// Checkbox "Framework folder"
checkBoxFramework = new Button(compCheckboxes, SWT.CHECK);
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);
checkBoxFramework.setLayoutData(gd);
checkBoxFramework.addSelectionListener(new SelectionListener() {
@ -515,28 +518,38 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
public void buttonPressed(SelectionEvent e) {
String str = null;
if (e.widget.equals(buttonOk)) {
String name = inputName.getText().trim();
text1 = name;
String value = inputValue.getText().trim();
text1 = inputName.getText().trim();
result = true;
String name = text1;
int flagBuiltIn = checkBoxBuiltIn.isVisible() && checkBoxBuiltIn.getSelection() ? ICSettingEntry.BUILTIN : 0;
int flagSystem = checkBoxSystem.isVisible() && checkBoxSystem.getSelection() ? 0 : ICSettingEntry.LOCAL;
int flagFramework = checkBoxFramework.isVisible() && checkBoxFramework.getSelection() ? ICSettingEntry.FRAMEWORKS_MAC : 0;
int indexPathKind = comboPathCategory.getSelectionIndex();
int flags = flagBuiltIn;
int kind = comboKind.getSelectionIndex();
boolean isProjectPath = indexPathKind == COMBO_PATH_INDEX_PROJECT;
boolean isWorkspacePath = (kind != COMBO_INDEX_MACRO) && (isProjectPath || indexPathKind == COMBO_PATH_INDEX_WORKSPACE);
int flagWorkspace = isWorkspacePath ? ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED : 0;
int flags = flagBuiltIn | flagWorkspace | flagSystem | flagFramework;
if (kind != COMBO_INDEX_MACRO) {
int flagSystem = checkBoxSystem.isVisible() && checkBoxSystem.getSelection() ? 0 : ICSettingEntry.LOCAL;
int flagFramework = checkBoxFramework.isVisible() && checkBoxFramework.getSelection() ? ICSettingEntry.FRAMEWORKS_MAC : 0;
int indexPathKind = comboPathCategory.getSelectionIndex();
boolean isProjectPath = indexPathKind == COMBO_PATH_INDEX_PROJECT;
boolean isWorkspacePath = indexPathKind == COMBO_PATH_INDEX_WORKSPACE;
int flagWorkspace = (isWorkspacePath || isProjectPath) ? ICSettingEntry.VALUE_WORKSPACE_PATH : 0;
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;
switch (kind) {
switch (comboKind.getSelectionIndex()) {
case COMBO_INDEX_INCLUDE_DIR:
entry = CDataUtil.createCIncludePathEntry(name, flags);
break;
case COMBO_INDEX_MACRO:
// Note that value=null is not supported by CMacroEntry
String value = inputValue.getText().trim();
entry = CDataUtil.createCMacroEntry(name, value, flags);
break;
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
* are made available under the terms of the Eclipse Public License v1.0
* 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.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.StatusMessageLine;
@ -156,11 +155,15 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
public String getText(Object element) {
if (element instanceof ICLanguageSettingEntry) {
ICLanguageSettingEntry entry = (ICLanguageSettingEntry) element;
String s = entry.getName();
if ((entry.getKind() == ICSettingEntry.MACRO) && (entry.getFlags()&ICSettingEntry.UNDEFINED) == 0) {
s = s + '=' + entry.getValue();
String text = entry.getName();
if (entry.getKind() == ICSettingEntry.MACRO) {
if ((entry.getFlags() & ICSettingEntry.UNDEFINED) == 0) {
text = text + '=' + entry.getValue();
}
} else if (LanguageSettingsImages.isProjectRelative(entry)) {
text = LanguageSettingsImages.toProjectRelative(text);
}
return s;
return text;
}
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
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -8,10 +8,8 @@
* Contributors:
* 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.ResourcesPlugin;
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.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
import org.eclipse.cdt.ui.CDTSharedImages;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.utils.UNCPathConverter;
import org.eclipse.cdt.internal.ui.newui.Messages;
/**
* Helper class to provide unified images for {@link ICLanguageSettingEntry}.
*/
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) {
String imageKey = getImageKey(kind, flags, isProjectRelative);
if (imageKey != null) {
@ -52,19 +99,35 @@ public class LanguageSettingsImages {
* @return the image for the entry with appropriate overlays.
*/
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) {
ICProjectDescription prjDescription = cfgDescription.getProjectDescription();
if (prjDescription != null) {
IProject project = prjDescription.getProject();
if (project != null) {
projectName = project.getName();
}
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);
}
}
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;
}
/**
* 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.
* @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
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
*
* Contributors:
* Andrew Gvozdev - Initial API and implementation
* IBM Corporation
*******************************************************************************/
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.CellEditor;
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.ComboBoxCellEditor;
import org.eclipse.jface.viewers.EditingSupport;
import org.eclipse.jface.viewers.FocusCellOwnerDrawHighlighter;
import org.eclipse.jface.viewers.TableLayout;
import org.eclipse.jface.viewers.TableViewer;
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.window.Window;
import org.eclipse.swt.SWT;
@ -327,6 +334,22 @@ public final class RegexErrorParserOptionPage extends AbstractCOptionPage {
fTableViewer.setUseHashlookup(true);
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();
createPatternColumn();
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.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.newui.LanguageSettingsImages;
import org.eclipse.cdt.internal.ui.newui.Messages;
import org.eclipse.cdt.internal.ui.newui.StatusMessageLine;

View file

@ -593,6 +593,7 @@ public class EnvironmentTab extends AbstractCPropertyTab {
}
vars = null;
super.performOK();
updateData();
}
@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;
}
.menu td { vertical-align: top; }
td.menu_name {font-weight: bold;}
/* Mike Behm's addition to the style sheet */
.userinput { font-family: monospace; }
.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="">
<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="">
<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>
<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>

395
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">
<html lang="en">
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
@ -8,189 +7,213 @@
<link rel="stylesheet" type="text/css" href="../help.css">
</head>
<body>
<div role="main"><h1>Edit Menu actions</h1>
<p><img src="../images/cdt_menu_edit.png" alt="Selecting Edit Menu" ></p>
<p>
<table border="1" cellspacing="0" cellpadding="3"> <tbody>
<tr>
<th id="name">Name</th>
<th id="function">Function</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>
<td style="text-align:left" valign="top" headers="name"><strong>Cut</strong></td>
<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 headers="keyboard"> Ctrl+X</td>
</tr>
<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 style="text-align:left" valign="top">
<td headers="name"><strong>Find Next</strong></td>
<td headers="function">Finds the next occurrence of the currently selected text. Editor only.</td>
<td headers="keyboard"> Ctrl+K</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 style="text-align:left" valign="top">
<td headers="name"><strong>Add Task...</strong></td>
<td headers="function">Add a user defined task to the current text selection or selected element.</td>
<td headers="keyboard"> Alt+Enter</td>
</tr>
<tr style="text-align:left" valign="top">
<td headers="name"><strong>Add to working set</strong></td>
<td headers="function">Add current resource to selected Working Set</td>
<td headers="keyboard"> Ctrl+I</td>
</tr>
<tr>
<td headers="name"><strong>Remove from working set</strong></td>
<td headers="function">Remove current resource from Working Set</td>
<td headers="keyboard"> Ctrl+Shift+I</td>
</tr>
<tr>
<td headers="name"><strong>Smart Insert Mode</strong></td>
<td headers="function">Toggles editor's Smart Insert Mode</td>
<td headers="keyboard"> Ctrl+Shift+Insert</td>
</tr>
<tr>
<td headers="name"><strong>Show Tooltip Description</strong></td>
<td headers="function">Displays tooltip description, where applicable.</td>
<td headers="keyboard">F2</td>
</tr>
<tr>
<td headers="name"><strong>Word Completion</strong></td>
<td headers="function">Completes current word in editor.</td>
<td headers="keyboard">Alt+/</td>
</tr>
<tr>
<td headers="name"><strong>Quick fix</strong></td>
<td headers="function">Call quick fix dialog for selected warning/error.</td>
<td headers="keyboard"> Ctrl+1</td>
</tr>
<tr>
<td headers="name"><strong>Content Assist</strong></td>
<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
<strong>Window &gt; Preferences &gt; C/C++ &gt; Editor &gt; Templates</strong> and go to the Editor preference page
<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>
</tr>
<tr>
<td headers="name"><strong>Parameter Hints</strong></td>
<td headers="function">Opens Parameter Hints dialog. Editor only</td>
<td headers="keyboard">Ctrl+Shift+Space</td>
</tr>
<tr style="text-align:left" valign="top">
<td headers="name"><strong>Shift Right</strong></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>
</tr>
</tbody>
</table>
<p></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>
<p>
<IMG alt="IBM Copyright Statement" src="../images/ng00_04a.gif" border=0>
</p>
</div></body>
<div role="main">
<h1>Edit Menu actions</h1>
<p>
<img src="../images/cdt_menu_edit.png" alt="Selecting Edit Menu">
</p>
<table class="menu" border="1" cellspacing="0">
<thead>
<tr>
<th id="name">Name</th>
<th id="function">Function</th>
<th id="keyboard">Keyboard Shortcut</th>
</tr>
</thead>
<tbody>
<tr>
<td class="menu_name" headers="name">Undo</td>
<td headers="function">Reverts the last change made in the
editor</td>
<td headers="keyboard">Ctrl+Z</td>
</tr>
<tr>
<td class="menu_name" headers="name">Redo</td>
<td headers="function">Re-applies a change previously reverted
with Undo</td>
<td headers="keyboard">Ctrl+Y</td>
</tr>
<tr>
<td class="menu_name" headers="name">Cut</td>
<td headers="function">Copies the currently selected text to
the clipboard and removes it from the editor</td>
<td headers="keyboard">Ctrl+X</td>
</tr>
<tr>
<td class="menu_name" headers="name">Copy</td>
<td headers="function">Copies the currently selected text to
the clipboard</td>
<td headers="keyboard">Ctrl+C</td>
</tr>
<tr>
<td class="menu_name" headers="name">Paste</td>
<td headers="function">Pastes the contents of the clipboard,
as text, to the currently active editor window</td>
<td headers="keyboard">Ctrl+V</td>
</tr>
<tr>
<td class="menu_name" headers="name">Delete</td>
<td headers="function">Deletes the currently selected text</td>
<td headers="keyboard">Delete</td>
</tr>
<tr>
<td class="menu_name" headers="name">Select All</td>
<td headers="function">Selects all the text in the currently
active editor window</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>
</tr>
<tr>
<td class="menu_name" headers="name">Word Completion</td>
<td headers="function">Completes the word containing the
cursor using the next available completion (If invoked repeatedly
it will cycle through the possibilities.)</td>
<td headers="keyboard">Alt+/</td>
</tr>
<tr>
<td class="menu_name" headers="name">Quick Fix</td>
<td headers="function">Displays the Quick Fix dialog
appropriate to the cursor position.</td>
<td headers="keyboard">Ctrl+1</td>
</tr>
<tr>
<td class="menu_name" headers="name">Content Assist</td>
<td headers="function">Displays the Content Assist dialog
appropriate to the cursor position (If invoked repeatedly it will
cycle through the available proposal types.)</td>
<td headers="keyboard">Ctrl+Space</td>
</tr>
<tr>
<td class="menu_name" headers="name">Parameter Hints</td>
<td headers="function">Displays the possible signatures in a
tooltip (Enabled when the cursor is in a parameter list)</td>
<td headers="keyboard">Ctrl+Shift+Space</td>
</tr>
<tr>
<td class="menu_name" headers="name">Set Encoding...</td>
<td headers="function">Displays a dialog in which the encoding
of the active editor can be specified</td>
<td headers="keyboard">&nbsp;</td>
</tr>
</tbody>
</table>
<p>
<img alt="IBM Copyright Statement" src="../images/ng00_04a.gif">
</p>
</div>
</body>
</html>

269
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">
<html lang="en">
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>File Menu actions</title>
<link rel="stylesheet" type="text/css" href="../help.css">
</head>
<body>
<div role="main"><h1>File Menu actions</h1>
<p><img src="../images/cdt_menu_file.png" alt="Selecting File Menu" ></p>
<p>
<table border="1" cellspacing="0" cellpadding="3">
<tbody>
<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>
<td valign="top" headers="name"><strong>Close</strong></td>
<td valign="top" headers="function">Close the current editor.
If the editor contains unsaved data, a save request dialog is shown.</td>
<td valign="top" headers="keyboard">Ctrl+F4</td>
</tr>
<tr>
<td valign="top" headers="name"><strong>Close All</strong></td>
<td valign="top" headers="function">Close all editors.
If editors contains unsaved data, a save request dialog will be shown.</td>
<td valign="top" headers="keyboard">Ctrl+Shift+F4</td>
</tr>
<tr>
<td valign="top" headers="name"><strong>Save</strong></td>
<td valign="top" headers="function">Save the content of the current editor.
Disabled if the editor does not contain unsaved changes.</td>
<td valign="top" headers="keyboard">Ctrl+S</td>
</tr>
<tr>
<td valign="top" headers="name"><strong>Save As</strong></td>
<td valign="top" headers="function">Save the content of the current editor under a new name.</td>
<td valign="top" headers="keyboard">&nbsp;</td>
</tr>
<tr>
<td valign="top" headers="name"><strong>Save All</strong></td>
<td valign="top" headers="function">Save the content of the current editor.
Disabled if no editor contains unsaved changes.</td>
<td valign="top" headers="keyboard">Ctrl+Shift+S</td>
</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>
<td valign="top" headers="name"><strong>Refresh</strong></td>
<td valign="top" headers="function">Refreshes the content of the selected element with the local file system.
When launched from no specific selection, this command refreshes all projects.</td>
<td valign="top" headers="keyboard">F5</td>
</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>
<td valign="top" headers="name"><strong>Print</strong></td>
<td valign="top" headers="function">Prints the content of the current editor. Enabled when an editor has the focus.</td>
<td valign="top" headers="keyboard">Ctrl+P</td>
</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>
<td valign="top" headers="name"><strong>Import</strong></td>
<td valign="top" headers="function">Opens the <strong>Import</strong> dialog and shows all import wizards.</td>
<td valign="top" headers="keyboard">&nbsp;</td>
</tr>
<tr valign="top">
<td valign="top" headers="name"><strong>Export</strong></td>
<td valign="top" headers="function">Opens the <strong>Export</strong> dialog and shows all export wizards.</td>
<td valign="top" headers="keyboard">&nbsp;</td>
</tr>
<tr valign="top">
<td valign="top" headers="name"><strong>Properties</strong></td>
<td valign="top" headers="function">Opens the property pages of the select elements.</td>
<td valign="top" headers="keyboard">Alt+Enter</td>
</tr>
<tr valign="top">
<td valign="top" headers="name"><strong>Exit</strong></td>
<td valign="top" headers="function">Exit Eclipse</td>
<td valign="top" headers="keyboard">&nbsp;</td>
</tr>
</tbody></table>
<p></p>
<p>
<img src="../images/ng00_04a.gif" ALT="IBM Copyright Statement" >
</p>
</div></body>
<div role="main">
<h1>File Menu actions</h1>
<p>
<img src="../images/cdt_menu_file.png" alt="Selecting File Menu">
</p>
<table class="menu" border="1" cellspacing="0">
<thead>
<tr>
<th id="name">Name</th>
<th id="function">Function</th>
<th id="keyboard">Keyboard Shortcut</th>
</tr>
</thead>
<tbody>
<tr>
<td class="menu_name" headers="name">New (submenu)</td>
<td headers="function">Creates a new project, folder, or file</td>
<td headers="keyboard">Alt+Shift+N</td>
</tr>
<tr>
<td class="menu_name" headers="name">Open File...</td>
<td headers="function">Opens an existing file</td>
<td headers="keyboard">&nbsp;</td>
</tr>
<tr>
<td class="menu_name" headers="name">Close</td>
<td headers="function">Closes the current editor (If the
editor contains unsaved data, a save request dialog is shown.)</td>
<td headers="keyboard">Ctrl+W</td>
</tr>
<tr>
<td class="menu_name" headers="name">Close All</td>
<td headers="function">Closes all editors (If any editors
contain unsaved data, save request dialogs will be shown for
them.)</td>
<td headers="keyboard">Ctrl+Shift+W</td>
</tr>
<tr>
<td class="menu_name" headers="name">Save</td>
<td headers="function">Saves the content of the current editor
(Disabled if the editor does not contain unsaved changes.)</td>
<td headers="keyboard">Ctrl+S</td>
</tr>
<tr>
<td class="menu_name" headers="name">Save As...</td>
<td headers="function">Saves the content of the current editor
under a new name</td>
<td headers="keyboard">&nbsp;</td>
</tr>
<tr>
<td class="menu_name" headers="name">Save All</td>
<td headers="function">Saves the content of all open editor
windows (Disabled if no editor contains unsaved changes.)</td>
<td headers="keyboard">Ctrl+Shift+S</td>
</tr>
<tr>
<td class="menu_name" headers="name">Revert</td>
<td headers="function">Reverts the content of the current
editor back to its most recently saved state (Disabled if the
editor does not contain unsaved changes.)</td>
<td headers="keyboard">&nbsp;</td>
</tr>
<tr>
<td class="menu_name" headers="name">Move...</td>
<td headers="function">Moves a resource</td>
<td headers="keyboard">&nbsp;</td>
</tr>
<tr>
<td class="menu_name" headers="name">Rename...</td>
<td headers="function">Renames a resource</td>
<td headers="keyboard">F2</td>
</tr>
<tr>
<td class="menu_name" headers="name">Refresh</td>
<td headers="function">Refreshes the selected element against
the local file system (If nothing is selected, all open projects
are refreshed.)</td>
<td headers="keyboard">F5</td>
</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>

View file

@ -13,21 +13,21 @@
<p><img src="../images/cdt_menu_navigate.png" alt="Selecting Navigate Menu" ></p>
<p>
<table border="1" cellspacing="0" cellpadding="3">
<table class="menu" border="1" cellspacing="0" cellpadding="3">
<tbody>
<tr><th id="name">Name</th><th id="function">Function</th><th id="keyboard">Keyboard Shortcut</th></tr>
<tr>
<td valign="top" headers="name"><strong>Go Into</strong></td>
<td valign="top" headers="function">Sets the view input to the currently selected element.</td>
<td valign="top" headers="keyboard">&nbsp;</td>
<td class="menu_name" headers="name">Go Into</td>
<td headers="function">Sets the view input to the currently selected element.</td>
<td headers="keyboard">&nbsp;</td>
</tr>
<tr>
<td valign="top" headers="name"><strong>Go To</strong></td>
<td valign="top" headers="function"><ul>
<td class="menu_name" headers="name">Go To</td>
<td headers="function"><ul>
<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;
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>
</ul>
</td>
<td valign="top" headers="keyboard">&nbsp;</td>
<td headers="keyboard">&nbsp;</td>
</tr>
<tr>
<td valign="top" headers="name"><strong>Open Type Hierarchy</strong></td>
<td valign="top" headers="function">Opens Type Hierarchy view for selected object</td>
<td valign="top" headers="keyboard">F4</td>
<td class="menu_name" headers="name">Open Type Hierarchy</td>
<td headers="function">Opens Type Hierarchy view for selected object</td>
<td headers="keyboard">F4</td>
</tr>
<tr>
<td valign="top" headers="name"><strong>Open Call Hierarchy</strong></td>
<td valign="top" headers="function">Opens Call Hierarchy view for selected object</td>
<td valign="top" headers="keyboard">Ctrl+Alt+H</td>
<td class="menu_name" headers="name">Open Call Hierarchy</td>
<td headers="function">Opens Call Hierarchy view for selected object</td>
<td headers="keyboard">Ctrl+Alt+H</td>
</tr>
<tr>
<td valign="top" headers="name"><strong>Open Declaration</strong></td>
<td valign="top" headers="function">Opens Declaration for selected object (class, variable...)</td>
<td valign="top" headers="keyboard">F3</td>
<td class="menu_name" headers="name">Open Declaration</td>
<td headers="function">Opens Declaration for selected object (class, variable...)</td>
<td headers="keyboard">F3</td>
</tr>
<tr>
<td valign="top" headers="name"><strong>Toggle Source/Header</strong></td>
<td valign="top" headers="function">Switches between source and corresponding header files.</td>
<td valign="top" headers="keyboard">&nbsp;</td>
<td class="menu_name" headers="name">Toggle Source/Header</td>
<td headers="function">Switches between source and corresponding header files.</td>
<td headers="keyboard">&nbsp;</td>
</tr>
<tr>
<td valign="top" headers="name"><strong>Open Element...</strong></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 valign="top" headers="keyboard">Ctrl+Shift+T</td>
<td class="menu_name" headers="name">Open Element...</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 headers="keyboard">Ctrl+Shift+T</td>
</tr>
<tr>
<td valign="top" headers="name"><strong>Open Resource</strong></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 class="menu_name" headers="name">Open Resource</td>
<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 valign="top" headers="keyboard">Ctrl+Shift+R</td>
<td headers="keyboard">Ctrl+Shift+R</td>
</tr>
<tr>
<td valign="top" headers="name"><strong>Show In</strong></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 valign="top" headers="keyboard">Ctrl+Shift+W</td>
<td class="menu_name" headers="name">Show In</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 headers="keyboard">Ctrl+Shift+W</td>
</tr>
<tr>
<td valign="top" headers="name"><strong>Quick Outline</strong></td>
<td valign="top" headers="function">Displays outline view for current source file.</td>
<td valign="top" headers="keyboard">&nbsp;</td>
<td class="menu_name" headers="name">Quick Outline</td>
<td headers="function">Displays outline view for current source file.</td>
<td headers="keyboard">&nbsp;</td>
</tr>
<tr>
<td valign="top" headers="name"><strong>Next</strong></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 valign="top" headers="keyboard">Ctrl+.</td>
<td class="menu_name" headers="name">Next</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 headers="keyboard">Ctrl+.</td>
</tr>
<tr>
<td valign="top" headers="name"><strong>Previous</strong></td>
<td valign="top" headers="function">The &quot;previous&quot; definition is based on
<td class="menu_name" headers="name">Previous</td>
<td headers="function">The &quot;previous&quot; definition is based on
where the focus is.
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>
<td valign="top" headers="name"><strong>Last Edit Location</strong></td>
<td valign="top" headers="function">Moves the cursor to the line that contains the last edit.
<td class="menu_name" headers="name">Last Edit Location</td>
<td headers="function">Moves the cursor to the line that contains the last edit.
Editor only.</td>
<td valign="top" headers="keyboard">Ctrl+Q</td>
<td headers="keyboard">Ctrl+Q</td>
</tr>
<tr>
<td valign="top" headers="name"><strong>Go to Line</strong></td>
<td valign="top" headers="function">Open a dialog where you can specify the line number
<td class="menu_name" headers="name">Go to Line</td>
<td headers="function">Open a dialog where you can specify the line number
to which to move the cursor.
Editor only.</td>
<td valign="top" headers="keyboard">Ctrl+L</td>
<td headers="keyboard">Ctrl+L</td>
</tr>
<tr>
<td valign="top" headers="name"><strong>Back</strong></td>
<td valign="top" headers="function">Moves the focus to the previous file.
<td class="menu_name" headers="name">Back</td>
<td headers="function">Moves the focus to the previous file.
Editor only.</td>
<td valign="top" headers="keyboard">Ctrl+Q</td>
<td headers="keyboard">Ctrl+Q</td>
</tr>
<tr>
<td valign="top" headers="name"><strong>Forward</strong></td>
<td valign="top" headers="function">Returns the focus from the previous file.
<td class="menu_name" headers="name">Forward</td>
<td headers="function">Returns the focus from the previous file.
Editor only.</td>
<td valign="top" headers="keyboard">Ctrl+Q</td>
<td headers="keyboard">Ctrl+Q</td>
</tr>
</tbody>

View file

@ -14,31 +14,31 @@
<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>
<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="keyboard">&nbsp;</td>
</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="keyboard">&nbsp;</td>
</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="keyboard">Ctrl+B</td>
</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="keyboard">&nbsp;</td>
</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:
<ul>
<li>Delete resource configuration for file/folder
@ -49,32 +49,32 @@
<td headers="keyboard">&nbsp;</td>
</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="keyboard">&nbsp;</td>
</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="keyboard">&nbsp;</td>
</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="keyboard">&nbsp;</td>
</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="keyboard">&nbsp;</td>
</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="keyboard">&nbsp;</td>
</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>,
<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),

View file

@ -17,55 +17,55 @@
alt="Selecting Refactor Menu">
</p>
<table border="1" cellspacing="0">
<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>
<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="keyboard">&nbsp;</td>
</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="keyboard">&nbsp;</td>
</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="keyboard">&nbsp;</td>
</tr>
<tr>
<td headers="name"><strong>Rename...</strong></td>
<td class="menu_name" headers="name">Rename...</td>
<td headers="function">Renames selected object (variable,
method, etc...) and propagates changes to other files in project.</td>
<td headers="keyboard">Alt+Shift+R</td>
</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="keyboard">Alt+Shift+L</td>
</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="keyboard">Alt+C</td>
</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="keyboard">Alt+Shift+M</td>
</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="keyboard">Alt+Shift+T</td>
</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="keyboard">&nbsp;</td>
</tr>

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