KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > corext > dom > fragments > IASTFragment


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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 Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.corext.dom.fragments;
12
13 import org.eclipse.jdt.core.dom.ASTNode;
14
15 /**
16  * An IASTFragment represents 'part' of an AST, but
17  * not necessarily a subtree of the AST. A fragment
18  * may simply be an instance of some sort of pattern
19  * or formation in an AST.
20  * Such "fragments", however, do correspond to a
21  * contiguous source code region, and, thus, posses a
22  * source start position, and a source length. Every
23  * fragment maps to an ASTNode, although this mapping is
24  * not necessarily straightforward, and more than one
25  * fragment may map to a given node.
26  *
27  * Fragments support abstract operations, which
28  * support the notion of 'matching' fragments.
29  * One operation determines whether a fragment 'matches'
30  * a given fragment. Another operation finds all
31  * sub-fragments (fragments contained within a
32  * parent fragment, including the parent itself)
33  * which 'match' another given fragment.
34  *
35  */

36 public interface IASTFragment {
37         
38     /**
39      * Determines whether <code> other </code>
40      * 'matches' <code> this </code>.
41      * This binary operation should be reflexive,
42      * symmetric, and transitive.
43      *
44      * That two node match does not imply that their source ranges
45      * are the same, or that they map (via getAssociatedNode()) to the
46      * same node.
47      */

48     public boolean matches(IASTFragment other);
49     
50     /**
51      * Returns (at least some approximation of) a maximal set of
52      * sub-fragments of this fragment which match <code> toMatch </code>
53      */

54     public IASTFragment[] getSubFragmentsMatching(IASTFragment toMatch);
55
56     /**
57      * Every fragment maps to a node.
58      * Multiple fragments can map to the same node.
59      *
60      * @return ASTNode The node to which this fragment maps.
61      */

62     public ASTNode getAssociatedNode();
63     
64     /**
65      * Every fragment has a source start position.
66      *
67      * @return int The source start position.
68      */

69     public int getStartPosition();
70     
71     /**
72      * Every fragment has a source length.
73      *
74      * @return int The source length.
75      */

76     public int getLength();
77 }
78
Popular Tags