~ubuntu-branches/debian/sid/eclipse-cdt/sid

« back to all changes in this revision

Viewing changes to results/plugins/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTFieldDeclarator.java

  • Committer: Package Import Robot
  • Author(s): Jakub Adam
  • Date: 2011-10-06 21:15:04 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20111006211504-8dutmljjih0zikfv
Tags: 8.0.1-1
* New upstream release.
* Split the JNI packages into a separate architecture dependent
  package and made eclipse-cdt architecture independent.
* Install JNI libraries into multiarch aware location
* Bumped Standards-Version to 3.9.2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*******************************************************************************
2
 
 * Copyright (c) 2005, 2008 IBM Corporation and others.
3
 
 * All rights reserved. This program and the accompanying materials
4
 
 * are made available under the terms of the Eclipse Public License v1.0
5
 
 * which accompanies this distribution, and is available at
6
 
 * http://www.eclipse.org/legal/epl-v10.html
7
 
 *
8
 
 * Contributors:
9
 
 *    IBM Rational Software - Initial API and implementation
10
 
 *    Markus Schorn (Wind River Systems)
11
 
 *******************************************************************************/
12
 
package org.eclipse.cdt.internal.core.dom.parser.c;
13
 
 
14
 
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
15
 
import org.eclipse.cdt.core.dom.ast.IASTExpression;
16
 
import org.eclipse.cdt.core.dom.ast.IASTFieldDeclarator;
17
 
import org.eclipse.cdt.core.dom.ast.IASTName;
18
 
import org.eclipse.cdt.core.dom.ast.IASTNode;
19
 
 
20
 
/**
21
 
 * @author jcamelon
22
 
 */
23
 
public class CASTFieldDeclarator extends CASTDeclarator implements IASTFieldDeclarator {
24
 
    private IASTExpression bitFieldSize;
25
 
 
26
 
    public CASTFieldDeclarator() {
27
 
        }
28
 
 
29
 
        public CASTFieldDeclarator(IASTName name, IASTExpression bitFieldSize) {
30
 
                super(name);
31
 
                setBitFieldSize(bitFieldSize);
32
 
        }
33
 
 
34
 
        @Override
35
 
        public CASTFieldDeclarator copy() {
36
 
                CASTFieldDeclarator copy = new CASTFieldDeclarator();
37
 
                copyBaseDeclarator(copy);
38
 
                copy.setBitFieldSize(bitFieldSize == null ? null : bitFieldSize.copy());
39
 
                return copy;
40
 
        }
41
 
        
42
 
        public IASTExpression getBitFieldSize() {
43
 
        return bitFieldSize;
44
 
    }
45
 
 
46
 
 
47
 
    public void setBitFieldSize(IASTExpression size) {
48
 
        assertNotFrozen();
49
 
        bitFieldSize = size;
50
 
        if (size != null) {
51
 
                        size.setParent(this);
52
 
                        size.setPropertyInParent(FIELD_SIZE);
53
 
                }
54
 
    }
55
 
 
56
 
    @Override
57
 
        protected boolean postAccept(ASTVisitor action) {
58
 
                if (bitFieldSize != null && !bitFieldSize.accept(action))
59
 
                        return false;
60
 
                
61
 
                return super.postAccept(action);
62
 
        }
63
 
 
64
 
    @Override
65
 
        public void replace(IASTNode child, IASTNode other) {
66
 
        if( child == bitFieldSize) {
67
 
            other.setPropertyInParent( child.getPropertyInParent() );
68
 
            other.setParent( child.getParent() );
69
 
            bitFieldSize = (IASTExpression) other;
70
 
        } else {
71
 
                super.replace(child, other);
72
 
        }
73
 
    }
74
 
    
75
 
    
76
 
}