Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 8318d81e3beeb79846e82081acfe20f6b6ef32b0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/*******************************************************************************
 * Copyright (c) 2009,2012 QNX Software Systems
 * 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:
 *    QNX Software Systems (Alena Laskavaia)  - initial API and implementation
 *******************************************************************************/
package org.eclipse.cdt.codan.core.cxx.internal.model;

import java.util.List;

import org.eclipse.cdt.codan.core.cxx.model.ICodanCommentMap;
import org.eclipse.cdt.core.dom.ast.IASTComment;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;

/**
 * Implementation of ICodanCommentMap.
 */
public class CodanCommentMap implements ICodanCommentMap {
	private NodeCommentMap commentedNodeMap;

	/**
	 * @param commentedNodeMap
	 */
	public CodanCommentMap(NodeCommentMap commentedNodeMap) {
		this.commentedNodeMap = commentedNodeMap;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.cdt.codan.core.cxx.model.ICodanCommentMap#
	 * getTrailingCommentsForNode(org.eclipse.cdt.core.dom.ast.IASTNode)
	 */
	@Override
	public List<IASTComment> getTrailingCommentsForNode(IASTNode node) {
		return commentedNodeMap.getTrailingCommentsForNode(node);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.cdt.codan.core.cxx.model.ICodanCommentMap#
	 * getLeadingCommentsForNode(org.eclipse.cdt.core.dom.ast.IASTNode)
	 */
	@Override
	public List<IASTComment> getLeadingCommentsForNode(IASTNode node) {
		return commentedNodeMap.getLeadingCommentsForNode(node);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.eclipse.cdt.codan.core.cxx.model.ICodanCommentMap#getFreestandingForNode
	 * (org.eclipse.cdt.core.dom.ast.IASTStatement)
	 */
	@Override
	public List<IASTComment> getFreestandingForNode(IASTNode node) {
		return commentedNodeMap.getFreestandingCommentsForNode(node);
	}

	/**
	 * @param node
	 * @return
	 */
	@Override
	public IASTComment getLastLeadingCommentForNode(IASTNode node) {
		IASTComment comment = null;
		List<IASTComment> comms = getLeadingCommentsForNode(node);
		if (comms.size() > 0) {
			comment = comms.get(comms.size() - 1);
		}
		return comment;
	}

	/**
	 * @param node
	 * @return
	 */
	@Override
	public IASTComment getFirstTrailingCommentForNode(IASTNode node) {
		IASTComment comment = null;
		List<IASTComment> comms = getTrailingCommentsForNode(node);
		if (comms.size() > 0) {
			comment = comms.get(0);
		}
		return comment;
	}

	/**
	 * @param node
	 * @return
	 */
	@Override
	public IASTComment getLastFreestandingCommentForNode(IASTNode node) {
		IASTComment comment = null;
		List<IASTComment> comms = getFreestandingForNode(node);
		if (comms.size() > 0) {
			comment = comms.get(comms.size() - 1);
		}
		return comment;
	}
}

Back to the top