001: /*******************************************************************************
002: * Copyright (c) 2000, 2006 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.jdt.internal.compiler;
011:
012: import org.eclipse.jdt.core.compiler.CategorizedProblem;
013:
014: /*
015: * Part of the source element parser responsible for building the output. It
016: * gets notified of structural information as they are detected, relying on the
017: * requestor to assemble them together, based on the notifications it got.
018: *
019: * The structural investigation includes: - package statement - import
020: * statements - top-level types: package member, member types (member types of
021: * member types...) - fields - methods
022: *
023: * If reference information is requested, then all source constructs are
024: * investigated and type, field & method references are provided as well.
025: *
026: * Any (parsing) problem encountered is also provided.
027: *
028: * All positions are relative to the exact source fed to the parser.
029: *
030: * Elements which are complex are notified in two steps: - enter <Element> :
031: * once the element header has been identified - exit <Element> : once the
032: * element has been fully consumed
033: *
034: * other simpler elements (package, import) are read all at once: - accept
035: * <Element>
036: */
037:
038: public interface ISourceElementRequestor {
039:
040: public static class TypeInfo {
041: public int declarationStart;
042: public int modifiers;
043: public char[] name;
044: public int nameSourceStart;
045: public int nameSourceEnd;
046: public char[] super class;
047: public char[][] super interfaces;
048: public TypeParameterInfo[] typeParameters;
049: public long[] annotationPositions;
050: public char[][] categories;
051: public boolean secondary;
052: public boolean anonymousMember;
053: }
054:
055: public static class TypeParameterInfo {
056: public int declarationStart;
057: public int declarationEnd;
058: public char[] name;
059: public int nameSourceStart;
060: public int nameSourceEnd;
061: public char[][] bounds;
062: public long[] annotationPositions;
063: }
064:
065: public static class MethodInfo {
066: public boolean isConstructor;
067: public boolean isAnnotation;
068: public int declarationStart;
069: public int modifiers;
070: public char[] returnType;
071: public char[] name;
072: public int nameSourceStart;
073: public int nameSourceEnd;
074: public char[][] parameterTypes;
075: public char[][] parameterNames;
076: public char[][] exceptionTypes;
077: public TypeParameterInfo[] typeParameters;
078: public long[] annotationPositions;
079: public char[][] categories;
080: }
081:
082: public static class FieldInfo {
083: public int declarationStart;
084: public int modifiers;
085: public char[] type;
086: public char[] name;
087: public int nameSourceStart;
088: public int nameSourceEnd;
089: public long[] annotationPositions;
090: public char[][] categories;
091: }
092:
093: void acceptConstructorReference(char[] typeName, int argCount,
094: int sourcePosition);
095:
096: void acceptFieldReference(char[] fieldName, int sourcePosition);
097:
098: /**
099: * @param declarationStart
100: * This is the position of the first character of the import
101: * keyword.
102: * @param declarationEnd
103: * This is the position of the ';' ending the import statement or
104: * the end of the comment following the import.
105: * @param tokens
106: * This are the tokens of the import like specified in the source.
107: * @param onDemand
108: * set to true if the import is an import on demand (e.g. import
109: * java.io.*). False otherwise.
110: * @param modifiers
111: * can be set to static from 1.5 on.
112: */
113: void acceptImport(int declarationStart, int declarationEnd,
114: char[][] tokens, boolean onDemand, int modifiers);
115:
116: /*
117: * Table of line separator position. This table is passed once at the end of
118: * the parse action, so as to allow computation of normalized ranges.
119: *
120: * A line separator might corresponds to several characters in the source,
121: *
122: */
123: void acceptLineSeparatorPositions(int[] positions);
124:
125: void acceptMethodReference(char[] methodName, int argCount,
126: int sourcePosition);
127:
128: void acceptPackage(int declarationStart, int declarationEnd,
129: char[] name);
130:
131: void acceptProblem(CategorizedProblem problem);
132:
133: void acceptTypeReference(char[][] typeName, int sourceStart,
134: int sourceEnd);
135:
136: void acceptTypeReference(char[] typeName, int sourcePosition);
137:
138: void acceptUnknownReference(char[][] name, int sourceStart,
139: int sourceEnd);
140:
141: void acceptUnknownReference(char[] name, int sourcePosition);
142:
143: void enterCompilationUnit();
144:
145: void enterConstructor(MethodInfo methodInfo);
146:
147: void enterField(FieldInfo fieldInfo);
148:
149: void enterInitializer(int declarationStart, int modifiers);
150:
151: void enterMethod(MethodInfo methodInfo);
152:
153: void enterType(TypeInfo typeInfo);
154:
155: void exitCompilationUnit(int declarationEnd);
156:
157: void exitConstructor(int declarationEnd);
158:
159: /*
160: * initializationStart denotes the source start of the expression used for
161: * initializing the field if any (-1 if no initialization).
162: */
163: void exitField(int initializationStart, int declarationEnd,
164: int declarationSourceEnd);
165:
166: void exitInitializer(int declarationEnd);
167:
168: void exitMethod(int declarationEnd, int defaultValueStart,
169: int defaultValueEnd);
170:
171: void exitType(int declarationEnd);
172: }
|