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

« back to all changes in this revision

Viewing changes to core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/util/ASTNodes.java

  • Committer: Package Import Robot
  • Author(s): Jakub Adam
  • Date: 2013-10-03 20:30:16 UTC
  • mfrom: (1.1.11)
  • Revision ID: package-import@ubuntu.com-20131003203016-d4ug6l0xgosasumq
Tags: 8.2.1-1
* New upstream release.
* Updated autotools documentation sources.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*******************************************************************************
 
2
 * Copyright (c) 2012 Google, Inc 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
 *         Sergey Prigogin (Google) - initial API and implementation
 
10
 *******************************************************************************/
 
11
package org.eclipse.cdt.internal.core.dom.rewrite.util;
 
12
 
 
13
import static org.eclipse.cdt.internal.core.dom.parser.ASTTranslationUnit.getNodeEndOffset;
 
14
 
 
15
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
 
16
import org.eclipse.cdt.core.dom.ast.IASTNode;
 
17
 
 
18
/**
 
19
 * Collection of helper methods for common operations on AST nodes.
 
20
 */
 
21
public class ASTNodes {
 
22
        /** Not instantiatable. */
 
23
        private ASTNodes() {
 
24
        }
 
25
 
 
26
        /**
 
27
         * Returns the offset of an AST node.
 
28
         */
 
29
        public static int offset(IASTNode node) {
 
30
                return node.getFileLocation().getNodeOffset();
 
31
        }
 
32
 
 
33
        /**
 
34
         * Returns the exclusive end offset of an AST node.
 
35
         */
 
36
        public static int endOffset(IASTNode node) {
 
37
                IASTFileLocation location = node.getFileLocation();
 
38
                return location.getNodeOffset() + location.getNodeLength();
 
39
        }
 
40
 
 
41
        /**
 
42
         * Returns the offset of the beginning of the next line after the node, or the end-of-file
 
43
         * offset if there is no line delimiter after the node.
 
44
         */
 
45
        public static int skipToNextLineAfterNode(String text, IASTNode node) {
 
46
                return TextUtil.skipToNextLine(text, getNodeEndOffset(node));
 
47
        }
 
48
}