| /********************************************************************** |
| * Copyright (c) 2002,2003 Rational Software Corporation and others. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Common Public License v0.5 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/cpl-v05.html |
| * |
| * Contributors: |
| * IBM Rational Software - Initial API and implementation |
| ***********************************************************************/ |
| package org.eclipse.cdt.internal.core.parser.ast.complete; |
| |
| import java.util.ArrayList; |
| import java.util.Iterator; |
| import java.util.List; |
| |
| import org.eclipse.cdt.core.parser.ISourceElementRequestor; |
| import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException; |
| import org.eclipse.cdt.core.parser.ast.IASTDeclaration; |
| import org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification; |
| import org.eclipse.cdt.core.parser.ast.IReferenceManager; |
| import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol; |
| |
| /** |
| * @author jcamelon |
| * |
| */ |
| public class ASTLinkageSpecification extends ASTAnonymousDeclaration implements IASTLinkageSpecification |
| { |
| private List declarations = new ArrayList(); |
| private final String linkageString; |
| |
| /** |
| * |
| */ |
| public ASTLinkageSpecification( IContainerSymbol scope, String linkageString, int startingOffset, int startingLine ) |
| { |
| super( scope ); |
| this.linkageString = linkageString; |
| setStartingOffsetAndLineNumber(startingOffset, startingLine); |
| } |
| /* (non-Javadoc) |
| * @see org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification#getLinkageString() |
| */ |
| public String getLinkageString() |
| { |
| return linkageString; |
| } |
| /* (non-Javadoc) |
| * @see org.eclipse.cdt.core.parser.ast.IASTScope#getDeclarations() |
| */ |
| public Iterator getDeclarations() throws ASTNotImplementedException |
| { |
| return declarations.iterator(); |
| } |
| /* (non-Javadoc) |
| * @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#acceptElement(org.eclipse.cdt.core.parser.ISourceElementRequestor) |
| */ |
| public void acceptElement(ISourceElementRequestor requestor, IReferenceManager manager) |
| { |
| } |
| /* (non-Javadoc) |
| * @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#enterScope(org.eclipse.cdt.core.parser.ISourceElementRequestor) |
| */ |
| public void enterScope(ISourceElementRequestor requestor, IReferenceManager manager) |
| { |
| try |
| { |
| requestor.enterLinkageSpecification(this); |
| } |
| catch (Exception e) |
| { |
| /* do nothing */ |
| } |
| } |
| /* (non-Javadoc) |
| * @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#exitScope(org.eclipse.cdt.core.parser.ISourceElementRequestor) |
| */ |
| public void exitScope(ISourceElementRequestor requestor, IReferenceManager manager) |
| { |
| try |
| { |
| requestor.exitLinkageSpecification(this); |
| } |
| catch (Exception e) |
| { |
| /* do nothing */ |
| } |
| } |
| |
| public void addDeclaration(IASTDeclaration declaration) |
| { |
| declarations.add(declaration); |
| } |
| |
| private int startingLineNumber, startingOffset, endingLineNumber, endingOffset; |
| /* (non-Javadoc) |
| * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getStartingLine() |
| */ |
| public final int getStartingLine() { |
| return startingLineNumber; |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getEndingLine() |
| */ |
| public final int getEndingLine() { |
| return endingLineNumber; |
| } |
| /* (non-Javadoc) |
| * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#setStartingOffset(int) |
| */ |
| public final void setStartingOffsetAndLineNumber(int offset, int lineNumber) |
| { |
| startingOffset = offset; |
| startingLineNumber = lineNumber; |
| } |
| /* (non-Javadoc) |
| * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#setEndingOffset(int) |
| */ |
| public final void setEndingOffsetAndLineNumber(int offset, int lineNumber) |
| { |
| endingOffset = offset; |
| endingLineNumber = lineNumber; |
| } |
| /* (non-Javadoc) |
| * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getStartingOffset() |
| */ |
| public final int getStartingOffset() |
| { |
| return startingOffset; |
| } |
| /* (non-Javadoc) |
| * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getEndingOffset() |
| */ |
| public final int getEndingOffset() |
| { |
| return endingOffset; |
| } |
| |
| } |
| |