Source Code Cross Referenced for CompletionProposal.java in  » IDE-Eclipse » jdt » org » eclipse » jdt » core » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Eclipse » jdt » org.eclipse.jdt.core 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*******************************************************************************
0002:         * Copyright (c) 2004, 2007 IBM Corporation and others.
0003:         * All rights reserved. This program and the accompanying materials
0004:         * are made available under the terms of the Eclipse Public License v1.0
0005:         * which accompanies this distribution, and is available at
0006:         * http://www.eclipse.org/legal/epl-v10.html
0007:         *
0008:         * Contributors:
0009:         *     IBM Corporation - initial API and implementation
0010:         *******************************************************************************/package org.eclipse.jdt.core;
0011:
0012:        import org.eclipse.core.runtime.IProgressMonitor;
0013:        import org.eclipse.jdt.core.compiler.CharOperation;
0014:        import org.eclipse.jdt.internal.codeassist.InternalCompletionProposal;
0015:
0016:        /**
0017:         * Completion proposal.
0018:         * <p>
0019:         * In typical usage, the user working in a Java code editor issues
0020:         * a code assist command. This command results in a call to
0021:         * <code>ICodeAssist.codeComplete(position, completionRequestor)</code>
0022:         * passing the current position in the source code. The code assist
0023:         * engine analyzes the code in the buffer, determines what kind of
0024:         * Java language construct is at that position, and proposes ways
0025:         * to complete that construct. These proposals are instances of
0026:         * the class <code>CompletionProposal</code>. These proposals,
0027:         * perhaps after sorting and filtering, are presented to the user
0028:         * to make a choice.
0029:         * </p>
0030:         * <p>
0031:         * The proposal is as follows: insert
0032:         * the {@linkplain #getCompletion() completion string} into the
0033:         * source file buffer, replacing the characters between 
0034:         * {@linkplain #getReplaceStart() the start}
0035:         * and {@linkplain #getReplaceEnd() end}. The string
0036:         * can be arbitrary; for example, it might include not only the 
0037:         * name of a method but a set of parentheses. Moreover, the source
0038:         * range may include source positions before or after the source
0039:         * position where <code>ICodeAssist.codeComplete</code> was invoked.
0040:         * The rest of the information associated with the proposal is
0041:         * to provide context that may help a user to choose from among
0042:         * competing proposals.
0043:         * </p>
0044:         * <p>
0045:         * The completion engine creates instances of this class; it is not intended 
0046:         * to be instantiated or subclassed by clients.
0047:         * </p>
0048:         * 
0049:         * @see ICodeAssist#codeComplete(int, CompletionRequestor)
0050:         * @since 3.0
0051:         */
0052:        public final class CompletionProposal extends
0053:                InternalCompletionProposal {
0054:            private boolean updateCompletion = false;
0055:
0056:            /**
0057:             * Completion is a declaration of an anonymous class.
0058:             * This kind of completion might occur in a context like
0059:             * <code>"new List^;"</code> and complete it to
0060:             * <code>"new List() {}"</code>.
0061:             * <p>
0062:             * The following additional context information is available
0063:             * for this kind of completion proposal at little extra cost:
0064:             * <ul>
0065:             * <li>{@link #getDeclarationSignature()} -
0066:             * the type signature of the type being implemented or subclassed
0067:             * </li>
0068:             * <li>{@link #getDeclarationKey()} -
0069:             * the type unique key of the type being implemented or subclassed
0070:             * </li>
0071:             * <li>{@link #getSignature()} -
0072:             * the method signature of the constructor that is referenced
0073:             * </li>
0074:             * <li>{@link #getKey()} -
0075:             * the method unique key of the constructor that is referenced
0076:             * if the declaring type is not an interface
0077:             * </li>
0078:             * <li>{@link #getFlags()} -
0079:             * the modifiers flags of the constructor that is referenced
0080:             * </li>
0081:             * </ul>
0082:             * </p>
0083:             * 
0084:             * @see #getKind()
0085:             */
0086:            public static final int ANONYMOUS_CLASS_DECLARATION = 1;
0087:
0088:            /**
0089:             * Completion is a reference to a field.
0090:             * This kind of completion might occur in a context like
0091:             * <code>"this.ref^ = 0;"</code> and complete it to
0092:             * <code>"this.refcount = 0;"</code>.
0093:             * <p>
0094:             * The following additional context information is available
0095:             * for this kind of completion proposal at little extra cost:
0096:             * <ul>
0097:             * <li>{@link #getDeclarationSignature()} -
0098:             * the type signature of the type that declares the field that is referenced
0099:             * </li>
0100:             * <li>{@link #getFlags()} -
0101:             * the modifiers flags (including ACC_ENUM) of the field that is referenced
0102:             * </li>
0103:             * <li>{@link #getName()} -
0104:             * the simple name of the field that is referenced
0105:             * </li>
0106:             * <li>{@link #getSignature()} -
0107:             * the type signature of the field's type (as opposed to the
0108:             * signature of the type in which the referenced field
0109:             * is declared)
0110:             * </li>
0111:             * </ul>
0112:             * </p>
0113:             * 
0114:             * @see #getKind()
0115:             */
0116:            public static final int FIELD_REF = 2;
0117:
0118:            /**
0119:             * Completion is a keyword.
0120:             * This kind of completion might occur in a context like
0121:             * <code>"public cl^ Foo {}"</code> and complete it to
0122:             * <code>"public class Foo {}"</code>.
0123:             * <p>
0124:             * The following additional context information is available
0125:             * for this kind of completion proposal at little extra cost:
0126:             * <ul>
0127:             * <li>{@link #getName()} -
0128:             * the keyword token
0129:             * </li>
0130:             * <li>{@link #getFlags()} -
0131:             * the corresponding modifier flags if the keyword is a modifier
0132:             * </li>
0133:             * </ul>
0134:             * </p>
0135:             * 
0136:             * @see #getKind()
0137:             */
0138:            public static final int KEYWORD = 3;
0139:
0140:            /**
0141:             * Completion is a reference to a label.
0142:             * This kind of completion might occur in a context like
0143:             * <code>"break lo^;"</code> and complete it to
0144:             * <code>"break loop;"</code>.
0145:             * <p>
0146:             * The following additional context information is available
0147:             * for this kind of completion proposal at little extra cost:
0148:             * <ul>
0149:             * <li>{@link #getName()} -
0150:             * the simple name of the label that is referenced
0151:             * </li>
0152:             * </ul>
0153:             * </p>
0154:             * 
0155:             * @see #getKind()
0156:             */
0157:            public static final int LABEL_REF = 4;
0158:
0159:            /**
0160:             * Completion is a reference to a local variable.
0161:             * This kind of completion might occur in a context like
0162:             * <code>"ke^ = 4;"</code> and complete it to
0163:             * <code>"keys = 4;"</code>.
0164:             * <p>
0165:             * The following additional context information is available
0166:             * for this kind of completion proposal at little extra cost:
0167:             * <ul>
0168:             * <li>{@link #getFlags()} -
0169:             * the modifiers flags of the local variable that is referenced
0170:             * </li>
0171:             * <li>{@link #getName()} -
0172:             * the simple name of the local variable that is referenced
0173:             * </li>
0174:             * <li>{@link #getSignature()} -
0175:             * the type signature of the local variable's type
0176:             * </li>
0177:             * </ul>
0178:             * </p>
0179:             * 
0180:             * @see #getKind()
0181:             */
0182:            public static final int LOCAL_VARIABLE_REF = 5;
0183:
0184:            /**
0185:             * Completion is a reference to a method.
0186:             * This kind of completion might occur in a context like
0187:             * <code>"System.out.pr^();"</code> and complete it to
0188:             * <code>""System.out.println();"</code>.
0189:             * <p>
0190:             * The following additional context information is available
0191:             * for this kind of completion proposal at little extra cost:
0192:             * <ul>
0193:             * <li>{@link #getDeclarationSignature()} -
0194:             * the type signature of the type that declares the method that is referenced
0195:             * </li>
0196:             * <li>{@link #getFlags()} -
0197:             * the modifiers flags of the method that is referenced
0198:             * </li>
0199:             * <li>{@link #getName()} -
0200:             * the simple name of the method that is referenced
0201:             * </li>
0202:             * <li>{@link #getSignature()} -
0203:             * the method signature of the method that is referenced
0204:             * </li>
0205:             * </ul>
0206:             * </p>
0207:             * 
0208:             * @see #getKind()
0209:             */
0210:            public static final int METHOD_REF = 6;
0211:
0212:            /**
0213:             * Completion is a declaration of a method.
0214:             * This kind of completion might occur in a context like
0215:             * <code>"new List() {si^};"</code> and complete it to
0216:             * <code>"new List() {public int size() {} };"</code>.
0217:             * <p>
0218:             * The following additional context information is available
0219:             * for this kind of completion proposal at little extra cost:
0220:             * <ul>
0221:             * <li>{@link #getDeclarationSignature()} -
0222:             * the type signature of the type that declares the
0223:             * method that is being overridden or implemented
0224:             * </li>
0225:             * <li>{@link #getDeclarationKey()} -
0226:             * the unique of the type that declares the
0227:             * method that is being overridden or implemented
0228:             * </li>
0229:             * <li>{@link #getName()} -
0230:             * the simple name of the method that is being overridden
0231:             * or implemented
0232:             * </li>
0233:             * <li>{@link #getSignature()} -
0234:             * the method signature of the method that is being
0235:             * overridden or implemented
0236:             * </li>
0237:             * <li>{@link #getKey()} -
0238:             * the method unique key of the method that is being
0239:             * overridden or implemented
0240:             * </li>
0241:             * <li>{@link #getFlags()} -
0242:             * the modifiers flags of the method that is being
0243:             * overridden or implemented
0244:             * </li>
0245:             * </ul>
0246:             * </p>
0247:             * 
0248:             * @see #getKind()
0249:             */
0250:            public static final int METHOD_DECLARATION = 7;
0251:
0252:            /**
0253:             * Completion is a reference to a package.
0254:             * This kind of completion might occur in a context like
0255:             * <code>"import java.u^.*;"</code> and complete it to
0256:             * <code>"import java.util.*;"</code>.
0257:             * <p>
0258:             * The following additional context information is available
0259:             * for this kind of completion proposal at little extra cost:
0260:             * <ul>
0261:             * <li>{@link #getDeclarationSignature()} -
0262:             * the dot-based package name of the package that is referenced
0263:             * </li>
0264:             * </ul>
0265:             * </p>
0266:             * 
0267:             * @see #getKind()
0268:             */
0269:            public static final int PACKAGE_REF = 8;
0270:
0271:            /**
0272:             * Completion is a reference to a type. Any kind of type
0273:             * is allowed, including primitive types, reference types,
0274:             * array types, parameterized types, and type variables.
0275:             * This kind of completion might occur in a context like
0276:             * <code>"public static Str^ key;"</code> and complete it to
0277:             * <code>"public static String key;"</code>.
0278:             * <p>
0279:             * The following additional context information is available
0280:             * for this kind of completion proposal at little extra cost:
0281:             * <ul>
0282:             * <li>{@link #getDeclarationSignature()} -
0283:             * the dot-based package name of the package that contains
0284:             * the type that is referenced
0285:             * </li>
0286:             * <li>{@link #getSignature()} -
0287:             * the type signature of the type that is referenced
0288:             * </li>
0289:             * <li>{@link #getFlags()} -
0290:             * the modifiers flags (including Flags.AccInterface, AccEnum,
0291:             * and AccAnnotation) of the type that is referenced
0292:             * </li>
0293:             * </ul>
0294:             * </p>
0295:             * 
0296:             * @see #getKind()
0297:             */
0298:            public static final int TYPE_REF = 9;
0299:
0300:            /**
0301:             * Completion is a declaration of a variable (locals, parameters,
0302:             * fields, etc.).
0303:             * <p>
0304:             * The following additional context information is available
0305:             * for this kind of completion proposal at little extra cost:
0306:             * <ul>
0307:             * <li>{@link #getName()} -
0308:             * the simple name of the variable being declared
0309:             * </li>
0310:             * <li>{@link #getSignature()} -
0311:             * the type signature of the type of the variable
0312:             * being declared
0313:             * </li>
0314:             * <li>{@link #getFlags()} -
0315:             * the modifiers flags of the variable being declared
0316:             * </li>
0317:             * </ul>
0318:             * </p>
0319:             * @see #getKind()
0320:             */
0321:            public static final int VARIABLE_DECLARATION = 10;
0322:
0323:            /**
0324:             * Completion is a declaration of a new potential method.
0325:             * This kind of completion might occur in a context like
0326:             * <code>"new List() {si^};"</code> and complete it to
0327:             * <code>"new List() {public int si() {} };"</code>.
0328:             * <p>
0329:             * The following additional context information is available
0330:             * for this kind of completion proposal at little extra cost:
0331:             * <ul>
0332:             * <li>{@link #getDeclarationSignature()} -
0333:             * the type signature of the type that declares the
0334:             * method that is being created
0335:             * </li>
0336:             * <li>{@link #getName()} -
0337:             * the simple name of the method that is being created
0338:             * </li>
0339:             * <li>{@link #getSignature()} -
0340:             * the method signature of the method that is being
0341:             * created
0342:             * </li>
0343:             * <li>{@link #getFlags()} -
0344:             * the modifiers flags of the method that is being
0345:             * created
0346:             * </li>
0347:             * </ul>
0348:             * </p>
0349:             * 
0350:             * @see #getKind()
0351:             * @since 3.1
0352:             */
0353:            public static final int POTENTIAL_METHOD_DECLARATION = 11;
0354:
0355:            /**
0356:             * Completion is a reference to a method name.
0357:             * This kind of completion might occur in a context like
0358:             * <code>"import p.X.fo^"</code> and complete it to
0359:             * <code>"import p.X.foo;"</code>.
0360:             * <p>
0361:             * The following additional context information is available
0362:             * for this kind of completion proposal at little extra cost:
0363:             * <ul>
0364:             * <li>{@link #getDeclarationSignature()} -
0365:             * the type signature of the type that declares the method that is referenced
0366:             * </li>
0367:             * <li>{@link #getFlags()} -
0368:             * the modifiers flags of the method that is referenced
0369:             * </li>
0370:             * <li>{@link #getName()} -
0371:             * the simple name of the method that is referenced
0372:             * </li>
0373:             * <li>{@link #getSignature()} -
0374:             * the method signature of the method that is referenced
0375:             * </li>
0376:             * </ul>
0377:             * </p>
0378:             * 
0379:             * @see #getKind()
0380:             * @since 3.1
0381:             */
0382:            public static final int METHOD_NAME_REFERENCE = 12;
0383:
0384:            /**
0385:             * Completion is a reference to annotation's attribute.
0386:             * This kind of completion might occur in a context like
0387:             * <code>"@Annot(attr^=value)"</code> and complete it to
0388:             * <code>"@Annot(attribute^=value)"</code>.
0389:             * <p>
0390:             * The following additional context information is available
0391:             * for this kind of completion proposal at little extra cost:
0392:             * <ul>
0393:             * <li>{@link #getDeclarationSignature()} -
0394:             * the type signature of the annotation that declares the attribute that is referenced
0395:             * </li>
0396:             * <li>{@link #getFlags()} -
0397:             * the modifiers flags of the attribute that is referenced
0398:             * </li>
0399:             * <li>{@link #getName()} -
0400:             * the simple name of the attribute that is referenced
0401:             * </li>
0402:             * <li>{@link #getSignature()} -
0403:             * the type signature of the attribute's type (as opposed to the
0404:             * signature of the type in which the referenced attribute
0405:             * is declared)
0406:             * </li>
0407:             * </ul>
0408:             * </p>
0409:             * 
0410:             * @see #getKind()
0411:             * @since 3.1
0412:             */
0413:            public static final int ANNOTATION_ATTRIBUTE_REF = 13;
0414:
0415:            /**
0416:             * Completion is a link reference to a field in a javadoc text.
0417:             * This kind of completion might occur in a context like
0418:             * <code>"	* blabla System.o^ blabla"</code> and complete it to
0419:             * <code>"	* blabla {&#64;link System#out } blabla"</code>.
0420:             * <p>
0421:             * The following additional context information is available
0422:             * for this kind of completion proposal at little extra cost:
0423:             * <ul>
0424:             * <li>{@link #getDeclarationSignature()} -
0425:             * the type signature of the type that declares the field that is referenced
0426:             * </li>
0427:             * <li>{@link #getFlags()} -
0428:             * the modifiers flags (including ACC_ENUM) of the field that is referenced
0429:             * </li>
0430:             * <li>{@link #getName()} -
0431:             * the simple name of the field that is referenced
0432:             * </li>
0433:             * <li>{@link #getSignature()} -
0434:             * the type signature of the field's type (as opposed to the
0435:             * signature of the type in which the referenced field
0436:             * is declared)
0437:             * </li>
0438:             * </ul>
0439:             * </p>
0440:             * 
0441:             * @see #getKind()
0442:             * @since 3.2
0443:             */
0444:            public static final int JAVADOC_FIELD_REF = 14;
0445:
0446:            /**
0447:             * Completion is a link reference to a method in a javadoc text.
0448:             * This kind of completion might occur in a context like
0449:             * <code>"	* blabla Runtime#get^ blabla"</code> and complete it to
0450:             * <code>"	* blabla {&#64;link Runtime#getRuntime() }"</code>.
0451:             * <p>
0452:             * The following additional context information is available
0453:             * for this kind of completion proposal at little extra cost:
0454:             * <ul>
0455:             * <li>{@link #getDeclarationSignature()} -
0456:             * the type signature of the type that declares the method that is referenced
0457:             * </li>
0458:             * <li>{@link #getFlags()} -
0459:             * the modifiers flags of the method that is referenced
0460:             * </li>
0461:             * <li>{@link #getName()} -
0462:             * the simple name of the method that is referenced
0463:             * </li>
0464:             * <li>{@link #getSignature()} -
0465:             * the method signature of the method that is referenced
0466:             * </li>
0467:             * </ul>
0468:             * </p>
0469:             * 
0470:             * @see #getKind()
0471:             * @since 3.2
0472:             */
0473:            public static final int JAVADOC_METHOD_REF = 15;
0474:
0475:            /**
0476:             * Completion is a link reference to a type in a javadoc text.
0477:             * Any kind of type is allowed, including primitive types, reference types,
0478:             * array types, parameterized types, and type variables.
0479:             * This kind of completion might occur in a context like
0480:             * <code>"	* blabla Str^ blabla"</code> and complete it to
0481:             * <code>"	* blabla {&#64;link String } blabla"</code>.
0482:             * <p>
0483:             * The following additional context information is available
0484:             * for this kind of completion proposal at little extra cost:
0485:             * <ul>
0486:             * <li>{@link #getDeclarationSignature()} -
0487:             * the dot-based package name of the package that contains
0488:             * the type that is referenced
0489:             * </li>
0490:             * <li>{@link #getSignature()} -
0491:             * the type signature of the type that is referenced
0492:             * </li>
0493:             * <li>{@link #getFlags()} -
0494:             * the modifiers flags (including Flags.AccInterface, AccEnum,
0495:             * and AccAnnotation) of the type that is referenced
0496:             * </li>
0497:             * </ul>
0498:             * </p>
0499:             * 
0500:             * @see #getKind()
0501:             * @since 3.2
0502:             */
0503:            public static final int JAVADOC_TYPE_REF = 16;
0504:
0505:            /**
0506:             * Completion is a value reference to a static field in a javadoc text.
0507:             * This kind of completion might occur in a context like
0508:             * <code>"	* blabla System.o^ blabla"</code> and complete it to
0509:             * <code>"	* blabla {&#64;value System#out } blabla"</code>.
0510:             * <p>
0511:             * The following additional context information is available
0512:             * for this kind of completion proposal at little extra cost:
0513:             * <ul>
0514:             * <li>{@link #getDeclarationSignature()} -
0515:             * the type signature of the type that declares the field that is referenced
0516:             * </li>
0517:             * <li>{@link #getFlags()} -
0518:             * the modifiers flags (including ACC_ENUM) of the field that is referenced
0519:             * </li>
0520:             * <li>{@link #getName()} -
0521:             * the simple name of the field that is referenced
0522:             * </li>
0523:             * <li>{@link #getSignature()} -
0524:             * the type signature of the field's type (as opposed to the
0525:             * signature of the type in which the referenced field
0526:             * is declared)
0527:             * </li>
0528:             * </ul>
0529:             * </p>
0530:             * 
0531:             * @see #getKind()
0532:             * @since 3.2
0533:             */
0534:            public static final int JAVADOC_VALUE_REF = 17;
0535:
0536:            /**
0537:             * Completion is a method argument or a class/method type parameter
0538:             * in javadoc param tag.
0539:             * This kind of completion might occur in a context like
0540:             * <code>"	* @param arg^ blabla"</code> and complete it to
0541:             * <code>"	* @param argument blabla"</code>.
0542:             * or
0543:             * <code>"	* @param &lt;T^ blabla"</code> and complete it to
0544:             * <code>"	* @param &lt;TT&gt; blabla"</code>.
0545:             * <p>
0546:             * The following additional context information is available
0547:             * for this kind of completion proposal at little extra cost:
0548:             * <ul>
0549:             * <li>{@link #getDeclarationSignature()} -
0550:             * the type signature of the type that declares the field that is referenced
0551:             * </li>
0552:             * <li>{@link #getFlags()} -
0553:             * the modifiers flags (including ACC_ENUM) of the field that is referenced
0554:             * </li>
0555:             * <li>{@link #getName()} -
0556:             * the simple name of the field that is referenced
0557:             * </li>
0558:             * <li>{@link #getSignature()} -
0559:             * the type signature of the field's type (as opposed to the
0560:             * signature of the type in which the referenced field
0561:             * is declared)
0562:             * </li>
0563:             * </ul>
0564:             * </p>
0565:             * 
0566:             * @see #getKind()
0567:             * @since 3.2
0568:             */
0569:            public static final int JAVADOC_PARAM_REF = 18;
0570:
0571:            /**
0572:             * Completion is a javadoc block tag.
0573:             * This kind of completion might occur in a context like
0574:             * <code>"	* @s^ blabla"</code> and complete it to
0575:             * <code>"	* @see blabla"</code>.
0576:             * <p>
0577:             * The following additional context information is available
0578:             * for this kind of completion proposal at little extra cost:
0579:             * <ul>
0580:             * <li>{@link #getDeclarationSignature()} -
0581:             * the type signature of the type that declares the field that is referenced
0582:             * </li>
0583:             * <li>{@link #getFlags()} -
0584:             * the modifiers flags (including ACC_ENUM) of the field that is referenced
0585:             * </li>
0586:             * <li>{@link #getName()} -
0587:             * the simple name of the field that is referenced
0588:             * </li>
0589:             * <li>{@link #getSignature()} -
0590:             * the type signature of the field's type (as opposed to the
0591:             * signature of the type in which the referenced field
0592:             * is declared)
0593:             * </li>
0594:             * </ul>
0595:             * </p>
0596:             * 
0597:             * @see #getKind()
0598:             * @since 3.2
0599:             */
0600:            public static final int JAVADOC_BLOCK_TAG = 19;
0601:
0602:            /**
0603:             * Completion is a javadoc inline tag.
0604:             * This kind of completion might occur in a context like
0605:             * <code>"	* Insert @l^ Object"</code> and complete it to
0606:             * <code>"	* Insert {&#64;link Object }"</code>.
0607:             * <p>
0608:             * The following additional context information is available
0609:             * for this kind of completion proposal at little extra cost:
0610:             * <ul>
0611:             * <li>{@link #getDeclarationSignature()} -
0612:             * the type signature of the type that declares the field that is referenced
0613:             * </li>
0614:             * <li>{@link #getFlags()} -
0615:             * the modifiers flags (including ACC_ENUM) of the field that is referenced
0616:             * </li>
0617:             * <li>{@link #getName()} -
0618:             * the simple name of the field that is referenced
0619:             * </li>
0620:             * <li>{@link #getSignature()} -
0621:             * the type signature of the field's type (as opposed to the
0622:             * signature of the type in which the referenced field
0623:             * is declared)
0624:             * </li>
0625:             * </ul>
0626:             * </p>
0627:             * 
0628:             * @see #getKind()
0629:             * @since 3.2
0630:             */
0631:            public static final int JAVADOC_INLINE_TAG = 20;
0632:
0633:            /**
0634:             * Completion is an import of reference to a static field.
0635:             * <p>
0636:             * The following additional context information is available
0637:             * for this kind of completion proposal at little extra cost:
0638:             * <ul>
0639:             * <li>{@link #getDeclarationSignature()} -
0640:             * the type signature of the type that declares the field that is imported
0641:             * </li>
0642:             * <li>{@link #getFlags()} -
0643:             * the modifiers flags (including ACC_ENUM) of the field that is imported
0644:             * </li>
0645:             * <li>{@link #getName()} -
0646:             * the simple name of the field that is imported
0647:             * </li>
0648:             * <li>{@link #getSignature()} -
0649:             * the type signature of the field's type (as opposed to the
0650:             * signature of the type in which the referenced field
0651:             * is declared)
0652:             * </li>
0653:             * <li>{@link #getAdditionalFlags()} -
0654:             * the completion flags (including ComletionFlags.StaticImport)
0655:             * of the proposed import
0656:             * </li>
0657:             * </ul>
0658:             * </p>
0659:             * 
0660:             * @see #getKind()
0661:             * 
0662:             * @since 3.3
0663:             */
0664:            public static final int FIELD_IMPORT = 21;
0665:
0666:            /**
0667:             * Completion is an import of reference to a static method.
0668:             * <p>
0669:             * The following additional context information is available
0670:             * for this kind of completion proposal at little extra cost:
0671:             * <ul>
0672:             * <li>{@link #getDeclarationSignature()} -
0673:             * the type signature of the type that declares the method that is imported
0674:             * </li>
0675:             * <li>{@link #getFlags()} -
0676:             * the modifiers flags of the method that is imported
0677:             * </li>
0678:             * <li>{@link #getName()} -
0679:             * the simple name of the method that is imported
0680:             * </li>
0681:             * <li>{@link #getSignature()} -
0682:             * the method signature of the method that is imported
0683:             * </li>
0684:             * <li>{@link #getAdditionalFlags()} -
0685:             * the completion flags (including ComletionFlags.StaticImport)
0686:             * of the proposed import
0687:             * </li>
0688:             * </ul>
0689:             * </p>
0690:             * 
0691:             * @see #getKind()
0692:             * 
0693:             * @since 3.3
0694:             */
0695:            public static final int METHOD_IMPORT = 22;
0696:
0697:            /**
0698:             * Completion is an import of reference to a type.
0699:             * Only reference to reference types are allowed.
0700:             * <p>
0701:             * The following additional context information is available
0702:             * for this kind of completion proposal at little extra cost:
0703:             * <ul>
0704:             * <li>{@link #getDeclarationSignature()} -
0705:             * the dot-based package name of the package that contains
0706:             * the type that is imported
0707:             * </li>
0708:             * <li>{@link #getSignature()} -
0709:             * the type signature of the type that is imported
0710:             * </li>
0711:             * <li>{@link #getFlags()} -
0712:             * the modifiers flags (including Flags.AccInterface, AccEnum,
0713:             * and AccAnnotation) of the type that is imported
0714:             * </li>
0715:             * <li>{@link #getAdditionalFlags()} -
0716:             * the completion flags (including ComletionFlags.StaticImport)
0717:             * of the proposed import
0718:             * </li>
0719:             * </ul>
0720:             * </p>
0721:             * 
0722:             * @see #getKind()
0723:             * 
0724:             * @since 3.3
0725:             */
0726:            public static final int TYPE_IMPORT = 23;
0727:
0728:            /**
0729:             * First valid completion kind.
0730:             * 
0731:             * @since 3.1
0732:             */
0733:            protected static final int FIRST_KIND = ANONYMOUS_CLASS_DECLARATION;
0734:
0735:            /**
0736:             * Last valid completion kind.
0737:             * 
0738:             * @since 3.1
0739:             */
0740:            protected static final int LAST_KIND = TYPE_IMPORT;
0741:
0742:            /**
0743:             * Kind of completion request.
0744:             */
0745:            private int completionKind;
0746:
0747:            /**
0748:             * Offset in original buffer where ICodeAssist.codeComplete() was
0749:             * requested.
0750:             */
0751:            private int completionLocation;
0752:
0753:            /**
0754:             * Start position (inclusive) of source range in original buffer 
0755:             * containing the relevant token
0756:             * defaults to empty subrange at [0,0).
0757:             */
0758:            private int tokenStart = 0;
0759:
0760:            /**
0761:             * End position (exclusive) of source range in original buffer 
0762:             * containing the relevant token;
0763:             * defaults to empty subrange at [0,0).
0764:             */
0765:            private int tokenEnd = 0;
0766:
0767:            /**
0768:             * Completion string; defaults to empty string.
0769:             */
0770:            private char[] completion = CharOperation.NO_CHAR;
0771:
0772:            /**
0773:             * Start position (inclusive) of source range in original buffer 
0774:             * to be replaced by completion string; 
0775:             * defaults to empty subrange at [0,0).
0776:             */
0777:            private int replaceStart = 0;
0778:
0779:            /**
0780:             * End position (exclusive) of source range in original buffer 
0781:             * to be replaced by completion string;
0782:             * defaults to empty subrange at [0,0).
0783:             */
0784:            private int replaceEnd = 0;
0785:
0786:            /**
0787:             * Relevance rating; positive; higher means better;
0788:             * defaults to minimum rating.
0789:             */
0790:            private int relevance = 1;
0791:
0792:            /**
0793:             * Signature of the relevant package or type declaration
0794:             * in the context, or <code>null</code> if none.
0795:             * Defaults to null.
0796:             */
0797:            private char[] declarationSignature = null;
0798:
0799:            /**
0800:             * Unique key of the relevant package or type declaration
0801:             * in the context, or <code>null</code> if none.
0802:             * Defaults to null.
0803:             */
0804:            private char[] declarationKey = null;
0805:
0806:            /**
0807:             * Simple name of the method, field,
0808:             * member, or variable relevant in the context, or
0809:             * <code>null</code> if none.
0810:             * Defaults to null.
0811:             */
0812:            private char[] name = null;
0813:
0814:            /**
0815:             * Signature of the method, field type, member type,
0816:             * relevant in the context, or <code>null</code> if none.
0817:             * Defaults to null.
0818:             */
0819:            private char[] signature = null;
0820:
0821:            /**
0822:             * Unique of the method, field type, member type,
0823:             * relevant in the context, or <code>null</code> if none.
0824:             * Defaults to null.
0825:             */
0826:            private char[] key = null;
0827:
0828:            /**
0829:             * Array of required completion proposals, or <code>null</code> if none.
0830:             * The proposal can not be applied if the required proposals aren't applied.
0831:             * Defaults to <code>null</code>.
0832:             */
0833:            private CompletionProposal[] requiredProposals;
0834:
0835:            /**
0836:             * Modifier flags relevant in the context, or
0837:             * <code>Flags.AccDefault</code> if none.
0838:             * Defaults to <code>Flags.AccDefault</code>.
0839:             */
0840:            private int flags = Flags.AccDefault;
0841:
0842:            /**
0843:             * Completion flags relevant in the context, or
0844:             * <code>CompletionFlags.Default</code> if none.
0845:             * Defaults to <code>CompletionFlags.Default</code>.
0846:             */
0847:            private int additionalFlags = CompletionFlags.Default;
0848:
0849:            /**
0850:             * Parameter names (for method completions), or
0851:             * <code>null</code> if none. Lazily computed.
0852:             * Defaults to <code>null</code>.
0853:             */
0854:            private char[][] parameterNames = null;
0855:
0856:            /**
0857:             * Indicates whether parameter names have been computed.
0858:             */
0859:            private boolean parameterNamesComputed = false;
0860:
0861:            /**
0862:             * Creates a basic completion proposal. All instance
0863:             * field have plausible default values unless otherwise noted.
0864:             * <p>
0865:             * Note that the constructors for this class are internal to the
0866:             * Java model implementation. Clients cannot directly create
0867:             * CompletionProposal objects.
0868:             * </p>
0869:             * 
0870:             * @param kind one of the kind constants declared on this class
0871:             * @param completionOffset original offset of code completion request
0872:             * @return a new completion proposal
0873:             */
0874:            public static CompletionProposal create(int kind,
0875:                    int completionOffset) {
0876:                return new CompletionProposal(kind, completionOffset);
0877:            }
0878:
0879:            /**
0880:             * Creates a basic completion proposal. All instance
0881:             * field have plausible default values unless otherwise noted.
0882:             * <p>
0883:             * Note that the constructors for this class are internal to the
0884:             * Java model implementation. Clients cannot directly create
0885:             * CompletionProposal objects.
0886:             * </p>
0887:             * 
0888:             * @param kind one of the kind constants declared on this class
0889:             * @param completionLocation original offset of code completion request
0890:             */
0891:            CompletionProposal(int kind, int completionLocation) {
0892:                if ((kind < CompletionProposal.FIRST_KIND)
0893:                        || (kind > CompletionProposal.LAST_KIND)) {
0894:                    throw new IllegalArgumentException();
0895:                }
0896:                if (this .completion == null || completionLocation < 0) {
0897:                    // Work around for bug 132558 (https://bugs.eclipse.org/bugs/show_bug.cgi?id=132558).
0898:                    // completionLocation can be -1 if the completion occur at the start of a file or
0899:                    // the start of a code snippet but this API isn't design to support negative position.
0900:                    if (this .completion == null || completionLocation != -1) {
0901:                        throw new IllegalArgumentException();
0902:                    }
0903:                    completionLocation = 0;
0904:                }
0905:                this .completionKind = kind;
0906:                this .completionLocation = completionLocation;
0907:            }
0908:
0909:            /**
0910:             * Returns the completion flags relevant in the context, or
0911:             * <code>CompletionFlags.Default</code> if none.
0912:             * <p>
0913:             * This field is available for the following kinds of
0914:             * completion proposals:
0915:             * <ul>
0916:             * <li><code>FIELD_IMPORT</code> - completion flags
0917:             * of the attribute that is referenced. Completion flags for
0918:             * this proposal kind can only include <code>CompletionFlags.StaticImport</code></li>
0919:             * <li><code>METHOD_IMPORT</code> - completion flags
0920:             * of the attribute that is referenced. Completion flags for
0921:             * this proposal kind can only include <code>CompletionFlags.StaticImport</code></li>
0922:             * <li><code>TYPE_IMPORT</code> - completion flags
0923:             * of the attribute that is referenced. Completion flags for
0924:             * this proposal kind can only include <code>CompletionFlags.StaticImport</code></li>
0925:             * </ul>
0926:             * For other kinds of completion proposals, this method returns
0927:             * <code>CompletionFlags.Default</code>.
0928:             * </p>
0929:             * 
0930:             * @return the completion flags, or
0931:             * <code>CompletionFlags.Default</code> if none
0932:             * @see CompletionFlags
0933:             * 
0934:             * @since 3.3
0935:             */
0936:            public int getAdditionalFlags() {
0937:                return this .additionalFlags;
0938:            }
0939:
0940:            /**
0941:             * Sets the completion flags relevant in the context.
0942:             * <p>
0943:             * If not set, defaults to none.
0944:             * </p>
0945:             * <p>
0946:             * The completion engine creates instances of this class and sets
0947:             * its properties; this method is not intended to be used by other clients.
0948:             * </p>
0949:             * 
0950:             * @param additionalFlags the completion flags, or
0951:             * <code>CompletionFlags.Default</code> if none
0952:             * 
0953:             * @since 3.3
0954:             */
0955:            public void setAdditionalFlags(int additionalFlags) {
0956:                this .additionalFlags = additionalFlags;
0957:            }
0958:
0959:            /**
0960:             * Returns the kind of completion being proposed.
0961:             * <p>
0962:             * The set of different kinds of completion proposals is
0963:             * expected to change over time. It is strongly recommended
0964:             * that clients do <b>not</b> assume that the kind is one of the
0965:             * ones they know about, and code defensively for the
0966:             * possibility of unexpected future growth.
0967:             * </p>
0968:             * 
0969:             * @return the kind; one of the kind constants
0970:             * declared on this class, or possibly a kind unknown
0971:             * to the caller
0972:             */
0973:            public int getKind() {
0974:                return this .completionKind;
0975:            }
0976:
0977:            /**
0978:             * Returns the character index in the source file buffer
0979:             * where source completion was requested (the 
0980:             * <code>offset</code> parameter to
0981:             * <code>ICodeAssist.codeComplete</code> minus one).
0982:             * 
0983:             * @return character index in source file buffer
0984:             * @see ICodeAssist#codeComplete(int,CompletionRequestor)
0985:             */
0986:            // TODO (david) https://bugs.eclipse.org/bugs/show_bug.cgi?id=132558
0987:            public int getCompletionLocation() {
0988:                return this .completionLocation;
0989:            }
0990:
0991:            /**
0992:             * Returns the character index of the start of the
0993:             * subrange in the source file buffer containing the
0994:             * relevant token being completed. This
0995:             * token is either the identifier or Java language keyword
0996:             * under, or immediately preceding, the original request 
0997:             * offset. If the original request offset is not within
0998:             * or immediately after an identifier or keyword, then the
0999:             * position returned is original request offset and the
1000:             * token range is empty.
1001:             * 
1002:             * @return character index of token start position (inclusive)
1003:             */
1004:            public int getTokenStart() {
1005:                return this .tokenStart;
1006:            }
1007:
1008:            /**
1009:             * Returns the character index of the end (exclusive) of the subrange
1010:             * in the source file buffer containing the
1011:             * relevant token. When there is no relevant token, the
1012:             * range is empty
1013:             * (<code>getEndToken() == getStartToken()</code>).
1014:             * 
1015:             * @return character index of token end position (exclusive)
1016:             */
1017:            public int getTokenEnd() {
1018:                return this .tokenEnd;
1019:            }
1020:
1021:            /**
1022:             * Sets the character indices of the subrange in the
1023:             * source file buffer containing the relevant token being
1024:             * completed. This token is either the identifier or
1025:             * Java language keyword under, or immediately preceding,
1026:             * the original request offset. If the original request
1027:             * offset is not within or immediately after an identifier
1028:             * or keyword, then the source range begins at original
1029:             * request offset and is empty.
1030:             * <p>
1031:             * If not set, defaults to empty subrange at [0,0).
1032:             * </p>
1033:             * 
1034:             * @param startIndex character index of token start position (inclusive)
1035:             * @param endIndex character index of token end position (exclusive)
1036:             */
1037:            public void setTokenRange(int startIndex, int endIndex) {
1038:                if (startIndex < 0 || endIndex < startIndex) {
1039:                    throw new IllegalArgumentException();
1040:                }
1041:                this .tokenStart = startIndex;
1042:                this .tokenEnd = endIndex;
1043:            }
1044:
1045:            /**
1046:             * Returns the proposed sequence of characters to insert into the
1047:             * source file buffer, replacing the characters at the specified
1048:             * source range. The string can be arbitrary; for example, it might
1049:             * include not only the name of a method but a set of parentheses.
1050:             * <p>
1051:             * The client must not modify the array returned.
1052:             * </p>
1053:             * 
1054:             * @return the completion string
1055:             */
1056:            public char[] getCompletion() {
1057:                if (this .completionKind == METHOD_DECLARATION) {
1058:                    this .findParameterNames(null);
1059:                    if (this .updateCompletion) {
1060:                        this .updateCompletion = false;
1061:
1062:                        if (this .parameterNames != null) {
1063:                            int length = this .parameterNames.length;
1064:                            StringBuffer completionBuffer = new StringBuffer(
1065:                                    this .completion.length);
1066:
1067:                            int start = 0;
1068:                            int end = CharOperation.indexOf('%',
1069:                                    this .completion);
1070:
1071:                            completionBuffer.append(this .completion, start, end
1072:                                    - start);
1073:
1074:                            for (int i = 0; i < length; i++) {
1075:                                completionBuffer.append(this .parameterNames[i]);
1076:                                start = end + 1;
1077:                                end = CharOperation.indexOf('%',
1078:                                        this .completion, start);
1079:                                if (end > -1) {
1080:                                    completionBuffer.append(this .completion,
1081:                                            start, end - start);
1082:                                } else {
1083:                                    completionBuffer.append(this .completion,
1084:                                            start, this .completion.length
1085:                                                    - start);
1086:                                }
1087:                            }
1088:                            int nameLength = completionBuffer.length();
1089:                            this .completion = new char[nameLength];
1090:                            completionBuffer.getChars(0, nameLength,
1091:                                    this .completion, 0);
1092:                        }
1093:                    }
1094:                }
1095:                return this .completion;
1096:            }
1097:
1098:            /**
1099:             * Sets the proposed sequence of characters to insert into the
1100:             * source file buffer, replacing the characters at the specified
1101:             * source range. The string can be arbitrary; for example, it might
1102:             * include not only the name of a method but a set of parentheses.
1103:             * <p>
1104:             * If not set, defaults to an empty character array.
1105:             * </p>
1106:             * <p>
1107:             * The completion engine creates instances of this class and sets
1108:             * its properties; this method is not intended to be used by other clients.
1109:             * </p>
1110:             * 
1111:             * @param completion the completion string
1112:             */
1113:            public void setCompletion(char[] completion) {
1114:                this .completion = completion;
1115:            }
1116:
1117:            /**
1118:             * Returns the character index of the start of the
1119:             * subrange in the source file buffer to be replaced
1120:             * by the completion string. If the subrange is empty
1121:             * (<code>getReplaceEnd() == getReplaceStart()</code>),
1122:             * the completion string is to be inserted at this
1123:             * index.
1124:             * <p>
1125:             * Note that while the token subrange is precisely 
1126:             * specified, the replacement range is loosely
1127:             * constrained and may not bear any direct relation
1128:             * to the original request offset. For example,
1129:             * it would be possible for a type completion to 
1130:             * propose inserting an import declaration at the
1131:             * top of the compilation unit; or the completion
1132:             * might include trailing parentheses and
1133:             * punctuation for a method completion.
1134:             * </p>
1135:             * 
1136:             * @return replacement start position (inclusive)
1137:             */
1138:            public int getReplaceStart() {
1139:                return this .replaceStart;
1140:            }
1141:
1142:            /**
1143:             * Returns the character index of the end of the
1144:             * subrange in the source file buffer to be replaced
1145:             * by the completion string. If the subrange is empty
1146:             * (<code>getReplaceEnd() == getReplaceStart()</code>),
1147:             * the completion string is to be inserted at this
1148:             * index.
1149:             * 
1150:             * @return replacement end position (exclusive)
1151:             */
1152:            public int getReplaceEnd() {
1153:                return this .replaceEnd;
1154:            }
1155:
1156:            /**
1157:             * Sets the character indices of the subrange in the
1158:             * source file buffer to be replaced by the completion
1159:             * string. If the subrange is empty
1160:             * (<code>startIndex == endIndex</code>),
1161:             * the completion string is to be inserted at this
1162:             * index.
1163:             * <p>
1164:             * If not set, defaults to empty subrange at [0,0).
1165:             * </p>
1166:             * <p>
1167:             * The completion engine creates instances of this class and sets
1168:             * its properties; this method is not intended to be used by other clients.
1169:             * </p>
1170:             * 
1171:             * @param startIndex character index of replacement start position (inclusive)
1172:             * @param endIndex character index of replacement end position (exclusive)
1173:             */
1174:            public void setReplaceRange(int startIndex, int endIndex) {
1175:                if (startIndex < 0 || endIndex < startIndex) {
1176:                    throw new IllegalArgumentException();
1177:                }
1178:                this .replaceStart = startIndex;
1179:                this .replaceEnd = endIndex;
1180:            }
1181:
1182:            /**
1183:             * Returns the relative relevance rating of this proposal.
1184:             * 
1185:             * @return relevance rating of this proposal; ratings are positive; higher means better
1186:             */
1187:            public int getRelevance() {
1188:                return this .relevance;
1189:            }
1190:
1191:            /**
1192:             * Sets the relative relevance rating of this proposal.
1193:             * <p>
1194:             * If not set, defaults to the lowest possible rating (1).
1195:             * </p>
1196:             * <p>
1197:             * The completion engine creates instances of this class and sets
1198:             * its properties; this method is not intended to be used by other clients.
1199:             * </p>
1200:             * 
1201:             * @param rating relevance rating of this proposal; ratings are positive; higher means better
1202:             */
1203:            public void setRelevance(int rating) {
1204:                if (rating <= 0) {
1205:                    throw new IllegalArgumentException();
1206:                }
1207:                this .relevance = rating;
1208:            }
1209:
1210:            /**
1211:             * Returns the type signature or package name of the relevant
1212:             * declaration in the context, or <code>null</code> if none.
1213:             * <p>
1214:             * This field is available for the following kinds of
1215:             * completion proposals:
1216:             * <ul>
1217:             *  <li><code>ANNOTATION_ATTRIBUT_REF</code> - type signature
1218:             * of the annotation that declares the attribute that is referenced</li>
1219:             * <li><code>ANONYMOUS_CLASS_DECLARATION</code> - type signature
1220:             * of the type that is being subclassed or implemented</li>
1221:             * 	<li><code>FIELD_IMPORT</code> - type signature
1222:             * of the type that declares the field that is imported</li>
1223:             *  <li><code>FIELD_REF</code> - type signature
1224:             * of the type that declares the field that is referenced</li>
1225:             * 	<li><code>METHOD_IMPORT</code> - type signature
1226:             * of the type that declares the method that is imported</li>
1227:             *  <li><code>METHOD_REF</code> - type signature
1228:             * of the type that declares the method that is referenced</li>
1229:             * 	<li><code>METHOD_DECLARATION</code> - type signature
1230:             * of the type that declares the method that is being
1231:             * implemented or overridden</li>
1232:             * 	<li><code>PACKAGE_REF</code> - dot-based package 
1233:             * name of the package that is referenced</li>
1234:             * 	<li><code>TYPE_IMPORT</code> - dot-based package 
1235:             * name of the package containing the type that is imported</li>
1236:             *  <li><code>TYPE_REF</code> - dot-based package 
1237:             * name of the package containing the type that is referenced</li>
1238:             *  <li><code>POTENTIAL_METHOD_DECLARATION</code> - type signature
1239:             * of the type that declares the method that is being created</li>
1240:             * </ul>
1241:             * For kinds of completion proposals, this method returns
1242:             * <code>null</code>. Clients must not modify the array
1243:             * returned.
1244:             * </p>
1245:             * 
1246:             * @return a type signature or a package name (depending
1247:             * on the kind of completion), or <code>null</code> if none
1248:             * @see Signature
1249:             */
1250:            public char[] getDeclarationSignature() {
1251:                return this .declarationSignature;
1252:            }
1253:
1254:            /**
1255:             * Returns the key of the relevant
1256:             * declaration in the context, or <code>null</code> if none.
1257:             * <p>
1258:             * This field is available for the following kinds of
1259:             * completion proposals:
1260:             * <ul>
1261:             * <li><code>ANONYMOUS_CLASS_DECLARATION</code> - key
1262:             * of the type that is being subclassed or implemented</li>
1263:             * 	<li><code>METHOD_DECLARATION</code> - key
1264:             * of the type that declares the method that is being
1265:             * implemented or overridden</li>
1266:             * </ul>
1267:             * For kinds of completion proposals, this method returns
1268:             * <code>null</code>. Clients must not modify the array
1269:             * returned.
1270:             * </p>
1271:             * 
1272:             * @return a key, or <code>null</code> if none
1273:             * @see org.eclipse.jdt.core.dom.ASTParser#createASTs(ICompilationUnit[], String[], org.eclipse.jdt.core.dom.ASTRequestor, IProgressMonitor)
1274:             * @since 3.1
1275:             */
1276:            public char[] getDeclarationKey() {
1277:                return this .declarationKey;
1278:            }
1279:
1280:            /**
1281:             * Sets the type or package signature of the relevant
1282:             * declaration in the context, or <code>null</code> if none.
1283:             * <p>
1284:             * If not set, defaults to none.
1285:             * </p>
1286:             * <p>
1287:             * The completion engine creates instances of this class and sets
1288:             * its properties; this method is not intended to be used by other clients.
1289:             * </p>
1290:             * 
1291:             * @param signature the type or package signature, or
1292:             * <code>null</code> if none
1293:             */
1294:            public void setDeclarationSignature(char[] signature) {
1295:                this .declarationSignature = signature;
1296:            }
1297:
1298:            /**
1299:             * Sets the type or package key of the relevant
1300:             * declaration in the context, or <code>null</code> if none.
1301:             * <p>
1302:             * If not set, defaults to none.
1303:             * </p>
1304:             * <p>
1305:             * The completion engine creates instances of this class and sets
1306:             * its properties; this method is not intended to be used by other clients.
1307:             * </p>
1308:             * 
1309:             * @param key the type or package key, or
1310:             * <code>null</code> if none
1311:             * @since 3.1
1312:             */
1313:            public void setDeclarationKey(char[] key) {
1314:                this .declarationKey = key;
1315:            }
1316:
1317:            /**
1318:             * Returns the simple name of the method, field,
1319:             * member, or variable relevant in the context, or
1320:             * <code>null</code> if none.
1321:             * <p>
1322:             * This field is available for the following kinds of
1323:             * completion proposals:
1324:             * <ul>
1325:             *  <li><code>ANNOTATION_ATTRIBUT_REF</code> - the name of the attribute</li>
1326:             * 	<li><code>FIELD_IMPORT</code> - the name of the field</li>
1327:             *  <li><code>FIELD_REF</code> - the name of the field</li>
1328:             * 	<li><code>KEYWORD</code> - the keyword</li>
1329:             * 	<li><code>LABEL_REF</code> - the name of the label</li>
1330:             * 	<li><code>LOCAL_VARIABLE_REF</code> - the name of the local variable</li>
1331:             * 	<li><code>METHOD_IMPORT</code> - the name of the method</li>
1332:             *  <li><code>METHOD_REF</code> - the name of the method (the type simple name for constructor)</li>
1333:             * 	<li><code>METHOD_DECLARATION</code> - the name of the method (the type simple name for constructor)</li>
1334:             * 	<li><code>VARIABLE_DECLARATION</code> - the name of the variable</li>
1335:             *  <li><code>POTENTIAL_METHOD_DECLARATION</code> - the name of the method</li>
1336:             * </ul>
1337:             * For kinds of completion proposals, this method returns
1338:             * <code>null</code>. Clients must not modify the array
1339:             * returned.
1340:             * </p>
1341:             * 
1342:             * @return the keyword, field, method, local variable, or member
1343:             * name, or <code>null</code> if none
1344:             */
1345:            public char[] getName() {
1346:                return this .name;
1347:            }
1348:
1349:            /**
1350:             * Sets the simple name of the method (type simple name for constructor), field,
1351:             * member, or variable relevant in the context, or
1352:             * <code>null</code> if none.
1353:             * <p>
1354:             * If not set, defaults to none.
1355:             * </p>
1356:             * <p>
1357:             * The completion engine creates instances of this class and sets
1358:             * its properties; this method is not intended to be used by other clients.
1359:             * </p>
1360:             * 
1361:             * @param name the keyword, field, method, local variable,
1362:             * or member name, or <code>null</code> if none
1363:             */
1364:            public void setName(char[] name) {
1365:                this .name = name;
1366:            }
1367:
1368:            /**
1369:             * Returns the signature of the method or type
1370:             * relevant in the context, or <code>null</code> if none.
1371:             * <p>
1372:             * This field is available for the following kinds of
1373:             * completion proposals:
1374:             * <ul>
1375:             * <li><code>ANNOTATION_ATTRIBUT_REF</code> - the type signature
1376:             * of the referenced attribute's type</li>
1377:             * <li><code>ANONYMOUS_CLASS_DECLARATION</code> - method signature
1378:             * of the constructor that is being invoked</li>
1379:             * 	<li><code>FIELD_IMPORT</code> - the type signature
1380:             * of the referenced field's type</li>
1381:             *  <li><code>FIELD_REF</code> - the type signature
1382:             * of the referenced field's type</li>
1383:             * 	<li><code>LOCAL_VARIABLE_REF</code> - the type signature
1384:             * of the referenced local variable's type</li>
1385:             * 	<li><code>METHOD_IMPORT</code> - method signature
1386:             * of the method that is imported</li>
1387:             *  <li><code>METHOD_REF</code> - method signature
1388:             * of the method that is referenced</li>
1389:             * 	<li><code>METHOD_DECLARATION</code> - method signature
1390:             * of the method that is being implemented or overridden</li>
1391:             * 	<li><code>TYPE_IMPORT</code> - type signature
1392:             * of the type that is imported</li>
1393:             * 	<li><code>TYPE_REF</code> - type signature
1394:             * of the type that is referenced</li>
1395:             * 	<li><code>VARIABLE_DECLARATION</code> - the type signature
1396:             * of the type of the variable being declared</li>
1397:             *  <li><code>POTENTIAL_METHOD_DECLARATION</code> - method signature
1398:             * of the method that is being created</li>
1399:             * </ul>
1400:             * For kinds of completion proposals, this method returns
1401:             * <code>null</code>. Clients must not modify the array
1402:             * returned.
1403:             * </p>
1404:             * 
1405:             * @return the signature, or <code>null</code> if none
1406:             * @see Signature
1407:             */
1408:            public char[] getSignature() {
1409:                return this .signature;
1410:            }
1411:
1412:            /**
1413:             * Returns the key relevant in the context,
1414:             * or <code>null</code> if none.
1415:             * <p>
1416:             * This field is available for the following kinds of
1417:             * completion proposals:
1418:             * <ul>
1419:             * <li><code>ANONYMOUS_CLASS_DECLARATION</code> - method key
1420:             * of the constructor that is being invoked, or <code>null</code> if
1421:             * the declaring type is an interface</li>
1422:             * 	<li><code>METHOD_DECLARATION</code> - method key
1423:             * of the method that is being implemented or overridden</li>
1424:             * </ul>
1425:             * For kinds of completion proposals, this method returns
1426:             * <code>null</code>. Clients must not modify the array
1427:             * returned.
1428:             * </p>
1429:             * 
1430:             * @return the key, or <code>null</code> if none
1431:             * @see org.eclipse.jdt.core.dom.ASTParser#createASTs(ICompilationUnit[], String[], org.eclipse.jdt.core.dom.ASTRequestor, IProgressMonitor)
1432:             * @since 3.1
1433:             */
1434:            public char[] getKey() {
1435:                return this .key;
1436:            }
1437:
1438:            //	/**
1439:            //	 * Returns the package name of the relevant
1440:            //	 * declaration in the context, or <code>null</code> if none.
1441:            //	 * <p>
1442:            //	 * This field is available for the following kinds of
1443:            //	 * completion proposals:
1444:            //	 * <ul>
1445:            //	 * <li><code>ANONYMOUS_CLASS_DECLARATION</code> - the dot-based package name
1446:            //	 * of the type that is being subclassed or implemented</li>
1447:            //	 * 	<li><code>FIELD_REF</code> - the dot-based package name
1448:            //	 * of the type that declares the field that is referenced</li>
1449:            //	 * 	<li><code>METHOD_REF</code> - the dot-based package name
1450:            //	 * of the type that declares the method that is referenced</li>
1451:            //	 * 	<li><code>METHOD_DECLARATION</code> - the dot-based package name
1452:            //	 * of the type that declares the method that is being
1453:            //	 * implemented or overridden</li>
1454:            //	 * </ul>
1455:            //	 * For kinds of completion proposals, this method returns
1456:            //	 * <code>null</code>. Clients must not modify the array
1457:            //	 * returned.
1458:            //	 * </p>
1459:            //	 * 
1460:            //	 * @return the dot-based package name, or
1461:            //	 * <code>null</code> if none
1462:            //	 * @see #getDeclarationSignature()
1463:            //	 * @see #getSignature()
1464:            //	 * 
1465:            //	 * @since 3.1
1466:            //	 */
1467:            //	public char[] getDeclarationPackageName() {
1468:            //		return this.declarationPackageName;
1469:            //	}
1470:            //	
1471:            //	/**
1472:            //	 * Returns the type name of the relevant
1473:            //	 * declaration in the context without the package fragment,
1474:            //	 * or <code>null</code> if none. 
1475:            //	 * <p>
1476:            //	 * This field is available for the following kinds of
1477:            //	 * completion proposals:
1478:            //	 * <ul>
1479:            //	 * <li><code>ANONYMOUS_CLASS_DECLARATION</code> - the dot-based type name
1480:            //	 * of the type that is being subclassed or implemented</li>
1481:            //	 * 	<li><code>FIELD_REF</code> - the dot-based type name
1482:            //	 * of the type that declares the field that is referenced
1483:            //	 * or an anonymous type instantiation ("new X(){}") if it is an anonymous type</li>
1484:            //	 * 	<li><code>METHOD_REF</code> - the dot-based type name
1485:            //	 * of the type that declares the method that is referenced
1486:            //	 * or an anonymous type instantiation ("new X(){}") if it is an anonymous type</li>
1487:            //	 * 	<li><code>METHOD_DECLARATION</code> - the dot-based type name
1488:            //	 * of the type that declares the method that is being
1489:            //	 * implemented or overridden</li>
1490:            //	 * </ul>
1491:            //	 * For kinds of completion proposals, this method returns
1492:            //	 * <code>null</code>. Clients must not modify the array
1493:            //	 * returned.
1494:            //	 * </p>
1495:            //	 * 
1496:            //	 * @return the dot-based package name, or
1497:            //	 * <code>null</code> if none
1498:            //	 * @see #getDeclarationSignature()
1499:            //	 * @see #getSignature()
1500:            //	 * 
1501:            //	 * @since 3.1
1502:            //	 */
1503:            //	public char[] getDeclarationTypeName() {
1504:            //		return this.declarationTypeName;
1505:            //	}
1506:            //	
1507:            //	/**
1508:            //	 * Returns the package name of the method or type
1509:            //	 * relevant in the context, or <code>null</code> if none.
1510:            //	 * <p>
1511:            //	 * This field is available for the following kinds of
1512:            //	 * completion proposals:
1513:            //	 * <ul>
1514:            //	 * 	<li><code>FIELD_REF</code> - the dot-based package name
1515:            //	 * of the referenced field's type</li>
1516:            //	 * 	<li><code>LOCAL_VARIABLE_REF</code> - the dot-based package name
1517:            //	 * of the referenced local variable's type</li>
1518:            //	 * 	<li><code>METHOD_REF</code> -  the dot-based package name
1519:            //	 * of the return type of the method that is referenced</li>
1520:            //	 * 	<li><code>METHOD_DECLARATION</code> - the dot-based package name
1521:            //	 * of the return type of the method that is being implemented
1522:            //	 * or overridden</li>
1523:            //	 * 	<li><code>PACKAGE_REF</code> - the dot-based package name
1524:            //	 * of the package that is referenced</li>
1525:            //	 * 	<li><code>TYPE_REF</code> - the dot-based package name
1526:            //	 * of the type that is referenced</li>
1527:            //	 * 	<li><code>VARIABLE_DECLARATION</code> - the dot-based package name
1528:            //	 * of the type of the variable being declared</li>
1529:            //	 * </ul>
1530:            //	 * For kinds of completion proposals, this method returns
1531:            //	 * <code>null</code>. Clients must not modify the array
1532:            //	 * returned.
1533:            //	 * </p>
1534:            //	 * 
1535:            //	 * @return the package name, or <code>null</code> if none
1536:            //	 * 
1537:            //	 * @see #getDeclarationSignature()
1538:            //	 * @see #getSignature()
1539:            //	 * 
1540:            //	 * @since 3.1
1541:            //	 */
1542:            //	public char[] getPackageName() {
1543:            //		return this.packageName;
1544:            //	}
1545:            //	
1546:            //	/**
1547:            //	 * Returns the type name without the package fragment of the method or type
1548:            //	 * relevant in the context, or <code>null</code> if none.
1549:            //	 * <p>
1550:            //	 * This field is available for the following kinds of
1551:            //	 * completion proposals:
1552:            //	 * <ul>
1553:            //	 * 	<li><code>FIELD_REF</code> - the dot-based type name
1554:            //	 * of the referenced field's type</li>
1555:            //	 * 	<li><code>LOCAL_VARIABLE_REF</code> - the dot-based type name
1556:            //	 * of the referenced local variable's type</li>
1557:            //	 * 	<li><code>METHOD_REF</code> -  the dot-based type name
1558:            //	 * of the return type of the method that is referenced</li>
1559:            //	 * 	<li><code>METHOD_DECLARATION</code> - the dot-based type name
1560:            //	 * of the return type of the method that is being implemented
1561:            //	 * or overridden</li>
1562:            //	 * 	<li><code>TYPE_REF</code> - the dot-based type name
1563:            //	 * of the type that is referenced</li>
1564:            //	 * 	<li><code>VARIABLE_DECLARATION</code> - the dot-based package name
1565:            //	 * of the type of the variable being declared</li>
1566:            //	 * </ul>
1567:            //	 * For kinds of completion proposals, this method returns
1568:            //	 * <code>null</code>. Clients must not modify the array
1569:            //	 * returned.
1570:            //	 * </p>
1571:            //	 * 
1572:            //	 * @return the package name, or <code>null</code> if none
1573:            //	 * 
1574:            //	 * @see #getDeclarationSignature()
1575:            //	 * @see #getSignature()
1576:            //	 * 
1577:            //	 * @since 3.1
1578:            //	 */
1579:            //	public char[] getTypeName() {
1580:            //		return this.typeName;
1581:            //	}
1582:            //	
1583:            //	/**
1584:            //	 * Returns the parameter package names of the method 
1585:            //	 * relevant in the context, or <code>null</code> if none.
1586:            //	 * <p>
1587:            //	 * This field is available for the following kinds of
1588:            //	 * completion proposals:
1589:            //	 * <ul>
1590:            //	 * 	<li><code>ANONYMOUS_CLASS_DECLARATION</code> - parameter package names
1591:            //	 * of the constructor that is being invoked</li>
1592:            //	 * 	<li><code>METHOD_REF</code> - parameter package names
1593:            //	 * of the method that is referenced</li>
1594:            //	 * 	<li><code>METHOD_DECLARATION</code> - parameter package names
1595:            //	 * of the method that is being implemented or overridden</li>
1596:            //	 * </ul>
1597:            //	 * For kinds of completion proposals, this method returns
1598:            //	 * <code>null</code>. Clients must not modify the array
1599:            //	 * returned.
1600:            //	 * </p>
1601:            //	 * 
1602:            //	 * @return the package name, or <code>null</code> if none
1603:            //	 * 
1604:            //	 * @see #getDeclarationSignature()
1605:            //	 * @see #getSignature()
1606:            //	 * 
1607:            //	 * @since 3.1
1608:            //	 */
1609:            //	public char[][] getParameterPackageNames() {
1610:            //		return this.parameterPackageNames;
1611:            //	}
1612:            //	
1613:            //	/**
1614:            //	 * Returns the parameter type names without the package fragment of
1615:            //	 * the method relevant in the context, or <code>null</code> if none.
1616:            //	 * <p>
1617:            //	 * This field is available for the following kinds of
1618:            //	 * completion proposals:
1619:            //	 * <ul>
1620:            //	 * 	<li><code>ANONYMOUS_CLASS_DECLARATION</code> - parameter type names
1621:            //	 * of the constructor that is being invoked</li>
1622:            //	 * 	<li><code>METHOD_REF</code> - parameter type names
1623:            //	 * of the method that is referenced</li>
1624:            //	 * 	<li><code>METHOD_DECLARATION</code> - parameter type names
1625:            //	 * of the method that is being implemented or overridden</li>
1626:            //	 * </ul>
1627:            //	 * For kinds of completion proposals, this method returns
1628:            //	 * <code>null</code>. Clients must not modify the array
1629:            //	 * returned.
1630:            //	 * </p>
1631:            //	 * 
1632:            //	 * @return the package name, or <code>null</code> if none
1633:            //	 * 
1634:            //	 * @see #getDeclarationSignature()
1635:            //	 * @see #getSignature()
1636:            //	 * 
1637:            //	 * @since 3.1
1638:            //	 */
1639:            //	public char[][] getParameterTypeNames() {
1640:            //		return this.parameterTypeNames;
1641:            //	}
1642:
1643:            /**
1644:             * Sets the signature of the method, field type, member type,
1645:             * relevant in the context, or <code>null</code> if none.
1646:             * <p>
1647:             * If not set, defaults to none.
1648:             * </p>
1649:             * <p>
1650:             * The completion engine creates instances of this class and sets
1651:             * its properties; this method is not intended to be used by other clients.
1652:             * </p>
1653:             * 
1654:             * @param signature the signature, or <code>null</code> if none
1655:             */
1656:            public void setSignature(char[] signature) {
1657:                this .signature = signature;
1658:            }
1659:
1660:            /**
1661:             * Sets the key of the method, field type, member type,
1662:             * relevant in the context, or <code>null</code> if none.
1663:             * <p>
1664:             * If not set, defaults to none.
1665:             * </p>
1666:             * <p>
1667:             * The completion engine creates instances of this class and sets
1668:             * its properties; this method is not intended to be used by other clients.
1669:             * </p>
1670:             * 
1671:             * @param key the key, or <code>null</code> if none
1672:             * @since 3.1
1673:             */
1674:            public void setKey(char[] key) {
1675:                this .key = key;
1676:            }
1677:
1678:            /**
1679:             * Returns the modifier flags relevant in the context, or
1680:             * <code>Flags.AccDefault</code> if none.
1681:             * <p>
1682:             * This field is available for the following kinds of
1683:             * completion proposals:
1684:             * <ul>
1685:             * <li><code>ANNOTATION_ATTRIBUT_REF</code> - modifier flags
1686:             * of the attribute that is referenced; 
1687:             * <li><code>ANONYMOUS_CLASS_DECLARATION</code> - modifier flags
1688:             * of the constructor that is referenced</li>
1689:             * 	<li><code>FIELD_IMPORT</code> - modifier flags
1690:             * of the field that is imported.</li>
1691:             *  <li><code>FIELD_REF</code> - modifier flags
1692:             * of the field that is referenced; 
1693:             * <code>Flags.AccEnum</code> can be used to recognize
1694:             * references to enum constants
1695:             * </li>
1696:             * 	<li><code>KEYWORD</code> - modifier flag
1697:             * corresponding to the modifier keyword</li>
1698:             * 	<li><code>LOCAL_VARIABLE_REF</code> - modifier flags
1699:             * of the local variable that is referenced</li>
1700:             *  <li><code>METHOD_IMPORT</code> - modifier flags
1701:             * of the method that is imported;
1702:             *  </li>
1703:             * 	<li><code>METHOD_REF</code> - modifier flags
1704:             * of the method that is referenced;
1705:             * <code>Flags.AccAnnotation</code> can be used to recognize
1706:             * references to annotation type members
1707:             * </li>
1708:             * <li><code>METHOD_DECLARATION</code> - modifier flags
1709:             * for the method that is being implemented or overridden</li>
1710:             * <li><code>TYPE_IMPORT</code> - modifier flags
1711:             * of the type that is imported; <code>Flags.AccInterface</code>
1712:             * can be used to recognize references to interfaces, 
1713:             * <code>Flags.AccEnum</code> enum types,
1714:             * and <code>Flags.AccAnnotation</code> annotation types</li>
1715:             * <li><code>TYPE_REF</code> - modifier flags
1716:             * of the type that is referenced; <code>Flags.AccInterface</code>
1717:             * can be used to recognize references to interfaces, 
1718:             * <code>Flags.AccEnum</code> enum types,
1719:             * and <code>Flags.AccAnnotation</code> annotation types
1720:             * </li>
1721:             * 	<li><code>VARIABLE_DECLARATION</code> - modifier flags
1722:             * for the variable being declared</li>
1723:             * 	<li><code>POTENTIAL_METHOD_DECLARATION</code> - modifier flags
1724:             * for the method that is being created</li>
1725:             * </ul>
1726:             * For other kinds of completion proposals, this method returns
1727:             * <code>Flags.AccDefault</code>.
1728:             * </p>
1729:             * 
1730:             * @return the modifier flags, or
1731:             * <code>Flags.AccDefault</code> if none
1732:             * @see Flags
1733:             */
1734:            public int getFlags() {
1735:                return this .flags;
1736:            }
1737:
1738:            /**
1739:             * Sets the modifier flags relevant in the context.
1740:             * <p>
1741:             * If not set, defaults to none.
1742:             * </p>
1743:             * <p>
1744:             * The completion engine creates instances of this class and sets
1745:             * its properties; this method is not intended to be used by other clients.
1746:             * </p>
1747:             * 
1748:             * @param flags the modifier flags, or
1749:             * <code>Flags.AccDefault</code> if none
1750:             */
1751:            public void setFlags(int flags) {
1752:                this .flags = flags;
1753:            }
1754:
1755:            /**
1756:             * Returns the required completion proposals.
1757:             * The proposal can be apply only if these required completion proposals are also applied.
1758:             * If the required proposal aren't applied the completion could create completion problems.
1759:             * 
1760:             * <p>
1761:             * This field is available for the following kinds of
1762:             * completion proposals:
1763:             * <ul>
1764:             * 	<li><code>FIELD_REF</code> - The allowed required proposals for this kind are:
1765:             *   <ul>
1766:             *    <li><code>TYPE_REF</code></li>
1767:             *    <li><code>TYPE_IMPORT</code></li>
1768:             *    <li><code>FIELD_IMPORT</code></li>
1769:             *   </ul>
1770:             * </li>
1771:             * 	<li><code>METHOD_REF</code> - The allowed required proposals for this kind are:
1772:             *   <ul>
1773:             *    <li><code>TYPE_REF</code></li>
1774:             *    <li><code>TYPE_IMPORT</code></li>
1775:             *    <li><code>METHOD_IMPORT</code></li>
1776:             *   </ul>
1777:             *  </li>
1778:             * </ul>
1779:             * </p>
1780:             * <p>
1781:             * Other kinds of required proposals will be returned in the future, therefore clients of this
1782:             * API must allow with {@link CompletionRequestor#setAllowsRequiredProposals(int, int, boolean)} 
1783:             * only kinds which are in this list to avoid unexpected results in the future.
1784:             * </p>
1785:             * <p>
1786:             * A required completion proposal cannot have required completion proposals.
1787:             * </p>
1788:             * 
1789:             * @return the required completion proposals, or <code>null</code> if none.
1790:             * 
1791:             * @see CompletionRequestor#setAllowsRequiredProposals(int, int,boolean)
1792:             * 
1793:             * @since 3.3
1794:             */
1795:            public CompletionProposal[] getRequiredProposals() {
1796:                return this .requiredProposals;
1797:            }
1798:
1799:            /**
1800:             * Sets the list of required completion proposals, or <code>null</code> if none.
1801:             * <p>
1802:             * If not set, defaults to none.
1803:             * </p>
1804:             * <p>
1805:             * The completion engine creates instances of this class and sets
1806:             * its properties; this method is not intended to be used by other clients.
1807:             * </p>
1808:             * 
1809:             * @param proposals the list of required completion proposals, or
1810:             * <code>null</code> if none
1811:             * @since 3.3
1812:             */
1813:            public void setRequiredProposals(CompletionProposal[] proposals) {
1814:                this .requiredProposals = proposals;
1815:            }
1816:
1817:            /**
1818:             * Finds the method parameter names.
1819:             * This information is relevant to method reference (and
1820:             * method declaration proposals). Returns <code>null</code>
1821:             * if not available or not relevant.
1822:             * <p>
1823:             * The client must not modify the array returned.
1824:             * </p>
1825:             * <p>
1826:             * <b>Note that this is an expensive thing to compute, which may require
1827:             * parsing Java source files, etc. Use sparingly.</b>
1828:             * </p>
1829:             * 
1830:             * @param monitor the progress monitor, or <code>null</code> if none
1831:             * @return the parameter names, or <code>null</code> if none
1832:             * or not available or not relevant
1833:             */
1834:            public char[][] findParameterNames(IProgressMonitor monitor) {
1835:                if (!this .parameterNamesComputed) {
1836:                    this .parameterNamesComputed = true;
1837:
1838:                    switch (this .completionKind) {
1839:                    case ANONYMOUS_CLASS_DECLARATION:
1840:                        try {
1841:                            this .parameterNames = this 
1842:                                    .findMethodParameterNames(
1843:                                            this .declarationPackageName,
1844:                                            this .declarationTypeName,
1845:                                            CharOperation.lastSegment(
1846:                                                    this .declarationTypeName,
1847:                                                    '.'),
1848:                                            Signature
1849:                                                    .getParameterTypes(this .originalSignature == null ? this .signature
1850:                                                            : this .originalSignature));
1851:                        } catch (IllegalArgumentException e) {
1852:                            // protection for invalid signature
1853:                            if (this .parameterTypeNames != null) {
1854:                                this .parameterNames = this 
1855:                                        .createDefaultParameterNames(this .parameterTypeNames.length);
1856:                            } else {
1857:                                this .parameterNames = null;
1858:                            }
1859:                        }
1860:                        break;
1861:                    case METHOD_REF:
1862:                        try {
1863:                            this .parameterNames = this 
1864:                                    .findMethodParameterNames(
1865:                                            this .declarationPackageName,
1866:                                            this .declarationTypeName,
1867:                                            this .name,
1868:                                            Signature
1869:                                                    .getParameterTypes(this .originalSignature == null ? this .signature
1870:                                                            : this .originalSignature));
1871:                        } catch (IllegalArgumentException e) {
1872:                            // protection for invalid signature
1873:                            if (this .parameterTypeNames != null) {
1874:                                this .parameterNames = this 
1875:                                        .createDefaultParameterNames(this .parameterTypeNames.length);
1876:                            } else {
1877:                                this .parameterNames = null;
1878:                            }
1879:                        }
1880:                        break;
1881:                    case METHOD_DECLARATION:
1882:                        try {
1883:                            this .parameterNames = this 
1884:                                    .findMethodParameterNames(
1885:                                            this .declarationPackageName,
1886:                                            this .declarationTypeName,
1887:                                            this .name,
1888:                                            Signature
1889:                                                    .getParameterTypes(this .originalSignature == null ? this .signature
1890:                                                            : this .originalSignature));
1891:                        } catch (IllegalArgumentException e) {
1892:                            // protection for invalid signature
1893:                            if (this .parameterTypeNames != null) {
1894:                                this .parameterNames = this 
1895:                                        .createDefaultParameterNames(this .parameterTypeNames.length);
1896:                            } else {
1897:                                this .parameterNames = null;
1898:                            }
1899:                        }
1900:                        if (this .parameterNames != null) {
1901:                            this .updateCompletion = true;
1902:                        }
1903:                        break;
1904:                    }
1905:                }
1906:                return this .parameterNames;
1907:            }
1908:
1909:            /**
1910:             * Sets the method parameter names.
1911:             * This information is relevant to method reference (and
1912:             * method declaration proposals).
1913:             * <p>
1914:             * The completion engine creates instances of this class and sets
1915:             * its properties; this method is not intended to be used by other clients.
1916:             * </p>
1917:             * 
1918:             * @param parameterNames the parameter names, or <code>null</code> if none
1919:             */
1920:            public void setParameterNames(char[][] parameterNames) {
1921:                this .parameterNames = parameterNames;
1922:                this .parameterNamesComputed = true;
1923:            }
1924:
1925:            /**
1926:             * Returns the accessibility of the proposal.
1927:             * <p>
1928:             * This field is available for the following kinds of
1929:             * completion proposals:
1930:             * <ul>
1931:             * 	<li><code>TYPE_REF</code> - accessibility of the type</li>
1932:             * </ul>
1933:             * For these kinds of completion proposals, this method returns
1934:             * {@link IAccessRule#K_ACCESSIBLE} or {@link IAccessRule#K_DISCOURAGED}
1935:             * or {@link IAccessRule#K_NON_ACCESSIBLE}.
1936:             * By default this method return {@link IAccessRule#K_ACCESSIBLE}.
1937:             * </p>
1938:             * 
1939:             * @see IAccessRule
1940:             * 
1941:             * @return the accessibility of the proposal
1942:             * 
1943:             * @since 3.1
1944:             */
1945:            public int getAccessibility() {
1946:                return this .accessibility;
1947:            }
1948:
1949:            /**
1950:             * Returns whether this proposal is a constructor.
1951:             * <p>
1952:             * This field is available for the following kinds of
1953:             * completion proposals:
1954:             * <ul>
1955:             * <li><code>METHOD_REF</code> - return <code>true</code>
1956:             * if the referenced method is a constructor</li>
1957:             * 	<li><code>METHOD_DECLARATION</code> - return <code>true</code>
1958:             * if the declared method is a constructor</li>
1959:             * </ul>
1960:             * For kinds of completion proposals, this method returns
1961:             * <code>false</code>.
1962:             * </p>
1963:             * 
1964:             * @return <code>true</code> if the proposal is a constructor.
1965:             * @since 3.1
1966:             */
1967:            public boolean isConstructor() {
1968:                return this .isConstructor;
1969:            }
1970:
1971:            public String toString() {
1972:                StringBuffer buffer = new StringBuffer();
1973:                buffer.append('[');
1974:                switch (this .completionKind) {
1975:                case CompletionProposal.ANONYMOUS_CLASS_DECLARATION:
1976:                    buffer.append("ANONYMOUS_CLASS_DECLARATION"); //$NON-NLS-1$
1977:                    break;
1978:                case CompletionProposal.FIELD_REF:
1979:                    buffer.append("FIELD_REF"); //$NON-NLS-1$
1980:                    break;
1981:                case CompletionProposal.KEYWORD:
1982:                    buffer.append("KEYWORD"); //$NON-NLS-1$
1983:                    break;
1984:                case CompletionProposal.LABEL_REF:
1985:                    buffer.append("LABEL_REF"); //$NON-NLS-1$
1986:                    break;
1987:                case CompletionProposal.LOCAL_VARIABLE_REF:
1988:                    buffer.append("LOCAL_VARIABLE_REF"); //$NON-NLS-1$
1989:                    break;
1990:                case CompletionProposal.METHOD_DECLARATION:
1991:                    buffer.append("METHOD_DECLARATION"); //$NON-NLS-1$
1992:                    if (this .isConstructor) {
1993:                        buffer.append("<CONSTRUCTOR>"); //$NON-NLS-1$
1994:                    }
1995:                    break;
1996:                case CompletionProposal.METHOD_REF:
1997:                    buffer.append("METHOD_REF"); //$NON-NLS-1$
1998:                    if (this .isConstructor) {
1999:                        buffer.append("<CONSTRUCTOR>"); //$NON-NLS-1$
2000:                    }
2001:                    break;
2002:                case CompletionProposal.PACKAGE_REF:
2003:                    buffer.append("PACKAGE_REF"); //$NON-NLS-1$
2004:                    break;
2005:                case CompletionProposal.TYPE_REF:
2006:                    buffer.append("TYPE_REF"); //$NON-NLS-1$
2007:                    break;
2008:                case CompletionProposal.VARIABLE_DECLARATION:
2009:                    buffer.append("VARIABLE_DECLARATION"); //$NON-NLS-1$
2010:                    break;
2011:                case CompletionProposal.POTENTIAL_METHOD_DECLARATION:
2012:                    buffer.append("POTENTIAL_METHOD_DECLARATION"); //$NON-NLS-1$
2013:                    break;
2014:                case CompletionProposal.METHOD_NAME_REFERENCE:
2015:                    buffer.append("METHOD_IMPORT"); //$NON-NLS-1$
2016:                    break;
2017:                case CompletionProposal.ANNOTATION_ATTRIBUTE_REF:
2018:                    buffer.append("ANNOTATION_ATTRIBUTE_REF"); //$NON-NLS-1$
2019:                    break;
2020:                case CompletionProposal.JAVADOC_BLOCK_TAG:
2021:                    buffer.append("JAVADOC_BLOCK_TAG"); //$NON-NLS-1$
2022:                    break;
2023:                case CompletionProposal.JAVADOC_INLINE_TAG:
2024:                    buffer.append("JAVADOC_INLINE_TAG"); //$NON-NLS-1$
2025:                    break;
2026:                case CompletionProposal.JAVADOC_FIELD_REF:
2027:                    buffer.append("JAVADOC_FIELD_REF"); //$NON-NLS-1$
2028:                    break;
2029:                case CompletionProposal.JAVADOC_METHOD_REF:
2030:                    buffer.append("JAVADOC_METHOD_REF"); //$NON-NLS-1$
2031:                    break;
2032:                case CompletionProposal.JAVADOC_TYPE_REF:
2033:                    buffer.append("JAVADOC_TYPE_REF"); //$NON-NLS-1$
2034:                    break;
2035:                case CompletionProposal.JAVADOC_PARAM_REF:
2036:                    buffer.append("JAVADOC_PARAM_REF"); //$NON-NLS-1$
2037:                    break;
2038:                case CompletionProposal.JAVADOC_VALUE_REF:
2039:                    buffer.append("JAVADOC_VALUE_REF"); //$NON-NLS-1$
2040:                    break;
2041:                case CompletionProposal.FIELD_IMPORT:
2042:                    buffer.append("FIELD_IMPORT"); //$NON-NLS-1$
2043:                    break;
2044:                case CompletionProposal.METHOD_IMPORT:
2045:                    buffer.append("METHOD_IMPORT"); //$NON-NLS-1$
2046:                    break;
2047:                case CompletionProposal.TYPE_IMPORT:
2048:                    buffer.append("TYPE_IMPORT"); //$NON-NLS-1$
2049:                    break;
2050:                default:
2051:                    buffer.append("PROPOSAL"); //$NON-NLS-1$
2052:                    break;
2053:
2054:                }
2055:                buffer.append("]{completion:"); //$NON-NLS-1$
2056:                if (this .completion != null)
2057:                    buffer.append(this .completion);
2058:                buffer.append(", declSign:"); //$NON-NLS-1$
2059:                if (this .declarationSignature != null)
2060:                    buffer.append(this .declarationSignature);
2061:                buffer.append(", sign:"); //$NON-NLS-1$
2062:                if (this .signature != null)
2063:                    buffer.append(this .signature);
2064:                buffer.append(", declKey:"); //$NON-NLS-1$
2065:                if (this .declarationKey != null)
2066:                    buffer.append(this .declarationKey);
2067:                buffer.append(", key:"); //$NON-NLS-1$
2068:                if (this .key != null)
2069:                    buffer.append(key);
2070:                buffer.append(", name:"); //$NON-NLS-1$
2071:                if (this .name != null)
2072:                    buffer.append(this .name);
2073:                buffer.append(", ["); //$NON-NLS-1$
2074:                buffer.append(this .replaceStart);
2075:                buffer.append(',');
2076:                buffer.append(this .replaceEnd);
2077:                buffer.append("], relevance="); //$NON-NLS-1$
2078:                buffer.append(this .relevance);
2079:                buffer.append('}');
2080:                return buffer.toString();
2081:            }
2082:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.