Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2004, 2011 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html Contributors: IBM Corporation - initial API and implementation Andreas Magnusson <andreas.ch.magnusson@gmail.com>- contribution for bug 151500 /
  
  package org.eclipse.jdt.internal.codeassist;
  
  import  org.eclipse.core.runtime.IProgressMonitor;
Internal completion proposal

Since:
3.1
  
  public class InternalCompletionProposal extends CompletionProposal {
  	private static Object NO_ATTACHED_SOURCE = new Object();
  	
  	protected NameLookup nameLookup;
  
  	protected char[] declarationPackageName;
  	protected char[] declarationTypeName;
  	protected char[] packageName;
  	protected char[] typeName;
  	protected char[][] parameterPackageNames;
  	protected char[][] parameterTypeNames;
  
  	protected char[] originalSignature;
  
  	private boolean hasNoParameterNamesFromIndex = false;
  	private boolean updateCompletion = false;
  
  	protected int accessibility = .;
  
  	protected boolean isConstructor = false;

Kind of completion request.
  
  	private int completionKind;

Offset in original buffer where ICodeAssist.codeComplete() was requested.
  
  	private int completionLocation;

Start position (inclusive) of source range in original buffer containing the relevant token defaults to empty subrange at [0,0).
  
  	private int tokenStart = 0;

End position (exclusive) of source range in original buffer containing the relevant token; defaults to empty subrange at [0,0).
  
  	private int tokenEnd = 0;

Completion string; defaults to empty string.
  
  	private char[] completion = .;

Start position (inclusive) of source range in original buffer to be replaced by completion string; defaults to empty subrange at [0,0).
  
  	private int replaceStart = 0;

End position (exclusive) of source range in original buffer to be replaced by completion string; defaults to empty subrange at [0,0).
 
 	private int replaceEnd = 0;

Relevance rating; positive; higher means better; defaults to minimum rating.
 
 	private int relevance = 1;

Signature of the relevant package or type declaration in the context, or null if none. Defaults to null.
 
 	private char[] declarationSignature = null;

Unique key of the relevant package or type declaration in the context, or null if none. Defaults to null.
 
 	private char[] declarationKey = null;

Simple name of the method, field, member, or variable relevant in the context, or null if none. Defaults to null.
 
 	private char[] name = null;

Signature of the method, field type, member type, relevant in the context, or null if none. Defaults to null.
 
 	private char[] signature = null;

Unique of the method, field type, member type, relevant in the context, or null if none. Defaults to null.
 
 	private char[] key = null;

Array of required completion proposals, or null if none. The proposal can not be applied if the required proposals aren't applied. Defaults to null.
 
Modifier flags relevant in the context, or Flags.AccDefault if none. Defaults to Flags.AccDefault.
 
 	private int flags = .;

Completion flags relevant in the context, or CompletionFlags.Default if none. Defaults to CompletionFlags.Default.
 
Parameter names (for method completions), or null if none. Lazily computed. Defaults to null.
 
 	private char[][] parameterNames = null;

Indicates whether parameter names have been computed.
 
 	private boolean parameterNamesComputed = false;
 	
 	protected char[][] findConstructorParameterNames(char[] declaringTypePackageNamechar[] declaringTypeNamechar[] selectorchar[][] paramTypeNames){
 		if(paramTypeNames == null || declaringTypeName == nullreturn null;
 
 		char[][] parameters = null;
 		int length = paramTypeNames.length;
 
 		char[] tName = CharOperation.concat(declaringTypePackageName,declaringTypeName,'.');
 		Object cachedType = this...get(tName);
 
 		IType type = null;
 		if(cachedType != null) {
 			if(cachedType !=  && cachedType instanceof BinaryType) {
 				type = (BinaryType)cachedType;
 			}
 		} else {
 			// TODO (david) shouldn't it be NameLookup.ACCEPT_ALL ?
 			NameLookup.Answer answer = this..findType(new String(declaringTypeName),
 				new String(declaringTypePackageName),
 				false,
 				true/* consider secondary types */,
 				false/* do NOT wait for indexes */,
 				false/*don't check restrictions*/,
 				null);
 			type = answer == null ? null : answer.type;
 			if(type instanceof BinaryType){
 				this...put(tNametype);
 			} else {
 				type = null;
 			}
 		}
 
 		if(type != null) {
 			// https://bugs.eclipse.org/bugs/show_bug.cgi?id=316937
 			// BinaryType#getMethod() creates a new instance of BinaryMethod, which is a dummy.
 			// Instead we have to use IType#findMethods() to get a handle to the method of our interest.
 			try {
 				IMethod method = findMethod(typeselectorparamTypeNames);
 
 					if (packageFragmentRoot.isArchive() ||
 						SourceMapper mapper = ((JavaElement)method).getSourceMapper();
 						if (mapper != null) {
 							char[][] paramNames = mapper.getMethodParameterNames(method);
 
 							// map source and try to find parameter names
 							if(paramNames == null) {
 								if (!packageFragmentRoot.isArchive()) this..++;
 								char[] source = mapper.findSource(typeinfo);
 								if (source != null){
 									mapper.mapSource(typesourceinfo);
 								}
 								paramNames = mapper.getMethodParameterNames(method);
 							}
 
 							if(paramNames != null) {
 								parameters = paramNames;
 							}
 						}
 					}
 				} else {
 					char[][] argumentNames = info.getArgumentNames();
 					if (argumentNames != null && argumentNames.length == length) {
 						parameters = argumentNames;
 						return parameters;
 					}
 
 					parameters = new char[length][];
 					String[] params = method.getParameterNames();
 					for(int i = 0;	ilength ; i++){
 						parameters[i] = params[i].toCharArray();
 					}
 				}
 			} catch(JavaModelException e){
 				parameters = null;
 			}
 		}
 
 		// default parameters name
 		if(parameters == null) {
 			parameters = CompletionEngine.createDefaultParameterNames(length);
 		}
 
 		return parameters;
 	}
 	
 	protected char[][] findMethodParameterNames(char[] declaringTypePackageNamechar[] declaringTypeNamechar[] selectorchar[][] paramTypeNames){
 		if(paramTypeNames == null || declaringTypeName == nullreturn null;
 
 		char[][] parameters = null;
 		int length = paramTypeNames.length;
 
 		char[] tName = CharOperation.concat(declaringTypePackageName,declaringTypeName,'.');
 		Object cachedType = this...get(tName);
 
 		IType type = null;
 		if(cachedType != null) {
 			if(cachedType !=  && cachedType instanceof BinaryType) {
 				type = (BinaryType)cachedType;
 			}
 		} else {
 			// TODO (david) shouldn't it be NameLookup.ACCEPT_ALL ?
 			NameLookup.Answer answer = this..findType(new String(declaringTypeName),
 				new String(declaringTypePackageName),
 				false,
 				true/* consider secondary types */,
 				false/* do NOT wait for indexes */,
 				false/*don't check restrictions*/,
 				null);
 			type = answer == null ? null : answer.type;
 			if(type instanceof BinaryType){
 				this...put(tNametype);
 			} else {
 				type = null;
 			}
 		}
 
 		if(type != null) {
 			// https://bugs.eclipse.org/bugs/show_bug.cgi?id=316937
 			// BinaryType#getMethod() creates a new instance of BinaryMethod, which is a dummy.
 			// Instead we have to use IType#findMethods() to get a handle to the method of our interest.
 			try{
 				IMethod method = findMethod(typeselectorparamTypeNames);
 				parameters = new char[length][];
 				String[] params = method.getParameterNames();
 				for(int i = 0;	ilength ; i++){
 					parameters[i] = params[i].toCharArray();
 				}
 			} catch(JavaModelException e){
 				parameters = null;
 			}
 		}
 
 		// default parameters name
 		if(parameters == null) {
 			parameters = CompletionEngine.createDefaultParameterNames(length);
 		}
 
 		return parameters;
 	}
 
 	private IMethod findMethod(IType typechar[] selectorchar[][] paramTypeNamesthrows JavaModelException {
 		IMethod method = null;
 		int startingIndex = 0;
 		String[] args;
 		IType enclosingType = type.getDeclaringType();
 		// If the method is a constructor of a non-static inner type, add the enclosing type as an 
 		// additional parameter to the constructor
 		if (enclosingType != null
 				&& CharOperation.equals(type.getElementName().toCharArray(), selector)
 				&& !Flags.isStatic(type.getFlags())) {
 			args = new String[paramTypeNames.length+1];
 			startingIndex = 1;
 			args[0] = Signature.createTypeSignature(enclosingType.getFullyQualifiedName(), true);
 		} else {
 			args = new String[paramTypeNames.length];
 		}
 		int length = args.length;
 		for(int i = startingIndex;	ilength ; i++){
 			args[i] = new String(paramTypeNames[i-startingIndex]);
 		}
 		method = type.getMethod(new String(selector), args);
 		
 		IMethod[] methods = type.findMethods(method);
 		if (methods != null && methods.length > 0) {
 			method = methods[0];
 		}
 		return method;
 	}
 
 	protected char[] getDeclarationPackageName() {
 		return this.;
 	}
 
 	protected char[] getDeclarationTypeName() {
 		return this.;
 	}
 	
 	private int getOpenedBinaryTypesThreshold() {
 		return JavaModelManager.getJavaModelManager().getOpenableCacheSize() / 10;
 	}
 
 	protected char[] getPackageName() {
 		return this.;
 	}
 
 	protected char[] getTypeName() {
 		return this.;
 	}
 
 	protected char[][] getParameterPackageNames() {
 		return this.;
 	}
 
 
 	protected char[][] getParameterTypeNames() {
 		return this.;
 	}
 
 	protected void setDeclarationPackageName(char[] declarationPackageName) {
 		this. = declarationPackageName;
 	}
 
 	protected void setDeclarationTypeName(char[] declarationTypeName) {
 		this. = declarationTypeName;
 	}
 
 	protected void setPackageName(char[] packageName) {
 		this. = packageName;
 	}
 
 	protected void setTypeName(char[] typeName) {
 		this. = typeName;
 	}
 
 	protected void setParameterPackageNames(char[][] parameterPackageNames) {
 		this. = parameterPackageNames;
 	}
 
 	protected void setParameterTypeNames(char[][] parameterTypeNames) {
 		this. = parameterTypeNames;
 	}
 
 	protected void setAccessibility(int kind) {
 		this. = kind;
 	}
 
 	protected void setIsContructor(boolean isConstructor) {
 		this. = isConstructor;
 	}
 	public void setOriginalSignature(char[] originalSignature) {
 		this. = originalSignature;
 	}
Creates a basic completion proposal. All instance field have plausible default values unless otherwise noted.

Note that the constructors for this class are internal to the Java model implementation. Clients cannot directly create CompletionProposal objects.

Parameters:
kind one of the kind constants declared on this class
completionLocation original offset of code completion request
 
 	public InternalCompletionProposal(int kindint completionLocation) {
 		if ((kind < )
 				|| (kind > )) {
 			throw new IllegalArgumentException();
 		}
 		if (this. == null || completionLocation < 0) {
 			// Work around for bug 132558 (https://bugs.eclipse.org/bugs/show_bug.cgi?id=132558).
 			// completionLocation can be -1 if the completion occur at the start of a file or
 			// the start of a code snippet but this API isn't design to support negative position.
 			if(this. == null || completionLocation != -1) {
 				throw new IllegalArgumentException();
 			}
 			completionLocation = 0;
 		}
 		this. = kind;
 		this. = completionLocation;
 	}

Returns the completion flags relevant in the context, or CompletionFlags.Default if none.

This field is available for the following kinds of completion proposals:

  • FIELD_IMPORT - completion flags of the attribute that is referenced. Completion flags for this proposal kind can only include CompletionFlags.StaticImport
  • METHOD_IMPORT - completion flags of the attribute that is referenced. Completion flags for this proposal kind can only include CompletionFlags.StaticImport
  • TYPE_IMPORT - completion flags of the attribute that is referenced. Completion flags for this proposal kind can only include CompletionFlags.StaticImport
For other kinds of completion proposals, this method returns CompletionFlags.Default.

Returns:
the completion flags, or CompletionFlags.Default if none
Since:
3.3
See also:
CompletionFlags
 
 	public int getAdditionalFlags() {
 		return this.;
 	}

Sets the completion flags relevant in the context.

If not set, defaults to none.

The completion engine creates instances of this class and sets its properties; this method is not intended to be used by other clients.

Parameters:
additionalFlags the completion flags, or CompletionFlags.Default if none
Since:
3.3
 
 	public void setAdditionalFlags(int additionalFlags) {
 		this. = additionalFlags;
 	}

Returns the kind of completion being proposed.

The set of different kinds of completion proposals is expected to change over time. It is strongly recommended that clients do not assume that the kind is one of the ones they know about, and code defensively for the possibility of unexpected future growth.

Returns:
the kind; one of the kind constants declared on this class, or possibly a kind unknown to the caller
 
 	public int getKind() {
 		return this.;
 	}

Returns the character index in the source file buffer where source completion was requested (the offset parameter to ICodeAssist.codeComplete minus one).

Returns:
character index in source file buffer
See also:
ICodeAssist.codeComplete(int,CompletionRequestor)
 
 	// TODO (david) https://bugs.eclipse.org/bugs/show_bug.cgi?id=132558
 	public int getCompletionLocation() {
 		return this.;
 	}

Returns the character index of the start of the subrange in the source file buffer containing the relevant token being completed. This token is either the identifier or Java language keyword under, or immediately preceding, the original request offset. If the original request offset is not within or immediately after an identifier or keyword, then the position returned is original request offset and the token range is empty.

Returns:
character index of token start position (inclusive)
 
 	public int getTokenStart() {
 		return this.;
 	}

Returns the character index of the end (exclusive) of the subrange in the source file buffer containing the relevant token. When there is no relevant token, the range is empty (getEndToken() == getStartToken()).

Returns:
character index of token end position (exclusive)
 
 	public int getTokenEnd() {
 		return this.;
 	}

Sets the character indices of the subrange in the source file buffer containing the relevant token being completed. This token is either the identifier or Java language keyword under, or immediately preceding, the original request offset. If the original request offset is not within or immediately after an identifier or keyword, then the source range begins at original request offset and is empty.

If not set, defaults to empty subrange at [0,0).

Parameters:
startIndex character index of token start position (inclusive)
endIndex character index of token end position (exclusive)
 
 	public void setTokenRange(int startIndexint endIndex) {
 		if (startIndex < 0 || endIndex < startIndex) {
 			throw new IllegalArgumentException();
 		}
 		this. = startIndex;
 		this. = endIndex;
 	}

Returns the proposed sequence of characters to insert into the source file buffer, replacing the characters at the specified source range. The string can be arbitrary; for example, it might include not only the name of a method but a set of parentheses.

The client must not modify the array returned.

Returns:
the completion string
 
 	public char[] getCompletion() {
 			if(this.) {
 				this. = false;
 
 				if(this. != null) {
 					int length = this..length;
 					StringBuffer completionBuffer = new StringBuffer(this..length);
 
 					int start = 0;
 					int end = CharOperation.indexOf('%'this.);
 
 					completionBuffer.append(this.startend - start);
 
 					for(int i = 0 ; i < length ; i++){
 						completionBuffer.append(this.[i]);
 						start = end + 1;
 						end = CharOperation.indexOf('%'this.start);
 						if(end > -1){
 							completionBuffer.append(this.startend - start);
 						} else {
 							completionBuffer.append(this.startthis..length - start);
 						}
 					}
 					int nameLength = completionBuffer.length();
 					this. = new char[nameLength];
 					completionBuffer.getChars(0, nameLengththis., 0);
 				}
 			}
 		}
 		return this.;
 	}

Sets the proposed sequence of characters to insert into the source file buffer, replacing the characters at the specified source range. The string can be arbitrary; for example, it might include not only the name of a method but a set of parentheses.

If not set, defaults to an empty character array.

The completion engine creates instances of this class and sets its properties; this method is not intended to be used by other clients.

Parameters:
completion the completion string
 
 	public void setCompletion(char[] completion) {
 		this. = completion;
 	}

Returns the character index of the start of the subrange in the source file buffer to be replaced by the completion string. If the subrange is empty (getReplaceEnd() == getReplaceStart()), the completion string is to be inserted at this index.

Note that while the token subrange is precisely specified, the replacement range is loosely constrained and may not bear any direct relation to the original request offset. For example, it would be possible for a type completion to propose inserting an import declaration at the top of the compilation unit; or the completion might include trailing parentheses and punctuation for a method completion.

Returns:
replacement start position (inclusive)
 
 	public int getReplaceStart() {
 		return this.;
 	}

Returns the character index of the end of the subrange in the source file buffer to be replaced by the completion string. If the subrange is empty (getReplaceEnd() == getReplaceStart()), the completion string is to be inserted at this index.

Returns:
replacement end position (exclusive)
 
 	public int getReplaceEnd() {
 		return this.;
 	}

Sets the character indices of the subrange in the source file buffer to be replaced by the completion string. If the subrange is empty (startIndex == endIndex), the completion string is to be inserted at this index.

If not set, defaults to empty subrange at [0,0).

The completion engine creates instances of this class and sets its properties; this method is not intended to be used by other clients.

Parameters:
startIndex character index of replacement start position (inclusive)
endIndex character index of replacement end position (exclusive)
 
 	public void setReplaceRange(int startIndexint endIndex) {
 		if (startIndex < 0 || endIndex < startIndex) {
 			throw new IllegalArgumentException();
 		}
 		this. = startIndex;
 		this. = endIndex;
 	}

Returns the relative relevance rating of this proposal.

Returns:
relevance rating of this proposal; ratings are positive; higher means better
 
 	public int getRelevance() {
 		return this.;
 	}

Sets the relative relevance rating of this proposal.

If not set, defaults to the lowest possible rating (1).

The completion engine creates instances of this class and sets its properties; this method is not intended to be used by other clients.

Parameters:
rating relevance rating of this proposal; ratings are positive; higher means better
 
 	public void setRelevance(int rating) {
 		if (rating <= 0) {
 			throw new IllegalArgumentException();
 		}
 		this. = rating;
 	}

Returns the type signature or package name of the relevant declaration in the context, or null if none.

This field is available for the following kinds of completion proposals:

  • ANNOTATION_ATTRIBUT_REF - type signature of the annotation that declares the attribute that is referenced
  • ANONYMOUS_CLASS_DECLARATION - type signature of the type that is being subclassed or implemented
  • FIELD_IMPORT - type signature of the type that declares the field that is imported
  • FIELD_REF - type signature of the type that declares the field that is referenced
  • FIELD_REF_WITH_CASTED_RECEIVER - type signature of the type that declares the field that is referenced
  • METHOD_IMPORT - type signature of the type that declares the method that is imported
  • METHOD_REF - type signature of the type that declares the method that is referenced
  • METHOD_REF_WITH_CASTED_RECEIVER - type signature of the type that declares the method that is referenced
  • METHOD_DECLARATION - type signature of the type that declares the method that is being implemented or overridden
  • PACKAGE_REF - dot-based package name of the package that is referenced
  • TYPE_IMPORT - dot-based package name of the package containing the type that is imported
  • TYPE_REF - dot-based package name of the package containing the type that is referenced
  • POTENTIAL_METHOD_DECLARATION - type signature of the type that declares the method that is being created
For kinds of completion proposals, this method returns null. Clients must not modify the array returned.

Returns:
a type signature or a package name (depending on the kind of completion), or null if none
See also:
Signature
 
 	public char[] getDeclarationSignature() {
 		return this.;
 	}

Returns the key of the relevant declaration in the context, or null if none.

This field is available for the following kinds of completion proposals:

  • ANONYMOUS_CLASS_DECLARATION - key of the type that is being subclassed or implemented
  • METHOD_DECLARATION - key of the type that declares the method that is being implemented or overridden
For kinds of completion proposals, this method returns null. Clients must not modify the array returned.

Returns:
a key, or null if none
Since:
3.1
See also:
org.eclipse.jdt.core.dom.ASTParser.createASTs(ICompilationUnit[], String[], org.eclipse.jdt.core.dom.ASTRequestor, IProgressMonitor)
 
 	public char[] getDeclarationKey() {
 		return this.;
 	}

Sets the type or package signature of the relevant declaration in the context, or null if none.

If not set, defaults to none.

The completion engine creates instances of this class and sets its properties; this method is not intended to be used by other clients.

Parameters:
signature the type or package signature, or null if none
 
 	public void setDeclarationSignature(char[] signature) {
 		this. = signature;
 	}

Sets the type or package key of the relevant declaration in the context, or null if none.

If not set, defaults to none.

The completion engine creates instances of this class and sets its properties; this method is not intended to be used by other clients.

Parameters:
key the type or package key, or null if none
Since:
3.1
 
 	public void setDeclarationKey(char[] key) {
 		this. = key;
 	}

Returns the simple name of the method, field, member, or variable relevant in the context, or null if none.

This field is available for the following kinds of completion proposals:

  • ANNOTATION_ATTRIBUT_REF - the name of the attribute
  • FIELD_IMPORT - the name of the field
  • FIELD_REF - the name of the field
  • FIELD_REF_WITH_CASTED_RECEIVER - the name of the field
  • KEYWORD - the keyword
  • LABEL_REF - the name of the label
  • LOCAL_VARIABLE_REF - the name of the local variable
  • METHOD_IMPORT - the name of the method
  • METHOD_REF - the name of the method (the type simple name for constructor)
  • METHOD_REF_WITH_CASTED_RECEIVER - the name of the method
  • METHOD_DECLARATION - the name of the method (the type simple name for constructor)
  • VARIABLE_DECLARATION - the name of the variable
  • POTENTIAL_METHOD_DECLARATION - the name of the method
For kinds of completion proposals, this method returns null. Clients must not modify the array returned.

Returns:
the keyword, field, method, local variable, or member name, or null if none
 
 	public char[] getName() {
 		return this.;
 	}


Sets the simple name of the method (type simple name for constructor), field, member, or variable relevant in the context, or null if none.

If not set, defaults to none.

The completion engine creates instances of this class and sets its properties; this method is not intended to be used by other clients.

Parameters:
name the keyword, field, method, local variable, or member name, or null if none
 
 	public void setName(char[] name) {
 		this. = name;
 	}

Returns the signature of the method or type relevant in the context, or null if none.

This field is available for the following kinds of completion proposals:

  • ANNOTATION_ATTRIBUT_REF - the type signature of the referenced attribute's type
  • ANONYMOUS_CLASS_DECLARATION - method signature of the constructor that is being invoked
  • FIELD_IMPORT - the type signature of the referenced field's type
  • FIELD_REF - the type signature of the referenced field's type
  • FIELD_REF_WITH_CASTED_RECEIVER - the type signature of the referenced field's type
  • LOCAL_VARIABLE_REF - the type signature of the referenced local variable's type
  • METHOD_IMPORT - method signature of the method that is imported
  • METHOD_REF - method signature of the method that is referenced
  • METHOD_REF_WITH_CASTED_RECEIVER - method signature of the method that is referenced
  • METHOD_DECLARATION - method signature of the method that is being implemented or overridden
  • TYPE_IMPORT - type signature of the type that is imported
  • TYPE_REF - type signature of the type that is referenced
  • VARIABLE_DECLARATION - the type signature of the type of the variable being declared
  • POTENTIAL_METHOD_DECLARATION - method signature of the method that is being created
For kinds of completion proposals, this method returns null. Clients must not modify the array returned.

Returns:
the signature, or null if none
See also:
Signature
 
 	public char[] getSignature() {
 		return this.;
 	}

Returns the key relevant in the context, or null if none.

This field is available for the following kinds of completion proposals:

  • ANONYMOUS_CLASS_DECLARATION - method key of the constructor that is being invoked, or null if the declaring type is an interface
  • METHOD_DECLARATION - method key of the method that is being implemented or overridden
For kinds of completion proposals, this method returns null. Clients must not modify the array returned.

Returns:
the key, or null if none
Since:
3.1
See also:
org.eclipse.jdt.core.dom.ASTParser.createASTs(ICompilationUnit[], String[], org.eclipse.jdt.core.dom.ASTRequestor, IProgressMonitor)
 
 	public char[] getKey() {
 		return this.;
 	}
 
 //	/**
 //	 * Returns the package name of the relevant
 //	 * declaration in the context, or <code>null</code> if none.
 //	 * <p>
 //	 * This field is available for the following kinds of
 //	 * completion proposals:
 //	 * <ul>
 //	 * <li><code>ANONYMOUS_CLASS_DECLARATION</code> - the dot-based package name
 //	 * of the type that is being subclassed or implemented</li>
 //	 * 	<li><code>FIELD_REF</code> - the dot-based package name
 //	 * of the type that declares the field that is referenced</li>
 //	 * 	<li><code>METHOD_REF</code> - the dot-based package name
 //	 * of the type that declares the method that is referenced</li>
 //	 * 	<li><code>METHOD_DECLARATION</code> - the dot-based package name
 //	 * of the type that declares the method that is being
 //	 * implemented or overridden</li>
 //	 * </ul>
//	 * For kinds of completion proposals, this method returns
//	 * <code>null</code>. Clients must not modify the array
//	 * returned.
//	 * </p>
//	 *
//	 * @return the dot-based package name, or
//	 * <code>null</code> if none
//	 * @see #getDeclarationSignature()
//	 * @see #getSignature()
//	 *
//	 * @since 3.1
//	 */
//	public char[] getDeclarationPackageName() {
//		return this.declarationPackageName;
//	}
//	/**
//	 * Returns the type name of the relevant
//	 * declaration in the context without the package fragment,
//	 * or <code>null</code> if none.
//	 * <p>
//	 * This field is available for the following kinds of
//	 * completion proposals:
//	 * <ul>
//	 * <li><code>ANONYMOUS_CLASS_DECLARATION</code> - the dot-based type name
//	 * of the type that is being subclassed or implemented</li>
//	 * 	<li><code>FIELD_REF</code> - the dot-based type name
//	 * of the type that declares the field that is referenced
//	 * or an anonymous type instantiation ("new X(){}") if it is an anonymous type</li>
//	 * 	<li><code>METHOD_REF</code> - the dot-based type name
//	 * of the type that declares the method that is referenced
//	 * or an anonymous type instantiation ("new X(){}") if it is an anonymous type</li>
//	 * 	<li><code>METHOD_DECLARATION</code> - the dot-based type name
//	 * of the type that declares the method that is being
//	 * implemented or overridden</li>
//	 * </ul>
//	 * For kinds of completion proposals, this method returns
//	 * <code>null</code>. Clients must not modify the array
//	 * returned.
//	 * </p>
//	 *
//	 * @return the dot-based package name, or
//	 * <code>null</code> if none
//	 * @see #getDeclarationSignature()
//	 * @see #getSignature()
//	 *
//	 * @since 3.1
//	 */
//	public char[] getDeclarationTypeName() {
//		return this.declarationTypeName;
//	}
//	/**
//	 * Returns the package name of the method or type
//	 * relevant in the context, or <code>null</code> if none.
//	 * <p>
//	 * This field is available for the following kinds of
//	 * completion proposals:
//	 * <ul>
//	 * 	<li><code>FIELD_REF</code> - the dot-based package name
//	 * of the referenced field's type</li>
//	 * 	<li><code>LOCAL_VARIABLE_REF</code> - the dot-based package name
//	 * of the referenced local variable's type</li>
//	 * 	<li><code>METHOD_REF</code> -  the dot-based package name
//	 * of the return type of the method that is referenced</li>
//	 * 	<li><code>METHOD_DECLARATION</code> - the dot-based package name
//	 * of the return type of the method that is being implemented
//	 * or overridden</li>
//	 * 	<li><code>PACKAGE_REF</code> - the dot-based package name
//	 * of the package that is referenced</li>
//	 * 	<li><code>TYPE_REF</code> - the dot-based package name
//	 * of the type that is referenced</li>
//	 * 	<li><code>VARIABLE_DECLARATION</code> - the dot-based package name
//	 * of the type of the variable being declared</li>
//	 * </ul>
//	 * For kinds of completion proposals, this method returns
//	 * <code>null</code>. Clients must not modify the array
//	 * returned.
//	 * </p>
//	 *
//	 * @return the package name, or <code>null</code> if none
//	 *
//	 * @see #getDeclarationSignature()
//	 * @see #getSignature()
//	 *
//	 * @since 3.1
//	 */
//	public char[] getPackageName() {
//		return this.packageName;
//	}
//	/**
//	 * Returns the type name without the package fragment of the method or type
//	 * relevant in the context, or <code>null</code> if none.
//	 * <p>
//	 * This field is available for the following kinds of
//	 * completion proposals:
//	 * <ul>
//	 * 	<li><code>FIELD_REF</code> - the dot-based type name
//	 * of the referenced field's type</li>
//	 * 	<li><code>LOCAL_VARIABLE_REF</code> - the dot-based type name
//	 * of the referenced local variable's type</li>
//	 * 	<li><code>METHOD_REF</code> -  the dot-based type name
//	 * of the return type of the method that is referenced</li>
//	 * 	<li><code>METHOD_DECLARATION</code> - the dot-based type name
//	 * of the return type of the method that is being implemented
//	 * or overridden</li>
//	 * 	<li><code>TYPE_REF</code> - the dot-based type name
//	 * of the type that is referenced</li>
//	 * 	<li><code>VARIABLE_DECLARATION</code> - the dot-based package name
//	 * of the type of the variable being declared</li>
//	 * </ul>
//	 * For kinds of completion proposals, this method returns
//	 * <code>null</code>. Clients must not modify the array
//	 * returned.
//	 * </p>
//	 *
//	 * @return the package name, or <code>null</code> if none
//	 *
//	 * @see #getDeclarationSignature()
//	 * @see #getSignature()
//	 *
//	 * @since 3.1
//	 */
//	public char[] getTypeName() {
//		return this.typeName;
//	}
//	/**
//	 * Returns the parameter package names of the method
//	 * relevant in the context, or <code>null</code> if none.
//	 * <p>
//	 * This field is available for the following kinds of
//	 * completion proposals:
//	 * <ul>
//	 * 	<li><code>ANONYMOUS_CLASS_DECLARATION</code> - parameter package names
//	 * of the constructor that is being invoked</li>
//	 * 	<li><code>METHOD_REF</code> - parameter package names
//	 * of the method that is referenced</li>
//	 * 	<li><code>METHOD_DECLARATION</code> - parameter package names
//	 * of the method that is being implemented or overridden</li>
//	 * </ul>
//	 * For kinds of completion proposals, this method returns
//	 * <code>null</code>. Clients must not modify the array
//	 * returned.
//	 * </p>
//	 *
//	 * @return the package name, or <code>null</code> if none
//	 *
//	 * @see #getDeclarationSignature()
//	 * @see #getSignature()
//	 *
//	 * @since 3.1
//	 */
//	public char[][] getParameterPackageNames() {
//		return this.parameterPackageNames;
//	}
//	/**
//	 * Returns the parameter type names without the package fragment of
//	 * the method relevant in the context, or <code>null</code> if none.
//	 * <p>
//	 * This field is available for the following kinds of
//	 * completion proposals:
//	 * <ul>
//	 * 	<li><code>ANONYMOUS_CLASS_DECLARATION</code> - parameter type names
//	 * of the constructor that is being invoked</li>
//	 * 	<li><code>METHOD_REF</code> - parameter type names
//	 * of the method that is referenced</li>
//	 * 	<li><code>METHOD_DECLARATION</code> - parameter type names
//	 * of the method that is being implemented or overridden</li>
//	 * </ul>
//	 * For kinds of completion proposals, this method returns
//	 * <code>null</code>. Clients must not modify the array
//	 * returned.
//	 * </p>
//	 *
//	 * @return the package name, or <code>null</code> if none
//	 *
//	 * @see #getDeclarationSignature()
//	 * @see #getSignature()
//	 *
//	 * @since 3.1
//	 */
//	public char[][] getParameterTypeNames() {
//		return this.parameterTypeNames;
//	}
Sets the signature of the method, field type, member type, relevant in the context, or null if none.

If not set, defaults to none.

The completion engine creates instances of this class and sets its properties; this method is not intended to be used by other clients.

Parameters:
signature the signature, or null if none
	public void setSignature(char[] signature) {
		this. = signature;
	}

Sets the key of the method, field type, member type, relevant in the context, or null if none.

If not set, defaults to none.

The completion engine creates instances of this class and sets its properties; this method is not intended to be used by other clients.

Parameters:
key the key, or null if none
Since:
3.1
	public void setKey(char[] key) {
		this. = key;
	}

Returns the modifier flags relevant in the context, or Flags.AccDefault if none.

This field is available for the following kinds of completion proposals:

  • ANNOTATION_ATTRIBUT_REF - modifier flags of the attribute that is referenced;
  • ANONYMOUS_CLASS_DECLARATION - modifier flags of the constructor that is referenced
  • FIELD_IMPORT - modifier flags of the field that is imported.
  • FIELD_REF - modifier flags of the field that is referenced; Flags.AccEnum can be used to recognize references to enum constants
  • FIELD_REF_WITH_CASTED_RECEIVER - modifier flags of the field that is referenced.
  • KEYWORD - modifier flag corresponding to the modifier keyword
  • LOCAL_VARIABLE_REF - modifier flags of the local variable that is referenced
  • METHOD_IMPORT - modifier flags of the method that is imported;
  • METHOD_REF - modifier flags of the method that is referenced; Flags.AccAnnotation can be used to recognize references to annotation type members
  • METHOD_REF_WITH_CASTED_RECEIVER - modifier flags of the method that is referenced.
  • METHOD_DECLARATION - modifier flags for the method that is being implemented or overridden
  • TYPE_IMPORT - modifier flags of the type that is imported; Flags.AccInterface can be used to recognize references to interfaces, Flags.AccEnum enum types, and Flags.AccAnnotation annotation types
  • TYPE_REF - modifier flags of the type that is referenced; Flags.AccInterface can be used to recognize references to interfaces, Flags.AccEnum enum types, and Flags.AccAnnotation annotation types
  • VARIABLE_DECLARATION - modifier flags for the variable being declared
  • POTENTIAL_METHOD_DECLARATION - modifier flags for the method that is being created
For other kinds of completion proposals, this method returns Flags.AccDefault.

Returns:
the modifier flags, or Flags.AccDefault if none
See also:
Flags
	public int getFlags() {
		return this.;
	}

Sets the modifier flags relevant in the context.

If not set, defaults to none.

The completion engine creates instances of this class and sets its properties; this method is not intended to be used by other clients.

Parameters:
flags the modifier flags, or Flags.AccDefault if none
	public void setFlags(int flags) {
		this. = flags;
	public void setHasNoParameterNamesFromIndex(boolean hasNoParameterNamesFromIndex) {
		this. = hasNoParameterNamesFromIndex;
	}

Returns the required completion proposals. The proposal can be apply only if these required completion proposals are also applied. If the required proposal aren't applied the completion could create completion problems.

This field is available for the following kinds of completion proposals:

  • FIELD_REF - The allowed required proposals for this kind are:
    • TYPE_REF
    • TYPE_IMPORT
    • FIELD_IMPORT
  • METHOD_REF - The allowed required proposals for this kind are:
    • TYPE_REF
    • TYPE_IMPORT
    • METHOD_IMPORT
  • TYPE_REF - The allowed required proposals for this kind are:
    • TYPE_REF

Other kinds of required proposals will be returned in the future, therefore clients of this API must allow with CompletionRequestor.setAllowsRequiredProposals(int, int, boolean) only kinds which are in this list to avoid unexpected results in the future.

A required proposal of a given kind is proposed even if CompletionRequestor.isIgnored(int) return true for that kind.

A required completion proposal cannot have required completion proposals.

Returns:
the required completion proposals, or null if none.
Since:
3.3
See also:
CompletionRequestor.setAllowsRequiredProposals(int, int,boolean)
		return this.;
	}


Sets the list of required completion proposals, or null if none.

If not set, defaults to none.

The completion engine creates instances of this class and sets its properties; this method is not intended to be used by other clients.

Parameters:
proposals the list of required completion proposals, or null if none
Since:
3.3
	public void setRequiredProposals(CompletionProposal[] proposals) {
		this. = proposals;
	}

Finds the method parameter names. This information is relevant to method reference (and method declaration proposals). Returns null if not available or not relevant.

The client must not modify the array returned.

Note that this is an expensive thing to compute, which may require parsing Java source files, etc. Use sparingly.

Parameters:
monitor the progress monitor, or null if none
Returns:
the parameter names, or null if none or not available or not relevant
	public char[][] findParameterNames(IProgressMonitor monitor) {
			switch(this.) {
					try {
								CharOperation.lastSegment(this.'.'),
								Signature.getParameterTypes(this. == null ? this. : this.));
						// protection for invalid signature
						if(this. != null) {
							this. =  CompletionEngine.createDefaultParameterNames(this..length);
else {
							this. = null;
					break;
					try {
								CharOperation.lastSegment(this.'.'),
								Signature.getParameterTypes(this. == null ? this. : this.));
						// protection for invalid signature
						if(this. != null) {
							this. =  CompletionEngine.createDefaultParameterNames(this..length);
else {
							this. = null;
					break;
					try {
								this.,
								Signature.getParameterTypes(this. == null ? this. : this.));
						// protection for invalid signature
						if(this. != null) {
							this. =  CompletionEngine.createDefaultParameterNames(this..length);
else {
							this. = null;
					break;
					try {
								this.,
								Signature.getParameterTypes(this. == null ? this. : this.));
						// protection for invalid signature
						if(this. != null) {
							this. =  CompletionEngine.createDefaultParameterNames(this..length);
else {
							this. = null;
					break;
					try {
								this.,
								Signature.getParameterTypes(this. == null ? this. : this.));
						// protection for invalid signature
						if(this. != null) {
							this. =  CompletionEngine.createDefaultParameterNames(this..length);
else {
							this. = null;
					if(this. != null) {
						this. = true;
					break;
		return this.;
	}

Sets the method parameter names. This information is relevant to method reference (and method declaration proposals).

The completion engine creates instances of this class and sets its properties; this method is not intended to be used by other clients.

Parameters:
parameterNames the parameter names, or null if none
	public void setParameterNames(char[][] parameterNames) {
		this. = parameterNames;
	}

Returns the accessibility of the proposal.

This field is available for the following kinds of completion proposals:

  • TYPE_REF - accessibility of the type
For these kinds of completion proposals, this method returns IAccessRule.K_ACCESSIBLE or IAccessRule.K_DISCOURAGED or IAccessRule.K_NON_ACCESSIBLE. By default this method return IAccessRule.K_ACCESSIBLE.

Returns:
the accessibility of the proposal
Since:
3.1
See also:
IAccessRule
	public int getAccessibility() {
		return this.;
	}

Returns whether this proposal is a constructor.

This field is available for the following kinds of completion proposals:

  • METHOD_REF - return true if the referenced method is a constructor
  • METHOD_DECLARATION - return true if the declared method is a constructor
For kinds of completion proposals, this method returns false.

Returns:
true if the proposal is a constructor.
Since:
3.1
	public boolean isConstructor() {
		return this.;
	private int receiverStart;
	private int receiverEnd;
	private char[] receiverSignature;

Returns the type signature or package name of the relevant receiver in the context, or null if none.

This field is available for the following kinds of completion proposals:

  • FIELD_REF_WITH_CASTED_RECEIVER - type signature of the type that cast the receiver of the field that is referenced
  • METHOD_REF_WITH_CASTED_RECEIVER - type signature of the type that cast the receiver of the method that is referenced
For kinds of completion proposals, this method returns null. Clients must not modify the array returned.

Returns:
a type signature or a package name (depending on the kind of completion), or null if none
Since:
3.4
See also:
Signature
	public char[] getReceiverSignature() {
		return this.;
	}

Returns the character index of the start of the subrange in the source file buffer containing the relevant receiver of the member being completed. This receiver is an expression.

This field is available for the following kinds of completion proposals:

  • FIELD_REF_WITH_CASTED_RECEIVER
  • METHOD_REF_WITH_CASTED_RECEIVER
For kinds of completion proposals, this method returns 0.

Returns:
character index of receiver start position (inclusive)
Since:
3.4
	public int getReceiverStart() {
		return this.;
	}

Returns the character index of the end (exclusive) of the subrange in the source file buffer containing the relevant receiver of the member being completed. *

This field is available for the following kinds of completion proposals:

  • FIELD_REF_WITH_CASTED_RECEIVER
  • METHOD_REF_WITH_CASTED_RECEIVER
For kinds of completion proposals, this method returns 0.

Returns:
character index of receiver end position (exclusive)
Since:
3.4
	public int getReceiverEnd() {
		return this.;
	}

Sets the type or package signature of the relevant receiver in the context, or null if none.

If not set, defaults to none.

The completion engine creates instances of this class and sets its properties; this method is not intended to be used by other clients.

Parameters:
signature the type or package signature, or null if none
Since:
3.4
	public void setReceiverSignature(char[] signature) {
		this. = signature;
	}

Sets the character indices of the subrange in the source file buffer containing the relevant receiver of the member being completed.

If not set, defaults to empty subrange at [0,0).

Parameters:
startIndex character index of receiver start position (inclusive)
endIndex character index of receiver end position (exclusive)
Since:
3.4
	public void setReceiverRange(int startIndexint endIndex) {
		this. = startIndex;
		this. = endIndex;
	public String toString() {
		StringBuffer buffer = new StringBuffer();
		buffer.append('[');
		switch(this.) {
				buffer.append("ANONYMOUS_CLASS_DECLARATION"); //$NON-NLS-1$
				break;
				buffer.append("FIELD_REF"); //$NON-NLS-1$
				break;
				buffer.append("KEYWORD"); //$NON-NLS-1$
				break;
				buffer.append("LABEL_REF"); //$NON-NLS-1$
				break;
				buffer.append("LOCAL_VARIABLE_REF"); //$NON-NLS-1$
				break;
				buffer.append("METHOD_DECLARATION"); //$NON-NLS-1$
				if(this.) {
					buffer.append("<CONSTRUCTOR>"); //$NON-NLS-1$
				break;
				buffer.append("METHOD_REF"); //$NON-NLS-1$
				if(this.) {
					buffer.append("<CONSTRUCTOR>"); //$NON-NLS-1$
				break;
				buffer.append("PACKAGE_REF"); //$NON-NLS-1$
				break;
				buffer.append("TYPE_REF"); //$NON-NLS-1$
				break;
				buffer.append("VARIABLE_DECLARATION"); //$NON-NLS-1$
				break;
				buffer.append("POTENTIAL_METHOD_DECLARATION"); //$NON-NLS-1$
				break;
				buffer.append("METHOD_IMPORT"); //$NON-NLS-1$
				break;
				buffer.append("ANNOTATION_ATTRIBUTE_REF"); //$NON-NLS-1$
				break;
				buffer.append("JAVADOC_BLOCK_TAG"); //$NON-NLS-1$
				break;
				buffer.append("JAVADOC_INLINE_TAG"); //$NON-NLS-1$
				break;
				buffer.append("JAVADOC_FIELD_REF"); //$NON-NLS-1$
				break;
				buffer.append("JAVADOC_METHOD_REF"); //$NON-NLS-1$
				break;
				buffer.append("JAVADOC_TYPE_REF"); //$NON-NLS-1$
				break;
				buffer.append("JAVADOC_PARAM_REF"); //$NON-NLS-1$
				break;
				buffer.append("JAVADOC_VALUE_REF"); //$NON-NLS-1$
				break;
				buffer.append("FIELD_IMPORT"); //$NON-NLS-1$
				break;
				buffer.append("METHOD_IMPORT"); //$NON-NLS-1$
				break;
				buffer.append("TYPE_IMPORT"); //$NON-NLS-1$
				break;
				buffer.append("METHOD_REF_WITH_CASTED_RECEIVER"); //$NON-NLS-1$
				break;
				buffer.append("FIELD_REF_WITH_CASTED_RECEIVER"); //$NON-NLS-1$
				break;
				buffer.append("CONSTRUCTOR_INVOCATION"); //$NON-NLS-1$
				break;
				buffer.append("ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION"); //$NON-NLS-1$
				break;
			default :
				buffer.append("PROPOSAL"); //$NON-NLS-1$
				break;
		buffer.append("]{completion:"); //$NON-NLS-1$
		if (this. != nullbuffer.append(this.);
		buffer.append(", declSign:"); //$NON-NLS-1$
		if (this. != nullbuffer.append(this.);
		buffer.append(", sign:"); //$NON-NLS-1$
		if (this. != nullbuffer.append(this.);
		buffer.append(", declKey:"); //$NON-NLS-1$
		if (this. != nullbuffer.append(this.);
		buffer.append(", key:"); //$NON-NLS-1$
		if (this. != nullbuffer.append(this.);
		buffer.append(", name:"); //$NON-NLS-1$
		if (this. != nullbuffer.append(this.);
		buffer.append(", replace:["); //$NON-NLS-1$
		buffer.append(this.);
		buffer.append(',');
		buffer.append(this.);
		buffer.append("], token:["); //$NON-NLS-1$
		buffer.append(this.);
		buffer.append(',');
		buffer.append(this.);
		buffer.append("], relevance:"); //$NON-NLS-1$
		buffer.append(this.);
		buffer.append('}');
		return buffer.toString();
	public boolean canUseDiamond(CompletionContext coreContext) {
		if (this.getKind() != return false;
		if (coreContext instanceof InternalCompletionContext) {
			InternalCompletionContext internalCompletionContext = (InternalCompletionContextcoreContext;
			if (internalCompletionContext.extendedContext == nullreturn false;
			char[] name1 = this.;
			char[] name2 = this.;
			char[] declarationType = CharOperation.concat(name1name2'.');  // fully qualified name
			// even if the type arguments used in the method have been substituted,
			// extract the original type arguments only, since thats what we want to compare with the class
			// type variables (Substitution might have happened when the constructor is coming from another
			// CU and not the current one).
			char[] sign = (this. != null)? this. : getSignature();
			if (!(sign == null || sign.length < 2)) {
				sign = Signature.removeCapture(sign);
			char[][] types= Signature.getParameterTypes(sign);
			String[] paramTypeNamesnew String[types.length];
			for (int i= 0; i < types.lengthi++) {
				paramTypeNames[i]= new String(Signature.toCharArray(types[i]));
			return internalCompletionContext.extendedContext.canUseDiamond(paramTypeNames,declarationType);
		else {
			return false;